@seriousgaming/sdk 0.0.0-stage → 1.0.0-alpha.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.
Files changed (170) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +1 -0
  3. package/README.md +29 -2
  4. package/lib/build/callbacks.d.ts +998 -0
  5. package/lib/build/callbacks.js +32 -0
  6. package/lib/build/context-merge.d.ts +59 -0
  7. package/lib/build/context-merge.js +118 -0
  8. package/lib/build/document.d.ts +36 -0
  9. package/lib/build/document.js +8 -0
  10. package/lib/build/encoding.d.ts +26 -0
  11. package/lib/build/encoding.js +78 -0
  12. package/lib/build/endpoints.d.ts +421 -0
  13. package/lib/build/endpoints.js +46 -0
  14. package/lib/build/hooks.d.ts +74 -0
  15. package/lib/build/hooks.js +1 -0
  16. package/lib/build/index.d.ts +18 -0
  17. package/lib/build/index.js +16 -0
  18. package/lib/build/llm.d.ts +166 -0
  19. package/lib/build/llm.js +17 -0
  20. package/lib/build/resource-schema.d.ts +1048 -0
  21. package/lib/build/resource-schema.js +7 -0
  22. package/lib/build/scheduling.d.ts +112 -0
  23. package/lib/build/scheduling.js +217 -0
  24. package/lib/build/seed.d.ts +51 -0
  25. package/lib/build/seed.js +89 -0
  26. package/lib/build/signatures.d.ts +372 -0
  27. package/lib/build/signatures.js +1 -0
  28. package/lib/build/speech.d.ts +102 -0
  29. package/lib/build/speech.js +11 -0
  30. package/lib/build/tick-validation.d.ts +23 -0
  31. package/lib/build/tick-validation.js +96 -0
  32. package/lib/build/timer.d.ts +74 -0
  33. package/lib/build/timer.js +1 -0
  34. package/lib/build/validators.d.ts +116 -0
  35. package/lib/build/validators.js +1 -0
  36. package/lib/commands.d.ts +357 -0
  37. package/lib/commands.js +14 -0
  38. package/lib/e2e.d.ts +238 -0
  39. package/lib/e2e.js +248 -0
  40. package/lib/projection.d.ts +266 -0
  41. package/lib/projection.js +23 -0
  42. package/lib/testing/index.d.ts +13 -0
  43. package/lib/testing/index.js +13 -0
  44. package/lib/testing/logic-args.d.ts +177 -0
  45. package/lib/testing/logic-args.js +229 -0
  46. package/lib/testing/stub-services.d.ts +41 -0
  47. package/lib/testing/stub-services.js +176 -0
  48. package/lib/ui/CrossTeamDataContext.d.ts +36 -0
  49. package/lib/ui/CrossTeamDataContext.js +32 -0
  50. package/lib/ui/PresentationContext.d.ts +72 -0
  51. package/lib/ui/PresentationContext.js +13 -0
  52. package/lib/ui/PresentationWrapper.d.ts +12 -0
  53. package/lib/ui/PresentationWrapper.js +78 -0
  54. package/lib/ui/SessionUserInterfaceCallbacksContext.d.ts +3 -0
  55. package/lib/ui/SessionUserInterfaceCallbacksContext.js +7 -0
  56. package/lib/ui/SessionUserInterfaceDataContext.d.ts +103 -0
  57. package/lib/ui/SessionUserInterfaceDataContext.js +17 -0
  58. package/lib/ui/SessionUserInterfaceHookFailuresContext.d.ts +44 -0
  59. package/lib/ui/SessionUserInterfaceHookFailuresContext.js +15 -0
  60. package/lib/ui/SessionUserInterfaceHostOverlaysContext.d.ts +23 -0
  61. package/lib/ui/SessionUserInterfaceHostOverlaysContext.js +23 -0
  62. package/lib/ui/SessionUserInterfaceLocaleContext.d.ts +11 -0
  63. package/lib/ui/SessionUserInterfaceLocaleContext.js +13 -0
  64. package/lib/ui/SessionUserInterfaceMetaContext.d.ts +39 -0
  65. package/lib/ui/SessionUserInterfaceMetaContext.js +13 -0
  66. package/lib/ui/SessionUserInterfaceParticipantsContext.d.ts +12 -0
  67. package/lib/ui/SessionUserInterfaceParticipantsContext.js +16 -0
  68. package/lib/ui/SessionUserInterfaceTeamConfigurationContext.d.ts +53 -0
  69. package/lib/ui/SessionUserInterfaceTeamConfigurationContext.js +23 -0
  70. package/lib/ui/SessionUserInterfaceTeamLinksContext.d.ts +56 -0
  71. package/lib/ui/SessionUserInterfaceTeamLinksContext.js +12 -0
  72. package/lib/ui/SessionUserInterfaceTeamsContext.d.ts +13 -0
  73. package/lib/ui/SessionUserInterfaceTeamsContext.js +13 -0
  74. package/lib/ui/SessionUserInterfaceThemeContext.d.ts +9 -0
  75. package/lib/ui/SessionUserInterfaceThemeContext.js +7 -0
  76. package/lib/ui/SessionUserInterfaceThemePreferenceContext.d.ts +3 -0
  77. package/lib/ui/SessionUserInterfaceThemePreferenceContext.js +7 -0
  78. package/lib/ui/SessionUserInterfaceWalkthroughLinkContext.d.ts +42 -0
  79. package/lib/ui/SessionUserInterfaceWalkthroughLinkContext.js +26 -0
  80. package/lib/ui/SessionUserInterfaceWrapper.d.ts +8 -0
  81. package/lib/ui/SessionUserInterfaceWrapper.js +321 -0
  82. package/lib/ui/SettingsEditorCallbacksContext.d.ts +3 -0
  83. package/lib/ui/SettingsEditorCallbacksContext.js +7 -0
  84. package/lib/ui/SettingsEditorContext.d.ts +33 -0
  85. package/lib/ui/SettingsEditorContext.js +16 -0
  86. package/lib/ui/SettingsEditorLocaleContext.d.ts +13 -0
  87. package/lib/ui/SettingsEditorLocaleContext.js +15 -0
  88. package/lib/ui/SettingsEditorThemeContext.d.ts +9 -0
  89. package/lib/ui/SettingsEditorThemeContext.js +7 -0
  90. package/lib/ui/SettingsEditorThemePreferenceContext.d.ts +3 -0
  91. package/lib/ui/SettingsEditorThemePreferenceContext.js +7 -0
  92. package/lib/ui/SettingsEditorWrapper.d.ts +13 -0
  93. package/lib/ui/SettingsEditorWrapper.js +74 -0
  94. package/lib/ui/UserInterfaceCallbacksContext.d.ts +3 -0
  95. package/lib/ui/UserInterfaceCallbacksContext.js +7 -0
  96. package/lib/ui/UserInterfaceDataContext.d.ts +78 -0
  97. package/lib/ui/UserInterfaceDataContext.js +11 -0
  98. package/lib/ui/UserInterfaceLocaleContext.d.ts +13 -0
  99. package/lib/ui/UserInterfaceLocaleContext.js +15 -0
  100. package/lib/ui/UserInterfaceOwnTeamContext.d.ts +25 -0
  101. package/lib/ui/UserInterfaceOwnTeamContext.js +26 -0
  102. package/lib/ui/UserInterfaceOwnTeamJoinLinkContext.d.ts +52 -0
  103. package/lib/ui/UserInterfaceOwnTeamJoinLinkContext.js +13 -0
  104. package/lib/ui/UserInterfaceParticipantContext.d.ts +16 -0
  105. package/lib/ui/UserInterfaceParticipantContext.js +24 -0
  106. package/lib/ui/UserInterfaceParticipantsContext.d.ts +12 -0
  107. package/lib/ui/UserInterfaceParticipantsContext.js +13 -0
  108. package/lib/ui/UserInterfaceRunKindContext.d.ts +31 -0
  109. package/lib/ui/UserInterfaceRunKindContext.js +31 -0
  110. package/lib/ui/UserInterfaceTeamsContext.d.ts +12 -0
  111. package/lib/ui/UserInterfaceTeamsContext.js +13 -0
  112. package/lib/ui/UserInterfaceThemeContext.d.ts +9 -0
  113. package/lib/ui/UserInterfaceThemeContext.js +7 -0
  114. package/lib/ui/UserInterfaceThemePreferenceContext.d.ts +3 -0
  115. package/lib/ui/UserInterfaceThemePreferenceContext.js +7 -0
  116. package/lib/ui/UserInterfaceTimerContext.d.ts +10 -0
  117. package/lib/ui/UserInterfaceTimerContext.js +12 -0
  118. package/lib/ui/UserInterfaceValidationContext.d.ts +25 -0
  119. package/lib/ui/UserInterfaceValidationContext.js +14 -0
  120. package/lib/ui/UserInterfaceViewerRoleContext.d.ts +14 -0
  121. package/lib/ui/UserInterfaceViewerRoleContext.js +17 -0
  122. package/lib/ui/UserInterfaceWrapper.d.ts +8 -0
  123. package/lib/ui/UserInterfaceWrapper.js +219 -0
  124. package/lib/ui/expectedParentOrigin.d.ts +10 -0
  125. package/lib/ui/expectedParentOrigin.js +32 -0
  126. package/lib/ui/index.d.ts +50 -0
  127. package/lib/ui/index.js +52 -0
  128. package/lib/ui/internal/SurfaceGate.d.ts +19 -0
  129. package/lib/ui/internal/SurfaceGate.js +17 -0
  130. package/lib/ui/internal/SurfaceScope.d.ts +17 -0
  131. package/lib/ui/internal/SurfaceScope.js +16 -0
  132. package/lib/ui/internal/createContexts.d.ts +50 -0
  133. package/lib/ui/internal/createContexts.js +32 -0
  134. package/lib/ui/internal/document-attributes.d.ts +9 -0
  135. package/lib/ui/internal/document-attributes.js +87 -0
  136. package/lib/ui/internal/surface-timer.d.ts +3 -0
  137. package/lib/ui/internal/surface-timer.js +11 -0
  138. package/lib/ui/internal/useLatestRef.d.ts +7 -0
  139. package/lib/ui/internal/useLatestRef.js +11 -0
  140. package/lib/ui/internal/useOptimisticMerge.d.ts +19 -0
  141. package/lib/ui/internal/useOptimisticMerge.js +28 -0
  142. package/lib/ui/internal/useSurfaceControls.d.ts +52 -0
  143. package/lib/ui/internal/useSurfaceControls.js +19 -0
  144. package/lib/ui/internal/useTypedPastState.d.ts +17 -0
  145. package/lib/ui/internal/useTypedPastState.js +17 -0
  146. package/lib/ui/mutation-commit.d.ts +32 -0
  147. package/lib/ui/mutation-commit.js +1 -0
  148. package/lib/ui/mutation-outcome.d.ts +66 -0
  149. package/lib/ui/mutation-outcome.js +49 -0
  150. package/lib/ui/request-id.d.ts +18 -0
  151. package/lib/ui/request-id.js +44 -0
  152. package/lib/ui/testing.d.ts +365 -0
  153. package/lib/ui/testing.js +572 -0
  154. package/lib/ui/tick-snapshot.d.ts +28 -0
  155. package/lib/ui/tick-snapshot.js +34 -0
  156. package/lib/ui/ui-protocol.d.ts +799 -0
  157. package/lib/ui/ui-protocol.js +50 -0
  158. package/lib/ui/useAsset.d.ts +80 -0
  159. package/lib/ui/useAsset.js +139 -0
  160. package/lib/ui/useEndpointCallbacks.d.ts +31 -0
  161. package/lib/ui/useEndpointCallbacks.js +68 -0
  162. package/lib/ui/useHostChannel.d.ts +90 -0
  163. package/lib/ui/useHostChannel.js +338 -0
  164. package/lib/ui/useMutationReporter.d.ts +100 -0
  165. package/lib/ui/useMutationReporter.js +97 -0
  166. package/lib/ui/usePastState.d.ts +39 -0
  167. package/lib/ui/usePastState.js +63 -0
  168. package/lib/ui/useViewerStorage.d.ts +54 -0
  169. package/lib/ui/useViewerStorage.js +141 -0
  170. package/package.json +83 -3
