@trops/dash-core 0.1.499 → 0.1.501

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/index.js CHANGED
@@ -49187,6 +49187,27 @@ var EnforcementToggles = function EnforcementToggles() {
49187
49187
  _useState10 = _slicedToArray(_useState1, 2),
49188
49188
  pendingDisable = _useState10[0],
49189
49189
  setPendingDisable = _useState10[1];
49190
+
49191
+ // lastTestResult: feedback for the "Test prompt" button. Tells the
49192
+ // user whether their JIT response was actually persisted, so they
49193
+ // don't have to interpret the post-grant "server not connected"
49194
+ // error as failure.
49195
+ var _useState11 = React.useState(null),
49196
+ _useState12 = _slicedToArray(_useState11, 2),
49197
+ lastTestResult = _useState12[0],
49198
+ setLastTestResult = _useState12[1];
49199
+
49200
+ // Auto-clear the test result after 30 seconds so it doesn't linger
49201
+ // forever after a successful test.
49202
+ React.useEffect(function () {
49203
+ if (!lastTestResult) return;
49204
+ var timer = setTimeout(function () {
49205
+ return setLastTestResult(null);
49206
+ }, 30000);
49207
+ return function () {
49208
+ return clearTimeout(timer);
49209
+ };
49210
+ }, [lastTestResult]);
49190
49211
  var writeSecurity = function writeSecurity(updates) {
49191
49212
  if (!(appContext !== null && appContext !== void 0 && appContext.changeSettings)) return;
49192
49213
  var next = _objectSpread$g(_objectSpread$g({}, settings), {}, {
@@ -49229,6 +49250,87 @@ var EnforcementToggles = function EnforcementToggles() {
49229
49250
  }
49230
49251
  setPendingDisable(null);
49231
49252
  };
49253
+
49254
+ // One-click JIT trigger for testing. Calls the gate via a fake widget
49255
+ // identity that has no grant — the gate denies, JIT escalates, the
49256
+ // modal pops. We classify the outcome so the user knows whether their
49257
+ // JIT response was actually persisted (vs whether the test ran at all).
49258
+ //
49259
+ // Outcome classification:
49260
+ // message includes "Server not connected" → granted
49261
+ // (gate passed, post-gate server lookup expectedly failed because
49262
+ // "test-server" doesn't exist — the goal is the consent flow, not
49263
+ // the server response)
49264
+ // message includes "user declined" → denied
49265
+ // message includes "JIT consent timed out" → timeout
49266
+ // anything else → unknown error
49267
+ var triggerTestJitPrompt = /*#__PURE__*/function () {
49268
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
49269
+ var _window$mainApi3, _window$mainApi3$call, result, msg, _t5;
49270
+ return _regeneratorRuntime.wrap(function (_context5) {
49271
+ while (1) switch (_context5.prev = _context5.next) {
49272
+ case 0:
49273
+ setLastTestResult({
49274
+ status: "pending",
49275
+ message: "Waiting for response…"
49276
+ });
49277
+ _context5.prev = 1;
49278
+ _context5.next = 2;
49279
+ return (_window$mainApi3 = window.mainApi) === null || _window$mainApi3 === void 0 || (_window$mainApi3 = _window$mainApi3.mcp) === null || _window$mainApi3 === void 0 || (_window$mainApi3$call = _window$mainApi3.callTool) === null || _window$mainApi3$call === void 0 ? void 0 : _window$mainApi3$call.call(_window$mainApi3, "test-server", "test_tool", {
49280
+ path: "/tmp/jit-probe.txt"
49281
+ }, null, "@test/jit-probe");
49282
+ case 2:
49283
+ result = _context5.sent;
49284
+ // callTool resolves to { error, message } on the main side; classify.
49285
+ msg = (result === null || result === void 0 ? void 0 : result.message) || JSON.stringify(result || {});
49286
+ if (/server not connected/i.test(msg)) {
49287
+ setLastTestResult({
49288
+ status: "granted",
49289
+ message: "Granted — your response was saved as a 'live' grant for @test/jit-probe."
49290
+ });
49291
+ } else if (/user declined/i.test(msg)) {
49292
+ setLastTestResult({
49293
+ status: "denied",
49294
+ message: "Denied — no grant written."
49295
+ });
49296
+ } else if (/timed out/i.test(msg)) {
49297
+ setLastTestResult({
49298
+ status: "timeout",
49299
+ message: "Timed out — no response within 60s."
49300
+ });
49301
+ } else {
49302
+ setLastTestResult({
49303
+ status: "unknown",
49304
+ message: "Unexpected: " + msg
49305
+ });
49306
+ }
49307
+ _context5.next = 4;
49308
+ break;
49309
+ case 3:
49310
+ _context5.prev = 3;
49311
+ _t5 = _context5["catch"](1);
49312
+ setLastTestResult({
49313
+ status: "error",
49314
+ message: "Test threw: " + ((_t5 === null || _t5 === void 0 ? void 0 : _t5.message) || String(_t5))
49315
+ });
49316
+ case 4:
49317
+ case "end":
49318
+ return _context5.stop();
49319
+ }
49320
+ }, _callee5, null, [[1, 3]]);
49321
+ }));
49322
+ return function triggerTestJitPrompt() {
49323
+ return _ref6.apply(this, arguments);
49324
+ };
49325
+ }();
49326
+ var TEST_RESULT_STYLE = {
49327
+ pending: "text-gray-400",
49328
+ granted: "text-green-400",
49329
+ denied: "text-amber-400",
49330
+ timeout: "text-amber-400",
49331
+ unknown: "text-red-400",
49332
+ error: "text-red-400"
49333
+ };
49232
49334
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
49233
49335
  className: "flex flex-col space-y-4 border border-gray-700 rounded p-4",
