@to11ai/sdk 0.0.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.
@@ -0,0 +1,22 @@
1
+ import type { ResolvedPrompt } from "./prompts/types";
2
+ export interface GatewayAuthOptions {
3
+ apiKey: string;
4
+ projectId: string;
5
+ }
6
+ /**
7
+ * Build the auth headers required for every request through the to11 gateway.
8
+ *
9
+ * @example
10
+ * const headers = gatewayAuthHeaders({ apiKey, projectId });
11
+ */
12
+ export declare function gatewayAuthHeaders(options: GatewayAuthOptions): Record<string, string>;
13
+ /**
14
+ * Build prompt provenance headers from a resolved prompt.
15
+ * Omits `x-to11-prompt-labels` when the prompt has no labels,
16
+ * since the gateway rejects empty header values.
17
+ *
18
+ * @example
19
+ * const prompt = await client.prompts.resolve({ slug, labels });
20
+ * const headers = gatewayPromptHeaders(prompt);
21
+ */
22
+ export declare function gatewayPromptHeaders(prompt: ResolvedPrompt): Record<string, string>;
@@ -0,0 +1,27 @@
1
+ // src/gateway.ts
2
+ function gatewayAuthHeaders(options) {
3
+ if (options.apiKey.trim().length === 0) {
4
+ throw new Error("[to11ai/sdk] `apiKey` must not be empty.");
5
+ }
6
+ if (options.projectId.trim().length === 0) {
7
+ throw new Error("[to11ai/sdk] `projectId` must not be empty.");
8
+ }
9
+ return {
10
+ "x-to11-authorization": `Bearer ${options.apiKey}`,
11
+ "x-to11-project-id": options.projectId
12
+ };
13
+ }
14
+ function gatewayPromptHeaders(prompt) {
15
+ const headers = {
16
+ "x-to11-prompt-id": prompt.promptId,
17
+ "x-to11-prompt-version": String(prompt.version)
18
+ };
19
+ if (prompt.labels.length > 0) {
20
+ headers["x-to11-prompt-labels"] = prompt.labels.join(",");
21
+ }
22
+ return headers;
23
+ }
24
+ export {
25
+ gatewayPromptHeaders,
26
+ gatewayAuthHeaders
27
+ };
@@ -0,0 +1,38 @@
1
+ import type { ResolvedPrompt } from "./types";
2
+ export interface CacheConfig {
3
+ /** Time-to-live in seconds. Default: 300 (5 minutes) */
4
+ ttlSeconds?: number;
5
+ /** Maximum number of entries. Default: 100 */
6
+ maxEntries?: number;
7
+ }
8
+ /**
9
+ * Build a canonical cache key for a resolve() call.
10
+ *
11
+ * - projectId is included to prevent cross-project cache collisions: a single
12
+ * PromptResource can serve multiple projects, so the same slug+labels must
13
+ * not share a cache entry across different projects.
14
+ * - Labels are sorted alphabetically so ["production", "en"] and ["en", "production"]
15
+ * map to the same key.
16
+ * - Variables are canonicalized with deterministic sorted-keys JSON before hashing.
17
+ * - Each segment is JSON-encoded so that separator characters in slug or label
18
+ * values cannot cause key collisions (e.g. a slug containing "|" or ",").
19
+ */
20
+ export declare function buildCacheKey(projectId: string, slug: string, labels: string[], variables?: Record<string, unknown>): string;
21
+ /**
22
+ * In-memory LRU cache for ResolvedPrompt objects.
23
+ *
24
+ * Uses a Map (insertion-ordered) as the backing store. On every access, the
25
+ * entry is deleted and re-inserted to maintain LRU order — oldest entries sit
26
+ * at the front of the Map.
27
+ */
28
+ export declare class PromptCache {
29
+ private readonly ttlMs;
30
+ private readonly maxEntries;
31
+ private readonly store;
32
+ constructor(config?: CacheConfig);
33
+ get(key: string): ResolvedPrompt | undefined;
34
+ set(key: string, value: ResolvedPrompt): void;
35
+ delete(key: string): void;
36
+ clear(): void;
37
+ get size(): number;
38
+ }
@@ -0,0 +1,160 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
8
+ var __toCommonJS = (from) => {
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
10
+ if (entry)
11
+ return entry;
12
+ entry = __defProp({}, "__esModule", { value: true });
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ __moduleCache.set(from, entry);
22
+ return entry;
23
+ };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
29
+ var __export = (target, all) => {
30
+ for (var name in all)
31
+ __defProp(target, name, {
32
+ get: all[name],
33
+ enumerable: true,
34
+ configurable: true,
35
+ set: __exportSetter.bind(all, name)
36
+ });
37
+ };
38
+
39
+ // src/prompts/resource.ts
40
+ var exports_resource = {};
41
+ __export(exports_resource, {
42
+ PromptResource: () => PromptResource
43
+ });
44
+ module.exports = __toCommonJS(exports_resource);
45
+ var import_errors = require("../errors");
46
+ var import_cache = require("./cache");
47
+ function unwrap(envelope) {
48
+ if (envelope.data === null || envelope.data === undefined) {
49
+ throw new Error("API returned success but data is null");
50
+ }
51
+ return envelope.data;
52
+ }
53
+ function getProjectPromptsPath(projectId) {
54
+ return `/v1/projects/${encodeURIComponent(projectId)}/prompts`;
55
+ }
56
+ function getProjectPromptPath(projectId, promptId) {
57
+ return `${getProjectPromptsPath(projectId)}/${encodeURIComponent(promptId)}`;
58
+ }
59
+
60
+ class PromptResource {
61
+ transport;
62
+ cache;
63
+ constructor(transport, cacheConfig) {
64
+ this.transport = transport;
65
+ this.cache = new import_cache.PromptCache(cacheConfig);
66
+ }
67
+ async create(input) {
68
+ const { projectId, ...body } = input;
69
+ const envelope = await this.transport.request("POST", getProjectPromptsPath(projectId), { body });
70
+ return unwrap(envelope);
71
+ }
72
+ async list(input) {
73
+ const { projectId, ...queryRest } = input;
74
+ const envelope = await this.transport.request("GET", getProjectPromptsPath(projectId), {
75
+ query: {
76
+ ...queryRest
77
+ }
78
+ });
79
+ const raw = unwrap(envelope);
80
+ const items = Array.isArray(raw) ? raw : raw.items ?? [];
81
+ const pagination = envelope.pagination ?? (Array.isArray(raw) ? undefined : raw.pagination) ?? {
82
+ page: 1,
83
+ limit: items.length,
84
+ total: items.length,
85
+ totalPages: 1
86
+ };
87
+ return { items, pagination };
88
+ }
89
+ async get(input) {
90
+ const { projectId, promptId } = input;
91
+ const envelope = await this.transport.request("GET", getProjectPromptPath(projectId, promptId));
92
+ return unwrap(envelope);
93
+ }
94
+ async update(input) {
95
+ const { projectId, promptId, ...body } = input;
96
+ const envelope = await this.transport.request("PATCH", getProjectPromptPath(projectId, promptId), { body });
97
+ return unwrap(envelope);
98
+ }
99
+ async archive(input) {
100
+ const { projectId, promptId } = input;
101
+ const envelope = await this.transport.request("DELETE", getProjectPromptPath(projectId, promptId));
102
+ return unwrap(envelope);
103
+ }
104
+ async createVersion(input) {
105
+ const { projectId, promptId, ...body } = input;
106
+ const envelope = await this.transport.request("POST", `${getProjectPromptPath(projectId, promptId)}/versions`, { body });
107
+ return unwrap(envelope);
108
+ }
109
+ async listVersions(input) {
110
+ const { projectId, promptId } = input;
111
+ const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/versions`);
112
+ return unwrap(envelope);
113
+ }
114
+ async getVersion(input) {
115
+ const { projectId, promptId, versionNumber } = input;
116
+ const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/versions/${encodeURIComponent(String(versionNumber))}`);
117
+ return unwrap(envelope);
118
+ }
119
+ async moveLabel(input) {
120
+ const { projectId, promptId, label, ...body } = input;
121
+ const envelope = await this.transport.request("PUT", `${getProjectPromptPath(projectId, promptId)}/labels/${encodeURIComponent(label)}`, { body });
122
+ return unwrap(envelope);
123
+ }
124
+ async listLabels(input) {
125
+ const { projectId, promptId } = input;
126
+ const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/labels`);
127
+ return unwrap(envelope);
128
+ }
129
+ async resolve(input) {
130
+ const {
131
+ projectId,
132
+ slug,
133
+ labels,
134
+ variables,
135
+ cache: useCache = true,
136
+ fallback
137
+ } = input;
138
+ const cacheKey = import_cache.buildCacheKey(projectId, slug, labels, variables);
139
+ if (useCache) {
140
+ const cached = this.cache.get(cacheKey);
141
+ if (cached)
142
+ return structuredClone(cached);
143
+ }
144
+ try {
145
+ const envelope = await this.transport.request("POST", `${getProjectPromptsPath(projectId)}:resolve`, {
146
+ body: { slug, labels, variables }
147
+ });
148
+ const result = unwrap(envelope);
149
+ if (useCache) {
150
+ this.cache.set(cacheKey, structuredClone(result));
151
+ }
152
+ return result;
153
+ } catch (err) {
154
+ if (err instanceof import_errors.To11aiNetworkError && fallback !== undefined) {
155
+ return fallback;
156
+ }
157
+ throw err;
158
+ }
159
+ }
160
+ }
@@ -0,0 +1,21 @@
1
+ import type { Transport } from "../transport";
2
+ import type { CacheConfig } from "./cache";
3
+ import type { ArchivePromptInput, ArchivePromptResult, CreatePromptInput, CreatePromptResult, CreatePromptVersionInput, CreatePromptVersionResult, GetPromptInput, GetPromptResult, GetPromptVersionInput, GetPromptVersionResult, ListPromptLabelsInput, ListPromptLabelsResult, ListPromptsInput, ListPromptsResult, ListPromptVersionsInput, ListPromptVersionsResult, MovePromptLabelInput, MovePromptLabelResult, PaginatedResult, ResolvePromptInput, ResolvePromptResult, UpdatePromptInput, UpdatePromptResult } from "./types";
4
+ export type { CacheConfig } from "./cache";
5
+ export type { ArchivePromptInput, ArchivePromptResult, ChatMessage, CreatePromptInput, CreatePromptResult, CreatePromptVersionInput, CreatePromptVersionResult, GetPromptInput, GetPromptResult, GetPromptVersionInput, GetPromptVersionResult, ListPromptLabelsInput, ListPromptLabelsResult, ListPromptsInput, ListPromptsResult, ListPromptVersionsInput, ListPromptVersionsResult, MovePromptLabelInput, MovePromptLabelResult, PaginatedResult, PaginationInfo, Prompt, PromptFormat, PromptLabelPointer, PromptStatus, PromptVersion, RenderedPrompt, ResolvedPrompt, ResolvePromptInput, ResolvePromptResult, UpdatePromptInput, UpdatePromptResult, } from "./types";
6
+ export declare class PromptResource {
7
+ private readonly transport;
8
+ private readonly cache;
9
+ constructor(transport: Transport, cacheConfig?: CacheConfig);
10
+ create(input: CreatePromptInput): Promise<CreatePromptResult>;
11
+ list(input: ListPromptsInput): Promise<PaginatedResult<ListPromptsResult>>;
12
+ get(input: GetPromptInput): Promise<GetPromptResult>;
13
+ update(input: UpdatePromptInput): Promise<UpdatePromptResult>;
14
+ archive(input: ArchivePromptInput): Promise<ArchivePromptResult>;
15
+ createVersion(input: CreatePromptVersionInput): Promise<CreatePromptVersionResult>;
16
+ listVersions(input: ListPromptVersionsInput): Promise<ListPromptVersionsResult>;
17
+ getVersion(input: GetPromptVersionInput): Promise<GetPromptVersionResult>;
18
+ moveLabel(input: MovePromptLabelInput): Promise<MovePromptLabelResult>;
19
+ listLabels(input: ListPromptLabelsInput): Promise<ListPromptLabelsResult>;
20
+ resolve(input: ResolvePromptInput): Promise<ResolvePromptResult>;
21
+ }
@@ -0,0 +1,120 @@
1
+ // src/prompts/resource.ts
2
+ import { To11aiNetworkError } from "../errors";
3
+ import { buildCacheKey, PromptCache } from "./cache";
4
+ function unwrap(envelope) {
5
+ if (envelope.data === null || envelope.data === undefined) {
6
+ throw new Error("API returned success but data is null");
7
+ }
8
+ return envelope.data;
9
+ }
10
+ function getProjectPromptsPath(projectId) {
11
+ return `/v1/projects/${encodeURIComponent(projectId)}/prompts`;
12
+ }
13
+ function getProjectPromptPath(projectId, promptId) {
14
+ return `${getProjectPromptsPath(projectId)}/${encodeURIComponent(promptId)}`;
15
+ }
16
+
17
+ class PromptResource {
18
+ transport;
19
+ cache;
20
+ constructor(transport, cacheConfig) {
21
+ this.transport = transport;
22
+ this.cache = new PromptCache(cacheConfig);
23
+ }
24
+ async create(input) {
25
+ const { projectId, ...body } = input;
26
+ const envelope = await this.transport.request("POST", getProjectPromptsPath(projectId), { body });
27
+ return unwrap(envelope);
28
+ }
29
+ async list(input) {
30
+ const { projectId, ...queryRest } = input;
31
+ const envelope = await this.transport.request("GET", getProjectPromptsPath(projectId), {
32
+ query: {
33
+ ...queryRest
34
+ }
35
+ });
36
+ const raw = unwrap(envelope);
37
+ const items = Array.isArray(raw) ? raw : raw.items ?? [];
38
+ const pagination = envelope.pagination ?? (Array.isArray(raw) ? undefined : raw.pagination) ?? {
39
+ page: 1,
40
+ limit: items.length,
41
+ total: items.length,
42
+ totalPages: 1
43
+ };
44
+ return { items, pagination };
45
+ }
46
+ async get(input) {
47
+ const { projectId, promptId } = input;
48
+ const envelope = await this.transport.request("GET", getProjectPromptPath(projectId, promptId));
49
+ return unwrap(envelope);
50
+ }
51
+ async update(input) {
52
+ const { projectId, promptId, ...body } = input;
53
+ const envelope = await this.transport.request("PATCH", getProjectPromptPath(projectId, promptId), { body });
54
+ return unwrap(envelope);
55
+ }
56
+ async archive(input) {
57
+ const { projectId, promptId } = input;
58
+ const envelope = await this.transport.request("DELETE", getProjectPromptPath(projectId, promptId));
59
+ return unwrap(envelope);
60
+ }
61
+ async createVersion(input) {
62
+ const { projectId, promptId, ...body } = input;
63
+ const envelope = await this.transport.request("POST", `${getProjectPromptPath(projectId, promptId)}/versions`, { body });
64
+ return unwrap(envelope);
65
+ }
66
+ async listVersions(input) {
67
+ const { projectId, promptId } = input;
68
+ const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/versions`);
69
+ return unwrap(envelope);
70
+ }
71
+ async getVersion(input) {
72
+ const { projectId, promptId, versionNumber } = input;
73
+ const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/versions/${encodeURIComponent(String(versionNumber))}`);
74
+ return unwrap(envelope);
75
+ }
76
+ async moveLabel(input) {
77
+ const { projectId, promptId, label, ...body } = input;
78
+ const envelope = await this.transport.request("PUT", `${getProjectPromptPath(projectId, promptId)}/labels/${encodeURIComponent(label)}`, { body });
79
+ return unwrap(envelope);
80
+ }
81
+ async listLabels(input) {
82
+ const { projectId, promptId } = input;
83
+ const envelope = await this.transport.request("GET", `${getProjectPromptPath(projectId, promptId)}/labels`);
84
+ return unwrap(envelope);
85
+ }
86
+ async resolve(input) {
87
+ const {
88
+ projectId,
89
+ slug,
90
+ labels,
91
+ variables,
92
+ cache: useCache = true,
93
+ fallback
94
+ } = input;
95
+ const cacheKey = buildCacheKey(projectId, slug, labels, variables);
96
+ if (useCache) {
97
+ const cached = this.cache.get(cacheKey);
98
+ if (cached)
99
+ return structuredClone(cached);
100
+ }
101
+ try {
102
+ const envelope = await this.transport.request("POST", `${getProjectPromptsPath(projectId)}:resolve`, {
103
+ body: { slug, labels, variables }
104
+ });
105
+ const result = unwrap(envelope);
106
+ if (useCache) {
107
+ this.cache.set(cacheKey, structuredClone(result));
108
+ }
109
+ return result;
110
+ } catch (err) {
111
+ if (err instanceof To11aiNetworkError && fallback !== undefined) {
112
+ return fallback;
113
+ }
114
+ throw err;
115
+ }
116
+ }
117
+ }
118
+ export {
119
+ PromptResource
120
+ };
@@ -0,0 +1,142 @@
1
+ export type PromptStatus = "active" | "archived";
2
+ export type PromptFormat = "text" | "chat";
3
+ export interface ChatMessage {
4
+ role: "system" | "user" | "assistant" | "tool";
5
+ content: string;
6
+ }
7
+ export interface Prompt {
8
+ id: string;
9
+ projectId: string;
10
+ name: string;
11
+ slug: string;
12
+ description: string | null;
13
+ tags: string[];
14
+ status: PromptStatus;
15
+ createdByUserId: string;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ }
19
+ export interface PromptVersion {
20
+ id: string;
21
+ promptId: string;
22
+ version: number;
23
+ format: PromptFormat;
24
+ templateJson: unknown;
25
+ variablesSchema: unknown;
26
+ modelConfig: unknown;
27
+ changelog: string | null;
28
+ createdByUserId: string;
29
+ createdAt: string;
30
+ }
31
+ export interface PromptLabelPointer {
32
+ promptId: string;
33
+ label: string;
34
+ versionId: string;
35
+ updatedByUserId: string;
36
+ updatedAt: string;
37
+ }
38
+ export type RenderedPrompt = {
39
+ format: "text";
40
+ text: string;
41
+ } | {
42
+ format: "chat";
43
+ messages: ChatMessage[];
44
+ };
45
+ export interface ResolvedPrompt {
46
+ promptId: string;
47
+ versionId: string;
48
+ version: number;
49
+ labels: string[];
50
+ contentHash: string;
51
+ rendered: RenderedPrompt;
52
+ }
53
+ export interface PaginationInfo {
54
+ page: number;
55
+ limit: number;
56
+ total: number;
57
+ totalPages: number;
58
+ }
59
+ export interface PaginatedResult<T> {
60
+ items: T[];
61
+ pagination: PaginationInfo;
62
+ }
63
+ export interface CreatePromptInput {
64
+ projectId: string;
65
+ name: string;
66
+ slug: string;
67
+ description?: string;
68
+ tags?: string[];
69
+ }
70
+ export type CreatePromptResult = Prompt;
71
+ export interface ListPromptsInput {
72
+ projectId: string;
73
+ status?: PromptStatus;
74
+ sortBy?: "createdAt" | "updatedAt" | "name";
75
+ tags?: string;
76
+ page?: number;
77
+ limit?: number;
78
+ }
79
+ export type ListPromptsResult = Prompt;
80
+ export interface GetPromptInput {
81
+ projectId: string;
82
+ promptId: string;
83
+ }
84
+ export type GetPromptResult = Prompt;
85
+ export interface UpdatePromptInput {
86
+ projectId: string;
87
+ promptId: string;
88
+ name?: string;
89
+ description?: string | null;
90
+ tags?: string[];
91
+ }
92
+ export type UpdatePromptResult = Prompt;
93
+ export interface ArchivePromptInput {
94
+ projectId: string;
95
+ promptId: string;
96
+ }
97
+ export type ArchivePromptResult = Prompt;
98
+ export interface CreatePromptVersionInput {
99
+ projectId: string;
100
+ promptId: string;
101
+ format: PromptFormat;
102
+ templateJson: unknown;
103
+ variablesSchema: unknown;
104
+ modelConfig?: unknown;
105
+ changelog?: string;
106
+ }
107
+ export type CreatePromptVersionResult = PromptVersion;
108
+ export interface ListPromptVersionsInput {
109
+ projectId: string;
110
+ promptId: string;
111
+ }
112
+ export type ListPromptVersionsResult = PromptVersion[];
113
+ export interface GetPromptVersionInput {
114
+ projectId: string;
115
+ promptId: string;
116
+ versionNumber: number;
117
+ }
118
+ export type GetPromptVersionResult = PromptVersion;
119
+ export interface MovePromptLabelInput {
120
+ projectId: string;
121
+ promptId: string;
122
+ label: string;
123
+ versionId: string;
124
+ reason?: string;
125
+ }
126
+ export type MovePromptLabelResult = PromptLabelPointer;
127
+ export interface ListPromptLabelsInput {
128
+ projectId: string;
129
+ promptId: string;
130
+ }
131
+ export type ListPromptLabelsResult = PromptLabelPointer[];
132
+ export interface ResolvePromptInput {
133
+ projectId: string;
134
+ slug: string;
135
+ labels: string[];
136
+ variables?: Record<string, unknown>;
137
+ /** Set false to bypass the LRU cache for this call. Default: true */
138
+ cache?: boolean;
139
+ /** Fallback prompt served if the API is unreachable and cache is empty. */
140
+ fallback?: ResolvedPrompt;
141
+ }
142
+ export type ResolvePromptResult = ResolvedPrompt;
@@ -0,0 +1,44 @@
1
+ export type AuthConfig = {
2
+ readonly apiKey: string;
3
+ readonly getAccessToken?: never;
4
+ } | {
5
+ readonly getAccessToken: () => Promise<string>;
6
+ readonly apiKey?: never;
7
+ };
8
+ export interface TransportConfig {
9
+ readonly baseUrl: string;
10
+ readonly auth: AuthConfig;
11
+ /** Request timeout in milliseconds. Default: 30_000 */
12
+ readonly timeoutMs?: number;
13
+ /** Max number of retries for network errors / 5xx (not counting the initial attempt). Default: 3 */
14
+ readonly maxRetries?: number;
15
+ }
16
+ /** Standard API envelope returned by the to11ai server. */
17
+ export interface ApiEnvelope<T = unknown> {
18
+ readonly success: boolean;
19
+ readonly code: number;
20
+ readonly data: T | null;
21
+ readonly error: {
22
+ code?: string;
23
+ message: string;
24
+ details?: unknown;
25
+ } | null;
26
+ readonly pagination: {
27
+ readonly page: number;
28
+ readonly limit: number;
29
+ readonly total: number;
30
+ readonly totalPages: number;
31
+ } | null;
32
+ }
33
+ export declare class Transport {
34
+ private readonly baseUrl;
35
+ private readonly auth;
36
+ private readonly timeoutMs;
37
+ private readonly maxRetries;
38
+ constructor(config: TransportConfig);
39
+ private buildHeaders;
40
+ request<T>(method: string, path: string, options?: {
41
+ query?: Record<string, string | number | boolean | undefined>;
42
+ body?: unknown;
43
+ }): Promise<ApiEnvelope<T>>;
44
+ }
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@to11ai/sdk",
3
+ "version": "0.0.2",
4
+ "type": "module",
5
+ "main": "./dist/client.cjs",
6
+ "module": "./dist/client.js",
7
+ "types": "./src/client.ts",
8
+ "files": [
9
+ "dist",
10
+ "src",
11
+ "!src/**/*.test.ts",
12
+ "!src/**/*.fixture.ts",
13
+ "README.md"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "types": "./src/client.ts",
18
+ "bun": "./src/client.ts",
19
+ "deno": "./src/client.ts",
20
+ "import": "./dist/client.js",
21
+ "require": "./dist/client.cjs",
22
+ "default": "./dist/client.js"
23
+ },
24
+ "./prompts": {
25
+ "types": "./src/prompts/resource.ts",
26
+ "bun": "./src/prompts/resource.ts",
27
+ "deno": "./src/prompts/resource.ts",
28
+ "import": "./dist/prompts/resource.js",
29
+ "require": "./dist/prompts/resource.cjs",
30
+ "default": "./dist/prompts/resource.js"
31
+ },
32
+ "./errors": {
33
+ "types": "./src/errors.ts",
34
+ "bun": "./src/errors.ts",
35
+ "deno": "./src/errors.ts",
36
+ "import": "./dist/errors.js",
37
+ "require": "./dist/errors.cjs",
38
+ "default": "./dist/errors.js"
39
+ },
40
+ "./gateway": {
41
+ "types": "./src/gateway.ts",
42
+ "bun": "./src/gateway.ts",
43
+ "deno": "./src/gateway.ts",
44
+ "import": "./dist/gateway.js",
45
+ "require": "./dist/gateway.cjs",
46
+ "default": "./dist/gateway.js"
47
+ }
48
+ },
49
+ "publishConfig": {
50
+ "access": "restricted"
51
+ },
52
+ "scripts": {
53
+ "build": "bun run build:clean && bun run build:esm && bun run build:cjs && bun run build:types",
54
+ "build:clean": "rm -rf dist",
55
+ "build:esm": "bun build src/client.ts src/prompts/resource.ts src/errors.ts src/gateway.ts --outdir dist --target node --format esm --external '*'",
56
+ "build:cjs": "bun build src/client.ts src/prompts/resource.ts src/errors.ts src/gateway.ts --outdir dist --target node --format cjs --external '*' --entry-naming '[dir]/[name].cjs'",
57
+ "build:types": "tsc -p tsconfig.build.json",
58
+ "prepack": "bun run build",
59
+ "test": "bun test",
60
+ "typecheck": "bun x tsc --noEmit",
61
+ "lint": "biome check .",
62
+ "lint:check": "biome check --error-on-warnings .",
63
+ "lint:fix": "biome check --fix .",
64
+ "format": "biome format --write ."
65
+ },
66
+ "devDependencies": {
67
+ "@biomejs/biome": "^2.4.15",
68
+ "@types/bun": "^1.3.13",
69
+ "typescript": "^5.9.3"
70
+ }
71
+ }