mlai-code 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/checkpoints.mjs +217 -0
  4. package/src/cli.mjs +178 -31
  5. package/src/cloud.mjs +2 -0
  6. package/src/engine.mjs +1 -1
  7. package/src/headless.mjs +25 -9
  8. package/src/home.mjs +3 -2
  9. package/src/host.mjs +141 -13
  10. package/src/ide-quick.mjs +147 -0
  11. package/src/ide.mjs +182 -0
  12. package/src/netbox.mjs +1 -1
  13. package/src/parity.mjs +20 -1
  14. package/src/relay.mjs +1 -1
  15. package/src/render.mjs +12 -3
  16. package/src/runtime.mjs +23 -1
  17. package/src/sandbox.mjs +19 -3
  18. package/src/server.mjs +46 -7
  19. package/src/session.mjs +53 -10
  20. package/src/shared-data.mjs +1 -1
  21. package/src/tui/acp.mjs +121 -19
  22. package/src/tui/app.mjs +24 -5
  23. package/src/tui/chat.mjs +43 -16
  24. package/src/tui/cmd-config.mjs +3 -1
  25. package/src/tui/cmd-core.mjs +11 -7
  26. package/src/tui/cmd-extensibility.mjs +13 -2
  27. package/src/tui/commands.mjs +2 -1
  28. package/src/tui/extensions-local.mjs +2 -0
  29. package/src/tui/mcp-config.mjs +22 -4
  30. package/src/tui/review-cli.mjs +15 -4
  31. package/src/tui/snapshots.mjs +57 -16
  32. package/src/tui/statusline.mjs +2 -1
  33. package/src/two-words.mjs +14 -8
  34. package/src/view-sync.mjs +48 -0
  35. package/src/wakeups.mjs +2 -2
  36. package/src/winenv.mjs +1 -1
  37. package/src/workspace-api.mjs +21 -4
  38. package/vendor/client-sdk/index.cjs +5 -4
  39. package/vendor/cloud-cli/mlai.mjs +184 -28
  40. package/worker/architecture_worker.py +33 -4
  41. package/worker/browser_tool.py +19 -1
  42. package/worker/build_planner.py +75 -7
  43. package/worker/chat_fork.py +4 -1
  44. package/worker/checkpoints.py +71 -8
  45. package/worker/cloud_pty.py +91 -2
  46. package/worker/command_safety.py +80 -3
  47. package/worker/compaction_brief.py +186 -0
  48. package/worker/connected_turn.py +30 -0
  49. package/worker/context_manager.py +6 -0
  50. package/worker/conversation.py +139 -12
  51. package/worker/deck_render.js +11 -0
  52. package/worker/deck_tools.py +825 -0
  53. package/worker/git_sync.py +42 -17
  54. package/worker/goals.py +4 -0
  55. package/worker/image_generation.py +102 -23
  56. package/worker/kimi_bridge.py +580 -52
  57. package/worker/kimi_gates.py +74 -6
  58. package/worker/kimi_hook.py +213 -19
  59. package/worker/media_tools.py +182 -0
  60. package/worker/memory.py +2 -2
  61. package/worker/mlai_hooks.py +314 -5
  62. package/worker/mlai_mcp.py +49 -11
  63. package/worker/mlai_review/README.md +35 -0
  64. package/worker/mlai_review/__init__.py +1 -0
  65. package/worker/mlai_review/__main__.py +261 -0
  66. package/worker/mlai_review/_compat.py +29 -0
  67. package/worker/mlai_review/analysis/__init__.py +3 -0
  68. package/worker/mlai_review/analysis/detect.py +50 -0
  69. package/worker/mlai_review/analysis/main.py +128 -0
  70. package/worker/mlai_review/analysis/messages.py +8 -0
  71. package/worker/mlai_review/analysis/tools.py +194 -0
  72. package/worker/mlai_review/application/__init__.py +1 -0
  73. package/worker/mlai_review/application/asking.py +53 -0
  74. package/worker/mlai_review/application/challengers.py +142 -0
  75. package/worker/mlai_review/application/context_builder.py +194 -0
  76. package/worker/mlai_review/application/errors.py +17 -0
  77. package/worker/mlai_review/application/feedback.py +52 -0
  78. package/worker/mlai_review/application/matching.py +46 -0
  79. package/worker/mlai_review/application/messages.py +41 -0
  80. package/worker/mlai_review/application/ports.py +222 -0
  81. package/worker/mlai_review/application/prompts.py +342 -0
  82. package/worker/mlai_review/application/review_service.py +200 -0
  83. package/worker/mlai_review/application/reviewers.py +438 -0
  84. package/worker/mlai_review/application/streaming.py +91 -0
  85. package/worker/mlai_review/application/tools.py +138 -0
  86. package/worker/mlai_review/application/usage.py +145 -0
  87. package/worker/mlai_review/application/write_check.py +46 -0
  88. package/worker/mlai_review/contracts/__init__.py +5 -0
  89. package/worker/mlai_review/contracts/analysis.py +57 -0
  90. package/worker/mlai_review/contracts/review.py +42 -0
  91. package/worker/mlai_review/domain/__init__.py +4 -0
  92. package/worker/mlai_review/domain/changes.py +77 -0
  93. package/worker/mlai_review/domain/context.py +147 -0
  94. package/worker/mlai_review/domain/diagnostics.py +239 -0
  95. package/worker/mlai_review/domain/feedback.py +216 -0
  96. package/worker/mlai_review/domain/findings.py +505 -0
  97. package/worker/mlai_review/domain/lifecycle.py +85 -0
  98. package/worker/mlai_review/domain/partition.py +42 -0
  99. package/worker/mlai_review/domain/relations.py +166 -0
  100. package/worker/mlai_review/domain/relevance.py +202 -0
  101. package/worker/mlai_review/domain/report.py +99 -0
  102. package/worker/mlai_review/domain/structure.py +56 -0
  103. package/worker/mlai_review/domain/writes.py +86 -0
  104. package/worker/mlai_review/eval.py +221 -0
  105. package/worker/mlai_review/eval_cases/clean-rename.json +11 -0
  106. package/worker/mlai_review/eval_cases/missing-ownership-check.json +22 -0
  107. package/worker/mlai_review/eval_cases/off-by-one.json +22 -0
  108. package/worker/mlai_review/eval_cases/sql-injection.json +20 -0
  109. package/worker/mlai_review/feedback_report.py +60 -0
  110. package/worker/mlai_review/infrastructure/__init__.py +1 -0
  111. package/worker/mlai_review/infrastructure/analysis/__init__.py +1 -0
  112. package/worker/mlai_review/infrastructure/analysis/none.py +12 -0
  113. package/worker/mlai_review/infrastructure/analysis/translate.py +17 -0
  114. package/worker/mlai_review/infrastructure/github/__init__.py +0 -0
  115. package/worker/mlai_review/infrastructure/github/client.py +445 -0
  116. package/worker/mlai_review/infrastructure/github/feedback.py +212 -0
  117. package/worker/mlai_review/infrastructure/github/http.py +31 -0
  118. package/worker/mlai_review/infrastructure/github/rendering.py +398 -0
  119. package/worker/mlai_review/infrastructure/github/token.py +20 -0
  120. package/worker/mlai_review/infrastructure/local/__init__.py +1 -0
  121. package/worker/mlai_review/infrastructure/local/analyzer.py +48 -0
  122. package/worker/mlai_review/infrastructure/local/events.py +100 -0
  123. package/worker/mlai_review/infrastructure/local/git_reader.py +233 -0
  124. package/worker/mlai_review/infrastructure/local/publisher.py +138 -0
  125. package/worker/mlai_review/infrastructure/messages.py +54 -0
  126. package/worker/mlai_review/infrastructure/models/__init__.py +0 -0
  127. package/worker/mlai_review/infrastructure/models/openai_compatible.py +269 -0
  128. package/worker/mlai_review/infrastructure/structure/__init__.py +1 -0
  129. package/worker/mlai_review/infrastructure/structure/heuristic.py +186 -0
  130. package/worker/mlai_review/infrastructure/structure/tree_sitter.py +186 -0
  131. package/worker/mlai_review/infrastructure/workspace/__init__.py +1 -0
  132. package/worker/mlai_review/infrastructure/workspace/local.py +105 -0
  133. package/worker/mlai_review/infrastructure/workspace/memory.py +77 -0
  134. package/worker/mlai_review/infrastructure/workspace/paths.py +17 -0
  135. package/worker/mlai_review/pipeline.py +89 -0
  136. package/worker/mlai_review/runtime.py +194 -0
  137. package/worker/mlai_review/settings.py +139 -0
  138. package/worker/model_stream.py +21 -7
  139. package/worker/offline_guard.py +1 -1
  140. package/worker/preview.py +62 -4
  141. package/worker/product_facts.py +20 -0
  142. package/worker/project_context.py +33 -7
  143. package/worker/reply_language.py +92 -10
  144. package/worker/repo_policy.py +5 -0
  145. package/worker/roles.json +199 -37
  146. package/worker/roles.py +271 -9
  147. package/worker/runner.py +366 -53
  148. package/worker/runtime_control.py +64 -3
  149. package/worker/secret_scan.py +3 -2
  150. package/worker/server_memory.py +122 -0
  151. package/worker/site_check.py +279 -0
  152. package/worker/skill_library.py +15 -3
  153. package/worker/skill_pack.py +170 -16
  154. package/worker/subagents.py +6 -2
  155. package/worker/tool_catalog.py +4 -3
  156. package/worker/verification.py +156 -19
  157. package/worker/wakeups.py +56 -4
