opencode-pair-autonomy 1.0.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 (128) hide show
  1. package/README.md +90 -0
  2. package/bin/opencode-pair-autonomy.js +20 -0
  3. package/dist/__tests__/comment-guard.test.d.ts +1 -0
  4. package/dist/__tests__/config.test.d.ts +1 -0
  5. package/dist/__tests__/learning.test.d.ts +1 -0
  6. package/dist/__tests__/plan-mode.test.d.ts +1 -0
  7. package/dist/agents.d.ts +2 -0
  8. package/dist/cli.d.ts +1 -0
  9. package/dist/cli.js +15351 -0
  10. package/dist/commands.d.ts +2 -0
  11. package/dist/config.d.ts +3 -0
  12. package/dist/hooks/comment-guard.d.ts +15 -0
  13. package/dist/hooks/file-edited.d.ts +7 -0
  14. package/dist/hooks/index.d.ts +46 -0
  15. package/dist/hooks/post-tool-use.d.ts +5 -0
  16. package/dist/hooks/pre-compact.d.ts +4 -0
  17. package/dist/hooks/pre-tool-use.d.ts +5 -0
  18. package/dist/hooks/prompt-refiner.d.ts +38 -0
  19. package/dist/hooks/runtime.d.ts +91 -0
  20. package/dist/hooks/sdk.d.ts +6 -0
  21. package/dist/hooks/session-end.d.ts +4 -0
  22. package/dist/hooks/session-start.d.ts +19 -0
  23. package/dist/hooks/stop.d.ts +5 -0
  24. package/dist/i18n/index.d.ts +15 -0
  25. package/dist/index.d.ts +3 -0
  26. package/dist/index.js +17823 -0
  27. package/dist/installer.d.ts +12 -0
  28. package/dist/learning/analyzer.d.ts +15 -0
  29. package/dist/learning/store.d.ts +4 -0
  30. package/dist/learning/types.d.ts +32 -0
  31. package/dist/mcp.d.ts +4 -0
  32. package/dist/project-facts.d.ts +8 -0
  33. package/dist/prompts/coordinator.d.ts +2 -0
  34. package/dist/prompts/shared.d.ts +5 -0
  35. package/dist/prompts/workers.d.ts +8 -0
  36. package/dist/types.d.ts +81 -0
  37. package/dist/utils.d.ts +6 -0
  38. package/examples/opencode-pair-autonomy.jsonc +35 -0
  39. package/examples/opencode.jsonc +17 -0
  40. package/package.json +103 -0
  41. package/vendor/mcp/pg-mcp/README.md +91 -0
  42. package/vendor/mcp/pg-mcp/config.example.json +26 -0
  43. package/vendor/mcp/pg-mcp/config.json +15 -0
  44. package/vendor/mcp/pg-mcp/package-lock.json +1288 -0
  45. package/vendor/mcp/pg-mcp/package.json +18 -0
  46. package/vendor/mcp/pg-mcp/src/config.js +71 -0
  47. package/vendor/mcp/pg-mcp/src/db.js +85 -0
  48. package/vendor/mcp/pg-mcp/src/index.js +203 -0
  49. package/vendor/mcp/pg-mcp/src/sqlGuard.js +75 -0
  50. package/vendor/mcp/pg-mcp/src/tools.js +89 -0
  51. package/vendor/mcp/ssh-mcp/README.md +46 -0
  52. package/vendor/mcp/ssh-mcp/config.example.json +23 -0
  53. package/vendor/mcp/ssh-mcp/config.json +6 -0
  54. package/vendor/mcp/ssh-mcp/package-lock.json +1142 -0
  55. package/vendor/mcp/ssh-mcp/package.json +18 -0
  56. package/vendor/mcp/ssh-mcp/src/config.js +140 -0
  57. package/vendor/mcp/ssh-mcp/src/index.js +130 -0
  58. package/vendor/mcp/ssh-mcp/src/ssh.js +163 -0
  59. package/vendor/mcp/sudo-mcp/README.md +51 -0
  60. package/vendor/mcp/sudo-mcp/config.example.json +28 -0
  61. package/vendor/mcp/sudo-mcp/config.json +28 -0
  62. package/vendor/mcp/sudo-mcp/package-lock.json +1145 -0
  63. package/vendor/mcp/sudo-mcp/package.json +18 -0
  64. package/vendor/mcp/sudo-mcp/src/config.js +57 -0
  65. package/vendor/mcp/sudo-mcp/src/index.js +267 -0
  66. package/vendor/mcp/sudo-mcp/src/runner.js +168 -0
  67. package/vendor/mcp/web-agent-mcp/package-lock.json +2886 -0
  68. package/vendor/mcp/web-agent-mcp/package.json +28 -0
  69. package/vendor/mcp/web-agent-mcp/src/adapters/cloakbrowser/adapter.ts +335 -0
  70. package/vendor/mcp/web-agent-mcp/src/adapters/cloakbrowser/auth-heuristics.ts +324 -0
  71. package/vendor/mcp/web-agent-mcp/src/adapters/cloakbrowser/launcher.ts +1340 -0
  72. package/vendor/mcp/web-agent-mcp/src/config/env.ts +107 -0
  73. package/vendor/mcp/web-agent-mcp/src/core/action-flow.ts +82 -0
  74. package/vendor/mcp/web-agent-mcp/src/core/artifact-store.ts +109 -0
  75. package/vendor/mcp/web-agent-mcp/src/core/errors.ts +108 -0
  76. package/vendor/mcp/web-agent-mcp/src/core/observation-flow.ts +38 -0
  77. package/vendor/mcp/web-agent-mcp/src/core/policy-engine.ts +113 -0
  78. package/vendor/mcp/web-agent-mcp/src/core/retry-policy.ts +42 -0
  79. package/vendor/mcp/web-agent-mcp/src/core/session-manager.ts +670 -0
  80. package/vendor/mcp/web-agent-mcp/src/core/session-restart-policy.ts +34 -0
  81. package/vendor/mcp/web-agent-mcp/src/core/task-history.ts +97 -0
  82. package/vendor/mcp/web-agent-mcp/src/index.ts +3 -0
  83. package/vendor/mcp/web-agent-mcp/src/schemas/act.ts +167 -0
  84. package/vendor/mcp/web-agent-mcp/src/schemas/common.ts +56 -0
  85. package/vendor/mcp/web-agent-mcp/src/schemas/observe.ts +214 -0
  86. package/vendor/mcp/web-agent-mcp/src/schemas/page.ts +21 -0
  87. package/vendor/mcp/web-agent-mcp/src/schemas/policy.ts +42 -0
  88. package/vendor/mcp/web-agent-mcp/src/schemas/runtime.ts +21 -0
  89. package/vendor/mcp/web-agent-mcp/src/schemas/session.ts +63 -0
  90. package/vendor/mcp/web-agent-mcp/src/server.ts +75 -0
  91. package/vendor/mcp/web-agent-mcp/src/tools/act/click.ts +68 -0
  92. package/vendor/mcp/web-agent-mcp/src/tools/act/drag.ts +57 -0
  93. package/vendor/mcp/web-agent-mcp/src/tools/act/enter-code.ts +78 -0
  94. package/vendor/mcp/web-agent-mcp/src/tools/act/fill.ts +65 -0
  95. package/vendor/mcp/web-agent-mcp/src/tools/act/pinch.ts +58 -0
  96. package/vendor/mcp/web-agent-mcp/src/tools/act/press.ts +67 -0
  97. package/vendor/mcp/web-agent-mcp/src/tools/act/shared.ts +73 -0
  98. package/vendor/mcp/web-agent-mcp/src/tools/act/swipe.ts +59 -0
  99. package/vendor/mcp/web-agent-mcp/src/tools/act/wait-for.ts +56 -0
  100. package/vendor/mcp/web-agent-mcp/src/tools/act/wheel.ts +59 -0
  101. package/vendor/mcp/web-agent-mcp/src/tools/observe/a11y.ts +60 -0
  102. package/vendor/mcp/web-agent-mcp/src/tools/observe/auth-state.ts +92 -0
  103. package/vendor/mcp/web-agent-mcp/src/tools/observe/boxes.ts +66 -0
  104. package/vendor/mcp/web-agent-mcp/src/tools/observe/console.ts +67 -0
  105. package/vendor/mcp/web-agent-mcp/src/tools/observe/dom.ts +60 -0
  106. package/vendor/mcp/web-agent-mcp/src/tools/observe/network.ts +67 -0
  107. package/vendor/mcp/web-agent-mcp/src/tools/observe/page-state.ts +93 -0
  108. package/vendor/mcp/web-agent-mcp/src/tools/observe/screenshot.ts +73 -0
  109. package/vendor/mcp/web-agent-mcp/src/tools/observe/text.ts +70 -0
  110. package/vendor/mcp/web-agent-mcp/src/tools/observe/wait-for-network.ts +70 -0
  111. package/vendor/mcp/web-agent-mcp/src/tools/page/navigate.ts +59 -0
  112. package/vendor/mcp/web-agent-mcp/src/tools/policy/recommend-observation.ts +40 -0
  113. package/vendor/mcp/web-agent-mcp/src/tools/register-tools.ts +55 -0
  114. package/vendor/mcp/web-agent-mcp/src/tools/runtime/evaluate-js.ts +83 -0
  115. package/vendor/mcp/web-agent-mcp/src/tools/session/close.ts +41 -0
  116. package/vendor/mcp/web-agent-mcp/src/tools/session/create.ts +86 -0
  117. package/vendor/mcp/web-agent-mcp/src/tools/session/restart.ts +72 -0
  118. package/vendor/mcp/web-agent-mcp/src/utils/fs.ts +28 -0
  119. package/vendor/mcp/web-agent-mcp/src/utils/ids.ts +9 -0
  120. package/vendor/mcp/web-agent-mcp/src/utils/time.ts +7 -0
  121. package/vendor/mcp/web-agent-mcp/tsconfig.json +22 -0
  122. package/vendor/skills/editorial-technical-ui/SKILL.md +84 -0
  123. package/vendor/skills/figma-console/SKILL.md +839 -0
  124. package/vendor/skills/go-fiber-postgres/SKILL.md +31 -0
  125. package/vendor/skills/opencode-plugin-dev/SKILL.md +31 -0
  126. package/vendor/skills/rust-media-desktop/SKILL.md +30 -0
  127. package/vendor/skills/vue-vite-ui/SKILL.md +31 -0
  128. package/vendor/skills/web-agent-browser/SKILL.md +140 -0
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { RuntimeServices } from "../../server.js";
4
+ import { actionResultSchema, wheelInputSchema } from "../../schemas/act.js";
5
+ import { createActionFailureResponse, createActionSuccessResult } from "./shared.js";
6
+
7
+ export function registerWheelTool(server: McpServer, services: RuntimeServices) {
8
+ server.registerTool(
9
+ "act.wheel",
10
+ {
11
+ title: "Wheel Scroll",
12
+ description: "Scroll the viewport or a target element using wheel input.",
13
+ inputSchema: wheelInputSchema,
14
+ outputSchema: actionResultSchema,
15
+ annotations: {
16
+ readOnlyHint: false,
17
+ destructiveHint: false,
18
+ idempotentHint: false,
19
+ openWorldHint: true
20
+ }
21
+ },
22
+ async (input: z.infer<typeof wheelInputSchema>) => {
23
+ try {
24
+ const action = await services.history.startAction("act.wheel", input, {
25
+ session_id: input.session_id,
26
+ page_id: input.page_id
27
+ });
28
+ const { session, page, result } = await services.sessions.wheel(input.session_id, input.page_id, {
29
+ selector: input.selector,
30
+ deltaX: input.delta_x,
31
+ deltaY: input.delta_y,
32
+ steps: input.steps,
33
+ stepDelayMs: input.step_delay_ms,
34
+ timeoutMs: input.timeout_ms
35
+ });
36
+ const data = { verificationHint: result.verificationHint };
37
+ services.sessions.recordSuccess(session.sessionId);
38
+ await services.history.finishAction(action, "succeeded", data);
39
+ return createActionSuccessResult({
40
+ actionId: action.action_id,
41
+ sessionId: session.sessionId,
42
+ pageId: page.pageId,
43
+ appliedMode: "physical",
44
+ verificationHint: result.verificationHint,
45
+ targetSelectorKnown: Boolean(input.selector)
46
+ });
47
+ } catch (error) {
48
+ return createActionFailureResponse({
49
+ services,
50
+ error,
51
+ sessionId: input.session_id,
52
+ pageId: input.page_id,
53
+ appliedMode: "physical",
54
+ targetSelectorKnown: Boolean(input.selector)
55
+ });
56
+ }
57
+ }
58
+ );
59
+ }
@@ -0,0 +1,60 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { buildFollowUpByGoal } from "../../core/observation-flow.js";
4
+ import type { RuntimeServices } from "../../server.js";
5
+ import { createFailureResult } from "../../core/errors.js";
6
+ import { createToolSuccess } from "../../schemas/common.js";
7
+ import { observeA11yOutputSchema, observeSessionInputSchema } from "../../schemas/observe.js";
8
+
9
+ export function registerObserveA11yTool(server: McpServer, services: RuntimeServices) {
10
+ server.registerTool(
11
+ "observe.a11y",
12
+ {
13
+ title: "Observe Accessibility Tree",
14
+ description: "Capture a structured accessibility snapshot for the current page.",
15
+ inputSchema: observeSessionInputSchema,
16
+ outputSchema: observeA11yOutputSchema,
17
+ annotations: {
18
+ readOnlyHint: true,
19
+ destructiveHint: false,
20
+ idempotentHint: false,
21
+ openWorldHint: false
22
+ }
23
+ },
24
+ async (input: z.infer<typeof observeSessionInputSchema>) => {
25
+ try {
26
+ const action = await services.history.startAction("observe.a11y", input, {
27
+ session_id: input.session_id,
28
+ page_id: input.page_id
29
+ });
30
+ const { session, page, result } = await services.sessions.observeA11y(
31
+ input.session_id,
32
+ input.page_id
33
+ );
34
+ const artifact = await services.artifacts.writeText("a11y", JSON.stringify(result, null, 2), {
35
+ session_id: session.sessionId,
36
+ page_id: page.pageId,
37
+ action_id: action.action_id,
38
+ url: result.url,
39
+ title: result.title
40
+ });
41
+ const data = {
42
+ snapshot_id: artifact.artifact_id,
43
+ format: "a11y",
44
+ url: result.url,
45
+ title: result.title,
46
+ tree: result,
47
+ follow_up_by_goal: buildFollowUpByGoal({
48
+ pageStateKnown: true,
49
+ targetSelectorKnown: false,
50
+ recentFailure: "none"
51
+ })
52
+ };
53
+ await services.history.finishAction(action, "succeeded", { snapshot_id: artifact.artifact_id });
54
+ return createToolSuccess({ ok: true, code: "OK", action_id: action.action_id, session_id: session.sessionId, page_id: page.pageId, artifact_ids: [artifact.artifact_id], data });
55
+ } catch (error) {
56
+ return createFailureResult(error);
57
+ }
58
+ }
59
+ );
60
+ }
@@ -0,0 +1,92 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { buildFollowUpByGoal } from "../../core/observation-flow.js";
4
+ import { createFailureResult } from "../../core/errors.js";
5
+ import {
6
+ authStateInputSchema,
7
+ observeAuthStateOutputSchema
8
+ } from "../../schemas/observe.js";
9
+ import { createToolSuccess } from "../../schemas/common.js";
10
+ import type { RuntimeServices } from "../../server.js";
11
+
12
+ export function registerObserveAuthStateTool(server: McpServer, services: RuntimeServices) {
13
+ server.registerTool(
14
+ "observe.auth_state",
15
+ {
16
+ title: "Observe Auth State",
17
+ description: "Classify login flows using page text, frames, and recent network activity.",
18
+ inputSchema: authStateInputSchema,
19
+ outputSchema: observeAuthStateOutputSchema,
20
+ annotations: {
21
+ readOnlyHint: true,
22
+ destructiveHint: false,
23
+ idempotentHint: false,
24
+ openWorldHint: true
25
+ }
26
+ },
27
+ async (input: z.infer<typeof authStateInputSchema>) => {
28
+ try {
29
+ const action = await services.history.startAction("observe.auth_state", input, {
30
+ session_id: input.session_id,
31
+ page_id: input.page_id
32
+ });
33
+ const { session, page, result } = await services.sessions.observeAuthState(
34
+ input.session_id,
35
+ input.page_id,
36
+ input.recent_network_limit
37
+ );
38
+
39
+ const followUpByGoal = buildFollowUpByGoal({
40
+ pageStateKnown: true,
41
+ targetSelectorKnown: result.suggestedSelectors.length > 0,
42
+ recentFailure: "none"
43
+ });
44
+
45
+ const artifact = await services.artifacts.writeText("dom", JSON.stringify(result, null, 2), {
46
+ session_id: session.sessionId,
47
+ page_id: page.pageId,
48
+ action_id: action.action_id,
49
+ url: result.url,
50
+ title: result.title,
51
+ meta: {
52
+ state: result.state,
53
+ confidence: result.confidence,
54
+ suggested_selector_count: result.suggestedSelectors.length
55
+ }
56
+ });
57
+
58
+ const data = {
59
+ snapshot_id: artifact.artifact_id,
60
+ url: result.url,
61
+ title: result.title,
62
+ state: result.state,
63
+ confidence: result.confidence,
64
+ summary: result.summary,
65
+ evidence: result.evidence,
66
+ suggested_selectors: result.suggestedSelectors,
67
+ candidate_frames: result.frames,
68
+ recent_network: result.recentNetwork,
69
+ follow_up_by_goal: followUpByGoal
70
+ };
71
+
72
+ await services.history.finishAction(action, "succeeded", {
73
+ snapshot_id: artifact.artifact_id,
74
+ state: result.state,
75
+ confidence: result.confidence
76
+ });
77
+
78
+ return createToolSuccess({
79
+ ok: true,
80
+ code: "OK",
81
+ action_id: action.action_id,
82
+ session_id: session.sessionId,
83
+ page_id: page.pageId,
84
+ artifact_ids: [artifact.artifact_id],
85
+ data
86
+ });
87
+ } catch (error) {
88
+ return createFailureResult(error);
89
+ }
90
+ }
91
+ );
92
+ }
@@ -0,0 +1,66 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { RuntimeServices } from "../../server.js";
4
+ import { createFailureResult } from "../../core/errors.js";
5
+ import { createToolSuccess } from "../../schemas/common.js";
6
+ import { boxesInputSchema, observeBoxesOutputSchema } from "../../schemas/observe.js";
7
+
8
+ export function registerObserveBoxesTool(server: McpServer, services: RuntimeServices) {
9
+ server.registerTool(
10
+ "observe.boxes",
11
+ {
12
+ title: "Observe Element Boxes",
13
+ description: "Resolve bounding boxes for one or more CSS selectors on the current page.",
14
+ inputSchema: boxesInputSchema,
15
+ outputSchema: observeBoxesOutputSchema,
16
+ annotations: {
17
+ readOnlyHint: true,
18
+ destructiveHint: false,
19
+ idempotentHint: false,
20
+ openWorldHint: false
21
+ }
22
+ },
23
+ async (input: z.infer<typeof boxesInputSchema>) => {
24
+ try {
25
+ const action = await services.history.startAction("observe.boxes", input, {
26
+ session_id: input.session_id,
27
+ page_id: input.page_id
28
+ });
29
+ const { session, page, result } = await services.sessions.observeBoxes(
30
+ input.session_id,
31
+ input.page_id,
32
+ input.selectors
33
+ );
34
+ const artifact = await services.artifacts.writeText("boxes", JSON.stringify(result, null, 2), {
35
+ session_id: session.sessionId,
36
+ page_id: page.pageId,
37
+ action_id: action.action_id,
38
+ url: page.url,
39
+ title: page.title,
40
+ meta: {
41
+ selector_count: input.selectors.length
42
+ }
43
+ });
44
+ const data = {
45
+ element_map_id: artifact.artifact_id,
46
+ elements: result
47
+ };
48
+ await services.history.finishAction(action, "succeeded", {
49
+ element_map_id: artifact.artifact_id,
50
+ element_count: result.length
51
+ });
52
+ return createToolSuccess({
53
+ ok: true,
54
+ code: "OK",
55
+ action_id: action.action_id,
56
+ session_id: session.sessionId,
57
+ page_id: page.pageId,
58
+ artifact_ids: [artifact.artifact_id],
59
+ data
60
+ });
61
+ } catch (error) {
62
+ return createFailureResult(error);
63
+ }
64
+ }
65
+ );
66
+ }
@@ -0,0 +1,67 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { RuntimeServices } from "../../server.js";
4
+ import { createFailureResult } from "../../core/errors.js";
5
+ import { createToolSuccess } from "../../schemas/common.js";
6
+ import { logsInputSchema, observeLogsOutputSchema } from "../../schemas/observe.js";
7
+
8
+ export function registerObserveConsoleTool(server: McpServer, services: RuntimeServices) {
9
+ server.registerTool(
10
+ "observe.console",
11
+ {
12
+ title: "Observe Console Logs",
13
+ description: "Return recent browser console entries captured for the current page.",
14
+ inputSchema: logsInputSchema,
15
+ outputSchema: observeLogsOutputSchema,
16
+ annotations: {
17
+ readOnlyHint: true,
18
+ destructiveHint: false,
19
+ idempotentHint: false,
20
+ openWorldHint: false
21
+ }
22
+ },
23
+ async (input: z.infer<typeof logsInputSchema>) => {
24
+ try {
25
+ const action = await services.history.startAction("observe.console", input, {
26
+ session_id: input.session_id,
27
+ page_id: input.page_id
28
+ });
29
+ const { session, page, result } = await services.sessions.observeConsole(
30
+ input.session_id,
31
+ input.page_id,
32
+ input.limit
33
+ );
34
+ const artifact = await services.artifacts.writeText("console", JSON.stringify(result, null, 2), {
35
+ session_id: session.sessionId,
36
+ page_id: page.pageId,
37
+ action_id: action.action_id,
38
+ url: page.url,
39
+ title: page.title,
40
+ meta: {
41
+ limit: input.limit,
42
+ entry_count: result.length
43
+ }
44
+ });
45
+ const data = {
46
+ artifact_id: artifact.artifact_id,
47
+ entries: result
48
+ };
49
+ await services.history.finishAction(action, "succeeded", {
50
+ artifact_id: artifact.artifact_id,
51
+ entry_count: result.length
52
+ });
53
+ return createToolSuccess({
54
+ ok: true,
55
+ code: "OK",
56
+ action_id: action.action_id,
57
+ session_id: session.sessionId,
58
+ page_id: page.pageId,
59
+ artifact_ids: [artifact.artifact_id],
60
+ data
61
+ });
62
+ } catch (error) {
63
+ return createFailureResult(error);
64
+ }
65
+ }
66
+ );
67
+ }
@@ -0,0 +1,60 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { buildFollowUpByGoal } from "../../core/observation-flow.js";
4
+ import type { RuntimeServices } from "../../server.js";
5
+ import { createFailureResult } from "../../core/errors.js";
6
+ import { createToolSuccess } from "../../schemas/common.js";
7
+ import { observeDomOutputSchema, observeSessionInputSchema } from "../../schemas/observe.js";
8
+
9
+ export function registerObserveDomTool(server: McpServer, services: RuntimeServices) {
10
+ server.registerTool(
11
+ "observe.dom",
12
+ {
13
+ title: "Observe DOM Summary",
14
+ description: "Return a lightweight DOM summary for the current page.",
15
+ inputSchema: observeSessionInputSchema,
16
+ outputSchema: observeDomOutputSchema,
17
+ annotations: {
18
+ readOnlyHint: true,
19
+ destructiveHint: false,
20
+ idempotentHint: false,
21
+ openWorldHint: false
22
+ }
23
+ },
24
+ async (input: z.infer<typeof observeSessionInputSchema>) => {
25
+ try {
26
+ const action = await services.history.startAction("observe.dom", input, {
27
+ session_id: input.session_id,
28
+ page_id: input.page_id
29
+ });
30
+ const { session, page, result } = await services.sessions.observeDom(
31
+ input.session_id,
32
+ input.page_id
33
+ );
34
+ const artifact = await services.artifacts.writeText("dom", JSON.stringify(result, null, 2), {
35
+ session_id: session.sessionId,
36
+ page_id: page.pageId,
37
+ action_id: action.action_id,
38
+ url: result.url,
39
+ title: result.title
40
+ });
41
+ const data = {
42
+ snapshot_id: artifact.artifact_id,
43
+ format: "dom",
44
+ url: result.url,
45
+ title: result.title,
46
+ dom_summary: result.summary,
47
+ follow_up_by_goal: buildFollowUpByGoal({
48
+ pageStateKnown: true,
49
+ targetSelectorKnown: false,
50
+ recentFailure: "none"
51
+ })
52
+ };
53
+ await services.history.finishAction(action, "succeeded", { snapshot_id: artifact.artifact_id });
54
+ return createToolSuccess({ ok: true, code: "OK", action_id: action.action_id, session_id: session.sessionId, page_id: page.pageId, artifact_ids: [artifact.artifact_id], data });
55
+ } catch (error) {
56
+ return createFailureResult(error);
57
+ }
58
+ }
59
+ );
60
+ }
@@ -0,0 +1,67 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { RuntimeServices } from "../../server.js";
4
+ import { createFailureResult } from "../../core/errors.js";
5
+ import { createToolSuccess } from "../../schemas/common.js";
6
+ import { logsInputSchema, observeLogsOutputSchema } from "../../schemas/observe.js";
7
+
8
+ export function registerObserveNetworkTool(server: McpServer, services: RuntimeServices) {
9
+ server.registerTool(
10
+ "observe.network",
11
+ {
12
+ title: "Observe Network Logs",
13
+ description: "Return recent network events captured for the current page.",
14
+ inputSchema: logsInputSchema,
15
+ outputSchema: observeLogsOutputSchema,
16
+ annotations: {
17
+ readOnlyHint: true,
18
+ destructiveHint: false,
19
+ idempotentHint: false,
20
+ openWorldHint: false
21
+ }
22
+ },
23
+ async (input: z.infer<typeof logsInputSchema>) => {
24
+ try {
25
+ const action = await services.history.startAction("observe.network", input, {
26
+ session_id: input.session_id,
27
+ page_id: input.page_id
28
+ });
29
+ const { session, page, result } = await services.sessions.observeNetwork(
30
+ input.session_id,
31
+ input.page_id,
32
+ input.limit
33
+ );
34
+ const artifact = await services.artifacts.writeText("network", JSON.stringify(result, null, 2), {
35
+ session_id: session.sessionId,
36
+ page_id: page.pageId,
37
+ action_id: action.action_id,
38
+ url: page.url,
39
+ title: page.title,
40
+ meta: {
41
+ limit: input.limit,
42
+ entry_count: result.length
43
+ }
44
+ });
45
+ const data = {
46
+ artifact_id: artifact.artifact_id,
47
+ entries: result
48
+ };
49
+ await services.history.finishAction(action, "succeeded", {
50
+ artifact_id: artifact.artifact_id,
51
+ entry_count: result.length
52
+ });
53
+ return createToolSuccess({
54
+ ok: true,
55
+ code: "OK",
56
+ action_id: action.action_id,
57
+ session_id: session.sessionId,
58
+ page_id: page.pageId,
59
+ artifact_ids: [artifact.artifact_id],
60
+ data
61
+ });
62
+ } catch (error) {
63
+ return createFailureResult(error);
64
+ }
65
+ }
66
+ );
67
+ }
@@ -0,0 +1,93 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { buildFollowUpByGoal } from "../../core/observation-flow.js";
4
+ import { createFailureResult } from "../../core/errors.js";
5
+ import {
6
+ observePageStateOutputSchema,
7
+ pageStateInputSchema
8
+ } from "../../schemas/observe.js";
9
+ import { createToolSuccess } from "../../schemas/common.js";
10
+ import type { RuntimeServices } from "../../server.js";
11
+
12
+ export function registerObservePageStateTool(server: McpServer, services: RuntimeServices) {
13
+ server.registerTool(
14
+ "observe.page_state",
15
+ {
16
+ title: "Observe Page State",
17
+ description: "Return a composite page snapshot with text, frames, controls, and recent network activity.",
18
+ inputSchema: pageStateInputSchema,
19
+ outputSchema: observePageStateOutputSchema,
20
+ annotations: {
21
+ readOnlyHint: true,
22
+ destructiveHint: false,
23
+ idempotentHint: false,
24
+ openWorldHint: true
25
+ }
26
+ },
27
+ async (input: z.infer<typeof pageStateInputSchema>) => {
28
+ try {
29
+ const action = await services.history.startAction("observe.page_state", input, {
30
+ session_id: input.session_id,
31
+ page_id: input.page_id
32
+ });
33
+ const { session, page, result } = await services.sessions.observePageState(
34
+ input.session_id,
35
+ input.page_id,
36
+ input.recent_network_limit
37
+ );
38
+
39
+ const followUpByGoal = buildFollowUpByGoal({
40
+ pageStateKnown: true,
41
+ targetSelectorKnown: result.inputs.length > 0 || result.buttons.length > 0,
42
+ recentFailure: "none"
43
+ });
44
+
45
+ const artifact = await services.artifacts.writeText("dom", JSON.stringify(result, null, 2), {
46
+ session_id: session.sessionId,
47
+ page_id: page.pageId,
48
+ action_id: action.action_id,
49
+ url: result.url,
50
+ title: result.title,
51
+ meta: {
52
+ frame_count: result.frames.length,
53
+ input_count: result.inputs.length,
54
+ button_count: result.buttons.length,
55
+ recent_network_count: result.recentNetwork.length
56
+ }
57
+ });
58
+
59
+ const data = {
60
+ snapshot_id: artifact.artifact_id,
61
+ url: result.url,
62
+ title: result.title,
63
+ text: result.text,
64
+ truncated: result.truncated,
65
+ dom_summary: result.dom,
66
+ inputs: result.inputs,
67
+ buttons: result.buttons,
68
+ frames: result.frames,
69
+ recent_network: result.recentNetwork,
70
+ follow_up_by_goal: followUpByGoal
71
+ };
72
+
73
+ await services.history.finishAction(action, "succeeded", {
74
+ snapshot_id: artifact.artifact_id,
75
+ frame_count: result.frames.length,
76
+ recent_network_count: result.recentNetwork.length
77
+ });
78
+
79
+ return createToolSuccess({
80
+ ok: true,
81
+ code: "OK",
82
+ action_id: action.action_id,
83
+ session_id: session.sessionId,
84
+ page_id: page.pageId,
85
+ artifact_ids: [artifact.artifact_id],
86
+ data
87
+ });
88
+ } catch (error) {
89
+ return createFailureResult(error);
90
+ }
91
+ }
92
+ );
93
+ }
@@ -0,0 +1,73 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { buildFollowUpByGoal } from "../../core/observation-flow.js";
4
+ import type { RuntimeServices } from "../../server.js";
5
+ import { createFailureResult } from "../../core/errors.js";
6
+ import { createToolSuccess } from "../../schemas/common.js";
7
+ import { observeScreenshotOutputSchema, screenshotInputSchema } from "../../schemas/observe.js";
8
+
9
+ export function registerObserveScreenshotTool(server: McpServer, services: RuntimeServices) {
10
+ server.registerTool(
11
+ "observe.screenshot",
12
+ {
13
+ title: "Observe Screenshot",
14
+ description: "Capture a viewport, full-page, or element screenshot and persist it as an artifact.",
15
+ inputSchema: screenshotInputSchema,
16
+ outputSchema: observeScreenshotOutputSchema,
17
+ annotations: {
18
+ readOnlyHint: true,
19
+ destructiveHint: false,
20
+ idempotentHint: false,
21
+ openWorldHint: false
22
+ }
23
+ },
24
+ async (input: z.infer<typeof screenshotInputSchema>) => {
25
+ try {
26
+ const action = await services.history.startAction("observe.screenshot", input, {
27
+ session_id: input.session_id,
28
+ page_id: input.page_id
29
+ });
30
+ const { session, page, result } = await services.sessions.takeScreenshot(
31
+ input.session_id,
32
+ input.page_id,
33
+ input.mode,
34
+ input.format,
35
+ input.quality,
36
+ input.selector
37
+ );
38
+ const artifact = await services.artifacts.writeBinary("screenshot", result.bytes, input.format, {
39
+ session_id: session.sessionId,
40
+ page_id: page.pageId,
41
+ action_id: action.action_id,
42
+ url: result.url,
43
+ title: result.title,
44
+ meta: {
45
+ mode: input.mode,
46
+ selector: input.selector,
47
+ format: input.format,
48
+ quality: input.quality
49
+ }
50
+ });
51
+ const data = {
52
+ screenshot_id: artifact.artifact_id,
53
+ mode: input.mode,
54
+ width: result.width,
55
+ height: result.height,
56
+ bytes: artifact.bytes,
57
+ mime_type: result.mimeType,
58
+ storage_path: artifact.storage_path,
59
+ follow_up_by_goal: buildFollowUpByGoal({
60
+ pageStateKnown: true,
61
+ targetSelectorKnown: Boolean(input.selector),
62
+ needsFullPageContext: input.mode === "full",
63
+ recentFailure: input.mode === "viewport" ? "layout_uncertain" : "none"
64
+ })
65
+ };
66
+ await services.history.finishAction(action, "succeeded", { screenshot_id: artifact.artifact_id });
67
+ return createToolSuccess({ ok: true, code: "OK", action_id: action.action_id, session_id: session.sessionId, page_id: page.pageId, artifact_ids: [artifact.artifact_id], data });
68
+ } catch (error) {
69
+ return createFailureResult(error);
70
+ }
71
+ }
72
+ );
73
+ }