49234
49336
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -49268,6 +49370,31 @@ var EnforcementToggles = function EnforcementToggles() {
49268
49370
  return setPendingDisable(null);
49269
49371
  },
49270
49372
  onConfirm: confirmDisable
49373
+ }), enforceEnabled && jitEnabled && /*#__PURE__*/jsxRuntime.jsxs("div", {
49374
+ className: "flex flex-col gap-2 border-t border-gray-800 pt-4",
49375
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
49376
+ className: "flex flex-row items-center justify-between gap-4",
49377
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
49378
+ className: "flex flex-col",
49379
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
49380
+ className: "text-sm font-medium text-gray-200",
49381
+ children: "Test JIT consent prompt"
49382
+ }), /*#__PURE__*/jsxRuntime.jsxs("span", {
49383
+ className: "text-xs text-gray-400 mt-1",
49384
+ children: ["Fires a fake tool call from ", /*#__PURE__*/jsxRuntime.jsx("code", {
49385
+ children: "@test/jit-probe"
49386
+ }), " to", " ", /*#__PURE__*/jsxRuntime.jsx("code", {
49387
+ children: "test-server"
49388
+ }), ". The gate runs first (no real server needed), so you'll see the JIT modal exactly as it appears in production. The post-gate server lookup expectedly fails \u2014 that's fine; the goal here is to exercise the consent flow."]
49389
+ })]
49390
+ }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
49391
+ title: "Test prompt",
49392
+ onClick: triggerTestJitPrompt
49393
+ })]
49394
+ }), lastTestResult && /*#__PURE__*/jsxRuntime.jsxs("div", {
49395
+ className: "text-xs font-medium ".concat(TEST_RESULT_STYLE[lastTestResult.status] || "text-gray-400"),
49396
+ children: ["Last test (", lastTestResult.status, "): ", lastTestResult.message]
49397
+ })]
49271
49398
  })]
49272
49399
  });
49273
49400
  };
@@ -49294,10 +49421,10 @@ var DISABLE_COPY = {
49294
49421
  * nesting entirely; the user keeps context and the warning is
49295
49422
  * impossible to miss right where the toggle lives.
49296
49423
  */
49297
- var ConfirmDisableInline = function ConfirmDisableInline(_ref6) {
49298
- var pending = _ref6.pending,
49299
- onCancel = _ref6.onCancel,
49300
- onConfirm = _ref6.onConfirm;
49424
+ var ConfirmDisableInline = function ConfirmDisableInline(_ref7) {
49425
+ var pending = _ref7.pending,
49426
+ onCancel = _ref7.onCancel,
49427
+ onConfirm = _ref7.onConfirm;
49301
49428
  if (!pending) return null;
49302
49429
  var copy = DISABLE_COPY[pending.flag];
49303
49430
  if (!copy) return null;
@@ -49327,15 +49454,15 @@ var ConfirmDisableInline = function ConfirmDisableInline(_ref6) {
49327
49454
  })]
49328
49455
  });
