@capyclaw/browser-workbench 0.1.19 → 0.1.21

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 (220) hide show
  1. package/contract/browser-contract.json +45 -19
  2. package/node_modules/@capyclaw/asset-service/dsh-suite.json +1 -1
  3. package/node_modules/@capyclaw/asset-service/package.json +1 -1
  4. package/node_modules/@capyclaw/asset-service/src/index.mjs +10 -4
  5. package/node_modules/@capyclaw/document-workbench/package.json +6 -3
  6. package/node_modules/@capyclaw/document-workbench/src/client/index.mjs +56 -3
  7. package/node_modules/@capyclaw/document-workbench/src/client/visibility.mjs +112 -0
  8. package/node_modules/@capyclaw/document-workbench/src/model/manifest.mjs +6 -4
  9. package/node_modules/@capyclaw/document-workbench/src/model/ops.mjs +7 -2
  10. package/node_modules/@capyclaw/document-workbench/src/session/index.mjs +8 -0
  11. package/node_modules/@capyclaw/document-workbench/src/store/file-backend.mjs +17 -10
  12. package/node_modules/@capyclaw/document-workbench/src/store/projection.mjs +39 -0
  13. package/node_modules/@capyclaw/document-workbench/src/testing/index.mjs +14 -11
  14. package/node_modules/@capyclaw/foundation/abi/assets.mjs +26 -0
  15. package/node_modules/@capyclaw/foundation/abi/bridge.mjs +3 -1
  16. package/node_modules/@capyclaw/foundation/abi/index.mjs +15 -0
  17. package/node_modules/@capyclaw/foundation/abi/loader.mjs +8 -1
  18. package/node_modules/@capyclaw/foundation/abi/spec.mjs +5 -2
  19. package/node_modules/@capyclaw/foundation/abi/version.mjs +63 -5
  20. package/node_modules/@capyclaw/foundation/abi/visibility.mjs +90 -0
  21. package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +21 -4
  22. package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +5 -1
  23. package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +5 -2
  24. package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +4 -0
  25. package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +29 -2
  26. package/node_modules/@capyclaw/foundation/lib/kernel.mjs +13 -3
  27. package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +12 -2
  28. package/node_modules/@capyclaw/foundation/package.json +1 -1
  29. package/node_modules/@capyclaw/plugin-kit/package.json +3 -1
  30. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +5 -2
  31. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat.mjs +26 -0
  32. package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +3 -1
  33. package/node_modules/@capyclaw/plugin-kit/src/service/static.mjs +79 -0
  34. package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +13 -5
  35. package/node_modules/@capyclaw/service-host/dsh-suite.json +1 -1
  36. package/node_modules/@capyclaw/service-host/package.json +1 -1
  37. package/node_modules/@capyclaw/service-host/src/index.mjs +18 -19
  38. package/node_modules/@capyclaw/tool-host/dsh-suite.json +2 -2
  39. package/node_modules/@capyclaw/tool-host/lib/host.mjs +34 -4
  40. package/node_modules/@capyclaw/tool-host/package.json +1 -1
  41. package/node_modules/@capyclaw/tool-host/src/admit-images.mjs +80 -0
  42. package/node_modules/@capyclaw/tool-host/src/caller-session.mjs +25 -0
  43. package/node_modules/@capyclaw/tool-host/src/index.mjs +59 -14
  44. package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +272 -0
  45. package/node_modules/playwright/LICENSE +202 -0
  46. package/node_modules/playwright/NOTICE +5 -0
  47. package/node_modules/playwright/README.md +318 -0
  48. package/node_modules/playwright/ThirdPartyNotices.txt +14 -0
  49. package/node_modules/playwright/cli.js +19 -0
  50. package/node_modules/playwright/index.d.ts +17 -0
  51. package/node_modules/playwright/index.js +17 -0
  52. package/node_modules/playwright/index.mjs +18 -0
  53. package/node_modules/playwright/lib/agents/agentParser.js +89 -0
  54. package/node_modules/playwright/lib/agents/copilot-setup-steps.yml +34 -0
  55. package/node_modules/playwright/lib/agents/generateAgents.js +395 -0
  56. package/node_modules/playwright/lib/agents/playwright-test-coverage.prompt.md +31 -0
  57. package/node_modules/playwright/lib/agents/playwright-test-generate.prompt.md +8 -0
  58. package/node_modules/playwright/lib/agents/playwright-test-generator.agent.md +88 -0
  59. package/node_modules/playwright/lib/agents/playwright-test-heal.prompt.md +6 -0
  60. package/node_modules/playwright/lib/agents/playwright-test-healer.agent.md +56 -0
  61. package/node_modules/playwright/lib/agents/playwright-test-plan.prompt.md +9 -0
  62. package/node_modules/playwright/lib/agents/playwright-test-planner.agent.md +74 -0
  63. package/node_modules/playwright/lib/cli/reportActions.js +78 -0
  64. package/node_modules/playwright/lib/cli/testActions.js +217 -0
  65. package/node_modules/playwright/lib/common/index.js +2937 -0
  66. package/node_modules/playwright/lib/common/index.js.txt +33 -0
  67. package/node_modules/playwright/lib/errorContext.js +129 -0
  68. package/node_modules/playwright/lib/globals.js +58 -0
  69. package/node_modules/playwright/lib/index.js +827 -0
  70. package/node_modules/playwright/lib/isomorphic.js +260 -0
  71. package/node_modules/playwright/lib/isomorphic.js.txt +9 -0
  72. package/node_modules/playwright/lib/loader/loaderProcessEntry.js +34 -0
  73. package/node_modules/playwright/lib/loader/loaderProcessEntry.js.txt +9 -0
  74. package/node_modules/playwright/lib/matchers/expect.js +13496 -0
  75. package/node_modules/playwright/lib/matchers/expect.js.LICENSE +640 -0
  76. package/node_modules/playwright/lib/matchers/expect.js.txt +67 -0
  77. package/node_modules/playwright/lib/package.js +47 -0
  78. package/node_modules/playwright/lib/program.js +242 -0
  79. package/node_modules/playwright/lib/runner/index.js +8721 -0
  80. package/node_modules/playwright/lib/runner/index.js.txt +62 -0
  81. package/node_modules/playwright/lib/transform/babelBundle.js +72490 -0
  82. package/node_modules/playwright/lib/transform/babelBundle.js.LICENSE +2384 -0
  83. package/node_modules/playwright/lib/transform/babelBundle.js.txt +328 -0
  84. package/node_modules/playwright/lib/transform/esmLoader.js +8066 -0
  85. package/node_modules/playwright/lib/transform/esmLoader.js.LICENSE +355 -0
  86. package/node_modules/playwright/lib/transform/esmLoader.js.txt +60 -0
  87. package/node_modules/playwright/lib/util.js +373 -0
  88. package/node_modules/playwright/lib/worker/workerProcessEntry.js +1860 -0
  89. package/node_modules/playwright/lib/worker/workerProcessEntry.js.txt +19 -0
  90. package/node_modules/playwright/package.json +50 -0
  91. package/node_modules/playwright/test.d.ts +18 -0
  92. package/node_modules/playwright/test.js +24 -0
  93. package/node_modules/playwright/test.mjs +35 -0
  94. package/node_modules/playwright/types/test.d.ts +11191 -0
  95. package/node_modules/playwright/types/testReporter.d.ts +950 -0
  96. package/node_modules/playwright-core/LICENSE +202 -0
  97. package/node_modules/playwright-core/NOTICE +5 -0
  98. package/node_modules/playwright-core/README.md +3 -0
  99. package/node_modules/playwright-core/ThirdPartyNotices.txt +13 -0
  100. package/node_modules/playwright-core/bin/install_media_pack.ps1 +5 -0
  101. package/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +33 -0
  102. package/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +42 -0
  103. package/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +13 -0
  104. package/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +24 -0
  105. package/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +42 -0
  106. package/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +12 -0
  107. package/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +24 -0
  108. package/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +48 -0
  109. package/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +11 -0
  110. package/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +23 -0
  111. package/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +48 -0
  112. package/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +11 -0
  113. package/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +23 -0
  114. package/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +48 -0
  115. package/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +11 -0
  116. package/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +24 -0
  117. package/node_modules/playwright-core/browsers.json +52 -0
  118. package/node_modules/playwright-core/cli.js +22 -0
  119. package/node_modules/playwright-core/index.d.ts +17 -0
  120. package/node_modules/playwright-core/index.js +17 -0
  121. package/node_modules/playwright-core/index.mjs +28 -0
  122. package/node_modules/playwright-core/lib/bootstrap.js +149 -0
  123. package/node_modules/playwright-core/lib/coreBundle.js +78041 -0
  124. package/node_modules/playwright-core/lib/entry/cliDaemon.js +5 -0
  125. package/node_modules/playwright-core/lib/entry/dashboardApp.js +3 -0
  126. package/node_modules/playwright-core/lib/entry/mcp.js +10 -0
  127. package/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +3 -0
  128. package/node_modules/playwright-core/lib/package.js +50 -0
  129. package/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
  130. package/node_modules/playwright-core/lib/server/electron/loader.js +123 -0
  131. package/node_modules/playwright-core/lib/serverRegistry.js +1939 -0
  132. package/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +65 -0
  133. package/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +141 -0
  134. package/node_modules/playwright-core/lib/tools/cli-client/cli.js +7 -0
  135. package/node_modules/playwright-core/lib/tools/cli-client/help.json +808 -0
  136. package/node_modules/playwright-core/lib/tools/cli-client/minimist.js +128 -0
  137. package/node_modules/playwright-core/lib/tools/cli-client/output.js +352 -0
  138. package/node_modules/playwright-core/lib/tools/cli-client/program.js +422 -0
  139. package/node_modules/playwright-core/lib/tools/cli-client/registry.js +180 -0
  140. package/node_modules/playwright-core/lib/tools/cli-client/session.js +261 -0
  141. package/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
  142. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/SKILL.md +493 -0
  143. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
  144. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
  145. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
  146. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
  147. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
  148. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
  149. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
  150. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
  151. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
  152. package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
  153. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
  154. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
  155. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
  156. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
  157. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
  158. package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
  159. package/node_modules/playwright-core/lib/tools/skills/playwright-trace/SKILL.md +174 -0
  160. package/node_modules/playwright-core/lib/tools/utils/extension.js +112 -0
  161. package/node_modules/playwright-core/lib/tools/utils/socketConnection.js +108 -0
  162. package/node_modules/playwright-core/lib/utilsBundle.js +86078 -0
  163. package/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +1890 -0
  164. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
  165. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
  166. package/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  167. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
  168. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
  169. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
  170. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
  171. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
  172. package/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
  173. package/node_modules/playwright-core/lib/vite/dashboard/index.html +29 -0
  174. package/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +24 -0
  175. package/node_modules/playwright-core/lib/vite/htmlReport/index.html +16 -0
  176. package/node_modules/playwright-core/lib/vite/htmlReport/report.css +2 -0
  177. package/node_modules/playwright-core/lib/vite/htmlReport/report.js +32 -0
  178. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
  179. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +32 -0
  180. package/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  181. package/node_modules/playwright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
  182. package/node_modules/playwright-core/lib/vite/recorder/assets/index-Cn0mmDuv.js +129 -0
  183. package/node_modules/playwright-core/lib/vite/recorder/index.html +29 -0
  184. package/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +9 -0
  185. package/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +32 -0
  186. package/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +184 -0
  187. package/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
  188. package/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +7 -0
  189. package/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
  190. package/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  191. package/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
  192. package/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
  193. package/node_modules/playwright-core/lib/vite/traceViewer/index.html +44 -0
  194. package/node_modules/playwright-core/lib/vite/traceViewer/index.oNry3Hjv.js +1 -0
  195. package/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +16 -0
  196. package/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +9 -0
  197. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
  198. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +10 -0
  199. package/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +4 -0
  200. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CYwC_gH1.js +5 -0
  201. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
  202. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +18 -0
  203. package/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
  204. package/node_modules/playwright-core/lib/webp_codec.LICENSE +173 -0
  205. package/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
  206. package/node_modules/playwright-core/lib/xdg-open +1267 -0
  207. package/node_modules/playwright-core/package.json +34 -0
  208. package/node_modules/playwright-core/types/protocol.d.ts +24776 -0
  209. package/node_modules/playwright-core/types/structs.d.ts +52 -0
  210. package/node_modules/playwright-core/types/types.d.ts +27167 -0
  211. package/package.json +10 -8
  212. package/plugin.mjs +13 -1
  213. package/server/activate-log.mjs +66 -0
  214. package/server/contract.mjs +1 -1
  215. package/server/embedded-host.mjs +23 -2
  216. package/server/engine.mjs +11 -4
  217. package/server/routes/api.mjs +2 -2
  218. package/server/shared/SHARED_MANIFEST.json +4 -4
  219. package/server/workbench-framework.mjs +34 -0
  220. package/ui/app.js +87 -10
