@volter/supercode-teams 0.2.50 → 0.2.52
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/bin/workspace.mjs +4 -2
- package/connector/index.mjs +13 -5
- package/package.json +1 -1
- package/popup-terminals.mjs +3 -1
package/bin/workspace.mjs
CHANGED
|
@@ -724,11 +724,13 @@ async function connectorCommand(verb, { flags, rest, output, client, context, te
|
|
|
724
724
|
// answers one request at a time, and a long load would hold discovery and every other capture behind it.
|
|
725
725
|
const largeCore = new SupercodeHarnessClient({ command: binary, args: ['harness', 'serve'] });
|
|
726
726
|
const slowCore = new SupercodeHarnessClient({ command: binary, args: ['harness', 'serve'] });
|
|
727
|
-
|
|
727
|
+
// Followed (live) sessions follow and load through one of their own, so a watched session never waits behind a pass.
|
|
728
|
+
const liveCore = new SupercodeHarnessClient({ command: binary, args: ['harness', 'serve'] });
|
|
729
|
+
const connector = new TeamsConnector({ server: context.origin, teamId: context.team_id, machineId: saved.machine.id, sourceId: saved.source.id, credential: saved.credential.token, stateDir: state.directory, core, largeCore, slowCore, liveCore, hostKeyId });
|
|
728
730
|
// A connected machine is a person's: each pane it launches opens a window on its screen (SUPERCODE_POPUPS=0: none).
|
|
729
731
|
const machine = new TeamsMachine({ home: daemonHome, supercode: binary, popups: process.env.SUPERCODE_POPUPS !== '0', ...(flags.tmux_socket ? { tmuxSocket: String(flags.tmux_socket) } : {}), link: { server: context.origin, teamId: context.team_id, machineId: saved.machine.id, credential: saved.credential.token, incarnationId: connector.state.incarnation_id, configuration: () => connector.configuration() }, onTurn: (turn) => connector.noteTurn(turn) });
|
|
730
732
|
machine.on('link', (event) => { if (event.event === 'replaced') process.stderr.write(`supercode teams: ${event.error}. Two connectors were running for this machine; stop one of them (\`supercode teams disconnect\` where it should not run).\n`); });
|
|
731
|
-
const stopAll = async () => { await machine.stop().catch(() => {}); await connector.stop(); await core.close(); await largeCore.close(); await slowCore.close(); await lifecycle.close(); state.update(current => current ? ({ ...current, process: undefined }) : null); };
|
|
733
|
+
const stopAll = async () => { await machine.stop().catch(() => {}); await connector.stop(); await core.close(); await largeCore.close(); await slowCore.close(); await liveCore.close(); await lifecycle.close(); state.update(current => current ? ({ ...current, process: undefined }) : null); };
|
|
732
734
|
try { await connector.start({ roots: () => saved.roots }); await machine.start(); } catch (error) { await stopAll(); throw error; }
|
|
733
735
|
output({ version: 1, context: scope(context), data: { machine: saved.machine, source: saved.source, roots: saved.roots.map(({ path: _path, ...item }) => item), socket: machine.socketPath, foreground: true } });
|
|
734
736
|
await new Promise(resolveStop => { let stopped = false; stopConnector = async () => { if (stopped) return; stopped = true; await stopAll(); resolveStop(); }; for (const signal of ['SIGINT', 'SIGTERM', ...(process.platform === 'win32' ? ['SIGHUP', 'SIGBREAK'] : [])]) process.once(signal, stopConnector); });
|
package/connector/index.mjs
CHANGED
|
@@ -88,7 +88,7 @@ function atomic(path, value) {
|
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
export class TeamsConnector {
|
|
91
|
-
constructor({server,teamId,machineId,sourceId,credential,stateDir,core,largeCore=core,slowCore=largeCore,hostKeyId=null,effectExecutor=null,clock={nowMs:()=>Date.now()},fetch:fetchImpl=globalThis.fetch,heartbeatMs=15000,nativeIdleMs=NATIVE_IDLE_MS,nativeIdleBytes=NATIVE_IDLE_BYTES}){Object.assign(this,{server:serverOrigin(server),teamId,machineId,sourceId,credential,stateDir,core,largeCore,slowCore,hostKeyId,effectExecutor,clock,fetch:fetchImpl,heartbeatMs,nativeIdleMs,nativeIdleBytes});mkdirSync(stateDir,{recursive:true,mode:0o700});chmodSync(stateDir,0o700);this.statePath=join(stateDir,'connector.json');this.state=existsSync(this.statePath)?JSON.parse(readFileSync(this.statePath,'utf8')):{version:1,sequence:0,origins:{},outbox:[]};this.state.effects??={};if(Array.isArray(this.state.sync_status?.problems))this.state.sync_status.problems=this.state.sync_status.problems.filter(item=>item?.code!==CAPACITY_CODE);this.state.native_cache??={};this.state.incarnation_id=`inc_${randomBytes(16).toString('hex')}`;this.abort=new AbortController();this.work=Promise.resolve();this.nativeEffects=new NativeEffects(this);this.effects=new EffectConsumer(this,effectExecutor?{prepare:async effect=>({execute:()=>effectExecutor(effect,{core:this.core,signal:this.abort.signal})})}:this.nativeEffects);this.save();}
|
|
91
|
+
constructor({server,teamId,machineId,sourceId,credential,stateDir,core,largeCore=core,slowCore=largeCore,liveCore=core,hostKeyId=null,effectExecutor=null,clock={nowMs:()=>Date.now()},fetch:fetchImpl=globalThis.fetch,heartbeatMs=15000,nativeIdleMs=NATIVE_IDLE_MS,nativeIdleBytes=NATIVE_IDLE_BYTES}){Object.assign(this,{server:serverOrigin(server),teamId,machineId,sourceId,credential,stateDir,core,largeCore,slowCore,liveCore,hostKeyId,effectExecutor,clock,fetch:fetchImpl,heartbeatMs,nativeIdleMs,nativeIdleBytes});mkdirSync(stateDir,{recursive:true,mode:0o700});chmodSync(stateDir,0o700);this.statePath=join(stateDir,'connector.json');this.state=existsSync(this.statePath)?JSON.parse(readFileSync(this.statePath,'utf8')):{version:1,sequence:0,origins:{},outbox:[]};this.state.effects??={};if(Array.isArray(this.state.sync_status?.problems))this.state.sync_status.problems=this.state.sync_status.problems.filter(item=>item?.code!==CAPACITY_CODE);this.state.native_cache??={};this.state.incarnation_id=`inc_${randomBytes(16).toString('hex')}`;this.abort=new AbortController();this.work=Promise.resolve();this.nativeEffects=new NativeEffects(this);this.effects=new EffectConsumer(this,effectExecutor?{prepare:async effect=>({execute:()=>effectExecutor(effect,{core:this.core,signal:this.abort.signal})})}:this.nativeEffects);this.save();}
|
|
92
92
|
save(){atomic(this.statePath,this.state);}
|
|
93
93
|
// What `supercode teams status` shows about this connector: its last error, and the sessions it could not capture
|
|
94
94
|
// (most recent first, bounded; an entry clears when that session next captures). They are kept in connector.json,
|
|
@@ -291,9 +291,9 @@ export class TeamsConnector {
|
|
|
291
291
|
follow(key,options){
|
|
292
292
|
const {locator}=options,controller=new AbortController(),stop=()=>controller.abort(this.abort.signal.reason);this.abort.signal.addEventListener('abort',stop,{once:true});
|
|
293
293
|
// A follow event may land between beats, after the rule changed: it reads the configuration afresh.
|
|
294
|
-
const followed={...options,configuration:null,stamp:undefined};
|
|
294
|
+
const followed={...options,configuration:null,stamp:undefined,live:true};
|
|
295
295
|
const task=(async()=>{
|
|
296
|
-
for await(const _event of this.
|
|
296
|
+
for await(const _event of this.liveCore.session(locator).follow({signal:controller.signal})){
|
|
297
297
|
if(controller.signal.aborted)break;
|
|
298
298
|
// A capture that fails is that session's problem, as on a beat; the follow goes on.
|
|
299
299
|
try{await this.capture(followed);}catch(error){if(controller.signal.aborted)break;if(connectionError(error))this.lastError=error;else this.noteSessionProblem(followed,error);}
|
|
@@ -403,8 +403,16 @@ export class TeamsConnector {
|
|
|
403
403
|
if(origin&&ruleId&&stamp)origin.capture_stamps={...origin.capture_stamps,[ruleId]:{stamp,rule_revision:ruleRevision,backfill_mode:backfillMode}};
|
|
404
404
|
this.save();
|
|
405
405
|
}
|
|
406
|
-
capture
|
|
407
|
-
|
|
406
|
+
// Every load happens before the capture joins the serial queue, which then holds only the quick compare and
|
|
407
|
+
// upload; a followed (live) session loads through a harness process of its own, so a watched session's new turn
|
|
408
|
+
// never waits behind a pass's loads.
|
|
409
|
+
async capture(options) {
|
|
410
|
+
if(!options.preloaded&&this.largeSession(options))return this.captureLarge(options);
|
|
411
|
+
if(!options.preloaded){
|
|
412
|
+
const {locator}=options,path=locator?.storage?.kind==='file'&&existsSync(locator.storage.path)?realpathSync(locator.storage.path):null;
|
|
413
|
+
const artifactBefore=path?statSync(path):null;
|
|
414
|
+
options={...options,preloaded:{loaded:await (options.live?this.liveCore:this.core).session(locator).load(),artifactBefore}};
|
|
415
|
+
}
|
|
408
416
|
const work=this.work.then(()=>this.captureSerial(options)).then(receipt=>{this.clearSessionProblem(options.harness,options.nativeSessionId);return receipt;});
|
|
409
417
|
this.work=work.catch(()=>{});
|
|
410
418
|
return work;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/supercode-teams",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A machine daemon serving this machine's doors, and a local or remote Teams server for shared session discovery, OpenTelemetry ingestion and access to enrolled machines.",
|
|
6
6
|
"license": "MIT",
|
package/popup-terminals.mjs
CHANGED
|
@@ -38,9 +38,11 @@ const ADAPTERS = {
|
|
|
38
38
|
{ name: 'terminal', find: () => firstPath('/System/Applications/Utilities/Terminal.app', '/Applications/Utilities/Terminal.app'), launch: (p, argv) => ['open', ['-a', p, selfDeletingScript(argv, '.command')]] },
|
|
39
39
|
],
|
|
40
40
|
win32: [
|
|
41
|
+
// Windows Terminal first: its window opens in front of the others, where one started by a background process
|
|
42
|
+
// (the daemon is one) opens behind them; WezTerm started that way never painted its window (volter-desktop).
|
|
43
|
+
{ name: 'windows-terminal', find: () => onPath('wt') ?? firstPath(join(localApps, 'Microsoft', 'WindowsApps', 'wt.exe')), launch: (p, argv) => [p, ['-w', 'new', 'new-tab', '--', ...argv]] },
|
|
41
44
|
{ name: 'wezterm', find: () => onPath('wezterm') ?? firstPath(join(programFiles, 'WezTerm', 'wezterm.exe')), launch: (p, argv) => [p, ['start', '--always-new-process', '--', ...argv]] },
|
|
42
45
|
{ name: 'alacritty', find: () => onPath('alacritty') ?? firstPath(join(programFiles, 'Alacritty', 'alacritty.exe')), launch: (p, argv) => [p, ['-e', ...argv]] },
|
|
43
|
-
{ name: 'windows-terminal', find: () => onPath('wt') ?? firstPath(join(localApps, 'Microsoft', 'WindowsApps', 'wt.exe')), launch: (p, argv) => [p, ['-w', 'new', 'new-tab', '--', ...argv]] },
|
|
44
46
|
// A console window of its own, on every Windows: it lives exactly as long as its command.
|
|
45
47
|
{ name: 'conhost', find: () => firstPath(join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'conhost.exe')), launch: (p, argv) => [p, argv] },
|
|
46
48
|
],
|