@x-otto/cli 0.0.1-alpha.2 → 0.0.1-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -65
- package/bin/otto.js +6 -0
- package/dist/{auth-command-CXAB3_hs.js → auth-command-D1T16ed-.js} +3 -3
- package/dist/auth-command-D1T16ed-.js.map +1 -0
- package/dist/build-id-D7Wf4tQw.js +3 -0
- package/dist/build-id-D7Wf4tQw.js.map +1 -0
- package/dist/bundled-extensions/plugin-otto-wire-protocols/plugin-dist/meta.json +1 -1
- package/dist/bundled-extensions/plugin-otto-wire-protocols/plugin-dist/plugin.cjs +2085 -18164
- package/dist/bundled-extensions/plugin-otto-wire-protocols/src/anthropic-messages.ts +2 -2
- package/dist/bundled-extensions/plugin-otto-wire-protocols/src/openai-completions.ts +12 -5
- package/dist/bundled-extensions/plugin-otto-wire-protocols/src/openai-responses.ts +4 -1
- package/dist/bundled-extensions/plugin-skill-inductor/plugin-dist/meta.json +1 -1
- package/dist/bundled-extensions/plugin-skill-inductor/plugin-dist/plugin.cjs +78 -52294
- package/dist/bundled-extensions-C3n8jg20.js +3 -0
- package/dist/bundled-extensions-C3n8jg20.js.map +1 -0
- package/dist/command-dispatcher-ZyrfHgIk.js +21 -0
- package/dist/command-dispatcher-ZyrfHgIk.js.map +1 -0
- package/dist/create-host-app-BXQ8bU-B.js +3 -0
- package/dist/create-host-app-BXQ8bU-B.js.map +1 -0
- package/dist/create-host-app-DXII2WTM.js +2 -0
- package/dist/discover-with-bundled-B5d4q___.js +2 -0
- package/dist/discover-with-bundled-CF8qFP41.js +3 -0
- package/dist/discover-with-bundled-CF8qFP41.js.map +1 -0
- package/dist/doctor-CuNvDmyA.js +36 -0
- package/dist/doctor-CuNvDmyA.js.map +1 -0
- package/dist/{extension-BKXIr86F.js → extension-DLFCUBJr.js} +41 -33
- package/dist/extension-DLFCUBJr.js.map +1 -0
- package/dist/extension-I87MkZYp.js +2 -0
- package/dist/feedback-B-d-GV2J.js +2 -0
- package/dist/feedback-DuTIx3-K.js +21 -0
- package/dist/feedback-DuTIx3-K.js.map +1 -0
- package/dist/{feishu-setup-D6vnuNLw.js → feishu-setup-B6ETf-8Y.js} +2 -2
- package/dist/{feishu-setup-D6vnuNLw.js.map → feishu-setup-B6ETf-8Y.js.map} +1 -1
- package/dist/ftue-doctor-recovery-DeAf8jVo.js +3 -0
- package/dist/ftue-doctor-recovery-DeAf8jVo.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -12
- package/dist/index.js.map +1 -1
- package/dist/observe-CZ96Vre9.js +83 -0
- package/dist/observe-CZ96Vre9.js.map +1 -0
- package/dist/parse-cli-CqocMnXY.js +3 -0
- package/dist/parse-cli-CqocMnXY.js.map +1 -0
- package/dist/persistence-CTXa-OyC.js +85 -0
- package/dist/persistence-CTXa-OyC.js.map +1 -0
- package/dist/plugin-assembly-check-C2TephMb.js +3 -0
- package/dist/plugin-assembly-check-C2TephMb.js.map +1 -0
- package/dist/registry-BOX7DaxS.js +2 -0
- package/dist/{registry-D0NONjLv.js → registry-BdCcwyGy.js} +2 -2
- package/dist/registry-BdCcwyGy.js.map +1 -0
- package/dist/{run-attach-Ci5jYyCa.js → run-attach-CvGCWF_i.js} +2 -2
- package/dist/{run-attach-Ci5jYyCa.js.map → run-attach-CvGCWF_i.js.map} +1 -1
- package/dist/{serve-pVR6UIT9.js → serve-Dbn3THez.js} +3 -3
- package/dist/serve-Dbn3THez.js.map +1 -0
- package/dist/{service-client-BLNeugM9.js → service-client-Cr4sxDVM.js} +1 -1
- package/dist/{service-client-BLNeugM9.js.map → service-client-Cr4sxDVM.js.map} +1 -1
- package/dist/{version-C0qM-qJM.js → version-Cq2kcrXL.js} +2 -2
- package/dist/{version-C0qM-qJM.js.map → version-Cq2kcrXL.js.map} +1 -1
- package/package.json +5 -5
- package/dist/auth-command-CXAB3_hs.js.map +0 -1
- package/dist/build-id-BX4QHzM0.js +0 -3
- package/dist/build-id-BX4QHzM0.js.map +0 -1
- package/dist/command-dispatcher-Vb_AJSAR.js +0 -13
- package/dist/command-dispatcher-Vb_AJSAR.js.map +0 -1
- package/dist/debug-CiosFwme.js +0 -34
- package/dist/debug-CiosFwme.js.map +0 -1
- package/dist/discover-with-bundled-CznLjkkw.js +0 -3
- package/dist/discover-with-bundled-CznLjkkw.js.map +0 -1
- package/dist/doctor-C84-hhEr.js +0 -30
- package/dist/doctor-C84-hhEr.js.map +0 -1
- package/dist/extension-BKXIr86F.js.map +0 -1
- package/dist/extension-CnON6Xum.js +0 -2
- package/dist/extension-plugin-Bmqlc6as.js +0 -2
- package/dist/extension-plugin-C2Yhv77x.js +0 -7
- package/dist/extension-plugin-C2Yhv77x.js.map +0 -1
- package/dist/feedback-BES_6ebi.js +0 -21
- package/dist/feedback-BES_6ebi.js.map +0 -1
- package/dist/feedback-BRbLUn9u.js +0 -2
- package/dist/model-auth-DUPFPOjY.js +0 -2
- package/dist/model-auth-qY5zeBF7.js +0 -3
- package/dist/model-auth-qY5zeBF7.js.map +0 -1
- package/dist/observe-CVg-MRM2.js +0 -32
- package/dist/observe-CVg-MRM2.js.map +0 -1
- package/dist/parse-cli-BCfFgFAC.js +0 -3
- package/dist/parse-cli-BCfFgFAC.js.map +0 -1
- package/dist/persistenced-CCwHu1Ww.js +0 -36
- package/dist/persistenced-CCwHu1Ww.js.map +0 -1
- package/dist/registry-B3nfN62q.js +0 -2
- package/dist/registry-D0NONjLv.js.map +0 -1
- package/dist/remote-persistence-server-B_hONoVR.js +0 -35
- package/dist/remote-persistence-server-B_hONoVR.js.map +0 -1
- package/dist/serve-pVR6UIT9.js.map +0 -1
- package/dist/time-travel-ZozuPPI-.js +0 -21
- package/dist/time-travel-ZozuPPI-.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
1
|
# @x-otto/cli
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Module Purpose
|
|
4
4
|
|
|
5
|
-
Otto
|
|
5
|
+
Otto's command-line entry point — parses arguments and dispatches to Print / JSON / Interactive run modes and subcommands.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Usage
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
# Print
|
|
10
|
+
# Print mode (single run)
|
|
11
11
|
otto "fix the bug" -p
|
|
12
12
|
|
|
13
|
-
# Interactive
|
|
13
|
+
# Interactive mode (REPL, default)
|
|
14
14
|
otto -i
|
|
15
15
|
|
|
16
|
-
# JSON
|
|
16
|
+
# JSON mode
|
|
17
17
|
otto "summarize this file" --json
|
|
18
18
|
|
|
19
|
-
#
|
|
19
|
+
# Specify a model
|
|
20
20
|
otto "explain this" -m claude-sonnet-4
|
|
21
21
|
|
|
22
|
-
#
|
|
22
|
+
# Enable debugging
|
|
23
23
|
otto -i --inspect
|
|
24
24
|
|
|
25
|
-
#
|
|
26
|
-
otto doctor #
|
|
27
|
-
otto config #
|
|
28
|
-
otto auth #
|
|
29
|
-
otto extension #
|
|
30
|
-
otto serve #
|
|
31
|
-
otto persistenced #
|
|
32
|
-
otto observe #
|
|
33
|
-
otto debug #
|
|
34
|
-
otto time-travel #
|
|
35
|
-
otto mcp # MCP server OAuth
|
|
36
|
-
otto ps #
|
|
37
|
-
otto migrate #
|
|
38
|
-
otto feedback #
|
|
25
|
+
# Subcommands
|
|
26
|
+
otto doctor # environment diagnostics
|
|
27
|
+
otto config # configuration migration
|
|
28
|
+
otto auth # credential management
|
|
29
|
+
otto extension # plugin management (install / list / update / remove / trust)
|
|
30
|
+
otto serve # start HTTP/WS service
|
|
31
|
+
otto persistenced # standalone persistence storage service
|
|
32
|
+
otto observe # observation panel
|
|
33
|
+
otto debug # debug panel
|
|
34
|
+
otto time-travel # time travel (checkpoints / restore / fork / replay)
|
|
35
|
+
otto mcp # MCP server OAuth management
|
|
36
|
+
otto ps # process list
|
|
37
|
+
otto migrate # data/config import & export
|
|
38
|
+
otto feedback # feedback management
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
##
|
|
41
|
+
## Arguments
|
|
42
42
|
|
|
43
|
-
|
|
|
43
|
+
| Argument | Description |
|
|
44
44
|
|------|------|
|
|
45
|
-
| `-p` / `--print` | Print
|
|
46
|
-
| `-i` / `--interactive` | Interactive
|
|
47
|
-
| `--json` | JSON
|
|
48
|
-
| `-m` / `--model` |
|
|
49
|
-
| `-c` / `--config` |
|
|
50
|
-
| `-d` / `--project` |
|
|
51
|
-
| `-v` / `--verbose` |
|
|
52
|
-
| `-q` / `--quiet` |
|
|
53
|
-
| `--continue` |
|
|
54
|
-
| `--inspect[=port]` |
|
|
55
|
-
| `--max-tool-turns` |
|
|
56
|
-
| `--max-tool-turn-extensions` |
|
|
57
|
-
| `--session-url` |
|
|
58
|
-
| `--session-token` |
|
|
59
|
-
| `--id` |
|
|
60
|
-
| `--help` / `--version` |
|
|
61
|
-
|
|
62
|
-
##
|
|
45
|
+
| `-p` / `--print` | Print mode |
|
|
46
|
+
| `-i` / `--interactive` | Interactive mode |
|
|
47
|
+
| `--json` | JSON mode |
|
|
48
|
+
| `-m` / `--model` | Specify model |
|
|
49
|
+
| `-c` / `--config` | Config file path |
|
|
50
|
+
| `-d` / `--project` | Working directory |
|
|
51
|
+
| `-v` / `--verbose` | Verbose logging |
|
|
52
|
+
| `-q` / `--quiet` | Error-level logging only |
|
|
53
|
+
| `--continue` | Resume last session |
|
|
54
|
+
| `--inspect[=port]` | Enable debugging (default 9229) |
|
|
55
|
+
| `--max-tool-turns` | Max tool calls per turn |
|
|
56
|
+
| `--max-tool-turn-extensions` | Number of compaction-and-continue extensions after hitting the cap |
|
|
57
|
+
| `--session-url` | Remote persistence URL |
|
|
58
|
+
| `--session-token` | Remote persistence bearer token |
|
|
59
|
+
| `--id` | Explicit workspace ID |
|
|
60
|
+
| `--help` / `--version` | Help / version |
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
63
|
|
|
64
64
|
```bash
|
|
65
65
|
pnpm add @x-otto/cli
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Or build from the repo:
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
71
|
pnpm --filter @x-otto/cli build
|
|
72
72
|
node packages/cli/bin/otto.js
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
Global install (dev):
|
|
76
76
|
|
|
77
77
|
```bash
|
|
78
78
|
pnpm --filter @x-otto/cli build
|
|
@@ -81,30 +81,30 @@ pnpm --global link packages/cli
|
|
|
81
81
|
|
|
82
82
|
## API
|
|
83
83
|
|
|
84
|
-
|
|
|
84
|
+
| Export | Type | Description |
|
|
85
85
|
|---|---|---|
|
|
86
|
-
| `runCli` | `() => Promise<number>` |
|
|
86
|
+
| `runCli` | `() => Promise<number>` | Main execution entry point, returns exit code |
|
|
87
87
|
|
|
88
|
-
##
|
|
88
|
+
## Directory Overview
|
|
89
89
|
|
|
90
90
|
```
|
|
91
91
|
bin/
|
|
92
|
-
otto #
|
|
92
|
+
otto # binary entry point (#!/usr/bin/env node)
|
|
93
93
|
src/
|
|
94
|
-
cli.ts #
|
|
95
|
-
parse-cli.ts #
|
|
96
|
-
types.ts #
|
|
97
|
-
index.ts #
|
|
98
|
-
auth-command.ts # auth
|
|
99
|
-
build-id.ts #
|
|
100
|
-
commands/ #
|
|
101
|
-
i18n/ #
|
|
102
|
-
modes/ #
|
|
103
|
-
session-contract/ #
|
|
104
|
-
tests/ # 14
|
|
94
|
+
cli.ts # main execution entry (SUB_COMMANDS registry)
|
|
95
|
+
parse-cli.ts # argument parsing (parseCLI)
|
|
96
|
+
types.ts # core types
|
|
97
|
+
index.ts # top-level execution + runCli export
|
|
98
|
+
auth-command.ts # auth subcommand
|
|
99
|
+
build-id.ts # build metadata
|
|
100
|
+
commands/ # subcommand modules (~49 files)
|
|
101
|
+
i18n/ # internationalization types
|
|
102
|
+
modes/ # run-mode helpers
|
|
103
|
+
session-contract/ # session contract
|
|
104
|
+
tests/ # 14 test files
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
##
|
|
107
|
+
## Development Commands
|
|
108
108
|
|
|
109
109
|
```bash
|
|
110
110
|
pnpm --filter @x-otto/cli build
|
|
@@ -112,9 +112,9 @@ pnpm --filter @x-otto/cli typecheck
|
|
|
112
112
|
pnpm --filter @x-otto/cli clean
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
##
|
|
115
|
+
## Related Packages
|
|
116
116
|
|
|
117
|
-
`@x-otto/agent
|
|
118
|
-
`@x-otto/memory
|
|
119
|
-
`@x-otto/runtime
|
|
120
|
-
`@x-otto/setting
|
|
117
|
+
`@x-otto/agent`, `@x-otto/ai`, `@x-otto/coding`, `@x-otto/env`, `@x-otto/hooks`, `@x-otto/mcp`,
|
|
118
|
+
`@x-otto/memory`, `@x-otto/persistence`, `@x-otto/interchange`, `@x-otto/remote-persistence-server`,
|
|
119
|
+
`@x-otto/runtime`, `@x-otto/schedule`, `@x-otto/service`, `@x-otto/session`, `@x-otto/session-contract`,
|
|
120
|
+
`@x-otto/setting`, `@x-otto/shared`, `@x-otto/tools`, `@x-otto/trace-view`, `@x-otto/tui`
|
package/bin/otto.js
CHANGED
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
// 必须靠本文件的检测逻辑主动重新注入)。
|
|
16
16
|
//
|
|
17
17
|
// 可覆盖:OTTO_MAX_OLD_SPACE_MB 环境变量(运维在容器/内存受限环境下调整)。
|
|
18
|
+
// 抑制 node:sqlite 实验特性警告(TUI 输出不能被污染)
|
|
19
|
+
const _ew = process.emitWarning;
|
|
20
|
+
process.emitWarning = function(w, ...a) {
|
|
21
|
+
if (typeof w === 'string' && w.includes('SQLite is an experimental')) return;
|
|
22
|
+
return _ew.call(process, w, ...a);
|
|
23
|
+
};
|
|
18
24
|
import { spawn } from 'node:child_process'
|
|
19
25
|
import { fileURLToPath } from 'node:url'
|
|
20
26
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
2
|
+
import{t as e}from"./create-host-app-BXQ8bU-B.js";import{createDefaultAuthStore as t}from"@x-otto/ai";import{createInterface as n}from"node:readline/promises";async function r(n,i={}){if(!i.authStore&&i.bootstrap){let t=e({workspaceDir:i.bootstrap.workspaceDir,projectConfigPath:i.bootstrap.projectConfigPath,logger:{name:`otto-auth`,level:i.bootstrap.verbose?`debug`:`info`,destination:`stderr`}});try{return await t.start(),await r(n,{...i,authStore:t.authStore,bootstrap:void 0})}finally{await t.stop()}}let s=i.stdout??(e=>process.stdout.write(e)),l=i.stderr??(e=>process.stderr.write(e)),u=i.authStore??t({watchForExternalChanges:!1}),[d,f]=n;switch(d){case`login`:return a(u,f,{stdout:s,stderr:l,prompt:i.prompt});case`logout`:return o(u,f,{stdout:s,stderr:l});case`status`:case void 0:return c(u,{stdout:s});default:return l(`otto auth: unknown action '${d}'. Use login | status | logout.\n`),1}}function i(e){return e.oauth.list().map(e=>e.id)}async function a(e,t,r){let a=i(e);if(a.length===0)return r.stderr(`otto auth login: no OAuth-capable providers available yet.
|
|
3
3
|
Install a provider plugin first — run \`otto\` (interactive) for guided setup,
|
|
4
4
|
or: otto extension install anthropic-provider
|
|
5
5
|
`),1;if(!t)return r.stderr(`otto auth login: missing provider. One of: ${a.join(`, `)}\n`),1;let o=e.oauth.get(t);if(!o)return r.stderr(`otto auth login: unknown provider '${t}'. One of: ${a.join(`, `)}\n`),r.stderr(`Hint: plugin providers (cursor, anthropic, …) need the plugin installed with provider capability granted.
|
|
6
6
|
otto extension install --link extensions/plugin-cursor --yes
|
|
7
7
|
# user-scope install auto-trusts; then otto auth login cursor
|
|
8
8
|
`),1;let s=r.prompt?void 0:n({input:process.stdin,output:process.stdout}),c=r.prompt??(e=>s.question(e)),l=new AbortController,u=()=>l.abort();process.on(`SIGINT`,u);try{let n={onAuth:e=>{r.stdout(`\nOpen this URL in your browser to authorize:\n ${e.url}\n`),e.code&&r.stdout(`Code: ${e.code}\n`),e.instructions&&r.stdout(`${e.instructions}\n`)},onPrompt:async e=>{let t=e.placeholder?` (${e.placeholder})`:``;return(await c(`${e.message}${t}: `)).trim()},onManualCode:async e=>{let t=c(`
|
|
9
|
-
Paste the code here: `).then(e=>e.trim(),()=>``);return e?e.aborted?``:Promise.race([t,new Promise(t=>{e.addEventListener(`abort`,()=>t(``),{once:!0})})]):t},onProgress:e=>r.stdout(`${e}\n`),signal:l.signal};return await e.login(t,n),r.stdout(`\n✓ Logged in to ${o.name}.\n`),0}catch(e){return r.stderr(`\notto auth login failed: ${e.message}\n`),1}finally{process.off(`SIGINT`,u),s?.close()}}async function o(e,t,n){if(!t)return n.stderr(`otto auth logout: missing provider. One of: ${e.listProviders().join(`, `)}\n`),1;let r=await e.hasCredential(t);return await e.logout(t),n.stdout(r?`✓ Logged out of ${t}.\n`:`${t} was not logged in.\n`),0}const s={oauth:`OAuth`,api_key:`API key (stored)`,env:`API key (env)`};async function c(e,t){t.stdout(`Authentication status:
|
|
9
|
+
Paste the code here: `).then(e=>e.trim(),()=>``);return e?e.aborted?``:Promise.race([t,new Promise(t=>{e.addEventListener(`abort`,()=>t(``),{once:!0})})]):t},onProgress:e=>r.stdout(`${e}\n`),signal:l.signal};return await e.login(t,n),r.stdout(`\n✓ Logged in to ${o.name}.\n`),0}catch(e){return r.stderr(`\notto auth login failed: ${e.message}\n`),1}finally{process.off(`SIGINT`,u),s?.close()}}async function o(e,t,n){if(!t)return n.stderr(`otto auth logout: missing provider. One of: ${e.listProviders().join(`, `)}\n`),1;let r=await e.hasCredential(t);return await e.logout(t),n.stdout(r?`✓ Logged out of ${t}.\n`:`${t} was not logged in.\n`),0}const s={oauth:`OAuth`,api_key:`API key (stored)`,env:`API key (env)`};async function c(e,t){await e.ensureInitialized(),t.stdout(`Authentication status:
|
|
10
10
|
`);for(let n of e.listProviders()){let r=await e.getAuthSource(n),i=r?s[r]:`not configured`;t.stdout(` ${n.padEnd(16)} ${i}\n`)}return 0}export{r as runAuthCommand};
|
|
11
|
-
//# sourceMappingURL=auth-command-
|
|
11
|
+
//# sourceMappingURL=auth-command-D1T16ed-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-command-D1T16ed-.js","names":[],"sources":["../src/auth-command.ts"],"sourcesContent":["import { createInterface } from 'node:readline/promises'\n\nimport { createHostApp } from './create-host-app'\nimport { createDefaultAuthStore } from '@x-otto/ai'\nimport type { AuthStore, OAuthLoginOptions } from '@x-otto/ai'\n\n/**\n * `otto auth login|status|logout` 子命令(M8-07)。\n *\n * 驱动 AuthStore.login 的 onAuth/onPrompt/onManualCode 回调:\n * - Anthropic(usesCallbackServer=false)→ loopback(54545) 优先自动回填,\n * 端口占用时回退托管回调 + 用户回贴 code(onManualCode 必须提供);\n * - loopback provider(OpenAI/Codex,usesCallbackServer=true)→ 浏览器重定向自动完成。\n * - 插件 OAuth(cursor/anthropic 等)→ 须 bootstrap App 装载插件后再查 oauth 表(RFC-130 M131-1)。\n */\nexport interface AuthBootstrapOptions {\n workspaceDir: string\n projectConfigPath?: string\n verbose?: boolean\n}\n\nexport interface AuthCommandDeps {\n authStore?: AuthStore\n /** 未注入 authStore 时,经 App.start() 装载插件 OAuth(对齐 TUI `/auth`)。 */\n bootstrap?: AuthBootstrapOptions\n stdout?: (s: string) => void\n stderr?: (s: string) => void\n /** 单行读取器(注入便于测试);未提供时按需创建 readline。 */\n prompt?: (question: string) => Promise<string>\n}\n\nexport async function runAuthCommand(args: string[], deps: AuthCommandDeps = {}): Promise<number> {\n if (!deps.authStore && deps.bootstrap) {\n const app = createHostApp({\n workspaceDir: deps.bootstrap.workspaceDir,\n projectConfigPath: deps.bootstrap.projectConfigPath,\n logger: {\n name: 'otto-auth',\n level: deps.bootstrap.verbose ? 'debug' : 'info',\n destination: 'stderr',\n },\n })\n try {\n await app.start()\n return await runAuthCommand(args, {\n ...deps,\n authStore: app.authStore,\n bootstrap: undefined,\n })\n } finally {\n await app.stop()\n }\n }\n\n const stdout = deps.stdout ?? ((s) => process.stdout.write(s))\n const stderr = deps.stderr ?? ((s) => process.stderr.write(s))\n // watchForExternalChanges:false —— `otto auth *` 是一次性命令,跑完即退出,不需要跨进程凭据\n // 实时同步(那是给 TUI/serve 长驻进程用的)。AuthStore 的 fs.watch 句柄本身已 unref(不阻塞\n // 事件循环清空,见 auth-store.ts setupWatcher 注释),此处显式关闭仍是更准确的语义表达——\n // 避免为一个秒退的脚本无谓建立/拆除一个不会被用到的 watcher。\n const authStore = deps.authStore ?? createDefaultAuthStore({ watchForExternalChanges: false })\n\n const [action, provider] = args\n\n switch (action) {\n case 'login':\n return authLogin(authStore, provider, { stdout, stderr, prompt: deps.prompt })\n case 'logout':\n return authLogout(authStore, provider, { stdout, stderr })\n case 'status':\n case undefined:\n return authStatus(authStore, { stdout })\n default:\n stderr(`otto auth: unknown action '${action}'. Use login | status | logout.\\n`)\n return 1\n }\n}\n\nfunction loginableProviders(authStore: AuthStore): string[] {\n return authStore.oauth.list().map((p) => p.id)\n}\n\nasync function authLogin(\n authStore: AuthStore,\n provider: string | undefined,\n io: { stdout: (s: string) => void; stderr: (s: string) => void; prompt?: (q: string) => Promise<string> },\n): Promise<number> {\n const providers = loginableProviders(authStore)\n // UX(round 6):零 provider 插件时 providers 为空数组——\"One of: \"后面是空串,\n // 用户面对死端。指回引导路径而不是展示空名单。\n if (providers.length === 0) {\n io.stderr(\n 'otto auth login: no OAuth-capable providers available yet.\\n' +\n 'Install a provider plugin first — run `otto` (interactive) for guided setup,\\n' +\n 'or: otto extension install anthropic-provider\\n',\n )\n return 1\n }\n if (!provider) {\n io.stderr(`otto auth login: missing provider. One of: ${providers.join(', ')}\\n`)\n return 1\n }\n\n const oauth = authStore.oauth.get(provider)\n if (!oauth) {\n io.stderr(`otto auth login: unknown provider '${provider}'. One of: ${providers.join(', ')}\\n`)\n io.stderr(\n 'Hint: plugin providers (cursor, anthropic, …) need the plugin installed with provider capability granted.\\n' +\n ' otto extension install --link extensions/plugin-cursor --yes\\n' +\n ' # user-scope install auto-trusts; then otto auth login cursor\\n',\n )\n return 1\n }\n\n const rl = io.prompt ? undefined : createInterface({ input: process.stdin, output: process.stdout })\n const ask = io.prompt ?? ((q: string) => rl!.question(q))\n\n const controller = new AbortController()\n const onSigint = (): void => controller.abort()\n process.on('SIGINT', onSigint)\n\n try {\n const options: OAuthLoginOptions = {\n onAuth: (info) => {\n io.stdout(`\\nOpen this URL in your browser to authorize:\\n ${info.url}\\n`)\n if (info.code) {\n io.stdout(`Code: ${info.code}\\n`)\n }\n if (info.instructions) {\n io.stdout(`${info.instructions}\\n`)\n }\n },\n onPrompt: async (p) => {\n const suffix = p.placeholder ? ` (${p.placeholder})` : ''\n return (await ask(`${p.message}${suffix}: `)).trim()\n },\n // loopback 回调先完成时经 signal 放行。readline 本身无法中断,由 finally 的\n // rl.close() 收尾——close 会 reject 悬挂的 question,故 catch 归一为空串防 unhandled。\n onManualCode: async (signal?: AbortSignal) => {\n const question = ask('\\nPaste the code here: ').then(\n (s) => s.trim(),\n () => '',\n )\n if (!signal) return question\n if (signal.aborted) return ''\n return Promise.race([\n question,\n new Promise<string>((resolve) => {\n signal.addEventListener('abort', () => resolve(''), { once: true })\n }),\n ])\n },\n onProgress: (m) => io.stdout(`${m}\\n`),\n signal: controller.signal,\n }\n\n await authStore.login(provider, options)\n io.stdout(`\\n✓ Logged in to ${oauth.name}.\\n`)\n return 0\n } catch (error) {\n io.stderr(`\\notto auth login failed: ${(error as Error).message}\\n`)\n return 1\n } finally {\n process.off('SIGINT', onSigint)\n rl?.close()\n }\n}\n\nasync function authLogout(\n authStore: AuthStore,\n provider: string | undefined,\n io: { stdout: (s: string) => void; stderr: (s: string) => void },\n): Promise<number> {\n if (!provider) {\n io.stderr(\n `otto auth logout: missing provider. One of: ${authStore.listProviders().join(', ')}\\n`,\n )\n return 1\n }\n\n const had = await authStore.hasCredential(provider)\n await authStore.logout(provider)\n io.stdout(had ? `✓ Logged out of ${provider}.\\n` : `${provider} was not logged in.\\n`)\n return 0\n}\n\nconst SOURCE_LABEL: Record<string, string> = {\n oauth: 'OAuth',\n api_key: 'API key (stored)',\n env: 'API key (env)',\n}\n\nasync function authStatus(\n authStore: AuthStore,\n io: { stdout: (s: string) => void },\n): Promise<number> {\n // RFC-341 修复:`AuthStore.listProviders()` 是同步方法,读的是内存 cache——\n // cache 由 `ensureInitialized()`(异步读盘)填充,且没有任何调用方保证在\n // `listProviders()` 之前完成过初始化(`getAuthSource()` 等其余方法内部各自会\n // `await ensureInitialized()`,唯独 `listProviders()` 没有)。此前这里直接调\n // `listProviders()` 时 cache 大概率还是空的(首次调用、无其余方法先触发过初始化\n // 的一次性命令场景),导致 `otto auth status`/Setup Wizard 装完 provider 后\n // 立即查询状态永远显示\"未配置\"——即便凭据其实已经成功落盘(真实事故:OrbStack\n // 虚拟机全流程测试实测复现,auth.json 里确有凭据但 status/doctor 均报未配置)。\n await authStore.ensureInitialized()\n io.stdout('Authentication status:\\n')\n for (const provider of authStore.listProviders()) {\n const source = await authStore.getAuthSource(provider)\n const label = source ? SOURCE_LABEL[source] : 'not configured'\n io.stdout(` ${provider.padEnd(16)} ${label}\\n`)\n }\n return 0\n}\n"],"mappings":";+JA+BA,eAAsB,EAAe,EAAgB,EAAwB,EAAE,CAAmB,CAChG,GAAI,CAAC,EAAK,WAAa,EAAK,UAAW,CACrC,IAAM,EAAM,EAAc,CACxB,aAAc,EAAK,UAAU,aAC7B,kBAAmB,EAAK,UAAU,kBAClC,OAAQ,CACN,KAAM,YACN,MAAO,EAAK,UAAU,QAAU,QAAU,OAC1C,YAAa,SACd,CACF,CAAC,CACF,GAAI,CAEF,OADA,MAAM,EAAI,OAAO,CACV,MAAM,EAAe,EAAM,CAChC,GAAG,EACH,UAAW,EAAI,UACf,UAAW,IAAA,GACZ,CAAC,QACM,CACR,MAAM,EAAI,MAAM,EAIpB,IAAM,EAAS,EAAK,SAAY,GAAM,QAAQ,OAAO,MAAM,EAAE,EACvD,EAAS,EAAK,SAAY,GAAM,QAAQ,OAAO,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,CAChD,IAAM,EAAS,MAAM,EAAU,cAAc,EAAS,CAChD,EAAQ,EAAS,EAAa,GAAU,iBAC9C,EAAG,OAAO,KAAK,EAAS,OAAO,GAAG,CAAC,GAAG,EAAM,IAAI,CAElD,MAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-id-D7Wf4tQw.js","names":[],"sources":["../src/build-id.ts"],"sourcesContent":["// auto-generated by scripts/gen-build-id.mjs — DO NOT EDIT\nexport const BUILD_ID = 4713\nexport const BUILD_BRANCH = 'dev'\nexport const BUILD_HASH = 'f084c2d1c'\n"],"mappings":";AACA,MAAa,EAAW,KAEX,EAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"apiVersion":1,"compilerVersion":"0.1.0-alpha.
|
|
1
|
+
{"apiVersion":1,"compilerVersion":"0.1.0-alpha.4","sourceHash":"831e810b41c3acebde9f13d0dd7806e131e5416a6e5839634af534ace7f0a693"}
|