@spawnco/sdk-types 0.0.47 → 0.0.49

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/dist/index.d.mts CHANGED
@@ -213,6 +213,30 @@ interface SpawnServerSDK__V1<TConfig = any> {
213
213
  price: number;
214
214
  }): Promise<boolean>;
215
215
  };
216
+ /**
217
+ * Variant-scoped document storage.
218
+ * Documents persist across server restarts and copy when variants fork.
219
+ */
220
+ documents: {
221
+ /**
222
+ * Read a document by name. Returns null if not found.
223
+ * Documents are scoped to the current variant.
224
+ */
225
+ get<T = unknown>(name: string): Promise<T | null>;
226
+ /**
227
+ * Write a document. Creates if not exists, replaces if exists.
228
+ * Value must be JSON-serializable.
229
+ */
230
+ set<T = unknown>(name: string, value: T): Promise<void>;
231
+ /**
232
+ * Delete a document by name.
233
+ */
234
+ delete(name: string): Promise<void>;
235
+ /**
236
+ * List all document names for this variant.
237
+ */
238
+ list(): Promise<string[]>;
239
+ };
216
240
  config: {
217
241
  get(): Promise<TConfig>;
218
242
  version(): Promise<string>;
@@ -292,6 +316,48 @@ interface SpawnServerSDK__V1<TConfig = any> {
292
316
  limit?: number;
293
317
  }): Promise<Record<string, LeaderboardEntry[]>>;
294
318
  };
319
+ /**
320
+ * LLM API for conversational AI with persistent memory.
321
+ * Used for NPC dialog, content generation, and dynamic gameplay.
322
+ */
323
+ llm: LlmApi;
324
+ }
325
+ type LlmModel = 'fast' | 'smart';
326
+ interface LlmChatOptions<T = void> {
327
+ /** Unique conversation ID, e.g., "npc:merlin:player:123" */
328
+ conversationId: string;
329
+ /** User's message to the AI */
330
+ message: string;
331
+ /** System prompt (only used on first message of conversation) */
332
+ system?: string;
333
+ /** JSON Schema for structured output (uses tool_use under the hood) */
334
+ schema?: T extends void ? never : object;
335
+ /** Max messages to keep in history (default: 20) */
336
+ maxHistory?: number;
337
+ /** Model selection: 'fast' (~500ms) or 'smart' (~2s) */
338
+ model?: LlmModel;
339
+ }
340
+ interface LlmChatResponse<T = void> {
341
+ /** Raw response text */
342
+ text: string;
343
+ /** Parsed object if schema was provided */
344
+ object: T extends void ? undefined : T;
345
+ /** Token usage for billing */
346
+ usage: {
347
+ inputTokens: number;
348
+ outputTokens: number;
349
+ };
350
+ }
351
+ interface LlmApi {
352
+ /**
353
+ * Conversational chat with persistent memory.
354
+ * Conversation state stored in variant documents automatically.
355
+ */
356
+ chat<T = void>(options: LlmChatOptions<T>): Promise<LlmChatResponse<T>>;
357
+ /**
358
+ * Clear conversation history (e.g., NPC "forgets" player)
359
+ */
360
+ clearConversation(conversationId: string): Promise<void>;
295
361
  }
296
362
  interface TokenPayload {
297
363
  sub: string;
@@ -356,6 +422,6 @@ interface LeaderboardEntry {
356
422
  timestamp: number;
357
423
  }
358
424
  type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
359
- type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room'>;
425
+ type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room' | 'llm'>;
360
426
 
361
- export type { ClipDescriptor, ClipFormat, ClipKind, ClipListOptions, ClipLookupOptions, ClipStatus, ClipThumbnailDescriptor, InventoryItem, Item, LeaderboardEntry, Room, RoomInfo, RoomVisibility, SoundSettings, SpawnClientSDK__V0, SpawnClientSDK__V1, SpawnServerSDK__V0, SpawnServerSDK__V1, TokenPayload, UploadClipOptions, User };
427
+ export type { ClipDescriptor, ClipFormat, ClipKind, ClipListOptions, ClipLookupOptions, ClipStatus, ClipThumbnailDescriptor, InventoryItem, Item, LeaderboardEntry, LlmApi, LlmChatOptions, LlmChatResponse, LlmModel, Room, RoomInfo, RoomVisibility, SoundSettings, SpawnClientSDK__V0, SpawnClientSDK__V1, SpawnServerSDK__V0, SpawnServerSDK__V1, TokenPayload, UploadClipOptions, User };
package/dist/index.d.ts CHANGED
@@ -213,6 +213,30 @@ interface SpawnServerSDK__V1<TConfig = any> {
213
213
  price: number;
214
214
  }): Promise<boolean>;