49329
49456
  };
49330
- var WidgetGrantRow = function WidgetGrantRow(_ref7) {
49331
- var widgetId = _ref7.widgetId,
49332
- declared = _ref7.declared,
49333
- granted = _ref7.granted,
49334
- hasManifest = _ref7.hasManifest,
49335
- grantOrigin = _ref7.grantOrigin,
49336
- onRevokeWidget = _ref7.onRevokeWidget,
49337
- onRevokeServer = _ref7.onRevokeServer,
49338
- onGrantManually = _ref7.onGrantManually;
49457
+ var WidgetGrantRow = function WidgetGrantRow(_ref8) {
49458
+ var widgetId = _ref8.widgetId,
49459
+ declared = _ref8.declared,
49460
+ granted = _ref8.granted,
49461
+ hasManifest = _ref8.hasManifest,
49462
+ grantOrigin = _ref8.grantOrigin,
49463
+ onRevokeWidget = _ref8.onRevokeWidget,
49464
+ onRevokeServer = _ref8.onRevokeServer,
49465
+ onGrantManually = _ref8.onGrantManually;
49339
49466
  var declaredServers = declared && declared.servers || {};
49340
49467
  var grantedServers = granted && granted.servers || {};
49341
49468
  var allServerNames = Array.from(new Set([].concat(_toConsumableArray(Object.keys(declaredServers)), _toConsumableArray(Object.keys(grantedServers)))));
@@ -49407,10 +49534,10 @@ var WidgetGrantRow = function WidgetGrantRow(_ref7) {
49407
49534
  })]
49408
49535
  });
49409
49536
  };
49410
- var PermsList = function PermsList(_ref8) {
49411
- var label = _ref8.label,
49412
- declaredItems = _ref8.declaredItems,
49413
- grantedItems = _ref8.grantedItems;
49537
+ var PermsList = function PermsList(_ref9) {
49538
+ var label = _ref9.label,
49539
+ declaredItems = _ref9.declaredItems,
49540
+ grantedItems = _ref9.grantedItems;
49414
49541
  if (declaredItems.length === 0 && grantedItems.length === 0) return null;
49415
49542
  var grantedSet = new Set(grantedItems);
49416
49543
  var declaredSet = new Set(declaredItems);
@@ -49466,8 +49593,8 @@ function isServerEntirelyStale(decl, grant) {
49466
49593
  * the user audit grants that were approved against a scanner guess
49467
49594
  * rather than the developer's explicit declaration.
49468
49595
  */
49469
- var GrantOriginBadge = function GrantOriginBadge(_ref9) {
49470
- var origin = _ref9.origin;
49596
+ var GrantOriginBadge = function GrantOriginBadge(_ref0) {
49597
+ var origin = _ref0.origin;
49471
49598
  var styles = {
49472
49599
  declared: {
49473
49600
  label: "declared",
@@ -49620,10 +49747,10 @@ var noop = function noop() {};
49620
49747
  * users who don't want the wall of text collapse manually.
49621
49748
  */
49622
49749
  var HowThisWorksPanel = function HowThisWorksPanel() {
49623
- var _useState11 = React.useState(true),
49624
- _useState12 = _slicedToArray(_useState11, 2),
49625
- open = _useState12[0],
49626
- setOpen = _useState12[1];
49750
+ var _useState13 = React.useState(true),
49751
+ _useState14 = _slicedToArray(_useState13, 2),
49752
+ open = _useState14[0],
49753
+ setOpen = _useState14[1];
49627
49754
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
49628
49755
  className: "border border-gray-700 rounded",
49629
49756
  children: [/*#__PURE__*/jsxRuntime.jsxs("button", {