@flrande/browserctl 0.5.0 → 0.6.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 (136) hide show
  1. package/dist/client.d.ts +34 -0
  2. package/dist/client.js +138 -0
  3. package/dist/commandRegistry.d.ts +16 -0
  4. package/dist/commandRegistry.js +21 -0
  5. package/dist/help.d.ts +4 -0
  6. package/dist/help.js +24 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.js +23 -0
  9. package/dist/runCli.d.ts +5 -0
  10. package/dist/runCli.js +170 -0
  11. package/package.json +32 -57
  12. package/INSTALL-CN.md +0 -92
  13. package/INSTALL.md +0 -92
  14. package/LICENSE +0 -21
  15. package/README-CN.md +0 -69
  16. package/README.md +0 -69
  17. package/apps/browserctl/src/commands/a11y-snapshot.ts +0 -20
  18. package/apps/browserctl/src/commands/act.test.ts +0 -71
  19. package/apps/browserctl/src/commands/act.ts +0 -64
  20. package/apps/browserctl/src/commands/command-wrappers.test.ts +0 -688
  21. package/apps/browserctl/src/commands/common.test.ts +0 -87
  22. package/apps/browserctl/src/commands/common.ts +0 -191
  23. package/apps/browserctl/src/commands/console-list.test.ts +0 -102
  24. package/apps/browserctl/src/commands/console-list.ts +0 -108
  25. package/apps/browserctl/src/commands/cookie-clear.ts +0 -18
  26. package/apps/browserctl/src/commands/cookie-get.ts +0 -18
  27. package/apps/browserctl/src/commands/cookie-set.ts +0 -22
  28. package/apps/browserctl/src/commands/dialog-arm.ts +0 -20
  29. package/apps/browserctl/src/commands/dom-query-all.ts +0 -18
  30. package/apps/browserctl/src/commands/dom-query.ts +0 -18
  31. package/apps/browserctl/src/commands/download-trigger.ts +0 -22
  32. package/apps/browserctl/src/commands/download-wait.test.ts +0 -67
  33. package/apps/browserctl/src/commands/download-wait.ts +0 -27
  34. package/apps/browserctl/src/commands/element-screenshot.ts +0 -20
  35. package/apps/browserctl/src/commands/frame-list.ts +0 -16
  36. package/apps/browserctl/src/commands/frame-snapshot.ts +0 -18
  37. package/apps/browserctl/src/commands/har-export.test.ts +0 -112
  38. package/apps/browserctl/src/commands/har-export.ts +0 -120
  39. package/apps/browserctl/src/commands/memory-delete.ts +0 -20
  40. package/apps/browserctl/src/commands/memory-inspect.ts +0 -20
  41. package/apps/browserctl/src/commands/memory-list.ts +0 -90
  42. package/apps/browserctl/src/commands/memory-mode-set.ts +0 -29
  43. package/apps/browserctl/src/commands/memory-purge.ts +0 -16
  44. package/apps/browserctl/src/commands/memory-resolve.ts +0 -56
  45. package/apps/browserctl/src/commands/memory-status.ts +0 -16
  46. package/apps/browserctl/src/commands/memory-ttl-set.ts +0 -28
  47. package/apps/browserctl/src/commands/memory-upsert.ts +0 -142
  48. package/apps/browserctl/src/commands/network-list.test.ts +0 -110
  49. package/apps/browserctl/src/commands/network-list.ts +0 -112
  50. package/apps/browserctl/src/commands/network-wait-for.test.ts +0 -90
  51. package/apps/browserctl/src/commands/network-wait-for.ts +0 -100
  52. package/apps/browserctl/src/commands/profile-list.ts +0 -16
  53. package/apps/browserctl/src/commands/profile-use.ts +0 -18
  54. package/apps/browserctl/src/commands/response-body.ts +0 -24
  55. package/apps/browserctl/src/commands/screenshot.ts +0 -16
  56. package/apps/browserctl/src/commands/session-drop.test.ts +0 -36
  57. package/apps/browserctl/src/commands/session-drop.ts +0 -16
  58. package/apps/browserctl/src/commands/session-list.test.ts +0 -81
  59. package/apps/browserctl/src/commands/session-list.ts +0 -70
  60. package/apps/browserctl/src/commands/snapshot.ts +0 -16
  61. package/apps/browserctl/src/commands/status.ts +0 -10
  62. package/apps/browserctl/src/commands/storage-get.ts +0 -20
  63. package/apps/browserctl/src/commands/storage-set.ts +0 -22
  64. package/apps/browserctl/src/commands/tab-close.ts +0 -20
  65. package/apps/browserctl/src/commands/tab-focus.ts +0 -20
  66. package/apps/browserctl/src/commands/tab-open.ts +0 -19
  67. package/apps/browserctl/src/commands/tabs.ts +0 -13
  68. package/apps/browserctl/src/commands/trace-get.test.ts +0 -61
  69. package/apps/browserctl/src/commands/trace-get.ts +0 -62
  70. package/apps/browserctl/src/commands/upload-arm.ts +0 -26
  71. package/apps/browserctl/src/commands/wait-element.test.ts +0 -80
  72. package/apps/browserctl/src/commands/wait-element.ts +0 -76
  73. package/apps/browserctl/src/commands/wait-text.test.ts +0 -110
  74. package/apps/browserctl/src/commands/wait-text.ts +0 -93
  75. package/apps/browserctl/src/commands/wait-url.test.ts +0 -80
  76. package/apps/browserctl/src/commands/wait-url.ts +0 -76
  77. package/apps/browserctl/src/daemon-client.test.ts +0 -253
  78. package/apps/browserctl/src/daemon-client.ts +0 -632
  79. package/apps/browserctl/src/e2e.test.ts +0 -103
  80. package/apps/browserctl/src/main.dispatch.test.ts +0 -461
  81. package/apps/browserctl/src/main.test.ts +0 -334
  82. package/apps/browserctl/src/main.ts +0 -957
  83. package/apps/browserctl/src/smoke.e2e.test.ts +0 -97
  84. package/apps/browserctl/src/test-port.ts +0 -26
  85. package/apps/browserd/src/bootstrap.ts +0 -432
  86. package/apps/browserd/src/chrome-relay-extension-bridge.test.ts +0 -250
  87. package/apps/browserd/src/chrome-relay-extension-bridge.ts +0 -506
  88. package/apps/browserd/src/container.ts +0 -3088
  89. package/apps/browserd/src/main.test.ts +0 -1436
  90. package/apps/browserd/src/main.ts +0 -7
  91. package/apps/browserd/src/test-port.ts +0 -26
  92. package/apps/browserd/src/tool-matrix.test.ts +0 -887
  93. package/bin/browserctl.cjs +0 -21
  94. package/bin/browserd.cjs +0 -21
  95. package/extensions/chrome-relay/README-CN.md +0 -39
  96. package/extensions/chrome-relay/README.md +0 -39
  97. package/extensions/chrome-relay/background.js +0 -1687
  98. package/extensions/chrome-relay/manifest.json +0 -15
  99. package/extensions/chrome-relay/popup.html +0 -369
  100. package/extensions/chrome-relay/popup.js +0 -972
  101. package/packages/core/src/bootstrap.test.ts +0 -10
  102. package/packages/core/src/driver-registry.test.ts +0 -45
  103. package/packages/core/src/driver-registry.ts +0 -22
  104. package/packages/core/src/driver.ts +0 -47
  105. package/packages/core/src/index.ts +0 -6
  106. package/packages/core/src/navigation-memory.test.ts +0 -259
  107. package/packages/core/src/navigation-memory.ts +0 -360
  108. package/packages/core/src/ref-cache.test.ts +0 -61
  109. package/packages/core/src/ref-cache.ts +0 -28
  110. package/packages/core/src/session-store.test.ts +0 -82
  111. package/packages/core/src/session-store.ts +0 -138
  112. package/packages/core/src/types.ts +0 -9
  113. package/packages/driver-chrome-relay/src/chrome-relay-driver.test.ts +0 -744
  114. package/packages/driver-chrome-relay/src/chrome-relay-driver.ts +0 -2429
  115. package/packages/driver-chrome-relay/src/chrome-relay-extension-runtime.test.ts +0 -264
  116. package/packages/driver-chrome-relay/src/chrome-relay-extension-runtime.ts +0 -521
  117. package/packages/driver-chrome-relay/src/index.ts +0 -26
  118. package/packages/driver-managed/src/index.ts +0 -22
  119. package/packages/driver-managed/src/managed-driver.test.ts +0 -183
  120. package/packages/driver-managed/src/managed-driver.ts +0 -341
  121. package/packages/driver-managed/src/managed-local-driver.test.ts +0 -608
  122. package/packages/driver-managed/src/managed-local-driver.ts +0 -2243
  123. package/packages/driver-remote-cdp/src/index.ts +0 -19
  124. package/packages/driver-remote-cdp/src/remote-cdp-driver.test.ts +0 -727
  125. package/packages/driver-remote-cdp/src/remote-cdp-driver.ts +0 -2264
  126. package/packages/protocol/src/envelope.test.ts +0 -25
  127. package/packages/protocol/src/envelope.ts +0 -31
  128. package/packages/protocol/src/errors.test.ts +0 -17
  129. package/packages/protocol/src/errors.ts +0 -11
  130. package/packages/protocol/src/index.ts +0 -3
  131. package/packages/protocol/src/tools.ts +0 -3
  132. package/packages/transport-mcp-stdio/src/index.ts +0 -3
  133. package/packages/transport-mcp-stdio/src/sdk-server.ts +0 -139
  134. package/packages/transport-mcp-stdio/src/server.test.ts +0 -281
  135. package/packages/transport-mcp-stdio/src/server.ts +0 -183
  136. package/packages/transport-mcp-stdio/src/tool-map.ts +0 -84