215
215
  };
216
+ /**
217
+ * Variant-scoped document storage.
218
+ * Documents persist across server restarts and copy when variants fork.
219
+ */
220
+ documents: {
221
+ /**
222
+ * Read a document by name. Returns null if not found.
223
+ * Documents are scoped to the current variant.
224
+ */
225
+ get<T = unknown>(name: string): Promise<T | null>;
226
+ /**
227
+ * Write a document. Creates if not exists, replaces if exists.
228
+ * Value must be JSON-serializable.
229
+ */
230
+ set<T = unknown>(name: string, value: T): Promise<void>;
231
+ /**
232
+ * Delete a document by name.
233
+ */
234
+ delete(name: string): Promise<void>;
235
+ /**
236
+ * List all document names for this variant.
237
+ */
238
+ list(): Promise<string[]>;
239
+ };
216
240
  config: {
217
241
  get(): Promise<TConfig>;
218
242
  version(): Promise<string>;
@@ -292,6 +316,48 @@ interface SpawnServerSDK__V1<TConfig = any> {
292
316
  limit?: number;
293
317
  }): Promise<Record<string, LeaderboardEntry[]>>;
294
318
  };
319
+ /**
320
+ * LLM API for conversational AI with persistent memory.
321
+ * Used for NPC dialog, content generation, and dynamic gameplay.
322
+ */
323
+ llm: LlmApi;
324
+ }
325
+ type LlmModel = 'fast' | 'smart';
326
+ interface LlmChatOptions<T = void> {
327
+ /** Unique conversation ID, e.g., "npc:merlin:player:123" */
328
+ conversationId: string;
329
+ /** User's message to the AI */
330
+ message: string;
331
+ /** System prompt (only used on first message of conversation) */
332
+ system?: string;
333
+ /** JSON Schema for structured output (uses tool_use under the hood) */
334
+ schema?: T extends void ? never : object;
335
+ /** Max messages to keep in history (default: 20) */
336
+ maxHistory?: number;
337
+ /** Model selection: 'fast' (~500ms) or 'smart' (~2s) */
338
+ model?: LlmModel;
339
+ }
340
+ interface LlmChatResponse<T = void> {
341
+ /** Raw response text */
342
+ text: string;
343
+ /** Parsed object if schema was provided */
344
+ object: T extends void ? undefined : T;
345
+ /** Token usage for billing */
346
+ usage: {
347
+ inputTokens: number;
348
+ outputTokens: number;
349
+ };
350
+ }
351
+ interface LlmApi {
352
+ /**
353
+ * Conversational chat with persistent memory.
354
+ * Conversation state stored in variant documents automatically.
355
+ */
356
+ chat<T = void>(options: LlmChatOptions<T>): Promise<LlmChatResponse<T>>;
357
+ /**
358
+ * Clear conversation history (e.g., NPC "forgets" player)
359
+ */
360
+ clearConversation(conversationId: string): Promise<void>;
295
361
  }
