@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,39 @@
|
|
|
1
|
+
// src/core/simpleAdapter.ts
|
|
2
|
+
var SimpleAdapter = class {
|
|
3
|
+
historyConverter;
|
|
4
|
+
agentName = "";
|
|
5
|
+
agentDescription = "";
|
|
6
|
+
constructor(options) {
|
|
7
|
+
this.historyConverter = options?.historyConverter;
|
|
8
|
+
}
|
|
9
|
+
async onCleanup(_roomId) {
|
|
10
|
+
}
|
|
11
|
+
async onStarted(agentName, agentDescription) {
|
|
12
|
+
this.agentName = agentName;
|
|
13
|
+
this.agentDescription = agentDescription;
|
|
14
|
+
}
|
|
15
|
+
async onEvent(input) {
|
|
16
|
+
const history = this.convertHistory(input.history);
|
|
17
|
+
await this.onMessage(
|
|
18
|
+
input.message,
|
|
19
|
+
input.tools,
|
|
20
|
+
history,
|
|
21
|
+
input.participantsMessage,
|
|
22
|
+
input.contactsMessage,
|
|
23
|
+
{
|
|
24
|
+
isSessionBootstrap: input.isSessionBootstrap,
|
|
25
|
+
roomId: input.roomId
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
convertHistory(provider) {
|
|
30
|
+
if (!this.historyConverter) {
|
|
31
|
+
return provider;
|
|
32
|
+
}
|
|
33
|
+
return provider.convert(this.historyConverter);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
SimpleAdapter
|
|
39
|
+
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BASE_TOOL_NAMES,
|
|
3
|
+
CONTACT_TOOL_NAMES,
|
|
4
|
+
MEMORY_TOOL_NAMES,
|
|
5
|
+
TOOL_MODELS,
|
|
6
|
+
getToolDescription
|
|
7
|
+
} from "./chunk-GVEQ3RAH.js";
|
|
8
|
+
import {
|
|
9
|
+
isToolExecutorError,
|
|
10
|
+
toLegacyToolExecutorErrorMessage
|
|
11
|
+
} from "./chunk-3BKAC4OZ.js";
|
|
12
|
+
|
|
13
|
+
// src/mcp/registrations.ts
|
|
14
|
+
function buildRoomScopedRegistrations(resolver, options = {}) {
|
|
15
|
+
const toolNames = resolveToolNames(options);
|
|
16
|
+
const registrations = buildRegistrations(toolNames, async (toolName, args) => {
|
|
17
|
+
const roomId = asNonEmptyString(args.room_id);
|
|
18
|
+
if (!roomId) {
|
|
19
|
+
return errorResult("Missing required room_id");
|
|
20
|
+
}
|
|
21
|
+
const tools = resolver(roomId);
|
|
22
|
+
if (!tools) {
|
|
23
|
+
return errorResult(`No tool context found for room_id ${roomId}`);
|
|
24
|
+
}
|
|
25
|
+
const toolArgs = { ...args };
|
|
26
|
+
delete toolArgs.room_id;
|
|
27
|
+
return executeToolCall(tools, toolName, toolArgs);
|
|
28
|
+
}, { injectRoomId: true });
|
|
29
|
+
if (options.additionalTools) {
|
|
30
|
+
registrations.push(...options.additionalTools);
|
|
31
|
+
}
|
|
32
|
+
return registrations;
|
|
33
|
+
}
|
|
34
|
+
function buildSingleContextRegistrations(tools, options = {}) {
|
|
35
|
+
const toolNames = resolveToolNames(options);
|
|
36
|
+
const registrations = buildRegistrations(toolNames, (_toolName, args) => {
|
|
37
|
+
return executeToolCall(tools, _toolName, args);
|
|
38
|
+
}, { injectRoomId: false });
|
|
39
|
+
if (options.additionalTools) {
|
|
40
|
+
registrations.push(...options.additionalTools);
|
|
41
|
+
}
|
|
42
|
+
return registrations;
|
|
43
|
+
}
|
|
44
|
+
function resolveToolNames(options) {
|
|
45
|
+
const names = /* @__PURE__ */ new Set();
|
|
46
|
+
for (const name of BASE_TOOL_NAMES) {
|
|
47
|
+
if (!options.enableContactTools && CONTACT_TOOL_NAMES.has(name)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
names.add(name);
|
|
51
|
+
}
|
|
52
|
+
if (options.enableMemoryTools) {
|
|
53
|
+
for (const name of MEMORY_TOOL_NAMES) {
|
|
54
|
+
names.add(name);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return names;
|
|
58
|
+
}
|
|
59
|
+
function buildRegistrations(toolNames, executor, opts) {
|
|
60
|
+
const registrations = [];
|
|
61
|
+
for (const toolName of toolNames) {
|
|
62
|
+
const model = TOOL_MODELS[toolName];
|
|
63
|
+
if (!model) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const properties = { ...model.properties };
|
|
67
|
+
const required = [...model.required];
|
|
68
|
+
if (opts.injectRoomId) {
|
|
69
|
+
properties.room_id = { type: "string", description: "The room ID to execute this tool in" };
|
|
70
|
+
required.push("room_id");
|
|
71
|
+
}
|
|
72
|
+
registrations.push({
|
|
73
|
+
name: toolName,
|
|
74
|
+
description: getToolDescription(toolName),
|
|
75
|
+
inputSchema: {
|
|
76
|
+
type: "object",
|
|
77
|
+
properties,
|
|
78
|
+
required
|
|
79
|
+
},
|
|
80
|
+
execute: (args) => executor(toolName, args)
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return registrations;
|
|
84
|
+
}
|
|
85
|
+
async function executeToolCall(tools, toolName, args) {
|
|
86
|
+
try {
|
|
87
|
+
const result = await tools.executeToolCall(toolName, args);
|
|
88
|
+
if (isToolExecutorError(result)) {
|
|
89
|
+
return errorResult(toLegacyToolExecutorErrorMessage(result) ?? result.message);
|
|
90
|
+
}
|
|
91
|
+
return successResult(result);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
return errorResult(error instanceof Error ? error.message : String(error));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function asNonEmptyString(value) {
|
|
97
|
+
if (typeof value !== "string") {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const trimmed = value.trim();
|
|
101
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
102
|
+
}
|
|
103
|
+
function successResult(value) {
|
|
104
|
+
return {
|
|
105
|
+
content: [{
|
|
106
|
+
type: "text",
|
|
107
|
+
text: serializeValue(value)
|
|
108
|
+
}]
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function errorResult(message) {
|
|
112
|
+
return {
|
|
113
|
+
content: [{ type: "text", text: message }],
|
|
114
|
+
isError: true
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function serializeValue(value) {
|
|
118
|
+
if (value === void 0 || value === null) {
|
|
119
|
+
return "";
|
|
120
|
+
}
|
|
121
|
+
if (typeof value === "string") {
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const json = JSON.stringify(value);
|
|
126
|
+
return typeof json === "string" ? json : String(value);
|
|
127
|
+
} catch {
|
|
128
|
+
return String(value);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/mcp/zod.ts
|
|
133
|
+
function buildZodShape(z, properties, required) {
|
|
134
|
+
const shape = {};
|
|
135
|
+
for (const [name, schema] of Object.entries(properties)) {
|
|
136
|
+
const validator = jsonSchemaToZod(z, schema);
|
|
137
|
+
shape[name] = required.has(name) ? validator : validator.optional();
|
|
138
|
+
}
|
|
139
|
+
return shape;
|
|
140
|
+
}
|
|
141
|
+
function jsonSchemaToZod(z, schema) {
|
|
142
|
+
const type = schema.type;
|
|
143
|
+
if (type === "string") {
|
|
144
|
+
if (Array.isArray(schema.enum) && schema.enum.every((v) => typeof v === "string")) {
|
|
145
|
+
const values = schema.enum;
|
|
146
|
+
if (values.length > 0) {
|
|
147
|
+
return z.enum(values);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return z.string();
|
|
151
|
+
}
|
|
152
|
+
if (type === "integer" || type === "number") {
|
|
153
|
+
return z.number();
|
|
154
|
+
}
|
|
155
|
+
if (type === "boolean") {
|
|
156
|
+
return z.boolean();
|
|
157
|
+
}
|
|
158
|
+
if (type === "array") {
|
|
159
|
+
const itemSchema = schema.items;
|
|
160
|
+
if (itemSchema && typeof itemSchema === "object") {
|
|
161
|
+
return z.array(jsonSchemaToZod(z, itemSchema));
|
|
162
|
+
}
|
|
163
|
+
return z.array(z.unknown());
|
|
164
|
+
}
|
|
165
|
+
if (type === "object") {
|
|
166
|
+
return z.record(z.string(), z.unknown());
|
|
167
|
+
}
|
|
168
|
+
return z.unknown();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export {
|
|
172
|
+
buildRoomScopedRegistrations,
|
|
173
|
+
buildSingleContextRegistrations,
|
|
174
|
+
successResult,
|
|
175
|
+
errorResult,
|
|
176
|
+
buildZodShape
|
|
177
|
+
};
|