@jackwener/browsermcp 0.0.35-embedded.0 → 0.0.35

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 (130) hide show
  1. package/CHANGELOG.md +2 -28
  2. package/README.md +8 -93
  3. package/dist/docs/api-reference.md +14 -2
  4. package/dist/docs/api-use.md +1 -1
  5. package/dist/docs/errors.md +2 -2
  6. package/dist/docs/instructions.md +7 -3
  7. package/dist/docs/js-tool.md +3 -1
  8. package/dist/docs/repl-session.md +1 -1
  9. package/dist/docs/tab-lifecycle.md +19 -3
  10. package/dist/docs/troubleshooting.md +1 -1
  11. package/dist/src/api/action-input.js +1 -1
  12. package/dist/src/api/action-input.js.map +1 -1
  13. package/dist/src/api/api.js +5 -1
  14. package/dist/src/api/api.js.map +1 -1
  15. package/dist/src/api/browser.js +3 -3
  16. package/dist/src/api/browser.js.map +1 -1
  17. package/dist/src/api/commands.js +132 -0
  18. package/dist/src/api/commands.js.map +1 -0
  19. package/dist/src/api/errors.js +2 -2
  20. package/dist/src/api/errors.js.map +1 -1
  21. package/dist/src/api/tab.js +1 -1
  22. package/dist/src/api/tab.js.map +1 -1
  23. package/dist/src/backends/extension-page.js +10 -7
  24. package/dist/src/backends/extension-page.js.map +1 -1
  25. package/dist/src/docs/manifest.js +3 -6
  26. package/dist/src/docs/manifest.js.map +1 -1
  27. package/dist/src/host/bridge.js +3 -1
  28. package/dist/src/host/bridge.js.map +1 -1
  29. package/dist/src/mcp/server.js +16 -13
  30. package/dist/src/mcp/server.js.map +1 -1
  31. package/dist/src/protocol.js +1 -1
  32. package/dist/src/protocol.js.map +1 -1
  33. package/dist/src/runtime/runtime.js +1 -1
  34. package/dist/src/runtime/runtime.js.map +1 -1
  35. package/dist/src/shared/api-contract.js +2 -2
  36. package/dist/src/shared/api-contract.js.map +1 -1
  37. package/docs/api-reference.md +14 -2
  38. package/docs/api-use.md +1 -1
  39. package/docs/errors.md +2 -2
  40. package/docs/guide.zh-CN.md +1 -1
  41. package/docs/instructions.md +7 -3
  42. package/docs/js-tool.md +3 -1
  43. package/docs/repl-session.md +1 -1
  44. package/docs/tab-lifecycle.md +19 -3
  45. package/docs/troubleshooting.md +1 -1
  46. package/extension/dist/background.js +21 -25
  47. package/extension/dist/manifest.json +1 -1
  48. package/package.json +3 -12
  49. package/dist/src/api/action-input.d.ts +0 -47
  50. package/dist/src/api/agent.d.ts +0 -10
  51. package/dist/src/api/api.d.ts +0 -50
  52. package/dist/src/api/browser.d.ts +0 -92
  53. package/dist/src/api/context.d.ts +0 -7
  54. package/dist/src/api/diff.d.ts +0 -8
  55. package/dist/src/api/errors.d.ts +0 -12
  56. package/dist/src/api/network.d.ts +0 -10
  57. package/dist/src/api/observation.d.ts +0 -4
  58. package/dist/src/api/streams.d.ts +0 -13
  59. package/dist/src/api/tab.d.ts +0 -312
  60. package/dist/src/api/webmcp.d.ts +0 -19
  61. package/dist/src/backends/backend.d.ts +0 -14
  62. package/dist/src/backends/browser-helpers.d.ts +0 -17
  63. package/dist/src/backends/extension-page.d.ts +0 -5
  64. package/dist/src/backends/managed-page.d.ts +0 -47
  65. package/dist/src/backends/page-transport.d.ts +0 -10
  66. package/dist/src/backends/page-types.d.ts +0 -82
  67. package/dist/src/docs/embedded.d.ts +0 -2
  68. package/dist/src/docs/embedded.js +0 -39
  69. package/dist/src/docs/embedded.js.map +0 -1
  70. package/dist/src/docs/manifest.d.ts +0 -23
  71. package/dist/src/docs/surface.d.ts +0 -12
  72. package/dist/src/electron/backend.d.ts +0 -50
  73. package/dist/src/electron/backend.js +0 -375
  74. package/dist/src/electron/backend.js.map +0 -1
  75. package/dist/src/electron/chrome.d.ts +0 -24
  76. package/dist/src/electron/chrome.js +0 -133
  77. package/dist/src/electron/chrome.js.map +0 -1
  78. package/dist/src/electron/driver.d.ts +0 -43
  79. package/dist/src/electron/driver.js +0 -241
  80. package/dist/src/electron/driver.js.map +0 -1
  81. package/dist/src/electron/event-buffer.d.ts +0 -16
  82. package/dist/src/electron/event-buffer.js +0 -59
  83. package/dist/src/electron/event-buffer.js.map +0 -1
  84. package/dist/src/electron/page.js +0 -834
  85. package/dist/src/electron/registry.d.ts +0 -104
  86. package/dist/src/electron/registry.js +0 -316
  87. package/dist/src/electron/registry.js.map +0 -1
  88. package/dist/src/electron/streams.d.ts +0 -16
  89. package/dist/src/electron/streams.js +0 -48
  90. package/dist/src/electron/streams.js.map +0 -1
  91. package/dist/src/embedded/index.d.ts +0 -39
  92. package/dist/src/embedded/index.js +0 -71
  93. package/dist/src/embedded/index.js.map +0 -1
  94. package/dist/src/host/bridge.d.ts +0 -50
  95. package/dist/src/host/doctor.d.ts +0 -34
  96. package/dist/src/host/extension.d.ts +0 -3
  97. package/dist/src/host/host.d.ts +0 -3
  98. package/dist/src/host/ipc.d.ts +0 -14
  99. package/dist/src/host/jsonc-config.d.ts +0 -1
  100. package/dist/src/host/launch.d.ts +0 -11
  101. package/dist/src/host/native-messaging.d.ts +0 -28
  102. package/dist/src/host/opencode.d.ts +0 -6
  103. package/dist/src/host/pi.d.ts +0 -6
  104. package/dist/src/host/registration.d.ts +0 -24
  105. package/dist/src/host/setup.d.ts +0 -7
  106. package/dist/src/host/socket.d.ts +0 -25
  107. package/dist/src/host/state.d.ts +0 -39
  108. package/dist/src/launcher/stdio.d.ts +0 -3
  109. package/dist/src/lib/paths.d.ts +0 -1
  110. package/dist/src/lib/sources.d.ts +0 -5
  111. package/dist/src/main.d.ts +0 -2
  112. package/dist/src/mcp/catalog.d.ts +0 -202
  113. package/dist/src/mcp/js-session.d.ts +0 -64
  114. package/dist/src/mcp/server.d.ts +0 -15
  115. package/dist/src/protocol.d.ts +0 -319
  116. package/dist/src/recon/analyzer.d.ts +0 -43
  117. package/dist/src/recon/discover.d.ts +0 -48
  118. package/dist/src/runtime/runtime.d.ts +0 -148
  119. package/dist/src/shared/api-contract.d.ts +0 -86
  120. package/dist/src/shared/aria-tree.d.ts +0 -2
  121. package/dist/src/shared/element-ref.d.ts +0 -4
  122. package/dist/src/shared/engine.d.ts +0 -50
  123. package/dist/src/shared/injected-source.d.ts +0 -2
  124. package/dist/src/shared/page-contract.d.ts +0 -256
  125. package/dist/src/sites/define.d.ts +0 -28
  126. package/dist/src/sites/drafts.d.ts +0 -39
  127. package/dist/src/sites/executor.d.ts +0 -34
  128. package/dist/src/sites/loader.d.ts +0 -84
  129. package/dist/src/sites/schema.d.ts +0 -11
  130. package/dist/src/version.d.ts +0 -2
