moi-computer 0.13.1-next.1 → 0.13.1-next.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.
Files changed (195) hide show
  1. package/client/api/app-config.ts +12 -1
  2. package/client/api/http.ts +11 -1
  3. package/client/app/app-router.tsx +3 -2
  4. package/client/app/routes/home-route.tsx +1 -1
  5. package/client/app/routes/workspace-registration.tsx +68 -0
  6. package/client/app/routes/workspace-route.tsx +33 -6
  7. package/client/app/shell/sidebar-layout.tsx +10 -5
  8. package/client/components/shared/workspace-icon.tsx +8 -17
  9. package/client/features/account/account-test-utils.tsx +15 -9
  10. package/client/features/account/api.ts +6 -6
  11. package/client/features/account/profile-actions.ts +5 -7
  12. package/client/features/app-settings/settings-page.tsx +2 -1
  13. package/client/features/applets/api.ts +6 -6
  14. package/client/features/applets/applet-cache.ts +6 -5
  15. package/client/features/applets/applet-log.ts +2 -1
  16. package/client/features/applets/applet-runtime.ts +2 -1
  17. package/client/features/applets/use-applet.ts +73 -18
  18. package/client/features/applets/widget-shell.tsx +4 -2
  19. package/client/features/chat/applet-chat-intents.ts +5 -13
  20. package/client/features/chat/chat-popup.tsx +8 -4
  21. package/client/features/chat/chat-send.ts +2 -2
  22. package/client/features/chat/composer/model-order.ts +4 -4
  23. package/client/features/chat/composer/model-picker.tsx +12 -10
  24. package/client/features/chat/composer/use-workspace-composer-state.tsx +1 -1
  25. package/client/features/chat/sessions/api.ts +11 -28
  26. package/client/features/chat/sessions/use-selected-session.ts +18 -100
  27. package/client/features/chat/use-chat.ts +8 -12
  28. package/client/features/collab/members/api.ts +4 -10
  29. package/client/features/collab/members/hooks.ts +32 -38
  30. package/client/features/collab/members/store.ts +96 -71
  31. package/client/features/collab/members/types.ts +5 -3
  32. package/client/features/collab/presence/client.ts +2 -3
  33. package/client/features/collab/presence/hooks.tsx +1 -1
  34. package/client/features/collab/proxy-user.ts +1 -3
  35. package/client/features/collab/sharing/workspace-members.tsx +0 -8
  36. package/client/features/dev/chat-states-page.tsx +3 -1
  37. package/client/features/dev/harness-debug-page.tsx +7 -7
  38. package/client/features/dev/workspace-setup-mocks.ts +1 -1
  39. package/client/features/dev/workspace-setup-preview.tsx +6 -4
  40. package/client/features/harness/api.ts +13 -10
  41. package/client/features/harness/harness-login-panel.tsx +9 -5
  42. package/client/features/harness/harness-presentation.ts +4 -4
  43. package/client/features/harness/harness-selector.tsx +13 -13
  44. package/client/features/harness/use-harness-login.ts +5 -5
  45. package/client/features/home/api.ts +38 -2
  46. package/client/features/home/home-page.tsx +43 -13
  47. package/client/features/home/shared-workspaces.tsx +70 -0
  48. package/client/features/home/workspace-invitations.tsx +101 -0
  49. package/client/features/identity/host-api.ts +3 -2
  50. package/client/features/identity/store.ts +1 -7
  51. package/client/features/onboarding/agent-setup-step.tsx +8 -8
  52. package/client/features/onboarding/onboarding-page.tsx +3 -2
  53. package/client/features/onboarding/workspace-setup-step.tsx +1 -1
  54. package/client/features/overview/api.ts +3 -5
  55. package/client/features/overview/default/registry.tsx +1 -1
  56. package/client/features/overview/default/views-widget.tsx +2 -2
  57. package/client/features/overview/hidden-panel.tsx +7 -5
  58. package/client/features/overview/overview.tsx +18 -16
  59. package/client/features/overview/workspace-name.tsx +2 -2
  60. package/client/features/scratchpad/scratchpad.tsx +9 -7
  61. package/client/features/scratchpad/use-scratchpad-snapshot.tsx +13 -5
  62. package/client/features/views/api.ts +34 -16
  63. package/client/features/views/use-view-actions.ts +10 -20
  64. package/client/features/views/view-manager.tsx +1 -1
  65. package/client/features/views/view-submission.ts +2 -21
  66. package/client/features/workspace/add/api.ts +5 -4
  67. package/client/features/workspace/add/create-workspace-dialog.tsx +12 -9
  68. package/client/features/workspace/add/import-workspace-dialog.tsx +7 -7
  69. package/client/features/workspace/add/use-workspace-import.ts +10 -10
  70. package/client/features/workspace/add/workspace-agent-options.ts +21 -20
  71. package/client/features/workspace/add/workspace-agent-selector.tsx +11 -11
  72. package/client/features/workspace/api.ts +60 -13
  73. package/client/features/workspace/harness-transition.ts +7 -13
  74. package/client/features/workspace/remote.ts +25 -0
  75. package/client/features/workspace/settings/api.ts +7 -12
  76. package/client/features/workspace/settings/connectors-settings.tsx +3 -3
  77. package/client/features/workspace/settings/general-settings.tsx +8 -8
  78. package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
  79. package/client/features/workspace/setup/workspace-recovery-states.tsx +43 -14
  80. package/client/features/workspace/setup/workspace-setup.tsx +6 -6
  81. package/client/features/workspace/tab-resolution.ts +2 -2
  82. package/client/features/workspace/use-workspace-navigation.ts +7 -4
  83. package/client/features/workspace/workspace-content.tsx +22 -20
  84. package/client/features/workspace/workspace-frame.tsx +13 -26
  85. package/client/features/workspace/workspace-layout-context.tsx +45 -12
  86. package/client/features/workspace/workspace-menu.tsx +2 -2
  87. package/client/features/workspace/workspace-pane.tsx +22 -0
  88. package/client/features/workspace/workspace-pending-screen.tsx +1 -1
  89. package/client/features/workspace/workspace-preferences.ts +34 -0
  90. package/client/features/workspace/workspace-presentation.tsx +12 -16
  91. package/client/features/workspace/workspace-screen.tsx +2 -2
  92. package/client/features/workspace/workspace-state.ts +2 -1
  93. package/client/features/workspace/workspace-tabs.tsx +1 -1
  94. package/client/features/workspace/workspace-test-utils.ts +23 -0
  95. package/client/runtime/use-workspace-events.ts +14 -0
  96. package/client/runtime/workspace-events.ts +9 -9
  97. package/client/store/ui.ts +29 -9
  98. package/dist/chunk-44khk4sp.js +2 -0
  99. package/dist/chunk-ba6mz56s.js +72 -0
  100. package/dist/chunk-ec5ennpv.js +1 -0
  101. package/dist/chunk-ectsnw81.js +2 -0
  102. package/dist/chunk-en7w5ypg.js +1 -0
  103. package/dist/chunk-f695wcx5.js +5 -0
  104. package/dist/chunk-kffcah9w.css +1 -0
  105. package/dist/{chunk-th91xfnp.js → chunk-n0fawy9x.js} +1 -1
  106. package/dist/chunk-pdt9hxfw.js +2 -0
  107. package/dist/chunk-rmd0ctfx.js +546 -0
  108. package/dist/chunk-zv22wv0g.js +1 -0
  109. package/dist/index.html +1 -1
  110. package/lib/harness-instructions.ts +4 -4
  111. package/lib/harness-types.ts +13 -0
  112. package/lib/types.ts +34 -49
  113. package/lib/workspace-config.ts +48 -0
  114. package/lib/workspace-layout.ts +2 -4
  115. package/package.json +4 -2
  116. package/server/README.md +29 -27
  117. package/server/api/harnesses.ts +5 -5
  118. package/server/api/index.ts +170 -68
  119. package/server/applets/index.ts +15 -9
  120. package/server/applets/views.ts +2 -17
  121. package/server/applets/widgets.ts +3 -2
  122. package/server/cli/commands/config.ts +8 -20
  123. package/server/cli/commands/hermes.ts +2 -2
  124. package/server/cli/commands/init.ts +96 -53
  125. package/server/cli/commands/openclaw.ts +2 -2
  126. package/server/cli/commands/refresh.ts +10 -1
  127. package/server/cli/commands/remote.ts +228 -0
  128. package/server/cli/commands/skill.ts +4 -4
  129. package/server/cli/commands/tabs.ts +5 -12
  130. package/server/cli/control.ts +35 -4
  131. package/server/cli/index.ts +10 -6
  132. package/server/cli/remote-command.ts +77 -0
  133. package/server/cli/remote-control.ts +70 -0
  134. package/server/cli/remote-operations.ts +244 -0
  135. package/server/collab/config.ts +3 -3
  136. package/server/collab/skill/index.ts +3 -3
  137. package/server/control.ts +38 -11
  138. package/server/harness/acp/session.ts +4 -4
  139. package/server/harness/auth.ts +26 -31
  140. package/server/harness/claude-code/index.ts +1 -1
  141. package/server/harness/codex/discovery.ts +1 -1
  142. package/server/harness/codex/session.ts +1 -1
  143. package/server/harness/detect.ts +14 -19
  144. package/server/harness/executable.ts +10 -10
  145. package/server/harness/hermes/NOTES.md +2 -2
  146. package/server/harness/hermes/index.ts +1 -1
  147. package/server/harness/install.ts +11 -11
  148. package/server/harness/openclaw/index.ts +1 -1
  149. package/server/harness/registry.ts +7 -6
  150. package/server/harness/types.ts +4 -4
  151. package/server/onboarding/jobs.ts +1 -1
  152. package/server/operations/commands.ts +46 -0
  153. package/server/operations/files.ts +148 -0
  154. package/server/operations/server.ts +206 -0
  155. package/server/remote/agent.ts +103 -0
  156. package/server/remote/client.ts +665 -0
  157. package/server/remote/workspace.ts +34 -0
  158. package/server/scratchpad/document.ts +32 -12
  159. package/server/scratchpad/executor.ts +16 -7
  160. package/server/sessions/config.ts +8 -5
  161. package/server/sessions/pending-views.ts +16 -0
  162. package/server/sessions/view-sessions.ts +10 -12
  163. package/server/skills/locations.ts +4 -4
  164. package/server/skills/update.ts +11 -11
  165. package/server/skills/version.ts +7 -7
  166. package/server/skills/workspace.ts +13 -11
  167. package/server/web.ts +11 -8
  168. package/server/workspace-state/file.ts +2 -0
  169. package/server/workspace-state/index.ts +0 -4
  170. package/server/workspaces/api.ts +28 -0
  171. package/server/workspaces/change-harness.ts +15 -26
  172. package/server/workspaces/import.ts +4 -4
  173. package/server/workspaces/init.ts +15 -13
  174. package/server/workspaces/layout.ts +60 -66
  175. package/server/workspaces/registry.ts +43 -18
  176. package/server/workspaces/shared.ts +74 -0
  177. package/server/workspaces/tabs.ts +6 -12
  178. package/skill/SKILL.md +24 -4
  179. package/client/api/app-ui-keys.ts +0 -6
  180. package/client/features/chat/sessions/browser-tab-state.ts +0 -43
  181. package/client/features/collab/members/keys.ts +0 -6
  182. package/client/features/workspace/browser-tab-state.ts +0 -51
  183. package/client/features/workspace/layout-save.ts +0 -13
  184. package/dist/chunk-3smkkcfw.js +0 -546
  185. package/dist/chunk-47h9c2qy.js +0 -2
  186. package/dist/chunk-8qed2gqp.js +0 -75
  187. package/dist/chunk-8zy3vesm.js +0 -1
  188. package/dist/chunk-a47zy276.js +0 -2
  189. package/dist/chunk-g4c1nte9.css +0 -1
  190. package/dist/chunk-kcactdr4.js +0 -2
  191. package/dist/chunk-m8bhx6tw.js +0 -1
  192. package/dist/chunk-pf19zcrn.js +0 -2
  193. package/dist/chunk-ygzxah0e.js +0 -1
  194. package/lib/workspace-types.ts +0 -13
  195. package/server/workspace-state/legacy-migration.ts +0 -79
