@ait-co/devtools 0.1.132 → 0.1.133

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.
Files changed (68) hide show
  1. package/dist/{attach-orchestrator-ca34r46y.js → attach-orchestrator-CE0S09YU.js} +110 -5
  2. package/dist/attach-orchestrator-CE0S09YU.js.map +1 -0
  3. package/dist/{attach-orchestrator-BiaYiNOr.js → attach-orchestrator-CMoDuG2A.js} +110 -5
  4. package/dist/attach-orchestrator-CMoDuG2A.js.map +1 -0
  5. package/dist/cell-BIdSQb9T.js +201 -0
  6. package/dist/cell-BIdSQb9T.js.map +1 -0
  7. package/dist/{cell-Cw4fVOl2.js → cell-D1y4shoV.js} +1 -21
  8. package/dist/cell-D1y4shoV.js.map +1 -0
  9. package/dist/cell-DHA578lX.js +200 -0
  10. package/dist/cell-DHA578lX.js.map +1 -0
  11. package/dist/{debug-server-Ch5p0ryv.js → debug-server-CS1BS2BX.js} +2 -2
  12. package/dist/{debug-server-Ch5p0ryv.js.map → debug-server-CS1BS2BX.js.map} +1 -1
  13. package/dist/{debug-server-DoWAtTNj.js → debug-server-DmzuK2c6.js} +7 -8
  14. package/dist/{debug-server-DoWAtTNj.js.map → debug-server-DmzuK2c6.js.map} +1 -1
  15. package/dist/{debug-server-BBUzxZSf.js → debug-server-DnNCoNiR.js} +7 -7
  16. package/dist/{debug-server-BBUzxZSf.js.map → debug-server-DnNCoNiR.js.map} +1 -1
  17. package/dist/mcp/cli.js +111 -4
  18. package/dist/mcp/cli.js.map +1 -1
  19. package/dist/mcp/server.js +1 -1
  20. package/dist/panel/index.js +1 -1
  21. package/dist/{pool-BtLh7U1y.d.ts → pool-x28Wv1ty.d.ts} +2 -2
  22. package/dist/{pool-BtLh7U1y.d.ts.map → pool-x28Wv1ty.d.ts.map} +1 -1
  23. package/dist/{qr-http-server-KB147M-S.js → qr-http-server-C_DTp9WU.js} +1 -1
  24. package/dist/{qr-http-server-KB147M-S.js.map → qr-http-server-C_DTp9WU.js.map} +1 -1
  25. package/dist/{relay-factory-cNgPfrWg.js → relay-factory-BQfmK7RP.js} +6 -6
  26. package/dist/{relay-factory-cNgPfrWg.js.map → relay-factory-BQfmK7RP.js.map} +1 -1
  27. package/dist/{relay-secret-store-CFc9n0OA.js → relay-secret-store-CLEGyHou.js} +2 -2
  28. package/dist/{relay-secret-store-CFc9n0OA.js.map → relay-secret-store-CLEGyHou.js.map} +1 -1
  29. package/dist/{relay-secret-store-DzxDsK6S.js → relay-secret-store-DGduVJhs.js} +2 -2
  30. package/dist/{relay-secret-store-DzxDsK6S.js.map → relay-secret-store-DGduVJhs.js.map} +1 -1
  31. package/dist/{relay-url-store-D3rY-GJJ.js → relay-url-store-B0X8TsGr.js} +2 -2
  32. package/dist/{relay-url-store-D3rY-GJJ.js.map → relay-url-store-B0X8TsGr.js.map} +1 -1
  33. package/dist/{relay-url-store-DGQ-HPQC.js → relay-url-store-CKW8RQzf.js} +2 -2
  34. package/dist/{relay-url-store-DGQ-HPQC.js.map → relay-url-store-CKW8RQzf.js.map} +1 -1
  35. package/dist/{relay-worker-BMSnlyls.d.ts → relay-worker-DtX_eszH.d.ts} +13 -1
  36. package/dist/relay-worker-DtX_eszH.d.ts.map +1 -0
  37. package/dist/{relay-worker-l34xNuci.js → relay-worker-MZq4fLv8.js} +8 -4
  38. package/dist/{relay-worker-l34xNuci.js.map → relay-worker-MZq4fLv8.js.map} +1 -1
  39. package/dist/rolldown-runtime-DGkTqVfb.js +15 -0
  40. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  41. package/dist/test-runner/bin.js +15 -101
  42. package/dist/test-runner/bin.js.map +1 -1
  43. package/dist/test-runner/config.d.ts +1 -1
  44. package/dist/test-runner/config.js +1 -1
  45. package/dist/test-runner/pool.d.ts +1 -1
  46. package/dist/test-runner/pool.js +1 -1
  47. package/dist/test-runner/relay-factory.js +3 -3
  48. package/dist/test-runner/relay-worker.d.ts +1 -1
  49. package/dist/test-runner/relay-worker.js +1 -1
  50. package/dist/test-runner/report.d.ts +10 -1
  51. package/dist/test-runner/report.d.ts.map +1 -1
  52. package/dist/test-runner/report.js +1 -0
  53. package/dist/test-runner/report.js.map +1 -1
  54. package/dist/{totp-DvOYkYim.js → totp-CZLLKfOC.js} +2 -14
  55. package/dist/{totp-DvOYkYim.js.map → totp-CZLLKfOC.js.map} +1 -1
  56. package/dist/totp-DAxys-r0.js +199 -0
  57. package/dist/totp-DAxys-r0.js.map +1 -0
  58. package/package.json +1 -1
  59. package/dist/attach-orchestrator-BiaYiNOr.js.map +0 -1
  60. package/dist/attach-orchestrator-ca34r46y.js.map +0 -1
  61. package/dist/cell-Bi8MAPA8.js +0 -88
  62. package/dist/cell-Bi8MAPA8.js.map +0 -1
  63. package/dist/cell-Cw4fVOl2.js.map +0 -1
  64. package/dist/cell-rr6gL9AT.js +0 -89
  65. package/dist/cell-rr6gL9AT.js.map +0 -1
  66. package/dist/log-CUik_tHp.js +0 -95
  67. package/dist/log-CUik_tHp.js.map +0 -1
  68. package/dist/relay-worker-BMSnlyls.d.ts.map +0 -1
