@rollrook-ai/sdk 0.0.0-stage → 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.
Files changed (143) hide show
  1. package/dist/agents.d.ts +9 -0
  2. package/dist/agents.d.ts.map +1 -0
  3. package/dist/agents.js +13 -0
  4. package/dist/agents.js.map +1 -0
  5. package/dist/assets.d.ts +35 -0
  6. package/dist/assets.d.ts.map +1 -0
  7. package/dist/assets.js +66 -0
  8. package/dist/assets.js.map +1 -0
  9. package/dist/assistant.d.ts +76 -0
  10. package/dist/assistant.d.ts.map +1 -0
  11. package/dist/assistant.js +161 -0
  12. package/dist/assistant.js.map +1 -0
  13. package/dist/audio.d.ts +55 -0
  14. package/dist/audio.d.ts.map +1 -0
  15. package/dist/audio.js +82 -0
  16. package/dist/audio.js.map +1 -0
  17. package/dist/bridge.d.ts +51 -0
  18. package/dist/bridge.d.ts.map +1 -0
  19. package/dist/bridge.js +78 -0
  20. package/dist/bridge.js.map +1 -0
  21. package/dist/calendar.d.ts +33 -0
  22. package/dist/calendar.d.ts.map +1 -0
  23. package/dist/calendar.js +63 -0
  24. package/dist/calendar.js.map +1 -0
  25. package/dist/context.d.ts +19 -0
  26. package/dist/context.d.ts.map +1 -0
  27. package/dist/context.js +25 -0
  28. package/dist/context.js.map +1 -0
  29. package/dist/errors.d.ts +74 -0
  30. package/dist/errors.d.ts.map +1 -0
  31. package/dist/errors.js +111 -0
  32. package/dist/errors.js.map +1 -0
  33. package/dist/events.d.ts +36 -0
  34. package/dist/events.d.ts.map +1 -0
  35. package/dist/events.js +81 -0
  36. package/dist/events.js.map +1 -0
  37. package/dist/files.d.ts +29 -0
  38. package/dist/files.d.ts.map +1 -0
  39. package/dist/files.js +43 -0
  40. package/dist/files.js.map +1 -0
  41. package/dist/index.d.ts +84 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +78 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/mock/index.d.ts +4 -0
  46. package/dist/mock/index.d.ts.map +1 -0
  47. package/dist/mock/index.js +3 -0
  48. package/dist/mock/index.js.map +1 -0
  49. package/dist/mock/mock-host.d.ts +255 -0
  50. package/dist/mock/mock-host.d.ts.map +1 -0
  51. package/dist/mock/mock-host.js +1274 -0
  52. package/dist/mock/mock-host.js.map +1 -0
  53. package/dist/mock/samples.d.ts +56 -0
  54. package/dist/mock/samples.d.ts.map +1 -0
  55. package/dist/mock/samples.js +283 -0
  56. package/dist/mock/samples.js.map +1 -0
  57. package/dist/mock/toolbar.d.ts +95 -0
  58. package/dist/mock/toolbar.d.ts.map +1 -0
  59. package/dist/mock/toolbar.js +279 -0
  60. package/dist/mock/toolbar.js.map +1 -0
  61. package/dist/net.d.ts +13 -0
  62. package/dist/net.d.ts.map +1 -0
  63. package/dist/net.js +26 -0
  64. package/dist/net.js.map +1 -0
  65. package/dist/plugin.d.ts +11 -0
  66. package/dist/plugin.d.ts.map +1 -0
  67. package/dist/plugin.js +13 -0
  68. package/dist/plugin.js.map +1 -0
  69. package/dist/raven.d.ts +51 -0
  70. package/dist/raven.d.ts.map +1 -0
  71. package/dist/raven.js +100 -0
  72. package/dist/raven.js.map +1 -0
  73. package/dist/segment-display.d.ts +93 -0
  74. package/dist/segment-display.d.ts.map +1 -0
  75. package/dist/segment-display.js +324 -0
  76. package/dist/segment-display.js.map +1 -0
  77. package/dist/settings.d.ts +19 -0
  78. package/dist/settings.d.ts.map +1 -0
  79. package/dist/settings.js +27 -0
  80. package/dist/settings.js.map +1 -0
  81. package/dist/storage.d.ts +28 -0
  82. package/dist/storage.d.ts.map +1 -0
  83. package/dist/storage.js +54 -0
  84. package/dist/storage.js.map +1 -0
  85. package/dist/system.d.ts +19 -0
  86. package/dist/system.d.ts.map +1 -0
  87. package/dist/system.js +24 -0
  88. package/dist/system.js.map +1 -0
  89. package/dist/theme.d.ts +51 -0
  90. package/dist/theme.d.ts.map +1 -0
  91. package/dist/theme.js +85 -0
  92. package/dist/theme.js.map +1 -0
  93. package/dist/types.d.ts +278 -0
  94. package/dist/types.d.ts.map +1 -0
  95. package/dist/types.js +2 -0
  96. package/dist/types.js.map +1 -0
  97. package/dist/ui.d.ts +57 -0
  98. package/dist/ui.d.ts.map +1 -0
  99. package/dist/ui.js +78 -0
  100. package/dist/ui.js.map +1 -0
  101. package/dist/usage.d.ts +14 -0
  102. package/dist/usage.d.ts.map +1 -0
  103. package/dist/usage.js +19 -0
  104. package/dist/usage.js.map +1 -0
  105. package/dist/video.d.ts +11 -0
  106. package/dist/video.d.ts.map +1 -0
  107. package/dist/video.js +17 -0
  108. package/dist/video.js.map +1 -0
  109. package/dist/wire.d.ts +214 -0
  110. package/dist/wire.d.ts.map +1 -0
  111. package/dist/wire.js +538 -0
  112. package/dist/wire.js.map +1 -0
  113. package/package.json +39 -4
  114. package/src/agents.ts +14 -0
  115. package/src/assets.ts +80 -0
  116. package/src/assistant.ts +185 -0
  117. package/src/audio.ts +90 -0
  118. package/src/bridge.ts +96 -0
  119. package/src/calendar.ts +68 -0
  120. package/src/context.ts +28 -0
  121. package/src/errors.ts +131 -0
  122. package/src/events.ts +90 -0
  123. package/src/files.ts +47 -0
  124. package/src/index.ts +152 -0
  125. package/src/mock/index.ts +3 -0
  126. package/src/mock/mock-host.ts +1408 -0
  127. package/src/mock/samples.ts +300 -0
  128. package/src/mock/toolbar.ts +321 -0
  129. package/src/net.ts +27 -0
  130. package/src/plugin.ts +14 -0
  131. package/src/raven.ts +116 -0
  132. package/src/segment-display.ts +377 -0
  133. package/src/settings.ts +29 -0
  134. package/src/storage.ts +59 -0
  135. package/src/system.ts +26 -0
  136. package/src/theme.ts +97 -0
  137. package/src/types.ts +327 -0
  138. package/src/ui.ts +88 -0
  139. package/src/usage.ts +21 -0
  140. package/src/video.ts +17 -0
  141. package/src/wire.ts +608 -0
  142. package/theme.css +407 -0
  143. package/README.md +0 -3
