@floless/app 0.115.0 → 0.117.0

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/dist/web/app.css CHANGED
@@ -277,8 +277,6 @@
277
277
  }
278
278
  .host-line { color: var(--text-muted); }
279
279
  .host-line.host-ok { color: var(--ok); }
280
- .host-line.host-dim { color: var(--text-dim); }
281
- .host-dim { color: var(--text-dim); }
282
280
 
283
281
  .messages {
284
282
  flex: 1;
@@ -2039,6 +2037,23 @@
2039
2037
  .import-failed-remedy-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-muted); margin-bottom: 6px; }
2040
2038
  .import-failed-cmd-row { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 6px; padding: 8px 8px 8px 12px; margin-bottom: 6px; }
2041
2039
  .import-failed-cmd-row:last-child { margin-bottom: 0; }
2040
+ /* #366 — the in-app verb beneath the copyable command. Two lines rather than three controls on one,
2041
+ so a long agent id still reads. The button reuses .lib-update (the Agent Library's own Update) —
2042
+ same verb, same treatment, nothing new to learn. */
2043
+ .import-failed-agent { margin-bottom: 10px; }
2044
+ .import-failed-agent:last-child { margin-bottom: 0; }
2045
+ .import-failed-act { display: flex; align-items: baseline; gap: 10px; margin: 5px 0 0 12px; flex-wrap: wrap; }
2046
+ .import-failed-agent-status { font-size: 11px; color: var(--text-dim); }
2047
+ .import-failed-agent-status.is-updated { color: var(--ok); }
2048
+ .import-failed-agent-status.is-error { color: var(--err); }
2049
+ /* "Nothing to update" is the ANSWER, not a success and not a failure — deliberately calmer than
2050
+ both, so it cannot read as either. Muted, no glyph. */
2051
+ .import-failed-agent-status.is-current { color: var(--text-muted); }
2052
+ .import-failed-retry { margin: 12px 0 0; font-size: 11.5px; color: var(--text-muted); }
2053
+ .import-failed-retry-go { font: inherit; color: var(--accent-bright); background: none; border: 0;
2054
+ padding: 0; cursor: pointer; text-decoration: underline; }
2055
+ .import-failed-retry-go:hover { color: var(--text); }
2056
+ .import-failed-retry-go:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
2042
2057
  .import-failed-cmd { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; color: var(--accent-bright); overflow-x: auto; white-space: pre; user-select: all;
2043
2058
  scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
2044
2059
  .import-failed-cmd::-webkit-scrollbar { height: 7px; }
@@ -2154,8 +2169,6 @@
2154
2169
  .wf-act.act-edit:hover { color: var(--accent); background: var(--accent-soft); }
2155
2170
  .wf-act.act-dup:hover { color: var(--text); border-color: var(--border-strong); }
2156
2171
  .wf-act.act-del:hover { color: var(--err); background: rgba(248, 113, 113, 0.1); border-color: var(--err); }
2157
- /* Archive is non-destructive/recoverable (unlike Delete) — warn tint, not err. */
2158
- .wf-act.act-archive:hover { color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); border-color: var(--warn); }
2159
2172
  .wf-empty-search { color: var(--text-dim); font-style: italic; font-size: 12px; padding: 16px 10px; text-align: center; }
2160
2173
  .wf-empty-search[hidden] { display: none; }
2161
2174
 
@@ -2339,7 +2352,6 @@
2339
2352
  padding: 1px 5px;
2340
2353
  border-radius: 3px;
2341
2354
  }