@@ -9,7 +9,7 @@
9
9
  * ${VAR} and ${VAR:-default} expand from this terminal's environment. Expanded env and header values are not written
10
10
  * to the session files: they travel to the engine like Vault secrets (MINI_MCP_ENV), see worker/mcp_local.py.
11
11
  */
12
- import {readFileSync} from 'node:fs';
12
+ import {readFileSync,statSync} from 'node:fs';
13
13
  import {mkdir,readFile,writeFile,rename} from 'node:fs/promises';
14
14
  import {spawn} from 'node:child_process';
15
15
  import path from 'node:path';
@@ -78,9 +78,9 @@ const hasRef=v=>typeof v==='string'&&/\$\{[A-Za-z_]/.test(v);
78
78
  * Values with ${VAR} references in env/headers move to mcpEnv (name -> {VAR: value} or {headers: {...}}).
79
79
  */
80
80
  export function engineServers(root,{env=process.env}={}){
81
- const out={},secret={},skipped=[];
81
+ const out={},secret={},skipped=[],blockedFiles=[];
82
82
  for(const s of listServers(root)){
83
- if(!s.enabled)continue;
83
+ if(!s.enabled){blockedFiles.push(...serverFiles(root,s.spec,env));continue}
84
84
  if(s.problem){skipped.push({name:s.name,reason:s.problem});continue}
85
85
  if(!s.trusted){skipped.push({name:s.name,reason:'defined by the repository and not trusted yet (/mcp trust)'});continue}
86
86
  const spec=s.spec,clean={...(spec.readOnly===true?{readOnly:true}:{})};
@@ -100,7 +100,25 @@ export function engineServers(root,{env=process.env}={}){
100
100
  }
101
101
  out[s.name]=clean;
102
102
  }
103
- return {mcpServers:out,mcpEnv:secret,skipped};
103
+ return {mcpServers:out,mcpEnv:secret,skipped,blockedFiles:[...new Set(blockedFiles)]};
104
+ }
105
+ /**
106
+ * BUG-0530: the program files of a stdio server (its script, not the interpreter on PATH). For a disabled server they
107
+ * become hard-deny paths, so the agent cannot start the server itself through the shell.
108
+ */
109
+ export function serverFiles(root,spec,env=process.env){
110
+ if(!isObj(spec)||spec.url||typeof spec.command!=='string')return [];
111
+ const base=typeof spec.cwd==='string'?path.resolve(root||process.cwd(),expand(spec.cwd,env)):(root||process.cwd());
112
+ const onPath=String(env.PATH||'').split(path.delimiter).filter(Boolean).map(d=>path.resolve(d));
113
+ const out=[];
114
+ for(const raw of [spec.command,...(Array.isArray(spec.args)?spec.args:[])]){
115
+ if(typeof raw!=='string'||!raw||raw.startsWith('-'))continue;
116
+ const p=path.resolve(base,expand(raw,env));
117
+ try{if(!statSync(p).isFile())continue}catch{continue}
118
+ if(onPath.includes(path.dirname(p)))continue;
119
+ out.push(p);
120
+ }
121
+ return out;
104
122
  }
105
123
  export async function trustRepoServers(root){await setTrusted(root,'mcp',repoServers(root))}
106
124
 
@@ -6,6 +6,7 @@ import {spawn,execFile} from 'node:child_process';
6
6
  import {readFile,writeFile,mkdir,rename} from 'node:fs/promises';
7
7
  import path from 'node:path';
8
8
  import {reviewRequest,addDismissal} from '../review.mjs';
9
+ import {hideEngineName} from '../runtime.mjs';
9
10
 
10
11
  export const SEVERITIES=['critical','high','medium','low','info'];
11
12
  const RANK={critical:0,high:1,medium:2,low:3,info:4};
@@ -61,7 +62,7 @@ export function parseReviewArgs(input){
61
62
  const REF=/^(?!-)[A-Za-z0-9._\/~^@{}-]{1,200}$/;
62
63
  export function gitRunner(root,execImpl=execFile){
63
64
  return (args,{allowFail=false}={})=>new Promise((resolve,reject)=>execImpl('git',args,{cwd:root,maxBuffer:8<<20,windowsHide:true},(e,stdout,stderr)=>{
64
- if(e&&!allowFail)reject(Object.assign(new Error(String(stderr||e.message).trim().split('\n').slice(-1)[0]||'git failed'),{code:e.code}));
65
+ if(e&&!allowFail)reject(Object.assign(new Error(gitReason(stderr||e.message)),{code:e.code}));
65
66
  else resolve(e?null:String(stdout).trim())}));
66
67
  }
67
68
  /** origin's default branch, else main or master (remote first). */
@@ -75,6 +76,12 @@ export async function defaultBase(git){
75
76
  * The reviewer's scope for a parsed target: {scope, base, head, title, body, label} or {empty:true, label}.
76
77
  * gh (optional): (args) => stdout|null, for a pull request's base branch and title.
77
78
  */
79
+ /** The line of a git error that says what went wrong ("fatal: ..."), not the trailing advice. */
80
+ export function gitReason(msg){
81
+ const lines=String(msg||'').split('\n').map(l=>l.trim()).filter(Boolean);
82
+ const fatal=lines.find(l=>/^(fatal|error):/i.test(l));
83
+ return (fatal||lines[0]||'git failed').replace(/^(fatal|error):\s*/i,'');
84
+ }
78
85
  export async function resolveTarget(o,{git,gh=async()=>null}){
79
86
  if(o.target==='repo')return {scope:'repo',label:'the whole repository'};
80
87
  if(await git(['rev-parse','--is-inside-work-tree'],{allowFail:true})!=='true')throw new ReviewUsage('This folder is not a git repository. Use /review repo to scan every file.');
@@ -83,8 +90,10 @@ export async function resolveTarget(o,{git,gh=async()=>null}){
83
90
  const n=o.pr;let info=null;
84
91
  try{info=JSON.parse(await gh(['pr','view',String(n),'--json','baseRefName,title,body'])||'null')}catch{info=null}
85
92
  const head='refs/mlai/pr/'+n;
93
+ // BUG-0512: say plainly when there is no origin remote, and show git's first error line, not its last.
94
+ if(await git(['remote','get-url','origin'],{allowFail:true})===null)throw new ReviewUsage('This repository has no remote named origin, so pull request #'+n+' cannot be fetched. Add one with: git remote add origin <url>');
86
95
  try{await git(['fetch','-q','--no-tags','origin','+refs/pull/'+n+'/head:'+head])}
87
- catch(e){throw new ReviewUsage('Could not fetch pull request #'+n+' from origin: '+e.message)}
96
+ catch(e){throw new ReviewUsage('Could not fetch pull request #'+n+' from origin: '+gitReason(e.message))}
88
97
  let base=o.base;
89
98
  if(!base&&info?.baseRefName&&REF.test(info.baseRefName)){
90
99
  const ref='refs/mlai/pr/'+n+'-base';
@@ -174,7 +183,9 @@ export function countsLine(s){
174
183
  export function renderReview(s,{label='',failOn='high',c=plain}={}){
175
184
  const lines=[];
176
185
  const kind=s.mode==='security'?'Security scan':s.mode==='deep'?'Deep review':'Review';
177
- lines.push(c.bold(kind+(label?' of '+label:''))+': '+countsLine(s));
186
+ // BUG-0494: a review that crashed or stopped never says "No issues found".
187
+ const head=s.state==='done'||s.findings.length?countsLine(s):s.state==='stopped'?c.yellow('stopped before it finished'):c.red('the review failed, nothing was checked');
188
+ lines.push(c.bold(kind+(label?' of '+label:''))+': '+head);
178
189
  if(s.findings.length)lines.push('',...s.findings.map((f,i)=>renderFinding(f,i+1,c)));
179
190
  if(s.resolved.length)lines.push('',c.dim(s.resolved.length+' earlier finding'+(s.resolved.length===1?' is':'s are')+' resolved.'));
180
191
  if(s.summary)lines.push('',oneLine(s.summary).slice(0,1200));
@@ -230,7 +241,7 @@ export async function runReview({root,dir,target,mode='standard',focus='',model=
230
241
  const state=foldReview(text,id);
231
242
  if(stopped){state.state='stopped'}
232
243
  else if(code===-1){state.state='error';state.error='The review could not start on this computer. Run mlai doctor --fix.'}
233
- else if(state.state==='running'){state.state='error';state.error='The reviewer stopped without a result.'+(err.trim()?' '+err.trim().split('\n').slice(-1)[0].slice(0,200):'')}
244
+ else if(state.state==='running'){state.state='error';state.error='The reviewer stopped without a result.'+(err.trim()?' '+hideEngineName(err.trim().split('\n').slice(-1)[0].slice(0,200)):'')}
234
245
  close(stopped?'stopped':state.state==='done'?'done':'error');
235
246
  return {state,target,id};
236
247
  }
@@ -2,11 +2,12 @@
2
2
  * Per-turn file snapshots for /rewind. Before each turn the project folder is recorded in a private git store in the
3
3
  * session folder (<session>/snapshots.git), never in the project's own repository: no commits, branches or stash
4
4
  * entries appear there. .gitignore rules are honored, so node_modules and build output are not copied.
5
- * Restoring a turn writes its files back and removes files created after it.
5
+ * Restoring a turn writes back only the files the agent changed in that turn and later (removing the ones it created);
6
+ * the user's own edits are left alone.
6
7
  */
7
8
  import {execFile} from 'node:child_process';
8
9
  import {existsSync} from 'node:fs';
9
- import {mkdir,readFile,writeFile,rm} from 'node:fs/promises';
10
+ import {mkdir,readFile,writeFile,rm,lstat} from 'node:fs/promises';
10
11
  import path from 'node:path';
11
12
 
12
13
  const LIMIT_MS=20000,MAX_BUFFER=64*1024*1024;
@@ -32,8 +33,24 @@ async function ensure(session){
32
33
  await writeFile(path.join(dir,'info','exclude'),own+'\n.git\n.mlai/sessions/\n');
33
34
  }
34
35
  const ref=n=>'refs/turns/'+n;
35
- /** The current folder as a tree id. */
36
- async function tree(session){await git(session,['add','-A','--','.']);return git(session,['write-tree'])}
36
+ // BUG-0553: snapshots skip large files (videos, data dumps, archives) so a question does not copy them into
37
+ // ~/.mlai/sessions every turn, and a folder too big to record is skipped as a whole.
38
+ export const SNAPSHOT_FILE_LIMIT=5*1024*1024,SNAPSHOT_TOTAL_LIMIT=200*1024*1024;
39
+ /** The current folder as a tree id. Files over SNAPSHOT_FILE_LIMIT are left out. */
40
+ async function tree(session){
41
+ const root=session.meta.root;
42
+ const list=(await git(session,['ls-files','-z','-c','-o','--exclude-standard'])).split('\0').filter(Boolean);
43
+ const keep=[],skip=[];let total=0;
44
+ for(const f of [...new Set(list)]){
45
+ const st=await lstat(path.join(root,f)).catch(()=>null);
46
+ if(st&&st.isFile()&&st.size>SNAPSHOT_FILE_LIMIT){skip.push(f);continue}
47
+ total+=st?.isFile()?st.size:0;keep.push(f);
48
+ }
49
+ if(total>SNAPSHOT_TOTAL_LIMIT)throw Object.assign(new Error('folder too large to snapshot'),{code:'TOO_LARGE'});
50
+ if(skip.length)await git(session,['rm','-q','--cached','--ignore-unmatch','--pathspec-from-file=-','--pathspec-file-nul'],{input:skip.join('\0')});
51
+ if(keep.length)await git(session,['add','-A','--pathspec-from-file=-','--pathspec-file-nul'],{input:keep.join('\0')});
52
+ return git(session,['write-tree']);
53
+ }
37
54
 
38
55
  /** Records the folder as it is before turn `turn` (0-based). Returns the commit id, or null when snapshots are off. */
39
56
  export async function snapshot(session,turn){
@@ -46,7 +63,7 @@ export async function snapshot(session,turn){
46
63
  return c;
47
64
  }catch(e){
48
65
  // A folder too large to record in time: turn snapshots off for this session rather than slowing every turn.
49
- if(e.code==='ETIMEDOUT'||e.killed||/timed out|ENOBUFS/.test(e.message)){session.meta.snapshots=false;await session.save().catch(()=>{})}
66
+ if(e.code==='TOO_LARGE'||e.code==='ETIMEDOUT'||e.killed||/timed out|ENOBUFS/.test(e.message)){session.meta.snapshots=false;await session.save().catch(()=>{})}
50
67
  return null;
51
68
  }
52
69
  }
@@ -54,7 +71,7 @@ export async function snapshot(session,turn){
54
71
  export async function snapshots(session){
55
72
  if(!existsSync(path.join(store(session),'HEAD')))return [];
56
73
  const out=await git(session,['for-each-ref','--format=%(refname)','refs/turns/']).catch(()=>'');
57
- return out.split('\n').map(r=>Number(r.split('/').pop())).filter(Number.isInteger).sort((a,b)=>a-b);
74
+ return out.split('\n').filter(r=>/^refs\/turns\/\d+$/.test(r)).map(r=>Number(r.split('/').pop())).sort((a,b)=>a-b);
58
75
  }
59
76
  /** Files that differ between now and the snapshot before `turn`: [{status:'A'|'M'|'D', path}] (A: created since). */
60
77
  export async function changesSince(session,turn){
@@ -62,26 +79,50 @@ export async function changesSince(session,turn){
62
79
  const out=await git(session,['diff','--name-status','--no-renames',ref(turn),now]);
63
80
  return out?out.split('\n').map(l=>{const [s,...p]=l.split('\t');return {status:s[0],path:p.join('\t')}}):[];
64
81
  }
82
+ /** Records the folder as the agent left it after turn `turn` (BUG-0525: so /rewind can tell the agent's changes from the user's). */
83
+ export async function snapshotAfter(session,turn){
84
+ if(session.meta.snapshots===false||!existsSync(path.join(store(session),'HEAD')))return null;
85
+ try{const c=await git(session,['commit-tree',await tree(session),'-m','After turn '+(turn+1)]);await git(session,['update-ref',afterRef(turn),c]);return c}catch{return null}
86
+ }
87
+ const afterRef=n=>'refs/turns/after/'+n;
88
+ const exists=(session,r)=>git(session,['rev-parse','-q','--verify',r+'^{commit}']).then(()=>true,()=>false);
89
+ const names=out=>out?out.split('\n').map(l=>{const [s,...p]=l.split('\t');return {status:s[0],path:p.join('\t')}}):[];
65
90
  /**
66
- * Writes the folder back to how it was before `turn`. The current state is kept as refs/turns/undo-<time> first, so a
67
- * rewind can itself be undone by hand. Returns {restored, removed} file counts.
91
+ * Writes back the files the agent changed in turn `turn` and later, as they were before `turn`. The current state is
92
+ * kept as refs/turns/undo-<time> first, so a rewind can itself be undone by hand.
93
+ * BUG-0525: files the user created or edited themselves (outside the agent's turns) are never touched, and a file the
94
+ * agent changed but the user edited again afterwards is kept (counted in `kept`). Returns {restored, removed, kept}.
68
95
  */
69
96
  export async function restore(session,turn){
70
97
  const list=await snapshots(session);
71
98
  if(!list.includes(turn))throw new Error('No file snapshot for turn '+(turn+1)+'.');
72
99
  const now=await tree(session);
73
100
  await git(session,['update-ref','refs/turns/undo-'+Date.now(),await git(session,['commit-tree',now,'-m','Before rewind'])]);
74
- const changes=await changesSince(session,turn);
75
- const created=changes.filter(c=>c.status==='A').map(c=>c.path);
76
- for(const f of created){
77
- const abs=path.resolve(session.meta.root,f);
78
- if(abs.startsWith(path.resolve(session.meta.root)+path.sep))await rm(abs,{force:true});
101
+ // The agent's changes per turn: before-turn snapshot to after-turn snapshot. Sessions from before after-snapshots
102
+ // existed fall back to the next turn's snapshot (or now).
103
+ const last=new Map();// path -> after ref of the last turn that changed it (null: no after snapshot)
104
+ for(const k of list.filter(k=>k>=turn)){
105
+ const hasAfter=await exists(session,afterRef(k));
106
+ const next=list.find(n=>n>k);
107
+ const end=hasAfter?afterRef(k):next!=null?ref(next):now;
108
+ for(const c of names(await git(session,['diff','--name-status','--no-renames',ref(k),end])))last.set(c.path,hasAfter?afterRef(k):null);
109
+ }
110
+ const base=path.resolve(session.meta.root);
111
+ let restored=0,removed=0,kept=0;
112
+ for(const [f,after] of last){
113
+ // Edited again by the user after the agent's turn: keep the user's version.
114
+ if(after&&await git(session,['diff','--quiet',after,now,'--',f]).then(()=>false,()=>true)){kept++;continue}
115
+ const abs=path.resolve(base,f);if(!abs.startsWith(base+path.sep))continue;
116
+ const before=await git(session,['ls-tree','-z',ref(turn),'--',f]).catch(()=>'');
117
+ if(before){await git(session,['checkout',ref(turn),'--',f]);restored++}
118
+ else if(existsSync(abs)||(await lstat(abs).catch(()=>null))){await rm(abs,{force:true});removed++}
79
119
  }
80
- await git(session,['read-tree',ref(turn)]);
81
- await git(session,['checkout-index','-a','-f']);
82
- return {restored:changes.length-created.length,removed:created.length};
120
+ return {restored,removed,kept};
83
121
  }
84
122
  /** Drops snapshots after `turn` (they belong to turns that no longer exist). */
85
123
  export async function forget(session,fromTurn){
86
124
  for(const n of await snapshots(session))if(n>fromTurn)await git(session,['update-ref','-d',ref(n)]).catch(()=>{});
125
+ if(!existsSync(path.join(store(session),'HEAD')))return;
126
+ const after=await git(session,['for-each-ref','--format=%(refname)','refs/turns/after/']).catch(()=>'');
127
+ for(const r of after.split('\n').filter(Boolean))if(Number(r.split('/').pop())>=fromTurn)await git(session,['update-ref','-d',r]).catch(()=>{});
87
128
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import {execFile,spawn} from 'node:child_process';
7
7
  import {width,truncate} from './ansi.mjs';
8
+ import {credits} from '../render.mjs';
8
9
  import {MODES,modeName,sessionMode} from '../modes.mjs';
9
10
 
10
11
  export const compact=n=>{n=Number(n)||0;const a=Math.abs(n);return a>=1e9?(n/1e9).toFixed(1).replace(/\.0$/,'')+'B':a>=1e6?(n/1e6).toFixed(1).replace(/\.0$/,'')+'M':a>=1e4?Math.round(n/1e3)+'k':a>=1e3?(n/1e3).toFixed(1).replace(/\.0$/,'')+'k':String(Math.round(n))};
@@ -57,7 +58,7 @@ function piece(name,d,t){
57
58
  case 'cwd':return d.folder?t.dim(d.folder):'';
58
59
  case 'session':return d.sessionName||d.session?t.dim(String(d.sessionName||d.session).slice(0,24)):'';
59
60
  case 'context':{if(!d.context)return '';const p=d.context.percent,style=p>=85?t.bad:p>=65?t.warn:t.dim;return style(p+'% context')}
60
- case 'credits':return d.tokensLeft!=null?t.dim(compact(d.tokensLeft)+' tokens left'):d.usage?.tokens?t.dim(compact(d.usage.tokens)+' tokens'):'';
61
+ case 'credits':return d.tokensLeft!=null?t.dim(credits(d.tokensLeft)+' left'):d.usage?.tokens?t.dim(credits(d.usage.tokens)):'';
61
62
  case 'time':{const n=d.now?new Date(d.now):new Date();return t.dim(String(n.getHours()).padStart(2,'0')+':'+String(n.getMinutes()).padStart(2,'0'))}
62
63
  }
63
64
  return '';
package/src/two-words.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // Same as lib/two-words.ts (tests/two-words.test.mjs keeps them identical). Every automatic name is exactly two title-case words. Names a person types are never passed through here.
1
+ // Same as lib/two-words.ts (tests/two-words.test.mjs keeps them identical). Every automatic name is one to five title-case words (BUG-0548). Names a person types are never passed through here.
2
2
  const STOP=new Set(('a an the to for of in on at by with from into onto about as and or but if so then than this that these those it its is are was were be been am do does did done '+
3
3
  'i me my mine we us our you your yours he she they them their please pls plz kindly can could would should will shall may might must just also really maybe like '+
4
4
  'help want wanted need needs needed lets let hey hi hello thanks thank ok okay now here there what how why when where which who whom whose some any all every something anything thing things '+
@@ -18,19 +18,25 @@ function tokens(text){
18
18
  // a file name counts as its base name: notes.txt is Notes, never Txt
19
19
  const t=raw.replace(/^[^\p{L}\p{N}#]+|[^\p{L}\p{N}]+$/gu,'').replace(/^([\p{L}\p{N}_-]+)\.[a-z][a-z0-9]{0,4}$/iu,'$1');if(!t)continue;
20
20
  const parts=/\p{N}|#/u.test(t)&&/\p{L}/u.test(t)||prose&&/^\p{L}{2,}-\p{L}{2,}$/u.test(t)?[t]:t.split(/[^\p{L}\p{N}]+/u); // in a sentence, long-running stays one word; slugs split
21
- for(const p of parts)if(p&&/\p{L}/u.test(p)&&!STOP.has(p.toLowerCase()))out.push(p.slice(0,24));
21
+ for(const p of parts)if(p&&/\p{L}/u.test(p)&&!/^[a-z]$/i.test(p)&&!STOP.has(p.toLowerCase()))out.push(p.slice(0,24));// a lone letter (add(a, b)) says nothing
22
22
  }
23
23
  return out;
24
24
  }
25
- /** Exactly two meaningful title-case words from free text, or the two-word fallback. `second` completes a single word (else it follows the intent). */
26
- export function twoWordTitle(text,fallback='New Chat',second){
27
- const w=tokens(text);if(!w.length)return fallback||'New Chat';
28
- if(w.length>1)return word(w[0])+' '+word(w[1]);
25
+ /** BUG-0548/BUG-0592: one to five meaningful title-case words from free text (filler dropped), or the fallback. `second` completes a single word.
26
+ `max` caps the words (file names keep two). Old stored two-word names are not renamed. */
27
+ export const TITLE_WORDS=5;
28
+ export function twoWordTitle(text,fallback='New Chat',second,max=TITLE_WORDS){
29
+ // BUG-0297: "file" says nothing about the chat; "Create a file calc.js" is Create Calc, not Create File.
30
+ let w=tokens(text);const lean=w.filter(t=>!/^files?$/i.test(t));if(lean.length>=2)w=lean;
31
+ if(!w.length)return fallback||'New Chat';
32
+ if(w.length>1||max<2)return w.slice(0,Math.max(1,max)).map(word).join(' ');
29
33
  const first=word(w[0]),hit=INTENT.find(([re])=>re.test(String(text??'')));let next=second||(hit?hit[1]:/\?\s*$/.test(String(text??''))?'Chat':'Task');
30
34
  if(next.toLowerCase()===first.toLowerCase())next='Task';
31
35
  return first+' '+next;
32
36
  }
37
+ /** The same rule under its current name. */
38
+ export const chatTitle=twoWordTitle;
33
39
  /** The first meaningful word plus a fixed second one: "Login Fork", "Web Team". */
34
- export const nameWith=(text,second)=>(tokens(text).length?twoWordTitle(text).split(' ')[0]:'New')+' '+second;
35
- /** True when a name is exactly two words, the shape every automatic name has. */
40
+ export const nameWith=(text,second)=>(tokens(text).length?twoWordTitle(text,'New',undefined,1):'New')+' '+second;
41
+ /** True when a name is exactly two words, the shape automatic names had before BUG-0548 (old stored names keep it). */
36
42
  export const isTwoWords=(t)=>String(t??'').trim().split(/\s+/).filter(Boolean).length===2;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * BUG-0478: terminal (mlai) chats were listed in the web app but opened empty, because only the Mac app sent the
3
+ * compact conversation view (workspace-api.mjs pushView). The terminal now sends the same view after each turn, so the
4
+ * web shows the chat as a read-only transcript. Questions and answers only, never file contents; best effort: an
5
+ * offline computer, an older server or a signed-out session never affects the run.
6
+ */
7
+ import os from 'node:os';
8
+ import {nameWith} from './two-words.mjs';
9
+
10
+ const FINAL=['completed','error','stopped','limited','interrupted'];
11
+ const clip=(s,n)=>String(s??'').slice(0,n);
12
+ // The engine sees the Ask card, session instructions and extra-folder notes; the transcript shows what the person typed.
13
+ export function shownTask(task){
14
+ let t=String(task||'');
15
+ const m=/^Session instructions from the user[\s\S]*?\n\nTask:\n/.exec(t);if(m)t=t.slice(m[0].length);
16
+ t=t.replace(/^Answer the question from the code[^\n]*\n\nQuestion: /,'').replace(/\n\nYou may also read these folders: [^\n]*$/,'');
17
+ return t;
18
+ }
19
+ function answer(turn){
20
+ const ev=Array.isArray(turn?.events)?turn.events:[];
21
+ const a=[...ev].reverse().find(e=>e?.type==='answer'&&typeof e.content==='string'&&e.content.trim())
22
+ ||[...ev].reverse().find(e=>e?.type==='assistant'&&typeof e.content==='string'&&e.content.trim());
23
+ if(a)return String(a.content);
24
+ const sub=turn?.status?.result?.submission;return typeof sub==='string'&&sub!=='Task complete'?sub:'';
25
+ }
26
+ /** Session.transcript() turns -> the view /api/laptop view_save accepts (lib/laptop-view.ts). */
27
+ export function transcriptView(turns,meta={},device=os.hostname(),now=Date.now()){
28
+ const list=(Array.isArray(turns)?turns:[]).filter(t=>t&&String(t.task||'').trim());
29
+ const last=list.at(-1),state=String(last?.status?.state||'idle');
30
+ const done=list.filter(t=>!t.current||FINAL.includes(String(t.status?.state||'')));
31
+ const conversation=done.slice(-12).map((t,i)=>({id:clip(t.status?.runId||t.runId||('turn-'+(list.length-done.length+i+1)),40),task:clip(shownTask(t.task),2000),answer:clip(answer(t),6000),state:String(t.status?.state||'unknown')}));
32
+ const running=last?.current&&!FINAL.includes(state);
33
+ const c=last?.completion;
34
+ return {title:clip(meta.title||nameWith(meta.folder,'Chat'),160),state:running?state:(FINAL.includes(state)?state:'idle'),task:running?clip(shownTask(last.task),2000):'',conversation,todos:[],
35
+ completion:c&&typeof c==='object'?{summary:clip(c.summary,4000),changedFiles:(Array.isArray(c.changedFiles)?c.changedFiles:[]).filter(f=>typeof f==='string').slice(0,50)}:null,updated:now,device:clip(device,80)};
36
+ }
37
+ /** The server name of a terminal session (lib/laptop-run.ts laptopWorkspace). */
38
+ export const serverName=meta=>meta?.cloudProject||meta?.project?'mini-'+(meta.cloudProject||meta.project):null;
39
+ /** Sends the view; resolves true when the server accepted it. Never throws. */
40
+ export async function pushTranscript(session,cloud,{device=os.hostname()}={}){
41
+ try{
42
+ const name=serverName(session?.meta);
43
+ if(!name||!/^mini-[a-f0-9-]{36}$/.test(name)||typeof cloud?.viewSave!=='function'||process.env.MLAI_NO_VIEW_SYNC==='1')return false;
44
+ const view=transcriptView(await session.transcript(),session.meta,device);
45
+ if(!view.conversation.length&&!view.task)return false;
46
+ await cloud.viewSave(name,view);return true;
47
+ }catch{return false}
48
+ }
package/src/wakeups.mjs CHANGED
@@ -11,12 +11,12 @@ async function writeJson(file,data){const tmp=file+'.'+process.pid+'.tmp';await
11
11
  export function dueWake(w,now=Date.now()){
12
12
  if(!w||typeof w!=='object'||w.state!=='pending'||!ID.test(String(w.id)))return null;
13
13
  const at=Date.parse(String(w.at));if(!Number.isFinite(at)||at>now)return null;
14
- return {id:w.id,kind:w.kind==='goal'?'goal':'agent',note:String(w.note||'').slice(0,1000),at:w.at};
14
+ return {id:w.id,kind:w.kind==='goal'||w.kind==='verify'?w.kind:'agent',note:String(w.note||'').slice(0,1000),at:w.at};
15
15
  }
16
16
  /** Run fields for the wake run, carried over from the session's last request (the worker keeps its own context). */
17
17
  export function wakeRun(request,wake){
18
18
  const r=request&&typeof request==='object'?request:{};
19
- return {task:wake.note||(wake.kind==='goal'?'Continue the goal':'Scheduled check-in'),wake:{id:wake.id,kind:wake.kind,note:wake.note},
19
+ return {task:wake.note||(wake.kind==='goal'?'Continue the goal':wake.kind==='verify'?'Continue and fix the open checks':'Scheduled check-in'),wake:{id:wake.id,kind:wake.kind,note:wake.note},
20
20
  ...(['plan','approve','auto','brief'].includes(r.mode)?{mode:r.mode}:{}),...(typeof r.role==='string'&&r.role?{role:r.role}:{}),
21
21
  ...(typeof r.modelId==='string'?{model:r.modelId}:{}),...(['low','medium','high'].includes(r.reasoningEffort)?{effort:r.reasoningEffort}:{}),
22
22
  ...(typeof r.planApproval==='string'?{planApproval:r.planApproval}:{}),...(Number(r.steps)>0?{steps:Math.min(160,Number(r.steps))}:{})};
package/src/winenv.mjs CHANGED
@@ -32,7 +32,7 @@ export function gitForWindows(env=process.env){
32
32
  */
33
33
  export const BUSYBOX={version:'FRP-6354-g5f09fb446',file:'busybox-w64u-FRP-6354-g5f09fb446.exe',sha256:'36b266923fc5765b42f5f981319f39568498fba60b53ccf26e8fc1e575e2a9a9'};
34
34
  export const BUSYBOX_UPSTREAM='https://frippery.org/files/busybox/';
35
- const PROD='https://mlai-mini-code.vercel.app';
35
+ const PROD='https://code.ml.ai';
36
36
  /** Download URLs for the pinned busybox, most trusted host first, without duplicates. */
37
37
  export function busyboxSources({server,env=process.env}={}){
38
38
  const out=[];const add=u=>{if(typeof u==='string'&&/^https?:\/\//.test(u)&&!out.includes(u))out.push(u)};
@@ -17,7 +17,7 @@ import {ensureRuntime} from './runtime.mjs';
17
17
  import {createReviews} from './review.mjs';
18
18
  import {killTree} from './winenv.mjs';
19
19
  import {createWakeScheduler} from './wakeups.mjs';
20
- import {starterSkills,validateSkill,importSession,POLICY_TEMPLATES,parseCheckpoints,checkpointRef,rewind,resumeTask,mimeType} from './parity.mjs';
20
+ import {starterSkills,validateSkill,importSession,POLICY_TEMPLATES,parseCheckpoints,checkpointRef,rewind,parseRescues,restoreRescue,RESCUE_LIST_ARGS,resumeTask,mimeType} from './parity.mjs';
21
21
  import {twoWordTitle,nameWith} from './two-words.mjs';
22
22
 
23
23
  const UUID=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
@@ -342,7 +342,7 @@ export function createLocalWorkspaces({cloud,home,device=os.hostname(),relay=fal
342
342
  const isGit=s.meta.git&&await isGitRepo(root);
343
343
  if(CLOUD_ONLY[action])throw fail(CLOUD_ONLY[action]+' are not available for sessions on this computer yet. Use a cloud workspace for this.',{code:'local_unsupported'});
344
344
  if(action.startsWith('deploy_')||action.startsWith('signals_')||/^(monitor|alert|schedule|schedules|releases|ingest|mission|missions|source|sources)_/.test(action))throw fail('This is not available for sessions on this computer yet. Use a cloud workspace for this.',{code:'local_unsupported'});
345
- if(['skill_save','session_import','browser_setup'].includes(action)&&running(e))throw new Error('Wait for the current task to finish before changing its tools or context.');
345
+ if(['skill_save','skill_delete','session_import','browser_setup'].includes(action)&&running(e))throw new Error('Wait for the current task to finish before changing its tools or context.');
346
346
  switch(action){
347
347
  case 'status':{const snap=await snapshot(e);const key=snap.status?.state+'|'+snap.history.length;if(key!==e.lastKey){e.lastKey=key;pushView(e)}return snap}
348
348
  case 'view':return {view:null,at:0};
@@ -391,6 +391,14 @@ export function createLocalWorkspaces({cloud,home,device=os.hostname(),relay=fal
391
391
  if(previous){const h=path.join(dir,'skill-history',skill.id);await mkdir(h,{recursive:true});await writeFile(path.join(h,Date.now()+'-'+randomUUID()+'.json'),previous)}
392
392
  await mkdir(path.join(dir,'skills'),{recursive:true});await writeFile(file,JSON.stringify(skill));return {ok:true,skill};
393
393
  }
394
+ case 'skill_delete':{
395
+ // BUG-0265: delete a user-created skill; the last version stays in skill history.
396
+ if(typeof b.id!=='string'||!/^[a-z0-9][-a-z0-9]{0,59}$/.test(b.id))throw new Error('Invalid skill ID');
397
+ const file=path.join(dir,'skills',b.id+'.json'),previous=await readFile(file).catch(()=>null);
398
+ if(!previous)throw new Error('Only skills you created can be deleted');
399
+ const h=path.join(dir,'skill-history',b.id);await mkdir(h,{recursive:true});await writeFile(path.join(h,Date.now()+'-'+randomUUID()+'.json'),previous);
400
+ await rm(file,{force:true});return {ok:true};
401
+ }
394
402
  case 'skill_history':{
395
403
  if(typeof b.id!=='string'||!/^[-a-z0-9]{1,60}$/.test(b.id))throw new Error('Invalid skill ID');
396
404
  const h=path.join(dir,'skill-history',b.id),versions=[];
@@ -455,14 +463,17 @@ export function createLocalWorkspaces({cloud,home,device=os.hostname(),relay=fal
455
463
  case 'terminal_stop':{const id=typeof b.id==='string'&&/^[a-z0-9]{8,32}$/.test(b.id)?b.id:'';if(!id)throw new Error('Nothing to stop');const c=terminals.get(id);if(!c)return {stopped:false};killTree(c.pid);return {stopped:true}}
456
464
  case 'diff':{
457
465
  if(!isGit)return {diff:'',untracked:'',skipped:[]};
458
- let d=await git(root,['diff','HEAD','--no-ext-diff','-M'],{ok:[1]}).catch(()=>'');
466
+ /* BUG-0293: Whole repository = working tree against the merge-base with the default branch. */
467
+ let base='HEAD',label='';
468
+ if(b.base==='branch'){const o=await gitOut(root,['symbolic-ref','--quiet','--short','refs/remotes/origin/HEAD']).catch(()=>'');for(const h of [o,'origin/main','origin/master','main','master'].filter(Boolean)){const m=await gitOut(root,['merge-base','HEAD',h]).catch(()=>'');if(m){base=m;label=h;break}}}
469
+ let d=await git(root,['diff',base,'--no-ext-diff','-M'],{ok:[1]}).catch(()=>'');
459
470
  const extra=(await gitOut(root,['ls-files','--others','--exclude-standard'])).split('\n').filter(Boolean),skipped=[];
460
471
  for(const f of extra.slice(0,200)){
461
472
  const p=path.join(root,f);let size=Infinity;try{const st=await stat(p);if(st.isFile())size=st.size}catch{}
462
473
  if(d.length>400000||size>200000){skipped.push(f);continue}
463
474
  d+=(await exec('git',['diff','--no-index','--no-ext-diff','--','/dev/null',f],{cwd:root})).stdout;
464
475
  }
465
- return {diff:d.slice(0,600000),untracked:extra.join('\n'),skipped:[...skipped,...extra.slice(200)]};
476
+ return {diff:d.slice(0,600000),untracked:extra.join('\n'),skipped:[...skipped,...extra.slice(200)],...(label?{base:label}:{})};
466
477
  }
467
478
  case 'export':{
468
479
  if(!isGit)throw new Error('Exporting a patch needs a git repository.');
@@ -475,6 +486,12 @@ export function createLocalWorkspaces({cloud,home,device=os.hostname(),relay=fal
475
486
  const ref=checkpointRef(b.checkpoint);if(ref==='HEAD')throw new Error('Choose a checkpoint to compare');
476
487
  const out=await py('checkpoints.py',['compare',ref.slice(5)],{cwd:root});if(out.error)throw new Error(out.error);return out;
477
488
  }
489
+ case 'rescues':return {rescues:isGit?parseRescues(await gitOut(root,RESCUE_LIST_ARGS).catch(()=>'')):[]};
490
+ case 'rescue_restore':{
491
+ idle(e,'restoring a rescue stash. Stop the agent first');
492
+ if(!isGit)throw new Error('Rescue stashes need a git repository.');
493
+ const r=await restoreRescue(b.sha,args=>git(root,args));change(e);return r;
494
+ }
478
495
  case 'restore':{
479
496
  idle(e,'restoring a checkpoint. Stop the agent first');
480
497
  if(b.confirm!==true)throw new Error('Confirm discarding changes before restoring');
@@ -47,7 +47,7 @@ function diagnostic({surface,version,os,arch,code,status,protocol=PROTOCOL}={}){
47
47
  class Client{
48
48
  constructor({baseUrl=DEFAULT_URL,tokenProvider=()=>null,fetchImpl=globalThis.fetch,surface='desktop',version='0.1.0',allowLoopback=false,timeoutMs=30000}={}){
49
49
  this.baseUrl=serverOrigin(baseUrl,{allowLoopback});this.tokenProvider=tokenProvider;this.fetch=fetchImpl;
50
- if(!['desktop','vscode','jetbrains','acp','laptop'].includes(surface))throw new ClientError('Invalid client surface');
50
+ if(!['desktop','vscode','jetbrains','acp','laptop','mobile'].includes(surface))throw new ClientError('Invalid client surface');
51
51
  this.surface=surface;this.version=string(version,'version',60);this.timeoutMs=timeoutMs;
52
52
  }
53
53
  async request(path,body,{method='POST',signal,authenticated=true,readOnly=false}={}){
@@ -78,7 +78,8 @@ class Client{
78
78
  if(signal?.aborted)throw abortError();
79
79
  if(error instanceof ClientError)throw error;
80
80
  if(attempt<retries){await delay(300*2**attempt,undefined,{signal});continue}
81
- throw new ClientError('Connection interrupted. Refresh status before retrying a write.',{code:'connection_interrupted',retryable:readOnly});
81
+ // The server address goes with the error so a client can say which server it could not reach (BUG-0504).
82
+ throw Object.assign(new ClientError('Connection interrupted. Refresh status before retrying a write.',{code:'connection_interrupted',retryable:readOnly}),{server:this.baseUrl});
82
83
  }finally{clearTimeout(timer);signal?.removeEventListener('abort',abort)}
83
84
  }
84
85
  }
@@ -102,9 +103,9 @@ class Client{
102
103
  if(!/^[a-f0-9-]{36}$/.test(requestId))throw new ClientError('Invalid request ID');
103
104
  return this.workspace(token,'run',{task,mode,planApproval:'guided',requestId},{signal});
104
105
  }
105
- approve(token,id,approved,{signal,revise}={}){
106
+ approve(token,id,approved,{signal,revise,all}={}){
106
107
  string(id,'approval ID',150);if(typeof approved!=='boolean')throw new ClientError('Approval must be explicit');
107
- return this.workspace(token,'approve',{id,approved,...(revise?{revise:string(revise,'revision',5000)}:{})},{signal});
108
+ return this.workspace(token,'approve',{id,approved,...(approved&&all===true?{all:true}:{}),...(revise?{revise:string(revise,'revision',5000)}:{})},{signal});
108
109
  }
109
110
  stop(token,options){return this.workspace(token,'stop',{},options)}
110
111
  async files(token,options){const s=await this.status(token,options);return {files:s.files||[]}}