@@ -1,3 +1,8 @@
1
+ import { openSharedWorkspace } from '../workspaces/shared'
2
+ import { executeScratchOp } from '../scratchpad/executor'
3
+ import type { ScratchOp, WorkspaceInfoResponse } from '@/lib/types'
4
+ import { workspaceApiBase, parseRemoteWorkspaceTarget } from '@/lib/workspace-config'
5
+ import { loadWorkspaceFileConfig } from '../workspaces/layout'
1
6
  import { resolveWorkspaceEnv } from '../workspaces/env'
2
7
  import { changeWorkspaceHarness } from '../workspaces/change-harness'
3
8
  import { HarnessTransitionError, reserveWorkspaceOperation } from '../workspaces/harness-transition'
@@ -19,11 +24,10 @@ import type {
19
24
  AppletThumbnailBatch,
20
25
  AppSettings,
21
26
  HarnessAvailability,
22
- SelectedSessionScope,
23
27
  UploadInfo,
24
28
  WorkspaceHarness,
25
29
  WorkspaceEntry,
26
- WorkspaceType
30
+ HarnessType
27
31
  } from '@/lib/types'
28
32
  import { isWorkspaceTabId } from '@/lib/workspace-tabs'
29
33
 
@@ -34,7 +38,7 @@ import { harnesses } from './harnesses'
34
38
  import { clientAppConfig, createdWorkspacesRoot, getAppConfig } from '../app-config'
