@spawnco/sdk-types 0.0.48 → 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
@@ -316,6 +316,48 @@ interface SpawnServerSDK__V1<TConfig = any> {
316
316
  limit?: number;
317
317
  }): Promise<Record<string, LeaderboardEntry[]>>;
318
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>;
319
361
  }
320
362
  interface TokenPayload {
321
363
  sub: string;
@@ -380,6 +422,6 @@ interface LeaderboardEntry {
380
422
  timestamp: number;
381
423
  }
382
424
  type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
383
- type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room'>;
425
+ type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room' | 'llm'>;
384
426
 
385
- 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
@@ -316,6 +316,48 @@ interface SpawnServerSDK__V1<TConfig = any> {
316
316
  limit?: number;
317
317
  }): Promise<Record<string, LeaderboardEntry[]>>;
318
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>;
319
361
  }
320
362
  interface TokenPayload {
321
363
  sub: string;
@@ -380,6 +422,6 @@ interface LeaderboardEntry {
380
422
  timestamp: number;
381
423
  }
382
424
  type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
383
- type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room'>;
425
+ type SpawnServerSDK__V0<TConfig = any> = Omit<SpawnServerSDK__V1<TConfig>, 'economy' | 'room' | 'llm'>;
384
426
 
385
- 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.48",
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
@@ -379,6 +379,55 @@ export interface SpawnServerSDK__V1<TConfig = any> {
379
379
  }
380
380
  ): Promise<Record<string, LeaderboardEntry[]>>;
381
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>;
382
431
  }
383
432
 
384
433
  // Token types
@@ -450,4 +499,4 @@ export interface LeaderboardEntry {
450
499
  // v0 sdk types for testing
451
500
 
452
501
  export type SpawnClientSDK__V0<TConfig = any> = Omit<SpawnClientSDK__V1<TConfig>, 'economy'>;
453
- 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'>;