@teatoolkit/sbud 0.0.0-stage → 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 teaToolkit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
- # Temporary Holding Version
1
+ # sbud for Node
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Node client for the sbud service, for Node 20 and later. This early preview has one call, `service()` on `SbudClient`, which reads the running service's version. The service itself has not been released yet, so the preview has been tested only against a stand-in service.
4
+
5
+ ```js
6
+ import { SbudClient } from "@teatoolkit/sbud";
7
+
8
+ console.log((await new SbudClient().service()).version);
9
+ ```
@@ -0,0 +1,15 @@
1
+ export interface ServiceInfo {
2
+ apiVersion: number;
3
+ version: string;
4
+ pid: number;
5
+ endpoint: string;
6
+ startedAt: string;
7
+ }
8
+ /** Talks to the sbud service over its named pipe (Windows) or Unix socket (macOS, Linux). */
9
+ export declare class SbudClient {
10
+ readonly endpoint: string;
11
+ constructor(endpoint?: string);
12
+ /** GET /v1/service: the running service's API version, version, process and endpoint. */
13
+ service(): Promise<ServiceInfo>;
14
+ private send;
15
+ }
package/dist/client.js ADDED
@@ -0,0 +1,37 @@
1
+ import { request } from "node:http";
2
+ import { defaultEndpoint } from "./endpoint.js";
3
+ import { SbudError } from "./errors.js";
4
+ /** Talks to the sbud service over its named pipe (Windows) or Unix socket (macOS, Linux). */
5
+ export class SbudClient {
6
+ endpoint;
7
+ constructor(endpoint) {
8
+ this.endpoint = endpoint ?? defaultEndpoint();
9
+ }
10
+ /** GET /v1/service: the running service's API version, version, process and endpoint. */
11
+ service() {
12
+ return this.send("GET", "/v1/service");
13
+ }
14
+ send(method, path) {
15
+ return new Promise((resolve, reject) => {
16
+ const req = request({ socketPath: this.endpoint, method, path, headers: { Accept: "application/json" } }, (res) => {
17
+ const chunks = [];
18
+ res.on("data", (chunk) => chunks.push(chunk));
19
+ res.on("end", () => {
20
+ const text = Buffer.concat(chunks).toString("utf8");
21
+ const body = text ? JSON.parse(text) : null;
22
+ const status = res.statusCode ?? 0;
23
+ if (status >= 400) {
24
+ const problem = (body ?? {});
25
+ reject(new SbudError(problem.kind ?? "failed", problem.title ?? `HTTP ${status}`, status));
26
+ }
27
+ else {
28
+ resolve(body);
29
+ }
30
+ });
31
+ res.on("error", reject);
32
+ });
33
+ req.on("error", () => reject(new SbudError("unavailable", `The sbud service is not answering at ${this.endpoint}.`)));
34
+ req.end();
35
+ });
36
+ }
37
+ }
@@ -0,0 +1,2 @@
1
+ /** The service's endpoint: SBUD_SOCKET if set, else the named pipe or socket the service uses by default. */
2
+ export declare function defaultEndpoint(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
@@ -0,0 +1,14 @@
1
+ import { homedir, userInfo } from "node:os";
2
+ import { join } from "node:path";
3
+ /** The service's endpoint: SBUD_SOCKET if set, else the named pipe or socket the service uses by default. */
4
+ export function defaultEndpoint(env = process.env, platform = process.platform) {
5
+ if (env.SBUD_SOCKET)
6
+ return env.SBUD_SOCKET;
7
+ if (platform === "win32") {
8
+ const user = userInfo().username.replace(/[^A-Za-z0-9._-]/g, "_");
9
+ return `\\\\.\\pipe\\sbud-${user}`;
10
+ }
11
+ if (env.XDG_RUNTIME_DIR)
12
+ return join(env.XDG_RUNTIME_DIR, "sbud.sock");
13
+ return join(env.SBUD_HOME || join(homedir(), ".sbud"), "sbud.sock");
14
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A request the service refused or could not answer. `kind` is the problem kind the service sent,
3
+ * such as `not-found`, or `unavailable` when the service did not answer at all.
4
+ */
5
+ export declare class SbudError extends Error {
6
+ readonly kind: string;
7
+ readonly title: string;
8
+ readonly status?: number | undefined;
9
+ constructor(kind: string, title: string, status?: number | undefined);
10
+ }
package/dist/errors.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A request the service refused or could not answer. `kind` is the problem kind the service sent,
3
+ * such as `not-found`, or `unavailable` when the service did not answer at all.
4
+ */
5
+ export class SbudError extends Error {
6
+ kind;
7
+ title;
8
+ status;
9
+ constructor(kind, title, status) {
10
+ super(title);
11
+ this.kind = kind;
12
+ this.title = title;
13
+ this.status = status;
14
+ this.name = "SbudError";
15
+ }
16
+ }
@@ -0,0 +1,3 @@
1
+ export { SbudClient, type ServiceInfo } from "./client.js";
2
+ export { defaultEndpoint } from "./endpoint.js";
3
+ export { SbudError } from "./errors.js";
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { SbudClient } from "./client.js";
2
+ export { defaultEndpoint } from "./endpoint.js";
3
+ export { SbudError } from "./errors.js";
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
- "name": "@teatoolkit/sbud",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@teatoolkit/sbud",
3
+ "version": "0.0.1",
4
+ "description": "Client for the sbud service, which manages Docker Sandboxes for AI agents. Early preview.",
5
+ "license": "MIT",
6
+ "author": "teaToolkit",
7
+ "private": false,
8
+ "type": "module",
9
+ "engines": {
10
+ "node": ">=20"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
18
+ "main": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "files": [
21
+ "dist",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsc -p tsconfig.build.json",
27
+ "check": "tsc -p tsconfig.json",
28
+ "test": "npm run check && node --test --test-reporter=spec \"build/test/**/*.test.js\"",
29
+ "prepack": "npm run build"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "20.19.43",
33
+ "typescript": "5.9.3"
34
+ }
35
+ }