35
39
  import { getAppSettings, pickAppSettingsPatch, saveAppSettings } from '../app-settings'
36
40
  import { appletForModule, recordAppletError } from '../applets/log'
37
- import { apiBaseFor, parseAppletTail, serveWorkspaceFile } from '../applets'
41
+ import { parseAppletTail, serveWorkspaceFile } from '../applets'
38
42
  import { applyEnvChanged } from '../workspaces/env-apply'
39
43
  import { publishEvent } from '../events'
40
44
  import { callFunction, parseFunctionPath } from '../applets/functions'
@@ -83,6 +87,7 @@ import { requiredEnvFor } from '../workspaces/required-env'
83
87
  import {
84
88
  deleteView,
85
89
  listCompiledViews,
90
+ getWorkspaceViews,
86
91
  listViews,
87
92
  serveView,
88
93
  updateViewTitle,
@@ -160,6 +165,14 @@ async function handleFunctionCall(
160
165
  }
161
166
  }
162
167
 
168
+ // Routes that describe the person using a workspace, not the workspace itself:
169
+ // their chats, their agent and what that agent runs with. A visitor's Moi answers
170
+ // them from its own folder; an owner never serves them to visitors.
171
+ const PERSONAL_ROUTE_RE = /^\/(?:sessions|state|harness|skills|env|mcp|uploads|preview)(?:\/|$)/
172
+ // A view being built belongs to the chat building it, so its lifecycle is
173
+ // personal too. Compiled views stay with the owner.
174
+ const PENDING_VIEW_ROUTE_RE = /^\/views(?:\/[^/]+(?:\/submit)?)?$/
175
+
163
176
  // Resolve `:id` to a registered workspace once, 404 if unknown, and stash it on
164
177
  // the context. Mounted on the single-workspace sub-app so every nested route
165
178
  // shares the lookup instead of repeating `getWorkspace(...) ?? 404`.