2342
- .menu-arrow { color: var(--text-dim); font-size: 14px; }
2343
2355
  .menu-divider {
2344
2356
  height: 1px;
2345
2357
  background: var(--border);
@@ -4161,6 +4173,30 @@ table.hist tr.current td { background:var(--accent-soft); }
4161
4173
  .rev-row-title { font-size:12.5px; font-weight:600; color:var(--text); font-family:var(--mono); overflow-wrap:anywhere; }
4162
4174
  .rev-row-sub { font-size:11px; color:var(--text-dim); margin-top:3px; }
4163
4175
  .rev-row-note { font-size:11px; color:var(--text-dim); font-style:italic; margin-top:4px; }
4176
+ /* Fan-out disclosure on a collapsed decision row (#493). One row can stand for hundreds of identical
4177
+ decisions, so the individual items are offered as evidence rather than asked to be trusted — closed
4178
+ by default, because auto-opening 230 items would bury the sibling rows the user must also see.
4179
+ The list is CAPPED and therefore a scroll container: at 230 items an uncapped block pushes the other
4180
+ decisions far off screen whenever it is opened. A cap means a scrollbar, and a scrollbar here must be
4181
+ themed in the same pass — a native white bar against the dark theme is exactly what the standing
4182
+ rule exists to stop. Reuses .ws-archived-summary's caret rotation idiom rather than a new one. */
4183
+ /* What ticking the row actually covers — stated visibly, not only in the accessible name. */
4184
+ .mig-fanout-scope { margin-top:5px; font-size:11px; color:var(--text-muted); }
4185
+ .mig-fanout { margin-top:7px; }
4186
+ .mig-fanout-summary { list-style:none; cursor:pointer; font-size:11px; color:var(--text-dim);
4187
+ display:flex; align-items:center; gap:5px; user-select:none; }
4188
+ .mig-fanout-summary::-webkit-details-marker { display:none; }
4189
+ .mig-fanout-summary:hover { color:var(--text-muted); }
4190
+ .mig-fanout-summary:focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:3px; }
4191
+ .mig-fanout[open] > .mig-fanout-summary .ws-archived-caret { transform:rotate(90deg); }
4192
+ .mig-fanout-list { margin-top:6px; max-height:172px; overflow-y:auto; display:flex; flex-direction:column;
4193
+ gap:2px; padding:6px 8px; border:1px solid var(--border); border-radius:5px; background:var(--surface-2);
4194
+ scrollbar-width:thin; scrollbar-color:var(--border-strong) transparent; }
4195
+ .mig-fanout-list::-webkit-scrollbar { width:9px; }
4196
+ .mig-fanout-list::-webkit-scrollbar-thumb { background:var(--border-strong); border-radius:5px; }
4197
+ .mig-fanout-list::-webkit-scrollbar-track { background:transparent; }
4198
+ .mig-fanout-item { font:500 11px/1.5 var(--mono); color:var(--text-muted); overflow-wrap:anywhere; }
4199
+
4164
4200
  .rev-fields { margin:6px 0 0; display:flex; flex-direction:column; gap:3px; }
4165
4201
  .rev-field { font-size:11.5px; color:var(--text-muted); overflow-wrap:anywhere; }
4166
4202
  .rev-field-key { font-family:var(--mono); color:var(--text-dim); margin-right:6px; }
@@ -4453,6 +4489,17 @@ tr.hist-diff-row[hidden] { display:none; }
4453
4489
  .kb-organize[aria-disabled="true"] { opacity:.6; cursor:default; background:var(--surface-2);
4454
4490
  border-color:var(--border-strong); color:var(--text-muted); box-shadow:none; }
4455
4491
  .kb-organize[aria-disabled="true"]:hover { background:var(--surface-2); border-color:var(--border-strong); box-shadow:none; }
