MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / run

Function run

apps/cli/src/commands/cli/run.ts:52–565  ·  view source on GitHub ↗
(promptArg: string | undefined, flagOptions: FlagOptions)

Source from the content-addressed store, hash-verified

50}
51
52export async function run(promptArg: string | undefined, flagOptions: FlagOptions) {
53 setLogger({
54 info: () => {},
55 warn: () => {},
56 error: () => {},
57 debug: () => {},
58 })
59
60 let prompt = promptArg
61
62 if (flagOptions.promptFile) {
63 if (!fs.existsSync(flagOptions.promptFile)) {
64 console.error(`[CLI] Error: Prompt file does not exist: ${flagOptions.promptFile}`)
65 process.exit(1)
66 }
67
68 prompt = fs.readFileSync(flagOptions.promptFile, "utf-8")
69 }
70
71 const requestedSessionId = flagOptions.sessionId?.trim()
72 const requestedCreateSessionId = flagOptions.createWithSessionId?.trim()
73 const shouldContinueSession = flagOptions.continue
74 const isResumeRequested = Boolean(requestedSessionId || shouldContinueSession)
75
76 if (flagOptions.createWithSessionId !== undefined && !requestedCreateSessionId) {
77 console.error("[CLI] Error: --create-with-session-id requires a non-empty session id")
78 process.exit(1)
79 }
80
81 if (flagOptions.sessionId !== undefined && !requestedSessionId) {
82 console.error("[CLI] Error: --session-id requires a non-empty session id")
83 process.exit(1)
84 }
85
86 if (requestedCreateSessionId && !isValidSessionId(requestedCreateSessionId)) {
87 console.error("[CLI] Error: --create-with-session-id must be a valid UUID session id")
88 process.exit(1)
89 }
90
91 if (requestedSessionId && !isValidSessionId(requestedSessionId)) {
92 console.error("[CLI] Error: --session-id must be a valid UUID session id")
93 process.exit(1)
94 }
95
96 if (requestedCreateSessionId && isResumeRequested) {
97 console.error("[CLI] Error: cannot use --create-with-session-id with --session-id/--continue")
98 process.exit(1)
99 }
100
101 if (requestedSessionId && shouldContinueSession) {
102 console.error("[CLI] Error: cannot use --session-id with --continue")
103 process.exit(1)
104 }
105
106 if (isResumeRequested && prompt) {
107 console.error("[CLI] Error: cannot use prompt or --prompt-file with --session-id/--continue")
108 console.error("[CLI] Usage: roo [--session-id <session-id> | --continue] [options]")
109 process.exit(1)

Callers

nothing calls this directly

Calls 15

activateMethod · 0.95
resumeTaskMethod · 0.95
runTaskMethod · 0.95
setLoggerFunction · 0.90
isValidOutputFormatFunction · 0.90
isValidSessionIdFunction · 0.85
loadSettingsFunction · 0.85
isSupportedProviderFunction · 0.85
getDefaultExtensionPathFunction · 0.85
runOnboardingFunction · 0.85
getApiKeyFromEnvFunction · 0.85

Tested by

no test coverage detected