@@ -1469,7 +1469,7 @@ async function executeWithJournal(cmd, execute) {
1469
1469
  }
1470
1470
 
1471
1471
  // src/protocol.ts
1472
- var PROTOCOL_REVISION = 4;
1472
+ var PROTOCOL_REVISION = 5;
1473
1473
  var NATIVE_HOST_NAME = "com.browsermcp.host";
1474
1474
  var MAX_FRAME_BYTES = 1024 * 1024;
1475
1475
 
@@ -21254,7 +21254,7 @@ var ActionError = class extends Error {
21254
21254
  hint;
21255
21255
  data;
21256
21256
  toJSON() {
21257
- return { code: this.code, message: this.message, ...this.hint && { hint: this.hint }, ...this.data };
21257
+ return { ...this.data, code: this.code, message: this.message, ...this.hint && { hint: this.hint } };
21258
21258
  }
21259
21259
  };
21260
21260
 
@@ -21277,7 +21277,7 @@ var evaluateOptions = external_exports.strictObject({
21277
21277
  });
21278
21278
  var discoveryOptions = external_exports.strictObject({
21279
21279
  query: external_exports.string().optional(),
21280
- limit: external_exports.number().int().min(1).max(100).optional(),
21280
+ limit: external_exports.number().int().min(1).max(1e4).optional(),
21281
21281
  offset: external_exports.number().int().nonnegative().optional()
21282
21282
  });
