@bbclaw/shared 0.1.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.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @bbclaw/shared
3
+ *
4
+ * Tiny zero-dependency types shared between core, cli, desktop, and backend.
5
+ * Anything that needs a runtime dependency (SDK types, http clients) belongs
6
+ * in @bbclaw/core, not here.
7
+ */
8
+ /** Discriminated result, used in lieu of `throw` for predictable failures. */
9
+ export type Result<T, E = Error> = {
10
+ ok: true;
11
+ value: T;
12
+ } | {
13
+ ok: false;
14
+ error: E;
15
+ };
16
+ export declare function ok<T>(value: T): Result<T, never>;
17
+ export declare function err<E>(error: E): Result<never, E>;
18
+ /**
19
+ * Top-level provider taxonomy. Each kind has its own family of implementations:
20
+ * - `anthropic`: official Anthropic API (and bedrock/vertex if we add them).
21
+ * - `openai-compat`: anything that speaks OpenAI's chat/completions schema.
22
+ * - `web-bridge`: browser-controlled chat services (DeepSeek/Kimi/ChatGPT/...).
23
+ */
24
+ export declare const PROVIDER_KINDS: readonly ["anthropic", "openai-compat", "web-bridge"];
25
+ export type ProviderKind = (typeof PROVIDER_KINDS)[number];
26
+ /**
27
+ * Minimal logger surface. Real implementations live wherever they make sense
28
+ * (CLI uses pino-pretty, desktop uses an in-memory ring buffer, backend uses
29
+ * pino → stdout). Core code calls these methods and stays unopinionated.
30
+ */
31
+ export interface Logger {
32
+ debug(...args: unknown[]): void;
33
+ info(...args: unknown[]): void;
34
+ warn(...args: unknown[]): void;
35
+ error(...args: unknown[]): void;
36
+ }
37
+ export declare const silentLogger: Logger;
38
+ /** Helpful for tests and dev: writes everything to stderr with a prefix. */
39
+ export declare function consoleLogger(prefix?: string): Logger;
40
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,8EAA8E;AAC9E,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAA;AAEnF,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAEhD;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAEjD;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,uDAAwD,CAAA;AACnF,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAE1D;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC/B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC9B,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC9B,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;CAChC;AAED,eAAO,MAAM,YAAY,EAAE,MAK1B,CAAA;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,MAAM,SAAa,GAAG,MAAM,CAWzD"}
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @bbclaw/shared
3
+ *
4
+ * Tiny zero-dependency types shared between core, cli, desktop, and backend.
5
+ * Anything that needs a runtime dependency (SDK types, http clients) belongs
6
+ * in @bbclaw/core, not here.
7
+ */
8
+ export function ok(value) {
9
+ return { ok: true, value };
10
+ }
11
+ export function err(error) {
12
+ return { ok: false, error };
13
+ }
14
+ /**
15
+ * Top-level provider taxonomy. Each kind has its own family of implementations:
16
+ * - `anthropic`: official Anthropic API (and bedrock/vertex if we add them).
17
+ * - `openai-compat`: anything that speaks OpenAI's chat/completions schema.
18
+ * - `web-bridge`: browser-controlled chat services (DeepSeek/Kimi/ChatGPT/...).
19
+ */
20
+ export const PROVIDER_KINDS = ['anthropic', 'openai-compat', 'web-bridge'];
21
+ export const silentLogger = {
22
+ debug: () => { },
23
+ info: () => { },
24
+ warn: () => { },
25
+ error: () => { },
26
+ };
27
+ /** Helpful for tests and dev: writes everything to stderr with a prefix. */
28
+ export function consoleLogger(prefix = '[bbclaw]') {
29
+ const write = (level, args) => {
30
+ // biome-ignore lint/suspicious/noConsole: intentional stderr logger
31
+ console.error(prefix, level, ...args);
32
+ };
33
+ return {
34
+ debug: (...a) => write('DEBUG', a),
35
+ info: (...a) => write('INFO', a),
36
+ warn: (...a) => write('WARN', a),
37
+ error: (...a) => write('ERROR', a),
38
+ };
39
+ }
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,UAAU,EAAE,CAAI,KAAQ;IAC5B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC5B,CAAC;AAED,MAAM,UAAU,GAAG,CAAI,KAAQ;IAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,eAAe,EAAE,YAAY,CAAU,CAAA;AAenF,MAAM,CAAC,MAAM,YAAY,GAAW;IAClC,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;IACf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;IACd,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;IACd,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;CAChB,CAAA;AAED,4EAA4E;AAC5E,MAAM,UAAU,aAAa,CAAC,MAAM,GAAG,UAAU;IAC/C,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,IAAe,EAAQ,EAAE;QACrD,oEAAoE;QACpE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,CAAA;IACvC,CAAC,CAAA;IACD,OAAO;QACL,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAClC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAChC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAChC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;KACnC,CAAA;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@bbclaw/shared",
3
+ "version": "0.1.0",
4
+ "description": "Shared type contracts for BBClaw — zero runtime deps.",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "scripts": {
23
+ "typecheck": "tsc --noEmit",
24
+ "build": "tsc",
25
+ "test": "vitest run --passWithNoTests"
26
+ }
27
+ }