moi-computer 0.10.1-next.4 → 0.10.1-next.6
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 -0
- package/client/features/applets/applet-thumbnail.ts +87 -0
- package/client/features/chat/ChatPopup.tsx +2 -1
- package/client/features/chat/chat-store.ts +6 -4
- package/client/features/chat/useChat.ts +7 -7
- package/client/features/views/ViewManager.tsx +14 -3
- package/dist/{chunk-gbp4m9p2.js → chunk-7paadv61.js} +1 -1
- package/dist/chunk-r8s1b672.css +1 -0
- package/dist/{chunk-jpdn7nx7.js → chunk-vwzshv0d.js} +19 -19
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/server/bundler/applet-css.ts +106 -1
- package/server/harness/codex/auth.ts +16 -1
- package/server/harness/codex/client.ts +37 -7
- package/dist/chunk-4vyggdzq.css +0 -1
package/dist/index.html
CHANGED
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
</script>
|
|
38
38
|
|
|
39
|
-
<link rel="stylesheet" crossorigin href="/chunk-
|
|
39
|
+
<link rel="stylesheet" crossorigin href="/chunk-r8s1b672.css"><script type="module" crossorigin src="/chunk-7paadv61.js"></script></head>
|
|
40
40
|
<body>
|
|
41
41
|
<div id="root"></div>
|
|
42
42
|
|
package/package.json
CHANGED
|
@@ -28,6 +28,111 @@ import postcss, { type Container, type Document } from 'postcss'
|
|
|
28
28
|
// matching an unrelated tag/class prefix like `bodycopy`.
|
|
29
29
|
const PAGE_ROOT_RE = /^(:root|:host|html|body)(?![\w-])/
|
|
30
30
|
|
|
31
|
+
// Tailwind's `group-has-*` / `peer-has-*` utilities compile to
|
|
32
|
+
// `.util:is(:where(.group):has(…) *)` — a non-subject `:has()` qualifying a
|
|
33
|
+
// universal `*` subject. Chrome cannot build a precise invalidation set for
|
|
34
|
+
// that shape and falls back to restyling the WHOLE document on unrelated DOM
|
|
35
|
+
// mutations: with one such rule mounted, every keystroke anywhere on the page
|
|
36
|
+
// recalculated styles for all ~10k elements (~140ms per key next to a large
|
|
37
|
+
// view — measured, see the chat-input-lag investigation). The equivalent
|
|
38
|
+
// descendant form `:where(.group):has(…) .util` matches the same elements
|
|
39
|
+
// with the same specificity (`:is()` takes its most specific argument), and
|
|
40
|
+
// Chrome invalidates it precisely.
|
|
41
|
+
//
|
|
42
|
+
// The rewrite is deliberately conservative, because it is only safe when it
|
|
43
|
+
// cannot reorder ancestor constraints:
|
|
44
|
+
// • The qualifier must sit on the LEFTMOST compound. That compound has no
|
|
45
|
+
// ancestor constraints to its left, so prepending its anchor imposes
|
|
46
|
+
// nothing new — this covers `.util:is(Q *)` and variant chains like
|
|
47
|
+
// `.util:is(Q *) > svg` (the `[&>svg]:` arbitrary variant). On any later
|
|
48
|
+
// compound (`A .util:is(Q *)`) the prepended anchor would force Q above
|
|
49
|
+
// A, which the original never required, so those are skipped.
|
|
50
|
+
// • Only the ONE `:is(…:has(…) *)` qualifier moves out. Every other
|
|
51
|
+
// qualifier (`:is(:where(.group)[data-x] *)`, stacked pseudos) stays on
|
|
52
|
+
// the subject, where it keeps constraining the same element — shadcn's
|
|
53
|
+
// alert-dialog stacks `group-data-*` and `group-has-data-*` exactly like
|
|
54
|
+
// this. Moving two anchors out would chain them into a strict ancestor
|
|
55
|
+
// order the original didn't have, so a second `:has` qualifier is left
|
|
56
|
+
// in place.
|
|
57
|
+
// • A qualifier with a top-level comma (`:is(A *, B)`) is skipped — the
|
|
58
|
+
// extraction is only equivalence-preserving for a single argument.
|
|
59
|
+
// The trailing `~` of `peer-has-*` (`:is(:where(.peer):has(…) ~ *)`) rides
|
|
60
|
+
// along, keeping the sibling combinator.
|
|
61
|
+
|
|
62
|
+
// Index of the first top-level combinator (space, >, +, ~ outside parens,
|
|
63
|
+
// brackets, and strings), or -1 when the selector is a single compound.
|
|
64
|
+
function firstCombinatorIndex(selector: string): number {
|
|
65
|
+
let depth = 0
|
|
66
|
+
let quote: string | null = null
|
|
67
|
+
for (let i = 0; i < selector.length; i++) {
|
|
68
|
+
const ch = selector[i]!
|
|
69
|
+
if (quote) {
|
|
70
|
+
if (ch === '\\') i++
|
|
71
|
+
else if (ch === quote) quote = null
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
if (ch === '"' || ch === "'") quote = ch
|
|
75
|
+
else if (ch === '\\') i++
|
|
76
|
+
else if (ch === '(' || ch === '[') depth++
|
|
77
|
+
else if (ch === ')' || ch === ']') depth--
|
|
78
|
+
else if (depth === 0 && (ch === ' ' || ch === '>' || ch === '+' || ch === '~')) return i
|
|
79
|
+
}
|
|
80
|
+
return -1
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// The span of the first `:is(…)` qualifier whose single argument contains
|
|
84
|
+
// `:has(` and ends with a universal `*` subject, or null.
|
|
85
|
+
function findHasQualifier(selector: string): { start: number; end: number; anchor: string } | null {
|
|
86
|
+
for (let from = 0; ; ) {
|
|
87
|
+
const start = selector.indexOf(':is(', from)
|
|
88
|
+
if (start === -1) return null
|
|
89
|
+
// Find the matching close paren, tracking nested parens and strings.
|
|
90
|
+
let depth = 0
|
|
91
|
+
let quote: string | null = null
|
|
92
|
+
let end = -1
|
|
93
|
+
let topComma = false
|
|
94
|
+
for (let i = start + 3; i < selector.length; i++) {
|
|
95
|
+
const ch = selector[i]!
|
|
96
|
+
if (quote) {
|
|
97
|
+
if (ch === '\\') i++
|
|
98
|
+
else if (ch === quote) quote = null
|
|
99
|
+
continue
|
|
100
|
+
}
|
|
101
|
+
if (ch === '"' || ch === "'") quote = ch
|
|
102
|
+
else if (ch === '\\') i++
|
|
103
|
+
else if (ch === '(') depth++
|
|
104
|
+
else if (ch === ')') {
|
|
105
|
+
depth--
|
|
106
|
+
if (depth === 0) {
|
|
107
|
+
end = i
|
|
108
|
+
break
|
|
109
|
+
}
|
|
110
|
+
} else if (ch === ',' && depth === 1) topComma = true
|
|
111
|
+
}
|
|
112
|
+
if (end === -1) return null
|
|
113
|
+
const inner = selector.slice(start + 4, end).trim()
|
|
114
|
+
if (!topComma && inner.includes(':has(') && inner.endsWith('*')) {
|
|
115
|
+
const anchor = inner.slice(0, -1).trim()
|
|
116
|
+
if (anchor.length > 0) return { start, end: end + 1, anchor }
|
|
117
|
+
}
|
|
118
|
+
from = end + 1
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function unqualifyNonSubjectHas(selector: string): string {
|
|
123
|
+
if (!selector.includes(':has(')) return selector
|
|
124
|
+
const combinatorAt = firstCombinatorIndex(selector)
|
|
125
|
+
const compound = combinatorAt === -1 ? selector : selector.slice(0, combinatorAt)
|
|
126
|
+
const rest = combinatorAt === -1 ? '' : selector.slice(combinatorAt)
|
|
127
|
+
const qualifier = findHasQualifier(compound)
|
|
128
|
+
if (!qualifier) return selector
|
|
129
|
+
const subject = (compound.slice(0, qualifier.start) + compound.slice(qualifier.end)).trim()
|
|
130
|
+
if (subject.length === 0) return selector
|
|
131
|
+
// `anchor` may end with the peer variant's `~`; the join keeps it a sibling
|
|
132
|
+
// combinator, otherwise it's a descendant combinator.
|
|
133
|
+
return `${qualifier.anchor} ${subject}${rest}`
|
|
134
|
+
}
|
|
135
|
+
|
|
31
136
|
function insideKeyframes(parent: Container | Document | undefined): boolean {
|
|
32
137
|
return parent?.type === 'atrule' && /keyframes$/i.test((parent as { name: string }).name)
|
|
33
138
|
}
|
|
@@ -39,7 +144,7 @@ export function scopeAppletCss(css: string, scope: string): string {
|
|
|
39
144
|
root.walkRules(rule => {
|
|
40
145
|
if (insideKeyframes(rule.parent)) return
|
|
41
146
|
rule.selectors = rule.selectors.map(selector => {
|
|
42
|
-
const s = selector.trim()
|
|
147
|
+
const s = unqualifyNonSubjectHas(selector.trim())
|
|
43
148
|
const rootToken = PAGE_ROOT_RE.exec(s)
|
|
44
149
|
if (rootToken) return container + s.slice(rootToken[0].length)
|
|
45
150
|
return `${container} ${s}`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HarnessAvailability, HarnessLogin } from '@/lib/types'
|
|
2
2
|
|
|
3
|
-
import { getCodexClient } from './client'
|
|
3
|
+
import { CODEX_MIN_SUPPORTED_VERSION, codexCliOutdated, getCodexClient } from './client'
|
|
4
4
|
|
|
5
5
|
type CodexAccount = { type: string }
|
|
6
6
|
type CodexAccountReadResponse = {
|
|
@@ -38,8 +38,23 @@ export function codexAccountReadiness(response: unknown): HarnessAvailability {
|
|
|
38
38
|
return CODEX_AVAILABLE
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
// Servers older than the supported floor reject every method moi calls with a
|
|
42
|
+
// bare "Invalid request", which the probe would surface as a generic failure —
|
|
43
|
+
// report the actionable cause instead.
|
|
44
|
+
export function codexOutdatedAvailability(
|
|
45
|
+
cliVersion: string | undefined
|
|
46
|
+
): HarnessAvailability | undefined {
|
|
47
|
+
if (!codexCliOutdated(cliVersion)) return undefined
|
|
48
|
+
return {
|
|
49
|
+
status: 'unavailable',
|
|
50
|
+
reason: `Codex ${cliVersion} is out of date. Update Codex to ${CODEX_MIN_SUPPORTED_VERSION} or newer`
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
export async function getCodexAuthReadiness(workspacePath: string): Promise<HarnessAvailability> {
|
|
42
55
|
const client = await getCodexClient(workspacePath)
|
|
56
|
+
const outdated = codexOutdatedAvailability(client.cliVersion)
|
|
57
|
+
if (outdated) return outdated
|
|
43
58
|
const account = await client.rpc<unknown>('account/read', { refreshToken: true })
|
|
44
59
|
return codexAccountReadiness(account)
|
|
45
60
|
}
|
|
@@ -68,6 +68,9 @@ export type CodexClient = {
|
|
|
68
68
|
// Whether this app-server accepts `turn/start.additionalContext` (the native
|
|
69
69
|
// per-turn context channel). Resolved from the initialize handshake.
|
|
70
70
|
supportsAdditionalContext: boolean
|
|
71
|
+
// CLI version from the initialize handshake's userAgent; undefined when it
|
|
72
|
+
// could not be parsed.
|
|
73
|
+
cliVersion: string | undefined
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
// `additionalContext` shipped in codex 0.135.0 (openai/codex#24154, May 2026).
|
|
@@ -76,18 +79,43 @@ export type CodexClient = {
|
|
|
76
79
|
// reliable signal is the version embedded in the initialize response's
|
|
77
80
|
// userAgent (e.g. `codex_cli_rs/0.144.5 (…)`); an unparsable userAgent gates
|
|
78
81
|
// to false and the session path falls back to appending context to the text.
|
|
79
|
-
const ADDITIONAL_CONTEXT_MIN_VERSION =
|
|
82
|
+
const ADDITIONAL_CONTEXT_MIN_VERSION = '0.135.0'
|
|
83
|
+
|
|
84
|
+
// The oldest codex whose app-server speaks every RPC method moi calls.
|
|
85
|
+
// `thread/read` was the last to land (openai/codex#9569, codex 0.89.0,
|
|
86
|
+
// Jan 2026); the core v2 thread/turn/account/model API arrived in 0.56.0
|
|
87
|
+
// and `config/read` in 0.64.0. Older servers complete the initialize
|
|
88
|
+
// handshake normally and then reject each method with a bare
|
|
89
|
+
// "Invalid request", so the handshake version is the only usable signal.
|
|
90
|
+
export const CODEX_MIN_SUPPORTED_VERSION = '0.89.0'
|
|
91
|
+
|
|
92
|
+
// Every codex release embeds `codex_cli_rs/<version> (…)` in the initialize
|
|
93
|
+
// response's userAgent (verified back to 0.45.0).
|
|
94
|
+
export function parseCodexCliVersion(userAgent: string | undefined): string | undefined {
|
|
95
|
+
return userAgent?.match(/\/(\d+\.\d+\.\d+)/)?.[1]
|
|
96
|
+
}
|
|
80
97
|
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
const v = [Number(m[1]), Number(m[2]), Number(m[3])]
|
|
98
|
+
function versionAtLeast(version: string, min: string): boolean {
|
|
99
|
+
const v = version.split('.').map(Number)
|
|
100
|
+
const m = min.split('.').map(Number)
|
|
85
101
|
for (let i = 0; i < 3; i++) {
|
|
86
|
-
if (v[i] !==
|
|
102
|
+
if (v[i] !== m[i]) return v[i] > m[i]
|
|
87
103
|
}
|
|
88
104
|
return true
|
|
89
105
|
}
|
|
90
106
|
|
|
107
|
+
// Unknown versions never flag as outdated — dev builds of codex report 0.0.0
|
|
108
|
+
// regardless of what they actually support.
|
|
109
|
+
export function codexCliOutdated(cliVersion: string | undefined): boolean {
|
|
110
|
+
if (!cliVersion || cliVersion === '0.0.0') return false
|
|
111
|
+
return !versionAtLeast(cliVersion, CODEX_MIN_SUPPORTED_VERSION)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function codexSupportsAdditionalContext(userAgent: string | undefined): boolean {
|
|
115
|
+
const version = parseCodexCliVersion(userAgent)
|
|
116
|
+
return version ? versionAtLeast(version, ADDITIONAL_CONTEXT_MIN_VERSION) : false
|
|
117
|
+
}
|
|
118
|
+
|
|
91
119
|
type ClientRecord = {
|
|
92
120
|
client: CodexClient
|
|
93
121
|
proc: ReturnType<typeof Bun.spawn>
|
|
@@ -246,7 +274,8 @@ async function startClient(workspacePath: string): Promise<ClientRecord> {
|
|
|
246
274
|
},
|
|
247
275
|
isAlive: () => alive,
|
|
248
276
|
workspacePath,
|
|
249
|
-
supportsAdditionalContext: false
|
|
277
|
+
supportsAdditionalContext: false,
|
|
278
|
+
cliVersion: undefined
|
|
250
279
|
}
|
|
251
280
|
const record: ClientRecord = { client, proc }
|
|
252
281
|
const recordPromise = Promise.resolve(record)
|
|
@@ -263,6 +292,7 @@ async function startClient(workspacePath: string): Promise<ClientRecord> {
|
|
|
263
292
|
capabilities: { experimentalApi: true, requestAttestation: false }
|
|
264
293
|
})
|
|
265
294
|
client.supportsAdditionalContext = codexSupportsAdditionalContext(init?.userAgent)
|
|
295
|
+
client.cliVersion = parseCodexCliVersion(init?.userAgent)
|
|
266
296
|
send({ jsonrpc: '2.0', method: 'initialized', params: {} })
|
|
267
297
|
debug(
|
|
268
298
|
`codex app-server started ws=${workspacePath} bin=${bin} ua=${init?.userAgent ?? 'unknown'} additionalContext=${client.supportsAdditionalContext}`
|