moi-computer 0.6.1-next.0 → 0.8.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.
- package/README.md +2 -2
- package/client/components/shared/BottomPanel.tsx +2 -1
- package/client/components/shared/PanelHeader.tsx +1 -1
- package/client/features/applets/AppletMount.tsx +9 -22
- package/client/features/applets/applet-cache.ts +7 -0
- package/client/features/applets/applet-styles.ts +21 -1
- package/client/features/applets/useApplet.ts +1 -1
- package/client/features/chat/ChatComposer.tsx +18 -4
- package/client/features/chat/ChatSelector.tsx +1 -1
- package/client/features/chat/TurnView.tsx +1 -1
- package/client/features/home/api.ts +0 -10
- package/client/features/home/workspace-setup/CreateWorkspaceDialog.tsx +21 -64
- package/client/features/home/workspace-setup/ImportWorkspaceDialog.tsx +1 -1
- package/client/features/scratchpad/Scratchpad.tsx +1 -3
- package/client/features/views/ViewManager.tsx +258 -0
- package/client/features/views/view-residency.ts +77 -0
- package/client/features/widgets/WidgetFrame.tsx +6 -2
- package/client/features/workspace/CustomizePanel.tsx +40 -24
- package/client/features/workspace/WorkspaceLayoutContext.tsx +8 -0
- package/client/features/workspace/WorkspaceScreen.tsx +51 -103
- package/client/features/workspace/WorkspaceTabs.tsx +1 -1
- package/client/index.css +4 -1
- package/client/runtime/workspace-theme.ts +29 -10
- package/client/theme.css +96 -6
- package/dist/chunk-0k7brsms.js +9 -0
- package/dist/{chunk-m11ckkxd.js → chunk-dtwxpxbg.js} +1 -1
- package/dist/{chunk-55sh4dty.js → chunk-ga7t9qsk.js} +1 -1
- package/dist/{chunk-w3tnv51j.js → chunk-h9h8f176.js} +1 -1
- package/dist/{chunk-rxvx4ta9.js → chunk-r5ce5cdg.js} +2 -2
- package/dist/chunk-tey2nq7c.js +31 -0
- package/dist/{chunk-afgbg75t.js → chunk-z73xpsa0.js} +1 -1
- package/dist/chunk-zzgredta.css +1 -0
- package/dist/index.html +1 -1
- package/lib/format.ts +18 -4
- package/lib/system-messages.ts +241 -0
- package/lib/themes.ts +123 -51
- package/lib/types.ts +2 -5
- package/package.json +5 -4
- package/server/api.ts +2 -73
- package/server/bundler/build-applet.ts +7 -4
- package/server/cli.ts +46 -15
- package/server/control.ts +13 -6
- package/server/harness/README.md +11 -0
- package/server/harness/claude-code/NOTES.md +22 -7
- package/server/harness/claude-code/adapter.ts +39 -5
- package/server/moi-scaffold.ts +1 -1
- package/server/registry.ts +0 -20
- package/server/scratchpad-executor.ts +23 -1
- package/server/theme.ts +24 -27
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +94 -57
- package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -12
- package/dist/chunk-175bm057.js +0 -27
- package/dist/chunk-agtetn7n.css +0 -1
- package/dist/chunk-exj6hr30.js +0 -9
package/server/api.ts
CHANGED
|
@@ -36,7 +36,6 @@ import { getClientFrameLog, getWireLog } from './harness/debug'
|
|
|
36
36
|
import { allHarnesses, harnessFor, isHarnessType } from './harness/registry'
|
|
37
37
|
import { broadcast } from './state'
|
|
38
38
|
import {
|
|
39
|
-
discoverWorkspace,
|
|
40
39
|
discoverWorkspaces,
|
|
41
40
|
getWorkspace,
|
|
42
41
|
listWorkspaces,
|
|
@@ -933,14 +932,12 @@ async function harnessAvailability(): Promise<Record<string, HarnessAvailability
|
|
|
933
932
|
}
|
|
934
933
|
|
|
935
934
|
// Where `/workspace/create` places new folders — the client shows the resolved
|
|
936
|
-
// location while the user types a name. `
|
|
937
|
-
//
|
|
938
|
-
// lets the dialog disable backends whose runtime is missing.
|
|
935
|
+
// location while the user types a name. `availability` lets the dialog disable
|
|
936
|
+
// backends whose runtime is missing.
|
|
939
937
|
workspaces.get('/create', async c =>
|
|
940
938
|
c.json({
|
|
941
939
|
root: CREATED_WORKSPACES_ROOT,
|
|
942
940
|
displayRoot: tildify(CREATED_WORKSPACES_ROOT),
|
|
943
|
-
canChooseFolder: process.platform === 'darwin',
|
|
944
941
|
availability: await harnessAvailability()
|
|
945
942
|
})
|
|
946
943
|
)
|
|
@@ -976,74 +973,6 @@ workspaces.post('/create', async c => {
|
|
|
976
973
|
return c.json(entry, 201)
|
|
977
974
|
})
|
|
978
975
|
|
|
979
|
-
// Guards against opening a second native picker while one is already up — a
|
|
980
|
-
// duplicate request (e.g. a quick re-click) resolves as canceled instead of
|
|
981
|
-
// spawning a second Finder dialog on top of the first.
|
|
982
|
-
let folderPickerOpen = false
|
|
983
|
-
|
|
984
|
-
export function isSameOriginRequest(req: Request): boolean {
|
|
985
|
-
const site = req.headers.get('sec-fetch-site')
|
|
986
|
-
if (site === 'cross-site') return false
|
|
987
|
-
// Modern browsers state the relationship directly — trust it. Reaching the
|
|
988
|
-
// Origin fallback below with a full-origin comparison would 403 every request
|
|
989
|
-
// behind a TLS-terminating proxy (Cloudflare Tunnel, nginx, ngrok — see
|
|
990
|
-
// client/lib/ws-url.ts): the browser sends `https://…` while `req.url` is
|
|
991
|
-
// built from the plain-HTTP listener.
|
|
992
|
-
if (site === 'same-origin') return true
|
|
993
|
-
const origin = req.headers.get('origin')
|
|
994
|
-
if (!origin) return true
|
|
995
|
-
// Older browsers without sec-fetch-site: compare hosts only, since the
|
|
996
|
-
// scheme the browser saw is unknowable behind TLS termination.
|
|
997
|
-
try {
|
|
998
|
-
return new URL(origin).host === new URL(req.url).host
|
|
999
|
-
} catch {
|
|
1000
|
-
return false
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
// Open the OS-native folder picker so the user can choose an existing folder to
|
|
1005
|
-
// import (the create dialog's "Use existing folder"). The server runs on the
|
|
1006
|
-
// user's machine, so it can drive the real system dialog — the browser can't.
|
|
1007
|
-
// Returns the same grouped provider discovery shape as `/discover`, or
|
|
1008
|
-
// `{ canceled: true }` if the dialog is dismissed. macOS only for now.
|
|
1009
|
-
workspaces.post('/choose-folder', async c => {
|
|
1010
|
-
if (!isSameOriginRequest(c.req.raw)) return c.text('Forbidden', 403)
|
|
1011
|
-
if (process.platform !== 'darwin') {
|
|
1012
|
-
return c.text('Choosing a folder is only supported on macOS for now', 400)
|
|
1013
|
-
}
|
|
1014
|
-
if (folderPickerOpen) return c.json({ canceled: true })
|
|
1015
|
-
folderPickerOpen = true
|
|
1016
|
-
try {
|
|
1017
|
-
// The picker is spawned by osascript, a background helper, so macOS won't
|
|
1018
|
-
// give it focus by default. `tell me to activate` forces the script runner
|
|
1019
|
-
// frontmost, and the short delay lets that settle before the panel opens so
|
|
1020
|
-
// it appears focused rather than behind other windows.
|
|
1021
|
-
const proc = Bun.spawn(
|
|
1022
|
-
[
|
|
1023
|
-
'osascript',
|
|
1024
|
-
'-e',
|
|
1025
|
-
'tell me to activate',
|
|
1026
|
-
'-e',
|
|
1027
|
-
'delay 0.2',
|
|
1028
|
-
'-e',
|
|
1029
|
-
'POSIX path of (choose folder with prompt "Select a project folder")'
|
|
1030
|
-
],
|
|
1031
|
-
{ stdout: 'pipe', stderr: 'pipe' }
|
|
1032
|
-
)
|
|
1033
|
-
const exitCode = await proc.exited
|
|
1034
|
-
// osascript exits non-zero when the user presses Cancel.
|
|
1035
|
-
if (exitCode !== 0) return c.json({ canceled: true })
|
|
1036
|
-
const path = (await new Response(proc.stdout).text()).trim()
|
|
1037
|
-
if (!path) return c.json({ canceled: true })
|
|
1038
|
-
return c.json(await discoverWorkspace(path))
|
|
1039
|
-
} catch (err) {
|
|
1040
|
-
const message = err instanceof Error ? err.message : String(err)
|
|
1041
|
-
return c.text(`Could not open the folder picker: ${message}`, 500)
|
|
1042
|
-
} finally {
|
|
1043
|
-
folderPickerOpen = false
|
|
1044
|
-
}
|
|
1045
|
-
})
|
|
1046
|
-
|
|
1047
976
|
// `/:id` is registered after the static `/discover` so the literal path wins.
|
|
1048
977
|
// `/api/workspaces/ws` (the live-event WebSocket) is intercepted by Bun's routes
|
|
1049
978
|
// table before it ever reaches Hono, so it never collides with `:id`.
|
|
@@ -415,12 +415,11 @@ function appletRuntimePlugin(
|
|
|
415
415
|
return { plugin, serverModules, assets }
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
//
|
|
419
|
-
//
|
|
420
|
-
// theme tokens.
|
|
418
|
+
// Shared Tailwind input for applet bundles. It maps semantic tokens and
|
|
419
|
+
// provides the same texture utilities available to host components.
|
|
421
420
|
const HOST_THEME_PATH = join(import.meta.dir, '..', '..', 'client', 'theme.css')
|
|
422
421
|
|
|
423
|
-
// Three things matter for
|
|
422
|
+
// Three things matter for applet styling:
|
|
424
423
|
// 1. The umbrella `@import 'tailwindcss'` brings in @layer theme + base +
|
|
425
424
|
// utilities — which is what spacing/color utilities like `left-2.5`,
|
|
426
425
|
// `gap-1.5`, `text-amber-500` need to resolve. The split
|
|
@@ -433,6 +432,7 @@ const HOST_THEME_PATH = join(import.meta.dir, '..', '..', 'client', 'theme.css')
|
|
|
433
432
|
// means the widget's CSS does NOT redefine the underlying
|
|
434
433
|
// `--background`/`--foreground` variables — those stay host-owned and
|
|
435
434
|
// the widget picks them up from `:root` at runtime.
|
|
435
|
+
// The same shared file also defines texture utilities for both surfaces.
|
|
436
436
|
// 3. Tailwind's auto-detection treats `.moi/` as a hidden directory
|
|
437
437
|
// and skips it. An explicit `@source` bypasses the dot-dir + gitignore
|
|
438
438
|
// filters.
|
|
@@ -461,6 +461,9 @@ async function writeSyntheticTailwindCss(
|
|
|
461
461
|
// back to `@media (prefers-color-scheme: dark)`, which diverges from the
|
|
462
462
|
// host and injects OS-preference media queries into the page.
|
|
463
463
|
`@custom-variant dark (&:is(.dark *));`,
|
|
464
|
+
// Textures use their light-on-dark treatment in every widget, regardless
|
|
465
|
+
// of the widget's selected workspace color.
|
|
466
|
+
`@custom-variant dark-or-widget (&:is(.dark *, [data-widget-chrome] *));`,
|
|
464
467
|
`@source "${sourceDir}";`
|
|
465
468
|
].join('\n')
|
|
466
469
|
await Bun.write(cssPath, contents)
|
package/server/cli.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import './cli-colors' // must precede citty: sets NO_COLOR before its color flag is computed
|
|
3
3
|
import { defineCommand, runMain, showUsage } from 'citty'
|
|
4
|
+
import { formatHex } from 'culori'
|
|
4
5
|
import { parse as devalueParse } from 'devalue'
|
|
5
6
|
import { existsSync } from 'node:fs'
|
|
6
7
|
import { tmpdir } from 'node:os'
|
|
@@ -9,8 +10,14 @@ import pc from './cli-pc'
|
|
|
9
10
|
|
|
10
11
|
import { isAgentCaller } from './agent-caller'
|
|
11
12
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
13
|
+
import {
|
|
14
|
+
COLOR_THEMES,
|
|
15
|
+
DEFAULT_WORKSPACE_THEME,
|
|
16
|
+
FONT_THEMES,
|
|
17
|
+
RADIUS_THEMES,
|
|
18
|
+
deriveThemeColors
|
|
19
|
+
} from '@/lib/themes'
|
|
20
|
+
import type { ColorTheme, FontTheme, RadiusTheme } from '@/lib/themes'
|
|
14
21
|
import { isParamsRecord } from '@/lib/workspace-tabs'
|
|
15
22
|
import type {
|
|
16
23
|
AppletLogEntry,
|
|
@@ -678,9 +685,9 @@ const refresh = defineCommand({
|
|
|
678
685
|
}
|
|
679
686
|
})
|
|
680
687
|
|
|
681
|
-
function hexToRgb(
|
|
682
|
-
const
|
|
683
|
-
return [(
|
|
688
|
+
function hexToRgb(hex: string): [number, number, number] {
|
|
689
|
+
const value = Number.parseInt(hex.slice(1), 16)
|
|
690
|
+
return [(value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff]
|
|
684
691
|
}
|
|
685
692
|
|
|
686
693
|
// Truecolor swatch using raw ANSI 24-bit escapes (picocolors maxes at 8 colors).
|
|
@@ -695,11 +702,11 @@ function swatch(bg?: string, fg?: string): string {
|
|
|
695
702
|
function themeSwatch(primary?: string): string {
|
|
696
703
|
if (!primary) return swatch()
|
|
697
704
|
const colors = deriveThemeColors(primary)
|
|
698
|
-
return swatch(colors.primary, colors.primaryForeground)
|
|
705
|
+
return swatch(formatHex(colors.primary), formatHex(colors.primaryForeground))
|
|
699
706
|
}
|
|
700
707
|
|
|
701
708
|
const theme = defineCommand({
|
|
702
|
-
meta: { name: 'theme', description: 'Show or set the workspace
|
|
709
|
+
meta: { name: 'theme', description: 'Show or set the workspace appearance' },
|
|
703
710
|
args: {
|
|
704
711
|
dir: {
|
|
705
712
|
type: 'positional',
|
|
@@ -707,7 +714,8 @@ const theme = defineCommand({
|
|
|
707
714
|
description: 'Workspace directory (default: current)'
|
|
708
715
|
},
|
|
709
716
|
font: { type: 'string', description: 'Font theme key to apply' },
|
|
710
|
-
color: { type: 'string', description: 'Color preset key to apply' }
|
|
717
|
+
color: { type: 'string', description: 'Color preset key to apply' },
|
|
718
|
+
radius: { type: 'string', description: 'Radius preset key to apply' }
|
|
711
719
|
},
|
|
712
720
|
async run({ args }) {
|
|
713
721
|
const path = resolve(args.dir)
|
|
@@ -720,7 +728,8 @@ const theme = defineCommand({
|
|
|
720
728
|
type: 'theme',
|
|
721
729
|
path,
|
|
722
730
|
font: args.font ?? null,
|
|
723
|
-
color: args.color ?? null
|
|
731
|
+
color: args.color ?? null,
|
|
732
|
+
radius: args.radius ?? null
|
|
724
733
|
})
|
|
725
734
|
)
|
|
726
735
|
|
|
@@ -749,16 +758,21 @@ const theme = defineCommand({
|
|
|
749
758
|
const chip = themeSwatch(preset.primary)
|
|
750
759
|
console.log(pc.green('✓') + ' Color set to ' + pc.bold(preset.label) + ' ' + chip)
|
|
751
760
|
}
|
|
761
|
+
if (res.radius) {
|
|
762
|
+
const preset = RADIUS_THEMES[res.radius as RadiusTheme]
|
|
763
|
+
console.log(pc.green('✓') + ' Radius set to ' + pc.bold(preset.label))
|
|
764
|
+
}
|
|
752
765
|
console.log()
|
|
753
766
|
if (notice) console.log(pc.yellow(notice) + '\n')
|
|
754
767
|
ws.close()
|
|
755
768
|
process.exit(0)
|
|
756
769
|
}
|
|
757
770
|
|
|
758
|
-
const currentFont: FontTheme = res.currentFont ??
|
|
759
|
-
const currentColor: ColorTheme
|
|
771
|
+
const currentFont: FontTheme = res.currentFont ?? DEFAULT_WORKSPACE_THEME.font
|
|
772
|
+
const currentColor: ColorTheme = res.currentColor ?? DEFAULT_WORKSPACE_THEME.color
|
|
773
|
+
const currentRadius: RadiusTheme = res.currentRadius ?? DEFAULT_WORKSPACE_THEME.radius
|
|
760
774
|
console.log('\n' + pc.bold('moi theme') + ' — workspace appearance')
|
|
761
|
-
console.log(pc.dim(' Usage: moi theme --font=<key> --color=<key>') + '\n')
|
|
775
|
+
console.log(pc.dim(' Usage: moi theme --font=<key> --color=<key> --radius=<key>') + '\n')
|
|
762
776
|
|
|
763
777
|
const fontRows = (Object.keys(FONT_THEMES) as FontTheme[]).map(key => {
|
|
764
778
|
const f = FONT_THEMES[key]
|
|
@@ -768,14 +782,13 @@ const theme = defineCommand({
|
|
|
768
782
|
selected ? pc.bold(key) : key,
|
|
769
783
|
f.label,
|
|
770
784
|
pc.dim(f.sans),
|
|
771
|
-
pc.dim(f.mono)
|
|
772
|
-
pc.dim(f.feel)
|
|
785
|
+
pc.dim(f.mono)
|
|
773
786
|
]
|
|
774
787
|
})
|
|
775
788
|
console.log(pc.dim(' Fonts'))
|
|
776
789
|
console.log(
|
|
777
790
|
columns(
|
|
778
|
-
['', 'key', 'label', 'sans', 'mono'
|
|
791
|
+
['', 'key', 'label', 'sans', 'mono'].map(h => pc.dim(h)),
|
|
779
792
|
fontRows
|
|
780
793
|
) + '\n'
|
|
781
794
|
)
|
|
@@ -798,6 +811,24 @@ const theme = defineCommand({
|
|
|
798
811
|
) + '\n'
|
|
799
812
|
)
|
|
800
813
|
|
|
814
|
+
const radiusRows = (Object.keys(RADIUS_THEMES) as RadiusTheme[]).map(key => {
|
|
815
|
+
const radius = RADIUS_THEMES[key]
|
|
816
|
+
const selected = key === currentRadius
|
|
817
|
+
return [
|
|
818
|
+
selected ? pc.green('→') : ' ',
|
|
819
|
+
selected ? pc.bold(key) : key,
|
|
820
|
+
radius.label,
|
|
821
|
+
pc.dim(radius.radius)
|
|
822
|
+
]
|
|
823
|
+
})
|
|
824
|
+
console.log(pc.dim(' Radius'))
|
|
825
|
+
console.log(
|
|
826
|
+
columns(
|
|
827
|
+
['', 'key', 'label', 'value'].map(h => pc.dim(h)),
|
|
828
|
+
radiusRows
|
|
829
|
+
) + '\n'
|
|
830
|
+
)
|
|
831
|
+
|
|
801
832
|
if (notice) console.log(pc.yellow(notice) + '\n')
|
|
802
833
|
ws.close()
|
|
803
834
|
process.exit(0)
|
package/server/control.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { stringify as devalueStringify } from 'devalue'
|
|
2
2
|
import { resolve } from 'path'
|
|
3
3
|
|
|
4
|
+
import { resolveWorkspaceTheme } from '@/lib/themes'
|
|
4
5
|
import type { WorkspaceEntry } from '@/lib/types'
|
|
5
6
|
import { isParamsRecord } from '@/lib/workspace-tabs'
|
|
6
7
|
|
|
@@ -18,7 +19,7 @@ import { readScratchpadImage, readScratchpadShapes } from './scratchpad'
|
|
|
18
19
|
import { relayScratchOp } from './scratchpad-relay'
|
|
19
20
|
import { broadcastAll } from './state'
|
|
20
21
|
import { assembleTabRows, resolveFocusTab } from './tabs'
|
|
21
|
-
import { applyThemeUpdate
|
|
22
|
+
import { applyThemeUpdate } from './theme'
|
|
22
23
|
import { handleBundle } from './widgets'
|
|
23
24
|
import { getViewList, handleBundleViews, hasViewId } from './views'
|
|
24
25
|
import {
|
|
@@ -353,18 +354,24 @@ export const control = Bun.serve({
|
|
|
353
354
|
const workspacePath = match.path
|
|
354
355
|
const layout = await loadLayout(workspacePath)
|
|
355
356
|
|
|
356
|
-
// Listing mode —
|
|
357
|
-
if (!data.font && !data.color) {
|
|
357
|
+
// Listing mode — no theme setting requested
|
|
358
|
+
if (!data.font && !data.color && !data.radius) {
|
|
359
|
+
const theme = resolveWorkspaceTheme(layout.theme)
|
|
358
360
|
ws.send(
|
|
359
361
|
JSON.stringify({
|
|
360
|
-
currentFont:
|
|
361
|
-
currentColor:
|
|
362
|
+
currentFont: theme.font,
|
|
363
|
+
currentColor: theme.color,
|
|
364
|
+
currentRadius: theme.radius
|
|
362
365
|
})
|
|
363
366
|
)
|
|
364
367
|
return
|
|
365
368
|
}
|
|
366
369
|
|
|
367
|
-
const result = applyThemeUpdate(layout.theme, {
|
|
370
|
+
const result = applyThemeUpdate(layout.theme, {
|
|
371
|
+
font: data.font,
|
|
372
|
+
color: data.color,
|
|
373
|
+
radius: data.radius
|
|
374
|
+
})
|
|
368
375
|
if (!result.ok) {
|
|
369
376
|
ws.send(JSON.stringify({ error: result.error }))
|
|
370
377
|
return
|
package/server/harness/README.md
CHANGED
|
@@ -30,6 +30,17 @@ Rules: **adapters are the only code that sees layer 1** — everything above
|
|
|
30
30
|
speaks layers 2/3 only. `lib/format.ts` and `lib/types.ts` never move into
|
|
31
31
|
this folder: the client imports them; they are the shared contract.
|
|
32
32
|
|
|
33
|
+
System machinery that backends leave in user-role text (slash-command
|
|
34
|
+
records, interrupt markers, injected reminder envelopes) is classified by
|
|
35
|
+
the shared rule registry in `lib/system-messages.ts` — provider-agnostic,
|
|
36
|
+
text-level. Adapters call it when building user turns: an all-machinery
|
|
37
|
+
message keeps its raw parts but lands as `origin: synthetic` (hidden by the
|
|
38
|
+
client), embedded envelopes strip out of real text, and notify-classified
|
|
39
|
+
messages (background-task notices) are rewritten to a readable sentence and
|
|
40
|
+
surface as `origin: notification` turns. Add new patterns there, not as
|
|
41
|
+
ad-hoc regexes in an adapter. (Exception: OpenClaw's inbound-meta stripper
|
|
42
|
+
mirrors upstream code verbatim and stays in `openclaw/strip.ts`.)
|
|
43
|
+
|
|
33
44
|
Socket-protocol notes the layers rely on (all defined in `lib/types.ts`):
|
|
34
45
|
|
|
35
46
|
- **`session_renamed`** — a new thread is created under the client's temporary
|
|
@@ -135,13 +135,14 @@ Of these the repo currently handles only `tool_result`.
|
|
|
135
135
|
|
|
136
136
|
At the SDK wire level, **every tool result and every harness-injected prompt is a `user` message**, because Anthropic's Messages API has no dedicated role for them. Classify by content and flags, in this priority order:
|
|
137
137
|
|
|
138
|
-
| # | Condition | What it really is
|
|
139
|
-
| --- | -------------------------------------------------------------- |
|
|
140
|
-
| 1 | `isReplay: true` | Replay from a resumed session; not new content
|
|
141
|
-
| 2 | `content[]` contains a `tool_result` block | Tool return back to the model
|
|
142
|
-
| 3 | `isSynthetic: true` | Harness-injected context (skill body, slash-command expansion, `<system-reminder>`, hook output)
|
|
143
|
-
| 4 |
|
|
144
|
-
| 5 |
|
|
138
|
+
| # | Condition | What it really is | UI behavior |
|
|
139
|
+
| --- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
140
|
+
| 1 | `isReplay: true` | Replay from a resumed session; not new content | Skip (or render only once from the persisted log) |
|
|
141
|
+
| 2 | `content[]` contains a `tool_result` block | Tool return back to the model | Route into the paired tool-use card; may carry extra metadata in top-level `tool_use_result` |
|
|
142
|
+
| 3 | `isSynthetic: true` | Harness-injected context (skill body, slash-command expansion, `<system-reminder>`, hook output) | Transcript-only context; hide by default, expose behind a toggle |
|
|
143
|
+
| 4 | Text matches a `lib/system-messages.ts` rule (all blocks) | CLI machinery written **without** flags: slash-command records, `[Request interrupted by user]`, `<local-command-stdout>`, bash-mode I/O, compact continuations, task notifications, … | Hide rules: as #3 — keep raw parts, mark `origin: synthetic`. Notify rules (task notifications): rewrite to readable text, `origin: notification`, shown |
|
|
144
|
+
| 5 | `parent_tool_use_id !== null` AND first user turn of a subtask | The `Agent` tool's `prompt` argument being replayed as the subtask's opening user turn | Render as the subtask's prompt inside the nested view, not in the main thread |
|
|
145
|
+
| 6 | none of the above | Actual user input typed into the chat | Render as the user bubble (embedded `<system-reminder>`/hook envelopes strip out first) |
|
|
145
146
|
|
|
146
147
|
### On `isSynthetic` specifically — the docs don't say, the source does
|
|
147
148
|
|
|
@@ -156,6 +157,20 @@ So `isSynthetic = true` means: _this user turn was fabricated by the harness and
|
|
|
156
157
|
|
|
157
158
|
`isSynthetic` and `parent_tool_use_id` are **orthogonal**. A sub-agent's initial prompt (observed on line 14 of the captured log) has `parent_tool_use_id` set but `isSynthetic` absent — from the subagent's frame, that IS real user input.
|
|
158
159
|
|
|
160
|
+
### Machinery the CLI does NOT flag (row #4)
|
|
161
|
+
|
|
162
|
+
Several user entries the CLI writes for itself carry **no** `isMeta`/`isSynthetic`, so they'd render as user bubbles without text classification. Inventory (verified against the CLI binary's strings and live transcripts; the rules live in `lib/system-messages.ts`):
|
|
163
|
+
|
|
164
|
+
- `<command-name>/<command-message>/<command-args>` (+ legacy `<command-contents>`) — slash-command invocation records
|
|
165
|
+
- `<local-command-stdout>` / `<local-command-stderr>` — local command output
|
|
166
|
+
- `[Request interrupted by user]` / `[Request interrupted by user for tool use]` — abort markers; the tool-use variant rides next to the aborted `tool_result` block
|
|
167
|
+
- `<bash-input>` / `<bash-stdout>` / `<bash-stderr>` — `!command` bash mode
|
|
168
|
+
- `<user-memory-input>` — `#note` memory mode
|
|
169
|
+
- `<task-notification>` (and the cloud `[SYSTEM NOTIFICATION - NOT USER INPUT]` preamble) — background-task notices; these are the one machinery kind that SURFACES: the rule rewrites the block to its `<summary>` text and the turn lands as `origin: notification` (plain text in the flow for now, a dedicated UI block later)
|
|
170
|
+
- `Caveat: The messages below were generated by the user while running local commands.` — `isMeta` in current CLIs, unflagged in older transcripts
|
|
171
|
+
- `This session is being continued from a previous conversation that ran out of context.` — post-compaction continuation summary
|
|
172
|
+
- `<system-reminder>` / `<user-prompt-submit-hook>` — envelopes attached to real messages; stripped from the text rather than hiding the turn
|
|
173
|
+
|
|
159
174
|
---
|
|
160
175
|
|
|
161
176
|
## 5. Sub-agent invocation — the nesting mechanism
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
SessionSnapshot,
|
|
7
7
|
StreamEvent,
|
|
8
8
|
SubagentRecord,
|
|
9
|
+
SyntheticTurnReason,
|
|
9
10
|
SystemNotice,
|
|
10
11
|
ToolCall,
|
|
11
12
|
ToolCaller,
|
|
@@ -16,6 +17,7 @@ import type {
|
|
|
16
17
|
|
|
17
18
|
import { isAttachmentOnlyPlaceholder, splitAttachmentNote } from '@/lib/attachment-note'
|
|
18
19
|
import { stripMoiContext } from '@/lib/moi-context'
|
|
20
|
+
import { classifySystemMessage, filterSystemText } from '@/lib/system-messages'
|
|
19
21
|
|
|
20
22
|
// Loose SDK message shape — we don't pull in the full SDK type tree; the
|
|
21
23
|
// adapter tolerates missing fields. Reference: ./NOTES.md.
|
|
@@ -154,9 +156,9 @@ function callerFromBlockType(type: string, name: string): ToolCaller {
|
|
|
154
156
|
return 'model'
|
|
155
157
|
}
|
|
156
158
|
|
|
157
|
-
function classifySyntheticReason(
|
|
158
|
-
firstText
|
|
159
|
-
|
|
159
|
+
function classifySyntheticReason(firstText: string): SyntheticTurnReason {
|
|
160
|
+
const verdict = classifySystemMessage([firstText])
|
|
161
|
+
if (verdict?.kind === 'hide') return verdict.reason
|
|
160
162
|
if (/<system-reminder>/i.test(firstText)) return 'system-reminder'
|
|
161
163
|
return 'other'
|
|
162
164
|
}
|
|
@@ -509,19 +511,49 @@ export class ClaudeAdapter {
|
|
|
509
511
|
const parts: Part[] = []
|
|
510
512
|
let firstText = ''
|
|
511
513
|
|
|
514
|
+
// A user message whose text is entirely backend machinery (see
|
|
515
|
+
// lib/system-messages.ts). Two fates: hide-classified messages — a
|
|
516
|
+
// slash-command record, an interrupt marker — keep their raw parts but
|
|
517
|
+
// land as synthetic turns, hidden exactly like the SDK's own isSynthetic
|
|
518
|
+
// injections; notify-classified messages (task notifications) surface as
|
|
519
|
+
// readable text below. Computed for isSynthetic entries too — local CC
|
|
520
|
+
// flags task notifications isMeta, and those must still surface. Replays
|
|
521
|
+
// stay untouched so their persisted-log counterpart renders once.
|
|
522
|
+
// Text-only messages qualify; real content (attachments, images) vetoes.
|
|
523
|
+
const systemVerdict =
|
|
524
|
+
msg.type === 'user' && !msg.isReplay && blocks.every(b => b.type === 'text')
|
|
525
|
+
? classifySystemMessage(blocks.map(b => b.text ?? ''))
|
|
526
|
+
: undefined
|
|
527
|
+
|
|
528
|
+
// A notification renders as plain text in the flow: none of the bubble
|
|
529
|
+
// machinery (attachment notes, echo matching, skill stashing) applies.
|
|
530
|
+
if (systemVerdict?.kind === 'notification') {
|
|
531
|
+
return {
|
|
532
|
+
id: turnId(msg),
|
|
533
|
+
role: 'user',
|
|
534
|
+
origin: { kind: 'notification' },
|
|
535
|
+
parentTaskId: msg.parent_tool_use_id ?? undefined,
|
|
536
|
+
parts: [{ type: 'text', text: systemVerdict.text }],
|
|
537
|
+
timestamp: msg.timestamp
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
512
541
|
for (const b of blocks) {
|
|
513
542
|
switch (b.type) {
|
|
514
543
|
case 'text':
|
|
515
544
|
if (b.text) {
|
|
516
545
|
let text = b.text
|
|
517
|
-
if (msg.type === 'user' && !msg.isSynthetic) {
|
|
546
|
+
if (msg.type === 'user' && !msg.isSynthetic && !systemVerdict) {
|
|
518
547
|
// Non-image attachments reach the agent as a temp-path note
|
|
519
548
|
// appended to the user's text (see lib/attachment-note.ts). The
|
|
520
549
|
// SDK persists that appended text, so fold the note back into
|
|
521
550
|
// file chips here — a reloaded bubble matches the live one
|
|
522
551
|
// instead of leaking temp paths into it.
|
|
523
552
|
const split = splitAttachmentNote(text)
|
|
524
|
-
|
|
553
|
+
// moi's own context envelope strips precisely (marker-guarded);
|
|
554
|
+
// other embedded machinery — system reminders, hook output —
|
|
555
|
+
// strips by the shared rules, keeping the typed text.
|
|
556
|
+
text = filterSystemText(stripMoiContext(split.text)).text
|
|
525
557
|
for (const f of split.files) {
|
|
526
558
|
parts.push({
|
|
527
559
|
type: 'file',
|
|
@@ -604,6 +636,8 @@ export class ClaudeAdapter {
|
|
|
604
636
|
origin = { kind: 'replay' }
|
|
605
637
|
} else if (msg.isSynthetic) {
|
|
606
638
|
origin = { kind: 'synthetic', reason: classifySyntheticReason(firstText) }
|
|
639
|
+
} else if (systemVerdict) {
|
|
640
|
+
origin = { kind: 'synthetic', reason: systemVerdict.reason }
|
|
607
641
|
} else if (msg.parent_tool_use_id) {
|
|
608
642
|
origin = { kind: 'subagent-prompt', parentToolCallId: msg.parent_tool_use_id }
|
|
609
643
|
} else {
|
package/server/moi-scaffold.ts
CHANGED
package/server/registry.ts
CHANGED
|
@@ -173,19 +173,6 @@ export function groupDiscoveredWorkspaces(
|
|
|
173
173
|
}))
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
export function discoveredWorkspaceForPath(
|
|
177
|
-
path: string,
|
|
178
|
-
candidates: DiscoveredWorkspaceCandidate[]
|
|
179
|
-
): DiscoveredWorkspace {
|
|
180
|
-
const normalizedPath = resolve(path)
|
|
181
|
-
return (
|
|
182
|
-
groupDiscoveredWorkspaces(candidates).find(workspace => workspace.path === normalizedPath) ?? {
|
|
183
|
-
path: normalizedPath,
|
|
184
|
-
types: []
|
|
185
|
-
}
|
|
186
|
-
)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
176
|
// Ask every harness for workspaces it knows about that aren't registered yet,
|
|
190
177
|
// then combine providers that claim the same normalized folder.
|
|
191
178
|
export async function discoverWorkspaces(): Promise<DiscoveredWorkspace[]> {
|
|
@@ -193,10 +180,3 @@ export async function discoverWorkspaces(): Promise<DiscoveredWorkspace[]> {
|
|
|
193
180
|
const found = await collectDiscoveredWorkspaces(registeredPaths)
|
|
194
181
|
return groupDiscoveredWorkspaces(found, registeredPaths).map(withDisplayPath)
|
|
195
182
|
}
|
|
196
|
-
|
|
197
|
-
// Inspect one folder through the same provider discovery used by the home
|
|
198
|
-
// suggestions. An empty types list means no provider recognized the folder.
|
|
199
|
-
export async function discoverWorkspace(path: string): Promise<DiscoveredWorkspace> {
|
|
200
|
-
const found = await collectDiscoveredWorkspaces(new Set())
|
|
201
|
-
return withDisplayPath(discoveredWorkspaceForPath(path, found))
|
|
202
|
-
}
|
|
@@ -76,6 +76,26 @@ function styleProps(style: ScratchStyle): Record<string, unknown> {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
// Run a synchronous load with tldraw's own logging held back. On a failed
|
|
80
|
+
// migration `StoreSchema` prints `Error migrating store Incompatible schema?`
|
|
81
|
+
// itself, which reaches the `moi scratch` caller ahead of — and contradicting —
|
|
82
|
+
// the actionable error we throw below ("the file is intact"). Whatever it says
|
|
83
|
+
// is replayed if the load actually succeeds, so only the swallowed-by-a-throw
|
|
84
|
+
// case is lost. Safe to swap `console.error` around: `loadSnapshot` is sync.
|
|
85
|
+
function loadQuietly(load: () => void): void {
|
|
86
|
+
const original = console.error
|
|
87
|
+
const held: unknown[][] = []
|
|
88
|
+
console.error = (...args: unknown[]) => {
|
|
89
|
+
held.push(args)
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
load()
|
|
93
|
+
} finally {
|
|
94
|
+
console.error = original
|
|
95
|
+
}
|
|
96
|
+
for (const args of held) original(...args)
|
|
97
|
+
}
|
|
98
|
+
|
|
79
99
|
// A fresh headless store hydrated from the saved snapshot (or empty). The
|
|
80
100
|
// snapshot shape (`{ document }`) matches what the browser PUTs and loads.
|
|
81
101
|
// A failed load is inspected for version skew: tldraw has no down-migrations,
|
|
@@ -86,7 +106,9 @@ function buildStore(doc: ScratchpadDoc | null, writer: ScratchpadWriter | undefi
|
|
|
86
106
|
const store = createTLStore({ shapeUtils: defaultShapeUtils, bindingUtils: defaultBindingUtils })
|
|
87
107
|
if (doc?.store) {
|
|
88
108
|
try {
|
|
89
|
-
|
|
109
|
+
loadQuietly(() =>
|
|
110
|
+
loadSnapshot(store, { document: doc } as unknown as Parameters<typeof loadSnapshot>[1])
|
|
111
|
+
)
|
|
90
112
|
} catch (err) {
|
|
91
113
|
const ahead = sequencesAhead(doc.schema, store.schema.serialize().sequences)
|
|
92
114
|
if (ahead.length > 0) {
|
package/server/theme.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { COLOR_THEMES, FONT_THEMES } from '@/lib/themes'
|
|
2
|
-
import type { ColorTheme, FontTheme,
|
|
1
|
+
import { COLOR_THEMES, FONT_THEMES, RADIUS_THEMES, resolveWorkspaceTheme } from '@/lib/themes'
|
|
2
|
+
import type { ColorTheme, FontTheme, RadiusTheme, WorkspaceTheme } from '@/lib/types'
|
|
3
3
|
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
export type ThemeUpdate = { font?: string; color?: string }
|
|
4
|
+
export type ThemeUpdate = { font?: string; color?: string; radius?: string }
|
|
7
5
|
export type ThemeUpdateResult =
|
|
8
|
-
| {
|
|
6
|
+
| {
|
|
7
|
+
ok: true
|
|
8
|
+
theme: WorkspaceTheme
|
|
9
|
+
applied: Partial<WorkspaceTheme>
|
|
10
|
+
}
|
|
9
11
|
| { ok: false; error: string }
|
|
10
12
|
|
|
11
|
-
// Pure merge + validation for a theme update. The workspace stores only the
|
|
12
|
-
// selected font and primary; all other color tokens are derived at runtime.
|
|
13
13
|
export function applyThemeUpdate(
|
|
14
|
-
current:
|
|
14
|
+
current: WorkspaceTheme | undefined,
|
|
15
15
|
update: ThemeUpdate
|
|
16
16
|
): ThemeUpdateResult {
|
|
17
17
|
if (update.font && !(update.font in FONT_THEMES)) {
|
|
@@ -20,30 +20,27 @@ export function applyThemeUpdate(
|
|
|
20
20
|
if (update.color && !(update.color in COLOR_THEMES)) {
|
|
21
21
|
return { ok: false, error: `Unknown color theme: ${update.color}` }
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const theme: ThemeShape = {
|
|
26
|
-
font: (update.font as FontTheme) ?? current?.font ?? 'default',
|
|
27
|
-
...(primary ? { primary } : {})
|
|
23
|
+
if (update.radius && !(update.radius in RADIUS_THEMES)) {
|
|
24
|
+
return { ok: false, error: `Unknown radius theme: ${update.radius}` }
|
|
28
25
|
}
|
|
29
26
|
|
|
27
|
+
const font = update.font as FontTheme | undefined
|
|
28
|
+
const color = update.color as ColorTheme | undefined
|
|
29
|
+
const radius = update.radius as RadiusTheme | undefined
|
|
30
|
+
const theme = resolveWorkspaceTheme({
|
|
31
|
+
...current,
|
|
32
|
+
...(font ? { font } : {}),
|
|
33
|
+
...(color ? { color } : {}),
|
|
34
|
+
...(radius ? { radius } : {})
|
|
35
|
+
})
|
|
36
|
+
|
|
30
37
|
return {
|
|
31
38
|
ok: true,
|
|
32
39
|
theme,
|
|
33
40
|
applied: {
|
|
34
|
-
...(
|
|
35
|
-
...(
|
|
41
|
+
...(font ? { font } : {}),
|
|
42
|
+
...(color ? { color } : {}),
|
|
43
|
+
...(radius ? { radius } : {})
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
// Reverse-lookup: resolve the stored primary to a preset key, or null for custom colors.
|
|
41
|
-
export function matchColorTheme(primary: string | undefined): ColorTheme | null {
|
|
42
|
-
for (const [key, preset] of Object.entries(COLOR_THEMES) as [
|
|
43
|
-
ColorTheme,
|
|
44
|
-
(typeof COLOR_THEMES)[ColorTheme]
|
|
45
|
-
][]) {
|
|
46
|
-
if (preset.primary === primary) return key
|
|
47
|
-
}
|
|
48
|
-
return null
|
|
49
|
-
}
|