package/dist/wire.js ADDED
@@ -0,0 +1,538 @@
1
+ import { FailedError } from "./errors.js";
2
+ /**
3
+ * Reads the host's replies and event payloads, checks their shape and maps
4
+ * the protocol's camelCase fields to the SDK's names.
5
+ */
6
+ export class Wire {
7
+ /**
8
+ * Whether a value is a plain JSON object.
9
+ *
10
+ * @param value - the value to test
11
+ * @returns true for a non-null, non-array object
12
+ */
13
+ static is_record(value) {
14
+ return typeof value === "object" && value !== null && !Array.isArray(value);
15
+ }
16
+ /**
17
+ * Whether a value is JSON: what `storage` may keep.
18
+ *
19
+ * @param value - the value to test
20
+ * @returns true when the value survives a JSON round trip unchanged
21
+ */
22
+ static is_json(value) {
23
+ if (value === null || typeof value === "boolean" || typeof value === "string") {
24
+ return true;
25
+ }
26
+ if (typeof value === "number") {
27
+ return Number.isFinite(value);
28
+ }
29
+ if (Array.isArray(value)) {
30
+ return value.every((item) => Wire.is_json(item));
31
+ }
32
+ if (Wire.is_record(value)) {
33
+ return Object.values(value).every((item) => Wire.is_json(item));
34
+ }
35
+ return false;
36
+ }
37
+ /**
38
+ * @param value - a reply or payload
39
+ * @param what - what the value should be, for the error message
40
+ * @returns the value as an object
41
+ * @throws FailedError when it is not one
42
+ */
43
+ static record(value, what) {
44
+ if (!Wire.is_record(value)) {
45
+ throw new FailedError(`malformed ${what}: expected an object`);
46
+ }
47
+ return value;
48
+ }
49
+ /**
50
+ * @param record - the object holding the field
51
+ * @param key - the field's wire name
52
+ * @param what - the object, for the error message
53
+ * @returns the field as a string
54
+ * @throws FailedError when it is not one
55
+ */
56
+ static string(record, key, what) {
57
+ const value = record[key];
58
+ if (typeof value !== "string") {
59
+ throw new FailedError(`malformed ${what}: ${key} is not a string`);
60
+ }
61
+ return value;
62
+ }
63
+ /**
64
+ * @param record - the object holding the field
65
+ * @param key - the field's wire name
66
+ * @param what - the object, for the error message
67
+ * @returns the field as a string, or undefined when it is null or missing
68
+ * @throws FailedError when it is something else
69
+ */
70
+ static optional_string(record, key, what) {
71
+ const value = record[key];
72
+ if (value === null || value === undefined) {
73
+ return undefined;
74
+ }
75
+ if (typeof value !== "string") {
76
+ throw new FailedError(`malformed ${what}: ${key} is not a string`);
77
+ }
78
+ return value;
79
+ }
80
+ /**
81
+ * @param record - the object holding the field
82
+ * @param key - the field's wire name
83
+ * @param what - the object, for the error message
84
+ * @returns the field as a number
85
+ * @throws FailedError when it is not one
86
+ */
87
+ static number(record, key, what) {
88
+ const value = record[key];
89
+ if (typeof value !== "number" || !Number.isFinite(value)) {
90
+ throw new FailedError(`malformed ${what}: ${key} is not a number`);
91
+ }
92
+ return value;
93
+ }
94
+ /**
95
+ * @param record - the object holding the field
96
+ * @param key - the field's wire name
97
+ * @param what - the object, for the error message
98
+ * @returns the field as a boolean
99
+ * @throws FailedError when it is not one
100
+ */
101
+ static boolean(record, key, what) {
102
+ const value = record[key];
103
+ if (typeof value !== "boolean") {
104
+ throw new FailedError(`malformed ${what}: ${key} is not a boolean`);
105
+ }
106
+ return value;
107
+ }
108
+ /**
109
+ * @param record - the object holding the field
110
+ * @param key - the field's wire name
111
+ * @param what - the object, for the error message
112
+ * @returns the field as an array
113
+ * @throws FailedError when it is not one
114
+ */
115
+ static array(record, key, what) {
116
+ const value = record[key];
117
+ if (!Array.isArray(value)) {
118
+ throw new FailedError(`malformed ${what}: ${key} is not an array`);
119
+ }
120
+ return value;
121
+ }
122
+ /**
123
+ * @param record - the object holding the field
124
+ * @param key - the field's wire name
125
+ * @param what - the object, for the error message
126
+ * @returns the field as a date, or undefined when it is null, missing or not a time
127
+ */
128
+ static optional_date(record, key, what) {
129
+ const text = Wire.optional_string(record, key, what);
130
+ const date = text === undefined ? undefined : new Date(text);
131
+ return date === undefined || Number.isNaN(date.getTime()) ? undefined : date;
132
+ }
133
+ /**
134
+ * @param record - the object holding the field
135
+ * @param key - the field's wire name
136
+ * @param list_allowed - the values the field may take
137
+ * @returns the field, one of the allowed values
138
+ * @throws FailedError when it is something else
139
+ */
140
+ static one_of(record, key, list_allowed) {
141
+ const value = record[key];
142
+ const found = list_allowed.find((allowed) => allowed === value);
143
+ if (found === undefined) {
144
+ throw new FailedError(`malformed reply: ${key} is not one of ${list_allowed.join(", ")}`);
145
+ }
146
+ return found;
147
+ }
148
+ /**
149
+ * @param raw - the theme as the host sends it
150
+ * @returns the theme
151
+ */
152
+ static theme(raw) {
153
+ const record = Wire.record(raw, "theme");
154
+ const colors = Wire.record(record["colors"], "theme colors");
155
+ const what = "theme colors";
156
+ return {
157
+ is_dark: Wire.boolean(record, "isDark", "theme"),
158
+ is_high_contrast: Wire.boolean(record, "isHighContrast", "theme"),
159
+ colors: {
160
+ background: Wire.string(colors, "background", what),
161
+ surface: Wire.string(colors, "surface", what),
162
+ sidebar: Wire.string(colors, "sidebar", what),
163
+ text: Wire.string(colors, "text", what),
164
+ secondary_text: Wire.string(colors, "secondaryText", what),
165
+ tertiary_text: Wire.string(colors, "tertiaryText", what),
166
+ separator: Wire.string(colors, "separator", what),
167
+ accent: Wire.string(colors, "accent", what),
168
+ on_accent: Wire.string(colors, "onAccent", what),
169
+ caution: Wire.string(colors, "caution", what),
170
+ segment: Wire.string(colors, "segment", what),
171
+ },
172
+ };
173
+ }
174
+ /**
175
+ * @param raw - the context as the host sends it
176
+ * @returns the context
177
+ */
178
+ static context(raw) {
179
+ const record = Wire.record(raw, "context");
180
+ return {
181
+ protocol: Wire.number(record, "protocol", "context"),
182
+ plugin_id: Wire.string(record, "pluginId", "context"),
183
+ plugin_version: Wire.string(record, "pluginVersion", "context"),
184
+ app_version: Wire.string(record, "appVersion", "context"),
185
+ view_id: Wire.string(record, "viewId", "context"),
186
+ slot: Wire.one_of(record, "slot", Wire.LIST_SLOTS),
187
+ instance_id: Wire.string(record, "instanceId", "context"),
188
+ theme: Wire.theme(record["theme"]),
189
+ };
190
+ }
191
+ /** The slots a view may show in. */
192
+ static LIST_SLOTS = ["dock", "sidebar", "footbar", "popover", "settings", "background"];
193
+ /** The code agents RollRook knows. */
194
+ static LIST_HARNESSES = ["claude", "codex", "agy"];
195
+ /** The severities of a plan limit. */
196
+ static LIST_SEVERITIES = ["normal", "warning", "critical"];
197
+ /** The reverb rooms of the mixer. */
198
+ static LIST_REVERB_ROOMS = [
199
+ "smallRoom",
200
+ "mediumRoom",
201
+ "largeRoom",
202
+ "mediumHall",
203
+ "largeHall",
204
+ "plate",
205
+ "cathedral",
206
+ ];
207
+ /**
208
+ * @param raw - a folder entry as the host sends it
209
+ * @returns the entry
210
+ */
211
+ static file_entry(raw) {
212
+ const record = Wire.record(raw, "file entry");
213
+ return {
214
+ name: Wire.string(record, "name", "file entry"),
215
+ is_directory: Wire.boolean(record, "isDirectory", "file entry"),
216
+ size: Wire.number(record, "size", "file entry"),
217
+ };
218
+ }
219
+ /**
220
+ * @param raw - the reply to `raven.answer`
221
+ * @returns the answer
222
+ */
223
+ static raven_answer(raw) {
224
+ const record = Wire.record(raw, "raven answer");
225
+ return {
226
+ is_running: Wire.boolean(record, "isRunning", "raven answer"),
227
+ answer: Wire.optional_string(record, "answer", "raven answer") ?? "",
228
+ };
229
+ }
230
+ /**
231
+ * @param raw - the `raven.turn` event's payload
232
+ * @returns the turn
233
+ */
234
+ static raven_turn(raw) {
235
+ const record = Wire.record(raw, "raven turn");
236
+ return {
237
+ conversation_id: Wire.string(record, "conversationId", "raven turn"),
238
+ is_running: Wire.boolean(record, "isRunning", "raven turn"),
239
+ answer: Wire.optional_string(record, "answer", "raven turn") ?? "",
240
+ };
241
+ }
242
+ /**
243
+ * @param raw - the `visibility` event's payload
244
+ * @returns the change
245
+ */
246
+ static visibility(raw) {
247
+ const record = Wire.record(raw, "visibility");
248
+ return {
249
+ is_shown: Wire.boolean(record, "isShown", "visibility"),
250
+ };
251
+ }
252
+ /**
253
+ * @param raw - the reply to `settings.get` or the `settings.changed` payload
254
+ * @returns the values by key
255
+ */
256
+ static setting_values(raw) {
257
+ const values = Wire.record(Wire.record(raw, "settings")["values"], "settings values");
258
+ const map_values = {};
259
+ for (const [key, value] of Object.entries(values)) {
260
+ if (Wire.is_json(value)) {
261
+ map_values[key] = value;
262
+ }
263
+ }
264
+ return map_values;
265
+ }
266
+ /**
267
+ * @param raw - the `message` event's payload
268
+ * @returns the message
269
+ */
270
+ static plugin_message(raw) {
271
+ const record = Wire.record(raw, "message");
272
+ const message = record["message"] ?? null;
273
+ return {
274
+ from_view_id: Wire.string(record, "fromViewId", "message"),
275
+ from_instance_id: Wire.string(record, "fromInstanceId", "message"),
276
+ message: Wire.is_json(message) ? message : null,
277
+ };
278
+ }
279
+ /**
280
+ * @param raw - one session of `agents.list`
281
+ * @returns the session
282
+ */
283
+ static agent_session(raw) {
284
+ const record = Wire.record(raw, "agent");
285
+ return {
286
+ id: Wire.string(record, "id", "agent"),
287
+ title: Wire.string(record, "title", "agent"),
288
+ harness: Wire.one_of(record, "harness", Wire.LIST_HARNESSES),
289
+ state: Wire.string(record, "state", "agent"),
290
+ host: Wire.optional_string(record, "host", "agent") ?? "",
291
+ };
292
+ }
293
+ /**
294
+ * @param raw - one limit of a `usage.list` account
295
+ * @returns the limit
296
+ */
297
+ static usage_limit(raw) {
298
+ const record = Wire.record(raw, "usage limit");
299
+ return {
300
+ id: Wire.string(record, "id", "usage limit"),
301
+ title: Wire.string(record, "title", "usage limit"),
302
+ used_percent: Wire.number(record, "usedPercent", "usage limit"),
303
+ resets_at: Wire.optional_date(record, "resetsAt", "usage limit"),
304
+ severity: Wire.one_of(record, "severity", Wire.LIST_SEVERITIES),
305
+ };
306
+ }
307
+ /**
308
+ * @param raw - one account of `usage.list`
309
+ * @returns the account
310
+ */
311
+ static usage_account(raw) {
312
+ const record = Wire.record(raw, "usage account");
313
+ const what = "usage account";
314
+ return {
315
+ harness: Wire.one_of(record, "harness", Wire.LIST_HARNESSES),
316
+ signed_in_as: Wire.optional_string(record, "signedInAs", what),
317
+ plan: Wire.optional_string(record, "plan", what),
318
+ is_default: Wire.boolean(record, "isDefault", what),
319
+ error: Wire.optional_string(record, "error", what),
320
+ fetched_at: Wire.optional_date(record, "fetchedAt", what),
321
+ list_limits: Wire.array(record, "limits", what).map((item) => Wire.usage_limit(item)),
322
+ };
323
+ }
324
+ /**
325
+ * @param raw - the reply to `usage.list` or the `usage.changed` payload
326
+ * @returns the accounts and the refresh state
327
+ */
328
+ static usage_snapshot(raw) {
329
+ const record = Wire.record(raw, "usage");
330
+ return {
331
+ list_accounts: Wire.array(record, "accounts", "usage").map((item) => Wire.usage_account(item)),
332
+ is_refreshing: Wire.boolean(record, "isRefreshing", "usage"),
333
+ next_refresh_at: Wire.optional_date(record, "nextRefreshAt", "usage"),
334
+ };
335
+ }
336
+ /**
337
+ * @param raw - a track's target as the host sends it
338
+ * @returns the target
339
+ */
340
+ static audio_target(raw) {
341
+ const record = Wire.record(raw, "audio target");
342
+ if (record["kind"] === "app") {
343
+ return { kind: "app", bundle_id: Wire.string(record, "bundleId", "audio target") };
344
+ }
345
+ if (record["kind"] === "tab") {
346
+ return {
347
+ kind: "tab",
348
+ session_id: Wire.number(record, "sessionId", "audio target"),
349
+ tab_id: Wire.number(record, "tabId", "audio target"),
350
+ };
351
+ }
352
+ throw new FailedError("malformed audio target: kind is not app or tab");
353
+ }
354
+ /**
355
+ * @param target - a track's target
356
+ * @returns the target as the host takes it
357
+ */
358
+ static audio_target_to_wire(target) {
359
+ return target.kind === "app"
360
+ ? { kind: "app", bundleId: target.bundle_id }
361
+ : { kind: "tab", sessionId: target.session_id, tabId: target.tab_id };
362
+ }
363
+ /**
364
+ * @param raw - a track's settings as the host sends them
365
+ * @returns the settings
366
+ */
367
+ static audio_settings(raw) {
368
+ const record = Wire.record(raw, "audio settings");
369
+ const what = "audio settings";
370
+ return {
371
+ is_taken_over: Wire.boolean(record, "isTakenOver", what),
372
+ is_muted: Wire.boolean(record, "isMuted", what),
373
+ volume: Wire.number(record, "volume", what),
374
+ pan: Wire.number(record, "pan", what),
375
+ is_left_inverted: Wire.boolean(record, "isLeftInverted", what),
376
+ is_right_inverted: Wire.boolean(record, "isRightInverted", what),
377
+ is_swapped: Wire.boolean(record, "isSwapped", what),
378
+ width: Wire.number(record, "width", what),
379
+ is_equalizer_enabled: Wire.boolean(record, "isEqualizerEnabled", what),
380
+ list_equalizer_gains: Wire.array(record, "equalizerGains", what).filter((gain) => typeof gain === "number"),
381
+ reverb_room: Wire.one_of(record, "reverbRoom", Wire.LIST_REVERB_ROOMS),
382
+ reverb_mix: Wire.number(record, "reverbMix", what),
383
+ };
384
+ }
385
+ /**
386
+ * @param settings - some of a track's settings
387
+ * @returns them as the host takes them
388
+ */
389
+ static audio_settings_to_wire(settings) {
390
+ const map_wire = {};
391
+ for (const [key, value] of Object.entries(settings)) {
392
+ const wire_key = Wire.map_audio_setting_names[key];
393
+ if (wire_key !== undefined && Wire.is_json(value)) {
394
+ map_wire[wire_key] = value;
395
+ }
396
+ }
397
+ return map_wire;
398
+ }
399
+ /** Each audio setting's wire name, by the SDK's name. */
400
+ static map_audio_setting_names = {
401
+ is_taken_over: "isTakenOver",
402
+ is_muted: "isMuted",
403
+ volume: "volume",
404
+ pan: "pan",
405
+ is_left_inverted: "isLeftInverted",
406
+ is_right_inverted: "isRightInverted",
407
+ is_swapped: "isSwapped",
408
+ width: "width",
409
+ is_equalizer_enabled: "isEqualizerEnabled",
410
+ list_equalizer_gains: "equalizerGains",
411
+ reverb_room: "reverbRoom",
412
+ reverb_mix: "reverbMix",
413
+ };
414
+ /**
415
+ * @param raw - one track of `audio.list` or `audio.tracks`
416
+ * @returns the track
417
+ */
418
+ static audio_track(raw) {
419
+ const record = Wire.record(raw, "audio track");
420
+ return {
421
+ target: Wire.audio_target(record["target"]),
422
+ name: Wire.string(record, "name", "audio track"),
423
+ icon_url: Wire.optional_string(record, "iconURL", "audio track"),
424
+ is_playing: Wire.boolean(record, "isPlaying", "audio track"),
425
+ is_capturing: Wire.boolean(record, "isCapturing", "audio track"),
426
+ has_video: record["hasVideo"] === true,
427
+ settings: Wire.audio_settings(record["settings"]),
428
+ };
429
+ }
430
+ /**
431
+ * @param raw - the reply to `audio.list` or the `audio.tracks` payload
432
+ * @returns the tracks
433
+ */
434
+ static audio_tracks(raw) {
435
+ const record = Wire.record(raw, "audio tracks");
436
+ return {
437
+ list_tracks: Wire.array(record, "tracks", "audio tracks").map((item) => Wire.audio_track(item)),
438
+ };
439
+ }
440
+ /**
441
+ * @param raw - the `audio.levels` payload
442
+ * @returns the levels
443
+ */
444
+ static audio_levels(raw) {
445
+ const record = Wire.record(raw, "audio levels");
446
+ return {
447
+ list_levels: Wire.array(record, "levels", "audio levels").map((item) => {
448
+ const level = Wire.record(item, "audio level");
449
+ return {
450
+ key: Wire.string(level, "key", "audio level"),
451
+ left: Wire.number(level, "left", "audio level"),
452
+ right: Wire.number(level, "right", "audio level"),
453
+ };
454
+ }),
455
+ };
456
+ }
457
+ /**
458
+ * @param raw - the reply to `system.searchCities`
459
+ * @returns the cities
460
+ */
461
+ static cities(raw) {
462
+ const record = Wire.record(raw, "system.searchCities reply");
463
+ return Wire.array(record, "cities", "system.searchCities reply").map((item) => {
464
+ const city = Wire.record(item, "city");
465
+ return {
466
+ name: Wire.string(city, "name", "city"),
467
+ time_zone_id: Wire.string(city, "timeZoneId", "city"),
468
+ };
469
+ });
470
+ }
471
+ /**
472
+ * @param raw - the reply to `net.fetch`
473
+ * @returns the response
474
+ */
475
+ static fetch_response(raw) {
476
+ const record = Wire.record(raw, "fetch response");
477
+ const headers = Wire.record(record["headers"] ?? {}, "fetch headers");
478
+ const map_headers = {};
479
+ for (const [name, value] of Object.entries(headers)) {
480
+ if (typeof value === "string") {
481
+ map_headers[name.toLowerCase()] = value;
482
+ }
483
+ }
484
+ return {
485
+ status: Wire.number(record, "status", "fetch response"),
486
+ map_headers,
487
+ body: Wire.optional_string(record, "body", "fetch response") ?? "",
488
+ };
489
+ }
490
+ /**
491
+ * @param item - one calendar item, with the SDK's names
492
+ * @returns the item in wire form, its unset fields left out
493
+ */
494
+ static calendar_item_to_wire(item) {
495
+ const record = {
496
+ id: item.id,
497
+ title: item.title,
498
+ };
499
+ const map_optional = {
500
+ start: item.start,
501
+ end: item.end,
502
+ due: item.due,
503
+ isAllDay: item.is_all_day,
504
+ isDone: item.is_done,
505
+ color: item.color,
506
+ };
507
+ for (const [key, value] of Object.entries(map_optional)) {
508
+ if (value !== undefined) {
509
+ record[key] = value;
510
+ }
511
+ }
512
+ return record;
513
+ }
514
+ /**
515
+ * @param raw - the `calendar.open` payload
516
+ * @returns the item the user opened
517
+ */
518
+ static calendar_open(raw) {
519
+ const record = Wire.record(raw, "calendar.open");
520
+ return {
521
+ id: Wire.string(record, "id", "calendar.open"),
522
+ };
523
+ }
524
+ /**
525
+ * @param raw - the `calendar.move` payload
526
+ * @returns the item the user moved and its new times
527
+ */
528
+ static calendar_move(raw) {
529
+ const record = Wire.record(raw, "calendar.move");
530
+ return {
531
+ id: Wire.string(record, "id", "calendar.move"),
532
+ start: Wire.optional_string(record, "start", "calendar.move"),
533
+ end: Wire.optional_string(record, "end", "calendar.move"),
534
+ due: Wire.optional_string(record, "due", "calendar.move"),
535
+ };
536
+ }
537
+ }
538
+ //# sourceMappingURL=wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgC1C;;;GAGG;AACH,MAAM,OAAO,IAAI;IACb;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,KAAc;QAC3B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,KAAc;QACzB,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5E,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,MAAM,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AAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;YACtD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACtB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACxB,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,GAAY;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QACjD,OAAO;YACH,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC;SACjD,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,GAAY;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QACjD,OAAO;YACH,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC;YAC9C,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC;YAC7D,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC;YACzD,GAAG,EAAE,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,eAAe,CAAC;SAC5D,CAAC;IACN,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@rollrook-ai/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Typed bridge, theme and mock host for RollRook plugins.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/rollrook-ai/rollrook-sdk.git",
10
+ "directory": "packages/sdk"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ },
17
+ "./mock": {
18
+ "types": "./dist/mock/index.d.ts",
19
+ "import": "./dist/mock/index.js"
20
+ },
21
+ "./theme.css": "./theme.css"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "src",
26
+ "theme.css"
27
+ ],
28
+ "sideEffects": [
29
+ "*.css"
30
+ ],
31
+ "scripts": {
32
+ "build": "tsc -p tsconfig.build.json",
33
+ "typecheck": "tsc -p tsconfig.json --noEmit",
34
+ "test": "vitest run"
35
+ },
36
+ "devDependencies": {
37
+ "happy-dom": "^21.0.4",
38
+ "typescript": "^7.0.2",
39
+ "vitest": "^5.1.2"
40
+ }
41
+ }
package/src/agents.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { Bridge } from "./bridge.js";
2
+ import type { AgentSession } from "./types.js";
3
+ import { Wire } from "./wire.js";
4
+
5
+ /** The code agent sessions RollRook watches. Needs the `agents.read` permission. */
6
+ export class AgentsApi {
7
+ /**
8
+ * @returns the sessions RollRook knows of
9
+ */
10
+ async list(): Promise<AgentSession[]> {
11
+ const record = Wire.record(await Bridge.call("agents.list"), "agents.list reply");
12
+ return Wire.array(record, "agents", "agents.list reply").map((agent: unknown) => Wire.agent_session(agent));
13
+ }
14
+ }