@@ -12,8 +12,14 @@ import { validateToolArguments } from '@capyclaw/plugin-kit/tools/validate'
12
12
  import { normalizeToolResult, resultText } from '@capyclaw/plugin-kit/tools/result'
13
13
  import { createServiceApi } from '@capyclaw/plugin-kit/service/api'
14
14
  import { createDescriptorRegistry } from './descriptors.mjs'
15
+ import { createModeGate } from './mode-gate.mjs'
16
+ import { runWithCallerSession, currentCallerSession } from './caller-session.mjs'
17
+ import { admitToolResultImages, resolveAttachments } from './admit-images.mjs'
15
18
 
19
+ export { admitToolResultImages, resolveAttachments } from './admit-images.mjs'
16
20
  export { createDescriptorRegistry } from './descriptors.mjs'
21
+ export { createModeGate } from './mode-gate.mjs'
22
+ export { runWithCallerSession, currentCallerSession } from './caller-session.mjs'
17
23
 
18
24
  const KINDS = new Set(['read', 'write', 'control'])
19
25
 
@@ -23,12 +29,13 @@ export function defineTool({
23
29
  inputSchema = { type: 'object', properties: {}, additionalProperties: false },
24
30
  kind = 'write',
25
31
  since = '1.0.0',
32
+ domain = '',
26
33
  handler,
27
34
  } = {}) {
28
35
  if (!name || typeof name !== 'string') throw new Error('defineTool 需要 name')
29
36
  if (typeof handler !== 'function') throw new Error(`工具 ${name} 需要 handler`)
30
37
  if (!KINDS.has(kind)) throw new Error(`工具 ${name} 的 kind 非法: ${kind}`)
31
- return Object.freeze({ name, description, inputSchema, kind, since, handler })
38
+ return Object.freeze({ name, description, inputSchema, kind, since, domain: String(domain || ''), handler })
32
39
  }
