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
|
@@ -5,17 +5,20 @@ import type { CodexClient } from './client'
|
|
|
5
5
|
export async function readCodexPages<T>(
|
|
6
6
|
client: Pick<CodexClient, 'rpc'>,
|
|
7
7
|
method: string,
|
|
8
|
-
params: Record<string, unknown> = {}
|
|
8
|
+
params: Record<string, unknown> = {},
|
|
9
|
+
options?: { timeoutMs?: number; onPage?: (rows: T[]) => void }
|
|
9
10
|
): Promise<T[]> {
|
|
10
11
|
const rows: T[] = []
|
|
11
12
|
const cursors = new Set<string>()
|
|
12
13
|
let cursor: string | undefined
|
|
13
14
|
do {
|
|
14
|
-
const page = await client.rpc<{ data?: T[]; nextCursor?: string | null }>(
|
|
15
|
-
|
|
16
|
-
...(cursor ? { cursor } : {})
|
|
17
|
-
|
|
15
|
+
const page = await client.rpc<{ data?: T[]; nextCursor?: string | null }>(
|
|
16
|
+
method,
|
|
17
|
+
{ ...params, ...(cursor ? { cursor } : {}) },
|
|
18
|
+
options?.timeoutMs === undefined ? undefined : { timeoutMs: options.timeoutMs }
|
|
19
|
+
)
|
|
18
20
|
rows.push(...(page.data ?? []))
|
|
21
|
+
options?.onPage?.(page.data ?? [])
|
|
19
22
|
cursor = page.nextCursor || undefined
|
|
20
23
|
if (cursor && cursors.has(cursor)) throw new Error(`Codex ${method} repeated a page cursor`)
|
|
21
24
|
if (cursor) cursors.add(cursor)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { join } from 'node:path'
|
|
2
|
+
import { runHarnessCommand } from '../command'
|
|
3
|
+
import type { ActionModel, HarnessActionInput } from '../types'
|
|
4
|
+
import { requireHarnessExecutable } from '../executable'
|
|
5
|
+
import { actionProgressServerName, executeHarnessAction } from '../run-action'
|
|
6
|
+
|
|
7
|
+
const actionModels: Record<ActionModel, { model: string; effort: 'medium' | 'xhigh' }> = {
|
|
8
|
+
fast: { model: 'gpt-6.1-terra', effort: 'medium' },
|
|
9
|
+
normal: { model: 'gpt-6.1-sol', effort: 'medium' },
|
|
10
|
+
smart: { model: 'gpt-6.1-sol', effort: 'xhigh' }
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function codexActionCommand(
|
|
14
|
+
executable: string,
|
|
15
|
+
cwd: string,
|
|
16
|
+
schema: string,
|
|
17
|
+
output: string,
|
|
18
|
+
progressUrl?: string,
|
|
19
|
+
model: ActionModel = 'normal'
|
|
20
|
+
): string[] {
|
|
21
|
+
return [
|
|
22
|
+
executable,
|
|
23
|
+
'exec',
|
|
24
|
+
'--model',
|
|
25
|
+
actionModels[model].model,
|
|
26
|
+
'-c',
|
|
27
|
+
`model_reasoning_effort=${JSON.stringify(actionModels[model].effort)}`,
|
|
28
|
+
'--ephemeral',
|
|
29
|
+
'--ignore-user-config',
|
|
30
|
+
'--ignore-rules',
|
|
31
|
+
'--strict-config',
|
|
32
|
+
'--skip-git-repo-check',
|
|
33
|
+
'--sandbox',
|
|
34
|
+
'read-only',
|
|
35
|
+
'--cd',
|
|
36
|
+
cwd,
|
|
37
|
+
'--output-schema',
|
|
38
|
+
schema,
|
|
39
|
+
'--output-last-message',
|
|
40
|
+
output,
|
|
41
|
+
'-c',
|
|
42
|
+
'approval_policy="never"',
|
|
43
|
+
// Native connected apps may read; writes require approval and this headless
|
|
44
|
+
// action never grants it. User MCP configs/hooks cannot override this policy.
|
|
45
|
+
'-c',
|
|
46
|
+
'apps._default.default_tools_approval_mode="writes"',
|
|
47
|
+
'-c',
|
|
48
|
+
'apps._default.destructive_enabled=false',
|
|
49
|
+
'-c',
|
|
50
|
+
'apps._default.open_world_enabled=false',
|
|
51
|
+
'-c',
|
|
52
|
+
'features.js_repl=false',
|
|
53
|
+
'-c',
|
|
54
|
+
'features.multi_agent=false',
|
|
55
|
+
'-c',
|
|
56
|
+
'notify=[]',
|
|
57
|
+
...(progressUrl
|
|
58
|
+
? ['-c', `mcp_servers.${actionProgressServerName}.url=${JSON.stringify(progressUrl)}`]
|
|
59
|
+
: []),
|
|
60
|
+
'-'
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function runCodexAction<TResult, TProgress = never>(
|
|
65
|
+
input: HarnessActionInput<TResult, TProgress>
|
|
66
|
+
): Promise<TResult> {
|
|
67
|
+
return executeHarnessAction(input, async action => {
|
|
68
|
+
const { cwd } = action
|
|
69
|
+
const schema = join(cwd, 'schema.json'),
|
|
70
|
+
output = join(cwd, 'result.json')
|
|
71
|
+
await Bun.write(schema, JSON.stringify(action.resultSchema))
|
|
72
|
+
const result = await runHarnessCommand({
|
|
73
|
+
command: codexActionCommand(
|
|
74
|
+
requireHarnessExecutable('codex'),
|
|
75
|
+
cwd,
|
|
76
|
+
schema,
|
|
77
|
+
output,
|
|
78
|
+
action.progressUrl,
|
|
79
|
+
action.model
|
|
80
|
+
),
|
|
81
|
+
cwd,
|
|
82
|
+
stdin: action.prompt,
|
|
83
|
+
signal: input.signal,
|
|
84
|
+
env: Object.fromEntries(
|
|
85
|
+
Object.entries(process.env).filter(
|
|
86
|
+
([key]) => !key.startsWith('CODEX_') || key === 'CODEX_HOME' || key === 'CODEX_API_KEY'
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
})
|
|
90
|
+
if (result === null) throw new Error('The agent could not complete the action')
|
|
91
|
+
return JSON.parse(await Bun.file(output).text())
|
|
92
|
+
})
|
|
93
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHarnessTempDir, removeHarnessTempDir, runHarnessCommand } from '../command'
|
|
1
2
|
import { join } from 'node:path'
|
|
2
3
|
|
|
3
4
|
import type { CodexThread } from './adapter'
|
|
@@ -7,10 +8,7 @@ import {
|
|
|
7
8
|
SESSION_TITLE_SCHEMA,
|
|
8
9
|
SESSION_TITLE_SYSTEM_PROMPT,
|
|
9
10
|
SESSION_TITLE_TIMEOUT_MS,
|
|
10
|
-
|
|
11
|
-
parseGeneratedSessionTitleJson,
|
|
12
|
-
removeSessionTitleTempDir,
|
|
13
|
-
runSessionTitleCommand
|
|
11
|
+
parseGeneratedSessionTitleJson
|
|
14
12
|
} from '../session-title'
|
|
15
13
|
import { requireHarnessExecutable } from '../executable'
|
|
16
14
|
|
|
@@ -96,10 +94,10 @@ export async function generateCodexSessionTitle(input: {
|
|
|
96
94
|
)
|
|
97
95
|
let tempDir: string | undefined
|
|
98
96
|
try {
|
|
99
|
-
tempDir = await
|
|
97
|
+
tempDir = await createHarnessTempDir()
|
|
100
98
|
const executable = requireHarnessExecutable('codex')
|
|
101
99
|
const env = codexSessionTitleEnv()
|
|
102
|
-
const featureOutput = await
|
|
100
|
+
const featureOutput = await runHarnessCommand({
|
|
103
101
|
command: [executable, 'features', 'list'],
|
|
104
102
|
cwd: tempDir,
|
|
105
103
|
signal: input.abortController.signal,
|
|
@@ -111,7 +109,7 @@ export async function generateCodexSessionTitle(input: {
|
|
|
111
109
|
const schemaPath = join(tempDir, 'schema.json')
|
|
112
110
|
const outputPath = join(tempDir, 'result.json')
|
|
113
111
|
await Bun.write(schemaPath, JSON.stringify(SESSION_TITLE_SCHEMA))
|
|
114
|
-
const output = await
|
|
112
|
+
const output = await runHarnessCommand({
|
|
115
113
|
command: codexSessionTitleCommand({
|
|
116
114
|
executable,
|
|
117
115
|
cwd: tempDir,
|
|
@@ -128,7 +126,7 @@ export async function generateCodexSessionTitle(input: {
|
|
|
128
126
|
return parseGeneratedSessionTitleJson(await Bun.file(outputPath).text())
|
|
129
127
|
} finally {
|
|
130
128
|
clearTimeout(timer)
|
|
131
|
-
if (tempDir) await
|
|
129
|
+
if (tempDir) await removeHarnessTempDir(tempDir).catch(() => {})
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
132
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SpeedMode } from '@/lib/types'
|
|
1
2
|
import type { MessageAttachment } from '@/lib/types'
|
|
2
3
|
import { attachmentLabel } from '@/lib/moi-attachments'
|
|
3
4
|
// Live state per (workspaceId, sessionId): display history, native lifecycle,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
type CodexTokenUsage,
|
|
24
25
|
type CodexTurn,
|
|
25
26
|
type SubagentReplay,
|
|
26
|
-
|
|
27
|
+
codexServiceTierForSpeedMode,
|
|
27
28
|
codexItemToNotice,
|
|
28
29
|
codexItemToTurn,
|
|
29
30
|
codexThreadToEvents,
|
|
@@ -905,7 +906,7 @@ type CodexSendInput = {
|
|
|
905
906
|
optimisticId?: string
|
|
906
907
|
model?: string
|
|
907
908
|
effort?: string
|
|
908
|
-
|
|
909
|
+
speedMode?: SpeedMode
|
|
909
910
|
stream?: boolean
|
|
910
911
|
// Rendered through native additionalContext or the legacy text envelope.
|
|
911
912
|
context?: MoiContext
|
|
@@ -936,7 +937,7 @@ async function sendMessage(
|
|
|
936
937
|
: undefined
|
|
937
938
|
const userInput = buildUserInput(prepared)
|
|
938
939
|
const { parts } = prepared
|
|
939
|
-
const serviceTier =
|
|
940
|
+
const serviceTier = codexServiceTierForSpeedMode(input.speedMode)
|
|
940
941
|
|
|
941
942
|
let rec: SessionRecord
|
|
942
943
|
try {
|
|
@@ -948,15 +949,14 @@ async function sendMessage(
|
|
|
948
949
|
cwd: input.workspacePath,
|
|
949
950
|
...CODEX_THREAD_ACCESS,
|
|
950
951
|
...(input.model ? { model: input.model } : {}),
|
|
951
|
-
|
|
952
|
+
serviceTier
|
|
952
953
|
})
|
|
953
954
|
const realId = started.thread.id
|
|
954
955
|
if (realId !== input.sessionId) {
|
|
955
956
|
aliases.set(recKey(input.workspaceId, input.sessionId), realId)
|
|
956
957
|
sendLanes.set(recKey(input.workspaceId, realId), lane)
|
|
957
958
|
await renameSessionReferences(
|
|
958
|
-
input.workspaceId,
|
|
959
|
-
input.workspacePath,
|
|
959
|
+
{ id: input.workspaceId, path: input.workspacePath },
|
|
960
960
|
input.sessionId,
|
|
961
961
|
realId
|
|
962
962
|
)
|
|
@@ -971,13 +971,13 @@ async function sendMessage(
|
|
|
971
971
|
})
|
|
972
972
|
rec.model = started.model ?? input.model
|
|
973
973
|
if (
|
|
974
|
-
(input.model || input.effort || input.
|
|
975
|
-
!(await hasSessionConfig(input.workspacePath, realId))
|
|
974
|
+
(input.model || input.effort || input.speedMode !== undefined) &&
|
|
975
|
+
!(await hasSessionConfig({ id: input.workspaceId, path: input.workspacePath }, realId))
|
|
976
976
|
) {
|
|
977
|
-
await saveSessionConfig(input.workspacePath, realId, {
|
|
977
|
+
await saveSessionConfig({ id: input.workspaceId, path: input.workspacePath }, realId, {
|
|
978
978
|
model: input.model,
|
|
979
979
|
effort: input.effort,
|
|
980
|
-
|
|
980
|
+
speedMode: input.speedMode
|
|
981
981
|
})
|
|
982
982
|
}
|
|
983
983
|
} else {
|
|
@@ -1075,7 +1075,7 @@ async function sendMessage(
|
|
|
1075
1075
|
summary: 'detailed',
|
|
1076
1076
|
...(input.model ? { model: input.model } : {}),
|
|
1077
1077
|
...(input.effort ? { effort: input.effort } : {}),
|
|
1078
|
-
|
|
1078
|
+
serviceTier
|
|
1079
1079
|
}
|
|
1080
1080
|
if (rec.activeTurnId) {
|
|
1081
1081
|
try {
|
|
@@ -17,7 +17,7 @@ export class CodexRpcError extends Error {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export type CodexTransport = {
|
|
20
|
-
rpc: <T>(method: string, params?: Json) => Promise<T>
|
|
20
|
+
rpc: <T>(method: string, params?: Json, options?: { timeoutMs?: number }) => Promise<T>
|
|
21
21
|
notify: (method: string, params?: Json) => void
|
|
22
22
|
onNotification: (listener: NotificationListener) => () => void
|
|
23
23
|
isAlive: () => boolean
|
|
@@ -92,14 +92,21 @@ export function createCodexTransport(options: TransportOptions): CodexTransport
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
function rpc<T>(
|
|
95
|
+
function rpc<T>(
|
|
96
|
+
method: string,
|
|
97
|
+
params: Json = {},
|
|
98
|
+
requestOptions?: { timeoutMs?: number }
|
|
99
|
+
): Promise<T> {
|
|
96
100
|
if (!alive) return Promise.reject(new Error('ChatGPT app-server is not running'))
|
|
97
101
|
const id = nextId++
|
|
98
102
|
return new Promise<T>((resolve, reject) => {
|
|
99
|
-
const timer = setTimeout(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
const timer = setTimeout(
|
|
104
|
+
() => {
|
|
105
|
+
pending.delete(id)
|
|
106
|
+
reject(new Error(`ChatGPT request timed out: ${method}`))
|
|
107
|
+
},
|
|
108
|
+
requestOptions?.timeoutMs ?? options.timeoutMs ?? 30_000
|
|
109
|
+
)
|
|
103
110
|
// Register before writing: a synchronous response must find its waiter.
|
|
104
111
|
pending.set(id, { resolve: resolve as (value: unknown) => void, reject, timer })
|
|
105
112
|
send({ jsonrpc: '2.0', id, method, params })
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { join } from 'node:path'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { chmod, mkdtemp, rm } from 'node:fs/promises'
|
|
4
|
+
|
|
5
|
+
import { agentCommand } from '../agent-launcher'
|
|
6
|
+
|
|
7
|
+
export async function runHarnessCommand(input: {
|
|
8
|
+
command: readonly string[]
|
|
9
|
+
cwd: string
|
|
10
|
+
stdin?: string
|
|
11
|
+
signal: AbortSignal
|
|
12
|
+
env?: Record<string, string | undefined>
|
|
13
|
+
}): Promise<string | null> {
|
|
14
|
+
if (input.signal.aborted) return null
|
|
15
|
+
try {
|
|
16
|
+
const proc = Bun.spawn(agentCommand(input.command), {
|
|
17
|
+
cwd: input.cwd,
|
|
18
|
+
stdin: new Blob([input.stdin ?? '']),
|
|
19
|
+
stdout: 'pipe',
|
|
20
|
+
stderr: 'ignore',
|
|
21
|
+
signal: input.signal,
|
|
22
|
+
env: input.env,
|
|
23
|
+
maxBuffer: 128 * 1024
|
|
24
|
+
})
|
|
25
|
+
const [exitCode, stdout] = await Promise.all([proc.exited, new Response(proc.stdout).text()])
|
|
26
|
+
return exitCode === 0 && !input.signal.aborted ? stdout : null
|
|
27
|
+
} catch {
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// On managed machines the command runs as the agent's user, which is
|
|
33
|
+
// neither the folder's owner nor in its group, so the folder is open to
|
|
34
|
+
// everyone: the agent works in it and Codex writes its answer there. It holds
|
|
35
|
+
// only temporary inputs and output for one run. Moi stays the owner, which is
|
|
36
|
+
// what lets it remove the folder from /tmp afterwards.
|
|
37
|
+
export async function createHarnessTempDir(): Promise<string> {
|
|
38
|
+
const path = await mkdtemp(join(tmpdir(), 'moi-harness-'))
|
|
39
|
+
await chmod(path, 0o777)
|
|
40
|
+
return path
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function removeHarnessTempDir(path: string): Promise<void> {
|
|
44
|
+
await rm(path, { recursive: true, force: true })
|
|
45
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { accessSync, constants, statSync } from 'node:fs'
|
|
2
|
+
import { homedir } from 'node:os'
|
|
2
3
|
import { delimiter, join, resolve } from 'node:path'
|
|
3
4
|
|
|
4
5
|
import { harnessInstructionMessage } from '@/lib/harness-instructions'
|
|
@@ -19,6 +20,9 @@ type ExecutableConfig = {
|
|
|
19
20
|
const executableConfig: Record<WorkspaceType, ExecutableConfig> = {
|
|
20
21
|
'claude-code': {
|
|
21
22
|
command: 'claude',
|
|
23
|
+
fallbackPaths: [
|
|
24
|
+
join(homedir(), '.local', 'bin', process.platform === 'win32' ? 'claude.exe' : 'claude')
|
|
25
|
+
],
|
|
22
26
|
unavailableReason: harnessInstructionMessage('claude-code')
|
|
23
27
|
},
|
|
24
28
|
codex: {
|
|
@@ -27,6 +31,7 @@ const executableConfig: Record<WorkspaceType, ExecutableConfig> = {
|
|
|
27
31
|
// on PATH: probe the known macOS bundle locations (ChatGPT.app is the
|
|
28
32
|
// current home, Codex.app the legacy standalone install).
|
|
29
33
|
fallbackPaths: [
|
|
34
|
+
join(homedir(), '.local', 'bin', process.platform === 'win32' ? 'codex.exe' : 'codex'),
|
|
30
35
|
'/Applications/ChatGPT.app/Contents/Resources/codex',
|
|
31
36
|
'/Applications/Codex.app/Contents/Resources/codex'
|
|
32
37
|
],
|
package/server/harness/fork.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type { StreamEvent } from '@/lib/types'
|
|
1
|
+
import type { SessionFork, StreamEvent } from '@/lib/types'
|
|
2
2
|
import { applyEvents } from '@/lib/format'
|
|
3
3
|
|
|
4
4
|
export class ForkUnsupportedError extends Error {}
|
|
5
5
|
|
|
6
|
-
export function inheritedHistoryBoundary(
|
|
6
|
+
export function inheritedHistoryBoundary(
|
|
7
|
+
events: StreamEvent[]
|
|
8
|
+
): Pick<SessionFork, 'throughMessageId' | 'noticeIds'> {
|
|
7
9
|
const view = applyEvents(events)
|
|
8
10
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
throughMessageId: view.turns.at(-1)?.id,
|
|
12
|
+
noticeIds: view.notices.map(notice => notice.id)
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { HARNESS_INSTRUCTIONS } from '@/lib/harness-instructions'
|
|
2
|
+
import { getAppConfig } from '../app-config'
|
|
3
|
+
import type { WorkspaceType } from '@/lib/types'
|
|
4
|
+
import { detectInstalledHarnesses } from './executable'
|
|
5
|
+
|
|
6
|
+
const installations = new Map<WorkspaceType, Promise<void>>()
|
|
7
|
+
|
|
8
|
+
export function installHarness(type: WorkspaceType): Promise<void> {
|
|
9
|
+
const config = getAppConfig()
|
|
10
|
+
if (config.environment !== 'local' || config.demo || config.agentLauncher) {
|
|
11
|
+
throw new Error('Agents can only be installed in local Moi')
|
|
12
|
+
}
|
|
13
|
+
if (type !== 'claude-code' && type !== 'codex') {
|
|
14
|
+
throw new Error('This agent requires manual installation')
|
|
15
|
+
}
|
|
16
|
+
const pending = installations.get(type)
|
|
17
|
+
if (pending) return pending
|
|
18
|
+
const installation = (async () => {
|
|
19
|
+
if ((await detectInstalledHarnesses())[type]) return
|
|
20
|
+
const url =
|
|
21
|
+
type === 'claude-code' ? 'https://claude.ai/install' : 'https://chatgpt.com/codex/install'
|
|
22
|
+
const command =
|
|
23
|
+
process.platform === 'win32'
|
|
24
|
+
? [
|
|
25
|
+
'powershell.exe',
|
|
26
|
+
'-NoProfile',
|
|
27
|
+
'-NonInteractive',
|
|
28
|
+
'-ExecutionPolicy',
|
|
29
|
+
'Bypass',
|
|
30
|
+
'-Command',
|
|
31
|
+
`$ErrorActionPreference = 'Stop'; irm ${url}.ps1 | iex`
|
|
32
|
+
]
|
|
33
|
+
: ['bash', '-o', 'pipefail', '-c', HARNESS_INSTRUCTIONS[type].command]
|
|
34
|
+
const child = Bun.spawn(command, {
|
|
35
|
+
stdin: 'ignore',
|
|
36
|
+
stdout: 'inherit',
|
|
37
|
+
stderr: 'inherit',
|
|
38
|
+
timeout: 5 * 60_000
|
|
39
|
+
})
|
|
40
|
+
if ((await child.exited) !== 0) {
|
|
41
|
+
throw new Error('Installation failed or timed out. Try again.')
|
|
42
|
+
}
|
|
43
|
+
if (!(await detectInstalledHarnesses())[type]) {
|
|
44
|
+
throw new Error('The installer finished, but the agent could not be found. Restart Moi.')
|
|
45
|
+
}
|
|
46
|
+
})().finally(() => installations.delete(type))
|
|
47
|
+
installations.set(type, installation)
|
|
48
|
+
return installation
|
|
49
|
+
}
|
|
@@ -1338,8 +1338,7 @@ async function sendOpenClawMessageImpl(input: {
|
|
|
1338
1338
|
if (created?.sessionId && created.sessionId !== input.sessionId) {
|
|
1339
1339
|
realSessionId = created.sessionId
|
|
1340
1340
|
await renameSessionReferences(
|
|
1341
|
-
input.workspaceId,
|
|
1342
|
-
input.workspacePath,
|
|
1341
|
+
{ id: input.workspaceId, path: input.workspacePath },
|
|
1343
1342
|
input.sessionId,
|
|
1344
1343
|
realSessionId
|
|
1345
1344
|
)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
2
|
+
import { WebStandardStreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js'
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
import { createHarnessTempDir, removeHarnessTempDir } from './command'
|
|
5
|
+
import type { ActionModel, HarnessActionInput } from './types'
|
|
6
|
+
|
|
7
|
+
export const actionProgressServerName = 'moi_action'
|
|
8
|
+
export const actionProgressToolName = 'report_progress'
|
|
9
|
+
|
|
10
|
+
export type ActionExecution = {
|
|
11
|
+
prompt: string
|
|
12
|
+
model: ActionModel
|
|
13
|
+
resultSchema: Record<string, unknown>
|
|
14
|
+
signal: AbortSignal
|
|
15
|
+
cwd: string
|
|
16
|
+
progressUrl?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function serveProgress<T>(schema: z.ZodType<T>, report: (value: T) => void | Promise<void>) {
|
|
20
|
+
const path = `/${crypto.randomUUID()}`
|
|
21
|
+
const server = Bun.serve({
|
|
22
|
+
hostname: '127.0.0.1',
|
|
23
|
+
port: 0,
|
|
24
|
+
async fetch(request) {
|
|
25
|
+
if (new URL(request.url).pathname !== path || request.headers.has('origin'))
|
|
26
|
+
return new Response('Not found', { status: 404 })
|
|
27
|
+
const mcp = new McpServer({ name: actionProgressServerName, version: '1.0.0' })
|
|
28
|
+
mcp.registerTool(
|
|
29
|
+
actionProgressToolName,
|
|
30
|
+
{
|
|
31
|
+
description: 'Report current action progress using the supplied schema',
|
|
32
|
+
inputSchema: { progress: schema },
|
|
33
|
+
annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false }
|
|
34
|
+
},
|
|
35
|
+
async ({ progress }) => {
|
|
36
|
+
await report(progress)
|
|
37
|
+
return { content: [{ type: 'text', text: 'Progress reported' }] }
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
const transport = new WebStandardStreamableHTTPServerTransport({ enableJsonResponse: true })
|
|
41
|
+
await mcp.connect(transport)
|
|
42
|
+
try {
|
|
43
|
+
return await transport.handleRequest(request)
|
|
44
|
+
} finally {
|
|
45
|
+
await mcp.close()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
return { url: `http://127.0.0.1:${server.port}${path}`, close: () => server.stop(true) }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function executeHarnessAction<TResult, TProgress>(
|
|
53
|
+
input: HarnessActionInput<TResult, TProgress>,
|
|
54
|
+
execute: (action: ActionExecution) => Promise<unknown>
|
|
55
|
+
): Promise<TResult> {
|
|
56
|
+
if (input.signal.aborted) throw new Error('Action cancelled')
|
|
57
|
+
const cwd = await createHarnessTempDir()
|
|
58
|
+
let progress: ReturnType<typeof serveProgress> | undefined
|
|
59
|
+
const stop = () => {
|
|
60
|
+
void progress?.close()
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
if (input.signal.aborted) throw new Error('Action cancelled')
|
|
64
|
+
if (input.progressSchema) progress = serveProgress(input.progressSchema, input.onProgress)
|
|
65
|
+
input.signal.addEventListener('abort', stop, { once: true })
|
|
66
|
+
const result = await execute({
|
|
67
|
+
model: input.model ?? 'normal',
|
|
68
|
+
prompt:
|
|
69
|
+
input.prompt +
|
|
70
|
+
(progress
|
|
71
|
+
? `\n\nUse ${actionProgressServerName}/${actionProgressToolName} to report brief progress when your activity changes. Report only work you are actually doing. Return the final result through the result schema.`
|
|
72
|
+
: ''),
|
|
73
|
+
resultSchema: z.toJSONSchema(input.resultSchema, { target: 'draft-7' }),
|
|
74
|
+
signal: input.signal,
|
|
75
|
+
cwd,
|
|
76
|
+
progressUrl: progress?.url
|
|
77
|
+
})
|
|
78
|
+
if (input.signal.aborted) throw new Error('Action cancelled')
|
|
79
|
+
return input.resultSchema.parse(result)
|
|
80
|
+
} finally {
|
|
81
|
+
input.signal.removeEventListener('abort', stop)
|
|
82
|
+
await progress?.close()
|
|
83
|
+
await removeHarnessTempDir(cwd).catch(() => {})
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { join } from 'node:path'
|
|
2
|
-
import { tmpdir } from 'node:os'
|
|
3
|
-
import { chmod, mkdtemp, rm } from 'node:fs/promises'
|
|
4
|
-
|
|
5
|
-
import { agentCommand } from '../agent-launcher'
|
|
6
|
-
|
|
7
1
|
const MAX_TITLE_SOURCE_LENGTH = 1_000
|
|
8
2
|
const MAX_GENERATED_TITLE_LENGTH = 64
|
|
9
3
|
|
|
@@ -63,43 +57,3 @@ export function parseGeneratedSessionTitleJson(value: string): string | null {
|
|
|
63
57
|
return null
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
|
-
|
|
67
|
-
export async function runSessionTitleCommand(input: {
|
|
68
|
-
command: readonly string[]
|
|
69
|
-
cwd: string
|
|
70
|
-
stdin?: string
|
|
71
|
-
signal: AbortSignal
|
|
72
|
-
env?: Record<string, string | undefined>
|
|
73
|
-
}): Promise<string | null> {
|
|
74
|
-
if (input.signal.aborted) return null
|
|
75
|
-
try {
|
|
76
|
-
const proc = Bun.spawn(agentCommand(input.command), {
|
|
77
|
-
cwd: input.cwd,
|
|
78
|
-
stdin: new Blob([input.stdin ?? '']),
|
|
79
|
-
stdout: 'pipe',
|
|
80
|
-
stderr: 'ignore',
|
|
81
|
-
signal: input.signal,
|
|
82
|
-
env: input.env,
|
|
83
|
-
maxBuffer: 128 * 1024
|
|
84
|
-
})
|
|
85
|
-
const [exitCode, stdout] = await Promise.all([proc.exited, new Response(proc.stdout).text()])
|
|
86
|
-
return exitCode === 0 && !input.signal.aborted ? stdout : null
|
|
87
|
-
} catch {
|
|
88
|
-
return null
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// On managed machines the title command runs as the agent's user, which is
|
|
93
|
-
// neither the folder's owner nor in its group, so the folder is open to
|
|
94
|
-
// everyone: the agent works in it and Codex writes its answer there. It holds
|
|
95
|
-
// only the schema and the title, for one run. moi stays the owner, which is
|
|
96
|
-
// what lets it remove the folder from /tmp afterwards.
|
|
97
|
-
export async function createSessionTitleTempDir(): Promise<string> {
|
|
98
|
-
const path = await mkdtemp(join(tmpdir(), 'moi-session-title-'))
|
|
99
|
-
await chmod(path, 0o777)
|
|
100
|
-
return path
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export async function removeSessionTitleTempDir(path: string): Promise<void> {
|
|
104
|
-
await rm(path, { recursive: true, force: true })
|
|
105
|
-
}
|
package/server/harness/types.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { SpeedMode } from '@/lib/types'
|
|
1
2
|
// The harness contract: what an agent backend must implement to be drivable
|
|
2
3
|
// by moi. See README.md in this folder for the full checklist and the
|
|
3
4
|
// message-type layers; each harness's index.ts exports one Harness object
|
|
4
5
|
// wrapping its session/adapter/transport modules.
|
|
5
6
|
import type { MessageAttachment } from '@/lib/types'
|
|
7
|
+
import type { ZodType } from 'zod'
|
|
6
8
|
import type { MoiContext } from '@/lib/moi-context'
|
|
7
9
|
import type {
|
|
8
10
|
HarnessAvailability,
|
|
@@ -20,7 +22,7 @@ import type {
|
|
|
20
22
|
// The superset of what any backend needs to accept a user message; harnesses
|
|
21
23
|
// ignore fields they don't support. OpenClaw honors model + effort (applied via
|
|
22
24
|
// sessions.patch) and stream (token previews), but has no Fast-mode setting so
|
|
23
|
-
// it ignores
|
|
25
|
+
// it ignores speedMode; agentId is OpenClaw-only (the gateway agent that owns
|
|
24
26
|
// the workspace).
|
|
25
27
|
export type HarnessLoginAttempt = HarnessLogin & {
|
|
26
28
|
completed?: Promise<void>
|
|
@@ -39,7 +41,7 @@ export type SendMessageInput = {
|
|
|
39
41
|
optimisticId?: string
|
|
40
42
|
model?: string
|
|
41
43
|
effort?: string
|
|
42
|
-
|
|
44
|
+
speedMode?: SpeedMode
|
|
43
45
|
stream?: boolean
|
|
44
46
|
// Structured moi context (lib/moi-context.ts). Each harness renders and
|
|
45
47
|
// injects it its own way: Claude Code as a leading system-reminder text
|
|
@@ -81,10 +83,32 @@ export type DiscoveredWorkspaceCandidate = {
|
|
|
81
83
|
|
|
82
84
|
export type HarnessWorkspace = Pick<WorkspaceEntry, 'id' | 'path' | 'type' | 'agentId'>
|
|
83
85
|
|
|
86
|
+
export type ActionModel = 'fast' | 'normal' | 'smart'
|
|
87
|
+
|
|
88
|
+
export type HarnessActionInput<TResult = unknown, TProgress = never> = {
|
|
89
|
+
prompt: string
|
|
90
|
+
// Portable model and effort choice, resolved by each harness. Defaults to normal.
|
|
91
|
+
model?: ActionModel
|
|
92
|
+
resultSchema: ZodType<TResult>
|
|
93
|
+
signal: AbortSignal
|
|
94
|
+
} & (
|
|
95
|
+
| { progressSchema?: never; onProgress?: never }
|
|
96
|
+
| {
|
|
97
|
+
progressSchema: ZodType<TProgress>
|
|
98
|
+
onProgress: (progress: TProgress) => void | Promise<void>
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
|
|
84
102
|
export type Harness = {
|
|
85
103
|
id: WorkspaceType
|
|
86
104
|
capabilities: HarnessCapabilities
|
|
87
105
|
|
|
106
|
+
// Ephemeral read/search action without a workspace or visible chat.
|
|
107
|
+
// Validates structured output against resultSchema; callers control timeout.
|
|
108
|
+
runAction?<TResult, TProgress = never>(
|
|
109
|
+
input: HarnessActionInput<TResult, TProgress>
|
|
110
|
+
): Promise<TResult>
|
|
111
|
+
|
|
88
112
|
// -- chat lifecycle ---------------------------------------------------------
|
|
89
113
|
sendMessage(input: SendMessageInput): Promise<void>
|
|
90
114
|
interrupt(workspaceId: string, sessionId: string): Promise<void>
|
|
@@ -112,7 +136,10 @@ export type Harness = {
|
|
|
112
136
|
sessionEvents(ws: WorkspaceEntry, sessionId: string): Promise<StreamEvent[]>
|
|
113
137
|
listModels(ws: WorkspaceEntry): Promise<Model[]>
|
|
114
138
|
// MCP server status for the connectors UI; absent = backend has no MCP story.
|
|
115
|
-
mcpStatus?(
|
|
139
|
+
mcpStatus?(
|
|
140
|
+
ws: WorkspaceEntry,
|
|
141
|
+
onProgress?: (connectors: McpServer[]) => void
|
|
142
|
+
): Promise<McpServer[]>
|
|
116
143
|
// Workspaces this backend knows about that aren't registered yet.
|
|
117
144
|
discoverWorkspaces?(registeredPaths: Set<string>): Promise<DiscoveredWorkspaceCandidate[]>
|
|
118
145
|
// Without a workspace, only check whether the runtime is installed. With a
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OnboardingAppletPlan, OnboardingIdea, OnboardingViewPlan } from '@/lib/onboarding'
|
|
2
|
+
|
|
3
|
+
function appletBrief(
|
|
4
|
+
title: string,
|
|
5
|
+
applets: (OnboardingAppletPlan | OnboardingViewPlan)[]
|
|
6
|
+
): string {
|
|
7
|
+
if (!applets.length) return `## ${title}\nNone planned.`
|
|
8
|
+
return `## ${title}\n${applets
|
|
9
|
+
.map(applet =>
|
|
10
|
+
[
|
|
11
|
+
`### ${applet.name}`,
|
|
12
|
+
...('icon' in applet ? [`Use view icon: ${applet.icon}`] : []),
|
|
13
|
+
applet.description,
|
|
14
|
+
...applet.features.map(feature => `- ${feature}`)
|
|
15
|
+
].join('\n')
|
|
16
|
+
)
|
|
17
|
+
.join('\n\n')}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function composeBuildBrief(idea: OnboardingIdea): string {
|
|
21
|
+
return [
|
|
22
|
+
`Build the Moi workspace “${idea.name}”. Start implementing this plan now.`,
|
|
23
|
+
`## Workspace\n${idea.description}\nIcon: ${idea.icon} (theme background, already configured).`,
|
|
24
|
+
`## Theme\nFont: ${idea.theme.font}\nColor: ${idea.theme.color}\nThese workspace presets are already configured; use the existing theme tokens.`,
|
|
25
|
+
appletBrief('Views', idea.views),
|
|
26
|
+
appletBrief('Overview widgets', idea.widgets),
|
|
27
|
+
'Follow the workspace instructions and use the normal Moi tools to create the views and widgets. Keep this Overview chat as the main coordination chat and use each view’s own build chat. Link to the views here so the user can follow their progress. Preserve the configured workspace name and icon. Use available data sources honestly and explain any access limitations.'
|
|
28
|
+
].join('\n\n')
|
|
29
|
+
}
|