@anweat/dsh-browser 0.1.15 → 0.2.0-rc.1

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 (162) hide show
  1. package/README.md +272 -75
  2. package/assets/skills/dsh-browser/SKILL.md +120 -0
  3. package/assets/skills/dsh-browser/references/develop.md +48 -0
  4. package/assets/skills/dsh-browser/references/observe.md +91 -0
  5. package/assets/skills/dsh-browser/references/opencli.md +25 -0
  6. package/assets/skills/dsh-browser/references/recipes.md +149 -0
  7. package/assets/skills/dsh-browser/references/userscripts.md +44 -0
  8. package/cordis.patch.yml +4 -0
  9. package/lib/actions/act.d.ts +3 -0
  10. package/lib/actions/act.js +147 -0
  11. package/lib/actions/act.js.map +1 -0
  12. package/lib/actions/automation.d.ts +3 -0
  13. package/lib/actions/automation.js +356 -0
  14. package/lib/actions/automation.js.map +1 -0
  15. package/lib/actions/crawl.d.ts +3 -0
  16. package/lib/actions/crawl.js +28 -0
  17. package/lib/actions/crawl.js.map +1 -0
  18. package/lib/actions/errors.d.ts +53 -0
  19. package/lib/actions/errors.js +178 -0
  20. package/lib/actions/errors.js.map +1 -0
  21. package/lib/actions/index-view.d.ts +42 -0
  22. package/lib/actions/index-view.js +268 -0
  23. package/lib/actions/index-view.js.map +1 -0
  24. package/lib/actions/inspect.d.ts +3 -0
  25. package/lib/actions/inspect.js +35 -0
  26. package/lib/actions/inspect.js.map +1 -0
  27. package/lib/actions/observe.d.ts +3 -0
  28. package/lib/actions/observe.js +121 -0
  29. package/lib/actions/observe.js.map +1 -0
  30. package/lib/actions/opencli.d.ts +3 -0
  31. package/lib/actions/opencli.js +51 -0
  32. package/lib/actions/opencli.js.map +1 -0
  33. package/lib/actions/registry.d.ts +35 -0
  34. package/lib/actions/registry.js +89 -0
  35. package/lib/actions/registry.js.map +1 -0
  36. package/lib/actions/run.d.ts +34 -0
  37. package/lib/actions/run.js +226 -0
  38. package/lib/actions/run.js.map +1 -0
  39. package/lib/actions/runtime.d.ts +3 -0
  40. package/lib/actions/runtime.js +33 -0
  41. package/lib/actions/runtime.js.map +1 -0
  42. package/lib/actions/schema.d.ts +31 -0
  43. package/lib/actions/schema.js +309 -0
  44. package/lib/actions/schema.js.map +1 -0
  45. package/lib/actions/script.d.ts +3 -0
  46. package/lib/actions/script.js +97 -0
  47. package/lib/actions/script.js.map +1 -0
  48. package/lib/actions/shared.d.ts +31 -0
  49. package/lib/actions/shared.js +45 -0
  50. package/lib/actions/shared.js.map +1 -0
  51. package/lib/actions/surface.d.ts +22 -0
  52. package/lib/actions/surface.js +18 -0
  53. package/lib/actions/surface.js.map +1 -0
  54. package/lib/actions/target.d.ts +3 -0
  55. package/lib/actions/target.js +66 -0
  56. package/lib/actions/target.js.map +1 -0
  57. package/lib/actions/types.d.ts +181 -0
  58. package/lib/actions/types.js +48 -0
  59. package/lib/actions/types.js.map +1 -0
  60. package/lib/activation-rules.d.ts +29 -0
  61. package/lib/activation-rules.js +33 -0
  62. package/lib/activation-rules.js.map +1 -0
  63. package/lib/approval-policy.d.ts +40 -2
  64. package/lib/approval-policy.js +184 -97
  65. package/lib/approval-policy.js.map +1 -1
  66. package/lib/automation-assets-rpc.d.ts +8 -2
  67. package/lib/automation-assets-rpc.js +67 -6
  68. package/lib/automation-assets-rpc.js.map +1 -1
  69. package/lib/automation-assets.d.ts +152 -4
  70. package/lib/automation-assets.js +255 -15
  71. package/lib/automation-assets.js.map +1 -1
  72. package/lib/automation-convert.d.ts +23 -0
  73. package/lib/automation-convert.js +110 -0
  74. package/lib/automation-convert.js.map +1 -0
  75. package/lib/automation-development.d.ts +26 -0
  76. package/lib/automation-development.js +47 -0
  77. package/lib/automation-development.js.map +1 -1
  78. package/lib/automation-execution.d.ts +57 -1
  79. package/lib/automation-execution.js +167 -11
  80. package/lib/automation-execution.js.map +1 -1
  81. package/lib/automation-journal.d.ts +92 -0
  82. package/lib/automation-journal.js +449 -0
  83. package/lib/automation-journal.js.map +1 -0
  84. package/lib/automation-v2.d.ts +138 -0
  85. package/lib/automation-v2.js +631 -0
  86. package/lib/automation-v2.js.map +1 -0
  87. package/lib/automation.d.ts +82 -5
  88. package/lib/automation.js +239 -82
  89. package/lib/automation.js.map +1 -1
  90. package/lib/browser-service.d.ts +304 -32
  91. package/lib/browser-service.js +631 -182
  92. package/lib/browser-service.js.map +1 -1
  93. package/lib/client/SettingsCard.js +95 -57
  94. package/lib/client/SettingsCard.js.map +1 -1
  95. package/lib/client/asset-editor.d.ts +55 -0
  96. package/lib/client/asset-editor.js +101 -0
  97. package/lib/client/asset-editor.js.map +1 -0
  98. package/lib/client/automation-assets-client.d.ts +99 -2
  99. package/lib/client/automation-assets-client.js +243 -10
  100. package/lib/client/automation-assets-client.js.map +1 -1
  101. package/lib/client/form.d.ts +48 -4
  102. package/lib/client/form.js +142 -29
  103. package/lib/client/form.js.map +1 -1
  104. package/lib/client/index.d.ts +25 -2
  105. package/lib/client/index.js +5 -1
  106. package/lib/client/index.js.map +1 -1
  107. package/lib/client/locales.d.ts +85 -6
  108. package/lib/client/locales.js +64 -12
  109. package/lib/client/locales.js.map +1 -1
  110. package/lib/client/prompts-form.d.ts +67 -0
  111. package/lib/client/prompts-form.js +140 -0
  112. package/lib/client/prompts-form.js.map +1 -0
  113. package/lib/client/prompts-status-client.d.ts +34 -0
  114. package/lib/client/prompts-status-client.js +53 -0
  115. package/lib/client/prompts-status-client.js.map +1 -0
  116. package/lib/client.js +1914 -329
  117. package/lib/client.js.map +1 -1
  118. package/lib/config.d.ts +50 -1
  119. package/lib/config.js +31 -1
  120. package/lib/config.js.map +1 -1
  121. package/lib/dialogs.d.ts +37 -0
  122. package/lib/dialogs.js +73 -0
  123. package/lib/dialogs.js.map +1 -0
  124. package/lib/freedom.d.ts +23 -7
  125. package/lib/freedom.js +48 -59
  126. package/lib/freedom.js.map +1 -1
  127. package/lib/index.d.ts +4 -4
  128. package/lib/index.js +36 -10
  129. package/lib/index.js.map +1 -1
  130. package/lib/journal.d.ts +109 -0
  131. package/lib/journal.js +238 -0
  132. package/lib/journal.js.map +1 -0
  133. package/lib/locator.d.ts +82 -0
  134. package/lib/locator.js +190 -0
  135. package/lib/locator.js.map +1 -0
  136. package/lib/observe-script.d.ts +27 -0
  137. package/lib/observe-script.js +565 -0
  138. package/lib/observe-script.js.map +1 -0
  139. package/lib/observe.d.ts +179 -0
  140. package/lib/observe.js +368 -0
  141. package/lib/observe.js.map +1 -0
  142. package/lib/policy-keys.d.ts +30 -0
  143. package/lib/policy-keys.js +34 -0
  144. package/lib/policy-keys.js.map +1 -0
  145. package/lib/prompt-limits.d.ts +30 -0
  146. package/lib/prompt-limits.js +31 -0
  147. package/lib/prompt-limits.js.map +1 -0
  148. package/lib/prompts.d.ts +131 -0
  149. package/lib/prompts.js +295 -0
  150. package/lib/prompts.js.map +1 -0
  151. package/lib/skill.d.ts +100 -0
  152. package/lib/skill.js +181 -0
  153. package/lib/skill.js.map +1 -0
  154. package/lib/tool-defs.d.ts +72 -0
  155. package/lib/tool-defs.js +67 -0
  156. package/lib/tool-defs.js.map +1 -0
  157. package/lib/tools.d.ts +19 -4
  158. package/lib/tools.js +124 -922
  159. package/lib/tools.js.map +1 -1
  160. package/package.json +35 -30
  161. package/scripts/dump-prompts.mjs +29 -0
  162. package/scripts/measure-tool-surface.mjs +190 -0