4492
+ /* The header ✓ Approve when the project has no model to approve (#490). `aria-disabled` and not
4493
+ `disabled`, for the reason .kb-organize and .ecard .e-act already record — a disabled button is
4494
+ unhoverable and unfocusable, so the data-tip explaining WHY would never reach the person who needs
4495
+ it, and approveProject re-checks the state itself. THIS RULE IS THE OTHER HALF OF THAT BARGAIN:
4496
+ without it `aria-disabled` renders as nothing, a sighted user sees an ordinary live button and only
4497
+ a screen-reader user is told it is unavailable — which is the same "offering an action there is
4498
+ nothing to perform" the fix is about, just moved. Found by review, after shipping the attribute
4499
+ alone and citing three precedents that all ship a matching visual rule. */
4500
+ #ws-approve[aria-disabled="true"] { opacity:.6; cursor:default; background:var(--surface-2);
4501
+ border-color:var(--border-strong); color:var(--text-muted); box-shadow:none; }
4502
+ #ws-approve[aria-disabled="true"]:hover { background:var(--surface-2); border-color:var(--border-strong); box-shadow:none; }
4456
4503
  .kb-organize:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
4457
4504
  /* Stage D — Adjust: steer the compiled wiki in plain English. A collapsed disclosure below Organize
4458
4505
  (only once a wiki exists), same idiom as .ws-archived. The submit is class="primary kb-adjust-submit"
package/dist/web/aware.js CHANGED
@@ -4277,6 +4277,12 @@
4277
4277
  function closeImportFailedModal() {
4278
4278
  hideModal($importFailedModal);
4279
4279
  dropImportFailedEsc();
4280
+ _importFailedFile = null; // don't hold a File handle past the dialog it belongs to
4281
+ _importFailedTouched = new Set();
4282
+ // AND the in-flight map. Leaving it populated meant a result for an update started in THIS dialog
4283
+ // could land after a DIFFERENT import had failed and opened a new one — writing its outcome into
4284
+ // the new dialog's rows and offering to retry an unrelated file.
4285
+ _importFailedVersions.clear();
4280
4286
  // Import has no single stable trigger (a menu item that has already closed, an OS file drop with
4281
4287
  // no DOM node, a hidden input), so fall back to the menu button rather than pretend otherwise.
4282
4288
  // <body> counts as no target: it is what activeElement reports when nothing is focused, and
@@ -4292,6 +4298,12 @@
4292
4298
  // stderr, and there is no reason to route it through a string template at all.
4293
4299
  function importFailedCmdRow(agent) {
4294
4300
  const cmd = `aware agent update ${agent}`;
4301
+ // TWO LINES, not three controls crammed onto one. The command line is left exactly as it was —
4302
+ // zero risk to what already works, and it stays readable when an agent id is long.
4303
+ const wrap = document.createElement('div');
4304
+ wrap.className = 'import-failed-agent';
4305
+ wrap.dataset.agent = agent;
4306
+
4295
4307
  const row = document.createElement('div');
4296
4308
  row.className = 'import-failed-cmd-row';
4297
4309
  const code = document.createElement('code');
@@ -4304,10 +4316,79 @@
4304
4316
  copy.dataset.tip = 'Copy this command';
4305
4317
  copy.textContent = '⎘ Copy';
4306
4318
  row.append(code, copy);
4307
- return row;
4319
+
4320
+ // The in-app verb. Same class and glyph as the Agent Library's own Update button, because it IS
4321
+ // the same verb (`updateAgent` → POST /api/agents/update) — a second visual treatment for one
4322
+ // action would just be a second thing to learn. Copy stays as the secondary: someone who prefers
4323
+ // to run it in their own terminal session should not lose that, which is this app's whole premise.
4324
+ const act = document.createElement('div');
4325
+ act.className = 'import-failed-act';
4326
+ const upd = document.createElement('button');
4327
+ upd.type = 'button';
4328
+ upd.className = 'lib-update';
4329
+ upd.dataset.agentUpdate = agent;
4330
+ upd.dataset.tip = `Update ${agent} right here — no need to leave FloLess`;
4331
+ upd.textContent = '↑ Update it now';
4332
+ const status = document.createElement('span');
4333
+ status.className = 'import-failed-agent-status';
4334
+ status.dataset.agentStatus = agent;
4335
+ act.append(upd, status);
4336
+
4337
+ wrap.append(row, act);
4338
+ return wrap;
4339
+ }
4340
+
4341
+ /**
4342
+ * Report one agent's update outcome in the import-failure dialog.
4343
+ *
4344
+ * THREE outcomes, and the third is the one the copy has to get right. `aware agent update` re-pulls
4345
+ * the latest REGISTRY version of an already-installed agent — it cannot conjure a build upstream has
4346
+ * never made. So "nothing to update" is neither success nor failure, it is the ANSWER: this agent has
4347
+ * not been released as runnable yet. It gets the calmest treatment of the three (muted, no glyph)
4348
+ * precisely so it does not read as either.
4349
+ */
4350
+ function importFailedAgentStatus(agent, state, detail) {
4351
+ if (!$importFailedModal) return;
4352
+ const el = $importFailedModal.querySelector(`[data-agent-status="${CSS.escape(agent)}"]`);
4353
+ if (!el) return;
4354
+ el.className = `import-failed-agent-status is-${state}`;
4355
+ el.textContent = state === 'updated' ? `✓ Updated to v${detail}`
4356
+ : state === 'current' ? 'Nothing to update — already the latest version. This agent hasn’t been released as runnable yet.'
4357
+ // We captured no "before" version, so we cannot honestly claim a change happened. Report what
4358
+ // AWARE now has and say nothing we do not know.
4359
+ : state === 'done' ? `AWARE finished — it reports v${detail || '?'} installed.`
4360
+ : state === 'busy' ? 'Updating… this can take a minute or two'
4361
+ : `Couldn’t update — ${String(detail || '').slice(0, 90)}`;
4362
+
4363
+ // EVERY TERMINAL STATE releases the button. Setting only the text left `aria-busy="true"` and
4364
+ // `disabled` in place forever, so assistive tech kept announcing "busy" on a finished row and the
4365
+ // user could not try again after a failure.
4366
+ const btn = $importFailedModal.querySelector(`[data-agent-update="${CSS.escape(agent)}"]`);
4367
+ if (btn && state !== 'busy') {
4368
+ btn.removeAttribute('aria-busy');
4369
+ btn.disabled = false;
4370
+ if (state === 'error') btn.textContent = '↻ Try again';
4371
+ }
4308
4372
  }
