@swarm-agent/sdk 0.1.49 → 0.1.51
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/HEADLESS_UI.md +4 -6
- package/README.md +138 -58
- package/dist/agents.d.ts +114 -0
- package/dist/agents.js +183 -0
- package/dist/auth.d.ts +14 -0
- package/dist/auth.js +16 -0
- package/dist/box.d.ts +88 -0
- package/dist/box.js +13 -0
- package/dist/browser.d.ts +6 -2
- package/dist/browser.js +11 -3
- package/dist/chat.d.ts +41 -7
- package/dist/chat.js +148 -83
- package/dist/client.d.ts +12 -0
- package/dist/client.js +19 -6
- package/dist/copy-tags.d.ts +26 -0
- package/dist/copy-tags.js +133 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.js +21 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/local-connection.d.ts +39 -0
- package/dist/local-connection.js +56 -0
- package/dist/permission-ui.d.ts +1 -0
- package/dist/permission-ui.js +37 -0
- package/dist/permissions.d.ts +4 -0
- package/dist/permissions.js +7 -0
- package/dist/projects.d.ts +25 -7
- package/dist/projects.js +65 -17
- package/dist/provider-auth.d.ts +5 -3
- package/dist/provider-auth.js +6 -8
- package/dist/realtime.d.ts +40 -6
- package/dist/realtime.js +156 -52
- package/dist/remote.d.ts +59 -0
- package/dist/remote.js +46 -0
- package/dist/sessions.d.ts +31 -1
- package/dist/sessions.js +49 -1
- package/dist/settings.d.ts +3 -0
- package/dist/settings.js +19 -3
- package/dist/signals.d.ts +148 -0
- package/dist/signals.js +97 -0
- package/dist/types.d.ts +97 -6
- package/dist/websocket.d.ts +3 -1
- package/dist/websocket.js +1 -1
- package/dist/workers.d.ts +6 -0
- package/dist/workers.js +27 -0
- package/dist/workspaces.d.ts +20 -0
- package/dist/workspaces.js +24 -0
- package/package.json +1 -1
package/dist/websocket.js
CHANGED
|
@@ -165,7 +165,7 @@ export class SwarmWebSocketBridge {
|
|
|
165
165
|
},
|
|
166
166
|
onPermissionRemoved: permissionId => send({ type: 'permission_removed', permissionId }),
|
|
167
167
|
onPermissionError: (error, permission) => send({ type: 'permission_error', permissionId: permission.id, error: error.message }),
|
|
168
|
-
onComplete: messages => send({ type: 'done', messages }),
|
|
168
|
+
onComplete: (messages, run) => send({ type: 'done', messages, run }),
|
|
169
169
|
onError: error => {
|
|
170
170
|
send({ type: 'error', error: error.message });
|
|
171
171
|
if (this.activeWatches.get(ws)?.watch === watch) {
|
package/dist/workers.d.ts
CHANGED
|
@@ -25,6 +25,12 @@ export declare class SwarmWorkersNamespace {
|
|
|
25
25
|
* Lists durable workers with pagination, lifecycle filters, and cursor support.
|
|
26
26
|
*/
|
|
27
27
|
list(params?: ListWorkersParams): Promise<ListWorkersResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates and activates the box's missing premade workers (Coder, Designer,
|
|
30
|
+
* Finder) and returns all three. Existing presets are returned unchanged.
|
|
31
|
+
* Presets are box-level: every job names its workspace.
|
|
32
|
+
*/
|
|
33
|
+
ensurePresets(): Promise<WorkerRecord[]>;
|
|
28
34
|
/**
|
|
29
35
|
* Updates a worker's definition with an explicit expected revision for optimistic concurrency.
|
|
30
36
|
* Body carries expected_revision only (no query params, no local_bindings).
|
package/dist/workers.js
CHANGED
|
@@ -39,6 +39,8 @@ export class SwarmWorkersNamespace {
|
|
|
39
39
|
instructions: params.instructions,
|
|
40
40
|
idempotency_key: params.idempotency_key.trim(),
|
|
41
41
|
};
|
|
42
|
+
if (params.role !== undefined)
|
|
43
|
+
body.role = params.role;
|
|
42
44
|
if (params.description !== undefined)
|
|
43
45
|
body.description = params.description;
|
|
44
46
|
if (params.requested_capabilities !== undefined)
|
|
@@ -132,6 +134,21 @@ export class SwarmWorkersNamespace {
|
|
|
132
134
|
next_cursor: typeof res.data.next_cursor === 'string' && res.data.next_cursor.length > 0 ? res.data.next_cursor : undefined,
|
|
133
135
|
};
|
|
134
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Creates and activates the box's missing premade workers (Coder, Designer,
|
|
139
|
+
* Finder) and returns all three. Existing presets are returned unchanged.
|
|
140
|
+
* Presets are box-level: every job names its workspace.
|
|
141
|
+
*/
|
|
142
|
+
async ensurePresets() {
|
|
143
|
+
const res = await this.transport.request('/v3/workers:ensure-presets', {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
body: {},
|
|
146
|
+
});
|
|
147
|
+
if (!res.data || typeof res.data !== 'object' || !Array.isArray(res.data.workers)) {
|
|
148
|
+
throw new SwarmValidationError('Malformed response envelope: expected workers array');
|
|
149
|
+
}
|
|
150
|
+
return res.data.workers;
|
|
151
|
+
}
|
|
135
152
|
/**
|
|
136
153
|
* Updates a worker's definition with an explicit expected revision for optimistic concurrency.
|
|
137
154
|
* Body carries expected_revision only (no query params, no local_bindings).
|
|
@@ -151,6 +168,8 @@ export class SwarmWorkersNamespace {
|
|
|
151
168
|
const body = {
|
|
152
169
|
expected_revision: expectedRevision,
|
|
153
170
|
};
|
|
171
|
+
if (params.role !== undefined)
|
|
172
|
+
body.role = params.role;
|
|
154
173
|
if (params.name !== undefined)
|
|
155
174
|
body.name = params.name;
|
|
156
175
|
if (params.description !== undefined)
|
|
@@ -593,6 +612,10 @@ export class SwarmWorkersNamespace {
|
|
|
593
612
|
body.input = params.input;
|
|
594
613
|
if (params.idempotency_key)
|
|
595
614
|
body.idempotency_key = params.idempotency_key.trim();
|
|
615
|
+
if (params.workspace_id && params.workspace_id.trim() !== '')
|
|
616
|
+
body.workspace_id = params.workspace_id.trim();
|
|
617
|
+
if (params.workspace_path && params.workspace_path.trim() !== '')
|
|
618
|
+
body.workspace_path = params.workspace_path.trim();
|
|
596
619
|
const res = await this.transport.request(`/v3/workers/${encodeURIComponent(params.worker_id.trim())}/direct`, {
|
|
597
620
|
method: 'POST',
|
|
598
621
|
headers,
|
|
@@ -629,6 +652,10 @@ export class SwarmWorkersNamespace {
|
|
|
629
652
|
}
|
|
630
653
|
if (params.idempotency_key)
|
|
631
654
|
body.idempotency_key = params.idempotency_key.trim();
|
|
655
|
+
if (params.workspace_id && params.workspace_id.trim() !== '')
|
|
656
|
+
body.workspace_id = params.workspace_id.trim();
|
|
657
|
+
if (params.workspace_path && params.workspace_path.trim() !== '')
|
|
658
|
+
body.workspace_path = params.workspace_path.trim();
|
|
632
659
|
const res = await this.transport.request(`/v3/workers/${encodeURIComponent(params.worker_id.trim())}/test`, {
|
|
633
660
|
method: 'POST',
|
|
634
661
|
headers,
|
package/dist/workspaces.d.ts
CHANGED
|
@@ -4,12 +4,32 @@ export declare class SwarmWorkspacesNamespace {
|
|
|
4
4
|
private transport;
|
|
5
5
|
constructor(transport: SwarmTransport);
|
|
6
6
|
createFolder(parent_path: string, name: string): Promise<WorkspaceFolder>;
|
|
7
|
+
/**
|
|
8
|
+
* Creates `parent_path/name` as a new, empty Git repository with one initial
|
|
9
|
+
* commit and registers it as a workspace, in one call. The daemon refuses a
|
|
10
|
+
* folder that already holds other content. Calling it again for a folder
|
|
11
|
+
* that is already registered returns that workspace.
|
|
12
|
+
*/
|
|
13
|
+
create(body: {
|
|
14
|
+
parent_path: string;
|
|
15
|
+
name: string;
|
|
16
|
+
make_current?: boolean;
|
|
17
|
+
}): Promise<WorkspaceResolution>;
|
|
18
|
+
/**
|
|
19
|
+
* Registers an existing folder. A Git repository by default; with
|
|
20
|
+
* `context_only` any readable folder (a project source, never selected as the
|
|
21
|
+
* coding workspace), and with `require_existing_content` as well the daemon
|
|
22
|
+
* refuses empty folders, system/Swarm storage directories and folders inside
|
|
23
|
+
* an already registered workspace (for folders the person named).
|
|
24
|
+
*/
|
|
7
25
|
add(body: {
|
|
8
26
|
path: string;
|
|
9
27
|
name?: string;
|
|
10
28
|
theme_id?: string;
|
|
11
29
|
make_current?: boolean;
|
|
12
30
|
confirm_committed_only?: boolean;
|
|
31
|
+
context_only?: boolean;
|
|
32
|
+
require_existing_content?: boolean;
|
|
13
33
|
}): Promise<WorkspaceResolution>;
|
|
14
34
|
inspectRepository(path: string): Promise<WorkspaceRepository>;
|
|
15
35
|
setupRepository(path: string, expected_resolved_path: string): Promise<WorkspaceRepository>;
|
package/dist/workspaces.js
CHANGED
|
@@ -6,6 +6,30 @@ export class SwarmWorkspacesNamespace {
|
|
|
6
6
|
async createFolder(parent_path, name) {
|
|
7
7
|
return (await this.transport.request('/v1/workspace/folders/create', { method: 'POST', body: { parent_path, name } })).data.folder;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates `parent_path/name` as a new, empty Git repository with one initial
|
|
11
|
+
* commit and registers it as a workspace, in one call. The daemon refuses a
|
|
12
|
+
* folder that already holds other content. Calling it again for a folder
|
|
13
|
+
* that is already registered returns that workspace.
|
|
14
|
+
*/
|
|
15
|
+
async create(body) {
|
|
16
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,62}$/.test(body.name)) {
|
|
17
|
+
throw new Error('Workspace name must be letters, digits, dashes and underscores (at most 63).');
|
|
18
|
+
}
|
|
19
|
+
const parent = body.parent_path.replace(/\/+$/, '');
|
|
20
|
+
if (!parent.startsWith('/'))
|
|
21
|
+
throw new Error('parent_path must be absolute.');
|
|
22
|
+
const path = `${parent}/${body.name}`;
|
|
23
|
+
await this.setupRepository(path, path);
|
|
24
|
+
return this.add({ path, name: body.name, make_current: body.make_current ?? false });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Registers an existing folder. A Git repository by default; with
|
|
28
|
+
* `context_only` any readable folder (a project source, never selected as the
|
|
29
|
+
* coding workspace), and with `require_existing_content` as well the daemon
|
|
30
|
+
* refuses empty folders, system/Swarm storage directories and folders inside
|
|
31
|
+
* an already registered workspace (for folders the person named).
|
|
32
|
+
*/
|
|
9
33
|
async add(body) {
|
|
10
34
|
return (await this.transport.request('/v1/workspace/add', { method: 'POST', body })).data.workspace;
|
|
11
35
|
}
|