@@ -0,0 +1,35 @@
1
+ /** `inspect` group: captured console and network records. @module dsh-browser/actions/inspect */
2
+ export const INSPECT_ACTIONS = [
3
+ {
4
+ name: 'inspect.console',
5
+ group: 'inspect',
6
+ summary: 'Read bounded, redacted console records captured since the last target.open with capture=["console"].',
7
+ notes: 'Records stay in memory and omit console argument objects.',
8
+ params: {
9
+ level: { type: 'string', enum: ['debug', 'log', 'info', 'warning', 'error'], description: 'Minimum severity. Defaults to debug.' },
10
+ limit: { type: 'number', description: 'Newest 1-200 records. Default 100.' },
11
+ clear: { type: 'boolean', description: 'Clear captured records after reading.' },
12
+ },
13
+ approval: 'none', readOnly: true, mutating: false, concurrencySafe: true, timeoutMs: 10_000,
14
+ examples: [{ args: { level: 'error' } }],
15
+ async execute(args, ctx) {
16
+ return ctx.service.consoleMessages({ ...args, session: ctx.session });
17
+ },
18
+ },
19
+ {
20
+ name: 'inspect.requests',
21
+ group: 'inspect',
22
+ summary: 'Read bounded, redacted failed and HTTP 4xx/5xx requests captured since the last target.open with capture=["network"].',
23
+ notes: 'Request/response bodies and headers are never recorded.',
24
+ params: {
25
+ limit: { type: 'number', description: 'Newest 1-200 records. Default 100.' },
26
+ clear: { type: 'boolean', description: 'Clear captured records after reading.' },
27
+ },
28
+ approval: 'none', readOnly: true, mutating: false, concurrencySafe: true, timeoutMs: 10_000,
29
+ examples: [{ args: {} }],
30
+ async execute(args, ctx) {
31
+ return ctx.service.networkRequests({ ...args, session: ctx.session });
32
+ },
33
+ },
34
+ ];
35
+ //# sourceMappingURL=inspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../src/actions/inspect.ts"],"names":[],"mappings":"AAAA,iGAAiG;AAIjG,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C;QACE,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,sGAAsG;QAC/G,KAAK,EAAE,2DAA2D;QAClE,MAAM,EAAE;YACN,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE;YAClI,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oCAAoC,EAAE;YAC5E,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,uCAAuC,EAAE;SACjF;QACD,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM;QAC3F,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC;QACxC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG;YACrB,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;QACvE,CAAC;KACF;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,uHAAuH;QAChI,KAAK,EAAE,yDAAyD;QAChE,MAAM,EAAE;YACN,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oCAAoC,EAAE;YAC5E,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,uCAAuC,EAAE;SACjF;QACD,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM;QAC3F,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACxB,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG;YACrB,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;QACvE,CAAC;KACF;CACF,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** `observe` group: read the page, take screenshots. @module dsh-browser/actions/observe */
2
+ import { type ActionDef } from './types.ts';
3
+ export declare const OBSERVE_ACTIONS: ActionDef[];
@@ -0,0 +1,121 @@
1
+ /** `observe` group: read the page, take screenshots. @module dsh-browser/actions/observe */
2
+ import { ActionArgError } from "./types.js";
3
+ import { TARGET_PARAMS } from "./schema.js";
4
+ import { targetOf } from "./shared.js";
5
+ import { ObserveArgError, OBSERVE_SECTIONS } from "../observe.js";
6
+ const OBSERVE_TOPICS = {
7
+ controls: {
8
+ summary: 'fields of a controls record',
9
+ text: [
10
+ 'One record per control: input, select, textarea, button, summary, contenteditable, ARIA widget (role=button, checkbox, ...). Radio inputs sharing a name are ONE record with role radiogroup and options. Open shadow DOM and same-origin iframes are searched.',
11
+ 'Use a record directly: browser_call({action:"act.fill",args:{locator:<record.locator>,text:"..."}}).',
12
+ 'A field that is absent was not observed or does not apply; false always means observed and not so.',
13
+ ' role, name, type - accessible role and name; type: input type, select-one, select-multiple, textarea, contenteditable.',
14
+ ' locator - verified on the live page to match this element only; has framePath inside an iframe.',
15
+ ' ambiguous:true - no unique locator exists. If locator is present it matches `matches` elements and this one is the nth (0-based): add index:nth plus an indexReason, or narrow with observe.read locator.',
16
+ ' actions - act.* names that can work now; [] when hidden, disabled, or readonly.',
17
+ ' visible, disabled, readonly, checked (true|false|"mixed"), expanded - states the control has.',
18
+ ' hasValue - not empty. value appears only with includeValues:true, and never for password, hidden, file, or token-like fields (those carry sensitive:true).',
19
+ ' options - select: [{value,label,selected,disabled?}], [] means no options; radiogroup: [{label,value,checked,disabled?,locator}].',
20
+ ' constraints - as declared: required, min, max, step, pattern, minlength, maxlength, accept, multiple.',
21
+ ' validity - {valid, flags?, validationMessage?} from the browser\'s own constraint validation.',
22
+ ' source - dom (native element state) or aria (role and aria-* attributes).',
23
+ 'frames lists each iframe searched; a cross-origin or sandboxed one has crossOrigin:true and its content is not observed (act.* can still use its framePath). Closed shadow roots cannot be read.',
24
+ ].join('\n'),
25
+ },
26
+ links: {
27
+ summary: 'fields of a links record',
28
+ text: [
29
+ 'One record per a[href] / area[href]: {text, href, locator, visible, target?}. href is absolute. locator is verified unique (role link + name, else the href, id, or testId); same-text links get distinct locators or ambiguous:true as for controls (browser_index({action:"observe.read.controls"})). A secret-looking query value (token, secret, password, session, ...) shows as [redacted] and the link gets no href locator.',
30
+ ].join('\n'),
31
+ },
32
+ tables: {
33
+ summary: 'fields of a tables record and coverage',
34
+ text: [
35
+ 'One record per table, or role=table/grid/treegrid element: {name?, locator, headers, rows, totalRows, coverage, reason?, declaredRows?}. rows holds the first maxItems rows as cell text; totalRows is how many rows the DOM holds.',
36
+ 'An empty body is rows:[] and totalRows:0 with its headers: a real empty result, not "not found" (that would be no table record, counts.tables 0).',
37
+ 'coverage:"partial" means the page has more rows than the DOM shows, and reason says why: a virtualized list (aria-rowcount larger than the rendered rows, declaredRows is the declared count) or pagination controls next to the table. Scroll or use the pager (act.*), then observe again. complete only says no such sign was found.',
38
+ ].join('\n'),
39
+ },
40
+ truncation: {
41
+ summary: 'limits, truncation, and sensitive values',
42
+ text: [
43
+ 'maxItems caps each section and each table\'s rows; maxBytes caps the whole result (2000-90000). The result is always valid JSON: whole items or rows are dropped from the end, text is cut at a character.',
44
+ 'truncation:{omittedBySection, reason} appears when anything is missing: content counts characters, tableRows counts rows, controls/links/tables count items. counts has how many the page had. No truncation key means nothing was cut.',
45
+ 'To get the rest: raise maxItems/maxBytes, ask for one section, or scope with locator (a form, a table) or region.',
46
+ 'limits (if present) lists what was not covered, such as cross-origin iframes. generation is the page generation at the start of the scan: pass it as expectGeneration to the next act.*.',
47
+ ].join('\n'),
48
+ },
49
+ };
50
+ export const OBSERVE_ACTIONS = [
51
+ {
52
+ name: 'observe.read',
53
+ group: 'observe',
54
+ summary: 'Read the current page: URL, title, readable text; with sections also its controls, links, and tables.',
55
+ notes: 'Always returns url, title, targetId, generation. Default sections [content] adds text. controls/links/tables give records whose locator you can pass to act.*; a locator is checked unique on the live page. Results are cut at item boundaries to fit maxBytes (truncation lists what is missing).',
56
+ topics: OBSERVE_TOPICS,
57
+ params: {
58
+ sections: { type: 'array', items: { type: 'string', enum: OBSERVE_SECTIONS }, description: 'Any of content (default), controls, links, tables.' },
59
+ ...TARGET_PARAMS,
60
+ region: { type: 'object', additionalProperties: false, description: 'Only items that touch this viewport rectangle.', properties: { x: { type: 'number', required: true }, y: { type: 'number', required: true }, width: { type: 'number', required: true }, height: { type: 'number', required: true } } },
61
+ maxItems: { type: 'number', description: 'Per section, 1-500. Default 50.' },
62
+ maxBytes: { type: 'number', description: 'Whole result, 2000-90000. Default 24000. Cut at item boundaries; truncation says what is missing.' },
63
+ includeValues: { type: 'boolean', description: 'Return control values. Never for password, hidden, or token-like fields (hasValue only).' },
64
+ timeoutMs: { type: 'number', description: 'Wait for the locator, 1-30000 ms.' },
65
+ },
66
+ approval: 'none', readOnly: true, mutating: false, concurrencySafe: false, timeoutMs: 30_000,
67
+ examples: [{ args: {} }, { args: { sections: ['controls'], locator: { role: 'form' } }, note: 'fields of one form' }],
68
+ async execute(args, ctx) {
69
+ const plain = ['sections', 'selector', 'locator', 'region', 'maxItems', 'maxBytes', 'includeValues', 'timeoutMs'].every(key => args[key] === undefined);
70
+ if (plain)
71
+ return ctx.service.read({ session: ctx.session });
72
+ try {
73
+ return await ctx.service.observe({
74
+ ...args.sections ? { sections: args.sections } : {},
75
+ ...targetOf(args, false) !== undefined ? { target: targetOf(args, false) } : {},
76
+ ...args.region ? { region: args.region } : {},
77
+ ...args.maxItems !== undefined ? { maxItems: args.maxItems } : {},
78
+ ...args.maxBytes !== undefined ? { maxBytes: args.maxBytes } : {},
79
+ ...args.includeValues !== undefined ? { includeValues: args.includeValues } : {},
80
+ ...args.timeoutMs !== undefined ? { timeoutMs: args.timeoutMs } : {},
81
+ session: ctx.session,
82
+ });
83
+ }
84
+ catch (error) {
85
+ if (error instanceof ObserveArgError)
86
+ throw new ActionArgError(error.message);
87
+ throw error;
88
+ }
89
+ },
90
+ },
91
+ {
92
+ name: 'observe.screenshot',
93
+ group: 'observe',
94
+ summary: 'Capture the page, a clip region, or one element. Files land inside the configured snapshotDir.',
95
+ params: {
96
+ ...TARGET_PARAMS,
97
+ clip: { type: 'object', additionalProperties: false, properties: {
98
+ x: { type: 'number', required: true }, y: { type: 'number', required: true }, width: { type: 'number', required: true }, height: { type: 'number', required: true },
99
+ } },
100
+ fullPage: { type: 'boolean', description: 'Capture the full scrollable page. Defaults to true for page screenshots; incompatible with selector/locator.' },
101
+ format: { type: 'string', enum: ['png', 'jpeg'], description: 'Image format. Defaults from filename or png.' },
102
+ quality: { type: 'number', description: 'JPEG quality 0-100.' },
103
+ filename: { type: 'string', description: 'Plain filename ending in .png, .jpg, or .jpeg. Directory traversal and absolute paths are rejected.' },
104
+ },
105
+ approval: 'none', readOnly: true, mutating: false, concurrencySafe: false, timeoutMs: 30_000,
106
+ examples: [{ args: {} }, { args: { locator: { role: 'heading', name: 'Pricing' } }, note: 'element screenshot' }],
107
+ async execute(args, ctx) {
108
+ const target = targetOf(args, false);
109
+ return ctx.service.screenshot({
110
+ ...target ? { target } : {},
111
+ ...args.clip ? { clip: args.clip } : {},
112
+ ...args.fullPage !== undefined ? { fullPage: args.fullPage } : {},
113
+ ...args.format ? { format: args.format } : {},
114
+ ...args.quality !== undefined ? { quality: args.quality } : {},
115
+ ...args.filename ? { filename: args.filename } : {},
116
+ session: ctx.session,
117
+ });
118
+ },
119
+ },
120
+ ];
121
+ //# sourceMappingURL=observe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observe.js","sourceRoot":"","sources":["../../src/actions/observe.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAE5F,OAAO,EAAE,cAAc,EAAoC,MAAM,YAAY,CAAA;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAEjE,MAAM,cAAc,GAAgC;IAClD,QAAQ,EAAE;QACR,OAAO,EAAE,6BAA6B;QACtC,IAAI,EAAE;YACJ,iQAAiQ;YACjQ,sGAAsG;YACtG,oGAAoG;YACpG,0HAA0H;YAC1H,mGAAmG;YACnG,6MAA6M;YAC7M,mFAAmF;YACnF,iGAAiG;YACjG,8JAA8J;YAC9J,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AG,CAAC,OAAO,CAAC,UAAU,CAAC;gBAC5B,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;gBAC3B,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;gBACvC,GAAG,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE;gBACjE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE;gBAC7C,GAAG,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE;gBAC9D,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE;gBACnD,OAAO,EAAE,GAAG,CAAC,OAAO;aACrB,CAAC,CAAA;QACJ,CAAC;KACF;CACF,CAAA"}
@@ -0,0 +1,3 @@
1
+ /** `opencli` group: bundled OpenCLI adapters. @module dsh-browser/actions/opencli */
2
+ import type { ActionDef } from './types.ts';
3
+ export declare const OPENCLI_ACTIONS: ActionDef[];
@@ -0,0 +1,51 @@
1
+ /** `opencli` group: bundled OpenCLI adapters. @module dsh-browser/actions/opencli */
2
+ export const OPENCLI_ACTIONS = [
3
+ {
4
+ name: 'opencli.status',
5
+ group: 'opencli',
6
+ summary: 'Run bundled OpenCLI doctor: daemon, extension, profile, and Browser Bridge connectivity.',
7
+ params: {},
8
+ approval: 'none', readOnly: true, mutating: false, concurrencySafe: true, timeoutMs: 45_000,
9
+ examples: [{ args: {} }],
10
+ async execute(_args, ctx) {
11
+ const result = await ctx.service.opencliDoctor(ctx.signal);
12
+ return { code: result.code, timedOut: result.timedOut, output: (result.stdout || result.stderr).slice(0, 20_000) };
13
+ },
14
+ },
15
+ {
16
+ name: 'opencli.catalog',
17
+ group: 'opencli',
18
+ summary: 'Discover bundled OpenCLI adapters through a filtered, capped catalog (command, access class, strategy, args).',
19
+ notes: 'Use before opencli.run to find exact command names.',
20
+ params: {
21
+ query: { type: 'string' }, site: { type: 'string' },
22
+ access: { type: 'string', enum: ['read', 'write'] },
23
+ strategy: { type: 'string' }, limit: { type: 'number' },
24
+ },
25
+ approval: 'none', readOnly: true, mutating: false, concurrencySafe: true, timeoutMs: 75_000,
26
+ examples: [{ args: { site: 'reddit', access: 'read', limit: 10 } }],
27
+ async execute(args, ctx) {
28
+ const items = await ctx.service.opencliCatalog(args, ctx.signal);
29
+ return { items: items.map(({ args: itemArgs, ...item }) => ({ ...item, args: itemArgs })) };
30
+ },
31
+ },
32
+ {
33
+ name: 'opencli.run',
34
+ group: 'opencli',
35
+ summary: 'Run any bundled OpenCLI adapter or browser-session command with verbatim argv.',
36
+ notes: 'Commands may reuse logged-in Chrome state or perform writes, so approval is skipped only in unrestricted mode. Prefer existing read-only actions when available.',
37
+ params: {
38
+ args: { type: 'array', required: true, items: { type: 'string' }, description: 'Arguments after opencli, e.g. ["reddit","search","dsh","-f","json"].' },
39
+ profile: { type: 'string', description: 'Optional OpenCLI profile alias, passed as --profile.' },
40
+ timeoutMs: { type: 'number' },
41
+ },
42
+ approval: 'opencli', readOnly: false, mutating: true, concurrencySafe: false, timeoutMs: 180_000,
43
+ examples: [{ args: { args: ['reddit', 'search', 'dsh', '-f', 'json'] } }],
44
+ async execute(args, ctx) {
45
+ const argv = [...args.profile ? ['--profile', args.profile] : [], ...args.args];
46
+ const result = await ctx.service.opencli(argv, { timeoutMs: Math.min(Math.max(args.timeoutMs ?? 60_000, 1_000), 120_000), signal: ctx.signal });
47
+ return { code: result.code, timedOut: result.timedOut, output: (result.stdout || result.stderr).slice(0, 100_000) };
48
+ },
49
+ },
50
+ ];
51
+ //# sourceMappingURL=opencli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opencli.js","sourceRoot":"","sources":["../../src/actions/opencli.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAIrF,MAAM,CAAC,MAAM,eAAe,GAAgB;IAC1C;QACE,IAAI,EAAE,gBAAgB;QACtB,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,0FAA0F;QACnG,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM;QAC3F,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QACxB,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG;YACtB,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,CAAA;QACpH,CAAC;KACF;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,+GAA+G;QACxH,KAAK,EAAE,qDAAqD;QAC5D,MAAM,EAAE;YACN,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACnD,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;YACnD,QAAQ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KAAK,EAAE,SAAS,EAAE,OAAO;QAChG,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;QACzE,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG;YACrB,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;YAC/E,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAA;YAC/I,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,CAAA;QACrH,CAAC;KACF;CACF,CAAA"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The action registry: the single definition of every model-visible browser
3
+ * capability. Tool surfaces, approval policy, and exposure rules are all
4
+ * derived from this list.
5
+ * @module dsh-browser/actions/registry
6
+ */
7
+ import { type ActionDef, type ActionGroup, type ActionTraits } from './types.ts';
8
+ export declare const ACTIONS: readonly ActionDef[];
9
+ export declare const GROUP_SUMMARIES: Record<ActionGroup, string>;
10
+ /**
11
+ * The flags that apply to THIS call. An action with sub-actions takes the flags of the operation the
12
+ * arguments select; an unknown or missing operation gets the action-level (strictest) flags.
13
+ */
14
+ export declare function traitsFor(action: ActionDef, args?: unknown): ActionTraits;
15
+ /** Whether any operation of the action is usable in `read-only` mode (decides whether it is listed there at all). */
16
+ export declare function readOnlyCapable(action: ActionDef): boolean;
17
+ /** `automation.develop.save` resolves to the action and its operation; undefined for anything else. */
18
+ export declare function findSubAction(name: unknown): {
19
+ action: ActionDef;
20
+ sub: string;
21
+ } | undefined;
22
+ /** `observe.read.controls` resolves to the action and its detail topic; undefined for anything else. */
23
+ export declare function findTopic(name: unknown): {
24
+ action: ActionDef;
25
+ topic: string;
26
+ } | undefined;
27
+ export declare function isActionGroup(value: unknown): value is ActionGroup;
28
+ export declare function findAction(name: unknown): ActionDef | undefined;
29
+ export declare function actionsInGroup(group: ActionGroup): ActionDef[];
30
+ /** Tool name for an action on the flat surface: `browser_<group>_<action>` (`browser_crawl` for crawl.crawl). */
31
+ export declare function flatToolName(action: ActionDef): string;
32
+ export declare function findActionByFlatTool(toolName: string): ActionDef | undefined;
33
+ /** The two tools of the indexed surface. */
34
+ export declare const INDEX_TOOL = "browser_index";
35
+ export declare const CALL_TOOL = "browser_call";
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The action registry: the single definition of every model-visible browser
3
+ * capability. Tool surfaces, approval policy, and exposure rules are all
4
+ * derived from this list.
5
+ * @module dsh-browser/actions/registry
6
+ */
7
+ import { ACTION_GROUPS } from "./types.js";
8
+ import { RUNTIME_ACTIONS } from "./runtime.js";
9
+ import { TARGET_ACTIONS } from "./target.js";
10
+ import { OBSERVE_ACTIONS } from "./observe.js";
11
+ import { ACT_ACTIONS } from "./act.js";
12
+ import { INSPECT_ACTIONS } from "./inspect.js";
13
+ import { SCRIPT_ACTIONS } from "./script.js";
14
+ import { AUTOMATION_ACTIONS } from "./automation.js";
15
+ import { CRAWL_ACTIONS } from "./crawl.js";
16
+ import { OPENCLI_ACTIONS } from "./opencli.js";
17
+ export const ACTIONS = [
18
+ ...RUNTIME_ACTIONS, ...TARGET_ACTIONS, ...OBSERVE_ACTIONS, ...ACT_ACTIONS, ...INSPECT_ACTIONS,
19
+ ...SCRIPT_ACTIONS, ...AUTOMATION_ACTIONS, ...CRAWL_ACTIONS, ...OPENCLI_ACTIONS,
20
+ ];
21
+ const BY_NAME = new Map(ACTIONS.map(action => [action.name, action]));
22
+ export const GROUP_SUMMARIES = {
23
+ runtime: 'runtime status and Chromium install',
24
+ target: 'open / close / list this session\'s page',
25
+ observe: 'read page text, screenshots',
26
+ act: 'click, fill, type, clear, press, select, check, hover, scroll, upload, wait',
27
+ inspect: 'captured console and failed-request records',
28
+ script: 'page JavaScript, built-in scripts, userscripts',
29
+ automation: 'search/run reusable assets, develop drafts, inline recipes',
30
+ crawl: 'bounded multi-page crawl',
31
+ opencli: 'bundled OpenCLI site adapters',
32
+ };
33
+ /**
34
+ * The flags that apply to THIS call. An action with sub-actions takes the flags of the operation the
35
+ * arguments select; an unknown or missing operation gets the action-level (strictest) flags.
36
+ */
37
+ export function traitsFor(action, args) {
38
+ const base = { readOnly: action.readOnly, mutating: action.mutating, concurrencySafe: action.concurrencySafe };
39
+ const set = action.subActions;
40
+ if (!set || !args || typeof args !== 'object')
41
+ return base;
42
+ const selected = args[set.key];
43
+ const sub = typeof selected === 'string' && Object.hasOwn(set.items, selected) ? set.items[selected] : undefined;
44
+ return sub?.traits ? { ...base, ...sub.traits } : base;
45
+ }
46
+ /** Whether any operation of the action is usable in `read-only` mode (decides whether it is listed there at all). */
47
+ export function readOnlyCapable(action) {
48
+ return action.readOnly || Object.values(action.subActions?.items ?? {}).some(sub => sub.traits?.readOnly === true);
49
+ }
50
+ /** `automation.develop.save` resolves to the action and its operation; undefined for anything else. */
51
+ export function findSubAction(name) {
52
+ if (typeof name !== 'string')
53
+ return undefined;
54
+ const cut = name.lastIndexOf('.');
55
+ const action = cut > 0 ? findAction(name.slice(0, cut)) : undefined;
56
+ const sub = name.slice(cut + 1);
57
+ return action?.subActions && Object.hasOwn(action.subActions.items, sub) ? { action, sub } : undefined;
58
+ }
59
+ /** `observe.read.controls` resolves to the action and its detail topic; undefined for anything else. */
60
+ export function findTopic(name) {
61
+ if (typeof name !== 'string')
62
+ return undefined;
63
+ const cut = name.lastIndexOf('.');
64
+ const action = cut > 0 ? findAction(name.slice(0, cut)) : undefined;
65
+ const topic = name.slice(cut + 1);
66
+ return action?.topics && Object.hasOwn(action.topics, topic) ? { action, topic } : undefined;
67
+ }
68
+ export function isActionGroup(value) {
69
+ return typeof value === 'string' && ACTION_GROUPS.includes(value);
70
+ }
71
+ export function findAction(name) {
72
+ return typeof name === 'string' ? BY_NAME.get(name) : undefined;
73
+ }
74
+ export function actionsInGroup(group) {
75
+ return ACTIONS.filter(action => action.group === group);
76
+ }
77
+ /** Tool name for an action on the flat surface: `browser_<group>_<action>` (`browser_crawl` for crawl.crawl). */
78
+ export function flatToolName(action) {
79
+ const [group, name] = action.name.split('.');
80
+ return group === name ? `browser_${group}` : `browser_${group}_${name}`;
81
+ }
82
+ const BY_FLAT_NAME = new Map(ACTIONS.map(action => [flatToolName(action), action]));
83
+ export function findActionByFlatTool(toolName) {
84
+ return BY_FLAT_NAME.get(toolName);
85
+ }
86
+ /** The two tools of the indexed surface. */
87
+ export const INDEX_TOOL = 'browser_index';
88
+ export const CALL_TOOL = 'browser_call';
89
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/actions/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAuD,MAAM,YAAY,CAAA;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,cA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AC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAA;IAChE,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW,KAAK,IAAI,IAAI,EAAE,CAAA;AACzE,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;AAEnF,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,OAAO,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AACnC,CAAC;AAED,4CAA4C;AAC5C,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAA;AACzC,MAAM,CAAC,MAAM,SAAS,GAAG,cAAc,CAAA"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Action dispatch: validate arguments, check availability, run the executor
3
+ * under a deadline, and wrap everything in the result envelope.
4
+ *
5
+ * Both tool surfaces call {@link runAction}, so the envelope and the error
6
+ * codes are identical whether the model reaches an action through
7
+ * `browser_call` or through a flat per-action tool.
8
+ * @module dsh-browser/actions/run
9
+ */
10
+ import { type ActionContext, type ActionEnvelope } from './types.ts';
11
+ import { type AutomationMode, type ExposureOptions } from '../freedom.ts';
12
+ /** Serialized-result cap; larger results get their longest strings shortened. */
13
+ export declare const RESULT_CHAR_LIMIT = 100000;
14
+ export interface RunEnvironment {
15
+ mode: AutomationMode;
16
+ options: ExposureOptions;
17
+ enabled: boolean;
18
+ }
19
+ /**
20
+ * Shorten the longest string fields until the serialized result fits. The
21
+ * result stays valid JSON; the envelope reports how much text was dropped.
22
+ */
23
+ export declare function truncateResult(result: Record<string, unknown>, limit?: number): {
24
+ result: Record<string, unknown>;
25
+ truncation?: {
26
+ omitted: number;
27
+ reason: string;
28
+ };
29
+ };
30
+ /**
31
+ * Run one action and return the envelope. Never throws: every failure is a
32
+ * structured error the model can act on.
33
+ */
34
+ export declare function runAction(name: unknown, rawArgs: unknown, ctx: ActionContext, env: RunEnvironment): Promise<ActionEnvelope>;