@yu_robotics/remote-cli 1.6.154 → 1.6.158

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 CHANGED
@@ -20,6 +20,8 @@ Router 1.6.117 and newer explicitly label standalone background-task notificatio
20
20
 
21
21
  ## Public Activity
22
22
 
23
+ From Router 1.6.158, completion pagination keeps the final body item (or complete worker group) with the completion note, optional model metadata and thread controls when they fit together. This avoids preventable footer-only continuations, including replies without model metadata. Indivisible oversized groups still split according to node, size and table limits; thread-button refreshes preserve the final body. This does not change streaming completion timing or the wire protocol.
24
+
23
25
  From CLI 1.6.153, Codex shell calls no longer lose their label when native command actions are absent or unknown. Native reads, searches, and directory listings remain preferred. Other calls use fixed operation labels such as `Run npm command` or `Run Git command` for simple allowlisted programs, and `Run shell command` for compound or unrecognized commands. These are deterministic operation labels, not model-authored purpose summaries: installed Codex 0.160.0 command items have no per-call description field. Arguments, full paths, output, and execution-wide reasoning are never copied into these fallback labels. Late native action metadata can enrich a pending row before its first result; repeated results retain one row. Existing description fields, heading limits, and card-node counts are unchanged; upgrade the CLI, with no new Router capability required.
24
26
 
