moi-computer 0.10.1-next.2 → 0.10.1-next.4
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/client/app/shell/SidebarLayout.tsx +53 -14
- package/client/components/shared/AgentBlobatar.tsx +3 -3
- package/client/components/shared/Composer.tsx +4 -10
- package/client/features/chat/ChatEmptyState.tsx +2 -9
- package/client/features/chat/ChatPanel.tsx +21 -23
- package/client/features/chat/ChatPopup.tsx +1 -2
- package/client/features/chat/composer/ChatComposer.tsx +2 -2
- package/client/features/chat/composer/banners/AgentAvailabilityBanner.tsx +101 -0
- package/client/features/chat/composer/banners/{ChatErrorBanner.tsx → ErrorBanner.tsx} +2 -2
- package/client/features/chat/composer/banners/{WorkspaceSkillUpdateBanner.tsx → SkillUpdateBanner.tsx} +3 -3
- package/client/features/chat/composer/useWorkspaceComposerState.tsx +14 -24
- package/client/features/chat/composer/useWorkspaceSkillUpdates.ts +6 -6
- package/client/features/chat/useAppletChatMessage.ts +9 -5
- package/client/features/dev/BlobatarShapesPage.tsx +344 -0
- package/client/features/dev/ChatStatesPage.tsx +3 -4
- package/client/features/dev/DevIndexPage.tsx +5 -0
- package/client/features/dev/DevRoutes.tsx +2 -0
- package/client/features/home/HomePage.tsx +47 -5
- package/client/features/home/WorkspacePreview.tsx +4 -4
- package/client/features/home/workspace-setup/WorkspaceAgentStep.tsx +1 -1
- package/client/features/update/{Update.tsx → UpdateControl.tsx} +33 -9
- package/client/features/workspace/CustomizePanel.tsx +1 -1
- package/client/features/workspace/WorkspaceScreen.tsx +5 -5
- package/client/features/workspace/api.ts +10 -1
- package/client/index.css +6 -1
- package/client/index.html +15 -0
- package/client/lib/agent-availability.ts +19 -0
- package/client/runtime/useWorkspaceEvents.ts +16 -2
- package/client/runtime/workspace-theme.ts +2 -8
- package/dist/chunk-104m57qw.js +2 -0
- package/dist/chunk-4vyggdzq.css +1 -0
- package/dist/chunk-bj3akjs2.js +1 -0
- package/dist/{chunk-0pcdwjkp.js → chunk-c9pjqx9m.js} +1 -1
- package/dist/chunk-gbp4m9p2.js +1 -0
- package/dist/{chunk-8jh75pjg.js → chunk-j2w2vak4.js} +2 -2
- package/dist/chunk-jpdn7nx7.js +83 -0
- package/dist/chunk-k2r9c95m.js +10 -0
- package/dist/chunk-kmbxhgwv.js +1 -0
- package/dist/{chunk-yt2qjn3m.js → chunk-tny85yt2.js} +2 -2
- package/dist/{chunk-9y2zbzqz.js → chunk-v7wr1df4.js} +1 -1
- package/dist/index.html +16 -1
- package/lib/themes.ts +31 -7
- package/lib/types.ts +9 -8
- package/package.json +1 -1
- package/server/AGENTS.md +1 -1
- package/server/agent.ts +46 -22
- package/server/api.ts +6 -6
- package/server/cli-ui-components.ts +63 -22
- package/server/harness/README.md +21 -12
- package/server/harness/claude-code/auth.ts +38 -23
- package/server/harness/claude-code/index.ts +1 -1
- package/server/harness/claude-code/permissions.ts +34 -0
- package/server/harness/claude-code/session.ts +7 -15
- package/server/harness/codex/auth.ts +31 -21
- package/server/harness/codex/client.ts +5 -14
- package/server/harness/codex/index.ts +1 -1
- package/server/harness/codex/permissions.ts +56 -0
- package/server/harness/codex/session.ts +25 -20
- package/server/harness/executable.ts +2 -2
- package/server/harness/hermes/index.ts +4 -5
- package/server/ui-components.ts +29 -0
- package/workspace/.claude/skills/moi-workspace/SKILL.md +10 -8
- package/workspace/.claude/skills/moi-workspace/references/UI-COMPONENTS.md +24 -21
- package/client/features/chat/composer/banners/WorkspaceAgentAvailabilityBanner.tsx +0 -82
- package/dist/chunk-4xmcsjjv.js +0 -1
- package/dist/chunk-dfs36zgc.js +0 -1
- package/dist/chunk-e4e993yf.js +0 -83
- package/dist/chunk-ek8w9tsp.css +0 -1
- package/dist/chunk-vq8ga42s.js +0 -1
- package/dist/chunk-yhj9bg1s.js +0 -2
- package/dist/chunk-yz743a75.js +0 -10
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
HookCallbackMatcher,
|
|
3
|
+
Options,
|
|
4
|
+
SyncHookJSONOutput
|
|
5
|
+
} from '@anthropic-ai/claude-agent-sdk'
|
|
6
|
+
|
|
7
|
+
export const CLAUDE_APPROVAL_REASON =
|
|
8
|
+
'Approved by moi: agent sessions run with default-approve access until UI approvals land.'
|
|
9
|
+
|
|
10
|
+
// A `PreToolUse` hook returning `allow` short-circuits the whole permission
|
|
11
|
+
// chain — settings rules, the `auto` mode classifier, and `canUseTool` alike —
|
|
12
|
+
// so nothing a moi session does comes back as a denial the model has to work
|
|
13
|
+
// around. `canUseTool` alone was not enough: the classifier's *deny* verdict
|
|
14
|
+
// (e.g. `curl … | sh`) never escalates to a prompt, it short-circuits into an
|
|
15
|
+
// error tool_result, so the callback was never consulted.
|
|
16
|
+
//
|
|
17
|
+
// This grants moi's Claude Code sessions strictly more than the CLI default:
|
|
18
|
+
// the classifier's safety judgment is off, and nothing replaces it until the
|
|
19
|
+
// UI approval flow lands. Narrow this to a real prompt before then.
|
|
20
|
+
export function claudeToolApproval(): SyncHookJSONOutput {
|
|
21
|
+
return {
|
|
22
|
+
continue: true,
|
|
23
|
+
hookSpecificOutput: {
|
|
24
|
+
hookEventName: 'PreToolUse',
|
|
25
|
+
permissionDecision: 'allow',
|
|
26
|
+
permissionDecisionReason: CLAUDE_APPROVAL_REASON
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// No `matcher` — the hook runs for every tool, built-in and MCP alike.
|
|
32
|
+
export const CLAUDE_APPROVAL_HOOKS: Partial<Record<'PreToolUse', HookCallbackMatcher[]>> = {
|
|
33
|
+
PreToolUse: [{ hooks: [async () => claudeToolApproval()] }]
|
|
34
|
+
} satisfies Options['hooks']
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
import { appendAttachmentNote, attachmentOnlyPlaceholder } from '@/lib/attachment-note'
|
|
22
22
|
import { buildSessionTitleSource } from '../session-title'
|
|
23
23
|
import { ClaudeAdapter } from './adapter'
|
|
24
|
+
import { CLAUDE_APPROVAL_HOOKS } from './permissions'
|
|
24
25
|
import { claudeSessionExists } from './sessions'
|
|
25
26
|
import { generateClaudeSessionTitle, renameClaudeSessionIfUnchanged } from './session-title'
|
|
26
27
|
import type { Part } from '@/lib/format'
|
|
@@ -103,18 +104,6 @@ const IDLE_TTL_MS = 5 * 60_000
|
|
|
103
104
|
// deliberately excluded — a leaked entry would keep the session alive forever.
|
|
104
105
|
const BG_TASK_TYPES = new Set(['local_bash', 'local_workflow'])
|
|
105
106
|
|
|
106
|
-
const ALLOWED_TOOLS = [
|
|
107
|
-
'Bash',
|
|
108
|
-
'Read',
|
|
109
|
-
'Write',
|
|
110
|
-
'Edit',
|
|
111
|
-
'MultiEdit',
|
|
112
|
-
'Glob',
|
|
113
|
-
'Grep',
|
|
114
|
-
'WebSearch',
|
|
115
|
-
'WebFetch'
|
|
116
|
-
]
|
|
117
|
-
|
|
118
107
|
type InputQueue = {
|
|
119
108
|
iterator: AsyncGenerator<SDKUserMessage>
|
|
120
109
|
push: (content: MessageContent) => void
|
|
@@ -621,9 +610,12 @@ function createLiveSession(input: {
|
|
|
621
610
|
// Emit `stream_event` partial-message frames so the adapter can surface a
|
|
622
611
|
// live token-by-token preview. Off = unchanged behavior (whole blocks only).
|
|
623
612
|
includePartialMessages: input.stream,
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
613
|
+
permissionMode: 'auto',
|
|
614
|
+
// Every tool call is approved before the permission system runs — see
|
|
615
|
+
// `permissions.ts`. `canUseTool` stays as the fallback for anything that
|
|
616
|
+
// reaches a prompt without passing through `PreToolUse`.
|
|
617
|
+
hooks: CLAUDE_APPROVAL_HOOKS,
|
|
618
|
+
canUseTool: async (_toolName, toolInput) => ({ behavior: 'allow', updatedInput: toolInput }),
|
|
627
619
|
settingSources: ['user', 'project'],
|
|
628
620
|
// MOI_AGENT marks every shell this session spawns as agent-driven (the
|
|
629
621
|
// moi CLI reads it — see agent-caller.ts), surviving the CLAUDECODE strip.
|
|
@@ -2,36 +2,46 @@ import type { HarnessAvailability, HarnessLogin } from '@/lib/types'
|
|
|
2
2
|
|
|
3
3
|
import { getCodexClient } from './client'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type CodexAccount = { type: string }
|
|
6
|
+
type CodexAccountReadResponse = {
|
|
7
|
+
account: CodexAccount | null
|
|
7
8
|
requiresOpenaiAuth: boolean
|
|
8
9
|
}
|
|
9
|
-
|
|
10
10
|
type CodexLoginResponse = { type: string; authUrl?: string }
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const CODEX_AVAILABLE: HarnessAvailability = { status: 'available' }
|
|
13
|
+
const CODEX_LOGIN_REQUIRED: HarnessAvailability = {
|
|
14
|
+
status: 'login-required',
|
|
15
|
+
reason: 'Codex is signed out. Sign in to send messages'
|
|
16
|
+
}
|
|
17
|
+
const CODEX_AUTH_UNAVAILABLE: HarnessAvailability = {
|
|
18
|
+
status: 'unavailable',
|
|
19
|
+
reason: 'Could not check the Codex login status'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
23
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value)
|
|
18
24
|
}
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
function isCodexAccountReadResponse(value: unknown): value is CodexAccountReadResponse {
|
|
27
|
+
return (
|
|
28
|
+
isRecord(value) &&
|
|
29
|
+
typeof value.requiresOpenaiAuth === 'boolean' &&
|
|
30
|
+
(value.account === null || (isRecord(value.account) && typeof value.account.type === 'string'))
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function codexAccountReadiness(response: unknown): HarnessAvailability {
|
|
35
|
+
if (!isCodexAccountReadResponse(response)) return CODEX_AUTH_UNAVAILABLE
|
|
36
|
+
|
|
37
|
+
if (response.requiresOpenaiAuth && response.account === null) return CODEX_LOGIN_REQUIRED
|
|
38
|
+
return CODEX_AVAILABLE
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
export async function getCodexAuthReadiness(workspacePath: string): Promise<HarnessAvailability> {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return codexAccountReadiness(account)
|
|
32
|
-
} catch {
|
|
33
|
-
return needsCodexLogin('Could not verify the Codex login')
|
|
34
|
-
}
|
|
42
|
+
const client = await getCodexClient(workspacePath)
|
|
43
|
+
const account = await client.rpc<unknown>('account/read', { refreshToken: true })
|
|
44
|
+
return codexAccountReadiness(account)
|
|
35
45
|
}
|
|
36
46
|
|
|
37
47
|
export async function startCodexLogin(workspacePath: string): Promise<HarnessLogin> {
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
} from './adapter'
|
|
26
26
|
import type { WorkspaceActivityPreview } from '../types'
|
|
27
27
|
import { findHarnessExecutable, requireHarnessExecutable } from '../executable'
|
|
28
|
+
import { codexServerRequestResponse } from './permissions'
|
|
28
29
|
import { debug } from '../../debug'
|
|
29
30
|
import { tapWire } from '../debug'
|
|
30
31
|
import { resolveWorkspaceEnv } from '../../workspace-env'
|
|
@@ -160,22 +161,12 @@ async function startClient(workspacePath: string): Promise<ClientRecord> {
|
|
|
160
161
|
}
|
|
161
162
|
}
|
|
162
163
|
|
|
163
|
-
// Server→client requests MUST be answered or the turn hangs.
|
|
164
|
-
//
|
|
165
|
-
//
|
|
164
|
+
// Server→client requests MUST be answered or the turn hangs. moi approves
|
|
165
|
+
// approval requests by default — an interim policy until UI approvals land;
|
|
166
|
+
// non-approval requests are rejected as unsupported.
|
|
166
167
|
function answerServerRequest(msg: Json) {
|
|
167
168
|
const method = msg.method as string
|
|
168
|
-
|
|
169
|
-
send({ jsonrpc: '2.0', id: msg.id, result: { decision: 'accept' } })
|
|
170
|
-
} else if (method === 'execCommandApproval') {
|
|
171
|
-
send({ jsonrpc: '2.0', id: msg.id, result: { decision: 'approved' } })
|
|
172
|
-
} else {
|
|
173
|
-
send({
|
|
174
|
-
jsonrpc: '2.0',
|
|
175
|
-
id: msg.id,
|
|
176
|
-
error: { code: -32601, message: `moi does not handle ${method}` }
|
|
177
|
-
})
|
|
178
|
-
}
|
|
169
|
+
send({ jsonrpc: '2.0', id: msg.id, ...codexServerRequestResponse(method) })
|
|
179
170
|
}
|
|
180
171
|
|
|
181
172
|
function handleLine(line: string) {
|
|
@@ -64,7 +64,7 @@ export const codexHarness: Harness = {
|
|
|
64
64
|
discoverWorkspaces: registeredPaths => discoverCodexWorkspaces(registeredPaths),
|
|
65
65
|
availability: async ws => {
|
|
66
66
|
const runtime = await pathHarnessAvailability('codex')
|
|
67
|
-
return runtime.available && ws ? getCodexAuthReadiness(ws.path) : runtime
|
|
67
|
+
return runtime.status === 'available' && ws ? getCodexAuthReadiness(ws.path) : runtime
|
|
68
68
|
},
|
|
69
69
|
startLogin: ws => startCodexLogin(ws.path),
|
|
70
70
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const CODEX_REVIEW = {
|
|
2
|
+
approvalPolicy: 'on-request'
|
|
3
|
+
} as const
|
|
4
|
+
|
|
5
|
+
export const CODEX_THREAD_ACCESS = {
|
|
6
|
+
...CODEX_REVIEW,
|
|
7
|
+
sandbox: 'workspace-write'
|
|
8
|
+
} as const
|
|
9
|
+
|
|
10
|
+
export const CODEX_TURN_ACCESS = {
|
|
11
|
+
...CODEX_REVIEW,
|
|
12
|
+
sandboxPolicy: {
|
|
13
|
+
type: 'workspaceWrite',
|
|
14
|
+
writableRoots: [],
|
|
15
|
+
networkAccess: false,
|
|
16
|
+
excludeTmpdirEnvVar: false,
|
|
17
|
+
excludeSlashTmp: false
|
|
18
|
+
}
|
|
19
|
+
} as const
|
|
20
|
+
|
|
21
|
+
const CODEX_LOCAL_CONTROL_GUIDANCE =
|
|
22
|
+
'Commands that contact the moi control server, including moi tabs, bundle, tab, debug, call-server-fn, theme, and config, need localhost network access. Run them with sandbox_permissions set to require_escalated on the first attempt so moi can approve the escalated request. A connection failure from a sandboxed attempt does not prove the control server is offline.'
|
|
23
|
+
|
|
24
|
+
export const CODEX_LOCAL_CONTROL_CONTEXT = {
|
|
25
|
+
'moi-control-access': {
|
|
26
|
+
value: CODEX_LOCAL_CONTROL_GUIDANCE,
|
|
27
|
+
kind: 'application'
|
|
28
|
+
}
|
|
29
|
+
} as const
|
|
30
|
+
|
|
31
|
+
// Codex versions before additionalContext append ambient context to the user
|
|
32
|
+
// message. Use the normal moi envelope marker so replay strips this block.
|
|
33
|
+
export const CODEX_LOCAL_CONTROL_FALLBACK = `<moi-context>
|
|
34
|
+
You are running in a \`moi\` workspace.
|
|
35
|
+
|
|
36
|
+
# Local control access
|
|
37
|
+
${CODEX_LOCAL_CONTROL_GUIDANCE}
|
|
38
|
+
|
|
39
|
+
IMPORTANT: This context comes from moi, not from the user, and the user does not see it.
|
|
40
|
+
</moi-context>`
|
|
41
|
+
|
|
42
|
+
// Server→client requests answered on the transport. Approval requests — the
|
|
43
|
+
// v2 `item/*/requestApproval` family plus the legacy v1 pair — are accepted:
|
|
44
|
+
// moi approves by default until it grows a UI approval flow. Anything else is
|
|
45
|
+
// rejected as unsupported so the turn never hangs on an unanswered request.
|
|
46
|
+
export function codexServerRequestResponse(
|
|
47
|
+
method: string
|
|
48
|
+
): { result: Record<string, unknown> } | { error: { code: number; message: string } } {
|
|
49
|
+
if (method.endsWith('requestApproval') || method === 'applyPatchApproval') {
|
|
50
|
+
return { result: { decision: 'accept' } }
|
|
51
|
+
}
|
|
52
|
+
if (method === 'execCommandApproval') {
|
|
53
|
+
return { result: { decision: 'approved' } }
|
|
54
|
+
}
|
|
55
|
+
return { error: { code: -32601, message: `moi does not handle ${method}` } }
|
|
56
|
+
}
|
|
@@ -39,6 +39,12 @@ import {
|
|
|
39
39
|
withCodexTurnDuration
|
|
40
40
|
} from './adapter'
|
|
41
41
|
import { type CodexClient, getCodexClient, interruptCodexTurn, readSubagentRecords } from './client'
|
|
42
|
+
import {
|
|
43
|
+
CODEX_LOCAL_CONTROL_CONTEXT,
|
|
44
|
+
CODEX_LOCAL_CONTROL_FALLBACK,
|
|
45
|
+
CODEX_THREAD_ACCESS,
|
|
46
|
+
CODEX_TURN_ACCESS
|
|
47
|
+
} from './permissions'
|
|
42
48
|
import { generateCodexSessionTitle, renameCodexSessionIfUnchanged } from './session-title'
|
|
43
49
|
import { agentStore } from '../../agent'
|
|
44
50
|
import { debug } from '../../debug'
|
|
@@ -53,13 +59,6 @@ import {
|
|
|
53
59
|
uploadToDisplayPart
|
|
54
60
|
} from '../../uploads'
|
|
55
61
|
|
|
56
|
-
// moi's trust model matches Claude Code's `bypassPermissions`: the agent acts
|
|
57
|
-
// autonomously in the workspace. Codex expresses that as full sandbox access
|
|
58
|
-
// with approvals disabled (approval prompts would otherwise arrive as
|
|
59
|
-
// server→client requests we have no UI for yet).
|
|
60
|
-
const SANDBOX_MODE = 'danger-full-access'
|
|
61
|
-
const APPROVAL_POLICY = 'never'
|
|
62
|
-
|
|
63
62
|
type CodexUserInputItem = { type: 'text'; text: string } | { type: 'image'; url: string }
|
|
64
63
|
|
|
65
64
|
// A child agent thread nested under this session (Codex multi-agent): the
|
|
@@ -118,10 +117,8 @@ export type CodexActiveSession = {
|
|
|
118
117
|
export function getCodexActiveSessions(): CodexActiveSession[] {
|
|
119
118
|
const out: CodexActiveSession[] = []
|
|
120
119
|
for (const s of sessions.values()) {
|
|
121
|
-
//
|
|
122
|
-
//
|
|
123
|
-
// policy is ever relaxed, `*requestApproval` / `elicitation` server
|
|
124
|
-
// requests are the signals to map to it.
|
|
120
|
+
// moi auto-accepts provider approval requests at the transport, so a
|
|
121
|
+
// session never blocks on approvals; requires-action is not surfaced.
|
|
125
122
|
if (s.processing) {
|
|
126
123
|
out.push({
|
|
127
124
|
workspaceId: s.workspaceId,
|
|
@@ -532,7 +529,8 @@ async function resumeSession(input: {
|
|
|
532
529
|
if (existing) return existing
|
|
533
530
|
const client = await getCodexClient(input.workspacePath)
|
|
534
531
|
const resumed = await client.rpc<{ thread: CodexThread }>('thread/resume', {
|
|
535
|
-
threadId: input.sessionId
|
|
532
|
+
threadId: input.sessionId,
|
|
533
|
+
...CODEX_THREAD_ACCESS
|
|
536
534
|
})
|
|
537
535
|
const rec = createRecord({ ...input, sessionId: resumed.thread.id, client })
|
|
538
536
|
// Rebuild child-agent transcripts from their own threads and register them
|
|
@@ -614,8 +612,7 @@ export async function sendCodexMessage(input: {
|
|
|
614
612
|
const client = await getCodexClient(input.workspacePath)
|
|
615
613
|
const started = await client.rpc<{ thread: CodexThread }>('thread/start', {
|
|
616
614
|
cwd: input.workspacePath,
|
|
617
|
-
|
|
618
|
-
approvalPolicy: APPROVAL_POLICY,
|
|
615
|
+
...CODEX_THREAD_ACCESS,
|
|
619
616
|
...(input.model ? { model: input.model } : {}),
|
|
620
617
|
...(serviceTier !== undefined ? { serviceTier } : {})
|
|
621
618
|
})
|
|
@@ -695,12 +692,19 @@ export async function sendCodexMessage(input: {
|
|
|
695
692
|
// inject nothing) and never echoed back in userMessage items. The entry
|
|
696
693
|
// key becomes the tag, so ship the unwrapped body. Older servers silently
|
|
697
694
|
// drop the field, so append to the text item there instead.
|
|
698
|
-
const additionalContext =
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
695
|
+
const additionalContext = client.supportsAdditionalContext
|
|
696
|
+
? {
|
|
697
|
+
...CODEX_LOCAL_CONTROL_CONTEXT,
|
|
698
|
+
...(input.context
|
|
699
|
+
? { 'moi-context': { value: renderMoiContextBody(input.context), kind: 'application' } }
|
|
700
|
+
: {})
|
|
701
|
+
}
|
|
702
|
+
: undefined
|
|
703
|
+
if (!additionalContext) {
|
|
704
|
+
const envelope = [
|
|
705
|
+
CODEX_LOCAL_CONTROL_FALLBACK,
|
|
706
|
+
...(input.context ? [renderMoiContext(input.context)] : [])
|
|
707
|
+
].join('\n\n')
|
|
704
708
|
const last = userInput[userInput.length - 1]
|
|
705
709
|
if (last?.type === 'text') last.text = appendMoiContext(last.text, envelope)
|
|
706
710
|
else userInput.push({ type: 'text', text: envelope })
|
|
@@ -709,6 +713,7 @@ export async function sendCodexMessage(input: {
|
|
|
709
713
|
threadId: rec.sessionId,
|
|
710
714
|
clientUserMessageId: turnId,
|
|
711
715
|
input: userInput,
|
|
716
|
+
...CODEX_TURN_ACCESS,
|
|
712
717
|
...(additionalContext ? { additionalContext } : {}),
|
|
713
718
|
// Without an explicit summary mode Codex still reasons but emits the
|
|
714
719
|
// reasoning item with EMPTY summary/content (verified on the wire —
|
|
@@ -91,6 +91,6 @@ export async function pathHarnessAvailability(
|
|
|
91
91
|
// probe anyway so the very first request can't report a false negative.
|
|
92
92
|
if (path === undefined) await loginShellPath()
|
|
93
93
|
return findHarnessExecutable(type, path)
|
|
94
|
-
? {
|
|
95
|
-
: {
|
|
94
|
+
? { status: 'available' }
|
|
95
|
+
: { status: 'unavailable', reason: executableConfig[type].unavailableReason }
|
|
96
96
|
}
|
|
@@ -116,13 +116,12 @@ export const hermesHarness: Harness = {
|
|
|
116
116
|
|
|
117
117
|
availability: async (ws): Promise<HarnessAvailability> => {
|
|
118
118
|
const runtime = await pathHarnessAvailability('hermes')
|
|
119
|
-
if (
|
|
119
|
+
if (runtime.status !== 'available' || !ws) return runtime
|
|
120
120
|
const profile = await resolveHermesProfile(ws.path, ws.agentId)
|
|
121
|
-
if (profile) return {
|
|
121
|
+
if (profile) return { status: 'available' }
|
|
122
122
|
return {
|
|
123
|
-
|
|
124
|
-
reason: 'Hermes profile not found — run moi hermes init to re-import it'
|
|
125
|
-
loginCommand: 'hermes profile list'
|
|
123
|
+
status: 'unavailable',
|
|
124
|
+
reason: 'Hermes profile not found — run moi hermes init to re-import it'
|
|
126
125
|
}
|
|
127
126
|
},
|
|
128
127
|
|
package/server/ui-components.ts
CHANGED
|
@@ -168,6 +168,10 @@ export const UI_COMPONENTS: Record<string, UiComponentEntry> = {
|
|
|
168
168
|
description: 'Native-feeling select with a styled popup',
|
|
169
169
|
registryItems: ['select']
|
|
170
170
|
},
|
|
171
|
+
separator: {
|
|
172
|
+
description: 'Horizontal or vertical dividing line',
|
|
173
|
+
registryItems: ['separator']
|
|
174
|
+
},
|
|
171
175
|
skeleton: {
|
|
172
176
|
description: 'Loading placeholder block',
|
|
173
177
|
registryItems: ['skeleton']
|
|
@@ -523,6 +527,31 @@ export type PlannedWrite = {
|
|
|
523
527
|
support: boolean
|
|
524
528
|
}
|
|
525
529
|
|
|
530
|
+
export type UiWritePartition = {
|
|
531
|
+
// Files to write now: everything new, plus existing requested files under
|
|
532
|
+
// --force. Existing support files are never here.
|
|
533
|
+
write: PlannedWrite[]
|
|
534
|
+
// Existing support files, always left untouched.
|
|
535
|
+
keepSupport: PlannedWrite[]
|
|
536
|
+
// Requested components already installed, skipped without --force — a bulk
|
|
537
|
+
// add proceeds past them instead of failing the whole batch.
|
|
538
|
+
skipInstalled: PlannedWrite[]
|
|
539
|
+
// Every requested file already exists and --force is off: the add would be
|
|
540
|
+
// a no-op, so the CLI fails loudly instead of quietly keeping everything.
|
|
541
|
+
allInstalled: boolean
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export function partitionUiWrites(plans: PlannedWrite[], force: boolean): UiWritePartition {
|
|
545
|
+
const requested = plans.filter(plan => !plan.support)
|
|
546
|
+
const skipInstalled = force ? [] : requested.filter(plan => plan.exists)
|
|
547
|
+
return {
|
|
548
|
+
write: plans.filter(plan => !plan.exists || (force && !plan.support)),
|
|
549
|
+
keepSupport: plans.filter(plan => plan.support && plan.exists),
|
|
550
|
+
skipInstalled,
|
|
551
|
+
allInstalled: !force && requested.length > 0 && skipInstalled.length === requested.length
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
526
555
|
export function planUiWrites(opts: {
|
|
527
556
|
files: FetchedUiFile[]
|
|
528
557
|
requestedItems: string[]
|
|
@@ -195,20 +195,22 @@ function cx(...classes: (string | false | undefined | null)[]) {
|
|
|
195
195
|
## Standard UI components
|
|
196
196
|
|
|
197
197
|
Need a standard control (button, dialog, select, table, chart…)? Don't hand-roll it —
|
|
198
|
-
`moi ui-components add <name
|
|
199
|
-
workspace theme tokens, overlays patched to keep applet styling) into `.moi/ui/`.
|
|
200
|
-
|
|
198
|
+
`moi ui-components add <name…>` installs moi-tuned shadcn components (Base UI + Tabler icons,
|
|
199
|
+
workspace theme tokens, overlays patched to keep applet styling) into `.moi/ui/`. Pass every
|
|
200
|
+
component you need in one call (`add table badge tabs`) instead of one `add` per component.
|
|
201
|
+
Import relatively: `import { Button } from '../ui/button'`.
|
|
201
202
|
|
|
202
203
|
- `moi ui-components` — the catalog with installed state. Read
|
|
203
204
|
`references/UI-COMPONENTS.md` first: the full catalog plus the essential usage rules
|
|
204
205
|
(Base UI composition, forms, styling, icons — condensed from the official shadcn skill).
|
|
205
|
-
- `moi ui-components docs <name
|
|
206
|
+
- `moi ui-components docs <name…>` — full official docs (markdown: anatomy, props, examples) on
|
|
206
207
|
demand. Read them before composing an unfamiliar component; the parts API (Base UI) differs
|
|
207
208
|
from Radix-era shadcn.
|
|
208
|
-
- `add` never installs npm packages
|
|
209
|
-
|
|
209
|
+
- `add` never rebuilds, and installs npm packages only with `--install` (pass it unless you
|
|
210
|
+
want to run the printed `bun install` yourself); run `moi bundle` yourself either way.
|
|
210
211
|
- Files in `.moi/ui/` are yours to customize (edits propagate to every applet using them);
|
|
211
|
-
|
|
212
|
+
`add` skips already-installed components (reported as kept) and overwrites only with
|
|
213
|
+
`--force`.
|
|
212
214
|
- Component names, their API, and the CLI are very close to a selected subset of shadcn, but the
|
|
213
215
|
actual implementation might differ.
|
|
214
216
|
|
|
@@ -439,4 +441,4 @@ This skill is installed with moi (via the CLI or the UI) and can fall behind whe
|
|
|
439
441
|
- **Then** — if you updated, mention it.
|
|
440
442
|
|
|
441
443
|
<!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
|
|
442
|
-
<moi-skill version="0.15.
|
|
444
|
+
<moi-skill version="0.15.1" />
|
|
@@ -13,11 +13,13 @@ Radix-era shadcn you may know.
|
|
|
13
13
|
## Workflow
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
|
-
moi ui-components
|
|
17
|
-
moi ui-components add select
|
|
18
|
-
moi ui-components
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
moi ui-components # catalog + what's installed
|
|
17
|
+
moi ui-components add select # → .moi/ui/select.tsx (+ any support files)
|
|
18
|
+
moi ui-components add table badge tabs --install # any number of names, one call —
|
|
19
|
+
# always prefer this over one `add` per
|
|
20
|
+
# component; --install runs the bun install too
|
|
21
|
+
moi ui-components docs select table # official docs as markdown
|
|
22
|
+
moi bundle # rebuild applets
|
|
21
23
|
```
|
|
22
24
|
|
|
23
25
|
```tsx
|
|
@@ -26,8 +28,9 @@ import { Button } from '../ui/button'
|
|
|
26
28
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
|
|
27
29
|
```
|
|
28
30
|
|
|
29
|
-
- `add` writes source files and nothing else — installing the deps it prints and
|
|
30
|
-
your job.
|
|
31
|
+
- `add` writes source files and nothing else by default — installing the deps it prints and
|
|
32
|
+
rebuilding is your job. Pass `--install` to have it run the `bun install` in `.moi/` for you;
|
|
33
|
+
rebuilding (`moi bundle`) stays yours either way.
|
|
31
34
|
- **If the build fails on a missing package** (happens in workspaces scaffolded before this
|
|
32
35
|
feature — `.moi/package.json` may lack the deps ui components need): check
|
|
33
36
|
`.moi/package.json` and install what's missing. Every ui component needs the baseline
|
|
@@ -39,9 +42,11 @@ import { Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectVa
|
|
|
39
42
|
(run in `.moi/`), plus whatever `add` printed for the specific component (`recharts`,
|
|
40
43
|
`embla-carousel-react`, `react-day-picker` + `date-fns`, `react-resizable-panels`,
|
|
41
44
|
`@tanstack/react-table`).
|
|
42
|
-
- Files in `.moi/ui/` are yours to customize; `add`
|
|
45
|
+
- Files in `.moi/ui/` are yours to customize; `add` never overwrites them without `--force` —
|
|
46
|
+
in a multi-name add, already-installed components are skipped (reported as kept) and the new
|
|
47
|
+
ones still install.
|
|
43
48
|
- Support files appear without being asked for (`utils.ts` with `cn`, `applet-portal.tsx`, and
|
|
44
|
-
registry dependencies like `
|
|
49
|
+
registry dependencies like `card` or `toggle`) — normal; use them if handy.
|
|
45
50
|
`applet-portal.tsx` is auto-generated machinery: never edit or remove it.
|
|
46
51
|
|
|
47
52
|
## Catalog
|
|
@@ -64,7 +69,7 @@ docs) · `chart` (Recharts wired to theme tokens) · `attachment` (file/image ti
|
|
|
64
69
|
(chat message)
|
|
65
70
|
|
|
66
71
|
**Structure & navigation:** `accordion` · `collapsible` · `tabs` · `carousel` · `pagination` ·
|
|
67
|
-
`resizable` (split panels)
|
|
72
|
+
`resizable` (split panels) · `separator` (divider line)
|
|
68
73
|
|
|
69
74
|
Picking one: quick info on hover → `hover-card` or `tooltip` · contextual panel on click →
|
|
70
75
|
`popover` · focused task needing input → `dialog` · destructive confirmation → `alert-dialog` ·
|
|
@@ -134,6 +139,9 @@ The biggest source of bugs when you know Radix-era shadcn. When unsure, `moi ui-
|
|
|
134
139
|
- **Slider**: plain number for one thumb (`defaultValue={50}`), array only for ranges.
|
|
135
140
|
- **Accordion**: no `type`/`collapsible` props — `defaultValue` is **always an array**
|
|
136
141
|
(`defaultValue={["item-1"]}`), `multiple` to allow several open.
|
|
142
|
+
- **`AlertAction` is absolutely positioned** in the alert's top-right corner, and the alert
|
|
143
|
+
reserves only ~4.5rem of right padding for it. Keep it to one small control (`size="sm"`
|
|
144
|
+
button or icon button); anything wider overlaps the title and description text.
|
|
137
145
|
|
|
138
146
|
## Forms
|
|
139
147
|
|
|
@@ -178,7 +186,10 @@ The biggest source of bugs when you know Radix-era shadcn. When unsure, `moi ui-
|
|
|
178
186
|
component's colors or typography.
|
|
179
187
|
- **`gap-*`, not `space-x-*`/`space-y-*`** (`flex flex-col gap-4`). **`size-10`, not
|
|
180
188
|
`w-10 h-10`.** **`truncate`**, not the three-class spell.
|
|
181
|
-
- **`cn()` from `../ui/utils` for conditional classes** — no template-literal ternaries.
|
|
189
|
+
- **`cn()` from `../ui/utils` for conditional classes** — no template-literal ternaries. The
|
|
190
|
+
same import works from `_`-prefixed shared modules next to your applets (a
|
|
191
|
+
`.moi/widgets/_utils.tsx` importing `cn` uses `../ui/utils` too) — no need to re-implement
|
|
192
|
+
it.
|
|
182
193
|
- **No manual `z-index` on overlays** — dialog/popover/menu/tooltip handle their own stacking.
|
|
183
194
|
|
|
184
195
|
## Icons
|
|
@@ -199,13 +210,5 @@ Cheapest first — stop at the first level that works:
|
|
|
199
210
|
3. **Edit the file in `.moi/ui/`** — e.g. add a `cva` variant to `button.tsx`; propagates to
|
|
200
211
|
every applet using it, and `add` won't overwrite it without `--force`.
|
|
201
212
|
4. **Wrapper components** — compose primitives into app-level pieces (a `ConfirmDialog` wrapping
|
|
202
|
-
`AlertDialog` parts) in `.moi/widgets/
|
|
203
|
-
|
|
204
|
-
## Fit within applets
|
|
205
|
-
|
|
206
|
-
- **Widgets** are small: keep the composition compact, the number of controls low, and enough room
|
|
207
|
-
around each action. Keep interactions inline and self-contained; avoid layered UI such as
|
|
208
|
-
popovers and tooltips. Page-scale chrome (sidebars, nav menus, sheets, toasts) is deliberately not
|
|
209
|
-
in the set — widgets don't need it, and a view's chrome should be custom (see
|
|
210
|
-
`references/DESIGN.md`).
|
|
211
|
-
- **Views** can use the full set, including `resizable` layouts and `data-table`.
|
|
213
|
+
`AlertDialog` parts) in a `_`-prefixed shared module (`.moi/widgets/_utils.tsx` — see the
|
|
214
|
+
workspace layout in the skill).
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
import { IconLoader2, IconLogin } from '@tabler/icons-react'
|
|
4
|
-
|
|
5
|
-
import { Button } from '@/client/components/ui/button'
|
|
6
|
-
import type { AgentLoginState, HarnessAvailability, HarnessLogin } from '@/lib/types'
|
|
7
|
-
|
|
8
|
-
import { ComposerBannerShell } from './ComposerBanner'
|
|
9
|
-
|
|
10
|
-
type WorkspaceAgentAvailabilityBannerProps = {
|
|
11
|
-
availability: Extract<HarnessAvailability, { available: false }>
|
|
12
|
-
// The server-owned ceremony. `pending` means some tab (maybe this one)
|
|
13
|
-
// started a login and the server is watching for it to land; `failed` means
|
|
14
|
-
// the last ceremony timed out or errored.
|
|
15
|
-
login?: AgentLoginState
|
|
16
|
-
onStartLogin: () => Promise<HarnessLogin>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function WorkspaceAgentAvailabilityBanner({
|
|
20
|
-
availability,
|
|
21
|
-
login,
|
|
22
|
-
onStartLogin
|
|
23
|
-
}: WorkspaceAgentAvailabilityBannerProps) {
|
|
24
|
-
// Local phase only bridges the gap between the POST resolving and the
|
|
25
|
-
// server's `agent:updated` event landing; the ceremony state is the truth.
|
|
26
|
-
const [phase, setPhase] = useState<'idle' | 'starting' | 'waiting'>('idle')
|
|
27
|
-
const [error, setError] = useState<string | null>(null)
|
|
28
|
-
|
|
29
|
-
// A settled ceremony (failed, or replaced by a fresh signed-out state)
|
|
30
|
-
// re-enables the button.
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (login?.state !== 'pending') setPhase('idle')
|
|
33
|
-
}, [login?.state])
|
|
34
|
-
|
|
35
|
-
const waiting = login?.state === 'pending' || phase === 'waiting'
|
|
36
|
-
const failure = login?.state === 'failed' ? login.reason : null
|
|
37
|
-
const busy = waiting || phase === 'starting'
|
|
38
|
-
|
|
39
|
-
const startLogin = async () => {
|
|
40
|
-
const authWindow = window.open('about:blank', 'moi-agent-login')
|
|
41
|
-
if (authWindow) authWindow.opener = null
|
|
42
|
-
setPhase('starting')
|
|
43
|
-
setError(null)
|
|
44
|
-
try {
|
|
45
|
-
const result = await onStartLogin()
|
|
46
|
-
if (result.url) {
|
|
47
|
-
if (!authWindow) throw new Error('Allow pop-ups, then try again')
|
|
48
|
-
authWindow.location.href = result.url
|
|
49
|
-
} else {
|
|
50
|
-
authWindow?.close()
|
|
51
|
-
}
|
|
52
|
-
setPhase('waiting')
|
|
53
|
-
} catch (err) {
|
|
54
|
-
authWindow?.close()
|
|
55
|
-
setPhase('idle')
|
|
56
|
-
setError(err instanceof Error ? err.message : 'Could not start sign-in')
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<ComposerBannerShell role="alert" className="flex items-center gap-2">
|
|
62
|
-
<IconLogin size={20} stroke={1.5} />
|
|
63
|
-
<div className="min-w-0 flex-1 space-y-1">
|
|
64
|
-
<div className="wrap-break-word">Log in to your agent to send messages</div>
|
|
65
|
-
{(error ?? failure) && (
|
|
66
|
-
<div className="wrap-break-word text-destructive">{error ?? failure}</div>
|
|
67
|
-
)}
|
|
68
|
-
</div>
|
|
69
|
-
|
|
70
|
-
{availability.loginCommand && (
|
|
71
|
-
<Button type="button" size="sm" onClick={() => void startLogin()} disabled={busy}>
|
|
72
|
-
{busy && <IconLoader2 stroke={1.75} className="animate-spin" />}
|
|
73
|
-
{phase === 'starting'
|
|
74
|
-
? 'Opening browser to sign in…'
|
|
75
|
-
: waiting
|
|
76
|
-
? 'Waiting for log in…'
|
|
77
|
-
: 'Log in'}
|
|
78
|
-
</Button>
|
|
79
|
-
)}
|
|
80
|
-
</ComposerBannerShell>
|
|
81
|
-
)
|
|
82
|
-
}
|
package/dist/chunk-4xmcsjjv.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Oc as a,Pc as b}from"/chunk-yt2qjn3m.js";import"/chunk-yhj9bg1s.js";import"/chunk-9y2zbzqz.js";export{b as useAppConfig,a as loadAppConfig};
|
package/dist/chunk-dfs36zgc.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"/chunk-pcnahct1.js";import"/chunk-9y2zbzqz.js";export{a as sanitizeSvg};
|