4309
4373
 
4310
- function openImportFailedModal(reason, agents) {
4374
+ /** The version the catalog currently reports for an agent, or null — used to tell the three apart. */
4375
+ function installedAgentVersion(id) {
4376
+ const a = agentCatalog.find((x) => x.id === id);
4377
+ return (a && (a.version || (a.manifest && a.manifest.version))) || null;
4378
+ }
4379
+
4380
+ /** The file this dialog is about, so "Retry the import" is genuinely ONE click rather than a polite
4381
+ * way of asking the user to find the file again. Cleared when the dialog closes. */
4382
+ let _importFailedFile = null;
4383
+ /** Agent ids whose in-app update finished — any one of them means a retry is worth offering. */
4384
+ let _importFailedTouched = new Set();
4385
+ /** id → the version installed BEFORE its in-app update, so the SSE result can tell "updated to vX"
4386
+ * from "already current". The agent-install-result payload carries ok/error and no version. */
4387
+ const _importFailedVersions = new Map();
4388
+
4389
+ function openImportFailedModal(reason, agents, file) {
4390
+ _importFailedFile = file || null;
4391
+ _importFailedTouched = new Set();
4311
4392
  const $sub = document.getElementById('import-failed-sub');
4312
4393
  const $remedy = document.getElementById('import-failed-remedy');
4313
4394
  const $rows = document.getElementById('import-failed-remedy-rows');
@@ -4326,6 +4407,19 @@
4326
4407
  : `This workflow needs ${agents.length} agents that aren’t runnable yet on this machine: ${named}.`
4327
4408
  + ' Updating usually fixes it. Any that report nothing to update haven’t been released yet — this workflow can’t run here until they are.';
4328
4409
  $rows.append(...agents.map(importFailedCmdRow)); // one command per agent, never a guessed multi-agent form
4410
+ // ONE retry offer for the whole dialog, not one per row: "retry THE import" is singular, and N
4411
+ // buttons doing the identical thing would just be N ways to ask the same question. Hidden until
4412
+ // something has actually changed — see importFailedOfferRetry.
4413
+ // REMOVE ANY PREVIOUS ONE FIRST. `$rows.replaceChildren()` above clears the rows' children, but
4414
+ // this banner is a SIBLING of $rows — so re-opening the dialog (a failed retry, or simply the
4415
+ // next bad import) used to leave the old one on screen and mint a second element with the same
4416
+ // id, until the dialog showed several retry prompts at once.
4417
+ document.getElementById('import-failed-retry')?.remove();
4418
+ const retry = document.createElement('div');
4419
+ retry.className = 'import-failed-retry';
4420
+ retry.id = 'import-failed-retry';
4421
+ retry.hidden = true;
4422
+ $rows.after(retry);
4329
4423
  $remedy.hidden = false;
4330
4424
  $detail.open = false; // the fix is the answer; the raw output is backup
4331
4425
  } else {
@@ -4346,7 +4440,61 @@
4346
4440
  document.addEventListener('keydown', _importFailedEsc);
4347
4441
  }
4348
4442
 
4443
+ /**
4444
+ * Offer a retry once ANY row has finished — a real version bump or a "nothing to update" both count,
4445
+ * because either is new information and a sibling agent's row may genuinely have fixed things.
4446
+ *
4447
+ * Purely additive: it never auto-triggers, never closes the dialog, and never removes the rows or the
4448
+ * raw-output details. Nothing the user was already reading disappears out from under them.
4449
+ */
4450
+ function importFailedOfferRetry() {
4451
+ const box = document.getElementById('import-failed-retry');
4452
+ if (!box || !_importFailedTouched.size || !_importFailedFile || box.childElementCount) return;
4453
+ const msg = document.createElement('span');
4454
+ msg.textContent = 'Worth another try — ';
4455
+ const go = document.createElement('button');
4456
+ go.type = 'button';
4457
+ go.className = 'import-failed-retry-go';
4458
+ go.dataset.tip = 'Import this workflow again, now that something has changed';
4459
+ go.textContent = 'Retry the import';
4460
+ // No ↺ glyph: it already means Rollback elsewhere in this app, and that is a materially
4461
+ // higher-stakes action to borrow an icon from.
4462
+ go.onclick = () => {
4463
+ const f = _importFailedFile;
4464
+ closeImportFailedModal();
4465
+ if (f) importFlo(f);
4466
+ };
4467
+ const tail = document.createElement('span');
4468
+ tail.textContent = ' now that something’s changed.';
4469
+ box.append(msg, go, tail);
4470
+ box.hidden = false;
4471
+ }
4472
+
4349
4473
  if ($importFailedModal) {
4474
+ // The in-app verb, per row. `updateAgent` is the SAME function the Agent Library's Update button
4475
+ // drives, so this inherits its in-flight dedupe and its SSE completion path rather than growing a
4476
+ // second way to run one command.
4477
+ $importFailedModal.addEventListener('click', async (e) => {
4478
+ const btn = e.target && e.target.closest && e.target.closest('[data-agent-update]');
4479
+ if (!btn) return;
4480
+ const id = btn.dataset.agentUpdate;
4481
+ if (!id || installingIds.has(id)) return;
4482
+ btn.setAttribute('aria-busy', 'true');
4483
+ btn.disabled = true;
4484
+ importFailedAgentStatus(id, 'busy');
4485
+ // LOAD THE CATALOGUE FIRST if we have not got one. The whole three-way outcome rests on knowing
4486
+ // the version BEFORE, and the catalogue loads lazily — with an empty one, `before` is null, and
4487
+ // "null !== '0.1.0'" would then report a confident "✓ Updated to v0.1.0" for a command that
4488
+ // found nothing to do. If it still cannot be read we say so rather than guess (state 'done').
4489
+ if (!agentCatalog.length) await loadAgentCatalog().catch(() => {});
4490
+ _importFailedVersions.set(id, installedAgentVersion(id));
4491
+ // The START can fail (bad id, server down) and `updateAgent`'s own catch cannot reach this row,
4492
+ // so it would sit disabled on "Updating…" forever. Own that end here.
4493
+ updateAgent(id, null, (err) => {
4494
+ _importFailedVersions.delete(id);
4495
+ importFailedAgentStatus(id, 'error', (err && err.message) || err);
4496
+ });
4497
+ });
4350
4498
  const $close = document.getElementById('import-failed-close');
4351
4499
  if ($close) $close.onclick = closeImportFailedModal;
4352
4500
  onBackdropDismiss($importFailedModal, closeImportFailedModal);
@@ -4391,7 +4539,9 @@
4391
4539
  // Only an install refusal carries AWARE's output. A bad file or a name clash is a one-line
4392
4540
  // problem the toast already states well — a dialog there would be ceremony.
4393
4541
  if (reason && $importFailedModal) {
4394
- openImportFailedModal(reason, Array.isArray(body.agentsUnavailable) ? body.agentsUnavailable : []);
4542
+ // The File goes with it, so "Retry the import" can genuinely be one click rather than a
4543
+ // polite way of asking the user to locate the file again.
4544
+ openImportFailedModal(reason, Array.isArray(body.agentsUnavailable) ? body.agentsUnavailable : [], file);
4395
4545
  return;
4396
4546
  }
4397
4547
  showToast(msg, body && body.code === 'exists' ? 'warn' : 'err');
@@ -6144,13 +6294,49 @@
6144
6294
  const a = availableCatalog.find((x) => x.id === m.id);
6145
6295
  showToast(`Installed “${a && a.display_name ? a.display_name : m.id}” — find it in Installed`, 'ok');
6146
6296
  }
6297
+ // `isUpdate` as well as the id. Without it, an INSTALL result for the same agent — started
6298
+ // in another tab, and deduped server-side so our update produced no event of its own —
6299
+ // would be reported as this dialog's update outcome.
6300
+ const forDialog = isUpdate && _importFailedVersions.has(m.id);
6147
6301
  loadAgentCatalog().then(() => {
6302
+ // Report it in the import-failure dialog too, if that is where the update was started
6303
+ // from. The catalogue has just been reloaded, so comparing against the version captured at
6304
+ // click time is what distinguishes a real bump from "already the latest" — the result
6305
+ // event itself says only ok/error.
6306
+ if (forDialog) {
6307
+ const before = _importFailedVersions.get(m.id);
6308
+ const after = installedAgentVersion(m.id);
6309
+ _importFailedVersions.delete(m.id);
6310
+ _importFailedTouched.add(m.id);
6311
+ // `before == null` means we never knew — claiming "Updated to vX" off that comparison
6312
+ // would be inventing a change we cannot see. Say what is installed and stop there.
6313
+ const state = before == null ? 'done' : (after && after !== before ? 'updated' : 'current');
6314
+ importFailedAgentStatus(m.id, state, after);
6315
+ importFailedOfferRetry();
6316
+ }
6148
6317
  if (!($libModal && $libModal.classList.contains('show'))) return;
6149
6318
  renderAvailable();
6150
6319
  if (libTab === 'installed') renderLibrary();
6151
- }).catch(() => {});
6320
+ }).catch(() => {
6321
+ // The update SUCCEEDED; only the catalogue refresh failed. Without this the row sits on
6322
+ // "Updating…" forever with its button disabled, for a command that actually worked.
6323
+ if (!forDialog) return;
6324
+ _importFailedVersions.delete(m.id);
6325
+ _importFailedTouched.add(m.id);
6326
+ importFailedAgentStatus(m.id, 'done', null);
6327
+ importFailedOfferRetry();
6328
+ });
6152
6329
  } else {
6153
6330
  showToast(`${isUpdate ? 'Update' : 'Install'} failed: ${String(m.error || '').slice(0, 80)}`, 'err');
6331
+ if (_importFailedVersions.has(m.id)) {
6332
+ // A failed update is NOT the "nothing to update" answer — say which it was, and re-arm the
6333
+ // row's own button so the user can try that one again without redoing the others.
6334
+ _importFailedVersions.delete(m.id);
6335
+ importFailedAgentStatus(m.id, 'error', m.error);
6336
+ const b = $importFailedModal
6337
+ && $importFailedModal.querySelector(`[data-agent-update="${CSS.escape(m.id)}"]`);
6338
+ if (b) { b.disabled = false; b.removeAttribute('aria-busy'); b.textContent = '↻ Try again'; }
6339
+ }
6154
6340
  if ($libModal && $libModal.classList.contains('show')) {
6155
6341
  if (isUpdate) renderLibrary();
6156
6342
  else renderAvailable();
@@ -7039,7 +7225,9 @@
7039
7225
  // (`agent-install-result`, action:'update'), so we flip the card to a busy spinner
7040
7226
  // and let the SSE handler refresh the catalog + re-render. `installingIds` is the
7041
7227
  // shared in-flight set (an id can't be installing and updating at once).
7042
- function updateAgent(id, btn) {
7228
+ // `onStartError` lets a caller that owns its own chrome (the import-failure dialog's per-agent row)
7229
+ // restore it when the START fails — the shared handling below can only reach the Library's cards.
7230
+ function updateAgent(id, btn, onStartError) {
7043
7231
  if (installingIds.has(id)) return; // already in flight (server dedupes too)
7044
7232
  installingIds.add(id);
7045
7233
  if (btn) { // immediate feedback before the next render
@@ -7053,6 +7241,7 @@
7053
7241
  .catch((e) => { // the START failed (bad id / server) — completion errors arrive via SSE
7054
7242
  installingIds.delete(id);
7055
7243
  if ($libModal && $libModal.classList.contains('show')) renderLibrary();
7244
+ if (onStartError) { try { onStartError(e); } catch { /* the caller's chrome, not ours */ } }
7056
7245
  reportErr(e);
7057
7246
  });
7058
7247
  }
@@ -398,7 +398,7 @@
398
398
  <div class="modal-title" id="import-failed-title">Import failed</div>
399
399
  <div class="modal-sub" id="import-failed-sub"></div>
400
400
  <div class="import-failed-remedy" id="import-failed-remedy" hidden>
401
- <div class="import-failed-remedy-label">Try this in your terminal AI, then import again:</div>
401
+ <div class="import-failed-remedy-label">Update it here, or run it in your terminal AI:</div>
402
402
  <div id="import-failed-remedy-rows"></div>
403
403
  </div>
404
404
  <details class="import-failed-detail" id="import-failed-detail">
@@ -0,0 +1,72 @@
1
+ /* Browser twin of server/contract-schema.ts's dependency-free JSON Schema subset. */
2
+
3
+ const plain = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
4
+ const equal = (a, b) => a === b || (Array.isArray(a) && Array.isArray(b)
5
+ && a.length === b.length && a.every((v, i) => equal(v, b[i])));
6
+ const kind = (v) => v === null ? 'null' : Array.isArray(v) ? 'array' : typeof v;
7
+ const typeMatches = (v, t) => ({
8
+ object: plain(v), array: Array.isArray(v), string: typeof v === 'string',
9
+ number: typeof v === 'number' && Number.isFinite(v),
10
+ integer: typeof v === 'number' && Number.isInteger(v),
11
+ boolean: typeof v === 'boolean', null: v === null,
12
+ })[t] === true;
13
+
14
+ function walk(value, node, root, path, errors) {
15
+ if (node.$ref) {
16
+ const match = /^#\/\$defs\/(.+)$/.exec(node.$ref);
17
+ const target = match && root.$defs?.[match[1]];
18
+ if (!target) errors.push({ path, message: `unresolved $ref ${node.$ref}` });
19
+ else walk(value, target, root, path, errors);
20
+ return;
21
+ }
22
+ if (node.oneOf) {
23
+ const candidates = node.oneOf.map((candidate) => {
24
+ const found = []; walk(value, candidate, root, path, found); return found;
25
+ });
26
+ const matches = candidates.filter((found) => found.length === 0).length;
27
+ if (matches !== 1) {
28
+ errors.push({ path, message: `must match exactly one oneOf branch (matched ${matches})` });
29
+ if (matches === 0) errors.push(...candidates.sort((a, b) => a.length - b.length)[0]);
30
+ }
31
+ }
32
+ if ('const' in node && !equal(value, node.const)) errors.push({ path, message: `must equal ${JSON.stringify(node.const)}` });
33
+ if (node.enum && !node.enum.some((v) => equal(value, v))) errors.push({ path, message: `must be one of ${JSON.stringify(node.enum)}` });
34
+ if (node.type) {
35
+ const types = Array.isArray(node.type) ? node.type : [node.type];
36
+ if (!types.some((t) => typeMatches(value, t))) {
37
+ errors.push({ path, message: `expected ${types.join(' | ')}, got ${kind(value)}` });
38
+ return;
39
+ }
40
+ }
41
+ if (typeof value === 'number' && Number.isFinite(value)) {
42
+ if (typeof node.minimum === 'number' && value < node.minimum) errors.push({ path, message: `must be >= ${node.minimum}` });
43
+ if (typeof node.maximum === 'number' && value > node.maximum) errors.push({ path, message: `must be <= ${node.maximum}` });
44
+ if (typeof node.exclusiveMinimum === 'number' && value <= node.exclusiveMinimum) errors.push({ path, message: `must be > ${node.exclusiveMinimum}` });
45
+ if (typeof node.exclusiveMaximum === 'number' && value >= node.exclusiveMaximum) errors.push({ path, message: `must be < ${node.exclusiveMaximum}` });
46
+ }
47
+ if (typeof value === 'string') {
48
+ const length = Array.from(value).length;
49
+ if (typeof node.minLength === 'number' && length < node.minLength) errors.push({ path, message: `expected at least ${node.minLength} characters, got ${length}` });
50
+ if (typeof node.maxLength === 'number' && length > node.maxLength) errors.push({ path, message: `expected at most ${node.maxLength} characters, got ${length}` });
51
+ }
52
+ if (plain(value)) {
53
+ for (const required of node.required || []) if (!Object.hasOwn(value, required)) errors.push({ path: `${path}.${required}`, message: 'required' });
54
+ const properties = node.properties || {};
55
+ for (const key of Object.keys(value)) {
56
+ if (Object.hasOwn(properties, key)) walk(value[key], properties[key], root, `${path}.${key}`, errors);
57
+ else if (node.additionalProperties === false) errors.push({ path: `${path}.${key}`, message: 'additional property not allowed' });
58
+ else if (plain(node.additionalProperties)) walk(value[key], node.additionalProperties, root, `${path}.${key}`, errors);
59
+ }
60
+ }
61
+ if (Array.isArray(value)) {
62
+ if (typeof node.minItems === 'number' && value.length < node.minItems) errors.push({ path, message: `expected at least ${node.minItems} items, got ${value.length}` });
63
+ if (typeof node.maxItems === 'number' && value.length > node.maxItems) errors.push({ path, message: `expected at most ${node.maxItems} items, got ${value.length}` });
64
+ if (node.items) value.forEach((item, i) => walk(item, node.items, root, `${path}[${i}]`, errors));
65
+ }
66
+ }
67
+
68
+ export function validateSchemaSubset(value, schema) {
69
+ const errors = [];
70
+ walk(value, schema, schema, '$', errors);
71
+ return { valid: errors.length === 0, errors };
72
+ }