33
40
 
34
41
  export function defineCapability({
@@ -40,6 +47,7 @@ export function defineCapability({
40
47
  dependsOn = [],
41
48
  provides = {},
42
49
  features = [],
50
+ domain = '',
43
51
  tools = [],
44
52
  } = {}) {
45
53
  if (!id || typeof id !== 'string') throw new Error('defineCapability 需要 id')
@@ -53,6 +61,7 @@ export function defineCapability({
53
61
  dependsOn: Object.freeze([...dependsOn]),
54
62
  provides: Object.freeze({ ...provides }),
55
63
  features: Object.freeze([...features]),
64
+ domain: String(domain || ''),
56
65
  tools: Object.freeze([...tools]),
57
66
  })
58
67
  }
@@ -99,7 +108,7 @@ function selectCapabilities(capabilities, enabled) {
99
108
  * @param {Array} capabilities
100
109
  * @param {{ enabled?: string[], ports?: object, report?: Function, reserved?: string[] }} options
101
110
  */
102
- export function createRegistry(capabilities, { enabled = null, ports = null, report = null, reserved = [] } = {}) {
111
+ export function createRegistry(capabilities, { enabled = null, ports = null, report = null, reserved = [], domain = '' } = {}) {
103
112
  validateCapabilities(capabilities)
104
113
  const selected = selectCapabilities(capabilities, enabled)
105
114
 
@@ -145,11 +154,12 @@ export function createRegistry(capabilities, { enabled = null, ports = null, rep
145
154
  title: cap.title,
146
155
  description: cap.description,
147
156
  tags: [...cap.tags],
157
+ domain: cap.domain || domain || '',
148
158
  tools: cap.tools.map((tool) => tool.name),
149
159
  })
150
160
  for (const tool of cap.tools) {
151
161
  TOOLS.push({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema })
152
- TOOL_META[tool.name] = { kind: tool.kind, since: tool.since, capability: cap.id }
162
+ TOOL_META[tool.name] = { kind: tool.kind, since: tool.since, capability: cap.id, domain: tool.domain || cap.domain || domain || '' }
153
163
  TOOL_IMPL[tool.name] = (args) => tool.handler(args || {}, ctx)
154
164
  }
155
165
  }
@@ -174,7 +184,7 @@ export function createRegistry(capabilities, { enabled = null, ports = null, rep
174
184
  if (typeof tool.handler !== 'function') throw new Error(`工具 ${tool.name} 需要 handler`)
175
185
  if (TOOL_IMPL[tool.name]) throw new Error(`工具已存在: ${tool.name}`)
176
186
  TOOLS.push({ name: tool.name, description: tool.description || '', inputSchema: tool.inputSchema || { type: 'object', properties: {} } })
177
- TOOL_META[tool.name] = { kind: tool.kind || 'write', since: tool.since || '1.0.0', capability: capabilityId }
187
+ TOOL_META[tool.name] = { kind: tool.kind || 'write', since: tool.since || '1.0.0', capability: capabilityId, domain: tool.domain || domain || '' }
178
188
  TOOL_IMPL[tool.name] = (args) => tool.handler(args || {}, ctx)
179
189
  return true
180
190
  }
@@ -341,17 +351,39 @@ export function buildInstructions({
341
351
  *
342
352
  * @param {object} ctx DSH cordis context
343
353
  * @param {object} registry createRegistry() 的返回值
344
- * @param {{ namespace?: string }} options
354
+ * @param {{ namespace?: string, domain?: string, modeGate?: object }} options
355
+ * domain:本 registry 的兜底领域(工具/能力未各自声明时用);
356
+ * modeGate:会话模式锁闸(createToolHost 服务级自动注入;独立调用可显式传)。
345
357
  * @returns {() => void} 反注册全部工具
346
358
  */
347
- export function registerWithDsh(ctx, registry, { namespace = '' } = {}) {
359
+ export function registerWithDsh(ctx, registry, { namespace = '', domain = '', modeGate = null } = {}) {
348
360
  if (!ctx?.tools?.register) throw new Error('registerWithDsh: 当前 DSH 没有 ctx.tools.register')
361
+ /* 领域工具一旦注册即声明给模式锁,并挂全局 guard 兜底(幂等)。
362
+ * install 的引用计数 disposer 必须随本次注册一起释放(旧写法丢弃⇒核心工具/guard 泄漏)。 */
363
+ const gateDispose = modeGate ? modeGate.install(ctx.tools) : null
349
364
  const disposers = []
365
+ if (typeof gateDispose === 'function') disposers.push(gateDispose)
366
+ /* 感知闸补挂(幂等):driver apply 那一刻 systemPrompt 可能尚未就绪,套件注册时再挂一次。
367
+ * 引用计数 disposer 随本次注册一起释放。cordis 服务缺席时访问可能抛错,try 包裹降级。 */
368
+ if (modeGate && typeof modeGate.installPrompt === 'function') {
369
+ let systemPrompt = null
370
+ try { systemPrompt = ctx.systemPrompt } catch { systemPrompt = null }
371
+ if (systemPrompt && typeof systemPrompt.section === 'function') {
372
+ const promptDispose = modeGate.installPrompt(systemPrompt)
373
+ if (typeof promptDispose === 'function') disposers.push(promptDispose)
374
+ }
375
+ }
350
376
  try {
351
377
  for (const tool of registry?.TOOLS || []) {
352
378
  const impl = registry.TOOL_IMPL?.[tool.name]
353
379
  if (typeof impl !== 'function') throw new Error(`registerWithDsh: 工具缺少实现 ${tool.name}`)
354
380
  const name = namespace ? `${namespace}_${tool.name}` : tool.name
381
+ const toolDomain = registry.TOOL_META?.[tool.name]?.domain || domain || ''
382
+ let when
383
+ if (modeGate && toolDomain) {
384
+ modeGate.declareTools(toolDomain, [name])
385
+ when = modeGate.whenFor(name)
386
+ }
355
387
  disposers.push(ctx.tools.register({
356
388
  name,
357
389
  description: tool.description || '',
@@ -364,16 +396,20 @@ export function registerWithDsh(ctx, registry, { namespace = '' } = {}) {
364
396
  ? value.content
365
397
  : normalizeToolResult(value).content),
366
398
  },
367
- execute: async (args, exec) => {
399
+ execute: async (args, exec) => runWithCallerSession(exec?.agent?.session?.id, async () => {
368
400
  const normalized = normalizeToolResult(await impl(args, exec))
369
401
  /* DSH 原生面成功恒 isError:false,失败必须 throw 才走错误路径(B 轴 P0-1)。
370
402
  * 把工具自报的 isError:true 转成 throw,与 MCP 面的失败语义对齐。 */
371
403
  if (normalized.isError === true) {
372
404
  throw new Error(resultText(normalized) || `工具 ${name} 执行失败`)
373
405
  }
374
- return normalized
375
- },
376
- }))
406
+ /* 图像准入:裸 base64 图像块(rsp_screen/browser_screenshot 等)必须先持久化成
407
+ * attachment ref 再入 session 日志,否则下一步序列化读 block.attachment.attachmentId
408
+ * 抛错、永久毒化该会话(2026-11-22 根因)。MCP 面不走这里,保留 wire 形态。 */
409
+ const content = await admitToolResultImages(normalized.content, resolveAttachments(exec, ctx), { name })
410
+ return { ...normalized, content }
411
+ }),
412
+ }, when ? { when } : {}))
377
413
  }
378
414
  } catch (error) {
379
415
  /* 全有或全无:任一工具注册失败,逆序释放已注册的,避免部分注册泄漏(B 轴 P0-6)。 */
@@ -392,9 +428,14 @@ export function registerWithDsh(ctx, registry, { namespace = '' } = {}) {
392
428
  export function createToolHost(config = {}) {
393
429
  // 跨套件能力发现注册表(互联标准 §A.4/§E)。深度校验器可选注入(suite-kit)。
394
430
  const descriptors = createDescriptorRegistry({ validate: config.validateDescriptor })
431
+ // 会话模式锁:全服务共享一个闸实例(所有套件的注册都经此)。getWorkStore 惰性解析
432
+ // (driver 注入 () => safeGet(ctx,'workStore'));底座缺席则降级为恒可见、不拒。
433
+ const modeGate = createModeGate({ getWorkStore: config.getWorkStore })
395
434
  return {
396
- api: createServiceApi('toolHost', '1.1.0', ['dsl', 'registry', 'validate', 'contract', 'mcp', 'instructions', 'native-tools', 'descriptors']),
397
- version: '0.2.0',
435
+ // M12 对齐:自报以 package.json 为权威——dsh.apiVersion=1.1.0(对外契约,
436
+ // 消费者 assertServiceApi 只断言 major 1),version=0.3.1。旧自报 1.2.0/0.3.0 是漂移。
437
+ api: createServiceApi('toolHost', '1.1.0', ['dsl', 'registry', 'validate', 'contract', 'mcp', 'instructions', 'native-tools', 'descriptors', 'mode-gate']),
438
+ version: '0.3.1',
398
439
  defineTool,
399
440
  defineCapability,
400
441
  createRegistry: (capabilities, options = {}) => createRegistry(capabilities, { ...config, ...options }),
@@ -402,12 +443,16 @@ export function createToolHost(config = {}) {
402
443
  createToolDispatcher,
403
444
  createCapabilityReport,
404
445
  buildInstructions,
405
- registerWithDsh,
446
+ // 服务级注册自动带会话模式锁(when 可见性 + guard 硬拒 + 感知提示 + 调用者会话 ALS),套件零接线。
447
+ registerWithDsh: (ctx, registry, options = {}) => registerWithDsh(ctx, registry, { modeGate, ...options }),
406
448
  validateToolArguments,
449
+ modeGate,
407
450
  // 能力描述符注册/发现(编排器按类型动态发现,套件零互依赖)。
408
451
  registerCapabilityDescriptor: (descriptor, options) => descriptors.register(descriptor, options),
409
452
  unregisterCapabilityDescriptor: (name) => descriptors.unregister(name),
410
- discoverCapabilities: (query) => descriptors.discover(query),
453
+ // 发现面按调用者会话过滤:原生工具调用里自动从 ALS 取会话(conductor_discover 无需接线);
454
+ // HTTP/墙等管理面无会话 → 不过滤(全局视图)。query.sessionId 可显式覆盖。
455
+ discoverCapabilities: (query = {}) => modeGate.filterEntries(descriptors.discover(query), query.sessionId || currentCallerSession()),
411
456
  capabilityCatalog: () => descriptors.catalog(),
412
457
  listSurfaces: () => descriptors.listSurfaces(),
413
458
  }
@@ -0,0 +1,272 @@
1
+ /**
2
+ * 会话模式锁 —— 工具面标准框架的强制闸(基础设施能力,非各套件自接)。
3
+ *
4
+ * 设计目标(用户诉求):锁定一种工作模式(如 rsp)后,本会话只看得见、调得动
5
+ * 该领域的工具;其余已注册能力(browser_* 等)从工具声明里消失,且即便被强行
6
+ * 调用也在分发层硬拒。所有经 tool-host 注册的能力自动受此约束。
7
+ *
8
+ * 三道原生闸在此全部落地:
9
+ * · when(可见性):registerWithDsh / bridge host 给每个领域工具挂 whenFor(name),
10
+ * DSH 每步 resolve() 求值,false 同时从声明与分发中排除该工具。
11
+ * · guard(分发硬拒,兜底):install(tools) 挂一个全局 ToolGuard,异领域调用返回
12
+ * denial。单调不可翻回,兜住任何绕过 when 的路径。
13
+ * · awareness(模型感知):installPrompt(systemPrompt) 注册一个动态提示 section,
14
+ * 每次组装按会话读锁状态,锁定即告知模型「主区工作台是唯一交付界面、用本领域
15
+ * 工具、勿用文件工具绕过」。缺了这道闸,when/guard 只挡得住领域工具,模型仍会
16
+ * 用无 domain 的内置文件工具(write/pwsh/office_*)绕过主区(2026-11-23 根因)。
17
+ *
18
+ * 领域来源:TOOL_META.domain(defineTool/defineCapability/createRegistry 声明)。
19
+ * 存储真源:work-store.getSessionMode(sid)(终生固化,无 unlock)。
20
+ * 降级:无 workStore / 无 sid / 未锁定 → 恒可见、不拒(与既有“底座缺席不启用”一致)。
21
+ * 无 domain 的工具(conductor/capyclaw/框架核心 mode_*)恒可见,不受锁限制。
22
+ */
23
+
24
+ /**
25
+ * @param {{ getWorkStore?: () => object|null }} deps
26
+ */
27
+ export function createModeGate({ getWorkStore } = {}) {
28
+ const domainByTool = new Map() // 原生工具名 → domain
29
+ const domainBySuite = new Map() // 套件名 → domain(描述符发现面按 suite 兜底)
30
+ const lockCache = new Map() // sid → kind(锁终生固化,一旦落定永不变更,可缓存)
31
+ let guardInstalled = false
32
+ const guardDisposers = []
33
+ let coreToolsRegistered = false
34
+ const coreDisposers = []
35
+ let installRefs = 0 // 安装方引用计数(见 install 注释)
36
+ let promptInstalled = false // 感知闸:动态提示 section 是否已注册
37
+ const promptDisposers = []
38
+ let promptRefs = 0 // 感知闸安装方引用计数(与 install 同语义)
39
+
40
+ function store() {
41
+ try { return typeof getWorkStore === 'function' ? getWorkStore() : null } catch { return null }
42
+ }
43
+
44
+ /** 当前会话锁定的工作模式 kind;未锁定/底座缺席/无 sid → null。 */
45
+ function modeOf(sessionId) {
46
+ const sid = String(sessionId || '').trim()
47
+ if (!sid) return null
48
+ if (lockCache.has(sid)) return lockCache.get(sid)
49
+ const ws = store()
50
+ if (!ws || typeof ws.getSessionMode !== 'function') return null
51
+ let rec = null
52
+ try { rec = ws.getSessionMode(sid) } catch { return null }
53
+ const kind = rec && rec.kind ? String(rec.kind) : null
54
+ if (kind) lockCache.set(sid, kind) // 只缓存已落定的锁;null 不缓存(可能稍后被认领)
55
+ return kind
56
+ }
57
+
58
+ /** 领域工具在指定会话里是否可见。无 domain / 未锁定 / 同领域 → 可见。 */
59
+ function isVisible(domain, sessionId) {
60
+ if (!domain) return true
61
+ const lock = modeOf(sessionId)
62
+ return !lock || domain === lock
63
+ }
64
+
65
+ /** 声明一组工具属于某领域(registerWithDsh / bridge host 注册时调用)。 */
66
+ function declareTools(domain, names = [], suite = domain) {
67
+ const d = String(domain || '').trim()
68
+ if (!d) return
69
+ for (const name of names || []) {
70
+ if (name) domainByTool.set(String(name), d)
71
+ }
72
+ if (suite) domainBySuite.set(String(suite), d)
73
+ }
74
+
75
+ /** 某工具的领域;未声明 → ''(恒可见)。 */
76
+ function domainOf(name) {
77
+ return domainByTool.get(String(name)) || ''
78
+ }
79
+
80
+ /**
81
+ * DSH register 的 when 条件。未声明领域的工具返回 undefined(不挂 when,恒可见,
82
+ * 也避免给内置/核心工具增加每步求值开销)。
83
+ * @returns {((context: object) => boolean)|undefined}
84
+ */
85
+ function whenFor(name) {
86
+ const domain = domainOf(name)
87
+ if (!domain) return undefined
88
+ return (context) => isVisible(domain, context?.agent?.session?.id)
89
+ }
90
+
91
+ /**
92
+ * 全局 ToolGuard(分发硬拒兜底)。非领域工具立即放行(不读 store,内置工具零开销);
93
+ * 领域工具在异领域锁定的会话里返回 denial。
94
+ * @returns {{reason: string, info: object}|undefined}
95
+ */
96
+ function guard(execution) {
97
+ const name = execution?.name
98
+ const domain = domainByTool.get(String(name))
99
+ if (!domain) return undefined
100
+ const lock = modeOf(execution?.agent?.session?.id)
101
+ if (!lock || domain === lock) return undefined
102
+ return {
103
+ reason: `本会话已锁定为「${lock}」工作模式,「${name}」属于「${domain}」领域,已被框架屏蔽。`
104
+ + `请只用「${lock}」领域的工具完成任务;确需其他领域,请新开一个会话。`,
105
+ info: { name: 'SessionModeLocked', code: 'SESSION_MODE_LOCKED', reason: `locked to ${lock}, tool domain ${domain}` },
106
+ }
107
+ }
108
+
109
+ /** 框架核心工具 mode_lock / mode_status(无领域,恒可见)——显式锁定入口与状态查询。
110
+ * 存储经 modeGate 的 getWorkStore 解析(不依赖插件 ctx),故可在任何 tools 就绪时机注册。 */
111
+ function coreTools() {
112
+ const textRender = (_args, value) => [{ type: 'text', text: typeof value === 'string' ? value : JSON.stringify(value, null, 2) }]
113
+ const OUTPUT_SCHEMA = { type: 'object', additionalProperties: true }
114
+ const modeLock = {
115
+ name: 'mode_lock',
116
+ description: '把当前会话锁定到一种工作模式(领域),如 rsp/browser/ppt/canvas。锁定后本会话只看得见、调得动该领域的工具,'
117
+ + '其余领域能力被框架从工具面屏蔽并在分发层硬拒。锁终生固化、不可解锁;确需其他领域请新开一个会话。',
118
+ parameters: {
119
+ type: 'object',
120
+ properties: { kind: { type: 'string', description: '要锁定的工作模式/领域,如 rsp、browser、ppt、canvas' } },
121
+ required: ['kind'],
122
+ additionalProperties: false,
123
+ },
124
+ output: { schema: OUTPUT_SCHEMA, render: textRender },
125
+ execute: async (args, exec) => {
126
+ const kind = String(args?.kind || '').trim()
127
+ if (!kind) return { ok: false, error: '需要 kind(要锁定的工作模式/领域)' }
128
+ const sid = exec?.agent?.session?.id
129
+ if (!sid) return { ok: false, error: '无法识别当前会话,不能锁定' }
130
+ const ws = store()
131
+ if (!ws || typeof ws.claimSessionMode !== 'function') return { ok: false, error: 'work-store 底座缺席,无法锁定' }
132
+ const res = ws.claimSessionMode(sid, kind, 'mode-lock', { explicit: true })
133
+ if (res && res.ok === false) {
134
+ return { ok: false, lockedTo: res.lockedTo, error: `本会话已固化为「${res.lockedTo}」模式,不能改为「${kind}」。确需其他领域请新开一个会话。` }
135
+ }
136
+ return {
137
+ ok: true, kind: res.kind, fresh: !!res.fresh, explicit: true,
138
+ message: res.fresh ? `已锁定为「${res.kind}」工作模式,本会话此后只用该领域工具。` : `本会话已处于「${res.kind}」工作模式。`,
139
+ }
140
+ },
141
+ }
142
+ const modeStatus = {
143
+ name: 'mode_status',
144
+ description: '查询当前会话的工作模式锁状态:是否锁定、锁定到哪个领域、由谁何时认领。未锁定时所有领域工具可见。',
145
+ parameters: { type: 'object', properties: {}, additionalProperties: false },
146
+ output: { schema: OUTPUT_SCHEMA, render: textRender },
147
+ execute: async (_args, exec) => {
148
+ const sid = exec?.agent?.session?.id
149
+ const ws = store()
150
+ if (!ws || typeof ws.getSessionMode !== 'function') return { locked: false, reason: 'work-store 底座缺席' }
151
+ if (!sid) return { locked: false, reason: '无法识别当前会话' }
152
+ const rec = ws.getSessionMode(sid)
153
+ if (!rec) return { locked: false, kind: null, message: '本会话未锁定工作模式,所有领域工具可见。' }
154
+ return {
155
+ locked: true, kind: rec.kind, claimedBy: rec.claimedBy || '', claimedAt: rec.claimedAt || '', explicit: !!rec.explicit,
156
+ message: `本会话已锁定为「${rec.kind}」工作模式,其余领域工具已被屏蔽。`,
157
+ }
158
+ },
159
+ }
160
+ return [modeLock, modeStatus]
161
+ }
162
+
163
+ /** 把 guard + 核心锁定工具挂到 DSH tools 服务(幂等)。每个套件在 tools 就绪时都会调用,
164
+ * 故核心工具注册不依赖 tool-host driver apply 那一刻 tools 是否已就绪(加载顺序鲁棒)。返回 disposer。
165
+ * 引用计数:多个安装方(driver apply / 各套件 registerWithDsh)共享同一份核心注册,
166
+ * 任一安装方卸载只减引用;最后一个释放才真正摘 guard + 核心工具,避免「丢 disposer」泄漏
167
+ * 与「先卸载者拆掉幸存者底座」两种事故。 */
168
+ function install(tools) {
169
+ if (!tools) return () => {}
170
+ if (!guardInstalled && typeof tools.guard === 'function') {
171
+ try {
172
+ const dispose = tools.guard(guard)
173
+ if (typeof dispose === 'function') guardDisposers.push(dispose)
174
+ guardInstalled = true
175
+ } catch { /* 底座不支持 guard 时降级:仅 when 生效 */ }
176
+ }
177
+ if (!coreToolsRegistered && typeof tools.register === 'function') {
178
+ for (const tool of coreTools()) {
179
+ try {
180
+ const d = tools.register(tool)
181
+ if (typeof d === 'function') coreDisposers.push(d)
182
+ } catch (err) {
183
+ console.warn(`[tool-host] 注册核心工具 ${tool.name} 失败:`, err?.message || err)
184
+ }
185
+ }
186
+ coreToolsRegistered = true
187
+ }
188
+ installRefs++
189
+ let released = false
190
+ return () => {
191
+ if (released) return
192
+ released = true
193
+ installRefs--
194
+ if (installRefs > 0) return
195
+ for (const dispose of guardDisposers.splice(0)) {
196
+ try { dispose() } catch { /* 忽略重复释放 */ }
197
+ }
198
+ for (const dispose of coreDisposers.splice(0)) {
199
+ try { dispose() } catch { /* 忽略重复释放 */ }
200
+ }
201
+ guardInstalled = false
202
+ coreToolsRegistered = false
203
+ }
204
+ }
205
+
206
+ /**
207
+ * 感知闸文本:锁定会话里注入系统提示,让模型知道主区工作台的存在与唯一交付地位。
208
+ * 只约束「工作台内容任务」的交付路径,不禁止为修插件/查资料等元任务读文件。
209
+ */
210
+ function awarenessText(kind) {
211
+ return `【会话工作模式锁】本会话已锁定为「${kind}」工作模式:GUI 主区界面就是「${kind}」工作台,它是本会话工作台内容任务的指定交付界面。\n`
212
+ + `- 用户要求创作/编辑文档、稿件等工作台内容时,必须用 ${kind}_* 专用工具直接读写主区工作台(先加载 ${kind} 相关 skill),让用户在主区实时看到结果。\n`
213
+ + `- 不得改用 write/pwsh/office_* 等通用文件工具生成独立文件来绕过主区交付;其他领域的工具与技能不适用于本会话。\n`
214
+ + `- 锁终生固化、不可解锁;确需其他领域,请提示用户新开会话。锁状态可用 mode_status 查询。`
215
+ }
216
+
217
+ /**
218
+ * 感知闸:把锁状态作为动态系统提示 section 挂到 DSH systemPrompt 服务(幂等)。
219
+ * text 回调每次 assemble 求值(DSH 每步组装提示时调用),按 context.agent.session.id
220
+ * 读锁:锁定 → 注入感知文本;未锁定/无会话 → 返回 ''(空 section 自动消失,零开销)。
221
+ * 锁可在会话中途被认领(墙上点选),回调动态读取故无需监听 agent 生命周期。
222
+ * 引用计数与 install(tools) 同语义:driver apply 与各套件 registerWithDsh 共享一份注册。
223
+ * 底座缺席(无 systemPrompt / 不支持 section)→ 降级为仅 when/guard 生效。
224
+ * @returns {() => void} 引用计数 disposer
225
+ */
226
+ function installPrompt(systemPrompt) {
227
+ if (!systemPrompt || typeof systemPrompt.section !== 'function') return () => {}
228
+ if (!promptInstalled) {
229
+ try {
230
+ const dispose = systemPrompt.section({
231
+ name: 'capyclaw:session-mode-lock',
232
+ order: 900,
233
+ interpolate: false,
234
+ text: (context) => {
235
+ const kind = modeOf(context?.agent?.session?.id)
236
+ return kind ? awarenessText(kind) : ''
237
+ },
238
+ })
239
+ if (typeof dispose === 'function') promptDisposers.push(dispose)
240
+ promptInstalled = true
241
+ } catch { /* 底座不支持 section 时降级:仅 when/guard 生效 */ }
242
+ }
243
+ promptRefs++
244
+ let released = false
245
+ return () => {
246
+ if (released) return
247
+ released = true
248
+ promptRefs--
249
+ if (promptRefs > 0) return
250
+ for (const dispose of promptDisposers.splice(0)) {
251
+ try { dispose() } catch { /* 忽略重复释放 */ }
252
+ }
253
+ promptInstalled = false
254
+ }
255
+ }
256
+
257
+ /**
258
+ * 能力发现面过滤:锁定会话里剔除异领域描述符(conductor_discover 自动受约束)。
259
+ * 无 domain 的描述符(编排/核心基建)保留。未锁定 → 原样返回。
260
+ */
261
+ function filterEntries(entries, sessionId) {
262
+ const lock = modeOf(sessionId)
263
+ if (!lock) return entries
264
+ return (entries || []).filter((entry) => {
265
+ const d = entry?.descriptor || {}
266
+ const domain = domainByTool.get(String(d.tool || d.name)) || domainBySuite.get(String(entry?.suite)) || ''
267
+ return !domain || domain === lock
268
+ })
269
+ }
270
+
271
+ return { declareTools, domainOf, modeOf, isVisible, whenFor, guard, install, installPrompt, filterEntries }
272
+ }
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Portions Copyright (c) Microsoft Corporation.
190
+ Portions Copyright 2017 Google Inc.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ Playwright
2
+ Copyright (c) Microsoft Corporation
3
+
4
+ This software contains code derived from the Puppeteer project (https://github.com/puppeteer/puppeteer),
5
+ available under the Apache 2.0 license (https://github.com/puppeteer/puppeteer/blob/master/LICENSE).