swarmlord 0.1.2 → 0.1.3
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 +1 -1
- package/dist/index.cjs +19 -8
- package/dist/index.d.cts +9 -6
- package/dist/index.d.mts +9 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.mjs +19 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ for await (const event of session.stream("Add tests")) {
|
|
|
82
82
|
await session.summarize(); // trigger context compaction
|
|
83
83
|
await session.revert(messageId); // undo to a specific message
|
|
84
84
|
await session.abort(); // cancel current turn
|
|
85
|
-
await session.
|
|
85
|
+
await session.end(); // clean up
|
|
86
86
|
|
|
87
87
|
// Direct sandbox access
|
|
88
88
|
const shellResult = await session.shell("npm test");
|
package/dist/index.cjs
CHANGED
|
@@ -103,6 +103,7 @@ function createSessionHandle(id, opts, agentConfig) {
|
|
|
103
103
|
content: input,
|
|
104
104
|
agent: agentConfig?.name,
|
|
105
105
|
model: agentConfig?.model,
|
|
106
|
+
tools: agentConfig?.tools,
|
|
106
107
|
config: agentConfig?.config
|
|
107
108
|
};
|
|
108
109
|
}
|
|
@@ -110,6 +111,7 @@ function createSessionHandle(id, opts, agentConfig) {
|
|
|
110
111
|
parts: input.parts,
|
|
111
112
|
agent: input.agent ?? agentConfig?.name,
|
|
112
113
|
model: input.model ?? agentConfig?.model,
|
|
114
|
+
tools: input.tools ?? agentConfig?.tools,
|
|
113
115
|
config: input.config ?? agentConfig?.config
|
|
114
116
|
};
|
|
115
117
|
}
|
|
@@ -273,9 +275,13 @@ function createSessionHandle(id, opts, agentConfig) {
|
|
|
273
275
|
});
|
|
274
276
|
if (!res.ok) throw new Error(`Failed to get file: ${res.status}`);
|
|
275
277
|
const b64 = await res.text();
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
278
|
+
if (typeof Buffer !== "undefined") {
|
|
279
|
+
const decoded = Buffer.from(b64, "base64");
|
|
280
|
+
return decoded.buffer.slice(decoded.byteOffset, decoded.byteOffset + decoded.byteLength);
|
|
281
|
+
}
|
|
282
|
+
const raw = atob(b64);
|
|
283
|
+
const bytes = new Uint8Array(raw.length);
|
|
284
|
+
for (let i = 0; i < raw.length; i++) bytes[i] = raw.charCodeAt(i);
|
|
279
285
|
return bytes.buffer;
|
|
280
286
|
},
|
|
281
287
|
async getArtifact(key) {
|
|
@@ -300,9 +306,9 @@ function createSessionHandle(id, opts, agentConfig) {
|
|
|
300
306
|
});
|
|
301
307
|
if (!res.ok) throw new Error(`Failed to update session: ${res.status}`);
|
|
302
308
|
},
|
|
303
|
-
async
|
|
309
|
+
async end() {
|
|
304
310
|
const res = await fetch(`${baseUrl}/session/${id}`, { method: "DELETE", headers: headers() });
|
|
305
|
-
if (!res.ok) throw new Error(`Failed to
|
|
311
|
+
if (!res.ok) throw new Error(`Failed to end session: ${res.status}`);
|
|
306
312
|
},
|
|
307
313
|
async runCommand(name, args) {
|
|
308
314
|
const res = await fetch(`${baseUrl}/session/${id}/command`, {
|
|
@@ -571,6 +577,7 @@ function createAgentHandle(clientOpts, config) {
|
|
|
571
577
|
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
572
578
|
body: JSON.stringify({
|
|
573
579
|
title: sessionOpts?.title,
|
|
580
|
+
tools: config.tools,
|
|
574
581
|
config: config.config,
|
|
575
582
|
webhook: sessionOpts?.webhook
|
|
576
583
|
})
|
|
@@ -605,10 +612,14 @@ function createAgentHandle(clientOpts, config) {
|
|
|
605
612
|
|
|
606
613
|
const DEFAULT_BASE_URL = "https://api.swarmlord.ai";
|
|
607
614
|
function createClient(opts) {
|
|
608
|
-
const
|
|
609
|
-
|
|
615
|
+
const apiKey = opts?.apiKey ?? (typeof process !== "undefined" ? process.env.SWARMLORD_API_KEY : void 0);
|
|
616
|
+
if (!apiKey) {
|
|
617
|
+
throw new Error("Missing API key. Pass it to createClient({ apiKey: '...' }) or set SWARMLORD_API_KEY.");
|
|
618
|
+
}
|
|
619
|
+
const baseUrl = (opts?.baseUrl ?? (typeof process !== "undefined" ? process.env.SWARMLORD_URL : void 0) ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
620
|
+
const normalizedOpts = { apiKey, baseUrl };
|
|
610
621
|
function headers() {
|
|
611
|
-
return { Authorization: `Bearer ${
|
|
622
|
+
return { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" };
|
|
612
623
|
}
|
|
613
624
|
return {
|
|
614
625
|
agent(nameOrConfig) {
|
package/dist/index.d.cts
CHANGED
|
@@ -3,12 +3,15 @@ interface ClientOptions {
|
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
}
|
|
5
5
|
type AgentName = "build" | "plan" | "explore" | "general" | (string & {});
|
|
6
|
+
type ToolName = "bash" | "read" | "write" | "edit" | "grep" | "glob" | "task" | "todoread" | "todowrite" | "websearch" | "webfetch" | "browser" | "batch" | (string & {});
|
|
7
|
+
type ToolsConfig = Partial<Record<ToolName, boolean>>;
|
|
6
8
|
interface AgentConfig {
|
|
7
9
|
name?: AgentName;
|
|
8
10
|
model?: string;
|
|
9
11
|
instructions?: string[];
|
|
10
12
|
permission?: PermissionConfig;
|
|
11
13
|
temperature?: number;
|
|
14
|
+
tools?: ToolsConfig;
|
|
12
15
|
config?: Config;
|
|
13
16
|
}
|
|
14
17
|
type PermissionConfig = string | Record<string, string | Record<string, string>>;
|
|
@@ -18,6 +21,7 @@ interface Config {
|
|
|
18
21
|
default_agent?: string;
|
|
19
22
|
instructions?: string[];
|
|
20
23
|
permission?: PermissionConfig;
|
|
24
|
+
tools?: ToolsConfig;
|
|
21
25
|
command?: Record<string, {
|
|
22
26
|
template: string;
|
|
23
27
|
description?: string;
|
|
@@ -253,6 +257,7 @@ type MessageInput = {
|
|
|
253
257
|
parts: Array<TextInput | FileInput>;
|
|
254
258
|
agent?: string;
|
|
255
259
|
model?: string;
|
|
260
|
+
tools?: ToolsConfig;
|
|
256
261
|
config?: Config;
|
|
257
262
|
};
|
|
258
263
|
interface SendResult {
|
|
@@ -482,7 +487,7 @@ interface SessionHandle {
|
|
|
482
487
|
title?: string;
|
|
483
488
|
archived?: boolean;
|
|
484
489
|
}): Promise<void>;
|
|
485
|
-
|
|
490
|
+
end(): Promise<void>;
|
|
486
491
|
runCommand(name: string, args?: Record<string, string>): Promise<string>;
|
|
487
492
|
replyToPermission(requestId: string, reply: "once" | "always" | "reject", message?: string): Promise<void>;
|
|
488
493
|
events(lastEventId?: number): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -606,10 +611,8 @@ interface SwarmlordClient {
|
|
|
606
611
|
data: ProviderModel[];
|
|
607
612
|
}>;
|
|
608
613
|
}
|
|
609
|
-
type CreateClientOptions =
|
|
610
|
-
|
|
611
|
-
};
|
|
612
|
-
declare function createClient(opts: CreateClientOptions): SwarmlordClient;
|
|
614
|
+
type CreateClientOptions = Partial<ClientOptions>;
|
|
615
|
+
declare function createClient(opts?: CreateClientOptions): SwarmlordClient;
|
|
613
616
|
|
|
614
617
|
export { createClient };
|
|
615
|
-
export type { AgentConfig, AgentEvent, AgentHandle, AgentName, AgentPart, AssistantMessageInfo, ClientOptions, CompactionPart, Config, CreateClientOptions, CreateScheduleOpts, CreateTriggerOpts, FileInput, FilePart, MessageInfo, MessageInput, MessagePart, OutputConfig, Part, PermissionConfig, PermissionReply, PermissionRequest, ProviderModel, ReasoningPart, RetryPart, ScheduleHandle, ScheduleInfo, SendResult, SessionHandle, SessionInfo, SessionMetrics, SessionStatus, ShellResult, StepFinishPart, StepStartPart, StreamCallbacks, SubtaskPart, SwarmlordClient, TaskHandle, TaskResult, TaskStatus, TextInput, TextPart, TodoItem, Tokens, ToolPart, ToolState, ToolStateCompleted, ToolStateError, ToolStatePending, ToolStateRunning, TriggerHandle, TriggerInfo, TriggerProviderName, UpdateScheduleOpts, UpdateTriggerOpts, UserMessageInfo, WithParts };
|
|
618
|
+
export type { AgentConfig, AgentEvent, AgentHandle, AgentName, AgentPart, AssistantMessageInfo, ClientOptions, CompactionPart, Config, CreateClientOptions, CreateScheduleOpts, CreateTriggerOpts, FileInput, FilePart, MessageInfo, MessageInput, MessagePart, OutputConfig, Part, PermissionConfig, PermissionReply, PermissionRequest, ProviderModel, ReasoningPart, RetryPart, ScheduleHandle, ScheduleInfo, SendResult, SessionHandle, SessionInfo, SessionMetrics, SessionStatus, ShellResult, StepFinishPart, StepStartPart, StreamCallbacks, SubtaskPart, SwarmlordClient, TaskHandle, TaskResult, TaskStatus, TextInput, TextPart, TodoItem, Tokens, ToolName, ToolPart, ToolState, ToolStateCompleted, ToolStateError, ToolStatePending, ToolStateRunning, ToolsConfig, TriggerHandle, TriggerInfo, TriggerProviderName, UpdateScheduleOpts, UpdateTriggerOpts, UserMessageInfo, WithParts };
|
package/dist/index.d.mts
CHANGED
|
@@ -3,12 +3,15 @@ interface ClientOptions {
|
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
}
|
|
5
5
|
type AgentName = "build" | "plan" | "explore" | "general" | (string & {});
|
|
6
|
+
type ToolName = "bash" | "read" | "write" | "edit" | "grep" | "glob" | "task" | "todoread" | "todowrite" | "websearch" | "webfetch" | "browser" | "batch" | (string & {});
|
|
7
|
+
type ToolsConfig = Partial<Record<ToolName, boolean>>;
|
|
6
8
|
interface AgentConfig {
|
|
7
9
|
name?: AgentName;
|
|
8
10
|
model?: string;
|
|
9
11
|
instructions?: string[];
|
|
10
12
|
permission?: PermissionConfig;
|
|
11
13
|
temperature?: number;
|
|
14
|
+
tools?: ToolsConfig;
|
|
12
15
|
config?: Config;
|
|
13
16
|
}
|
|
14
17
|
type PermissionConfig = string | Record<string, string | Record<string, string>>;
|
|
@@ -18,6 +21,7 @@ interface Config {
|
|
|
18
21
|
default_agent?: string;
|
|
19
22
|
instructions?: string[];
|
|
20
23
|
permission?: PermissionConfig;
|
|
24
|
+
tools?: ToolsConfig;
|
|
21
25
|
command?: Record<string, {
|
|
22
26
|
template: string;
|
|
23
27
|
description?: string;
|
|
@@ -253,6 +257,7 @@ type MessageInput = {
|
|
|
253
257
|
parts: Array<TextInput | FileInput>;
|
|
254
258
|
agent?: string;
|
|
255
259
|
model?: string;
|
|
260
|
+
tools?: ToolsConfig;
|
|
256
261
|
config?: Config;
|
|
257
262
|
};
|
|
258
263
|
interface SendResult {
|
|
@@ -482,7 +487,7 @@ interface SessionHandle {
|
|
|
482
487
|
title?: string;
|
|
483
488
|
archived?: boolean;
|
|
484
489
|
}): Promise<void>;
|
|
485
|
-
|
|
490
|
+
end(): Promise<void>;
|
|
486
491
|
runCommand(name: string, args?: Record<string, string>): Promise<string>;
|
|
487
492
|
replyToPermission(requestId: string, reply: "once" | "always" | "reject", message?: string): Promise<void>;
|
|
488
493
|
events(lastEventId?: number): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -606,10 +611,8 @@ interface SwarmlordClient {
|
|
|
606
611
|
data: ProviderModel[];
|
|
607
612
|
}>;
|
|
608
613
|
}
|
|
609
|
-
type CreateClientOptions =
|
|
610
|
-
|
|
611
|
-
};
|
|
612
|
-
declare function createClient(opts: CreateClientOptions): SwarmlordClient;
|
|
614
|
+
type CreateClientOptions = Partial<ClientOptions>;
|
|
615
|
+
declare function createClient(opts?: CreateClientOptions): SwarmlordClient;
|
|
613
616
|
|
|
614
617
|
export { createClient };
|
|
615
|
-
export type { AgentConfig, AgentEvent, AgentHandle, AgentName, AgentPart, AssistantMessageInfo, ClientOptions, CompactionPart, Config, CreateClientOptions, CreateScheduleOpts, CreateTriggerOpts, FileInput, FilePart, MessageInfo, MessageInput, MessagePart, OutputConfig, Part, PermissionConfig, PermissionReply, PermissionRequest, ProviderModel, ReasoningPart, RetryPart, ScheduleHandle, ScheduleInfo, SendResult, SessionHandle, SessionInfo, SessionMetrics, SessionStatus, ShellResult, StepFinishPart, StepStartPart, StreamCallbacks, SubtaskPart, SwarmlordClient, TaskHandle, TaskResult, TaskStatus, TextInput, TextPart, TodoItem, Tokens, ToolPart, ToolState, ToolStateCompleted, ToolStateError, ToolStatePending, ToolStateRunning, TriggerHandle, TriggerInfo, TriggerProviderName, UpdateScheduleOpts, UpdateTriggerOpts, UserMessageInfo, WithParts };
|
|
618
|
+
export type { AgentConfig, AgentEvent, AgentHandle, AgentName, AgentPart, AssistantMessageInfo, ClientOptions, CompactionPart, Config, CreateClientOptions, CreateScheduleOpts, CreateTriggerOpts, FileInput, FilePart, MessageInfo, MessageInput, MessagePart, OutputConfig, Part, PermissionConfig, PermissionReply, PermissionRequest, ProviderModel, ReasoningPart, RetryPart, ScheduleHandle, ScheduleInfo, SendResult, SessionHandle, SessionInfo, SessionMetrics, SessionStatus, ShellResult, StepFinishPart, StepStartPart, StreamCallbacks, SubtaskPart, SwarmlordClient, TaskHandle, TaskResult, TaskStatus, TextInput, TextPart, TodoItem, Tokens, ToolName, ToolPart, ToolState, ToolStateCompleted, ToolStateError, ToolStatePending, ToolStateRunning, ToolsConfig, TriggerHandle, TriggerInfo, TriggerProviderName, UpdateScheduleOpts, UpdateTriggerOpts, UserMessageInfo, WithParts };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,15 @@ interface ClientOptions {
|
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
}
|
|
5
5
|
type AgentName = "build" | "plan" | "explore" | "general" | (string & {});
|
|
6
|
+
type ToolName = "bash" | "read" | "write" | "edit" | "grep" | "glob" | "task" | "todoread" | "todowrite" | "websearch" | "webfetch" | "browser" | "batch" | (string & {});
|
|
7
|
+
type ToolsConfig = Partial<Record<ToolName, boolean>>;
|
|
6
8
|
interface AgentConfig {
|
|
7
9
|
name?: AgentName;
|
|
8
10
|
model?: string;
|
|
9
11
|
instructions?: string[];
|
|
10
12
|
permission?: PermissionConfig;
|
|
11
13
|
temperature?: number;
|
|
14
|
+
tools?: ToolsConfig;
|
|
12
15
|
config?: Config;
|
|
13
16
|
}
|
|
14
17
|
type PermissionConfig = string | Record<string, string | Record<string, string>>;
|
|
@@ -18,6 +21,7 @@ interface Config {
|
|
|
18
21
|
default_agent?: string;
|
|
19
22
|
instructions?: string[];
|
|
20
23
|
permission?: PermissionConfig;
|
|
24
|
+
tools?: ToolsConfig;
|
|
21
25
|
command?: Record<string, {
|
|
22
26
|
template: string;
|
|
23
27
|
description?: string;
|
|
@@ -253,6 +257,7 @@ type MessageInput = {
|
|
|
253
257
|
parts: Array<TextInput | FileInput>;
|
|
254
258
|
agent?: string;
|
|
255
259
|
model?: string;
|
|
260
|
+
tools?: ToolsConfig;
|
|
256
261
|
config?: Config;
|
|
257
262
|
};
|
|
258
263
|
interface SendResult {
|
|
@@ -482,7 +487,7 @@ interface SessionHandle {
|
|
|
482
487
|
title?: string;
|
|
483
488
|
archived?: boolean;
|
|
484
489
|
}): Promise<void>;
|
|
485
|
-
|
|
490
|
+
end(): Promise<void>;
|
|
486
491
|
runCommand(name: string, args?: Record<string, string>): Promise<string>;
|
|
487
492
|
replyToPermission(requestId: string, reply: "once" | "always" | "reject", message?: string): Promise<void>;
|
|
488
493
|
events(lastEventId?: number): Promise<ReadableStream<Uint8Array>>;
|
|
@@ -606,10 +611,8 @@ interface SwarmlordClient {
|
|
|
606
611
|
data: ProviderModel[];
|
|
607
612
|
}>;
|
|
608
613
|
}
|
|
609
|
-
type CreateClientOptions =
|
|
610
|
-
|
|
611
|
-
};
|
|
612
|
-
declare function createClient(opts: CreateClientOptions): SwarmlordClient;
|
|
614
|
+
type CreateClientOptions = Partial<ClientOptions>;
|
|
615
|
+
declare function createClient(opts?: CreateClientOptions): SwarmlordClient;
|
|
613
616
|
|
|
614
617
|
export { createClient };
|
|
615
|
-
export type { AgentConfig, AgentEvent, AgentHandle, AgentName, AgentPart, AssistantMessageInfo, ClientOptions, CompactionPart, Config, CreateClientOptions, CreateScheduleOpts, CreateTriggerOpts, FileInput, FilePart, MessageInfo, MessageInput, MessagePart, OutputConfig, Part, PermissionConfig, PermissionReply, PermissionRequest, ProviderModel, ReasoningPart, RetryPart, ScheduleHandle, ScheduleInfo, SendResult, SessionHandle, SessionInfo, SessionMetrics, SessionStatus, ShellResult, StepFinishPart, StepStartPart, StreamCallbacks, SubtaskPart, SwarmlordClient, TaskHandle, TaskResult, TaskStatus, TextInput, TextPart, TodoItem, Tokens, ToolPart, ToolState, ToolStateCompleted, ToolStateError, ToolStatePending, ToolStateRunning, TriggerHandle, TriggerInfo, TriggerProviderName, UpdateScheduleOpts, UpdateTriggerOpts, UserMessageInfo, WithParts };
|
|
618
|
+
export type { AgentConfig, AgentEvent, AgentHandle, AgentName, AgentPart, AssistantMessageInfo, ClientOptions, CompactionPart, Config, CreateClientOptions, CreateScheduleOpts, CreateTriggerOpts, FileInput, FilePart, MessageInfo, MessageInput, MessagePart, OutputConfig, Part, PermissionConfig, PermissionReply, PermissionRequest, ProviderModel, ReasoningPart, RetryPart, ScheduleHandle, ScheduleInfo, SendResult, SessionHandle, SessionInfo, SessionMetrics, SessionStatus, ShellResult, StepFinishPart, StepStartPart, StreamCallbacks, SubtaskPart, SwarmlordClient, TaskHandle, TaskResult, TaskStatus, TextInput, TextPart, TodoItem, Tokens, ToolName, ToolPart, ToolState, ToolStateCompleted, ToolStateError, ToolStatePending, ToolStateRunning, ToolsConfig, TriggerHandle, TriggerInfo, TriggerProviderName, UpdateScheduleOpts, UpdateTriggerOpts, UserMessageInfo, WithParts };
|
package/dist/index.mjs
CHANGED
|
@@ -101,6 +101,7 @@ function createSessionHandle(id, opts, agentConfig) {
|
|
|
101
101
|
content: input,
|
|
102
102
|
agent: agentConfig?.name,
|
|
103
103
|
model: agentConfig?.model,
|
|
104
|
+
tools: agentConfig?.tools,
|
|
104
105
|
config: agentConfig?.config
|
|
105
106
|
};
|
|
106
107
|
}
|
|
@@ -108,6 +109,7 @@ function createSessionHandle(id, opts, agentConfig) {
|
|
|
108
109
|
parts: input.parts,
|
|
109
110
|
agent: input.agent ?? agentConfig?.name,
|
|
110
111
|
model: input.model ?? agentConfig?.model,
|
|
112
|
+
tools: input.tools ?? agentConfig?.tools,
|
|
111
113
|
config: input.config ?? agentConfig?.config
|
|
112
114
|
};
|
|
113
115
|
}
|
|
@@ -271,9 +273,13 @@ function createSessionHandle(id, opts, agentConfig) {
|
|
|
271
273
|
});
|
|
272
274
|
if (!res.ok) throw new Error(`Failed to get file: ${res.status}`);
|
|
273
275
|
const b64 = await res.text();
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
276
|
+
if (typeof Buffer !== "undefined") {
|
|
277
|
+
const decoded = Buffer.from(b64, "base64");
|
|
278
|
+
return decoded.buffer.slice(decoded.byteOffset, decoded.byteOffset + decoded.byteLength);
|
|
279
|
+
}
|
|
280
|
+
const raw = atob(b64);
|
|
281
|
+
const bytes = new Uint8Array(raw.length);
|
|
282
|
+
for (let i = 0; i < raw.length; i++) bytes[i] = raw.charCodeAt(i);
|
|
277
283
|
return bytes.buffer;
|
|
278
284
|
},
|
|
279
285
|
async getArtifact(key) {
|
|
@@ -298,9 +304,9 @@ function createSessionHandle(id, opts, agentConfig) {
|
|
|
298
304
|
});
|
|
299
305
|
if (!res.ok) throw new Error(`Failed to update session: ${res.status}`);
|
|
300
306
|
},
|
|
301
|
-
async
|
|
307
|
+
async end() {
|
|
302
308
|
const res = await fetch(`${baseUrl}/session/${id}`, { method: "DELETE", headers: headers() });
|
|
303
|
-
if (!res.ok) throw new Error(`Failed to
|
|
309
|
+
if (!res.ok) throw new Error(`Failed to end session: ${res.status}`);
|
|
304
310
|
},
|
|
305
311
|
async runCommand(name, args) {
|
|
306
312
|
const res = await fetch(`${baseUrl}/session/${id}/command`, {
|
|
@@ -569,6 +575,7 @@ function createAgentHandle(clientOpts, config) {
|
|
|
569
575
|
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
570
576
|
body: JSON.stringify({
|
|
571
577
|
title: sessionOpts?.title,
|
|
578
|
+
tools: config.tools,
|
|
572
579
|
config: config.config,
|
|
573
580
|
webhook: sessionOpts?.webhook
|
|
574
581
|
})
|
|
@@ -603,10 +610,14 @@ function createAgentHandle(clientOpts, config) {
|
|
|
603
610
|
|
|
604
611
|
const DEFAULT_BASE_URL = "https://api.swarmlord.ai";
|
|
605
612
|
function createClient(opts) {
|
|
606
|
-
const
|
|
607
|
-
|
|
613
|
+
const apiKey = opts?.apiKey ?? (typeof process !== "undefined" ? process.env.SWARMLORD_API_KEY : void 0);
|
|
614
|
+
if (!apiKey) {
|
|
615
|
+
throw new Error("Missing API key. Pass it to createClient({ apiKey: '...' }) or set SWARMLORD_API_KEY.");
|
|
616
|
+
}
|
|
617
|
+
const baseUrl = (opts?.baseUrl ?? (typeof process !== "undefined" ? process.env.SWARMLORD_URL : void 0) ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
618
|
+
const normalizedOpts = { apiKey, baseUrl };
|
|
608
619
|
function headers() {
|
|
609
|
-
return { Authorization: `Bearer ${
|
|
620
|
+
return { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" };
|
|
610
621
|
}
|
|
611
622
|
return {
|
|
612
623
|
agent(nameOrConfig) {
|