@anweat/dsh-browser 0.1.17 → 0.2.0

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 (169) hide show
  1. package/README.md +266 -88
  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 +11 -3
  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 +68 -10
  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 +309 -32
  91. package/lib/browser-service.js +636 -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/settings-namespace.d.ts +1 -1
  117. package/lib/client/settings-namespace.js +1 -1
  118. package/lib/client/settings-namespace.js.map +1 -1
  119. package/lib/client.js +1915 -330
  120. package/lib/client.js.map +1 -1
  121. package/lib/config.d.ts +50 -1
  122. package/lib/config.js +31 -1
  123. package/lib/config.js.map +1 -1
  124. package/lib/dialogs.d.ts +37 -0
  125. package/lib/dialogs.js +73 -0
  126. package/lib/dialogs.js.map +1 -0
  127. package/lib/freedom.d.ts +23 -7
  128. package/lib/freedom.js +48 -59
  129. package/lib/freedom.js.map +1 -1
  130. package/lib/index.d.ts +5 -13
  131. package/lib/index.js +51 -30
  132. package/lib/index.js.map +1 -1
  133. package/lib/journal.d.ts +109 -0
  134. package/lib/journal.js +238 -0
  135. package/lib/journal.js.map +1 -0
  136. package/lib/locator.d.ts +82 -0
  137. package/lib/locator.js +190 -0
  138. package/lib/locator.js.map +1 -0
  139. package/lib/observe-script.d.ts +27 -0
  140. package/lib/observe-script.js +565 -0
  141. package/lib/observe-script.js.map +1 -0
  142. package/lib/observe.d.ts +179 -0
  143. package/lib/observe.js +368 -0
  144. package/lib/observe.js.map +1 -0
  145. package/lib/policy-keys.d.ts +30 -0
  146. package/lib/policy-keys.js +34 -0
  147. package/lib/policy-keys.js.map +1 -0
  148. package/lib/prompt-limits.d.ts +30 -0
  149. package/lib/prompt-limits.js +31 -0
  150. package/lib/prompt-limits.js.map +1 -0
  151. package/lib/prompts.d.ts +131 -0
  152. package/lib/prompts.js +295 -0
  153. package/lib/prompts.js.map +1 -0
  154. package/lib/skill.d.ts +100 -0
  155. package/lib/skill.js +181 -0
  156. package/lib/skill.js.map +1 -0
  157. package/lib/tool-defs.d.ts +72 -0
  158. package/lib/tool-defs.js +67 -0
  159. package/lib/tool-defs.js.map +1 -0
  160. package/lib/tools.d.ts +19 -4
  161. package/lib/tools.js +124 -922
  162. package/lib/tools.js.map +1 -1
  163. package/package.json +15 -11
  164. package/scripts/check-host-rpc.mjs +11 -4
  165. package/scripts/dump-prompts.mjs +29 -0
  166. package/scripts/measure-tool-surface.mjs +190 -0
  167. package/lib/settings-scope.d.ts +0 -56
  168. package/lib/settings-scope.js +0 -51
  169. package/lib/settings-scope.js.map +0 -1
package/lib/freedom.js CHANGED
@@ -1,56 +1,9 @@
1
- /** Public automation-freedom contract and tool exposure matrix. */
1
+ /** Public automation-freedom contract and action exposure matrix. */
2
+ import { ACTIONS, CALL_TOOL, INDEX_TOOL, findAction, flatToolName, readOnlyCapable, traitsFor } from "./actions/registry.js";
2
3
  export const AUTOMATION_MODES = ['read-only', 'standard', 'autonomous', 'unrestricted'];