296
362
  interface TokenPayload {
297
363
  sub: string;
@@ -356,6 +422,6 @@ interface LeaderboardEntry {
356
422
  timestamp: number;
357
423
  }
358
424
  type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
359
- type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room'>;
425
+ type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room' | 'llm'>;
360
426
 
361
- export type { ClipDescriptor, ClipFormat, ClipKind, ClipListOptions, ClipLookupOptions, ClipStatus, ClipThumbnailDescriptor, InventoryItem, Item, LeaderboardEntry, Room, RoomInfo, RoomVisibility, SoundSettings, SpawnClientSDK__V0, SpawnClientSDK__V1, SpawnServerSDK__V0, SpawnServerSDK__V1, TokenPayload, UploadClipOptions, User };
427
+ export type { ClipDescriptor, ClipFormat, ClipKind, ClipListOptions, ClipLookupOptions, ClipStatus, ClipThumbnailDescriptor, InventoryItem, Item, LeaderboardEntry, LlmApi, LlmChatOptions, LlmChatResponse, LlmModel, Room, RoomInfo, RoomVisibility, SoundSettings, SpawnClientSDK__V0, SpawnClientSDK__V1, SpawnServerSDK__V0, SpawnServerSDK__V1, TokenPayload, UploadClipOptions, User };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spawnco/sdk-types",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
4
4
  "description": "TypeScript type definitions for Spawn SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/v1.ts CHANGED
@@ -234,6 +234,34 @@ export interface SpawnServerSDK__V1<TConfig = any> {
234
234
  verifyPurchase({ purchaseId, price }: { purchaseId: string; price: number }): Promise<boolean>;
235
235
  };
236
236
 
237
+ /**
238
+ * Variant-scoped document storage.
239
+ * Documents persist across server restarts and copy when variants fork.
240
+ */
241
+ documents: {
242
+ /**
243
+ * Read a document by name. Returns null if not found.
244
+ * Documents are scoped to the current variant.
245
+ */
246
+ get<T = unknown>(name: string): Promise<T | null>;
247
+
248
+ /**
249
+ * Write a document. Creates if not exists, replaces if exists.
250
+ * Value must be JSON-serializable.
251
+ */
252
+ set<T = unknown>(name: string, value: T): Promise<void>;
253
+
254
+ /**
255
+ * Delete a document by name.
256
+ */
257
+ delete(name: string): Promise<void>;
258
+
259
+ /**
260
+ * List all document names for this variant.
261
+ */
262
+ list(): Promise<string[]>;
263
+ };
264
+
237
265
  config: {
238
266
  get(): Promise<TConfig>;
239
267
  version(): Promise<string>;
@@ -351,6 +379,55 @@ export interface SpawnServerSDK__V1<TConfig = any> {
351
379
  }
352
380
  ): Promise<Record<string, LeaderboardEntry[]>>;
353
381
  };
382
+
383
+ /**
384
+ * LLM API for conversational AI with persistent memory.
385
+ * Used for NPC dialog, content generation, and dynamic gameplay.
386
+ */
387
+ llm: LlmApi;
388
+ }
389
+
390
+ // LLM Types
391
+ export type LlmModel = 'fast' | 'smart';
392
+
393
+ export interface LlmChatOptions<T = void> {
394
+ /** Unique conversation ID, e.g., "npc:merlin:player:123" */
395
+ conversationId: string;
396
+ /** User's message to the AI */
397
+ message: string;
398
+ /** System prompt (only used on first message of conversation) */
399
+ system?: string;
400
+ /** JSON Schema for structured output (uses tool_use under the hood) */
401
+ schema?: T extends void ? never : object;
402
+ /** Max messages to keep in history (default: 20) */
403
+ maxHistory?: number;
404
+ /** Model selection: 'fast' (~500ms) or 'smart' (~2s) */
405
+ model?: LlmModel;
406
+ }
407
+
408
+ export interface LlmChatResponse<T = void> {
409
+ /** Raw response text */
410
+ text: string;
411
+ /** Parsed object if schema was provided */
412
+ object: T extends void ? undefined : T;
413
+ /** Token usage for billing */
414
+ usage: {
415
+ inputTokens: number;
416
+ outputTokens: number;
417
+ };
418
+ }
419
+
420
+ export interface LlmApi {
421
+ /**
422
+ * Conversational chat with persistent memory.
423
+ * Conversation state stored in variant documents automatically.
424
+ */
425
+ chat<T = void>(options: LlmChatOptions<T>): Promise<LlmChatResponse<T>>;
426
+
427
+ /**
428
+ * Clear conversation history (e.g., NPC "forgets" player)
429
+ */
430
+ clearConversation(conversationId: string): Promise<void>;
354
431
  }
355
432
 
356
433
  // Token types
@@ -422,4 +499,4 @@ export interface LeaderboardEntry {
422
499
  // v0 sdk types for testing
423
500
 
424
501
  export type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
425
- export type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room'>;
502
+ export type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room' | 'llm'>;