@nudge-ui/mcp 0.2.4 → 0.2.6
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 +18 -0
- package/dist/adapterRouting.d.ts +0 -1
- package/dist/adapterRouting.js +0 -1
- package/dist/bridge.d.ts +6 -57
- package/dist/bridge.js +293 -806
- package/dist/bridgeSession.d.ts +87 -0
- package/dist/bridgeSession.js +438 -0
- package/dist/cli.d.ts +3 -30
- package/dist/cli.js +54 -169
- package/dist/cli.mjs +237 -1372
- package/dist/discovery.d.ts +5 -6
- package/dist/discovery.js +5 -8
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/internal/agent-protocol.d.ts +53 -38
- package/dist/internal/agent-protocol.js +151 -42
- package/dist/project.d.ts +2 -7
- package/dist/project.js +5 -10
- package/dist/projectSessionClient.d.ts +4 -6
- package/dist/projectSessionClient.js +37 -15
- package/dist/protocol.d.ts +4 -20
- package/dist/protocol.js +3 -18
- package/dist/server.d.ts +3 -28
- package/dist/server.js +65 -137
- package/dist/sessionRegistry.d.ts +0 -2
- package/dist/sessionRegistry.js +1 -23
- package/package.json +1 -16
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/adapterRouting.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export interface ProjectTarget {
|
|
|
3
3
|
readonly workspaceRoot?: string;
|
|
4
4
|
readonly sessionId?: string;
|
|
5
5
|
}
|
|
6
|
-
/** Keeps each explicit project selection independent for the lifetime of an MCP connection. */
|
|
7
6
|
export declare class AdapterRouting {
|
|
8
7
|
readonly registryRoot: string;
|
|
9
8
|
private closing;
|
package/dist/adapterRouting.js
CHANGED
|
@@ -4,7 +4,6 @@ import { DiscoveredProjectRouter } from "./discovery.js";
|
|
|
4
4
|
import { defaultSessionRegistryRoot, resolveWorkspaceRoot } from "./project.js";
|
|
5
5
|
import { readLiveProjectSessions } from "./sessionRegistry.js";
|
|
6
6
|
import { selectProjectSession } from "./sessionSelection.js";
|
|
7
|
-
/** Keeps each explicit project selection independent for the lifetime of an MCP connection. */
|
|
8
7
|
export class AdapterRouting {
|
|
9
8
|
registryRoot;
|
|
10
9
|
closing = false;
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import { type
|
|
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
|
-
/** Stable project identity used to scope every browser message. */
|
|
11
3
|
readonly projectId: string;
|
|
12
|
-
/** Canonical app origin that
|
|
13
|
-
readonly origin
|
|
14
|
-
/**
|
|
4
|
+
/** Canonical app origin that pairing and Canvas routes must use. */
|
|
5
|
+
readonly origin: string;
|
|
6
|
+
/** Other explicit browser origins, such as loopback aliases on the same port. */
|
|
15
7
|
readonly allowedOrigins?: readonly string[];
|
|
16
8
|
readonly host?: "127.0.0.1" | "::1" | "localhost";
|
|
17
9
|
/** Use port 0 in tests or when several projects run concurrently. */
|
|
@@ -24,60 +16,17 @@ export interface BrowserBridgeOptions {
|
|
|
24
16
|
readonly idFactory?: () => string;
|
|
25
17
|
/** Private credential for a separately running MCP adapter. */
|
|
26
18
|
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
19
|
}
|
|
33
20
|
export interface BridgeAddress {
|
|
34
21
|
readonly host: string;
|
|
35
22
|
readonly port: number;
|
|
36
23
|
readonly url: string;
|
|
37
24
|
}
|
|
38
|
-
export
|
|
39
|
-
export interface BrowserBridge {
|
|
40
|
-
readonly httpServer: Server;
|
|
25
|
+
export interface BrowserBridge extends BridgeSessionControls {
|
|
41
26
|
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
27
|
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
28
|
start(): Promise<BridgeAddress>;
|
|
52
29
|
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
30
|
}
|
|
68
|
-
|
|
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
|
-
/**
|
|
80
|
-
* Creates the local browser bridge. It binds only to loopback and keeps every
|
|
81
|
-
* pairing, prompt, command, and acknowledgement in process memory.
|
|
82
|
-
*/
|
|
31
|
+
/** Binds only to loopback and keeps every pairing, prompt, command, and acknowledgement in process memory. */
|
|
83
32
|
export declare function createLoopbackBridge(options: BrowserBridgeOptions): BrowserBridge;
|