moi-computer 0.12.1-next.3 → 0.13.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/bunfig.toml +1 -5
- package/client/api/app-config.ts +1 -2
- package/client/api/app-ui-keys.ts +3 -1
- package/client/api/http.ts +4 -1
- package/client/api/workspace-keys.ts +3 -3
- package/client/app/app-provider.tsx +22 -2
- package/client/app/app-router.tsx +4 -0
- package/client/app/routes/home-route.tsx +14 -0
- package/client/app/routes/onboarding-route.tsx +11 -0
- package/client/app/routes/settings-route.tsx +1 -1
- package/client/app/routes/workspace-route.tsx +21 -19
- package/client/components/shared/screen-shell.tsx +23 -0
- package/client/components/shared/ultrafast-icon.tsx +61 -0
- package/client/components/shared/workspace-icon.tsx +2 -2
- package/client/features/account/account-test-utils.tsx +4 -3
- package/client/features/app-settings/api.ts +33 -0
- package/client/features/app-settings/general-settings.tsx +39 -0
- package/client/features/{settings → app-settings}/settings-page.tsx +5 -1
- package/client/features/chat/applet-chat-intents.ts +4 -20
- package/client/features/chat/chat-send.ts +17 -13
- package/client/features/chat/composer/model-order.ts +8 -4
- package/client/features/chat/composer/model-picker.tsx +88 -34
- package/client/features/chat/composer/use-workspace-composer-state.tsx +11 -3
- package/client/features/chat/composer/use-workspace-skill-updates.ts +1 -1
- package/client/features/chat/connection/chat-frames.ts +3 -15
- package/client/features/chat/messages/chat-empty-state.tsx +1 -4
- package/client/features/chat/messages/fork-history.ts +5 -5
- package/client/features/chat/messages/tool-group/subagent-card.tsx +1 -0
- package/client/features/chat/messages/turn-view.tsx +3 -12
- package/client/features/chat/messages/user-message-bubble.tsx +63 -0
- package/client/features/chat/sessions/api.ts +121 -80
- package/client/features/chat/sessions/browser-tab-state.ts +14 -12
- package/client/features/chat/sessions/chat-selector.tsx +5 -6
- package/client/features/chat/sessions/use-selected-session.ts +172 -257
- package/client/features/chat/use-chat.ts +14 -19
- package/client/features/collab/components/user-avatar.tsx +4 -10
- package/client/features/collab/workspace-users-menu.tsx +1 -1
- package/client/features/connectors/api.ts +12 -4
- package/client/features/connectors/mcp-server-cards.tsx +17 -7
- package/client/features/connectors/read-connectors.ts +35 -0
- package/client/features/demo/demo-dialog.tsx +11 -3
- package/client/features/dev/collab/local-user-settings.tsx +1 -1
- package/client/features/dev/dev-index-page.tsx +5 -0
- package/client/features/dev/dev-routes.tsx +2 -0
- package/client/features/dev/harness-debug-page.tsx +3 -3
- package/client/features/dev/onboarding-preview-page.tsx +76 -0
- package/client/features/dev/workspace-setup-mocks.ts +16 -14
- package/client/features/dev/workspace-setup-preview.tsx +11 -17
- package/client/features/harness/api.ts +45 -15
- package/client/features/harness/device-login-steps.tsx +9 -3
- package/client/features/harness/harness-login-panel.tsx +228 -0
- package/client/features/harness/harness-presentation.ts +15 -0
- package/client/features/harness/harness-selector.tsx +119 -0
- package/client/features/harness/use-harness-login.ts +77 -0
- package/client/features/home/home-page.tsx +7 -7
- package/client/features/onboarding/agent-setup-step.tsx +57 -0
- package/client/features/onboarding/api.ts +42 -0
- package/client/features/onboarding/onboarding-idea-disk.tsx +129 -0
- package/client/features/onboarding/onboarding-page.tsx +32 -0
- package/client/features/onboarding/onboarding-screen.tsx +20 -0
- package/client/features/onboarding/onboarding-status.tsx +24 -0
- package/client/features/onboarding/workspace-setup-step.tsx +239 -0
- package/client/features/overview/default/registry.tsx +2 -2
- package/client/features/overview/default/views-widget.tsx +6 -5
- package/client/features/overview/overview.tsx +9 -11
- package/client/features/overview/widget-canvas.tsx +1 -1
- package/client/features/overview/workspace-name.tsx +2 -2
- package/client/features/views/api.ts +69 -16
- package/client/features/views/pending-view-screen.tsx +30 -9
- package/client/features/views/use-view-actions.ts +19 -20
- package/client/features/views/view-presentation.ts +2 -2
- package/client/features/views/view-submission.ts +28 -41
- package/client/features/workspace/add/api.ts +3 -23
- package/client/features/workspace/add/create-workspace-dialog.tsx +6 -5
- package/client/features/workspace/add/import-workspace-dialog.tsx +3 -3
- package/client/features/workspace/add/workspace-agent-options.ts +11 -12
- package/client/features/workspace/add/workspace-agent-selector.tsx +3 -132
- package/client/features/workspace/api.ts +32 -36
- package/client/features/workspace/harness-transition.ts +89 -0
- package/client/features/{settings → workspace/settings}/api.ts +1 -34
- package/client/features/{settings → workspace/settings}/connectors-settings.tsx +31 -10
- package/client/features/workspace/settings/general-settings.tsx +180 -0
- package/client/features/{settings → workspace/settings}/use-env-vars.ts +1 -1
- package/client/features/{settings → workspace/settings}/workspace-icon-picker.tsx +3 -3
- package/client/features/workspace/setup/workspace-login-state.tsx +37 -156
- package/client/features/workspace/setup/workspace-recovery-states.tsx +0 -12
- package/client/features/workspace/setup/workspace-setup.tsx +34 -14
- package/client/features/workspace/setup/workspace-welcome-state.tsx +2 -2
- package/client/features/workspace/use-workspace-navigation.ts +25 -9
- package/client/features/workspace/workspace-content.tsx +11 -8
- package/client/features/workspace/workspace-frame.tsx +2 -1
- package/client/features/workspace/workspace-layout-context.tsx +5 -2
- package/client/features/workspace/workspace-menu.tsx +12 -8
- package/client/features/workspace/workspace-pending-screen.tsx +10 -10
- package/client/features/workspace/workspace-presentation.tsx +5 -13
- package/client/features/workspace/workspace-state.ts +169 -0
- package/client/features/workspace/workspace-tabs.tsx +22 -2
- package/client/index.css +2 -0
- package/client/index.tsx +3 -3
- package/client/lib/flags.ts +1 -1
- package/client/lib/{app-icon-registry.ts → identity-icon-registry.ts} +10 -14
- package/client/runtime/workspace-events.ts +21 -4
- package/client/runtime/workspace-theme.ts +9 -0
- package/client/tailwind-config.ts +43 -0
- package/dist/chunk-2y59vrxg.js +5 -0
- package/dist/chunk-58dyt9bk.js +2 -0
- package/dist/{chunk-tqd3pkg8.css → chunk-60q353jq.css} +1 -1
- package/dist/chunk-bncc7heg.js +1 -0
- package/dist/{chunk-11cab5dq.css → chunk-cq2r11fg.css} +1 -1
- package/dist/chunk-cqt3s31j.js +546 -0
- package/dist/chunk-dcmks9sm.js +75 -0
- package/dist/chunk-md45evr2.css +1 -0
- package/dist/chunk-n0nab26d.js +1 -0
- package/dist/chunk-nf2wkvf9.js +14 -0
- package/dist/chunk-nmzhgyp9.js +2 -0
- package/dist/chunk-q37knr3m.js +2 -0
- package/dist/chunk-s90m4qkz.js +1 -0
- package/dist/chunk-wjvd4byz.js +2 -0
- package/dist/index.html +1 -1
- package/lib/harness-instructions.ts +1 -1
- package/lib/{app-icons.ts → identity-icons.ts} +6 -7
- package/lib/onboarding.ts +41 -0
- package/lib/speed-mode.ts +5 -0
- package/lib/types.ts +75 -64
- package/lib/view-build-directives.ts +1 -2
- package/lib/workspace-icon.ts +2 -2
- package/lib/workspace-layout.ts +1 -1
- package/lib/workspace-name.ts +15 -12
- package/package.json +11 -8
- package/server/README.md +27 -25
- package/server/api/harnesses.ts +31 -8
- package/server/api/index.ts +189 -127
- package/server/api/onboarding.ts +46 -0
- package/server/app-config.ts +16 -24
- package/server/app-settings.ts +6 -2
- package/server/applets/config.ts +5 -5
- package/server/applets/views.ts +19 -17
- package/server/cli/commands/init.ts +3 -3
- package/server/cli/commands/skill.ts +16 -17
- package/server/cli/commands/start.ts +8 -34
- package/server/cli/server.ts +18 -6
- package/server/collab/config.ts +1 -2
- package/server/collab/manager.ts +4 -1
- package/server/collab/skill/index.ts +1 -1
- package/server/control.ts +3 -3
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +24 -8
- package/server/harness/acp/session.ts +8 -4
- package/server/harness/auth.ts +14 -17
- package/server/harness/claude-code/NOTES.md +4 -3
- package/server/harness/claude-code/index.ts +5 -6
- package/server/harness/claude-code/mcp.ts +17 -0
- package/server/harness/claude-code/models.ts +2 -20
- package/server/harness/claude-code/run-action.ts +123 -0
- package/server/harness/claude-code/session-title.ts +5 -7
- package/server/harness/claude-code/session.ts +24 -16
- package/server/harness/codex/NOTES.md +22 -10
- package/server/harness/codex/adapter.ts +14 -17
- package/server/harness/codex/client.ts +8 -5
- package/server/harness/codex/connectors.ts +92 -0
- package/server/harness/codex/index.ts +4 -1
- package/server/harness/codex/pagination.ts +8 -5
- package/server/harness/codex/run-action.ts +93 -0
- package/server/harness/codex/session-title.ts +6 -8
- package/server/harness/codex/session.ts +11 -11
- package/server/harness/codex/transport.ts +13 -6
- package/server/harness/command.ts +45 -0
- package/server/harness/executable.ts +5 -0
- package/server/harness/fork.ts +6 -4
- package/server/harness/install.ts +49 -0
- package/server/harness/openclaw/session.ts +1 -2
- package/server/harness/run-action.ts +85 -0
- package/server/harness/session-title.ts +0 -46
- package/server/harness/types.ts +30 -3
- package/server/onboarding/brief.ts +29 -0
- package/server/onboarding/ideas.ts +48 -0
- package/server/onboarding/jobs.ts +291 -0
- package/server/onboarding/prompt.md +49 -0
- package/server/sessions/archive.ts +5 -14
- package/server/sessions/config.ts +17 -16
- package/server/sessions/lifecycle.ts +15 -13
- package/server/sessions/pending-views.ts +79 -108
- package/server/sessions/selected.ts +75 -161
- package/server/sessions/store.ts +40 -113
- package/server/sessions/view-sessions.ts +128 -111
- package/server/skills/locations.ts +82 -0
- package/server/skills/lock.ts +29 -0
- package/server/skills/template.ts +36 -25
- package/server/skills/update.ts +52 -5
- package/server/skills/version.ts +17 -22
- package/server/skills/workspace.ts +121 -0
- package/server/web.ts +22 -8
- package/server/workspace-state/file.ts +177 -0
- package/server/workspace-state/index.ts +162 -0
- package/server/workspace-state/legacy-migration.ts +79 -0
- package/server/workspace-state/lock.ts +42 -0
- package/server/workspace-state/types.ts +16 -0
- package/server/workspaces/change-harness.ts +88 -0
- package/server/workspaces/harness-transition.ts +29 -0
- package/server/workspaces/init.ts +29 -6
- package/server/workspaces/layout.ts +3 -0
- package/server/workspaces/registry.ts +27 -1
- package/{workspace/.claude/skills/moi-workspace → skill}/SKILL.md +7 -5
- package/{workspace/.claude/skills/moi-workspace → skill}/references/COLLAB.md +4 -8
- package/skill/references/DESIGN.md +167 -0
- package/{workspace/.claude/skills/moi-workspace → skill}/references/SCRATCHPAD.md +2 -2
- package/{workspace/.claude/skills/moi-workspace → skill}/references/UI-COMPONENTS.md +3 -0
- package/ui-components/badge.tsx +1 -1
- package/client/accept-hmr-dependencies.ts +0 -22
- package/client/features/settings/general-settings.tsx +0 -103
- package/client/features/workspace/setup/workspace-setup-panel.tsx +0 -18
- package/dist/chunk-20ynagd4.js +0 -2
- package/dist/chunk-42tde9a6.js +0 -1
- package/dist/chunk-9w543s0r.js +0 -2
- package/dist/chunk-a5372n61.js +0 -546
- package/dist/chunk-aja9y1vn.js +0 -68
- package/dist/chunk-fvcvrh3d.css +0 -1
- package/dist/chunk-gtfjw3nx.js +0 -1
- package/dist/chunk-j39y2aky.js +0 -14
- package/dist/chunk-pcnahct1.js +0 -5
- package/dist/chunk-pja30km3.js +0 -1
- package/dist/chunk-rm894bc2.js +0 -2
- package/dist/chunk-tevvtfbk.js +0 -10
- package/dist/chunk-tgt9zd0r.js +0 -2
- package/dist/chunk-tv5k5z00.js +0 -1
- package/dist/chunk-zq2ae5dx.js +0 -2
- package/lib/experimental.ts +0 -14
- package/workspace/.claude/skills/moi-workspace/references/DESIGN.md +0 -157
- /package/client/features/{settings → app-settings}/profile-settings.tsx +0 -0
- /package/client/features/{settings → app-settings}/settings-section.tsx +0 -0
- /package/client/features/{settings → app-settings}/users-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/environment-settings.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/icon-picker-options.ts +0 -0
- /package/client/features/{settings → workspace/settings}/settings-layout.tsx +0 -0
- /package/client/features/{settings → workspace/settings}/workspace-settings-dialog.tsx +0 -0
- /package/{workspace/.claude/skills/moi-workspace → skill}/references/INTENTS.md +0 -0
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
// Claude Code as a Harness. Thin wiring over this folder's modules — see
|
|
2
2
|
// ../types.ts for the contract and ../README.md for the architecture.
|
|
3
|
+
import { runClaudeAction } from './run-action'
|
|
3
4
|
import { join } from 'node:path'
|
|
4
5
|
import { forkSession } from '@anthropic-ai/claude-agent-sdk'
|
|
5
6
|
|
|
6
|
-
import type { McpServer } from '@/lib/types'
|
|
7
|
-
|
|
8
7
|
import type { DiscoveredWorkspaceCandidate, Harness } from '../types'
|
|
9
8
|
import { findHarnessExecutable, pathHarnessAvailability } from '../executable'
|
|
10
9
|
import { getClaudeAuthReadiness, startClaudeLogin } from './auth'
|
|
11
10
|
import { isLinkedGitWorktree } from './git-worktree'
|
|
12
|
-
import { getMcpStatus } from './mcp'
|
|
11
|
+
import { claudeConnectors, getMcpStatus } from './mcp'
|
|
13
12
|
import { getClaudeModels, lastProbedClaudeCli, onClaudeCliChanged } from './models'
|
|
14
13
|
import {
|
|
15
14
|
SESSION_LIMITS,
|
|
@@ -82,6 +81,7 @@ onClaudeCliChanged(() => retireCCSessionsOnCliChange())
|
|
|
82
81
|
|
|
83
82
|
export const claudeCodeHarness: Harness = {
|
|
84
83
|
id: 'claude-code',
|
|
84
|
+
runAction: runClaudeAction,
|
|
85
85
|
capabilities: {
|
|
86
86
|
supportsStreaming: true,
|
|
87
87
|
imagesInline: 'base64',
|
|
@@ -104,9 +104,8 @@ export const claudeCodeHarness: Harness = {
|
|
|
104
104
|
getSessionWorkspacePreview(ws.path, includeFirstUserMessage),
|
|
105
105
|
sessionEvents: (ws, sessionId) => getSessionEvents(sessionId, ws.path),
|
|
106
106
|
listModels: ws => getClaudeModels(ws.path),
|
|
107
|
-
//
|
|
108
|
-
|
|
109
|
-
mcpStatus: async ws => (await getMcpStatus(ws.path)) as unknown as McpServer[],
|
|
107
|
+
// Expose only provider apps and explicitly configured MCP servers.
|
|
108
|
+
mcpStatus: async ws => claudeConnectors(await getMcpStatus(ws.path)),
|
|
110
109
|
discoverWorkspaces,
|
|
111
110
|
availability: async ws => {
|
|
112
111
|
const runtime = await pathHarnessAvailability('claude-code')
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { query } from '@anthropic-ai/claude-agent-sdk'
|
|
2
2
|
import type { McpServerStatus, SDKUserMessage } from '@anthropic-ai/claude-agent-sdk'
|
|
3
|
+
import type { McpServer } from '@/lib/types'
|
|
4
|
+
|
|
5
|
+
export function claudeConnectors(servers: McpServerStatus[]): McpServer[] {
|
|
6
|
+
const customSources = new Set(['user', 'project', 'local', 'managed', 'enterprise', 'plugin'])
|
|
7
|
+
return servers.flatMap(server => {
|
|
8
|
+
const source = server.source ?? server.scope
|
|
9
|
+
if (source === 'sdk' || source === 'agent' || source === 'dynamic') return []
|
|
10
|
+
const app = source === 'claudeai' || server.config?.type === 'claudeai-proxy'
|
|
11
|
+
if (!app && (!source || !customSources.has(source))) return []
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
name: server.name,
|
|
15
|
+
status: server.status
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
})
|
|
19
|
+
}
|
|
3
20
|
|
|
4
21
|
import { claudeCodeSpawn } from '../../agent-launcher'
|
|
5
22
|
import { debugEnabled } from '../../debug'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { query
|
|
1
|
+
import { query } from '@anthropic-ai/claude-agent-sdk'
|
|
2
2
|
import type { ModelInfo } from '@anthropic-ai/claude-agent-sdk'
|
|
3
3
|
|
|
4
4
|
import type { Model } from '@/lib/types'
|
|
@@ -97,24 +97,6 @@ const catalog = createClaudeCatalog({ probe: probeClaudeCli, fetch: fetchClaudeM
|
|
|
97
97
|
export const onClaudeCliChanged = catalog.onCliChanged
|
|
98
98
|
export const lastProbedClaudeCli = catalog.current
|
|
99
99
|
|
|
100
|
-
export function withClaudeFastModeDefault(
|
|
101
|
-
models: readonly ModelInfo[],
|
|
102
|
-
defaultFastMode: boolean
|
|
103
|
-
): Model[] {
|
|
104
|
-
return models.map(model =>
|
|
105
|
-
model.supportsFastMode ? { ...model, defaultFastMode } : { ...model }
|
|
106
|
-
)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
100
|
export async function getClaudeModels(cwd: string): Promise<Model[]> {
|
|
110
|
-
|
|
111
|
-
const [models, settings] = await Promise.all([
|
|
112
|
-
catalog.models(cwd, executable),
|
|
113
|
-
resolveSettings({ cwd, settingSources: ['user', 'project'] })
|
|
114
|
-
])
|
|
115
|
-
const defaultFastMode =
|
|
116
|
-
settings.effective.fastModePerSessionOptIn === true
|
|
117
|
-
? false
|
|
118
|
-
: settings.effective.fastMode === true
|
|
119
|
-
return withClaudeFastModeDefault(models, defaultFastMode)
|
|
101
|
+
return catalog.models(cwd, requireHarnessExecutable('claude-code'))
|
|
120
102
|
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { query, type Options, type Query } from '@anthropic-ai/claude-agent-sdk'
|
|
2
|
+
import { claudeCodeSpawn } from '../../agent-launcher'
|
|
3
|
+
import type { ActionModel, HarnessActionInput } from '../types'
|
|
4
|
+
import { requireHarnessExecutable } from '../executable'
|
|
5
|
+
import {
|
|
6
|
+
type ActionExecution,
|
|
7
|
+
actionProgressServerName,
|
|
8
|
+
actionProgressToolName,
|
|
9
|
+
executeHarnessAction
|
|
10
|
+
} from '../run-action'
|
|
11
|
+
|
|
12
|
+
const actionModels: Record<ActionModel, Required<Pick<Options, 'model' | 'effort'>>> = {
|
|
13
|
+
fast: { model: 'haiku', effort: 'high' },
|
|
14
|
+
normal: { model: 'sonnet', effort: 'medium' },
|
|
15
|
+
smart: { model: 'sonnet', effort: 'xhigh' }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const readTools = new Set([
|
|
19
|
+
'Read',
|
|
20
|
+
'Glob',
|
|
21
|
+
'Grep',
|
|
22
|
+
'WebSearch',
|
|
23
|
+
'WebFetch',
|
|
24
|
+
'ToolSearch',
|
|
25
|
+
'ListMcpResources',
|
|
26
|
+
'ReadMcpResource',
|
|
27
|
+
'StructuredOutput'
|
|
28
|
+
])
|
|
29
|
+
export function canReadTool(
|
|
30
|
+
name: string,
|
|
31
|
+
annotations?: { readOnly?: boolean; destructive?: boolean }
|
|
32
|
+
) {
|
|
33
|
+
return (
|
|
34
|
+
readTools.has(name) ||
|
|
35
|
+
(name.startsWith('mcp__') && annotations?.readOnly === true && annotations.destructive !== true)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function claudeAction(input: ActionExecution): Promise<unknown> {
|
|
40
|
+
const controller = new AbortController()
|
|
41
|
+
const abort = () => controller.abort()
|
|
42
|
+
input.signal.addEventListener('abort', abort, { once: true })
|
|
43
|
+
if (input.signal.aborted) controller.abort()
|
|
44
|
+
let run: Query | undefined
|
|
45
|
+
try {
|
|
46
|
+
run = query({
|
|
47
|
+
prompt: input.prompt,
|
|
48
|
+
options: {
|
|
49
|
+
...actionModels[input.model],
|
|
50
|
+
cwd: input.cwd,
|
|
51
|
+
abortController: controller,
|
|
52
|
+
persistSession: false,
|
|
53
|
+
maxTurns: 24,
|
|
54
|
+
pathToClaudeCodeExecutable: requireHarnessExecutable('claude-code'),
|
|
55
|
+
spawnClaudeCodeProcess: claudeCodeSpawn(),
|
|
56
|
+
settingSources: [],
|
|
57
|
+
env: { ...process.env, CLAUDECODE: undefined },
|
|
58
|
+
outputFormat: { type: 'json_schema', schema: input.resultSchema },
|
|
59
|
+
mcpServers: input.progressUrl
|
|
60
|
+
? {
|
|
61
|
+
[actionProgressServerName]: { type: 'http', url: input.progressUrl, alwaysLoad: true }
|
|
62
|
+
}
|
|
63
|
+
: undefined,
|
|
64
|
+
permissionMode: 'default',
|
|
65
|
+
hooks: {
|
|
66
|
+
PreToolUse: [
|
|
67
|
+
{
|
|
68
|
+
hooks: [
|
|
69
|
+
async event => {
|
|
70
|
+
if (event.hook_event_name !== 'PreToolUse') return {}
|
|
71
|
+
let allowed =
|
|
72
|
+
canReadTool(event.tool_name) ||
|
|
73
|
+
(!!input.progressUrl &&
|
|
74
|
+
event.tool_name ===
|
|
75
|
+
`mcp__${actionProgressServerName}__${actionProgressToolName}`)
|
|
76
|
+
if (!allowed && event.mcp_server && run) {
|
|
77
|
+
const servers = await run.mcpServerStatus()
|
|
78
|
+
const server = servers.find(server => server.name === event.mcp_server?.name)
|
|
79
|
+
const toolName = event.tool_name.split('__').slice(2).join('__')
|
|
80
|
+
allowed =
|
|
81
|
+
server?.tools?.some(
|
|
82
|
+
tool =>
|
|
83
|
+
tool.name === toolName && canReadTool(event.tool_name, tool.annotations)
|
|
84
|
+
) ?? false
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
hookSpecificOutput: {
|
|
88
|
+
hookEventName: 'PreToolUse',
|
|
89
|
+
permissionDecision: allowed ? 'allow' : 'deny',
|
|
90
|
+
permissionDecisionReason: 'This action only permits read/search tools'
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
canUseTool: async () => ({
|
|
99
|
+
behavior: 'deny',
|
|
100
|
+
message: 'This action only permits approved read/search tools'
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
for await (const message of run) {
|
|
105
|
+
if (message.type === 'result' && message.subtype === 'success' && !message.is_error)
|
|
106
|
+
return message.structured_output
|
|
107
|
+
if (message.type === 'result')
|
|
108
|
+
throw new Error(
|
|
109
|
+
message.subtype === 'success' ? message.result : 'The agent could not complete the action'
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
throw new Error('The agent returned no structured output')
|
|
113
|
+
} finally {
|
|
114
|
+
input.signal.removeEventListener('abort', abort)
|
|
115
|
+
run?.close()
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export async function runClaudeAction<TResult, TProgress = never>(
|
|
120
|
+
input: HarnessActionInput<TResult, TProgress>
|
|
121
|
+
): Promise<TResult> {
|
|
122
|
+
return executeHarnessAction(input, claudeAction)
|
|
123
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import { createHarnessTempDir, removeHarnessTempDir, runHarnessCommand } from '../command'
|
|
1
2
|
import { getSessionInfo, renameSession, type SDKSessionInfo } from '@anthropic-ai/claude-agent-sdk'
|
|
2
3
|
|
|
3
4
|
import {
|
|
4
5
|
SESSION_TITLE_SCHEMA,
|
|
5
6
|
SESSION_TITLE_SYSTEM_PROMPT,
|
|
6
7
|
SESSION_TITLE_TIMEOUT_MS,
|
|
7
|
-
|
|
8
|
-
parseGeneratedSessionTitle,
|
|
9
|
-
removeSessionTitleTempDir,
|
|
10
|
-
runSessionTitleCommand
|
|
8
|
+
parseGeneratedSessionTitle
|
|
11
9
|
} from '../session-title'
|
|
12
10
|
import { requireHarnessExecutable } from '../executable'
|
|
13
11
|
|
|
@@ -61,8 +59,8 @@ export async function generateClaudeSessionTitle(input: {
|
|
|
61
59
|
)
|
|
62
60
|
let tempDir: string | undefined
|
|
63
61
|
try {
|
|
64
|
-
tempDir = await
|
|
65
|
-
const output = await
|
|
62
|
+
tempDir = await createHarnessTempDir()
|
|
63
|
+
const output = await runHarnessCommand({
|
|
66
64
|
command: claudeSessionTitleCommand(requireHarnessExecutable('claude-code')),
|
|
67
65
|
cwd: tempDir,
|
|
68
66
|
stdin: JSON.stringify({ sessionTitleSource: input.source }),
|
|
@@ -72,7 +70,7 @@ export async function generateClaudeSessionTitle(input: {
|
|
|
72
70
|
return output ? parseClaudeSessionTitleOutput(output) : null
|
|
73
71
|
} finally {
|
|
74
72
|
clearTimeout(timer)
|
|
75
|
-
if (tempDir) await
|
|
73
|
+
if (tempDir) await removeHarnessTempDir(tempDir).catch(() => {})
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
76
|
|
|
@@ -37,6 +37,9 @@ import { resolveWorkspaceEnv } from '../../workspaces/env'
|
|
|
37
37
|
import { requireHarnessExecutable } from '../executable'
|
|
38
38
|
import type { SendMessageInput } from '../types'
|
|
39
39
|
|
|
40
|
+
// Claude supports only the original two speed modes.
|
|
41
|
+
type ClaudeSendMessageInput = Omit<SendMessageInput, 'speedMode'> & { fastMode: boolean }
|
|
42
|
+
|
|
40
43
|
// Media types Claude vision accepts; uploads.ts guarantees every image upload is
|
|
41
44
|
// normalized to one of these, so the cast on `media_type` below is sound.
|
|
42
45
|
type ImageMediaType = 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp'
|
|
@@ -80,7 +83,7 @@ type InputQueue = {
|
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
type PendingMessage = {
|
|
83
|
-
input:
|
|
86
|
+
input: ClaudeSendMessageInput
|
|
84
87
|
content: MessageContent
|
|
85
88
|
titleSource: string
|
|
86
89
|
turnId: string
|
|
@@ -129,8 +132,8 @@ type LiveSession = {
|
|
|
129
132
|
// the SDK does not guarantee their ordering relative to snapshots.
|
|
130
133
|
sawBackgroundSnapshot: boolean
|
|
131
134
|
model: string | undefined
|
|
132
|
-
// Live flag settings; undefined inherits provider
|
|
133
|
-
fastMode: boolean
|
|
135
|
+
// Live flag settings; undefined effort inherits the provider default.
|
|
136
|
+
fastMode: boolean
|
|
134
137
|
effort: string | undefined
|
|
135
138
|
// `includePartialMessages` is fixed at creation, so changes require resume.
|
|
136
139
|
stream: boolean
|
|
@@ -189,7 +192,7 @@ export type CCDebugSession = {
|
|
|
189
192
|
workspaceId: string
|
|
190
193
|
sessionId: string
|
|
191
194
|
model: string | undefined
|
|
192
|
-
fastMode: boolean
|
|
195
|
+
fastMode: boolean
|
|
193
196
|
effort: string | undefined
|
|
194
197
|
stream: boolean
|
|
195
198
|
queuedMessages: number
|
|
@@ -420,18 +423,19 @@ async function consume(s: LiveSession) {
|
|
|
420
423
|
const realId = msg.session_id
|
|
421
424
|
if (realId && realId !== s.sessionId) {
|
|
422
425
|
const from = renameSession(s, realId)
|
|
423
|
-
await renameSessionReferences(
|
|
426
|
+
await renameSessionReferences(
|
|
427
|
+
{ id: s.workspaceId, path: s.workspacePath },
|
|
428
|
+
from,
|
|
429
|
+
s.sessionId
|
|
430
|
+
)
|
|
424
431
|
}
|
|
425
432
|
startClaudeSessionTitleJob(s)
|
|
426
433
|
// Seed explicit startup settings only when no saved picker choice exists.
|
|
427
|
-
if (
|
|
428
|
-
(s.
|
|
429
|
-
!(await hasSessionConfig(s.workspacePath, s.sessionId))
|
|
430
|
-
) {
|
|
431
|
-
await saveSessionConfig(s.workspacePath, s.sessionId, {
|
|
434
|
+
if (!(await hasSessionConfig({ id: s.workspaceId, path: s.workspacePath }, s.sessionId))) {
|
|
435
|
+
await saveSessionConfig({ id: s.workspaceId, path: s.workspacePath }, s.sessionId, {
|
|
432
436
|
model: s.model,
|
|
433
437
|
effort: s.effort,
|
|
434
|
-
|
|
438
|
+
speedMode: s.fastMode ? 'fast' : 'normal'
|
|
435
439
|
})
|
|
436
440
|
}
|
|
437
441
|
}
|
|
@@ -587,7 +591,7 @@ function createLiveSession(input: {
|
|
|
587
591
|
isNew: boolean
|
|
588
592
|
model: string | undefined
|
|
589
593
|
effort: string | undefined
|
|
590
|
-
fastMode: boolean
|
|
594
|
+
fastMode: boolean
|
|
591
595
|
stream: boolean
|
|
592
596
|
// Resolved workspace env, fixed for the lifetime of the subprocess.
|
|
593
597
|
workspaceEnv: Record<string, string>
|
|
@@ -610,7 +614,7 @@ function createLiveSession(input: {
|
|
|
610
614
|
// Harness-neutral settings are strings; the picker supplies this model's
|
|
611
615
|
// supported effort levels from the SDK catalog.
|
|
612
616
|
...(input.effort ? { effort: input.effort as Options['effort'] } : {}),
|
|
613
|
-
|
|
617
|
+
settings: { fastMode: input.fastMode },
|
|
614
618
|
// Partial frames enable the opt-in live preview.
|
|
615
619
|
includePartialMessages: input.stream,
|
|
616
620
|
permissionMode: 'auto',
|
|
@@ -659,7 +663,7 @@ function createLiveSession(input: {
|
|
|
659
663
|
sessions.set(recKey(session.workspaceId, session.sessionId), session)
|
|
660
664
|
input.messages.live = session
|
|
661
665
|
debug(
|
|
662
|
-
`cc create ${input.isNew ? 'new' : 'resume'} ws=${input.workspaceId} session=${input.sessionId} model=${input.model ?? 'default'} effort=${input.effort ?? 'default'} fast=${input.fastMode
|
|
666
|
+
`cc create ${input.isNew ? 'new' : 'resume'} ws=${input.workspaceId} session=${input.sessionId} model=${input.model ?? 'default'} effort=${input.effort ?? 'default'} fast=${input.fastMode} live=${sessions.size}`
|
|
663
667
|
)
|
|
664
668
|
void consume(session)
|
|
665
669
|
return session
|
|
@@ -667,7 +671,11 @@ function createLiveSession(input: {
|
|
|
667
671
|
|
|
668
672
|
// Accept immediately, but keep the prompt and its settings in Moi until its
|
|
669
673
|
// turn starts. The returned promise settles when the message reaches the SDK.
|
|
670
|
-
export async function sendCCMessage(
|
|
674
|
+
export async function sendCCMessage(incoming: SendMessageInput): Promise<void> {
|
|
675
|
+
const input: ClaudeSendMessageInput = {
|
|
676
|
+
...incoming,
|
|
677
|
+
fastMode: incoming.speedMode === 'fast'
|
|
678
|
+
}
|
|
671
679
|
const prepared = prepareAttachmentMessage(input.workspaceId, input.content, input.attachments)
|
|
672
680
|
if (!prepared.text) return
|
|
673
681
|
const { content: userContent, parts } = buildUserMessage(prepared)
|
|
@@ -796,7 +804,7 @@ async function dispatchNextMessage(messages: SessionMessages): Promise<void> {
|
|
|
796
804
|
...(input.effort !== s.effort
|
|
797
805
|
? { effortLevel: (input.effort as Options['effort']) ?? null }
|
|
798
806
|
: {}),
|
|
799
|
-
...(input.fastMode !== s.fastMode ? { fastMode: input.fastMode
|
|
807
|
+
...(input.fastMode !== s.fastMode ? { fastMode: input.fastMode } : {})
|
|
800
808
|
})
|
|
801
809
|
if (!s.closed) {
|
|
802
810
|
s.effort = input.effort
|
|
@@ -102,7 +102,7 @@ does not spawn one per card.
|
|
|
102
102
|
Workspace import discovery separately reads up to 400 recent rollout heads
|
|
103
103
|
under the server's `$CODEX_HOME/sessions`, without requiring a CLI executable.
|
|
104
104
|
|
|
105
|
-
## Models, effort, and
|
|
105
|
+
## Models, effort, and speed modes
|
|
106
106
|
|
|
107
107
|
`model/list` is the source of picker capabilities. The catalog is paginated,
|
|
108
108
|
filters hidden rows, and is cached per client for one minute. Login/account
|
|
@@ -120,14 +120,19 @@ Changing a selection does not retry an earlier failed message.
|
|
|
120
120
|
Configured reasoning effort applies when supported by the selected model;
|
|
121
121
|
otherwise the adapter uses its advertised default. Fast mode is available when
|
|
122
122
|
`serviceTiers` includes `priority`. Only catalogs missing that field fall back
|
|
123
|
-
to `additionalSpeedTiers: ["fast"]`.
|
|
124
|
-
|
|
123
|
+
to `additionalSpeedTiers: ["fast"]`. Ultrafast uses the same capability check for
|
|
124
|
+
`ultrafast`, including the legacy fallback only when `serviceTiers` is missing.
|
|
125
|
+
The picker cycles regular → fast → ultrafast → regular, skipping unavailable
|
|
126
|
+
tiers. Moi stores `speedMode` as `normal`, `fast`, or `ultrafast`.
|
|
125
127
|
|
|
126
|
-
| Moi
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
128
|
+
| Moi speed mode | Native `serviceTier` |
|
|
129
|
+
| --------------- | -------------------- |
|
|
130
|
+
| Normal or unset | `null` |
|
|
131
|
+
| Fast | `"priority"` |
|
|
132
|
+
| Ultrafast | `"ultrafast"` |
|
|
133
|
+
|
|
134
|
+
When the catalog is available, UI sends resolve speed against model capabilities.
|
|
135
|
+
Unsupported Ultrafast falls back to Fast when supported, otherwise Normal.
|
|
131
136
|
|
|
132
137
|
Model, effort, and tier changes apply on the next **new turn**. `turn/steer`
|
|
133
138
|
has no fields for changing them during an active turn. Moi uses the persistent
|
|
@@ -204,8 +209,15 @@ Before restoring support:
|
|
|
204
209
|
is required. The status request omits resource catalogs with `toolsAndAuthOnly`.
|
|
205
210
|
It targets the workspace's most recently observed loaded chat, since an
|
|
206
211
|
app-scoped request can return null runtime states.
|
|
207
|
-
|
|
208
|
-
|
|
212
|
+
Settings list accessible apps from `app/list`, joined with `app/installed` for
|
|
213
|
+
runtime state. Custom MCP servers must have an explicit user, project, or admin
|
|
214
|
+
configuration layer; injected and packaged servers are omitted. Discovery failures
|
|
215
|
+
reach the Settings retry state. Full tool definitions and connector `_meta` are
|
|
216
|
+
not forwarded to display rows.
|
|
217
|
+
Settings request `/mcp?stream=true` for incremental NDJSON snapshots. Codex
|
|
218
|
+
`app/list/updated` notifications and paginated results feed partial rows; only
|
|
219
|
+
the final snapshot marks discovery complete. `app/list` has a 60-second RPC
|
|
220
|
+
deadline while other methods retain the default 30 seconds.
|
|
209
221
|
|
|
210
222
|
## Diagnostics and maintenance
|
|
211
223
|
|
|
@@ -13,7 +13,7 @@ import type {
|
|
|
13
13
|
Turn
|
|
14
14
|
} from '@/lib/format'
|
|
15
15
|
import { stripMoiContextLoose } from '@/lib/moi-context'
|
|
16
|
-
import type { McpServer, Model, SessionSummary } from '@/lib/types'
|
|
16
|
+
import type { SpeedMode, McpServer, Model, SessionSummary } from '@/lib/types'
|
|
17
17
|
|
|
18
18
|
import type { WorkspaceActivityPreview } from '../types'
|
|
19
19
|
|
|
@@ -133,11 +133,11 @@ export function withCodexTurnDuration(turn: Turn, durationMs: number | null | un
|
|
|
133
133
|
|
|
134
134
|
const CODEX_FAST_SERVICE_TIER = 'priority'
|
|
135
135
|
|
|
136
|
-
export function
|
|
137
|
-
|
|
138
|
-
): typeof CODEX_FAST_SERVICE_TIER |
|
|
139
|
-
if (
|
|
140
|
-
return
|
|
136
|
+
export function codexServiceTierForSpeedMode(
|
|
137
|
+
speedMode: SpeedMode | undefined
|
|
138
|
+
): typeof CODEX_FAST_SERVICE_TIER | 'ultrafast' | null {
|
|
139
|
+
if (speedMode === 'ultrafast') return 'ultrafast'
|
|
140
|
+
return speedMode === 'fast' ? CODEX_FAST_SERVICE_TIER : null
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// Legacy context can be cut mid-envelope in a thread/list preview.
|
|
@@ -185,16 +185,17 @@ export function selectCodexWorkspacePreview(
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
export function codexModelToModel(m: CodexModel
|
|
188
|
+
export function codexModelToModel(m: CodexModel): Model {
|
|
189
189
|
const efforts = (m.supportedReasoningEfforts ?? []).map(e => e.reasoningEffort)
|
|
190
190
|
const displayName = m.displayName.replace(/^GPT-/, '').replaceAll('-', ' ')
|
|
191
191
|
const supportsFastMode =
|
|
192
192
|
m.serviceTiers !== undefined
|
|
193
193
|
? m.serviceTiers.some(tier => tier.id === CODEX_FAST_SERVICE_TIER)
|
|
194
194
|
: (m.additionalSpeedTiers ?? []).includes('fast')
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
const supportsUltrafastMode =
|
|
196
|
+
m.serviceTiers !== undefined
|
|
197
|
+
? m.serviceTiers.some(tier => tier.id === 'ultrafast')
|
|
198
|
+
: (m.additionalSpeedTiers ?? []).includes('ultrafast')
|
|
198
199
|
return {
|
|
199
200
|
value: m.id,
|
|
200
201
|
resolvedModel: m.model,
|
|
@@ -208,12 +209,8 @@ export function codexModelToModel(m: CodexModel, configuredServiceTier?: string
|
|
|
208
209
|
...(m.defaultReasoningEffort && efforts.includes(m.defaultReasoningEffort)
|
|
209
210
|
? { defaultEffort: m.defaultReasoningEffort }
|
|
210
211
|
: {}),
|
|
211
|
-
...(
|
|
212
|
-
|
|
213
|
-
supportsFastMode: true,
|
|
214
|
-
defaultFastMode: defaultServiceTier === CODEX_FAST_SERVICE_TIER
|
|
215
|
-
}
|
|
216
|
-
: {})
|
|
212
|
+
...(supportsUltrafastMode ? { supportsUltrafastMode: true } : {}),
|
|
213
|
+
...(supportsFastMode ? { supportsFastMode: true } : {})
|
|
217
214
|
}
|
|
218
215
|
}
|
|
219
216
|
|
|
@@ -248,7 +245,7 @@ export function codexMcpServerToServer(server: {
|
|
|
248
245
|
|
|
249
246
|
export function codexModelsToModels(models: CodexModel[], config: CodexConfig): Model[] {
|
|
250
247
|
const mapped = models.map(model => {
|
|
251
|
-
const row = codexModelToModel(model
|
|
248
|
+
const row = codexModelToModel(model)
|
|
252
249
|
// Apply configured effort to every model that supports it, even with an
|
|
253
250
|
// explicit model override. Otherwise retain the catalog default.
|
|
254
251
|
if (
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// threads share the connection. Framing lives in transport.ts; see NOTES.md
|
|
3
3
|
// for lifecycle, configuration, and wire-type maintenance.
|
|
4
4
|
import { homedir } from 'node:os'
|
|
5
|
+
import { expandCodexApps } from './connectors'
|
|
5
6
|
|
|
6
7
|
import type { McpServer, Model, SessionSummary, StreamEvent } from '@/lib/types'
|
|
7
8
|
|
|
@@ -50,7 +51,7 @@ export function getCodexProcessInfo(workspacePath: string): Promise<CodexProcess
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
export type CodexClient = {
|
|
53
|
-
rpc: <T>(method: string, params?: Json) => Promise<T>
|
|
54
|
+
rpc: <T>(method: string, params?: Json, options?: { timeoutMs?: number }) => Promise<T>
|
|
54
55
|
onNotification: (l: NotificationListener) => () => void
|
|
55
56
|
isAlive: () => boolean
|
|
56
57
|
workspacePath: string
|
|
@@ -359,7 +360,8 @@ export async function getCodexModels(workspacePath: string): Promise<Model[]> {
|
|
|
359
360
|
// Runtime status distinguishes failed/disabled servers from authenticated ones.
|
|
360
361
|
export async function getCodexMcpStatus(
|
|
361
362
|
workspacePath: string,
|
|
362
|
-
sessionId?: string
|
|
363
|
+
sessionId?: string,
|
|
364
|
+
onProgress?: (connectors: McpServer[]) => void
|
|
363
365
|
): Promise<McpServer[]> {
|
|
364
366
|
try {
|
|
365
367
|
const client = await getCodexClient(workspacePath)
|
|
@@ -371,12 +373,13 @@ export async function getCodexMcpStatus(
|
|
|
371
373
|
detail: 'toolsAndAuthOnly',
|
|
372
374
|
...(sessionId ? { threadId: sessionId } : {})
|
|
373
375
|
})
|
|
374
|
-
|
|
376
|
+
const mapped = servers
|
|
375
377
|
.filter((s): s is { name: string; authStatus?: string } => typeof s.name === 'string')
|
|
376
378
|
.map(codexMcpServerToServer)
|
|
379
|
+
return await expandCodexApps(client, mapped, sessionId, workspacePath, onProgress)
|
|
377
380
|
} catch (err) {
|
|
378
|
-
console.error('[codex]
|
|
379
|
-
|
|
381
|
+
console.error('[codex] connector discovery failed', err)
|
|
382
|
+
throw err
|
|
380
383
|
}
|
|
381
384
|
}
|
|
382
385
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { McpServer } from '@/lib/types'
|
|
2
|
+
import type { CodexClient } from './client'
|
|
3
|
+
import { readCodexPages } from './pagination'
|
|
4
|
+
|
|
5
|
+
type InstalledApp = { id: string; enabled: boolean; callable: boolean }
|
|
6
|
+
type App = {
|
|
7
|
+
id: string
|
|
8
|
+
name: string
|
|
9
|
+
logoUrl: string | null
|
|
10
|
+
isAccessible: boolean
|
|
11
|
+
isEnabled: boolean
|
|
12
|
+
}
|
|
13
|
+
type ConfigLayer = {
|
|
14
|
+
name: { type: string }
|
|
15
|
+
config: { mcp_servers?: Record<string, unknown> }
|
|
16
|
+
disabledReason?: string | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const customSources = new Set([
|
|
20
|
+
'user',
|
|
21
|
+
'project',
|
|
22
|
+
'system',
|
|
23
|
+
'mdm',
|
|
24
|
+
'enterpriseManaged',
|
|
25
|
+
'legacyManagedConfigTomlFromFile',
|
|
26
|
+
'legacyManagedConfigTomlFromMdm'
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
export async function expandCodexApps(
|
|
30
|
+
client: Pick<CodexClient, 'rpc'> & Partial<Pick<CodexClient, 'onNotification'>>,
|
|
31
|
+
servers: McpServer[],
|
|
32
|
+
sessionId?: string,
|
|
33
|
+
workspacePath?: string,
|
|
34
|
+
onProgress?: (connectors: McpServer[]) => void
|
|
35
|
+
): Promise<McpServer[]> {
|
|
36
|
+
const context = sessionId ? { threadId: sessionId } : {}
|
|
37
|
+
const config = await client.rpc<{ layers: ConfigLayer[] | null }>('config/read', {
|
|
38
|
+
cwd: workspacePath,
|
|
39
|
+
includeLayers: true
|
|
40
|
+
})
|
|
41
|
+
// Only explicit configuration belongs in the custom-server list. Runtime-injected
|
|
42
|
+
// and packaged tools have no user/project/admin definition.
|
|
43
|
+
const customNames = new Set(
|
|
44
|
+
(config.layers ?? [])
|
|
45
|
+
.filter(layer => !layer.disabledReason && customSources.has(layer.name.type))
|
|
46
|
+
.flatMap(layer => Object.keys(layer.config.mcp_servers ?? {}))
|
|
47
|
+
)
|
|
48
|
+
const custom = servers.filter(
|
|
49
|
+
server => server.name !== 'codex_apps' && customNames.has(server.name)
|
|
50
|
+
)
|
|
51
|
+
if (!servers.some(server => server.name === 'codex_apps')) return custom
|
|
52
|
+
|
|
53
|
+
onProgress?.(custom)
|
|
54
|
+
const installed = await client.rpc<{ apps: InstalledApp[] }>('app/installed', context)
|
|
55
|
+
const runtime = new Map(installed.apps.map(app => [app.id, app]))
|
|
56
|
+
const toConnectors = (apps: App[]): McpServer[] => [
|
|
57
|
+
...custom,
|
|
58
|
+
...apps.map((app): McpServer => {
|
|
59
|
+
const state = runtime.get(app.id)
|
|
60
|
+
return {
|
|
61
|
+
name: `codex_apps/${app.id}`,
|
|
62
|
+
displayName: app.name,
|
|
63
|
+
iconUrl: app.logoUrl ? new URL(app.logoUrl, 'https://chatgpt.com').href : undefined,
|
|
64
|
+
status: !(state?.enabled ?? app.isEnabled)
|
|
65
|
+
? 'disabled'
|
|
66
|
+
: state?.callable
|
|
67
|
+
? 'connected'
|
|
68
|
+
: 'pending'
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
const progressApps = new Map<string, App>()
|
|
73
|
+
const publish = (apps: App[]) => {
|
|
74
|
+
for (const app of apps) if (app.isAccessible) progressApps.set(app.id, app)
|
|
75
|
+
onProgress?.(toConnectors([...progressApps.values()]))
|
|
76
|
+
}
|
|
77
|
+
const unsubscribe = client.onNotification?.((method, params) => {
|
|
78
|
+
if (method !== 'app/list/updated' || !Array.isArray(params.data)) return
|
|
79
|
+
publish(params.data as App[])
|
|
80
|
+
})
|
|
81
|
+
try {
|
|
82
|
+
const apps = await readCodexPages<App>(
|
|
83
|
+
client,
|
|
84
|
+
'app/list',
|
|
85
|
+
{ ...context, limit: 100 },
|
|
86
|
+
{ timeoutMs: 60_000, onPage: publish }
|
|
87
|
+
)
|
|
88
|
+
return toConnectors(apps.filter(app => app.isAccessible))
|
|
89
|
+
} finally {
|
|
90
|
+
unsubscribe?.()
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Codex as a Harness. Thin wiring over this folder's modules — see
|
|
2
2
|
// ../types.ts for the contract and ../README.md for the architecture.
|
|
3
|
+
import { runCodexAction } from './run-action'
|
|
3
4
|
import type { Harness } from '../types'
|
|
4
5
|
import { ForkUnsupportedError } from '../fork'
|
|
5
6
|
import { CodexRpcError } from './transport'
|
|
@@ -31,6 +32,7 @@ import { formatCodexStatusLines } from './status'
|
|
|
31
32
|
|
|
32
33
|
export const codexHarness: Harness = {
|
|
33
34
|
id: 'codex',
|
|
35
|
+
runAction: runCodexAction,
|
|
34
36
|
capabilities: {
|
|
35
37
|
supportsStreaming: true, // app-server always streams deltas; moi gates forwarding
|
|
36
38
|
imagesInline: 'data-url',
|
|
@@ -79,7 +81,8 @@ export const codexHarness: Harness = {
|
|
|
79
81
|
}
|
|
80
82
|
},
|
|
81
83
|
listModels: ws => getCodexModels(ws.path),
|
|
82
|
-
mcpStatus:
|
|
84
|
+
mcpStatus: (ws, onProgress) =>
|
|
85
|
+
getCodexMcpStatus(ws.path, getLatestCodexSessionId(ws.id), onProgress),
|
|
83
86
|
discoverWorkspaces: registeredPaths => discoverCodexWorkspaces(registeredPaths),
|
|
84
87
|
availability: async ws => {
|
|
85
88
|
const runtime = await pathHarnessAvailability('codex')
|