@yunhozz/arc 0.4.0 → 0.4.1
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/MANIFEST.sha256 +5 -5
- package/lib/installer/role-routing.mjs +35 -8
- package/lib/management/operations.mjs +5 -1
- package/lib/tui/app.mjs +53 -9
- package/lib/tui/setup.mjs +1 -0
- package/package.json +1 -1
package/MANIFEST.sha256
CHANGED
|
@@ -71,7 +71,7 @@ f9a0958fc424742f49ce6e2e0a49c7cf2bbe288e0cf3551d69a8a912c8f2709f lib/installer/
|
|
|
71
71
|
fbcff7b20be52f5f60ab3d510fbf4d6f514abdcac4396f94d378fe4439e71e29 lib/installer/package-references.mjs
|
|
72
72
|
882a8372c1841a222753ddcddb67954ae83bccb64321720a3708d77d724df2e1 lib/installer/plan.mjs
|
|
73
73
|
d9af774b8f299940a9d96cc6939ebea4ebe6c170860034f1a877c41853dd3110 lib/installer/preset.mjs
|
|
74
|
-
|
|
74
|
+
efe013e2ccf09886797345a283b8d31096f48fe8934d253aadf7d05a880e230c lib/installer/role-routing.mjs
|
|
75
75
|
ad55a09cea39d90f7e526765061db0dc03ba0907b6bb9c08b5cc40b32ff9deeb lib/installer/runtime-assets.mjs
|
|
76
76
|
9cbfd5103a690880e1582afa96b8b33bb92f175540bb8128df0435e32ff8e6ed lib/installer/runtime-config.mjs
|
|
77
77
|
bfc6c13638955fbd44b6002de3a5a2de911c50ad630a44ec1bcf0e987dfd825b lib/installer/shell-completion.mjs
|
|
@@ -85,7 +85,7 @@ c2ab7eda987cf62bba4dce1b7eb302f350a6c67679b0aaf063b3eea11eb010c5 lib/installer/
|
|
|
85
85
|
4692adc32f9b600e184080a71c3f9d94f387fe755f3e96e590352f59520badc6 lib/installer/upgrade-state.mjs
|
|
86
86
|
a869b311492567e43528caf766b73e8990fc3b059cab723aa27b0df48f31d9f7 lib/installer/upgrade.mjs
|
|
87
87
|
2946f055d61fbe2ffd6af1c182096e01d8c1a4bfb0aa274547ce5e147dccfd19 lib/limits.mjs
|
|
88
|
-
|
|
88
|
+
9164bb4ab5b7d5c98bf298686f4e69ed5618f689b29cec989c2b745cef7f4f62 lib/management/operations.mjs
|
|
89
89
|
446c17efc62a7799882dc83058855ccda38b5021aa35ea02ff1ea4b8ddfaa335 lib/management/status.mjs
|
|
90
90
|
d321ca1b41c7e3fb5515fca0028e748641155f621f833c2a1f8d897573dcd6a6 lib/management/update.mjs
|
|
91
91
|
7ecda29faac49d98739319e3282db2f415b88474f78e85b67d1d52dd4f16167a lib/management/workflow.mjs
|
|
@@ -153,13 +153,13 @@ b29a9f9a9a60836271545e3f75346d51d7d0bf1ac1eccbfa3a624717f78beebb lib/runtime/ta
|
|
|
153
153
|
5b14c4ffdff116a005601b737e94484e9eebdea746ec0e296ca7a34be2b7ea4a lib/runtime/verification.mjs
|
|
154
154
|
7e75d9bb51eac4bd1a6fccf45fb195c526bb3bc43cf0b04398b85ff7723f8689 lib/safe-fs/index.mjs
|
|
155
155
|
4174dfcfcd4d69a5486b91108ec03279cfd50644109c7457aa87f9ac877fb1ac lib/safe-fs/native.mjs
|
|
156
|
-
|
|
156
|
+
c734073417ea0bef026d072494762241e51e3a84a640a6b3a98ff2a46312e0a2 lib/tui/app.mjs
|
|
157
157
|
cb8b64e74008f28e9cba206c9ed4a85a7009712eefcd3a889e45767b7c912a58 lib/tui/custom-preset.mjs
|
|
158
158
|
b249d9ec192bdfb283cce77bbec185debdc7dfde1727204d305cd41f97d1c13c lib/tui/derive-install-plan.mjs
|
|
159
159
|
243e989a7f8af41f935a2681069ebb162827a6c3df5683af5a16cec3f24bf654 lib/tui/diagram.mjs
|
|
160
160
|
2a6cd4c21c8b2755aa20bb0e6ff7177379de108f104974f401b1f2315c3f8b30 lib/tui/mode.mjs
|
|
161
161
|
ddbb09108c07f65b881cce78233e6b24d259ed9429586eadebf61db24b7f8fbd lib/tui/render.mjs
|
|
162
|
-
|
|
162
|
+
826d0290fa7ee6bf0bf9bcbd31f4cdb0a5b49f446208614ae518a36182f835b4 lib/tui/setup.mjs
|
|
163
163
|
072a0f04a8a3347a45603524dc49b9ec0dec8f4a001cf3be332e9b99dca6d6e1 lib/tui/terminal.mjs
|
|
164
164
|
74207b1d8116f4f32e1c4f37cd7fc9faa3a2e160b637e2226da538f147eb5629 lib/watch/anchor-store.mjs
|
|
165
165
|
4d6c292344fbc16f2961635d8264d6cb854f759a6a870c4345524e67138372d9 lib/watch/args.mjs
|
|
@@ -180,7 +180,7 @@ d8340e96f53e3c5615a9427934b3fc33d511c533b40d467b98add47273e3995c lib/watch/scop
|
|
|
180
180
|
26cdc499cbb78a3bb647c78b30f96c1ceeb5a49f6621cc70b51262be5d2f2f9c lib/watch/watcher.mjs
|
|
181
181
|
ff9c33c8b3c2bd466d54ffbe4c7139ccd87c79c7de34a6c4cde92e9f6e9b42d2 native/binding.c
|
|
182
182
|
205bedc1dee1a9ffa58124c6e21256a1f0cbe24f06f7c8d7cb0b99524cfab9d0 native/binding.gyp
|
|
183
|
-
|
|
183
|
+
4f385f1670c54fe06f6279aaa3a1a09f0c6630e568afdddd33d4228c2cbf2e48 package.json
|
|
184
184
|
208c65cfde244d39ce45c3cf1b0acb128f04d21199b6b3fb5466e62db5b64af9 prebuilds/darwin-arm64/arc_safe_fs.node
|
|
185
185
|
572887ac794d10a8b921d8168ea2328e31f05b45987611ff02c83114dba901af prebuilds/darwin-x64/arc_safe_fs.node
|
|
186
186
|
2bb9443021f9d873712b26321de733eddd6794c45f0bc79e2d5dc98669196635 prebuilds/index.json
|
|
@@ -12,7 +12,7 @@ import {assertPlanSnapshot,applyTransaction} from './transaction.mjs';
|
|
|
12
12
|
import {renderProfiles,resolveModelSettings} from '../models/index.mjs';
|
|
13
13
|
import {COOPERATIVE_RUNTIME_MODULES,cooperativeVersions} from '../runtime/bootstrap.mjs';
|
|
14
14
|
import {acquireRoleRoutingLock} from '../runtime/role-routing.mjs';
|
|
15
|
-
import {NON_TERMINAL_STATES,listLeases} from '../runtime/role-dispatch-store.mjs';
|
|
15
|
+
import {NON_TERMINAL_STATES,listLeases,readLease,writeLease} from '../runtime/role-dispatch-store.mjs';
|
|
16
16
|
import {ROUTING_ROLES,parseRoleRoutingConfig,serializeRoleRoutingConfig,validateRoleRoutingConfig} from '../runtime/role-routing-config.mjs';
|
|
17
17
|
|
|
18
18
|
const digest=bytes=>'sha256:'+crypto.createHash('sha256').update(bytes).digest('hex');
|
|
@@ -110,20 +110,47 @@ export function inspectCompositeRemoval({target,safeFs,activeConfigPath,snapshot
|
|
|
110
110
|
}catch{return {removals:[],residualPaths:existing};}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
const forceFinishableLease=lease=>lease.route==='native'&&NON_TERMINAL_STATES.includes(lease.state)||lease.route==='bridge'&&lease.state==='reserved';
|
|
114
|
+
const blockingDispatch=(home,lease)=>({home,dispatchId:lease.dispatchId,role:lease.role,workflowId:lease.workflowId,route:lease.route,state:lease.state,hostPlatform:lease.hostPlatform,updatedAt:lease.updatedAt,forceFinishable:forceFinishableLease(lease)});
|
|
115
|
+
|
|
116
|
+
/** Non-terminal bridge leases block composite changes; native leases only block anchor moves. */
|
|
114
117
|
async function assertNoActiveBridgeDispatch(codexHome,runtimePlatforms){
|
|
115
118
|
let leases;
|
|
116
119
|
try{leases=await listLeases(codexHome,{runtimePlatforms});}
|
|
117
120
|
catch(cause){const error=new TargetConfigurationError('Dispatch leases cannot be read; composite settings are not published',{cause});error.activation='held';error.activeDispatches=null;throw error;}
|
|
118
|
-
const
|
|
119
|
-
if(
|
|
121
|
+
const blocking=leases.filter(lease=>lease.route==='bridge'&&NON_TERMINAL_STATES.includes(lease.state)).map(lease=>blockingDispatch(codexHome,lease));
|
|
122
|
+
if(blocking.length){const error=new TargetConfigurationError('Active bridge dispatches block composite publication; finish or cancel them first');error.activation='held';error.activeDispatches=[...new Set(blocking.map(entry=>entry.dispatchId))];error.blockingDispatches=blocking;throw error;}
|
|
120
123
|
}
|
|
121
124
|
async function assertNoActiveMovingDispatches(homes,runtimePlatforms){
|
|
122
|
-
let
|
|
123
|
-
try{
|
|
125
|
+
let blocking;
|
|
126
|
+
try{blocking=(await Promise.all(homes.map(async home=>(await listLeases(home,{runtimePlatforms})).filter(lease=>NON_TERMINAL_STATES.includes(lease.state)).map(lease=>blockingDispatch(home,lease))))).flat();}
|
|
124
127
|
catch(cause){const error=new TargetConfigurationError('Dispatch leases cannot be read; composite settings are not published',{cause});error.activation='held';error.activeDispatches=null;throw error;}
|
|
125
|
-
const active=[...new Set(
|
|
126
|
-
if(active.length){const error=new TargetConfigurationError('Active dispatches block moving mixed routing; finish or cancel them first');error.activation='held';error.activeDispatches=active;throw error;}
|
|
128
|
+
const active=[...new Set(blocking.map(entry=>entry.dispatchId))];
|
|
129
|
+
if(active.length){const error=new TargetConfigurationError('Active dispatches block moving mixed routing; finish or cancel them first');error.activation='held';error.activeDispatches=active;error.blockingDispatches=blocking;throw error;}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export async function forceFinishDispatches({context,entries,now=Date.now(),acquireLock=acquireRoleRoutingLock}){
|
|
133
|
+
const homes=new Map(),releases=[],finished=[],skipped=[],residualPaths=[],{runtimePlatforms}=context;
|
|
134
|
+
let failure,failed=false;
|
|
135
|
+
for(const entry of entries){if(!homes.has(entry.home))homes.set(entry.home,[]);homes.get(entry.home).push(entry);}
|
|
136
|
+
try{
|
|
137
|
+
for(const home of homes.keys())releases.push({home,release:await acquireLock(home)});
|
|
138
|
+
for(const [home,entries]of homes)for(const entry of entries){
|
|
139
|
+
const lease=await readLease(home,entry.dispatchId,{runtimePlatforms});
|
|
140
|
+
if(!lease||!NON_TERMINAL_STATES.includes(lease.state)||lease.state!==entry.state||lease.updatedAt!==entry.updatedAt){skipped.push({dispatchId:entry.dispatchId,reason:'changed'});continue;}
|
|
141
|
+
if(!forceFinishableLease(lease)){skipped.push({dispatchId:entry.dispatchId,reason:'not_eligible'});continue;}
|
|
142
|
+
await writeLease(home,{...lease,state:'cancelled',claims:{...(lease.claims??{}),terminal:{level:'operator-attested',source:'installer-force-finish',observed:'cancelled'}},reasons:[]},{now,runtimePlatforms});
|
|
143
|
+
finished.push(entry.dispatchId);
|
|
144
|
+
}
|
|
145
|
+
}catch(error){failure=error;failed=true;}
|
|
146
|
+
for(const {home,release}of releases.reverse()){let released=false;try{released=await release();}catch{}if(!released)residualPaths.push(path.join(home,'arc-role-platform-routing.lock'));}
|
|
147
|
+
if(failed||residualPaths.length){
|
|
148
|
+
if(!failed)failure=new TargetConfigurationError('Dispatch lock ownership could not be verified');
|
|
149
|
+
else if(!failure||typeof failure!=='object')failure=new Error('Force finish failed',{cause:failure});
|
|
150
|
+
if(residualPaths.length){failure.residualPaths=[...new Set([...(Array.isArray(failure.residualPaths)?failure.residualPaths:[]),...residualPaths])];failure.lockReleaseFailed=true;}
|
|
151
|
+
failure.forceFinish={finished,skipped};throw failure;
|
|
152
|
+
}
|
|
153
|
+
return {finished,skipped,residualPaths};
|
|
127
154
|
}
|
|
128
155
|
// A joining anchor may not have an installation yet. Retain descriptors so a
|
|
129
156
|
// refused move can remove only the empty directories created for its locks.
|
|
@@ -17,7 +17,7 @@ import {loadModelConfig,serializeModelConfig} from '../models/index.mjs';
|
|
|
17
17
|
import {readModelFileVersion} from '../models/config.mjs';
|
|
18
18
|
import {buildRoleRoutingConfig} from '../runtime/role-routing-config.mjs';
|
|
19
19
|
import {loadStaticModelCatalog,assertCompositeCatalogRoles} from '../models/static-catalog.mjs';
|
|
20
|
-
import {prepareCompositeFiles,publishCompositeFiles,readCompositeRoutingConfig,prepareCompositeDeactivation,publishCompositeDeactivation} from '../installer/role-routing.mjs';
|
|
20
|
+
import {prepareCompositeFiles,publishCompositeFiles,readCompositeRoutingConfig,prepareCompositeDeactivation,publishCompositeDeactivation,forceFinishDispatches} from '../installer/role-routing.mjs';
|
|
21
21
|
import {inspectPath,sameObjectIdentity,TargetConfigurationError} from '../installer/targets.mjs';
|
|
22
22
|
import {assertPlanSnapshot} from '../installer/transaction.mjs';
|
|
23
23
|
import {acquireRoleRoutingLock} from '../runtime/role-routing.mjs';
|
|
@@ -115,6 +115,10 @@ export async function prepareCompositeOperation(context,options){
|
|
|
115
115
|
files.externalPaths.push(...externalPaths.filter(filename=>!files.modelWrites.some(write=>write.path===filename)));
|
|
116
116
|
return {kind:'composite',operation:options.kind,plans,files,config,options:{target:'composite'},...(warnings.length?{warnings}:{}),...(mode.legacyAnchor?{anchorMove:{from:mode.anchor,to:anchor}}:{}),summary:['Composite configuration will be published only after all participating targets are ready.','Per-role execution support is reported by routing-status.']};
|
|
117
117
|
}
|
|
118
|
+
export async function forceFinishBlockingDispatches(context,entries){
|
|
119
|
+
const eligible=entries.filter(entry=>entry.forceFinishable);
|
|
120
|
+
return eligible.length?forceFinishDispatches({context,entries:eligible}):{finished:[],skipped:[],residualPaths:[]};
|
|
121
|
+
}
|
|
118
122
|
export async function executeCompositeOperation(context,prepared){
|
|
119
123
|
const held={routeStatus:'held',supportStatus:'unverified',reason:'Per-role execution support is reported by routing-status.'};
|
|
120
124
|
let result={results:[],interrupted:false},installationHeld;
|
package/lib/tui/app.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {readFileSync} from 'node:fs';
|
|
2
2
|
import {createTerminalSession} from './terminal.mjs';
|
|
3
|
-
import {escapeTerminalText,navigationHint,statusSpans,platformStatusSpans,wrapDetailRow,wrapDetailRows,wordmarkRows,fitChoiceRow} from './render.mjs';
|
|
4
|
-
import {createManagementContext,prepareOperation,executeOperation,readCompositeConfig,currentInstallState} from '../management/operations.mjs';
|
|
3
|
+
import {escapeTerminalText,cellWidth,navigationHint,statusSpans,platformStatusSpans,wrapDetailRow,wrapDetailRows,wordmarkRows,fitChoiceRow} from './render.mjs';
|
|
4
|
+
import {createManagementContext,prepareOperation,executeOperation,forceFinishBlockingDispatches,readCompositeConfig,currentInstallState} from '../management/operations.mjs';
|
|
5
5
|
import {collectStatus} from '../management/status.mjs';
|
|
6
|
-
import {runInstallFlow,loadRoleDefaults} from './setup.mjs';
|
|
6
|
+
import {runInstallFlow,loadRoleDefaults,roleDisplayName} from './setup.mjs';
|
|
7
7
|
import {loadStaticModelCatalog} from '../models/static-catalog.mjs';
|
|
8
8
|
import {statusInfo} from './mode.mjs';
|
|
9
9
|
import {installerRegistryOf,platformLabel} from '../platforms/index.mjs';
|
|
@@ -53,16 +53,60 @@ export function resultRows(result,registry=installerRegistryOf(),{version}={}){
|
|
|
53
53
|
const removed=result.code===0&&['removed','absent'].includes(result.cli?.status);
|
|
54
54
|
return[...(result.messages??[]).map(s=>clean(s.trim())),...[result.stdout,result.stderr].flatMap(text=>text?text.trimEnd().split(/\r?\n/).map(clean):[]),...(result.results??[]).flatMap(item=>{const platform=item.platform??item.target?.platform??'Target';return[...(removed&&item.status==='uninstalled'?[]:[item.status==='installed'?`ARC${version==null?'':' '+version} installed for ${label(platform)}.`:item.status==='uninstalled'?`Removed from ${label(platform)}.`:`${platform}: ${item.status}`]),...(item.residualPaths??[]).map(p=>'Residual path: '+p),...(item.error?['Error: '+errorLine(item.error)]:[])];}),...(removed?[result.cli.status==='removed'?'Removed ARC and CLI.':'Removed ARC.']:result.cli?['CLI: '+result.cli.status,...(result.cli.error?['CLI error: '+errorLine(result.cli.error)]:[])]:[]),...(result.error?['Error: '+errorLine(result.error)]:[]),...(result.code!==0?['Exit code: '+result.code]:[]),...(result.exitSession?[result.cli?'CLI removal ended this session.':'CLI replacement ended this session.']:[])].filter(row=>{if(!row.startsWith('Residual path: '))return true;if(residualRows.has(row))return false;residualRows.add(row);return true;});
|
|
55
55
|
}
|
|
56
|
+
function formatElapsed(ms){
|
|
57
|
+
const minutes=Math.floor(ms/60000),hours=Math.floor(minutes/60),days=Math.floor(hours/24);
|
|
58
|
+
if(minutes<1)return '<1m';if(hours<1)return `${minutes}m`;if(days<1)return `${hours}h ${minutes%60}m`;return `${days}d ${hours%24}h`;
|
|
59
|
+
}
|
|
60
|
+
function blockingInfo(entries,now){
|
|
61
|
+
const liveBridge=entry=>entry.route==='bridge'&&!entry.forceFinishable,eligible=entries.filter(entry=>entry.forceFinishable).length;
|
|
62
|
+
const summary=`${entries.length} active ${entries.length===1?'dispatch blocks':'dispatches block'} this change. ${eligible?`${eligible} can be force finished.`:'None can be force finished here.'}`;
|
|
63
|
+
const table=[['ID','Role','Workflow','Route','State','Age'],...entries.map(entry=>[
|
|
64
|
+
entry.dispatchId.slice(0,8),roleDisplayName(entry.role),entry.workflowId,entry.route+(liveBridge(entry)?'*':''),entry.state,Number.isFinite(Date.parse(entry.updatedAt))?formatElapsed(now-Date.parse(entry.updatedAt)):'unknown'
|
|
65
|
+
])].map(row=>row.map(escapeTerminalText));
|
|
66
|
+
const width=text=>[...text].reduce((sum,character)=>sum+cellWidth(character),0),widths=table[0].map((_,index)=>Math.max(...table.map(row=>width(row[index]))));
|
|
67
|
+
const info=({columns})=>{
|
|
68
|
+
const available=Math.max(2,Math.floor(Number(columns)||80)-3),sizes=[...widths],overflow=sizes.reduce((sum,size)=>sum+size,10)-available;
|
|
69
|
+
if(overflow>0)sizes[2]=Math.max(8,sizes[2]-overflow);
|
|
70
|
+
const rows=table.map(row=>fitChoiceRow(row.map((value,index)=>{
|
|
71
|
+
const text=index===2?fitChoiceRow(value,sizes[index]+3):value;
|
|
72
|
+
return text+(index<row.length-1?' '.repeat(Math.max(0,sizes[index]-width(text))):'');
|
|
73
|
+
}).join(' '),columns));
|
|
74
|
+
return[summary,'',...rows];
|
|
75
|
+
};
|
|
76
|
+
const notice=[],commands=new Set();
|
|
77
|
+
for(const entry of entries.filter(liveBridge)){
|
|
78
|
+
const key=JSON.stringify([entry.home,entry.workflowId]);if(commands.has(key))continue;commands.add(key);
|
|
79
|
+
if(notice.length===0)notice.push('* Live bridge is not force finished. Cancel it first:');
|
|
80
|
+
notice.push(` node ${entry.home}/skills/arc/runtime/cli.mjs cancel --cwd <project> --workflow ${entry.workflowId} --input -`);
|
|
81
|
+
}
|
|
82
|
+
if(eligible)notice.push('Force finish marks the native/reserved entries cancelled. Native agents in other sessions are not stopped.');
|
|
83
|
+
return{info,infoTones:[undefined,undefined,undefined,...entries.map(entry=>liveBridge(entry)?'note':undefined)],notice};
|
|
84
|
+
}
|
|
56
85
|
export async function runTui(options={}){
|
|
57
86
|
let session=options.session,code=0,finalReport;const controller=new AbortController(),signals=options.signals??process;const abort=()=>controller.abort();signals.on('SIGINT',abort);signals.on('SIGTERM',abort);
|
|
58
|
-
try{session??=createTerminalSession(options);const ui=createTuiInterface(session,{input:options.input??process.stdin,controller}),api={collectStatus,prepareOperation,executeOperation,currentInstallState,...options.services},context=options.context?{...options.context,signal:controller.signal}:await createManagementContext({...options.contextOptions,signal:controller.signal});const registry=installerRegistryOf(context),draft={};let selected=0;
|
|
87
|
+
try{session??=createTerminalSession(options);const ui=createTuiInterface(session,{input:options.input??process.stdin,controller}),api={collectStatus,prepareOperation,executeOperation,forceFinishBlockingDispatches,currentInstallState,...options.services},context=options.context?{...options.context,signal:controller.signal}:await createManagementContext({...options.contextOptions,signal:controller.signal});const registry=installerRegistryOf(context),draft={};let selected=0,lastRequest;
|
|
88
|
+
function prepareRequest(request){lastRequest=request;return api.prepareOperation(context,request);}
|
|
59
89
|
async function loadInstallState(){
|
|
60
90
|
// A failed preview is unverified; prepareOperation still validates at Apply.
|
|
61
91
|
try{return typeof api.currentInstallState==='function'?await api.currentInstallState(context):{mode:'unverified',platforms:[]};}
|
|
62
92
|
catch{return {mode:'unverified',platforms:[]};}
|
|
63
93
|
}
|
|
64
|
-
async function execute(prepared){
|
|
94
|
+
async function execute(prepared,{retried=false,request}={}){
|
|
65
95
|
if(!prepared)return;const result=await ui.busy(()=>api.executeOperation(context,prepared));code=result.code;
|
|
96
|
+
if(code!==130&&!result.exitSession&&!retried&&['composite','switch'].includes(prepared.kind)&&result.error?.blockingDispatches?.length){
|
|
97
|
+
const entries=result.error.blockingDispatches,eligible=entries.some(entry=>entry.forceFinishable);
|
|
98
|
+
if(await ui.menu('Active dispatches',eligible?['Force finish and retry']:[],{backRow:true,selected:1,...blockingInfo(entries,Date.now())})===0){
|
|
99
|
+
const notRetried='Install / Update was not retried.';let finished;
|
|
100
|
+
try{finished=await ui.busy(()=>api.forceFinishBlockingDispatches(context,entries));}
|
|
101
|
+
catch(error){if(['ARC_CANCELLED','ARC_TUI_EOF','ARC_TUI_HOME'].includes(error.code))throw error;await ui.page('Force finish',[...(error.forceFinish?.finished??[]).map(id=>'Finished: '+id),error.message,...(error.residualPaths??[]).map(p=>'Residual path: '+p),notRetried]);return false;}
|
|
102
|
+
if(finished.skipped.length||finished.residualPaths.length){await ui.page('Force finish',[...finished.finished.map(id=>'Finished: '+id),...finished.skipped.map(s=>`Skipped: ${s.dispatchId} (${s.reason})`),...finished.residualPaths.map(p=>'Residual path: '+p),notRetried]);return false;}
|
|
103
|
+
if(!request){await ui.page('Force finish',['The original operation request is unavailable.',notRetried]);return false;}
|
|
104
|
+
let next;
|
|
105
|
+
try{next=await ui.busy(()=>api.prepareOperation(context,request));}
|
|
106
|
+
catch(error){if(['ARC_CANCELLED','ARC_TUI_EOF','ARC_TUI_HOME'].includes(error.code))throw error;await ui.page('Force finish',[error.message,notRetried]);return false;}
|
|
107
|
+
return execute(next,{retried:true,request});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
66
110
|
if(code===0&&['install','preset','switch','composite'].includes(prepared.kind))for(const key of Object.keys(draft))delete draft[key];
|
|
67
111
|
const rows=prepared.kind==='update'&&code===0?[`ARC updated: ${prepared.currentVersion} → ${prepared.latestVersion}.`]:resultRows(result,registry,{version:packageVersion});
|
|
68
112
|
if(code===130||result.exitSession){finalReport=rows;if(result.exitSession)session.render({title:'Result',rows:finalReport,hint:'Session ended'});return true;}
|
|
@@ -74,7 +118,7 @@ export async function runTui(options={}){
|
|
|
74
118
|
const single=choice<platforms.length,target=single?platforms[choice].runtime.id:'all';if(single&&!installed(target))continue;
|
|
75
119
|
const state=single?await loadInstallState():null,switching=single&&state.mode==='composite'&&state.platforms.includes(target);
|
|
76
120
|
const proceed=await ui.menu('Uninstall',['Remove'],{backRow:true,selected:1,info:[single?`Remove ARC from ${platformLabel(target,registry)}?`:'Remove ARC from all platforms and the arc CLI?',...(switching?['Mixed routing will be turned off.']:[])]});
|
|
77
|
-
if(proceed===0)return ui.busy(()=>
|
|
121
|
+
if(proceed===0)return ui.busy(()=>prepareRequest({kind:'uninstall',target,removeCli:!single,...(switching?{switchFromComposite:true}:{})}));
|
|
78
122
|
}
|
|
79
123
|
}
|
|
80
124
|
while(true){const statuses=await api.collectStatus(context),installState=await loadInstallState();
|
|
@@ -82,11 +126,11 @@ export async function runTui(options={}){
|
|
|
82
126
|
const action=home[choice]?.id;if(choice===null||action==='exit')return code;selected=choice;
|
|
83
127
|
try{
|
|
84
128
|
let prepared;
|
|
85
|
-
if(action==='install'){const currentConfig=installState.mode==='composite'?await (api.readCompositeConfig?api.readCompositeConfig(context):readCompositeConfig(context)):undefined;prepared=await runInstallFlow({ui,statuses,draft,installState,currentConfig,loadRoleDefaults:target=>loadRoleDefaults({context,statuses,target}),loadCatalog:target=>api.loadCatalog?api.loadCatalog(target):loadStaticModelCatalog(target,{signal:controller.signal}),prepare:settings=>ui.busy(()=>
|
|
129
|
+
if(action==='install'){const currentConfig=installState.mode==='composite'?await (api.readCompositeConfig?api.readCompositeConfig(context):readCompositeConfig(context)):undefined;prepared=await runInstallFlow({ui,statuses,draft,installState,currentConfig,loadRoleDefaults:target=>loadRoleDefaults({context,statuses,target}),loadCatalog:target=>api.loadCatalog?api.loadCatalog(target):loadStaticModelCatalog(target,{signal:controller.signal}),prepare:settings=>ui.busy(()=>prepareRequest(settings)),registry});}
|
|
86
130
|
else if(action==='status')await ui.menu('Status',[],{backRow:true,...statusInfo(installState,statuses,registry)});
|
|
87
|
-
else if(action==='version'){prepared=await ui.busy(()=>
|
|
131
|
+
else if(action==='version'){prepared=await ui.busy(()=>prepareRequest({kind:'update'}));const action=await ui.menu('Check Version',prepared.canUpgrade?['Upgrade']:[],{backRow:true,info:prepared.canUpgrade?[`${prepared.currentVersion} → ${prepared.latestVersion}`]:prepared.latestVersion!=null?[`Up to date (${prepared.currentVersion})`]:[`${prepared.currentVersion} (latest unavailable)`,...(prepared.latestError?[prepared.latestError.message.split(/[\r\n]/)[0]]:[])]});if(action!==0||!prepared.canUpgrade)prepared=null;}
|
|
88
132
|
else if(action==='uninstall')prepared=await uninstall(statuses);
|
|
89
|
-
if(await execute(prepared))return code;
|
|
133
|
+
if(await execute(prepared,{request:lastRequest}))return code;
|
|
90
134
|
}catch(error){if(error.code==='ARC_TUI_HOME')continue;if(['ARC_CANCELLED','ARC_TUI_EOF'].includes(error.code))throw error;code=error.code==='ARC_CLI_INPUT'?2:1;try{await ui.page('Operation unavailable',[error.message,...(error.residualPaths??[]).map(p=>'Residual path: '+p),'No changes were applied.']);}catch(navigation){if(navigation.code!=='ARC_TUI_HOME')throw navigation;}}
|
|
91
135
|
}
|
|
92
136
|
|
package/lib/tui/setup.mjs
CHANGED
|
@@ -22,6 +22,7 @@ export function loadRoleDefaults({context,statuses,target,readText=filename=>rea
|
|
|
22
22
|
}
|
|
23
23
|
const installSettingKeys=['language','maxTotalSubagents','maxConcurrentSubagents'];
|
|
24
24
|
const installRoleNames=['Scouter','Planner','Implementer','QA','Reviewer'];
|
|
25
|
+
export function roleDisplayName(role){return installRoleNames[ROLES.indexOf(role)]??role;}
|
|
25
26
|
|
|
26
27
|
export function installSettingsDraft(statuses,platforms){
|
|
27
28
|
const values=platforms.map(platform=>{
|