@mind-harness/mh-browser 0.1.6 → 0.2.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.
@@ -44,7 +44,7 @@ const $remote = createTypertRemoteInfo({
44
44
  create: _mind_harness_mh_browser_mhBrowser_revealHandover_result$schema,
45
45
  jsonSchema: {"type":"object","properties":{"status":{"type":"string","enum":["revealed","not-handing-over","no-tab"]}},"required":["status"],"additionalProperties":true},
46
46
  },
47
- sourceLocation: {"file":"packages/mh-browser/src/service/service.ts","line":616,"column":9},
47
+ sourceLocation: {"file":"packages/mh-browser/src/service/service.ts","line":619,"column":9},
48
48
  },
49
49
  },
50
50
  }, z)
@@ -44,7 +44,7 @@ export const TYPERT_REMOTE = createTypertRemoteInfo({
44
44
  create: _mind_harness_mh_browser_mhBrowser_revealHandover_result$schema,
45
45
  jsonSchema: {"type":"object","properties":{"status":{"type":"string","enum":["revealed","not-handing-over","no-tab"]}},"required":["status"],"additionalProperties":true},
46
46
  },
47
- sourceLocation: {"file":"packages/mh-browser/src/service/service.ts","line":616,"column":9},
47
+ sourceLocation: {"file":"packages/mh-browser/src/service/service.ts","line":619,"column":9},
48
48
  },
49
49
  },
50
50
  }, z)
@@ -5,7 +5,7 @@ export declare const name = "mh-browser";
5
5
  export declare const inject: string[];
6
6
  export type Config = BrowserConfig;
7
7
  export declare const Config: import("@deepseek-ai/schemastery").default<BrowserConfig>;
8
- export declare function apply(ctx: Context, config: Config): void;
8
+ export declare function apply(ctx: Context, config: Config): Promise<void>;
9
9
  export { MhBrowserService };
10
10
  export { readAgentView } from './representation/agent-view.ts';
11
11
  export type { AgentViewDoc, AgentViewLink, AgentViewRead } from './representation/agent-view.ts';
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import type { Agent, PreStepDecision } from '@deepseek-ai/dsh-agent';
3
3
  import { type UserMessage } from '@deepseek-ai/dsh-llm';
4
+ import type { LogReader } from '../projections.ts';
4
5
  import type { MhBrowserService } from '../service/service.ts';
5
6
  import { type PresenceLogState } from './fold.ts';
6
7
  import './source.ts';
@@ -9,7 +10,7 @@ import './source.ts';
9
10
  * the reminder after the claimed input. `await next()` runs first, so a
10
11
  * caller that puts pages and then returns `next()` is folded into this step.
11
12
  */
12
- export declare function registerPresence(ctx: Context): void;
13
+ export declare function registerPresence(ctx: Context, reader: LogReader): void;
13
14
  /**
14
15
  * The reminder this step should carry. A set the log has but this process has
15
16
  * not checked (a resumed session) is re-read; one whose reminder a canceled
@@ -4,22 +4,12 @@ import { type PresenceLogState } from './presence/fold.ts';
4
4
  import { type AttachmentState } from './tools/attachments.ts';
5
5
  import { type DeliveryState } from './tools/delivery.ts';
6
6
  import { type TabLogState } from './tools/tab-log.ts';
7
- declare module '@deepseek-ai/dsh-session-projection/types' {
8
- interface SessionProjectionStateMap {
9
- mhBrowserDeliveries: DeliveryState;
10
- mhBrowserPresence: PresenceLogState;
11
- mhBrowserAttachments: AttachmentState;
12
- mhBrowserTabs: TabLogState;
13
- }
14
- }
15
- /** Host-only folds over the session log; every read of what the log says goes through these. */
16
- export declare function registerProjections(ctx: Context): void;
17
7
  export interface LogReader {
18
8
  deliveries(session: Session): DeliveryState;
19
9
  presence(session: Session): PresenceLogState;
20
10
  attachments(session: Session): AttachmentState;
21
11
  tabs(session: Session): TabLogState;
22
12
  }
23
- /** Fails closed when the registry or a unit is not active. */
24
- export declare function logReader(ctx: Context): LogReader;
13
+ /** Host-only folds over the session log; every read of what the log says goes through these. */
14
+ export declare function registerProjections(ctx: Context): Promise<LogReader>;
25
15
  //# sourceMappingURL=projections.d.ts.map
