@nudge-ui/mcp 0.2.3 → 0.2.5

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.
package/README.md CHANGED
@@ -64,6 +64,7 @@ uses pnpm, Yarn, or Bun. The package requires Node.js 20 or later.
64
64
  | --- | --- |
65
65
  | `nudge_list_sessions` | Discover running apps in the requested workspace. |
66
66
  | `nudge_listen` | Wait for the next implementation request. `nudge_connect` is an alias. |
67
+ | `nudge_get_request` | Recover an unacknowledged request and its sketch images by request ID. |
67
68
  | `nudge_get_status` | Read connection and request status. |
68
69
  | `nudge_report_activity` | Highlight Canvas frames associated with a file read or edit. |
69
70
  | `nudge_report_status` | Report working, completed, failed, or interrupted status. |
@@ -108,6 +109,23 @@ initializer's `--agent-only` mode to update the agent integration.
108
109
 
109
110
  The MCP adapter delivers requests through an active tool call. It cannot start
110
111
  a new agent turn after the host has ended the conversation or stopped waiting.
112
+ If the host wraps tools in `functions.exec` and returns a running cell ID,
113
+ keep the agent turn active and collect the result with `functions.wait`. A wrapper
114
+ yield does not complete the listening call.
115
+
116
+ A browser dispatch enters `delivered` while awaiting agent acknowledgment. The
117
+ agent must call `nudge_report_status` with `working` before starting work. If a
118
+ listening result was not collected, call `nudge_listen` again to recover the same
119
+ prompt and sketch images. `nudge_get_request` also supports explicit recovery by ID. Recovery
120
+ does not acknowledge or redispatch the request. Attachment bytes are retained in
121
+ memory until acknowledgment or interruption; no requests survive a bridge restart.
122
+
123
+ Unacknowledged deliveries expire after 60 seconds and become `interrupted`.
124
+ Recovery does not extend this deadline. The terminal outcome remains visible until
125
+ the agent listens again; the browser can then resend the prompt. Late
126
+ acknowledgments cannot revive an interrupted request. Both the project bridge and
127
+ adapter must use protocol version 3; upgrade both and restart them together.
128
+
111
129
  If a listening call times out, ask the agent to listen again and adjust the
112
130
  host's MCP timeout if supported.
113
131
 
package/dist/bridge.d.ts CHANGED
@@ -1,17 +1,10 @@
1
- import { type Server } from "node:http";
2
- import type { AgentActivity, AgentDeliveredPrompt, AgentRequestOutcome, AgentStatusSnapshot, AgentStatusUpdate, CanvasCommandResult, PairingResponse } from "./internal/agent-protocol.js";
3
- /** A clock port keeps command timeout tests deterministic. */
4
- export interface BridgeClock {
5
- now(): number;
6
- setTimeout(callback: () => void, delayMs: number): unknown;
7
- clearTimeout(handle: unknown): void;
8
- }
1
+ import { type BridgeClock, type BridgeSessionControls } from "./bridgeSession.js";
9
2
  export interface BrowserBridgeOptions {
10
3
  /** Stable project identity used to scope every browser message. */
11
4
  readonly projectId: string;
12
- /** Canonical app origin that browser routes must use. */
13
- readonly origin?: string;
14
- /** Explicit browser origins accepted by the loopback HTTP server. */
5
+ /** Canonical app origin that pairing and Canvas routes must use. */
6
+ readonly origin: string;
7
+ /** Other explicit browser origins accepted by the loopback HTTP server. */
15
8
  readonly allowedOrigins?: readonly string[];
16
9
  readonly host?: "127.0.0.1" | "::1" | "localhost";
17
10
  /** Use port 0 in tests or when several projects run concurrently. */
@@ -24,58 +17,19 @@ export interface BrowserBridgeOptions {
24
17
  readonly idFactory?: () => string;
25
18
  /** Private credential for a separately running MCP adapter. */
26
19
  readonly agentControlToken?: string;
27
- /**
28
- * Best-effort hook used by the CLI to reopen the last paired page when an
29
- * agent rearms listening but no browser controller stream is attached.
30
- */
31
- readonly onControllerUnavailable?: (pageUrl: string) => Promise<void> | void;
32
20
  }
33
21
  export interface BridgeAddress {
34
22
  readonly host: string;
35
23
  readonly port: number;
36
24
  readonly url: string;
37
25
  }
38
- export type BridgeLifecycle = "created" | "listening" | "closed";
39
- export interface BrowserBridge {
40
- readonly httpServer: Server;
26
+ /** A loopback HTTP server exposing one project session to its browser and MCP adapter. */
27
+ export interface BrowserBridge extends BridgeSessionControls {
41
28
  readonly projectId: string;
42
- readonly origin: string | null;
43
- /** The configured origin, or the explicitly approved browser origin. */
44
- readonly effectiveOrigin: string | null;
45
- readonly lifecycle: BridgeLifecycle;
46
29
  readonly address: BridgeAddress | null;
47
- readonly sessionToken: string | null;
48
- readonly lastPageUrl: string | null;
49
- /** Current companion/browser state, safe to expose to the browser. */
50
- getStatus(): AgentStatusSnapshot;
51
30
  start(): Promise<BridgeAddress>;
52
31
  close(): Promise<void>;
53
- /** Blocks until a paired browser dispatches a prompt. */
54
- waitForPrompt(signal?: AbortSignal, sessionId?: string, agentClientName?: string): Promise<AgentDeliveredPrompt>;
55
- /** Marks the agent-side listener as stopped without ending the project. */
56
- cancelListener(reason?: string): void;
57
- /** Emits temporary source attribution for the currently working request. */
58
- reportActivity(activity: AgentActivity): void;
59
- /** Reports the terminal result for the currently running browser request. */
60
- updateRequestStatus(update: AgentStatusUpdate | AgentRequestOutcome): void;
61
- /** Sends a Canvas command to the browser and waits for one bounded ack. */
62
- dispatchCanvasCommand(command: CanvasCommandInput): Promise<CanvasCommandResult>;
63
- /** Returns the currently paired browser token to the host process only. */
64
- pairBrowser(projectId: string, requestOrigin: string, pageUrl?: string): PairingResponse;
65
- /** Revokes a browser pairing; no data is written to disk. */
66
- disconnectBrowser(token: string): void;
67
32
  }
68
- export type CanvasCommandInput = Omit<import("./internal/agent-protocol.js").ReadCanvasStateCommand, "commandId"> & {
69
- readonly commandId?: string;
70
- } | Omit<import("./internal/agent-protocol.js").PresentRoutesCommand, "commandId"> & {
71
- readonly commandId?: string;
72
- } | Omit<import("./internal/agent-protocol.js").FocusCanvasGroupCommand, "commandId"> & {
73
- readonly commandId?: string;
74
- } | Omit<import("./internal/agent-protocol.js").FitCanvasCommand, "commandId"> & {
75
- readonly commandId?: string;
76
- } | Omit<import("./internal/agent-protocol.js").RemoveCanvasGroupCommand, "commandId"> & {
77
- readonly commandId?: string;
78
- };
79
33
  /**
80
34
  * Creates the local browser bridge. It binds only to loopback and keeps every
81
35
  * pairing, prompt, command, and acknowledgement in process memory.