@@ -172,6 +185,19 @@ const withWorkspace = createMiddleware<ApiEnv>(async (c, next) => {
172
185
  release = reserveWorkspaceOperation(id)
173
186
  const ws = await getWorkspace(id)
174
187
  if (!ws) return c.text('Workspace not found', 404)
188
+ const suffix = (c.req.path.split(`/workspaces/${encodeURIComponent(id)}`)[1] ?? '').replace(
189
+ /\/$/,
190
+ ''
191
+ )
192
+ const personal =
193
+ PERSONAL_ROUTE_RE.test(suffix) ||
194
+ (c.req.method !== 'GET' && PENDING_VIEW_ROUTE_RE.test(suffix))
195
+ if (ws.remote && suffix === '' && c.req.method === 'DELETE')
196
+ return c.text('Leaving remote workspaces is not available yet', 403)
197
+ if (ws.remote && getAppConfig().environment !== 'cloud')
198
+ return c.text('Remote workspaces require Cloud mode', 403)
199
+ if (ws.remote && suffix !== '' && !personal)
200
+ return c.text('Use the owner workspace address', 404)
175
201
  c.set('ws', ws)
176
202
  await next()
177
203
  } catch (error) {
@@ -188,10 +214,10 @@ one.use('*', withWorkspace)
188
214
  one.patch('/harness', async c => {
189
215
  if (getAppConfig().demo) return c.text('Changing agents is unavailable in the demo', 403)
190
216
  const body = await c.req.json().catch(() => null)
191
- if (!body || !['claude-code', 'codex'].includes(body.type))
217
+ if (!body || !['claude-code', 'codex'].includes(body.harness))
192
218
  return c.text('Invalid agent selection', 400)
193
219
  try {
194
- return c.json(await changeWorkspaceHarness(c.get('ws'), body.type))
220
+ return c.json(await changeWorkspaceHarness(c.get('ws'), body.harness))
195
221
  } catch (error) {
196
222
  if (error instanceof HarnessTransitionError) return c.text(error.message, 409)
197
223
  throw error
@@ -208,12 +234,18 @@ one.get('/widgets/*', c => {
208
234
  const ws = c.get('ws')
209
235
  const { name, file } = parseAppletTail(c.req.url, ws.id, 'widgets')
210
236
  if (!name) return c.text('Not found', 404)
211
- return serveWidget(name, file, ws.path, apiBaseFor(ws.id), c.req.header('if-none-match'))
237
+ return serveWidget(name, file, ws.path, workspaceApiBase(ws.id), c.req.header('if-none-match'))
212
238
  })
213
239
 
214
240
  // Views — full-screen agent apps. Mirrors the widget pair above: the exact path
215
241
  // lists (in manifest/nav order), `/*` serves one bundle file.
216
- one.get('/views', c => listViews(c.get('ws').path))
242
+ one.get('/views', async c =>
243
+ c.req.query('includePending') === 'true'
244
+ ? c.json({ views: await getWorkspaceViews(c.get('ws')) })
245
+ : listViews(c.get('ws').path)
246
+ )
247
+
248
+ const OWNER_VIEW = 'Use the owner workspace address for compiled views'
217
249
 
218
250
  one.patch('/views/:viewId', async c => {
219
251
  const ws = c.get('ws')
@@ -238,6 +270,7 @@ one.patch('/views/:viewId', async c => {
238
270
  throw error
239
271
  }
240
272
  }
273
+ if (ws.remote) return c.text(OWNER_VIEW, 404)
241
274
  const title = typeof body?.title === 'string' ? body.title.trim() : ''
242
275
  if (!title) return c.text('Expected { title: string }', 400)
243
276
 
@@ -262,7 +295,8 @@ one.delete('/views/:viewId', async c => {
262
295
  .map(session => session.sessionId)
263
296
  )
264
297
  await discardPendingView(ws, viewId, active)
265
- } else await deleteView(publishEvent, ws, viewId)
298
+ } else if (ws.remote) return c.text(OWNER_VIEW, 404)
299
+ else await deleteView(publishEvent, ws, viewId)
266
300
  return c.body(null, 204)
267
301
  } catch (error) {
268
302
  if (error instanceof ViewMutationError || error instanceof PendingViewError)
@@ -275,7 +309,7 @@ one.get('/views/*', c => {
275
309
  const ws = c.get('ws')
276
310
  const { name, file } = parseAppletTail(c.req.url, ws.id, 'views')
277
311
  if (!name) return c.text('Not found', 404)
278
- return serveView(name, file, ws.path, apiBaseFor(ws.id), c.req.header('if-none-match'))
312
+ return serveView(name, file, ws.path, workspaceApiBase(ws.id), c.req.header('if-none-match'))
279
313
  })
280
314
 
281
315
  one.post('/views', async c => {
@@ -289,7 +323,6 @@ one.post('/views/:viewId/submit', async c => {
289
323
  requirements?: string
290
324
  sessionId?: string
291
325
  optimisticId?: string
292
- selectedSessionScope?: SelectedSessionScope
293
326
  model?: string
294
327
  effort?: string
295
328
  speedMode?: SpeedMode
@@ -302,13 +335,6 @@ one.post('/views/:viewId/submit', async c => {
302
335
  if (body.optimisticId !== undefined && typeof body.optimisticId !== 'string') {
303
336
  return c.text('Invalid optimisticId', 400)
304
337
  }
305
- if (
306
- body.selectedSessionScope !== undefined &&
307
- body.selectedSessionScope !== 'shared' &&
308
- body.selectedSessionScope !== 'browser-tab'
309
- ) {
310
- return c.text('Invalid selectedSessionScope', 400)
311
- }
312
338
  const attachments = body.attachments ?? []
313
339
  if (!isMessageAttachments(attachments)) return c.text('Invalid attachments', 400)
314
340
  for (const attachment of attachments) {
@@ -317,13 +343,12 @@ one.post('/views/:viewId/submit', async c => {
317
343
  if (!getUpload(ws.id, attachment.uploadId))
318
344
  return c.text('Attachment not found or expired', 400)
319
345
  }
320
- const availability = await workspaceTypeAvailability(ws.type ?? 'claude-code')
346
+ const availability = await harnessTypeAvailability(ws.harness ?? 'claude-code')
321
347
  if (availability.status !== 'available') return c.text(availability.reason, 400)
322
348
  try {
323
349
  const result = await submitView(ws, c.req.param('viewId'), {
324
350
  requirements: body.requirements,
325
351
  sessionId: typeof body.sessionId === 'string' ? body.sessionId : undefined,
326
- selectedSessionScope: body.selectedSessionScope,
327
352
  attachments,
328
353
  optimisticId: body.optimisticId,
329
354
  model: typeof body.model === 'string' ? body.model : undefined,
@@ -347,7 +372,7 @@ one.post('/views/:viewId/submit', async c => {
347
372
  // localhost binding is NOT the guard.
348
373
  one.get('/files/*', c => {
349
374
  const ws = c.get('ws')
350
- const tail = new URL(c.req.url).pathname.split(`/api/workspaces/${ws.id}/files/`)[1] ?? ''
375
+ const tail = new URL(c.req.url).pathname.split(`${workspaceApiBase(ws.id)}/files/`)[1] ?? ''
351
376
  return serveWorkspaceFile(ws.path, tail, c.req.header('range'), c.req.header('if-none-match'))
352
377
  })
353
378
 
@@ -356,7 +381,7 @@ one.get('/files/*', c => {
356
381
  // `…/rpc/<module>/<fn>`.
357
382
  one.post('/rpc/*', c => {
358
383
  const ws = c.get('ws')
359
- const tail = new URL(c.req.url).pathname.split(`/api/workspaces/${ws.id}/rpc/`)[1] ?? ''
384
+ const tail = new URL(c.req.url).pathname.split(`${workspaceApiBase(ws.id)}/rpc/`)[1] ?? ''
360
385
  return handleFunctionCall(c.req.raw, tail, ws.path)
361
386
  })
362
387
 
@@ -412,7 +437,7 @@ one.post('/applet-log', async c => {
412
437
  // images only, resized server-side (see server/workspaces/preview.ts).
413
438
  one.get('/preview/*', c => {
414
439
  const ws = c.get('ws')
415
- const tail = new URL(c.req.url).pathname.split(`/api/workspaces/${ws.id}/preview/`)[1] ?? ''
440
+ const tail = new URL(c.req.url).pathname.split(`${workspaceApiBase(ws.id)}/preview/`)[1] ?? ''
416
441
  return serveWorkspaceImagePreview(ws.path, tail, c.req.header('if-none-match'))
417
442
  })
418
443
 
@@ -559,7 +584,7 @@ one.delete('/sessions/:sessionId/selection', async c => {
559
584
  })
560
585
 
561
586
  // Change run settings. Omitted fields stay; null clears one.
562
- one.patch('/sessions/:sessionId/config', async c => {
587
+ one.on('PATCH', ['/sessions/:sessionId/config', '/state/chat-defaults'], async c => {
563
588
  const body = await c.req.json().catch(() => null)
564
589
  if (typeof body !== 'object' || body === null) {
565
590
  return c.text('Expected a JSON object', 400)
@@ -651,7 +676,7 @@ one.get('/harness/debug', async c => {
651
676
  const sinceWire = Number(c.req.query('sinceWire') ?? 0) || 0
652
677
  const sinceBroadcast = Number(c.req.query('sinceBroadcast') ?? 0) || 0
653
678
  return c.json({
654
- provider: harness.id,
679
+ harness: harness.id,
655
680
  process: (await harness.debugInfo?.(ws)) ?? null,
656
681
  wire: getWireLog(harness.wireScope?.(ws) ?? ws.id, sinceWire),
657
682
  broadcasts: getClientFrameLog(ws.id, sinceBroadcast)
@@ -691,12 +716,12 @@ one.put('/env', async c => {
691
716
 
692
717
  one.get('/skills', async c => {
693
718
  const ws = c.get('ws')
694
- return c.json(await getWorkspaceSkillsStatus(ws.path, ws.type))
719
+ return c.json(await getWorkspaceSkillsStatus(ws.path, ws.harness))
695
720
  })
696
721
 
697
722
  one.post('/skills/update', async c => {
698
723
  const ws = c.get('ws')
699
- const result = await updateWorkspaceSkills(ws.path, ws.type ?? 'claude-code')
724
+ const result = await updateWorkspaceSkills(ws.path, ws.harness ?? 'claude-code')
700
725
  return c.json(result.status)
701
726
  })
702
727
 
@@ -706,7 +731,7 @@ one.get('/harness', async c => {
706
731
  const ws = c.get('ws')
707
732
  const harness = harnessFor(ws)
708
733
  const capabilities = {
709
- provider: harness.id,
734
+ harness: harness.id,
710
735
  supportsStreaming: harness.capabilities.supportsStreaming,
711
736
  supportsArchiving: Boolean(harness.archiveSession)
712
737
  }
@@ -779,7 +804,7 @@ one.put('/config', async c => {
779
804
  return c.text('Expected a workspace config field', 400)
780
805
  }
781
806
  await setWorkspaceConfig(ws.path, { name, icon })
782
- publishEvent({ type: 'workspace:updated', origin: eventOrigin(body.origin) })
807
+ publishEvent({ type: 'workspace:updated', workspaceId: ws.id, origin: eventOrigin(body.origin) })
783
808
  return c.json(await getWorkspaceConfig(ws.path))
784
809
  })
785
810
 
@@ -789,6 +814,24 @@ one.put('/config', async c => {
789
814
  // `origin` is the writing tab's id — echoed in the broadcast so that tab can
790
815
  // ignore its own save. This is the browser's write path; the agent's draws are
791
816
  // written server-side (see server/scratchpad/executor.ts). See docs/moi-scratchpad.md.
817
+ one.post('/scratchpad/ops', async c => {
818
+ try {
819
+ const form = await c.req.formData()
820
+ const op = JSON.parse(String(form.get('op'))) as ScratchOp | null
821
+ if (!op || typeof op.kind !== 'string') return c.text('Invalid scratchpad edit', 400)
822
+ let imageBytes: Uint8Array | undefined
823
+ if (op.kind === 'add-image') {
824
+ const image = form.get('image')
825
+ if (!(image instanceof File)) return c.text('Image file is required', 400)
826
+ imageBytes = new Uint8Array(await image.arrayBuffer())
827
+ }
828
+ const ws = c.get('ws')
829
+ return c.json(await executeScratchOp(ws.path, ws.id, op, imageBytes))
830
+ } catch (error) {
831
+ return c.text(error instanceof Error ? error.message : 'Scratchpad edit failed', 400)
832
+ }
833
+ })
834
+
792
835
  one.get('/scratchpad', async c => {
793
836
  return c.json(await loadScratchpadDoc(c.get('ws').path))
794
837
  })
@@ -860,13 +903,13 @@ one.put('/icon', async c => {
860
903
  }
861
904
  const workspaceIcon = { type: 'upload', value: icon } as const
862
905
  await setWorkspaceConfig(ws.path, { icon: workspaceIcon })
863
- publishEvent({ type: 'workspace:updated' })
906
+ publishEvent({ type: 'workspace:updated', workspaceId: c.get('ws').id })
864
907
  return c.json({ icon: workspaceIcon })
865
908
  })
866
909
 
867
910
  one.delete('/icon', async c => {
868
911
  await setWorkspaceConfig(c.get('ws').path, { icon: null })
869
- publishEvent({ type: 'workspace:updated' })
912
+ publishEvent({ type: 'workspace:updated', workspaceId: c.get('ws').id })
870
913
  return c.body(null, 204)
871
914
  })
872
915
 
@@ -875,15 +918,31 @@ one.delete('/icon', async c => {
875
918
  // DELETE unregisters.
876
919
  one.get('/', async c => {
877
920
  const ws = c.get('ws')
878
- const layout = await loadLayout(ws.path)
921
+ const config = await loadWorkspaceFileConfig(ws.path)
922
+ if (config.remote) {
923
+ return c.json({
924
+ version: 2,
925
+ remote: config.remote,
926
+ apiBase: workspaceApiBase(config.remote.workspace_id, config.remote.user_id),
927
+ isRemote: true,
928
+ cwd: ws.path,
929
+ // The agent belongs to this visitor, not to the owner's workspace.
930
+ harness: ws.harness,
931
+ agentId: ws.agentId
932
+ } satisfies WorkspaceInfoResponse)
933
+ }
934
+
935
+ const layout = config
879
936
  return c.json({
880
937
  ...layout,
938
+ apiBase: workspaceApiBase(ws.id),
939
+ isRemote: false,
881
940
  // Resolved display name: the settings override, or the folder name.
882
941
  name: layout.name || basename(ws.path),
883
942
  cwd: ws.path,
884
- provider: ws.type,
943
+ harness: ws.harness,
885
944
  agentId: ws.agentId
886
- })
945
+ } satisfies WorkspaceInfoResponse)
887
946
  })
888
947
 
889
948
  // Thumbnail freshness records, without image bytes — the capture hook compares
@@ -935,25 +994,26 @@ one.put('/applet-thumbnails', async c => {
935
994
 
936
995
  one.put('/', async c => {
937
996
  const ws = c.get('ws')
997
+ if (ws.remote) {
998
+ return c.text(
999
+ 'Remote references contain only the owner address; save shared content to the owner',
1000
+ 403
1001
+ )
1002
+ }
938
1003
  const body = await c.req.json()
939
- if (!body || body.version !== 1) return c.text('Bad request', 400)
1004
+ if (!body || body.version !== 2) return c.text('Bad request', 400)
940
1005
  // `origin` is the writing tab's id, echoed so that tab skips its own event.
941
- const { origin, harness, ...layout } = body
942
- // Preserve server-owned identity (name/icon) across a grid/theme save so the
943
- // client's PUT can't erase a `moi config`-set name. See mergeLayoutForSave.
1006
+ const { origin } = body
1007
+ // Only widgets and theme are taken from the body, so a grid/theme save can't
1008
+ // erase a `moi config`-set name or icon. See mergeLayoutForSave.
944
1009
  const existing = await loadLayout(ws.path)
945
- const next = mergeLayoutForSave(existing, layout)
946
- if (harness !== undefined && harness !== (ws.type ?? 'claude-code')) {
947
- next.selectedModel = existing.selectedModel
948
- next.selectedEffort = existing.selectedEffort
949
- next.selectedSpeedMode = existing.selectedSpeedMode
950
- }
1010
+ const next = mergeLayoutForSave(existing, body)
951
1011
  await saveLayout(next, ws.path)
952
1012
  if (
953
1013
  JSON.stringify(resolveWorkspaceTheme(existing.theme)) !==
954
1014
  JSON.stringify(resolveWorkspaceTheme(next.theme))
955
1015
  ) {
956
- publishEvent({ type: 'theme:updated', origin: eventOrigin(origin) })
1016
+ publishEvent({ type: 'theme:updated', workspaceId: ws.id, origin: eventOrigin(origin) })
957
1017
  }
958
1018
  return c.body(null, 204)
959
1019
  })
@@ -970,10 +1030,20 @@ one.delete('/', async c => {
970
1030
  // ---- workspace collection: /api/workspaces ----------------------------------
971
1031
  const workspaces = new Hono<ApiEnv>()
972
1032
 
1033
+ // Standalone Moi lists local workspaces only; remote references need Cloud.
1034
+ function visibleWorkspaces(entries: WorkspaceEntry[]) {
1035
+ return getAppConfig().environment === 'cloud' ? entries : entries.filter(entry => !entry.remote)
1036
+ }
1037
+
973
1038
  async function mergeWorkspaceList(entries: WorkspaceEntry[]) {
974
1039
  return Promise.all(
975
1040
  entries.map(async e => {
976
- const layout = await loadLayout(e.path)
1041
+ const layout = await loadWorkspaceFileConfig(e.path).catch(() => null)
1042
+ if (!layout) return e
1043
+ if (layout.remote) {
1044
+ return { ...e, remote: layout.remote, name: layout.remote.workspace_id }
1045
+ }
1046
+
977
1047
  return {
978
1048
  ...e,
979
1049
  name: layout.name ?? e.name,
@@ -988,7 +1058,7 @@ workspaces.get('/', async c => {
988
1058
  // Merge each workspace's live identity and theme over the registry snapshot
989
1059
  // so app-wide workspace lists render the same presentation as the workspace.
990
1060
  const entries = await listWorkspaces()
991
- return c.json(await mergeWorkspaceList(entries))
1061
+ return c.json(await mergeWorkspaceList(visibleWorkspaces(entries)))
992
1062
  })
993
1063
 
994
1064
  workspaces.put('/order', async c => {
@@ -997,12 +1067,16 @@ workspaces.put('/order', async c => {
997
1067
  return c.text('Expected { ids: string[] }', 400)
998
1068
  }
999
1069
  try {
1000
- const entries = await reorderWorkspaces(body.ids)
1070
+ // Hidden remote references keep their place after the visible ones.
1071
+ const all = await listWorkspaces()
1072
+ const visible = new Set(visibleWorkspaces(all).map(entry => entry.id))
1073
+ const hiddenIds = all.filter(entry => !visible.has(entry.id)).map(entry => entry.id)
1074
+ const entries = await reorderWorkspaces([...body.ids, ...hiddenIds])
1001
1075
  // List-only change: a narrow event so clients refetch just the sidebar
1002
1076
  // list, not every per-workspace query (`workspace:updated` also triggers
1003
1077
  // layout refetches in open workspaces).
1004
1078
  publishEvent({ type: 'workspaces-list:updated', origin: eventOrigin(body.origin) })
1005
- return c.json(await mergeWorkspaceList(entries))
1079
+ return c.json(await mergeWorkspaceList(visibleWorkspaces(entries)))
1006
1080
  } catch (err) {
1007
1081
  const message = err instanceof Error ? err.message : String(err)
1008
1082
  return c.text(message, 400)
@@ -1017,17 +1091,43 @@ const DEMO_CREATE_BLOCKED = 'Workspace creation is not available in the Moi demo
1017
1091
 
1018
1092
  workspaces.post('/', async c => {
1019
1093
  if (getAppConfig().demo) return c.text(DEMO_CREATE_BLOCKED, 403)
1020
- const body = await c.req.json()
1094
+ const body = await c.req.json().catch(() => null)
1095
+ if (body && typeof body === 'object' && 'remote' in body) {
1096
+ if (getAppConfig().environment !== 'cloud')
1097
+ return c.text('Shared workspaces require Cloud mode', 403)
1098
+ if (Object.keys(body).some(key => key !== 'remote' && key !== 'harness'))
1099
+ return c.text('Remote registration expects only remote and harness', 400)
1100
+ let remote
1101
+ try {
1102
+ remote = parseRemoteWorkspaceTarget(body.remote)
1103
+ } catch (error) {
1104
+ return c.text(error instanceof Error ? error.message : 'Invalid remote workspace', 400)
1105
+ }
1106
+ // The visitor's own agent. Omitted, the reference falls back to the same
1107
+ // default as any other workspace without a stored harness.
1108
+ const requested: unknown = body.harness
1109
+ if (requested !== undefined) {
1110
+ if (requested !== 'claude-code' && requested !== 'codex')
1111
+ return c.text('Unknown workspace type', 400)
1112
+ const availability = await harnessTypeAvailability(requested)
1113
+ if (availability.status !== 'available') return c.text(availability.reason, 400)
1114
+ }
1115
+ try {
1116
+ return c.json(await openSharedWorkspace(remote, requested), 201)
1117
+ } catch (error) {
1118
+ return c.text(error instanceof Error ? error.message : 'Could not open shared workspace', 503)
1119
+ }
1120
+ }
1021
1121
  if (!body?.path) return c.text('Missing path', 400)
1022
- const requestedType: unknown = body?.type ?? 'claude-code'
1023
- if (!isHarnessType(requestedType)) return c.text('Unknown workspace type', 400)
1024
- const type: WorkspaceType = requestedType
1025
- const availability = await workspaceTypeAvailability(type)
1122
+ const requestedHarness: unknown = body?.harness ?? 'claude-code'
1123
+ if (!isHarnessType(requestedHarness)) return c.text('Unknown workspace type', 400)
1124
+ const harness: HarnessType = requestedHarness
1125
+ const availability = await harnessTypeAvailability(harness)
1026
1126
  if (availability.status !== 'available') return c.text(availability.reason, 400)
1027
1127
  const path = resolve(String(body.path))
1028
1128
  let metadata: WorkspaceImportMetadata
1029
1129
  try {
1030
- metadata = await resolveWorkspaceImportMetadata(path, type)
1130
+ metadata = await resolveWorkspaceImportMetadata(path, harness)
1031
1131
  } catch (err) {
1032
1132
  const message = err instanceof Error ? err.message : String(err)
1033
1133
  return c.text(message, 400)
@@ -1036,16 +1136,16 @@ workspaces.post('/', async c => {
1036
1136
  // skills dir) and the `.moi/` scaffold, exactly like `moi init` — a workspace
1037
1137
  // added from the UI must be indistinguishable from one added via the CLI.
1038
1138
  try {
1039
- await provisionWorkspace(path, type)
1139
+ await provisionWorkspace(path, harness)
1040
1140
  } catch (err) {
1041
1141
  const message = err instanceof Error ? err.message : String(err)
1042
1142
  return c.text(`Could not initialize workspace: ${message}`, 500)
1043
1143
  }
1044
1144
  const entry = await registerWorkspace(path, {
1045
- type,
1145
+ harness,
1046
1146
  ...metadata
1047
1147
  })
1048
- return c.json(entry, 201)
1148
+ return c.json((await mergeWorkspaceList([entry]))[0], 201)
1049
1149
  })
1050
1150
 
1051
1151
  workspaces.get('/discover', async c => c.json(await discoverWorkspaces()))
@@ -1056,9 +1156,11 @@ workspaces.get('/previews', async c => {
1056
1156
  const entries = await listWorkspaces()
1057
1157
  const previews = await Promise.all(
1058
1158
  entries.map(async ws => {
1159
+ // A remote reference has no local content to preview.
1160
+ if (ws.remote) return [ws.id, { thumbnails: [] }] as const
1059
1161
  const views = await listCompiledViews(ws.path).catch(() => [])
1060
1162
  const preview = await getWorkspacePreview(ws.path, {
1061
- getProviderPreview: includeFirstUserMessage =>
1163
+ getHarnessPreview: includeFirstUserMessage =>
1062
1164
  harnessFor(ws).workspacePreview(ws, includeFirstUserMessage),
1063
1165
  viewIds: views.map(view => view.id),
1064
1166
  // Capture time in base36 keeps the versioned segment short and URL-safe.
@@ -1073,10 +1175,10 @@ workspaces.get('/previews', async c => {
1073
1175
 
1074
1176
  // Backends the create dialog can provision from scratch. OpenClaw workspaces
1075
1177
  // belong to their agents and arrive via discovery.
1076
- const CREATABLE_TYPES = new Set<WorkspaceType>(['claude-code', 'codex'])
1178
+ const CREATABLE_HARNESSES = new Set<HarnessType>(['claude-code', 'codex'])
1077
1179
 
1078
- async function workspaceTypeAvailability(type: WorkspaceType): Promise<HarnessAvailability> {
1079
- return (await harnessFor(type).availability?.()) ?? { status: 'available' }
1180
+ async function harnessTypeAvailability(harness: HarnessType): Promise<HarnessAvailability> {
1181
+ return (await harnessFor(harness).availability?.()) ?? { status: 'available' }
1080
1182
  }
1081
1183
 
1082
1184
  // Create a brand-new workspace: a fresh folder under createdWorkspacesRoot(),
@@ -1084,15 +1186,15 @@ async function workspaceTypeAvailability(type: WorkspaceType): Promise<HarnessAv
1084
1186
  workspaces.post('/create', async c => {
1085
1187
  if (getAppConfig().demo) return c.text(DEMO_CREATE_BLOCKED, 403)
1086
1188
  const body = await c.req.json()
1087
- const requestedType: unknown = body?.type ?? 'claude-code'
1088
- if (!isHarnessType(requestedType)) {
1189
+ const requestedHarness: unknown = body?.harness ?? 'claude-code'
1190
+ if (!isHarnessType(requestedHarness)) {
1089
1191
  return c.text('Unknown workspace type', 400)
1090
1192
  }
1091
- const type: WorkspaceType = requestedType
1092
- if (!CREATABLE_TYPES.has(type)) {
1193
+ const harness: HarnessType = requestedHarness
1194
+ if (!CREATABLE_HARNESSES.has(harness)) {
1093
1195
  return c.text('Workspaces of this type arrive through discovery, not creation', 400)
1094
1196
  }
1095
- const availability = await workspaceTypeAvailability(type)
1197
+ const availability = await harnessTypeAvailability(harness)
1096
1198
  if (availability.status !== 'available') return c.text(availability.reason, 400)
1097
1199
  const name =
1098
1200
  body?.name === undefined
@@ -1104,13 +1206,13 @@ workspaces.post('/create', async c => {
1104
1206
  if (invalid) return c.text(invalid, 400)
1105
1207
  const path = await createWorkspaceDirectory(name, createdWorkspacesRoot())
1106
1208
  try {
1107
- await provisionWorkspace(path, type)
1209
+ await provisionWorkspace(path, harness)
1108
1210
  } catch (err) {
1109
1211
  const message = err instanceof Error ? err.message : String(err)
1110
1212
  return c.text(`Could not create workspace: ${message}`, 500)
1111
1213
  }
1112
1214
  await setWorkspaceConfig(path, { name })
1113
- const entry = await registerWorkspace(path, { id: basename(path), type, name })
1215
+ const entry = await registerWorkspace(path, { id: basename(path), harness, name })
1114
1216
  // Nudge every connected client (the sidebar list) to refetch.
1115
1217
  publishEvent({ type: 'workspaces-list:updated' })
1116
1218
  return c.json(entry, 201)
@@ -182,13 +182,24 @@ export async function serveApplet(
182
182
  if (HASHED_FILE_RE.test(file)) {
183
183
  cache = { 'Cache-Control': IMMUTABLE_CACHE }
184
184
  } else {
185
- const etag = `"${bunFile.size}-${Math.trunc(bunFile.lastModified)}"`
185
+ // The served representation also depends on the API-base substitution format.
186
+ const etag = `"${bunFile.size}-${Math.trunc(bunFile.lastModified)}-${Bun.hash(apiBase)}-url-base-v2"`
186
187
  cache = { ETag: etag, 'Cache-Control': 'private, no-cache' }
187
188
  if (ifNoneMatch === etag) return new Response(null, { status: 304, headers: cache })
188
189
  }
189
190
 
190
191
  if (CODE_FILE_RE.test(file)) {
191
- const swapped = (await bunFile.text()).replaceAll(APPLET_API_BASE_SENTINEL, apiBase)
192
+ const runtimeBase = `(new URL(import.meta.url).pathname.match(/^\\/api\\/workspaces\\/[^/]+/)?.[0] ?? ${JSON.stringify(apiBase)})`
193
+ const swapped = (await bunFile.text()).replace(
194
+ /(["'])([^"'\n]*%%MOI_APPLET_API_BASE%%[^"'\n]*)\1/g,
195
+ (_match, _quote: string, value: string) =>
196
+ '(' +
197
+ value
198
+ .split(APPLET_API_BASE_SENTINEL)
199
+ .map(part => JSON.stringify(part))
200
+ .join(' + ' + runtimeBase + ' + ') +
201
+ ')'
202
+ )
192
203
  return new Response(swapped, { headers: { 'Content-Type': JS_CONTENT_TYPE, ...cache } })
193
204
  }
194
205
  return new Response(bunFile, {
@@ -200,12 +211,6 @@ export async function serveApplet(
200
211
  // Pure helpers behind the applet/files/rpc HTTP routes, kept here (not web.ts) so
201
212
  // they're unit-testable without importing web.ts — which binds ports on load.
202
213
 
203
- // The API base a served bundle's sentinel is rewritten to. RPC and workspace
204
- // file addresses resolved by `resolveUrl()` use this prefix.
205
- export function apiBaseFor(id: string): string {
206
- return `/api/workspaces/${id}`
207
- }
208
-
209
214
  // The entry's real name in the bundle dir (`.build/<kind>/<name>/index.js`).
210
215
  const ENTRY_DISK_FILE = 'index.js'
211
216
 
@@ -241,7 +246,8 @@ export function parseAppletTail(
241
246
  id: string,
242
247
  segment: 'widgets' | 'views'
243
248
  ): { name: string; file: string } {
244
- const tail = new URL(url).pathname.split(`/api/workspaces/${id}/${segment}/`)[1] ?? ''
249
+ const tail =
250
+ new URL(url).pathname.split(`/workspaces/${encodeURIComponent(id)}/${segment}/`)[1] ?? ''
245
251
  const slash = tail.indexOf('/')
246
252
  if (slash === -1) return { name: tail.replace(/\.js$/, ''), file: ENTRY_DISK_FILE }
247
253
  const file = tail.slice(slash + 1)
@@ -1,6 +1,5 @@
1
1
  import { existsSync } from 'node:fs'
2
2
 
3
- import { viewTabId } from '@/lib/workspace-tabs'
4
3
  import type { CompiledView, ViewConfig, ViewInfo, WorkspaceEntry } from '@/lib/types'
5
4
 
6
5
  import { syncAppletLogAfterBuild } from './log'
@@ -14,7 +13,6 @@ import {
14
13
  } from './'
15
14
  import { serializeWorkspaceBundle } from './bundle-queue'
16
15
  import { reloadModules } from './functions'
17
- import { loadLayout, saveLayout } from '../workspaces/layout'
18
16
  import { completeViewBuild, listPendingViews } from '../sessions/pending-views'
19
17
  import { archiveViewSessions } from '../sessions/archive'
20
18
  import type { WorkspaceRef } from '../workspace-state'
@@ -222,7 +220,7 @@ export async function handleBundleViews(
222
220
  const changedServerModules = new Set<string>()
223
221
  for (const r of results) {
224
222
  if (r.status === 'built') {
225
- publish({ type: 'view:updated', name: r.name, config: r.config ?? null })
223
+ publish({ type: 'view:updated', workspaceId, name: r.name, config: r.config ?? null })
226
224
  await completeViewBuild({ id: workspaceId, path: workspacePath }, r.name)
227
225
  for (const m of r.serverModules ?? []) changedServerModules.add(m)
228
226
  }
@@ -307,21 +305,8 @@ export async function deleteView(
307
305
  }
308
306
  reloadModules([`views/${viewId}`], workspacePath)
309
307
  await completeViewBuild(ws, viewId)
310
- const layout = await loadLayout(workspacePath)
311
- const tab = viewTabId(viewId)
312
- await saveLayout(
313
- {
314
- ...layout,
315
- tabs: {
316
- open: layout.tabs.open.filter(candidate => candidate !== tab),
317
- active: layout.tabs.active === tab ? 'overview' : layout.tabs.active
318
- }
319
- },
320
- workspacePath
321
- )
322
-
323
308
  publish({ type: 'view:deleted', workspaceId, name: viewId })
324
- publish({ type: 'workspace:updated' })
309
+ publish({ type: 'workspace:updated', workspaceId })
325
310
  await handleBundleViews(publish, workspaceId, workspacePath, false, viewId)
326
311
  })
327
312
  }
@@ -123,6 +123,7 @@ export async function listWidgets(workspacePath: string): Promise<Response> {
123
123
 
124
124
  export async function handleBundle(
125
125
  publish: (msg: unknown) => void,
126
+ workspaceId: string,
126
127
  workspacePath: string,
127
128
  force = false,
128
129
  target?: string
@@ -151,7 +152,7 @@ export async function handleBundle(
151
152
  const changedServerModules = new Set<string>()
152
153
  for (const r of results) {
153
154
  if (r.status === 'built') {
154
- publish({ type: 'widget:updated', name: r.name, config: r.config ?? null })
155
+ publish({ type: 'widget:updated', workspaceId, name: r.name, config: r.config ?? null })
155
156
  for (const m of r.serverModules ?? []) changedServerModules.add(m)
156
157
  }
157
158
  }
@@ -162,7 +163,7 @@ export async function handleBundle(
162
163
 
163
164
  if (layoutChanged) {
164
165
  const widgets = await getWidgetList(workspacePath)
165
- publish({ type: 'widget-layout:updated', widgets })
166
+ publish({ type: 'widget-layout:updated', workspaceId, widgets })
166
167
  }
167
168
 
168
169
  return results