@@ -36,7 +36,7 @@ export declare class MhBrowserService extends TypertRemoteService {
36
36
  private context;
37
37
  private ready;
38
38
  private closing;
39
- /** The browser exited. The next call that needs a page starts it again. */
39
+ /** The browser is not running. The next call that needs a page starts it. */
40
40
  private exited;
41
41
  private readonly exits;
42
42
  /** One queue per owner: a slow wait in one Session does not hold up another. */
@@ -170,6 +170,8 @@ export declare class MhBrowserService extends TypertRemoteService {
170
170
  * ends the read without falling back to a tab.
171
171
  */
172
172
  private readKnown;
173
+ /** Keep the newest Agent Views. A dropped one is read in full the next time. */
174
+ private rememberDocument;
173
175
  /** One page from a document, with no tab. */
174
176
  private pageOfShown;
175
177
  /**
@@ -225,12 +227,14 @@ export declare class MhBrowserService extends TypertRemoteService {
225
227
  /** No window opens on exit: the person may have quit it. Calls on old tabs find none. */
226
228
  private onExit;
227
229
  /**
228
- * The browser for a call that needs a page. One that exited starts again
229
- * here. The exit limit stops unattended restarts; a person's request is
230
- * one start per click and skips it.
230
+ * The browser for a call that needs a page. One that is not running starts
231
+ * again here. The exit limit stops unattended restarts; a person's request
232
+ * is one start per click and skips it.
231
233
  */
232
234
  private up;
233
235
  private stop;
236
+ /** Close a context the service is done with, and kill it if close stalls. */
237
+ private closeContext;
234
238
  private refuseIfPerson;
235
239
  private takenOver;
236
240
  private presenceUrls;
@@ -1,4 +1,5 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
3
- export declare function browserDownloadTool(ctx: Context): ToolDefinition;
3
+ import type { LogReader } from '../projections.ts';
4
+ export declare function browserDownloadTool(ctx: Context, reader: LogReader): ToolDefinition;
4
5
  //# sourceMappingURL=download.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
3
- export declare function browserHandoverTool(ctx: Context): ToolDefinition;
3
+ import type { LogReader } from '../projections.ts';
4
+ export declare function browserHandoverTool(ctx: Context, reader: LogReader): ToolDefinition;
4
5
  //# sourceMappingURL=handover.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
3
- export declare function browserInvokeTool(ctx: Context): ToolDefinition;
3
+ import type { LogReader } from '../projections.ts';
4
+ export declare function browserInvokeTool(ctx: Context, reader: LogReader): ToolDefinition;
4
5
  //# sourceMappingURL=invoke.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
3
- export declare function browserOpenTool(ctx: Context): ToolDefinition;
3
+ import type { LogReader } from '../projections.ts';
4
+ export declare function browserOpenTool(ctx: Context, reader: LogReader): ToolDefinition;
4
5
  //# sourceMappingURL=open.d.ts.map
@@ -1,6 +1,7 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
3
+ import type { LogReader } from '../projections.ts';
3
4
  export declare const PAGE_OPERATION_NAMES: readonly ["browser_click", "browser_hover", "browser_select_option", "browser_drag", "browser_type", "browser_fill_form", "browser_press_key", "browser_file_upload", "browser_handle_dialog", "browser_navigate_back", "browser_wait_for", "browser_snapshot", "browser_find", "browser_take_screenshot", "browser_evaluate"];
4
- export declare function pageOperationTools(ctx: Context): ToolDefinition[];
5
- export declare function pageOperationTool(ctx: Context, name: string): ToolDefinition;
5
+ export declare function pageOperationTools(ctx: Context, reader: LogReader): ToolDefinition[];
6
+ export declare function pageOperationTool(ctx: Context, reader: LogReader, name: string): ToolDefinition;
6
7
  //# sourceMappingURL=page-ops.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
2
  import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
3
- export declare function browserPresenceTool(ctx: Context): ToolDefinition;
3
+ import type { LogReader } from '../projections.ts';
4
+ export declare function browserPresenceTool(ctx: Context, reader: LogReader): ToolDefinition;
4
5
  //# sourceMappingURL=presence.d.ts.map
@@ -1,3 +1,4 @@
1
1
  import type { Context } from '@deepseek-ai/cordis';
2
- export declare function registerBrowserTools(ctx: Context): void;
2
+ import type { LogReader } from '../projections.ts';
3
+ export declare function registerBrowserTools(ctx: Context, reader: LogReader): void;
3
4
  //# sourceMappingURL=register.d.ts.map
@@ -3,10 +3,12 @@ import { HarnessError } from '@deepseek-ai/dsh-llm';
3
3
  import type { Session } from '@deepseek-ai/dsh-session';
4
4
  import type { ToolRunContext } from '@deepseek-ai/dsh-tools';
5
5
  import type { WriteTarget } from '../service/service.ts';
6
+ import { type BrowserCode } from '../types.ts';
6
7
  /** dsh shows the model only the message, so the message starts with the code. */
7
8
  export declare class BrowserToolError extends HarnessError {
9
+ readonly code: BrowserCode;
8
10
  readonly reason: string;
9
- constructor(code: string, reason: string);
11
+ constructor(code: BrowserCode, reason: string);
10
12
  }
11
13
  export declare const NO_WORKSPACE_REASON = "this session has no working directory";
12
14
  export interface ToolSession {
@@ -175,22 +175,25 @@ export interface TabInfo {
175
175
  inPresence: boolean;
176
176
  mayHaveChanged: boolean;
177
177
  }
178
+ /** Every code this package reports. The values are the model-facing contract. */
179
+ export declare const BROWSER_CODES: readonly ["AUTHORITY_MISMATCH", "BROWSER_UNAVAILABLE", "INTERRUPTED", "INVALID_ARGS", "INVALID_INPUT", "ITEM_REFUSED", "MODAL_STATE", "NO_SESSION", "NO_WORKSPACE", "NOT_DECLARED", "NOT_DELIVERED", "OUTSIDE_WORKSPACE", "PERSON_IN_CONTROL", "SANDBOX_DENIED", "STALE_REF", "TAKEN_OVER", "UNKNOWN_TAB"];
180
+ export type BrowserCode = (typeof BROWSER_CODES)[number];
178
181
  export declare class MhBrowserError extends Error {
179
- readonly code: string;
182
+ readonly code: BrowserCode;
180
183
  readonly page?: PageView;
181
- constructor(code: string, message: string, page?: PageView);
184
+ constructor(code: BrowserCode, message: string, page?: PageView);
182
185
  }
183
186
  /** Owner of the person's own window. It belongs to no Session. */
184
187
  export declare const PERSON_OWNER = "person";
185
- export declare const UNKNOWN_TAB = "UNKNOWN_TAB";
188
+ export declare const UNKNOWN_TAB: BrowserCode;
186
189
  export declare const UNKNOWN_TAB_REASON = "no such tab in this session";
187
190
  /**
188
191
  * Internal: a wait ended because its signal aborted. A tool never reports it:
189
192
  * a stopped call ends as the tool runtime's abort, a takeover as `TAKEN_OVER`.
190
193
  */
191
- export declare const INTERRUPTED = "INTERRUPTED";
194
+ export declare const INTERRUPTED: BrowserCode;
192
195
  /** The browser did not start or could not be restarted. */
193
- export declare const BROWSER_UNAVAILABLE = "BROWSER_UNAVAILABLE";
196
+ export declare const BROWSER_UNAVAILABLE: BrowserCode;
194
197
  export declare function unknownTab(): PageError;
195
198
  export type Download = {
196
199
  kind: 'saved';
@@ -0,0 +1,7 @@
1
+ /** Shown on a session's tab group while a handover is waiting. */
2
+ export declare const WAITING_TITLE = "\u7B49\u4F60\uFF1A";
3
+ /** The question on the handover card. `reason` is the sentence the model gave. */
4
+ export declare function handoverQuestion(reason: string): string;
5
+ /** The option that hands the browser back. */
6
+ export declare const HAND_BACK = "\u4EA4\u56DE";
7
+ //# sourceMappingURL=words.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mind-harness/mh-browser",
3
- "version": "0.1.6",
3
+ "version": "0.2.1",
4
4
  "description": "Opens pages in a real browser for the agent, keeps chosen Agent Views in context, and hands the browser to you when a person is needed.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "files": [
@@ -48,33 +48,36 @@
48
48
  "zod": "^4.6.6"
49
49
  },
50
50
  "devDependencies": {
51
- "@deepseek-ai/cordis": "~4.0.5",
52
- "@deepseek-ai/dsh-agent": "^0.2.1-rc.3",
53
- "@deepseek-ai/dsh-agent-loop": "^0.2.1-rc.3",
54
- "@deepseek-ai/dsh-agent-loop-testkit": "^0.2.1-rc.3",
55
- "@deepseek-ai/dsh-attachment": "^0.2.1-rc.3",
56
- "@deepseek-ai/dsh-browser-use": "^0.2.1-rc.3",
57
- "@deepseek-ai/dsh-home-paths": "^0.2.1-rc.3",
58
- "@deepseek-ai/dsh-llm": "^0.2.1-rc.3",
59
- "@deepseek-ai/dsh-llm-mock-server": "^0.2.1-rc.3",
60
- "@deepseek-ai/dsh-sandbox-policy": "^0.2.1-rc.3",
61
- "@deepseek-ai/dsh-session": "^0.2.1-rc.3",
62
- "@deepseek-ai/dsh-session-projection": "^0.2.1-rc.3",
63
- "@deepseek-ai/dsh-tools": "^0.2.1-rc.3",
64
- "@deepseek-ai/dsh-typert-protocol": "^0.2.1-rc.3",
65
- "@deepseek-ai/dsh-user-questions": "^0.2.1-rc.3",
66
- "@deepseek-ai/schemastery": "~3.18.5"
51
+ "@deepseek-ai/cordis": "~4.1.0",
52
+ "@deepseek-ai/dsh-agent": "^0.2.2-rc.1",
53
+ "@deepseek-ai/dsh-agent-loop": "^0.2.2-rc.1",
54
+ "@deepseek-ai/dsh-agent-loop-testkit": "^0.2.2-rc.1",
55
+ "@deepseek-ai/dsh-attachment": "^0.2.2-rc.1",
56
+ "@deepseek-ai/dsh-browser-use": "^0.2.2-rc.1",
57
+ "@deepseek-ai/dsh-home-paths": "^0.2.2-rc.1",
58
+ "@deepseek-ai/dsh-llm": "^0.2.2-rc.1",
59
+ "@deepseek-ai/dsh-llm-mock-server": "^0.2.2-rc.1",
60
+ "@deepseek-ai/dsh-sandbox-policy": "^0.2.2-rc.1",
61
+ "@deepseek-ai/dsh-session": "^0.2.2-rc.1",
62
+ "@deepseek-ai/dsh-session-projection": "^0.2.2-rc.1",
63
+ "@deepseek-ai/dsh-tools": "^0.2.2-rc.1",
64
+ "@deepseek-ai/dsh-typert-protocol": "^0.2.2-rc.1",
65
+ "@deepseek-ai/dsh-user-questions": "^0.2.2-rc.1",
66
+ "@deepseek-ai/schemastery": "~3.19.0"
67
67
  },
68
68
  "peerDependencies": {
69
- "@deepseek-ai/cordis": "~4.0.5",
70
- "@deepseek-ai/dsh-home-paths": ">=0.2.1-rc.3 <0.3.0",
71
- "@deepseek-ai/dsh-llm": ">=0.2.1-rc.3 <0.3.0",
72
- "@deepseek-ai/dsh-tools": ">=0.2.1-rc.3 <0.3.0",
73
- "@deepseek-ai/dsh-typert-protocol": ">=0.2.1-rc.3 <0.3.0",
74
- "@deepseek-ai/dsh-user-questions": ">=0.2.1-rc.3 <0.3.0",
75
- "@deepseek-ai/schemastery": "~3.18.5"
69
+ "@deepseek-ai/cordis": "^4.1.0",
70
+ "@deepseek-ai/dsh-home-paths": ">=0.2.2-rc.1 <0.2.3-0",
71
+ "@deepseek-ai/dsh-llm": ">=0.2.2-rc.1 <0.2.3-0",
72
+ "@deepseek-ai/dsh-tools": ">=0.2.2-rc.1 <0.2.3-0",
73
+ "@deepseek-ai/dsh-typert-protocol": ">=0.2.2-rc.1 <0.2.3-0",
74
+ "@deepseek-ai/dsh-user-questions": ">=0.2.2-rc.1 <0.2.3-0",
75
+ "@deepseek-ai/schemastery": "^3.19.0"
76
76
  },
77
77
  "icon": "./icon.svg",
78
+ "engines": {
79
+ "dsh": ">=0.2.2-rc.1 <0.2.3-0"
80
+ },
78
81
  "scripts": {
79
82
  "version": "node ../../scripts/mh/sync-extension-version.ts"
80
83
  }