@@ -0,0 +1,166 @@
1
+ /**
2
+ * LLM Integration Types
3
+ *
4
+ * Provides types for interacting with Language Models through the Serious Gaming SDK.
5
+ * Model selection and endpoint configuration is handled by the platform.
6
+ */
7
+ /**
8
+ * A content block inside an LLM message or response.
9
+ *
10
+ * - `text` — plain text content
11
+ * - `toolUse` — a structured intent emitted by the assistant; the caller is
12
+ * expected to run the tool in its own code and feed the result back via a
13
+ * `toolResult` block
14
+ * - `toolResult` — the result of a tool run, sent back in a `user` message so
15
+ * the model can continue the conversation
16
+ *
17
+ * The SDK relays tool intent and results across the wire; it never executes
18
+ * tools itself.
19
+ */
20
+ export type ContentBlock = {
21
+ type: 'text';
22
+ text: string;
23
+ } | {
24
+ type: 'toolUse';
25
+ id: string;
26
+ name: string;
27
+ input: unknown;
28
+ } | {
29
+ type: 'toolResult';
30
+ toolUseId: string;
31
+ content: string;
32
+ isError?: boolean;
33
+ };
34
+ /**
35
+ * A message in a conversation with an LLM.
36
+ *
37
+ * `content` may be a plain string (the common case) or an array of content
38
+ * blocks when the message carries tool-use intents or tool results.
39
+ */
40
+ export interface LLMMessage {
41
+ role: 'user' | 'assistant';
42
+ content: string | ContentBlock[];
43
+ }
44
+ /**
45
+ * JSON Schema for requesting structured responses from the LLM
46
+ * Follows the JSON Schema specification
47
+ */
48
+ export interface JSONSchema {
49
+ type?: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array' | string;
50
+ properties?: Record<string, JSONSchema>;
51
+ required?: string[];
52
+ description?: string;
53
+ items?: JSONSchema;
54
+ enum?: unknown[];
55
+ default?: unknown;
56
+ [key: string]: unknown;
57
+ }
58
+ /**
59
+ * LLM capability tier for a generateText call.
60
+ *
61
+ * - `quick` — fast, low-cost model (default)
62
+ * - `standard` — balanced model for typical generation tasks
63
+ * - `expert` — most capable model for complex reasoning and analysis
64
+ *
65
+ * Which model each tier maps to is configured at the platform level.
66
+ * If a tier is not configured, it falls back toward `quick`.
67
+ */
68
+ export type LLMTier = 'quick' | 'standard' | 'expert';
69
+ /**
70
+ * A tool the model may invoke. The model never executes anything itself —
71
+ * when it emits a `toolUse` content block, the caller runs the tool in its
72
+ * own code and feeds the result back via a `toolResult` block on the next
73
+ * turn.
74
+ *
75
+ * `name` must match `^[a-zA-Z0-9_-]{1,64}$`; the LLM client validates this
76
+ * at the boundary and throws before making a request.
77
+ */
78
+ export interface LLMTool {
79
+ name: string;
80
+ description: string;
81
+ inputSchema: JSONSchema;
82
+ }
83
+ /**
84
+ * Options for generating text with an LLM
85
+ */
86
+ export interface LLMGenerateOptions {
87
+ /**
88
+ * A simple prompt for text generation
89
+ * Use this for straightforward requests
90
+ */
91
+ prompt?: string;
92
+ /**
93
+ * A conversation history for multi-turn interactions
94
+ * Specify either `prompt` or `messages`, not both
95
+ */
96
+ messages?: LLMMessage[];
97
+ /**
98
+ * Optional system prompt to guide the LLM's behavior
99
+ * Provides context and instructions for how the LLM should respond
100
+ */
101
+ systemPrompt?: string;
102
+ /**
103
+ * JSON Schema for structured output
104
+ * When provided, the LLM will return a response that validates against this schema
105
+ */
106
+ jsonSchema?: JSONSchema;
107
+ /**
108
+ * The capability tier to use for this call.
109
+ * Defaults to `'quick'` if not specified.
110
+ */
111
+ tier?: LLMTier;
112
+ /**
113
+ * Tools the model may invoke. When set and the model decides to call a
114
+ * tool, the response's `stopReason` will be `'toolUse'` and at least one
115
+ * `toolUse` content block will be present. The caller runs the tool and
116
+ * feeds the result back as a `toolResult` block on the next call.
117
+ */
118
+ tools?: LLMTool[];
119
+ }
120
+ /**
121
+ * Why the LLM stopped generating.
122
+ *
123
+ * - `endTurn` — the model finished a normal response
124
+ * - `toolUse` — the model emitted one or more tool-use blocks and expects
125
+ * tool results back on the next call
126
+ * - `maxTokens` — the model hit a token limit before finishing
127
+ * - `refusal` — the model refused to respond; callers should branch
128
+ * separately (rewrite the prompt, escalate, etc.)
129
+ */
130
+ export type LLMStopReason = 'endTurn' | 'toolUse' | 'maxTokens' | 'refusal';
131
+ /**
132
+ * Token usage reported by the LLM provider for one generation call.
133
+ */
134
+ export interface LLMUsage {
135
+ inputTokens: number;
136
+ outputTokens: number;
137
+ }
138
+ /**
139
+ * Response from the LLM.
140
+ *
141
+ * `content` is an array of content blocks so a single response can carry
142
+ * text and one or more tool-use intents. Simple callers that just want the
143
+ * text can use {@link getText}.
144
+ *
145
+ * `usage` is present when the provider reports token counts for the call.
146
+ */
147
+ export interface LLMResponse {
148
+ content: ContentBlock[];
149
+ stopReason: LLMStopReason;
150
+ usage?: LLMUsage;
151
+ }
152
+ /**
153
+ * Helper for the common case where a caller just wants the assistant's
154
+ * text. Returns the concatenation of every `text` block in the response;
155
+ * `toolUse` blocks are skipped.
156
+ */
157
+ export declare function getText(response: LLMResponse): string;
158
+ /**
159
+ * Function for generating text with an LLM
160
+ * The actual endpoint and model are determined by the platform
161
+ *
162
+ * Can be called with a simple string prompt or a full options object:
163
+ * - generateText("Generate some text")
164
+ * - generateText({ prompt: "text", systemPrompt: "instructions" })
165
+ */
166
+ export type LLMGenerateFunction = (options: LLMGenerateOptions | string) => Promise<LLMResponse>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * LLM Integration Types
3
+ *
4
+ * Provides types for interacting with Language Models through the Serious Gaming SDK.
5
+ * Model selection and endpoint configuration is handled by the platform.
6
+ */
7
+ /**
8
+ * Helper for the common case where a caller just wants the assistant's
9
+ * text. Returns the concatenation of every `text` block in the response;
10
+ * `toolUse` blocks are skipped.
11
+ */
12
+ export function getText(response) {
13
+ return response.content
14
+ .filter((block) => block.type === 'text')
15
+ .map((block) => block.text)
16
+ .join('');
17
+ }