21283
21283
  var userTabInfo = external_exports.strictObject({
@@ -21300,7 +21300,7 @@ var discoveryResult = external_exports.strictObject({
21300
21300
  excluded: external_exports.strictObject({ owned: external_exports.number().int().nonnegative(), unsupported: external_exports.number().int().nonnegative() }),
21301
21301
  matched: external_exports.number().int().nonnegative(),
21302
21302
  offset: external_exports.number().int().nonnegative(),
21303
- limit: external_exports.number().int().min(1).max(100),
21303
+ limit: external_exports.number().int().min(1).max(1e4),
21304
21304
  hasMore: external_exports.boolean(),
21305
21305
  nextOffset: external_exports.number().int().nonnegative().optional(),
21306
21306
  items: external_exports.array(userTabInfo)
@@ -21409,7 +21409,7 @@ var SessionManager = class {
21409
21409
  emit;
21410
21410
  sessions = /* @__PURE__ */ new Map();
21411
21411
  childObservers = /* @__PURE__ */ new Map();
21412
- /** Tabs finalize handed back to the user (kept, released, handoff). Commands to them are refused until a claim; a stale Tab handle cannot re-adopt one. */
21412
+ /** Tabs finalize handed back to the user (released). Commands to them are refused until a claim; a stale Tab handle cannot re-adopt one. */
21413
21413
  released = /* @__PURE__ */ new Set();
21414
21414
  cursorSeq = 0;
21415
21415
  restored = null;
@@ -21469,7 +21469,7 @@ var SessionManager = class {
21469
21469
  if (s.idleTimer) clearTimeout(s.idleTimer);
21470
21470
  const remaining = Math.max(0, IDLE_MS[s.surface] - (Date.now() - s.lastActivity));
21471
21471
  s.idleTimer = setTimeout(() => {
21472
- void this.finalize(s, []).catch(() => {
21472
+ void this.finalize(s, [], true).catch(() => {
21473
21473
  });
21474
21474
  }, remaining);
21475
21475
  }
@@ -21682,7 +21682,7 @@ var SessionManager = class {
21682
21682
  const tabs = await chrome.tabs.query({ windowType: "normal" });
21683
21683
  return tabs.filter((t) => t.id !== void 0).map((t) => ({
21684
21684
  supported: isHttp(t.url),
21685
- owned: (this.ownerOf(t.id)?.leases.get(t.id)?.state ?? "none") === "active",
21685
+ owned: Boolean(this.ownerOf(t.id)),
21686
21686
  tab: { tabId: t.id, title: t.title, url: t.url, windowId: t.windowId, active: Boolean(t.active), groupId: t.groupId > 0 ? t.groupId : void 0, lastAccessed: t.lastAccessed }
21687
21687
  }));
21688
21688
  }
@@ -21723,11 +21723,7 @@ var SessionManager = class {
21723
21723
  if (!isHttp(tab.url)) throw new SessionError("claim_not_allowed", "Only http(s) tabs can be claimed");
21724
21724
  const owner = this.ownerOf(tabId);
21725
21725
  const prior = owner?.leases.get(tabId);
21726
- if (owner && owner !== s && prior?.state !== "handoff") throw new SessionError("already_claimed", `Tab ${tabId} belongs to session ${owner.key}`);
21727
- if (owner && owner !== s) {
21728
- owner.leases.delete(tabId);
21729
- if (owner.preferredTabId === tabId) owner.preferredTabId = null;
21730
- }
21726
+ if (owner && owner !== s) throw new SessionError("already_claimed", `Tab ${tabId} belongs to session ${owner.key}`);
21731
21727
  s.windowId = s.windowId ?? tab.windowId;
21732
21728
  this.released.delete(tabId);
21733
21729
  const origin = prior?.origin ?? "user";
@@ -21741,9 +21737,9 @@ var SessionManager = class {
21741
21737
  /** Close explicit user-tab ids without acquiring them into a browser session. */
21742
21738
  async closeUserTabs(tabIds) {
21743
21739
  const unique = [...new Set(tabIds)];
21744
- const eligible = new Set((await chrome.tabs.query({ windowType: "normal" })).filter((tab) => tab.id !== void 0 && (this.ownerOf(tab.id)?.leases.get(tab.id)?.state ?? "none") !== "active").map((tab) => tab.id));
21740
+ const eligible = new Set((await chrome.tabs.query({ windowType: "normal" })).filter((tab) => tab.id !== void 0 && !this.ownerOf(tab.id)).map((tab) => tab.id));
21745
21741
  const outcomes = await Promise.all(unique.map(async (tabId) => {
21746
- if (!eligible.has(tabId) || this.ownerOf(tabId)?.leases.get(tabId)?.state === "active") return { tabId, reason: "Tab is gone or controlled by a session" };
21742
+ if (!eligible.has(tabId) || this.ownerOf(tabId)) return { tabId, reason: "Tab is gone or controlled by a session" };
21747
21743
  try {
21748
21744
  await chrome.tabs.remove(tabId);
21749
21745
  return { tabId, closed: true };
@@ -21766,7 +21762,7 @@ var SessionManager = class {
21766
21762
  throw new SessionError("stale_page", `stale page identity ${page}`, "That tab no longer exists; open or claim a fresh tab.");
21767
21763
  }
21768
21764
  const lease = s.leases.get(tabId);
21769
- if (lease?.state === "handoff" || !lease && this.released.has(tabId)) throw new SessionError("page_released", `page ${page} was handed back to the user by finalize`, "finalize ends the session's control of its tabs; claim the tab again (browser.user.claimTab) or open a new one.");
21765
+ if (!lease && this.released.has(tabId)) throw new SessionError("page_released", `page ${page} was handed back to the user by finalize`, "finalize ends the session's control of its tabs; claim the tab again (browser.user.claimTab) or open a new one.");
21770
21766
  if (!lease) {
21771
21767
  const owner = this.ownerOf(tabId);
21772
21768
  if (owner && owner !== s) throw new SessionError("page_not_in_session", `page ${page} belongs to session ${owner.key}`);
@@ -21850,9 +21846,10 @@ var SessionManager = class {
21850
21846
  lease.mark = mark;
21851
21847
  void this.persist();
21852
21848
  }
21853
- async finalize(s, keep) {
21849
+ async finalize(s, keep, closing = false) {
21854
21850
  const closed = [];
21855
- const kept = [];
21851
+ const released = [];
21852
+ const retained = [];
21856
21853
  const failed = [];
21857
21854
  const keepByTab = /* @__PURE__ */ new Map();
21858
21855
  for (const k of keep) {
@@ -21863,21 +21860,20 @@ var SessionManager = class {
21863
21860
  for (const lease of [...s.leases.values()]) {
21864
21861
  const status = keepByTab.get(lease.tabId) ?? lease.mark ?? null;
21865
21862
  const page = pageId(lease.tabId);
21866
- if (status === "handoff") {
21863
+ if (status === "handoff" && !closing) {
21867
21864
  await detach(lease.tabId).catch(() => {
21868
21865
  });
21869
21866
  await this.hideCursor(lease.tabId);
21870
- this.released.add(lease.tabId);
21871
21867
  lease.state = "handoff";
21872
21868
  lease.mark = "handoff";
21873
- kept.push(page);
21869
+ retained.push(page);
21874
21870
  continue;
21875
21871
  }
21876
- const op = status === "deliverable" || lease.origin === "user" ? "release" : "close";
21872
+ const op = status === "deliverable" || status === "handoff" || lease.origin === "user" ? "release" : "close";
21877
21873
  try {
21878
21874
  await this.endTab(s, lease.tabId, op);
21879
21875
  if (op === "close") closed.push(page);
21880
- else kept.push(page);
21876
+ else released.push(page);
21881
21877
  } catch (error62) {
21882
21878
  failed.push({ page, reason: error62 instanceof Error ? error62.message : String(error62) });
21883
21879
  }
@@ -21889,8 +21885,8 @@ var SessionManager = class {
21889
21885
  this.sessions.delete(s.key);
21890
21886
  }
21891
21887
  await this.persist();
21892
- if (failed.length === 0) this.emit({ kind: "session_released", session: s.key, reason: "finalize" });
21893
- return { closed, kept, failed };
21888
+ if (s.leases.size === 0 && failed.length === 0) this.emit({ kind: "session_released", session: s.key, reason: "finalize" });
21889
+ return { closed, released, retained, failed };
21894
21890
  }
21895
21891
  async setVisibility(s, visible) {
21896
21892
  s.visible = visible;
@@ -24806,7 +24802,7 @@ async function handleCommand(cmd) {
24806
24802
  }
24807
24803
  case "session-finalize":
24808
24804
  closeSessionStreams(s.key);
24809
- return { id: cmd.id, ok: true, data: await sessions.finalize(s, cmd.keep ?? []) };
24805
+ return { id: cmd.id, ok: true, data: await sessions.finalize(s, cmd.keep ?? [], cmd.closing) };
24810
24806
  // ── human visibility ──
24811
24807
  case "cursor": {
24812
24808
  if (typeof cmd.x !== "number" || typeof cmd.y !== "number") return { id: cmd.id, ok: false, error: "Missing x/y" };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "BrowserMCP Connector",
4
- "version": "0.0.25",
4
+ "version": "0.0.27",
5
5
  "description": "Connect your logged-in Chrome to BrowserMCP agents through a local native host.",
6
6
  "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1DKzfAqudbl9AylDyPDJtv4/Uf0DsfYtNmkB42Drff0IJVZ0pRGznikRyz3gNpSSairFyg50pWtuh0EKM/QsU1VrTlHycY529ho8+xMLFO64w3OolId18F73YQ4wRFEo3ESTYLLKVPRrK23dewElkVqtl0u3a63tm6YFkxUxzlS3l6xLMFoSId135BNdVLqHUZe9s/SGE0nD44sDMoNmkJk3qw+oUg65LH+69uc80PtSsXz9uiU6Ma77t2UG42Szvm5HfEDlWfX0NMM042emU8gZ3Id77DKe4195LZs/uEolqwyL12WsUkXcXyhCF7iQ09H/Ye8I6D6SqiEklX1S8QIDAQAB",
7
7
  "permissions": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jackwener/browsermcp",
3
- "version": "0.0.35-embedded.0",
3
+ "version": "0.0.35",
4
4
  "description": "Chrome-backed MCP browser service with optional site adapters.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "browsermcp": "dist/src/main.js"
20
20
  },
21
21
  "scripts": {
22
- "build": "node scripts/clean.mjs && node scripts/extract-playwright-injected.mjs && tsc -p tsconfig.json && node scripts/gen-api-reference.mjs && node scripts/render-icons.mjs && node scripts/build-extension.mjs && node scripts/copy-assets.mjs && node scripts/build-embedded.mjs",
22
+ "build": "node scripts/clean.mjs && node scripts/extract-playwright-injected.mjs && tsc -p tsconfig.json && node scripts/gen-api-reference.mjs && node scripts/render-icons.mjs && node scripts/build-extension.mjs && node scripts/copy-assets.mjs",
23
23
  "build:ext": "node scripts/render-icons.mjs && node scripts/build-extension.mjs",
24
24
  "dev": "tsx src/main.ts",
25
25
  "test": "vitest run",
@@ -32,10 +32,7 @@
32
32
  "pack:store": "npm run build && node scripts/pack-extension.mjs store",
33
33
  "pack:manual": "npm run build && node scripts/pack-extension.mjs manual",
34
34
  "smoke:native": "node scripts/smoke-native-capabilities.mjs",
35
- "generate:chrome": "node scripts/gen-chrome-reference.mjs",
36
- "build:embedded": "tsc -p tsconfig.json && node scripts/build-embedded.mjs && node scripts/copy-assets.mjs",
37
- "smoke:embedded": "npm run build:embedded && node scripts/run-embedded-smoke.mjs",
38
- "smoke:embedded:package": "npm run build:embedded && node scripts/smoke-embedded-package.mjs"
35
+ "generate:chrome": "node scripts/gen-chrome-reference.mjs"
39
36
  },
40
37
  "files": [
41
38
  "dist/",
@@ -63,11 +60,9 @@
63
60
  "zod": "^4.6.5"
64
61
  },
65
62
  "devDependencies": {
66
- "@electron/asar": "^4.3.1",
67
63
  "@resvg/resvg-js": "^2.6.2",
68
64
  "@types/chrome": "^0.3.0",
69
65
  "@types/node": "^22.20.3",
70
- "electron": "^44.9.0",
71
66
  "esbuild": "^0.28.2",
72
67
  "playwright-core": "^1.63.0",
73
68
  "tsx": "^4.23.13",
@@ -78,10 +73,6 @@
78
73
  "./adapter-sdk": {
79
74
  "types": "./adapter-sdk/index.d.ts",
80
75
  "default": "./adapter-sdk/index.js"
81
- },
82
- "./embedded": {
83
- "types": "./dist/src/embedded/index.d.ts",
84
- "default": "./dist/src/embedded/index.js"
85
76
  }
86
77
  }
87
78
  }
@@ -1,47 +0,0 @@
1
- import type { Expectation } from '../shared/page-contract.js';
2
- import type { ActAction, Target } from './tab.js';
3
- export interface RawTarget {
4
- ref?: string | number;
5
- selector?: string;
6
- within?: string;
7
- nth?: number;
8
- role?: string;
9
- name?: string;
10
- label?: string;
11
- text?: string;
12
- testid?: string;
13
- x?: number;
14
- y?: number;
15
- frame?: Target['frame'];
16
- }
17
- export interface ActToolInput {
18
- action: ActAction;
19
- target?: RawTarget;
20
- to?: RawTarget;
21
- value?: string;
22
- files?: string[];
23
- direction?: 'up' | 'down' | 'left' | 'right';
24
- amount?: number;
25
- method?: 'cdp' | 'dom';
26
- timeoutMs?: number;
27
- settleMs?: number;
28
- }
29
- type Need = 'required' | 'nonempty' | 'present' | 'optional' | 'forbidden';
30
- export declare const ACTION_RULES: Record<ActAction, {
31
- target: Need;
32
- value: Need;
33
- files: Need;
34
- to: Need;
35
- scroll: boolean;
36
- }>;
37
- /** What the model can copy into the next call. Wire shape is error.details.expected. */
38
- export declare function expectedAct(action: ActAction): Record<string, string>;
39
- export declare function pickTarget(t: RawTarget | undefined, action: ActAction, slot: 'target' | 'to'): Target | undefined;
40
- export declare function checkActInput(input: ActToolInput): {
41
- target?: Target;
42
- to?: Target;
43
- method?: 'cdp' | 'dom';
44
- };
45
- /** Validate the public contract before sending a compiled expectation to the page. */
46
- export declare function checkExpect(what: Expectation): void;
47
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * The object model — the single surface behind both the typed MCP tools and the `js` session.
3
- * agent.browsers → browser.tabs / browser.user / browser.capabilities → tab.observe / tab.act / …
4
- * sites.<site>.<command>(args) · recon.discover(tab) · tools.define · browser.nameSession / browser.tabs.finalize
5
- * Split by object: tab.ts, browser.ts, api.ts (context.ts carries what they share). This file re-exports them.
6
- */
7
- export * from './tab.js';
8
- export * from './browser.js';
9
- export * from './api.js';
10
- export * from './context.js';
@@ -1,50 +0,0 @@
1
- /**
2
- * The object model's entry: agent.browsers · sites.<site>.<command>() · recon.discover(tab) · tools.define.
3
- * One surface behind both the typed entry tools and the `js` session.
4
- */
5
- import type { Runtime } from '../runtime/runtime.js';
6
- import { discoverEndpoints, type DiscoverResult } from '../recon/discover.js';
7
- import { listDefinedTools, type ToolDefinition } from '../sites/define.js';
8
- import type { DraftExpectation } from '../sites/drafts.js';
9
- import { Tab } from './tab.js';
10
- import { Browser } from './browser.js';
11
- export interface AgentApi {
12
- agent: {
13
- browsers: {
14
- getDefault(): Promise<Browser>;
15
- };
16
- browser: Browser;
17
- documentation: {
18
- get(name: string): Promise<string | null>;
19
- };
20
- };
21
- sites: Record<string, unknown> & {
22
- search(q: string, limit?: number): Promise<unknown>;
23
- list(): Promise<unknown>;
24
- enable(site: string, opts?: {
25
- write?: boolean;
26
- }): Promise<{
27
- site: string;
28
- tools: string[];
29
- }>;
30
- disable(site: string): Promise<boolean>;
31
- run(site: string, name: string, args?: Record<string, unknown>): Promise<unknown>;
32
- };
33
- recon: {
34
- discover(tab: Tab, opts?: Parameters<typeof discoverEndpoints>[1]): Promise<DiscoverResult>;
35
- };
36
- tools: {
37
- define(def: ToolDefinition | (Omit<ToolDefinition, 'func'> & {
38
- func?: string | ((ctx: Record<string, unknown>) => unknown);
39
- })): ReturnType<Runtime['defineTool']>;
40
- try(draftId: string, args: Record<string, unknown>, expect: DraftExpectation): ReturnType<Runtime['tryToolDraft']>;
41
- activate(draftId: string): ReturnType<Runtime['activateToolDraft']>;
42
- discard(draftId: string): Promise<ReturnType<Runtime['discardToolDraft']>>;
43
- list(): Promise<ReturnType<typeof listDefinedTools>>;
44
- remove(site: string, name: string): ReturnType<Runtime['removeTool']>;
45
- };
46
- session: {
47
- id: string;
48
- };
49
- }
50
- export declare function createAgentApi(rt: Runtime, sessionId: string): AgentApi;
@@ -1,92 +0,0 @@
1
- import { type TabDiscoveryOptions, type TabDiscoveryResult } from '../shared/api-contract.js';
2
- import type { StreamOptions, StreamReadOptions, StreamBatch } from '../protocol.js';
3
- import type { CloseUserTabsResult } from '../protocol.js';
4
- import { Tab } from './tab.js';
5
- import type { SessionContext } from './context.js';
6
- export declare class Browser {
7
- readonly id: string;
8
- readonly type: 'extension' | 'electron';
9
- private readonly ctx;
10
- constructor(id: string, type: 'extension' | 'electron', ctx: SessionContext);
11
- toJSON(): {
12
- type: 'Browser';
13
- id: string;
14
- backend: string;
15
- };
16
- private page;
17
- private ext;
18
- /** Chrome APIs through the connected backend. Electron supports an explicit compatibility subset. */
19
- readonly chrome: {
20
- call: (method: string, args?: unknown[]) => Promise<unknown>;
21
- describe: (member: string) => Promise<unknown>;
22
- watch: (event: string, options?: StreamOptions) => Promise<import("./streams.js").EventStream>;
23
- };
24
- /** This extension's own service-worker logs; not logs of other installed extensions. */
25
- readonly logs: {
26
- watch: (options?: StreamOptions) => Promise<import("./streams.js").EventStream>;
27
- read: (options?: StreamReadOptions) => Promise<StreamBatch>;
28
- };
29
- readonly tabs: {
30
- new: (url?: string) => Promise<Tab>;
31
- list: () => Promise<Array<{
32
- id?: string;
33
- tabId: number;
34
- pending?: true;
35
- url?: string;
36
- title?: string;
37
- active: boolean;
38
- selected: boolean;
39
- lifecycle?: "dormant" | "loading" | "ready";
40
- origin: "agent" | "user";
41
- state: "active" | "handoff";
42
- }>>;
43
- get: (tab: string | {
44
- tab?: string;
45
- tabId: number;
46
- }, opts?: {
47
- timeoutMs?: number;
48
- }) => Promise<Tab>;
49
- selected: () => Promise<Tab | undefined>;
50
- finalize: (opts?: {
51
- keep?: Array<{
52
- tab: string | Tab;
53
- status: "deliverable" | "handoff";
54
- }>;
55
- }) => Promise<{
56
- closed: string[];
57
- kept: string[];
58
- failed: Array<{
59
- page: string;
60
- reason: string;
61
- }>;
62
- }>;
63
- };
64
- readonly user: {
65
- /** Unclaimed supported tabs in the visible scope. Query is trimmed, case-insensitive literal substring of URL OR title (no token splitting). Inspect items, matched, totalInScope, excluded and hasMore; continue with nextOffset. Each call takes a fresh snapshot. */
66
- openTabs: (options?: {
67
- query?: string | undefined;
68
- limit?: number | undefined;
69
- offset?: number | undefined;
70
- } | undefined) => Promise<TabDiscoveryResult>;
71
- /** Claim by foreground, id, or unique url/title lookup; expected fields verify the tab's current identity. */
72
- claimTab: (tab: {
73
- tabId?: number;
74
- active?: boolean;
75
- title?: string;
76
- url?: string;
77
- expectedUrl?: string;
78
- expectedTitle?: string;
79
- }) => Promise<Tab>;
80
- /** Close user tabs by Chrome id without claiming or loading their pages. */
81
- closeTabs: (tabIds: number[]) => Promise<CloseUserTabsResult>;
82
- };
83
- nameSession(name: string): Promise<void>;
84
- readonly capabilities: {
85
- list: () => Promise<Array<{
86
- id: string;
87
- description: string;
88
- }>>;
89
- get: (id: string) => Promise<Record<string, unknown>>;
90
- };
91
- documentation(): Promise<string>;
92
- }
@@ -1,7 +0,0 @@
1
- /** What every object of the model carries: the runtime, the MCP session id, and that session's state. */
2
- import type { Runtime, SessionState } from '../runtime/runtime.js';
3
- export interface SessionContext {
4
- rt: Runtime;
5
- sessionId: string;
6
- state: SessionState;
7
- }
@@ -1,8 +0,0 @@
1
- export interface AriaDiff {
2
- changedRatio: number;
3
- text: string;
4
- added: number;
5
- removed: number;
6
- changed: number;
7
- }
8
- export declare function ariaDiff(prev: string, next: string): AriaDiff;
@@ -1,12 +0,0 @@
1
- /** Stable, branchable errors for the object API and typed tools. */
2
- export declare class ActionError extends Error {
3
- readonly code: string;
4
- readonly hint?: string | undefined;
5
- readonly data?: Record<string, unknown> | undefined;
6
- constructor(code: string, message: string, hint?: string | undefined, data?: Record<string, unknown> | undefined);
7
- toJSON(): Record<string, unknown>;
8
- }
9
- export declare function errorEnvelope(err: unknown): {
10
- ok: false;
11
- error: Record<string, unknown>;
12
- };
@@ -1,10 +0,0 @@
1
- /** Bounded, two-stage network evidence for agents. Raw captures stay in the session log. */
2
- export interface NetworkEntry extends Record<string, unknown> {
3
- seq: number;
4
- }
5
- export declare function networkSummary(e: NetworkEntry): Record<string, unknown>;
6
- export declare function networkDetail(e: NetworkEntry, opts?: {
7
- part?: 'request' | 'response';
8
- start?: number;
9
- maxChars?: number;
10
- }): Record<string, unknown>;
@@ -1,4 +0,0 @@
1
- import type { ObserveResult } from './tab.js';
2
- export declare const OBSERVATION_BUDGET = 10000;
3
- /** Page one immutable capture across documents. Offsets are text characters or DOM entries. */
4
- export declare function observationPage(capture: ObserveResult, cursor?: string): ObserveResult;
@@ -1,13 +0,0 @@
1
- import type { Command, StreamBatch, StreamOptions, StreamReadOptions } from '../protocol.js';
2
- import type { SessionContext } from './context.js';
3
- export interface EventStream {
4
- /** Reads after the handle's last read, or an explicit cursor. Filtering still advances the cursor. */
5
- read(options?: StreamReadOptions): Promise<StreamBatch>;
6
- /** Idempotently releases this subscription. */
7
- close(): Promise<void>;
8
- }
9
- export declare function browserCommand(ctx: SessionContext, feature: import('../protocol.js').BrowserFeature, action: Command['action'], params?: Partial<Command>): Promise<unknown>;
10
- export declare function watch(ctx: SessionContext, source: 'chrome' | 'cdp' | 'console' | 'extension', event?: string, options?: StreamOptions, page?: string, route?: {
11
- session: string;
12
- surface: 'browser' | 'adapter';
13
- }): Promise<EventStream>;