3
- export const ALL_BROWSER_TOOL_NAMES = [
4
- 'browser_open',
5
- 'browser_click',
6
- 'browser_type',
7
- 'browser_wait',
8
- 'browser_press',
9
- 'browser_select',
10
- 'browser_check',
11
- 'browser_hover',
12
- 'browser_set_files',
13
- 'browser_evaluate',
14
- 'browser_console',
15
- 'browser_requests',
16
- 'browser_scroll',
17
- 'browser_read',
18
- 'browser_screenshot',
19
- 'browser_close',
20
- 'browser_status',
21
- 'browser_install',
22
- 'browser_script_catalog',
23
- 'browser_script_validate',
24
- 'browser_script_run_builtin',
25
- 'browser_userscript_run',
26
- 'browser_recipe_run',
27
- 'browser_automation_search',
28
- 'browser_automation_develop',
29
- 'browser_automation_run',
30
- 'browser_opencli_status',
31
- 'browser_opencli_catalog',
32
- 'browser_opencli_run',
33
- 'browser_crawl',
34
- ];
35
- const READ_ONLY_TOOL_NAMES = new Set([
36
- 'browser_open',
37
- 'browser_wait',
38
- 'browser_read',
39
- 'browser_screenshot',
40
- 'browser_console',
41
- 'browser_requests',
42
- 'browser_close',
43
- 'browser_status',
44
- 'browser_script_catalog',
45
- 'browser_script_validate',
46
- 'browser_script_run_builtin',
47
- 'browser_recipe_run',
48
- 'browser_automation_search',
49
- 'browser_automation_develop',
50
- 'browser_opencli_status',
51
- 'browser_opencli_catalog',
52
- 'browser_crawl',
53
- ]);
4
+ export const TOOL_SURFACES = ['indexed', 'flat'];
5
+ /** Every browser action name (`group.action`), straight from the registry. */
6
+ export const ALL_BROWSER_ACTION_NAMES = ACTIONS.map(action => action.name);
54
7
  export function resolveAutomationMode(value) {
55
8
  const mode = value ?? 'standard';
56
9
  if (typeof mode !== 'string' || !AUTOMATION_MODES.includes(mode)) {
@@ -58,17 +11,53 @@ export function resolveAutomationMode(value) {
58
11
  }
59
12
  return mode;
60
13
  }
61
- export function isBrowserToolExposed(name, mode) {
62
- if (!ALL_BROWSER_TOOL_NAMES.includes(name))
14
+ export function resolveToolSurface(value) {
15
+ const surface = value ?? 'indexed';
16
+ if (typeof surface !== 'string' || !TOOL_SURFACES.includes(surface)) {
17
+ throw new Error('toolSurface must be one of: ' + TOOL_SURFACES.join(', '));
18
+ }
19
+ return surface;
20
+ }
21
+ /**
22
+ * Whether an action name is a known browser action allowed under the mode. With `args`, an action
23
+ * that bundles several operations (`automation.develop`) is judged by the operation the call selects;
24
+ * without them, by whether any operation is usable.
25
+ */
26
+ export function isBrowserActionExposed(name, mode, args) {
27
+ const action = findAction(name);
28
+ if (!action)
63
29
  return false;
64
- return mode !== 'read-only' || READ_ONLY_TOOL_NAMES.has(name);
30
+ if (mode !== 'read-only')
31
+ return true;
32
+ return args === undefined ? readOnlyCapable(action) : traitsFor(action, args).readOnly;
33
+ }
34
+ export function browserActionsForMode(mode) {
35
+ return ALL_BROWSER_ACTION_NAMES.filter(name => isBrowserActionExposed(name, mode));
36
+ }
37
+ /** Actions the model may use under this configuration. */
38
+ export function configuredBrowserActions(mode, options, enabled = true) {
39
+ if (!enabled)
40
+ return [];
41
+ return browserActionsForMode(mode).filter(name => name !== 'automation.develop' || options.modelDevelopmentEnabled);
65
42
  }
66
- export function browserToolsForMode(mode) {
67
- return ALL_BROWSER_TOOL_NAMES.filter(name => isBrowserToolExposed(name, mode));
43
+ /** Why an action cannot run now, or undefined when it can. */
44
+ export function actionUnavailableReason(action, mode, options, enabled = true, args) {
45
+ if (!enabled)
46
+ return 'browser service is disabled (enabled=false)';
47
+ if (mode === 'read-only' && !(args === undefined ? readOnlyCapable(action) : traitsFor(action, args).readOnly)) {
48
+ return args !== undefined && action.subActions && readOnlyCapable(action) ? `disabled by automationMode=${mode} for ${action.subActions.key}=${String(args[action.subActions.key])}` : `disabled by automationMode=${mode}`;
49
+ }
50
+ if (action.name === 'automation.develop' && !options.modelDevelopmentEnabled)
51
+ return 'disabled by automationAssets.modelDevelopmentEnabled=false';
52
+ return undefined;
68
53
  }
69
- export function configuredBrowserTools(mode, options, enabled = true) {
54
+ /** Tool names the plugin registers for a surface (empty when the service is disabled). */
55
+ export function configuredBrowserTools(mode, options, enabled = true, surface = 'indexed') {
70
56
  if (!enabled)
71
57
  return [];
72
- return browserToolsForMode(mode).filter(name => name !== 'browser_automation_develop' || options.modelDevelopmentEnabled);
58
+ if (surface === 'indexed')
59
+ return [INDEX_TOOL, CALL_TOOL];
60
+ const exposed = new Set(configuredBrowserActions(mode, options, enabled));
61
+ return ACTIONS.filter(action => exposed.has(action.name)).map(flatToolName);
73
62
  }
74
63
  //# sourceMappingURL=freedom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"freedom.js","sourceRoot":"","sources":["../src/freedom.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,CAAU,CAAA;AAGhG,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,cAAc;IACd,eAAe;IACf,cAAc;IACd,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,mBAAmB;IACnB,kBAAkB;IAClB,iBAAiB;IACjB,kBAAkB;IAClB,gBAAgB;IAChB,cAAc;IACd,oBAAoB;IACpB,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,wBAAwB;IACxB,yBAAyB;IACzB,4BAA4B;IAC5B,wBAAwB;IACxB,oBAAoB;IACpB,2BAA2B;IAC3B,4BAA4B;IAC5B,wBAAwB;IACxB,wBAAwB;IACxB,yBAAyB;IACzB,qBAAqB;IACrB,eAAe;CACP,CAAA;AAIV,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAkB;IACpD,cAAc;IACd,cAAc;IACd,cAAc;IACd,oBAAoB;IACpB,iBAAiB;IACjB,kBAAkB;IAClB,eAAe;IACf,gBAAgB;IAChB,wBAAwB;IACxB,yBAAyB;IACzB,4BAA4B;IAC5B,oBAAoB;IACpB,2BAA2B;IAC3B,4BAA4B;IAC5B,wBAAwB;IACxB,yBAAyB;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;IAC1P,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,oBAAoB,IAAI,CAAC,OAAO,CAAC,uBAAuB;QAAE,OAAO,4DAA4D,CAAA;IACjJ,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,sBAAsB,CAAC,IAAoB,EAAE,OAAwB,EAAE,OAAO,GAAG,IAAI,EAAE,UAAuB,SAAS;IACrI,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAA;IACvB,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;IACzD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,wBAAwB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IACzE,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAC7E,CAAC"}
package/lib/index.d.ts CHANGED
@@ -10,14 +10,6 @@ import type { Context } from '@deepseek-ai/cordis';
10
10
  import { Config } from './config.ts';
11
11
  export declare const name = "dsh-browser";
12
12
  export declare const inject: string[];
13
- /**
14
- * Loader entry id of this plugin's row in `cordis.patch.yml`, which is also the
15
- * settings namespace the plugin owns. On hosts whose `SettingsForms` still
16
- * exposes `register()` this is the scope namespace; on newer hosts it is the
17
- * profile patch entry id whose `Config` schema the settings page is derived
18
- * from. Keep it in sync with the bundle patch.
19
- */
20
- export declare const BROWSER_SETTINGS_NS = "browser";
21
13
  /**
22
14
  * The object cordis actually receives.
23
15
  *
@@ -31,21 +23,21 @@ export declare const BROWSER_SETTINGS_NS = "browser";
31
23
  */
32
24
  declare const plugin: {
33
25
  name: string;
34
- inject: readonly ["tools", "settings"];
26
+ inject: string[];
35
27
  apply: typeof apply;
36
28
  Config: import("@deepseek-ai/schemastery").default<Config>;
37
29
  };
38
30
  export default plugin;
39
31
  export { Config };
40
32
  export type { Config as BrowserConfig } from './config.ts';
41
- export type { BrowserService, RenderRule, RenderResult, SnapshotResult, PlatformSpec, SearchItem, InteractiveState, RecipeRunResult, ScriptRunResult, EvaluateResult, FileUploadResult } from './browser-service.ts';
33
+ export type { BrowserService, RenderRule, RenderResult, SnapshotResult, PlatformSpec, SearchItem, InteractiveState, RecipeServiceResult, ScriptRunResult, EvaluateResult, FileUploadResult } from './browser-service.ts';
42
34
  export type { AuthProfileConfig, ResolvedAuthProfile } from './auth-profiles.ts';
43
35
  export type { RulePackConfig, RuleStep, ResolvedRulePack } from './rule-packs.ts';
44
- export type { BrowserRecipeStep, RecipeStepResult } from './automation.ts';
36
+ export type { BrowserRecipeStep, RecipeStepResult, RecipeRunResult, RecipeExecutionStatus, RecipeValidationStatus, RecipeEffects, RecipeFailedStep, RecipeOutput } from './automation.ts';
45
37
  export type { UserscriptMetadata, UserscriptValidation, BuiltinScript } from './scripts.ts';
46
38
  export { BUILTIN_SCRIPTS, validateUserscript } from './scripts.ts';
47
- export type { AutomationMode, BrowserToolName } from './freedom.ts';
48
- export { AUTOMATION_MODES, ALL_BROWSER_TOOL_NAMES, browserToolsForMode, configuredBrowserTools } from './freedom.ts';
39
+ export type { AutomationMode, ToolSurface, BrowserActionName } from './freedom.ts';
40
+ export { AUTOMATION_MODES, TOOL_SURFACES, ALL_BROWSER_ACTION_NAMES, browserActionsForMode, configuredBrowserActions, configuredBrowserTools } from './freedom.ts';
49
41
  export type { AutomationAssetPolicy, AutomationAssetPolicyInput, AutomationAsset, AutomationAssetSummary, AutomationCandidate, AutomationCandidateSummary, AssetPersistenceMode, AssetActivationMode } from './automation-assets.ts';
50
42
  export { ASSET_PERSISTENCE_MODES, ASSET_ACTIVATION_MODES, resolveAutomationAssetPolicy, AutomationAssetStore } from './automation-assets.ts';
51
43
  export declare function apply(ctx: Context, config: Config): void;
package/lib/index.js CHANGED
@@ -9,22 +9,23 @@
9
9
  import fs from 'node:fs';
10
10
  import path from 'node:path';
11
11
  import { Config, resolveConfig } from "./config.js";
12
- import { resolveSettingsScope } from "./settings-scope.js";
13
12
  import { BrowserService } from "./browser-service.js";
14
13
  import { registerTools } from "./tools.js";
15
14
  import { browserPolicyDecision } from "./approval-policy.js";
15
+ import { resolveBrowserCall } from "./actions/surface.js";
16
+ import { registerSkillWhenAvailable } from "./skill.js";
17
+ import { installErrorHints } from "./actions/errors.js";
18
+ import { describePrompts } from "./prompts.js";
16
19
  import { AutomationAssetStore } from "./automation-assets.js";
17
20
  import { registerAutomationAssetRpc } from "./automation-assets-rpc.js";
18
21
  export const name = 'dsh-browser';
19
- export const inject = ['tools', 'settings'];
20
- /**
21
- * Loader entry id of this plugin's row in `cordis.patch.yml`, which is also the
22
- * settings namespace the plugin owns. On hosts whose `SettingsForms` still
23
- * exposes `register()` this is the scope namespace; on newer hosts it is the
24
- * profile patch entry id whose `Config` schema the settings page is derived
25
- * from. Keep it in sync with the bundle patch.
26
- */
27
- export const BROWSER_SETTINGS_NS = 'browser';
22
+ // Only `tools` is required: `apply` registers the model-facing tools there. `settings` is deliberately NOT declared:
23
+ // Cordis 4.0.4 treats every declared inject as required, so a Host composition without the Settings service
24
+ // (sdk-minimal, a profile with that row switched off) would leave the plugin pending forever. Nothing here reads
25
+ // `ctx.settings`; `apply` takes its config from the Loader entry. Without the Settings service the plugin runs with
26
+ // its Config defaults and the settings card is simply not served (the client mounts it only while the Host serves
27
+ // the `browser` namespace, see `src/client/index.ts`).
28
+ export const inject = ['tools'];
28
29
  /**
29
30
  * The object cordis actually receives.
30
31
  *
@@ -36,43 +37,62 @@ export const BROWSER_SETTINGS_NS = 'browser';
36
37
  * reports the omission. Exporting the assembled object as `default` is what
37
38
  * makes `Config` visible to the settings service.
38
39
  */
39
- const plugin = { name: 'dsh-browser', inject: ['tools', 'settings'], apply, Config };
40
+ const plugin = { name: 'dsh-browser', inject, apply, Config };
40
41
  export default plugin;
41
42
  export { Config };
42
43
  export { BUILTIN_SCRIPTS, validateUserscript } from "./scripts.js";
43
- export { AUTOMATION_MODES, ALL_BROWSER_TOOL_NAMES, browserToolsForMode, configuredBrowserTools } from "./freedom.js";
44
+ export { AUTOMATION_MODES, TOOL_SURFACES, ALL_BROWSER_ACTION_NAMES, browserActionsForMode, configuredBrowserActions, configuredBrowserTools } from "./freedom.js";
44
45
  export { ASSET_PERSISTENCE_MODES, ASSET_ACTIVATION_MODES, resolveAutomationAssetPolicy, AutomationAssetStore } from "./automation-assets.js";
45
46
  export function apply(ctx, config) {
46
- // Browser processes, tool exposure, and approval hooks are deliberately
47
- // startup-scoped. On hosts that still ship the legacy `settings.register`
48
- // provider we register a live scope; on dsh-v0.1.7-rc.2+ — which removed it
49
- // and derives settings pages from this entry's own Config schema — the
50
- // Loader re-applies the validated entry config by restarting this fiber.
51
- // The namespace is the bundle patch's loader entry id (`browser`), which is
52
- // also what the client settings card binds to.
53
- const settingsScope = resolveSettingsScope(ctx.settings, BROWSER_SETTINGS_NS, Config, config);
54
- const resolved = resolveConfig(settingsScope.get());
47
+ // `config` is the Loader entry's own `Config` (entry id `browser` in `cordis.patch.yml`, the same id the
48
+ // client settings card binds to); the Host derives the settings page from that schema. Every field that
49
+ // page edits is `.volatile()`, so a save commits the new value into the running references and emits
50
+ // `loader/volatile-update` without remounting this plugin. Browser processes, tool exposure and approval
51
+ // hooks are deliberately startup-scoped: `resolveConfig` reads them once here, so a saved value applies
52
+ // when the profile restarts. Only `prompts` is read live (see `ResolvedConfig.prompts`).
53
+ const resolved = resolveConfig(config);
55
54
  fs.mkdirSync(resolved.snapshotDir, { recursive: true });
56
55
  const service = new BrowserService(resolved);
57
56
  const assets = new AutomationAssetStore(resolved.automationAssets);
58
- // Apply the configured exposure/approval mode before every browser tool.
59
- // Validation remains active even when unrestricted mode skips approvals.
57
+ // Apply the configured exposure/approval mode before every browser call.
58
+ // Approval is decided per ACTION: browser_call (and each flat tool) is
59
+ // resolved to its action and arguments first, so the user is asked about
60
+ // `act.click #submit`, not about a generic dispatcher. browser_index only
61
+ // reads the catalog and is let through. Validation remains active even when
62
+ // unrestricted mode skips approvals.
60
63
  ctx.on('tools/pre-execute', async (exec, next) => {
61
64
  const downstream = await next();
62
65
  if (downstream.kind !== 'allow')
63
66
  return downstream;
64
- const assetId = exec.arguments?.id;
65
- const assetKind = exec.name === 'browser_automation_run' && typeof assetId === 'string'
66
- ? assets.get(assetId)?.kind : undefined;
67
- return browserPolicyDecision(exec.name, exec.arguments, resolved.automationMode, assetKind);
67
+ const call = resolveBrowserCall(exec.name, exec.arguments);
68
+ // `unresolved` is a browser_call naming no known action: it runs no
69
+ // action and returns a structured UNKNOWN_ACTION error, so nothing to approve.
70
+ if (call?.kind === 'index' || call?.kind === 'unresolved')
71
+ return downstream;
72
+ if (call?.kind === 'action') {
73
+ // automation.run and automation.develop test act on a stored asset: the policy needs to know what kind it is,
74
+ // and for a recipe draft which steps it would replay.
75
+ const callArgs = (call.args ?? {});
76
+ const replaysAsset = call.action === 'automation.run' || (call.action === 'automation.develop' && callArgs.action === 'test');
77
+ const target = replaysAsset && typeof callArgs.id === 'string' ? assets.get(callArgs.id) : undefined;
78
+ return browserPolicyDecision(call.action, call.args, resolved.automationMode, target?.kind, call.action === 'automation.develop' ? target?.recipe : undefined, target ? { id: target.id, name: target.name, revision: target.revision } : undefined);
79
+ }
80
+ return browserPolicyDecision(exec.name, exec.arguments, resolved.automationMode);
68
81
  });
69
82
  // Provide the `browser` service so consumers (web-search-pro) can inject it.
70
83
  // ctx.provide is scoped to this plugin's fiber; the browser instance itself
71
84
  // is closed via the effect disposer below.
72
85
  ctx.provide('browser', service);
73
86
  ctx.effect(() => () => void service.close());
74
- registerTools(ctx, resolved, service, assets);
75
- registerAutomationAssetRpc(ctx, assets, service);
87
+ // Optional: the `dsh-browser` skill is registered only when the Host has a
88
+ // skill registry. It must not be a declared `inject` (Cordis 4.0.4 would
89
+ // hang the plugin without it); this opens a scoped, optional dependency.
90
+ // `prompts.skill` is read live: the skill is registered, withdrawn or invalidated when it changes.
91
+ const skill = registerSkillWhenAvailable(ctx, undefined, resolved.prompts);
92
+ // `prompts.errorHints` replace the by-code hints wherever an error is built; read per call.
93
+ ctx.effect(() => installErrorHints(() => resolved.prompts.current().errorHints));
94
+ registerTools(ctx, resolved, service, assets, { skillAvailable: skill.isAvailable, refreshSkill: skill.refresh });
95
+ registerAutomationAssetRpc(ctx, assets, service, () => describePrompts({ prompts: resolved.prompts, mode: resolved.automationMode, options: resolved.automationAssets, enabled: resolved.enabled }));
76
96
  if (resolved.verbose) {
77
97
  try {
78
98
  const markerPath = path.join(resolved.snapshotDir, 'apply.log');
@@ -83,11 +103,12 @@ export function apply(ctx, config) {
83
103
  headless: resolved.headless,
84
104
  opencliEnabled: resolved.opencliEnabled,
85
105
  automationMode: resolved.automationMode,
106
+ toolSurface: resolved.toolSurface,
86
107
  snapshotDir: resolved.snapshotDir,
87
108
  }) + '\n', 'utf8');
88
109
  }
89
110
  catch { /* marker is best-effort */ }
90
111
  }
91
- ctx.logger?.(name).info('dsh-browser loaded: channel=' + resolved.channel + ' headless=' + resolved.headless + ' opencli=' + resolved.opencliEnabled + ' automation=' + resolved.automationMode);
112
+ ctx.logger?.(name).info('dsh-browser loaded: channel=' + resolved.channel + ' headless=' + resolved.headless + ' opencli=' + resolved.opencliEnabled + ' automation=' + resolved.automationMode + ' surface=' + resolved.toolSurface);
92
113
  }
93
114
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,OAAO,EAAE,MAAM,EAAE,aAAa,EAAuB,MAAM,aAAa,CAAA;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,EAAE,cA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AAC,eAAe,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,cAAc,EAAE,OAAO,EAAE,QAAQ,CAAC,gBAAgB,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;IAEpM,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;YAC/D,EAAE,CAAC,cAAc,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC;gBAC3C,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBAC5B,MAAM,EAAE,IAAI;gBACZ,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;gBAC3B,cAAc,EAAE,QAAQ,CAAC,cAAc;gBACvC,cAAc,EAAE,QAAQ,CAAC,cAAc;gBACvC,WAAW,EAAE,QAAQ,CAAC,WAAW;gBACjC,WAAW,EAAE,QAAQ,CAAC,WAAW;aAClC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QACpB,CAAC;QAAC,MAAM,CAAC,CAAC,2BAA2B,CAAC,CAAC;IACzC,CAAC;IAED,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,8BAA8B,GAAG,QAAQ,CAAC,OAAO,GAAG,YAAY,GAAG,QAAQ,CAAC,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC,cAAc,GAAG,cAAc,GAAG,QAAQ,CAAC,cAAc,GAAG,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAA;AACvO,CAAC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * The exploration journal: a bounded, in-memory record of what one session did through `browser_call`.
3
+ *
4
+ * It is evidence for turning an exploration into a draft (`automation.develop` draft_from_journal), not a
5
+ * log of the page. Entries hold the action, the page generation before and after, the locator, scrubbed
6
+ * parameters, and the outcome. Typed text never appears in an entry: fill/type text is a reference
7
+ * `{ref:'v<seq>', length, sensitive?}`. The text itself is kept in memory only when it is short (at most
8
+ * {@link RAW_TEXT_MAX} characters) and does not look secret (see {@link looksSecret}), and only so a draft
9
+ * can use it as a literal or an example; it is released together with its entry, and nothing is written to disk.
10
+ * @module dsh-browser/journal
11
+ */
12
+ import type { BrowserLocatorSpec } from './locator.ts';
13
+ import type { ErrorCode, ExecutionStatus } from './actions/types.ts';
14
+ /** Default number of entries a session keeps; the oldest are dropped first. */
15
+ export declare const JOURNAL_LIMIT = 200;
16
+ /** Typed text longer than this is never retained, only its length. */
17
+ export declare const RAW_TEXT_MAX = 200;
18
+ /** A scrubbed stand-in for a value that is not stored in the entry. */
19
+ export interface ValueRef {
20
+ ref: string;
21
+ length: number;
22
+ sensitive?: true;
23
+ }
24
+ export type JournalEffects = 'none' | 'observed' | 'unknown';
25
+ export interface JournalEntry {
26
+ seq: number;
27
+ /** `group.action`, e.g. `act.fill`. */
28
+ action: string;
29
+ /** The page the call ran on (`t1`...). */
30
+ targetId?: string;
31
+ generationBefore?: number;
32
+ generationAfter?: number;
33
+ /** The element the call acted on, as a LocatorSpec (a CSS `selector` argument becomes `{css}`). */
34
+ locator?: BrowserLocatorSpec;
35
+ /** The call's arguments with values scrubbed; see the module comment. */
36
+ params: Record<string, unknown>;
37
+ outcome: {
38
+ ok: boolean;
39
+ executionStatus: ExecutionStatus;
40
+ errorCode?: ErrorCode;
41
+ };
42
+ /** Whether the call changed anything: `none`, `observed` (it ran and changed state), `unknown` (it may have). */
43
+ effects: JournalEffects;
44
+ /** One short line about the result: page title/path or the error. */
45
+ summary: string;
46
+ /** A read-only observation: it never becomes a step. */
47
+ observation?: true;
48
+ /** The page URL after the call, secret query values redacted. */
49
+ url?: string;
50
+ /** For observations: characters of text read. */
51
+ size?: number;
52
+ }
53
+ /** Field names that suggest a secret; the same list `observe.read` uses for controls. */
54
+ export declare const SENSITIVE_NAME: RegExp;
55
+ export declare function cardLike(value: string): boolean;
56
+ export declare function tokenLike(value: string): boolean;
57
+ /** A value that looks like a token, a JWT or a card number. */
58
+ export declare function looksSecret(value: string): boolean;
59
+ /** A locator that names a password-like field (its label, name, css...). */
60
+ export declare function locatorSuggestsSecret(locator: BrowserLocatorSpec | undefined): boolean;
61
+ /** `https://u:p@host/path?token=x` -> secret query values and userinfo removed. Returns the cleaned URL and whether anything was removed. */
62
+ export declare function redactUrl(value: string): {
63
+ url: string;
64
+ redacted: boolean;
65
+ };
66
+ export interface ScrubbedCall {
67
+ params: Record<string, unknown>;
68
+ locator?: BrowserLocatorSpec;
69
+ /** The typed text, only when it may be retained. */
70
+ raw?: string;
71
+ }
72
+ /**
73
+ * Scrub the arguments of one call. `sensitiveControl` is true when the page itself says the target is a
74
+ * password-like control (type=password, autocomplete one-time-code, ...).
75
+ */
76
+ export declare function scrubCall(action: string, args: Record<string, unknown>, seq: number, sensitiveControl?: boolean): ScrubbedCall;
77
+ /** Whether a call goes into the journal. Lists, inspection, searches and drafting are not exploration. */
78
+ export declare function isJournaled(action: string): boolean;
79
+ export declare function isObservation(action: string): boolean;
80
+ /** What a finished call changed, from what it is and how it ended. */
81
+ export declare function effectsOf(mutating: boolean, outcome: JournalEntry['outcome']): JournalEffects;
82
+ export declare class SessionJournal {
83
+ readonly limit: number;
84
+ private nextSeq;
85
+ private items;
86
+ private readonly raws;
87
+ /** How many entries fell off the front because of the limit. */
88
+ dropped: number;
89
+ constructor(limit?: number);
90
+ /** Reserve the sequence number of a call that is about to run. */
91
+ allocate(): number;
92
+ add(entry: JournalEntry, raw?: string): void;
93
+ entries(): readonly JournalEntry[];
94
+ /** The retained typed text of an entry, if it was short and not secret. Internal: never part of an entry. */
95
+ rawText(seq: number): string | undefined;
96
+ get firstSeq(): number | undefined;
97
+ get lastSeq(): number | undefined;
98
+ get size(): number;
99
+ clear(): void;
100
+ }
101
+ /** The one-line summary of a finished call, with no secret query values. */
102
+ export declare function summarize(action: string, envelope: {
103
+ ok: boolean;
104
+ result?: Record<string, unknown>;
105
+ error?: {
106
+ code: string;
107
+ message: string;
108
+ };
109
+ }): string;