@@ -1,27 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
3
-
4
- export type DownloadWaitCommandResult = {
5
- driver: string;
6
- targetId: string;
7
- download: Record<string, unknown>;
8
- };
9
-
10
- export async function runDownloadWaitCommand(args: string[]): Promise<DownloadWaitCommandResult> {
11
- const context = parseCommandContext(args);
12
- const targetId = requirePositionalArg(context, 0, "targetId");
13
- const path = context.positional[1];
14
-
15
- return await callDaemonTool<DownloadWaitCommandResult>(
16
- "browser.download.wait",
17
- buildToolArguments(
18
- context,
19
- path === undefined
20
- ? { targetId }
21
- : {
22
- targetId,
23
- path
24
- }
25
- )
26
- );
27
- }
@@ -1,20 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
3
-
4
- export type ElementScreenshotCommandResult = Record<string, unknown>;
5
-
6
- export async function runElementScreenshotCommand(
7
- args: string[]
8
- ): Promise<ElementScreenshotCommandResult> {
9
- const context = parseCommandContext(args);
10
- const targetId = requirePositionalArg(context, 0, "targetId");
11
- const selector = requirePositionalArg(context, 1, "selector");
12
-
13
- return await callDaemonTool<ElementScreenshotCommandResult>(
14
- "browser.element.screenshot",
15
- buildToolArguments(context, {
16
- targetId,
17
- selector
18
- })
19
- );
20
- }
@@ -1,16 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
3
-
4
- export type FrameListCommandResult = Record<string, unknown>;
5
-
6
- export async function runFrameListCommand(args: string[]): Promise<FrameListCommandResult> {
7
- const context = parseCommandContext(args);
8
- const targetId = requirePositionalArg(context, 0, "targetId");
9
-
10
- return await callDaemonTool<FrameListCommandResult>(
11
- "browser.frame.list",
12
- buildToolArguments(context, {
13
- targetId
14
- })
15
- );
16
- }
@@ -1,18 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
3
-
4
- export type FrameSnapshotCommandResult = Record<string, unknown>;
5
-
6
- export async function runFrameSnapshotCommand(args: string[]): Promise<FrameSnapshotCommandResult> {
7
- const context = parseCommandContext(args);
8
- const targetId = requirePositionalArg(context, 0, "targetId");
9
- const frameId = requirePositionalArg(context, 1, "frameId");
10
-
11
- return await callDaemonTool<FrameSnapshotCommandResult>(
12
- "browser.frame.snapshot",
13
- buildToolArguments(context, {
14
- targetId,
15
- frameId
16
- })
17
- );
18
- }
@@ -1,112 +0,0 @@
1
- import { afterEach, describe, expect, it, vi } from "vitest";
2
-
3
- const { callDaemonToolMock } = vi.hoisted(() => ({
4
- callDaemonToolMock: vi.fn()
5
- }));
6
-
7
- vi.mock("../daemon-client", () => ({
8
- callDaemonTool: callDaemonToolMock
9
- }));
10
-
11
- import { runHarExportCommand } from "./har-export";
12
-
13
- afterEach(() => {
14
- callDaemonToolMock.mockReset();
15
- });
16
-
17
- describe("runHarExportCommand", () => {
18
- it("forwards export options", async () => {
19
- callDaemonToolMock.mockResolvedValue({ ok: true });
20
-
21
- await runHarExportCommand([
22
- "target:1",
23
- "--include-bodies",
24
- "--url-contains",
25
- "/api/",
26
- "--method",
27
- "get",
28
- "--status",
29
- "200",
30
- "--since",
31
- "2026-01-01T00:00:00.000Z",
32
- "--limit",
33
- "30"
34
- ]);
35
-
36
- expect(callDaemonToolMock).toHaveBeenCalledTimes(1);
37
- expect(callDaemonToolMock).toHaveBeenCalledWith("browser.network.harExport", {
38
- sessionId: "cli:local",
39
- targetId: "target:1",
40
- includeBodies: true,
41
- urlContains: "/api/",
42
- method: "GET",
43
- status: 200,
44
- since: "2026-01-01T00:00:00.000Z",
45
- limit: 30
46
- });
47
- });
48
-
49
- it.each([
50
- {
51
- label: "--url-contains",
52
- args: ["target:1", "--url-contains"],
53
- message: "Missing value for --url-contains."
54
- },
55
- {
56
- label: "--method",
57
- args: ["target:1", "--method"],
58
- message: "Missing value for --method."
59
- },
60
- {
61
- label: "--status",
62
- args: ["target:1", "--status"],
63
- message: "Missing value for --status."
64
- },
65
- {
66
- label: "--since",
67
- args: ["target:1", "--since"],
68
- message: "Missing value for --since."
69
- },
70
- {
71
- label: "--limit",
72
- args: ["target:1", "--limit"],
73
- message: "Missing value for --limit."
74
- }
75
- ])("throws when $label is missing a value", async ({ args, message }) => {
76
- await expect(runHarExportCommand(args)).rejects.toThrow(message);
77
- expect(callDaemonToolMock).not.toHaveBeenCalled();
78
- });
79
-
80
- it.each([
81
- {
82
- label: "empty --url-contains",
83
- args: ["target:1", "--url-contains", " "],
84
- message: "--url-contains must be a non-empty string."
85
- },
86
- {
87
- label: "status <= 0",
88
- args: ["target:1", "--status", "0"],
89
- message: "--status must be a positive integer."
90
- },
91
- {
92
- label: "status non-strict integer text",
93
- args: ["target:1", "--status", "201ok"],
94
- message: "--status must be a positive integer."
95
- },
96
- {
97
- label: "limit <= 0",
98
- args: ["target:1", "--limit", "0"],
99
- message: "--limit must be a positive integer."
100
- }
101
- ])("throws on invalid option value: $label", async ({ args, message }) => {
102
- await expect(runHarExportCommand(args)).rejects.toThrow(message);
103
- expect(callDaemonToolMock).not.toHaveBeenCalled();
104
- });
105
-
106
- it("throws on unknown option token", async () => {
107
- await expect(runHarExportCommand(["target:1", "--unknown"]))
108
- .rejects.toThrow("Unknown har-export option: --unknown");
109
-
110
- expect(callDaemonToolMock).not.toHaveBeenCalled();
111
- });
112
- });
@@ -1,120 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
3
-
4
- export type HarExportCommandResult = Record<string, unknown>;
5
-
6
- function parsePositiveInteger(value: string, optionName: string): number {
7
- const normalized = value.trim();
8
- if (!/^[1-9]\d*$/.test(normalized)) {
9
- throw new Error(`${optionName} must be a positive integer.`);
10
- }
11
-
12
- return Number.parseInt(normalized, 10);
13
- }
14
-
15
- function parseHarExportOptions(tokens: string[]): {
16
- includeBodies?: boolean;
17
- urlContains?: string;
18
- method?: string;
19
- status?: number;
20
- since?: string;
21
- limit?: number;
22
- } {
23
- let includeBodies = false;
24
- let urlContains: string | undefined;
25
- let method: string | undefined;
26
- let status: number | undefined;
27
- let since: string | undefined;
28
- let limit: number | undefined;
29
-
30
- for (let index = 0; index < tokens.length; index += 1) {
31
- const token = tokens[index];
32
- if (token === "--include-bodies") {
33
- includeBodies = true;
34
- continue;
35
- }
36
-
37
- if (token === "--url-contains") {
38
- const value = tokens[index + 1];
39
- if (value === undefined) {
40
- throw new Error("Missing value for --url-contains.");
41
- }
42
- const trimmed = value.trim();
43
- if (trimmed.length === 0) {
44
- throw new Error("--url-contains must be a non-empty string.");
45
- }
46
- urlContains = trimmed;
47
- index += 1;
48
- continue;
49
- }
50
-
51
- if (token === "--method") {
52
- const value = tokens[index + 1];
53
- if (value === undefined) {
54
- throw new Error("Missing value for --method.");
55
- }
56
- method = value.trim().toUpperCase();
57
- index += 1;
58
- continue;
59
- }
60
-
61
- if (token === "--status") {
62
- const value = tokens[index + 1];
63
- if (value === undefined) {
64
- throw new Error("Missing value for --status.");
65
- }
66
- status = parsePositiveInteger(value, "--status");
67
- index += 1;
68
- continue;
69
- }
70
-
71
- if (token === "--since") {
72
- const value = tokens[index + 1];
73
- if (value === undefined) {
74
- throw new Error("Missing value for --since.");
75
- }
76
- const trimmed = value.trim();
77
- if (trimmed.length === 0) {
78
- throw new Error("--since must be a non-empty ISO timestamp.");
79
- }
80
- since = trimmed;
81
- index += 1;
82
- continue;
83
- }
84
-
85
- if (token === "--limit") {
86
- const value = tokens[index + 1];
87
- if (value === undefined) {
88
- throw new Error("Missing value for --limit.");
89
- }
90
- limit = parsePositiveInteger(value, "--limit");
91
- index += 1;
92
- continue;
93
- }
94
-
95
- throw new Error(`Unknown har-export option: ${token}`);
96
- }
97
-
98
- return {
99
- ...(includeBodies ? { includeBodies: true } : {}),
100
- ...(urlContains !== undefined ? { urlContains } : {}),
101
- ...(method !== undefined ? { method } : {}),
102
- ...(status !== undefined ? { status } : {}),
103
- ...(since !== undefined ? { since } : {}),
104
- ...(limit !== undefined ? { limit } : {})
105
- };
106
- }
107
-
108
- export async function runHarExportCommand(args: string[]): Promise<HarExportCommandResult> {
109
- const context = parseCommandContext(args);
110
- const targetId = requirePositionalArg(context, 0, "targetId");
111
- const options = parseHarExportOptions(context.positional.slice(1));
112
-
113
- return await callDaemonTool<HarExportCommandResult>(
114
- "browser.network.harExport",
115
- buildToolArguments(context, {
116
- targetId,
117
- ...options
118
- })
119
- );
120
- }
@@ -1,20 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
3
-
4
- export type MemoryDeleteCommandResult = Record<string, unknown>;
5
-
6
- export async function runMemoryDeleteCommand(args: string[]): Promise<MemoryDeleteCommandResult> {
7
- const context = parseCommandContext(args);
8
- const id = requirePositionalArg(context, 0, "id");
9
-
10
- if (context.positional.length > 1) {
11
- throw new Error(`Unknown memory-delete option: ${context.positional[1]}`);
12
- }
13
-
14
- return await callDaemonTool<MemoryDeleteCommandResult>(
15
- "browser.memory.delete",
16
- buildToolArguments(context, {
17
- id
18
- })
19
- );
20
- }
@@ -1,20 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
3
-
4
- export type MemoryInspectCommandResult = Record<string, unknown>;
5
-
6
- export async function runMemoryInspectCommand(args: string[]): Promise<MemoryInspectCommandResult> {
7
- const context = parseCommandContext(args);
8
- const id = requirePositionalArg(context, 0, "id");
9
-
10
- if (context.positional.length > 1) {
11
- throw new Error(`Unknown memory-inspect option: ${context.positional[1]}`);
12
- }
13
-
14
- return await callDaemonTool<MemoryInspectCommandResult>(
15
- "browser.memory.inspect",
16
- buildToolArguments(context, {
17
- id
18
- })
19
- );
20
- }
@@ -1,90 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext } from "./common";
3
-
4
- export type MemoryListCommandResult = Record<string, unknown>;
5
-
6
- type MemoryListOptions = {
7
- domain?: string;
8
- profileId?: string;
9
- intentKey?: string;
10
- };
11
-
12
- function requireOptionValue(tokens: string[], index: number, optionName: string): string {
13
- const value = tokens[index + 1];
14
- if (value === undefined || value.startsWith("--")) {
15
- throw new Error(`Missing value for ${optionName}.`);
16
- }
17
-
18
- return value;
19
- }
20
-
21
- function parseListOptions(tokens: string[]): MemoryListOptions {
22
- let domain: string | undefined;
23
- let profileId: string | undefined;
24
- let intentKey: string | undefined;
25
-
26
- for (let index = 0; index < tokens.length; index += 1) {
27
- const token = tokens[index];
28
- if (token === "--domain") {
29
- const value = requireOptionValue(tokens, index, "--domain");
30
-
31
- const trimmedValue = value.trim();
32
- if (trimmedValue.length === 0) {
33
- throw new Error("--domain must be a non-empty string.");
34
- }
35
-
36
- domain = trimmedValue;
37
- index += 1;
38
- continue;
39
- }
40
-
41
- if (token === "--profile-id") {
42
- const value = requireOptionValue(tokens, index, "--profile-id");
43
-
44
- const trimmedValue = value.trim();
45
- if (trimmedValue.length === 0) {
46
- throw new Error("--profile-id must be a non-empty string.");
47
- }
48
-
49
- profileId = trimmedValue;
50
- index += 1;
51
- continue;
52
- }
53
-
54
- if (token === "--intent-key") {
55
- const value = requireOptionValue(tokens, index, "--intent-key");
56
-
57
- const trimmedValue = value.trim();
58
- if (trimmedValue.length === 0) {
59
- throw new Error("--intent-key must be a non-empty string.");
60
- }
61
-
62
- intentKey = trimmedValue;
63
- index += 1;
64
- continue;
65
- }
66
-
67
- throw new Error(`Unknown memory-list option: ${token}`);
68
- }
69
-
70
- return {
71
- ...(domain !== undefined ? { domain } : {}),
72
- ...(profileId !== undefined ? { profileId } : {}),
73
- ...(intentKey !== undefined ? { intentKey } : {})
74
- };
75
- }
76
-
77
- export async function runMemoryListCommand(args: string[]): Promise<MemoryListCommandResult> {
78
- const context = parseCommandContext(args);
79
- const options = parseListOptions(context.positional);
80
- const profileId = options.profileId ?? context.profile;
81
-
82
- return await callDaemonTool<MemoryListCommandResult>(
83
- "browser.memory.list",
84
- buildToolArguments(context, {
85
- ...(options.domain !== undefined ? { domain: options.domain } : {}),
86
- ...(profileId !== undefined ? { profileId } : {}),
87
- ...(options.intentKey !== undefined ? { intentKey: options.intentKey } : {})
88
- })
89
- );
90
- }
@@ -1,29 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
3
-
4
- export type MemoryModeSetCommandResult = Record<string, unknown>;
5
-
6
- function parseMemoryMode(value: string): "off" | "ask" | "auto" {
7
- const normalizedValue = value.trim().toLowerCase();
8
- if (normalizedValue === "off" || normalizedValue === "ask" || normalizedValue === "auto") {
9
- return normalizedValue;
10
- }
11
-
12
- throw new Error("mode must be one of: off, ask, auto.");
13
- }
14
-
15
- export async function runMemoryModeSetCommand(args: string[]): Promise<MemoryModeSetCommandResult> {
16
- const context = parseCommandContext(args);
17
- const mode = parseMemoryMode(requirePositionalArg(context, 0, "mode"));
18
-
19
- if (context.positional.length > 1) {
20
- throw new Error(`Unknown memory-mode-set option: ${context.positional[1]}`);
21
- }
22
-
23
- return await callDaemonTool<MemoryModeSetCommandResult>(
24
- "browser.memory.mode.set",
25
- buildToolArguments(context, {
26
- mode
27
- })
28
- );
29
- }
@@ -1,16 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext } from "./common";
3
-
4
- export type MemoryPurgeCommandResult = Record<string, unknown>;
5
-
6
- export async function runMemoryPurgeCommand(args: string[]): Promise<MemoryPurgeCommandResult> {
7
- const context = parseCommandContext(args);
8
- if (context.positional.length > 0) {
9
- throw new Error(`Unknown memory-purge option: ${context.positional[0]}`);
10
- }
11
-
12
- return await callDaemonTool<MemoryPurgeCommandResult>(
13
- "browser.memory.purge",
14
- buildToolArguments(context)
15
- );
16
- }
@@ -1,56 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
3
-
4
- export type MemoryResolveCommandResult = Record<string, unknown>;
5
-
6
- function requireOptionValue(tokens: string[], index: number, optionName: string): string {
7
- const value = tokens[index + 1];
8
- if (value === undefined || value.startsWith("--")) {
9
- throw new Error(`Missing value for ${optionName}.`);
10
- }
11
-
12
- return value;
13
- }
14
-
15
- function parseResolveOptions(tokens: string[]): {
16
- profileId?: string;
17
- } {
18
- let profileId: string | undefined;
19
-
20
- for (let index = 0; index < tokens.length; index += 1) {
21
- const token = tokens[index];
22
- if (token === "--profile-id") {
23
- const value = requireOptionValue(tokens, index, "--profile-id");
24
-
25
- const trimmedValue = value.trim();
26
- if (trimmedValue.length === 0) {
27
- throw new Error("--profile-id must be a non-empty string.");
28
- }
29
-
30
- profileId = trimmedValue;
31
- index += 1;
32
- continue;
33
- }
34
-
35
- throw new Error(`Unknown memory-resolve option: ${token}`);
36
- }
37
-
38
- return profileId === undefined ? {} : { profileId };
39
- }
40
-
41
- export async function runMemoryResolveCommand(args: string[]): Promise<MemoryResolveCommandResult> {
42
- const context = parseCommandContext(args);
43
- const domain = requirePositionalArg(context, 0, "domain");
44
- const intentKey = requirePositionalArg(context, 1, "intentKey");
45
- const options = parseResolveOptions(context.positional.slice(2));
46
- const profileId = options.profileId ?? context.profile ?? "default";
47
-
48
- return await callDaemonTool<MemoryResolveCommandResult>(
49
- "browser.memory.resolve",
50
- buildToolArguments(context, {
51
- domain,
52
- profileId,
53
- intentKey
54
- })
55
- );
56
- }
@@ -1,16 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext } from "./common";
3
-
4
- export type MemoryStatusCommandResult = Record<string, unknown>;
5
-
6
- export async function runMemoryStatusCommand(args: string[]): Promise<MemoryStatusCommandResult> {
7
- const context = parseCommandContext(args);
8
- if (context.positional.length > 0) {
9
- throw new Error(`Unknown memory-status option: ${context.positional[0]}`);
10
- }
11
-
12
- return await callDaemonTool<MemoryStatusCommandResult>(
13
- "browser.memory.status",
14
- buildToolArguments(context)
15
- );
16
- }
@@ -1,28 +0,0 @@
1
- import { callDaemonTool } from "../daemon-client";
2
- import { buildToolArguments, parseCommandContext, requirePositionalArg } from "./common";
3
-
4
- export type MemoryTtlSetCommandResult = Record<string, unknown>;
5
-
6
- function parseNonNegativeIntegerString(value: string): number {
7
- if (!/^(0|[1-9]\d*)$/.test(value)) {
8
- throw new Error("ttlDays must be a non-negative integer string.");
9
- }
10
-
11
- return Number.parseInt(value, 10);
12
- }
13
-
14
- export async function runMemoryTtlSetCommand(args: string[]): Promise<MemoryTtlSetCommandResult> {
15
- const context = parseCommandContext(args);
16
- const ttlDays = parseNonNegativeIntegerString(requirePositionalArg(context, 0, "ttlDays"));
17
-
18
- if (context.positional.length > 1) {
19
- throw new Error(`Unknown memory-ttl-set option: ${context.positional[1]}`);
20
- }
21
-
22
- return await callDaemonTool<MemoryTtlSetCommandResult>(
23
- "browser.memory.ttl.set",
24
- buildToolArguments(context, {
25
- ttlDays
26
- })
27
- );
28
- }