package/dist/mcp/cli.js CHANGED
@@ -2024,7 +2024,7 @@ async function readMcpSdkVersion() {
2024
2024
  * some test environments that skip the build step).
2025
2025
  */
2026
2026
  function readDevtoolsVersion() {
2027
- return "0.1.132";
2027
+ return "0.1.133";
2028
2028
  }
2029
2029
  /**
2030
2030
  * Derives the next recommended action from a completed diagnostics snapshot.
@@ -2932,6 +2932,110 @@ function buildIndicatorExpression(opts) {
2932
2932
  * Node-only. react-free. CdpConnection only.
2933
2933
  */
2934
2934
  /**
2935
+ * `__AIT_PERMS__` key → SDK function name whose `.getPermission()` is probed
2936
+ * (devtools#739). This is the exact contract sdk-example#265 consumes — do
2937
+ * not rename keys without a coordinated sdk-example update.
2938
+ *
2939
+ * Each SDK function is reached via `window.__sdk` — the SAME page-global
2940
+ * bridge `src/in-app/auto.ts` installs for `call_sdk`/`__sdkCall` (see
2941
+ * `src/test-runner/bundle.ts`'s `sdkRedirectPlugin`, which redirects bundled
2942
+ * `@apps-in-toss/web-framework` imports to this same object at runtime). The
2943
+ * test-runner bundle owns no independent SDK import — `window.__sdk` is a
2944
+ * page global regardless of whether a bundle has been injected yet, so this
2945
+ * preflight runs standalone via `injectGlobals`'s `Runtime.evaluate`
2946
+ * mechanism BEFORE the first bundle, rather than being prepended into
2947
+ * `rpc.ts#buildRunTestsExpression`. (Design choice documented in PR #739 —
2948
+ * bundle-prepend was the fallback plan if the SDK were only reachable from
2949
+ * inside bundle scope, which reality ruled out.)
2950
+ */
2951
+ const PERMISSION_PROBE_MAP = {
2952
+ clipboardRead: "getClipboardText",
2953
+ clipboardWrite: "setClipboardText",
2954
+ album: "fetchAlbumPhotos",
2955
+ camera: "openCamera",
2956
+ contacts: "fetchContacts",
2957
+ location: "getCurrentLocation"
2958
+ };
2959
+ /** Non-fatal bound for the permission preflight `Runtime.evaluate` round-trip. */
2960
+ const PERMISSION_PREFLIGHT_TIMEOUT_MS = 1e4;
2961
+ /**
2962
+ * Builds the `Runtime.evaluate` expression for the permission-state preflight
2963
+ * (devtools#739). Evaluated ONCE per relay session, before the first test
2964
+ * bundle is injected (see `relay-worker.ts#runTestFilesOverRelay`).
2965
+ *
2966
+ * For each entry in {@link PERMISSION_PROBE_MAP}, probes
2967
+ * `window.__sdk.<fn>.getPermission()` — a NON-blocking query (never
2968
+ * `openPermissionDialog`/`requestPermission`, which open native UI) — and
2969
+ * assigns the resolved `'allowed'|'denied'|'notDetermined'` status to
2970
+ * `globalThis.__AIT_PERMS__[<key>]`. A probe that is absent, throws, or
2971
+ * rejects resolves to `'unavailable'` — this expression never throws to its
2972
+ * caller, and a single slow/broken permission must not fail the others (each
2973
+ * probe is awaited independently, not short-circuited).
2974
+ *
2975
+ * Tests (sdk-example#265) read `globalThis.__AIT_PERMS__` to branch
2976
+ * deterministically per permission state instead of blanket outcome-branching.
2977
+ *
2978
+ * Returns a JSON-serialised string (the same double-serialisation pattern
2979
+ * `rpc.ts#buildRunTestsExpression` uses) rather than relying on CDP
2980
+ * `returnByValue` structural fidelity for a plain object across the Chii
2981
+ * relay — the Node side re-parses via `JSON.parse`.
2982
+ *
2983
+ * Pure function — no I/O, no CDP call. Callers pass the returned string to
2984
+ * `Runtime.evaluate`.
2985
+ */
2986
+ function buildPermissionPreflightExpression() {
2987
+ return `(async () => { const probe = async (fnName) => { try { const fn = globalThis.__sdk && globalThis.__sdk[fnName]; if (!fn || typeof fn.getPermission !== 'function') return 'unavailable'; const status = await fn.getPermission(); if (status === 'allowed' || status === 'denied' || status === 'notDetermined') return status; return 'unavailable'; } catch (e) { return 'unavailable'; } }; const result = {};${Object.entries(PERMISSION_PROBE_MAP).map(([key, fnName]) => ` result[${JSON.stringify(key)}] = await probe(${JSON.stringify(fnName)});`).join("\n")}\n globalThis.__AIT_PERMS__ = result; return JSON.stringify(result);})()`;
2988
+ }
2989
+ /**
2990
+ * Runs the permission-state preflight (devtools#739) via `Runtime.evaluate`
2991
+ * and returns the collected `__AIT_PERMS__` map, or `undefined` when the
2992
+ * preflight itself failed or timed out.
2993
+ *
2994
+ * NON-FATAL by design: any failure (CDP exception, timeout, page-side throw)
2995
+ * is caught here, logged as ONE stderr line, and swallowed — the whole test
2996
+ * run must proceed even when the preflight cannot complete (e.g. `window.__sdk`
2997
+ * not yet installed, or a page navigation mid-attach). Callers that want the
2998
+ * result for report provenance (`RelayRunReport.preflight`) get `undefined`
2999
+ * in that case, which downstream code treats the same as "not run".
3000
+ *
3001
+ * SECRET-HANDLING: no relay/wss/secret values are read or logged; only
3002
+ * permission-state strings cross this boundary.
3003
+ *
3004
+ * @param conn - The live CDP connection (relay-attached page).
3005
+ * @param timeoutMs - Round-trip bound. Defaults to {@link PERMISSION_PREFLIGHT_TIMEOUT_MS}.
3006
+ */
3007
+ async function runPermissionPreflight(conn, timeoutMs = PERMISSION_PREFLIGHT_TIMEOUT_MS) {
3008
+ const TIMEOUT_SENTINEL = Symbol("permission-preflight-timeout");
3009
+ const timeoutPromise = new Promise((resolve) => setTimeout(() => resolve(TIMEOUT_SENTINEL), timeoutMs));
3010
+ try {
3011
+ const evalPromise = conn.send("Runtime.evaluate", {
3012
+ expression: buildPermissionPreflightExpression(),
3013
+ returnByValue: true,
3014
+ awaitPromise: true
3015
+ });
3016
+ const raceResult = await Promise.race([evalPromise.then((v) => ({
3017
+ tag: "eval",
3018
+ v
3019
+ })), timeoutPromise.then(() => ({ tag: "timeout" }))]);
3020
+ if (raceResult.tag === "timeout") {
3021
+ process.stderr.write(`test-runner: permission preflight timed out after ${timeoutMs}ms — proceeding with __AIT_PERMS__ unset\n`);
3022
+ return;
3023
+ }
3024
+ if (raceResult.v.exceptionDetails) {
3025
+ process.stderr.write("test-runner: permission preflight threw — proceeding with __AIT_PERMS__ unset\n");
3026
+ return;
3027
+ }
3028
+ const rawValue = raceResult.v.result.value;
3029
+ if (typeof rawValue !== "string") return void 0;
3030
+ const parsed = JSON.parse(rawValue);
3031
+ if (typeof parsed !== "object" || parsed === null) return void 0;
3032
+ return parsed;
3033
+ } catch (e) {
3034
+ process.stderr.write(`test-runner: permission preflight failed (${e instanceof Error ? e.message : String(e)}) — proceeding with __AIT_PERMS__ unset\n`);
3035
+ return;
3036
+ }
3037
+ }
3038
+ /**
2935
3039
  * Injects each key of `globals` into `globalThis` in the page via a single
2936
3040
  * `Runtime.evaluate` call. Must be called BEFORE the first `bundleTestFile`
2937
3041
  * inject — the cell is session-global and applies to all subsequent files.
@@ -4178,6 +4282,8 @@ async function runTestFilesOverRelay(connection, files, opts) {
4178
4282
  const manualFiles = opts?.manualFiles;
4179
4283
  const manualTotal = manualFiles?.size ?? 0;
4180
4284
  let manualIndex = 0;
4285
+ let preflightPermissions;
4286
+ if (files.length > 0) preflightPermissions = await runPermissionPreflight(connection);
4181
4287
  try {
4182
4288
  for (const file of files) {
4183
4289
  if (pendingReconnectCheck) {
@@ -4280,7 +4386,8 @@ async function runTestFilesOverRelay(connection, files, opts) {
4280
4386
  duration: Date.now() - wallStart,
4281
4387
  files: fileResults,
4282
4388
  totals,
4283
- captures
4389
+ captures,
4390
+ ...preflightPermissions ? { preflight: { permissions: preflightPermissions } } : {}
4284
4391
  };
4285
4392
  }
4286
4393
  /**
@@ -7012,7 +7119,7 @@ function createDebugServer(deps) {
7012
7119
  };
7013
7120
  const server = new Server({
7014
7121
  name: "ait-debug",
7015
- version: "0.1.132"
7122
+ version: "0.1.133"
7016
7123
  }, { capabilities: { tools: { listChanged: true } } });
7017
7124
  server.setRequestHandler(ListToolsRequestSchema, () => {
7018
7125
  const conn = router.active;
@@ -8996,7 +9103,7 @@ function createDevServer(deps = {}) {
8996
9103
  const aitSource = deps.aitSource ?? new HttpAitSource({ stateEndpoint });
8997
9104
  const server = new Server({
8998
9105
  name: "ait-devtools",
8999
- version: "0.1.132"
9106
+ version: "0.1.133"
9000
9107
  }, { capabilities: { tools: {} } });
9001
9108
  server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: DEV_TOOL_DEFINITIONS.map((tool) => ({ ...tool })) }));
9002
9109
  server.setRequestHandler(CallToolRequestSchema, async (request) => {