25
27
  Router 1.6.145 combines each foreground tool call and its matching result into one collapsed row, retaining input, output, and diff previews. Independent calls, workers, and approvals remain separate. This uses the existing CLI protocol; the client does not need a new capability. See [Code Change Previews](../../README.md#code-change-previews).
@@ -189,6 +191,12 @@ CLI and Router 1.6.152 add standalone settings cards. `/backend` lists all eight
189
191
 
190
192
  From 1.6.154, numbered sections separate backend selection, scope and Confirm, or target backend, model/effort choices and secondary actions. Selected drafts and known preferences carry explicit checks; changing the target still never switches the coordinator. AGY model catalogs accept tab-delimited and formatted multi-space native rows, with exact IDs and explicit failures for empty, unusable or oversized responses. No inference or additional protocol capability is needed.
191
193
 
194
+ From Router 1.6.155, the selected backend application scope is highlighted in blue, and model/effort target selectors separate the main backend from other backends' worker preferences. Choices are shown together when the complete card fits its node and byte budgets; only oversized catalogs paginate, with headers, groups and pending/retry controls included. Viewing a target never changes the coordinator, and same-backend workers continue to share its per-thread preference. Existing CLI settings metadata is sufficient; no new capability or native request is required.
195
+
196
+ From CLI and Router 1.6.156, bare `/delegation` opens a thread-only On/Off card with a separate backend-availability section, gated by both `settingsCards` and `delegationCards`. Selection is confirmed only after cleanup and persistence succeed. Busy or queued work blocks toggles but not inspection/refresh; enabling does not bypass sandbox policy or prove authentication/quota. Parameterized toggles and `/delegation reset [backend]` remain text commands, and older peers retain the text menu.
197
+
198
+ Backend availability uses colored status badges: blue for the coordinator, green for installed workers, orange for blocked workers, red for unavailable backends and gray for unknown worker availability. Text labels and version or restriction details remain visible; these badges do not prove authentication or quota.
199
+
192
200
  ### Threads & Machines
193
201
 
194
202
  From CLI 1.6.121, new and existing threads without a saved preference enable
@@ -43,6 +43,7 @@ export declare class MessageHandler {
43
43
  private activityProgressSupported;
44
44
  private workerContextResetSupported;
45
45
  private settingsCardsSupported;
46
+ private delegationCardsSupported;
46
47
  private readonly settingsAdmission;
47
48
  private readonly settingsCatalogReader;
48
49
  private readonly settingsService;
@@ -186,6 +187,8 @@ export declare class MessageHandler {
186
187
  private settingsState;
187
188
  private settingsBusy;
188
189
  private settingsFallback;
190
+ /** Shared delegation cleanup/persistence for cards and parameterized text commands. */
191
+ private applyDelegationSetting;
189
192
  /** Shared native/persistent mutation for cards and parameterized text commands. */
190
193
  private applyPreference;
191
194
  private applyBackendSetting;
@@ -1 +1 @@
1
- {"version":3,"file":"MessageHandler.d.ts","sourceRoot":"","sources":["../../src/client/MessageHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMpD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAgK,MAAM,UAAU,CAAC;AACzM,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AA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@@ class MessageHandler {
117
117
  activityProgressSupported = false;
118
118
  workerContextResetSupported = false;
119
119
  settingsCardsSupported = false;
120
+ delegationCardsSupported = false;
120
121
  settingsAdmission = new SettingsAdmission_1.SettingsAdmission();
121
122
  settingsCatalogReader;
122
123
  settingsService;
@@ -135,7 +136,17 @@ class MessageHandler {
135
136
  this.settingsCatalogReader = new SettingsCatalog_1.SettingsCatalogReader(directoryGuard);
136
137
  this.settingsService = new SettingsService_1.SettingsService({
137
138
  state: id => this.settingsState(id),
138
- backends: async () => (await this.detectBackends()).map(entry => ({ ...entry, value: (0, config_1.backendKeyOf)(entry.id) })),
139
+ backends: async (id, kind) => {
140
+ if (kind !== 'delegation' || !id)
141
+ return (await this.detectBackends()).map(entry => ({ ...entry, value: (0, config_1.backendKeyOf)(entry.id) }));
142
+ const config = this.executorConfiguration();
143
+ const coordinator = this.threadPool.getBackendKey(id);
144
+ return (await this.delegation.registry.list(config)).map(item => {
145
+ const entry = (0, WorkerPolicy_1.workerAvailability)(config, this.directoryGuard, id, coordinator, item);
146
+ return { value: entry.backend, label: backendDisplayName(entry.backend), installed: entry.installed,
147
+ worker: entry.worker, version: entry.version, reason: entry.reason };
148
+ });
149
+ },
139
150
  catalog: async (id, target, kind) => {
140
151
  const thread = this.threadManager.getThread(id);
141
152
  if (!thread)
@@ -157,6 +168,8 @@ class MessageHandler {
157
168
  },
158
169
  backend: (id, target, scope, follow) => this.applyBackendSetting(id, target, scope, follow),
159
170
  preference: (id, target, kind, value) => this.applyPreference(id, target, kind, value),
171
+ delegation: (id, enabled) => this.applyDelegationSetting(id, enabled),
172
+ delegationSupported: id => Boolean(this.threadPool.getExecutor(id).configureDelegation),
160
173
  });
161
174
  this.wsClient.onClose?.(() => this.settingsService.invalidate());
162
175
  this.notificationAdapter = new hooks_1.FeishuNotificationAdapter(wsClient);
@@ -197,7 +210,7 @@ class MessageHandler {
197
210
  return;
198
211
  case 'settings_action':
199
212
  if (this.settingsCardsSupported) {
200
- const result = await this.settingsService.action(message);
213
+ const result = await this.settingsService.action(message, this.delegationCardsSupported);
201
214
  this.wsClient.send(result);
202
215
  }
203
216
  return;
@@ -242,6 +255,7 @@ class MessageHandler {
242
255
  this.delegationProgressSupported = data.capabilities?.delegationProgress === true;
243
256
  this.workerContextResetSupported = this.delegationProgressSupported && data.capabilities?.workerContextReset === true;
244
257
  this.settingsCardsSupported = data.capabilities?.settingsCards === true;
258
+ this.delegationCardsSupported = this.settingsCardsSupported && data.capabilities?.delegationCards === true;
245
259
  this.delegationProgressTextSupported = this.delegationProgressSupported
246
260
  && data.capabilities?.delegationProgressText === true;
247
261
  for (const pending of this.pendingApprovalCards.values()) {
@@ -343,7 +357,9 @@ class MessageHandler {
343
357
  });
344
358
  return;
345
359
  }
346
- if (this.settingsCardsSupported && openId && /^\/(?:backend|model|effort)$/.test(content?.trim() ?? '')) {
360
+ const settingsCommand = content?.trim() ?? '';
361
+ if (this.settingsCardsSupported && openId && (/^\/(?:backend|model|effort)$/.test(settingsCommand)
362
+ || (this.delegationCardsSupported && settingsCommand === '/delegation'))) {
347
363
  const kind = content.trim().slice(1);
348
364
  try {
349
365
  const menu = await this.settingsService.open(kind, resolvedThreadId, openId, undefined, messageId);
@@ -741,20 +757,11 @@ class MessageHandler {
741
757
  return true;
742
758
  }
743
759
  if (action) {
744
- if (action === 'off') {
745
- const thread = this.threadManager.getThread(threadId);
746
- const backend = this.threadPool.getBackendKey(threadId);
747
- // An implicit default does not imply that native tools were ever registered.
748
- if (thread.delegationBackends?.includes(backend) || (thread.delegation === true && !thread.delegationBackends)) {
749
- await executor.configureDelegation?.(undefined);
750
- // Preserve cleanup ownership across process recreation and backend switches.
751
- if (!thread.delegationBackends)
752
- await this.threadManager.updateThread(threadId, { delegationBackends: [backend] });
753
- }
754
- await this.delegationBridges.get(threadId)?.close();
755
- this.delegationBridges.delete(threadId);
760
+ const applied = await this.applyDelegationSetting(threadId, action === 'on');
761
+ if (!applied.success) {
762
+ this.sendResponse(messageId, threadId, applied);
763
+ return true;
756
764
  }
757
- await this.threadManager.updateThread(threadId, { delegation: action === 'on' });
758
765
  }
759
766
  const config = this.config.get('executor') ?? { type: 'auto' };
760
767
  const backends = await this.delegation.registry.list(config);
@@ -2523,7 +2530,8 @@ You can also use natural language commands to control Claude Code CLI.`,
2523
2530
  threads: result.threads,
2524
2531
  queueConfirmation: result.queueConfirmation,
2525
2532
  ...(result.executionMetadata ? { executionMetadata: result.executionMetadata } : {}),
2526
- ...(this.settingsCardsSupported && result.settingsMenu ? { settingsMenu: result.settingsMenu } : {}),
2533
+ ...(this.settingsCardsSupported && result.settingsMenu
2534
+ && (result.settingsMenu.kind !== 'delegation' || this.delegationCardsSupported) ? { settingsMenu: result.settingsMenu } : {}),
2527
2535
  cwd,
2528
2536
  timestamp: Date.now(),
2529
2537
  });
@@ -2543,13 +2551,13 @@ You can also use natural language commands to control Claude Code CLI.`,
2543
2551
  return undefined;
2544
2552
  const projection = (entry) => ({ id: entry.id, backend: entry.backend,
2545
2553
  cwd: entry.workingDirectory, generation: entry.delegationWorkspaceGeneration, model: entry.model,
2546
- models: entry.models, efforts: entry.efforts });
2554
+ models: entry.models, efforts: entry.efforts, delegation: entry.delegation, delegationBackends: entry.delegationBackends });
2547
2555
  const all = this.threadManager.listThreads().map(projection).sort((a, b) => a.id.localeCompare(b.id));
2548
2556
  const configuredModels = { ...thread.models };
2549
2557
  if (configuredModels.claude === undefined && thread.model)
2550
2558
  configuredModels.claude = thread.model;
2551
2559
  return { threadId, threadName: thread.name, coordinatorBackend: this.threadPool.getBackendKey(threadId),
2552
- followsGlobal: !thread.backend, configuredModels, configuredEfforts: { ...thread.efforts },
2560
+ followsGlobal: !thread.backend, configuredModels, configuredEfforts: { ...thread.efforts }, delegationEnabled: (0, DelegationSettings_1.isDelegationEnabled)(thread),
2553
2561
  revision: (0, crypto_1.createHash)('sha256').update(JSON.stringify({ thread: projection(thread), all, config: this.executorConfiguration() })).digest('hex') };
2554
2562
  }
2555
2563
  settingsBusy(threadId, exceptRequest, includeQueue = true) {
@@ -2558,7 +2566,7 @@ You can also use natural language commands to control Claude Code CLI.`,
2558
2566
  || this.settingsAdmission.hasCommand(threadId, exceptRequest) || (includeQueue && this.hasThreadQueueState(threadId));
2559
2567
  }
2560
2568
  settingsFallback(menu) {
2561
- const lines = [`${menu.kind === 'backend' ? 'Backend' : menu.kind === 'model' ? 'Model' : 'Reasoning effort'} settings`,
2569
+ const lines = [`${menu.kind === 'backend' ? 'Backend' : menu.kind === 'model' ? 'Model' : menu.kind === 'delegation' ? 'Delegation' : 'Reasoning effort'} settings`,
2562
2570
  `Thread: ${menu.threadName}`, `Target backend: ${menu.targetBackend}`,
2563
2571
  `Configured: ${menu.configuredValue ?? 'default'}`, `Effective: ${menu.effectiveValue ?? 'not reported'} (${menu.effectiveSource})`];
2564
2572
  if (menu.unavailableReason)
@@ -2567,10 +2575,40 @@ You can also use natural language commands to control Claude Code CLI.`,
2567
2575
  lines.push(`${choice.label}${choice.disabled ? ' (unavailable)' : ''}`);
2568
2576
  if (menu.kind === 'backend')
2569
2577
  lines.push('Card scope defaults to Current thread. Confirm to apply. Text commands: /backend <index> @ (current), /backend <index> (all).');
2578
+ else if (menu.kind === 'delegation')
2579
+ lines.push('Applies only to this thread. Text commands: /delegation on or /delegation off.');
2570
2580
  else
2571
2581
  lines.push(`Use the card buttons, or /${menu.kind} <value> for the active backend.`);
2572
2582
  return lines.join('\n');
2573
2583
  }
2584
+ /** Shared delegation cleanup/persistence for cards and parameterized text commands. */
2585
+ async applyDelegationSetting(threadId, enabled) {
2586
+ const thread = this.threadManager.getThread(threadId);
2587
+ if (!thread)
2588
+ return { success: false, error: 'This thread no longer exists.' };
2589
+ const executor = this.threadPool.getExecutor(threadId);
2590
+ if (enabled && !executor.configureDelegation)
2591
+ return { success: false, error: 'This executor does not support delegation tool registration.' };
2592
+ try {
2593
+ if (!enabled) {
2594
+ const backend = this.threadPool.getBackendKey(threadId);
2595
+ // An inherited enabled default does not mean tools were registered.
2596
+ if (thread.delegationBackends?.includes(backend) || (thread.delegation === true && !thread.delegationBackends)) {
2597
+ await executor.configureDelegation?.(undefined);
2598
+ // Keep ownership so inactive backends are cleaned when next resumed.
2599
+ if (!thread.delegationBackends)
2600
+ await this.threadManager.updateThread(threadId, { delegationBackends: [backend] });
2601
+ }
2602
+ await this.delegationBridges.get(threadId)?.close();
2603
+ this.delegationBridges.delete(threadId);
2604
+ }
2605
+ await this.threadManager.updateThread(threadId, { delegation: enabled });
2606
+ return { success: true, output: `Delegation ${enabled ? 'enabled' : 'disabled'} for this thread.` };
2607
+ }
2608
+ finally {
2609
+ this.settingsService.invalidate(threadId);
2610
+ }
2611
+ }
2574
2612
  /** Shared native/persistent mutation for cards and parameterized text commands. */
2575
2613
  async applyPreference(threadId, backend, kind, value, onStream) {
2576
2614
  const thread = this.threadManager.getThread(threadId);