@nuvin/session 0.1.0-rc.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/dist/chunk-3IPZO7LP.js +66 -0
- package/dist/chunk-7G3R25NS.js +6 -0
- package/dist/chunk-DGC7JSCG.js +0 -0
- package/dist/chunk-FR3R66RD.js +678 -0
- package/dist/chunk-UVJIG4DT.js +17 -0
- package/dist/client/directory.d.ts +141 -0
- package/dist/client/directory.d.ts.map +1 -0
- package/dist/client/endpoint.d.ts +33 -0
- package/dist/client/endpoint.d.ts.map +1 -0
- package/dist/client/index.d.ts +8 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +1060 -0
- package/dist/client/session-client.d.ts +60 -0
- package/dist/client/session-client.d.ts.map +1 -0
- package/dist/client/socket.d.ts +38 -0
- package/dist/client/socket.d.ts.map +1 -0
- package/dist/client/transport.d.ts +9 -0
- package/dist/client/transport.d.ts.map +1 -0
- package/dist/client/uds-socket.d.ts +23 -0
- package/dist/client/uds-socket.d.ts.map +1 -0
- package/dist/client/websocket.d.ts +54 -0
- package/dist/client/websocket.d.ts.map +1 -0
- package/dist/controller/agent-channel.d.ts +58 -0
- package/dist/controller/agent-channel.d.ts.map +1 -0
- package/dist/controller/index.d.ts +3 -0
- package/dist/controller/index.d.ts.map +1 -0
- package/dist/controller/index.js +441 -0
- package/dist/controller/session-controller.d.ts +147 -0
- package/dist/controller/session-controller.d.ts.map +1 -0
- package/dist/controller/test-utils.d.ts +15 -0
- package/dist/controller/test-utils.d.ts.map +1 -0
- package/dist/grant/index.d.ts +33 -0
- package/dist/grant/index.d.ts.map +1 -0
- package/dist/grant/index.js +12 -0
- package/dist/protocol/index.d.ts +3 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +7 -0
- package/dist/protocol/types.d.ts +855 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/version.d.ts +8 -0
- package/dist/protocol/version.d.ts.map +1 -0
- package/dist/state/approvals.d.ts +34 -0
- package/dist/state/approvals.d.ts.map +1 -0
- package/dist/state/dir-access.d.ts +9 -0
- package/dist/state/dir-access.d.ts.map +1 -0
- package/dist/state/index.d.ts +6 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +48 -0
- package/dist/state/json.d.ts +7 -0
- package/dist/state/json.d.ts.map +1 -0
- package/dist/state/messages.d.ts +105 -0
- package/dist/state/messages.d.ts.map +1 -0
- package/dist/state/session.d.ts +9 -0
- package/dist/state/session.d.ts.map +1 -0
- package/dist/state/tool-preview.d.ts +31 -0
- package/dist/state/tool-preview.d.ts.map +1 -0
- package/dist/state/tool-preview.js +300 -0
- package/dist/state/workflow-view.d.ts +10 -0
- package/dist/state/workflow-view.d.ts.map +1 -0
- package/dist/test-utils/fake-relay.d.ts +24 -0
- package/dist/test-utils/fake-relay.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +2 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/test-utils/index.js +250 -0
- package/dist/ui/history-grouping.d.ts +36 -0
- package/dist/ui/history-grouping.d.ts.map +1 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +135 -0
- package/dist/ui/picker-rows.d.ts +62 -0
- package/dist/ui/picker-rows.d.ts.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { AgentInput, AskUserAnswers } from "@nuvin/agent-core/shared";
|
|
2
|
+
import type { ModelCompletion, ServerEvent, SessionViewState, SlashCommandDescriptor } from "../protocol/types.ts";
|
|
3
|
+
import type { ClientTransport } from "./transport.ts";
|
|
4
|
+
export type ClientSubmitOptions = {
|
|
5
|
+
displayText: string;
|
|
6
|
+
attachmentLabels?: string[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Client-side mirror of the replicated session state. Applies every incoming
|
|
10
|
+
* `ServerEvent` through the same reducer the controller runs (parity by
|
|
11
|
+
* construction) and correlates commands with their acks.
|
|
12
|
+
*/
|
|
13
|
+
export interface SessionClient {
|
|
14
|
+
getState(): SessionViewState;
|
|
15
|
+
getSeq(): number;
|
|
16
|
+
subscribe(listener: () => void): () => void;
|
|
17
|
+
/** Raw frame hook for UI side-effects (e.g. close modals on state-reset). */
|
|
18
|
+
onEvent(listener: (event: ServerEvent) => void): () => void;
|
|
19
|
+
submit(input: AgentInput, opts: ClientSubmitOptions): Promise<void>;
|
|
20
|
+
decideApproval(toolCallId: string, decision: "a" | "n" | "y", comment?: string, grantDir?: string): Promise<void>;
|
|
21
|
+
answerQuestion(questionId: string, answers: AskUserAnswers): Promise<void>;
|
|
22
|
+
abort(): Promise<void>;
|
|
23
|
+
/** Cancel a queued (not-yet-running) message by its `turn-status.queued` id. */
|
|
24
|
+
dequeueMessage(queuedId: string): Promise<void>;
|
|
25
|
+
runSlashCommand(raw: string): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Resume a persisted transcript into this session (spec §4.4 load-history —
|
|
28
|
+
* the picker's Local resume path). The host loads the transcript and
|
|
29
|
+
* republishes through a state-reset event; this resolves on the ack.
|
|
30
|
+
*/
|
|
31
|
+
loadHistory(historyId: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Signal the daemon to reload provider keys / config after local onboarding
|
|
34
|
+
* wrote them to the shared config dir (spec §10/§12). Resolves on the ack.
|
|
35
|
+
*/
|
|
36
|
+
reloadConfig(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Abort the in-flight MCP OAuth login (spec §10). Sends `cancel-auth-flow`;
|
|
39
|
+
* the daemon invokes its live cancel handle, which publishes a cleared
|
|
40
|
+
* `auth-flow` event. Resolves on the ack.
|
|
41
|
+
*/
|
|
42
|
+
cancelAuthFlow(): Promise<void>;
|
|
43
|
+
/** Server-executed slash command descriptors from the attach snapshot. */
|
|
44
|
+
serverCommands(): SlashCommandDescriptor[];
|
|
45
|
+
/**
|
|
46
|
+
* Request path completions for `@file` autocomplete and remote-cwd entry.
|
|
47
|
+
* Round-trips through the host's `complete-path` handler; resolves with the
|
|
48
|
+
* completion strings the handler returned (empty array when none / unsupported).
|
|
49
|
+
*/
|
|
50
|
+
completePath(prefix: string): Promise<string[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Fetch the available models for the `/model` autocomplete popup. Round-trips
|
|
53
|
+
* through the host's `complete-models` handler; resolves with an empty
|
|
54
|
+
* completion when no host is attached / the daemon is unsupported.
|
|
55
|
+
*/
|
|
56
|
+
completeModels(): Promise<ModelCompletion>;
|
|
57
|
+
close(): void;
|
|
58
|
+
}
|
|
59
|
+
export declare function createSessionClient(transport: ClientTransport): SessionClient;
|
|
60
|
+
//# sourceMappingURL=session-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-client.d.ts","sourceRoot":"","sources":["../../src/client/session-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAa,MAAM,0BAA0B,CAAC;AAEtF,OAAO,KAAK,EAEV,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,IAAI,gBAAgB,CAAC;IAC7B,MAAM,IAAI,MAAM,CAAC;IACjB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5C,6EAA6E;IAC7E,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5D,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,cAAc,CACZ,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,EACzB,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3E,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,gFAAgF;IAChF,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C;;;;OAIG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C;;;OAGG;IACH,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B;;;;OAIG;IACH,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,0EAA0E;IAC1E,cAAc,IAAI,sBAAsB,EAAE,CAAC;IAC3C;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAChD;;;;OAIG;IACH,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IAC3C,KAAK,IAAI,IAAI,CAAC;CACf;AA+CD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,eAAe,GAAG,aAAa,CA+K7E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal socket surface the transports need. `ws`'s WebSocket satisfies it
|
|
3
|
+
* structurally (EventEmitter-style `on`); browsers and node >= 22 adapt the
|
|
4
|
+
* native WHATWG WebSocket via {@link adaptWhatwgSocket}; tests inject
|
|
5
|
+
* scripted fakes.
|
|
6
|
+
*/
|
|
7
|
+
export type TransportSocket = {
|
|
8
|
+
on(event: "open", listener: () => void): unknown;
|
|
9
|
+
on(event: "message", listener: (data: unknown) => void): unknown;
|
|
10
|
+
on(event: "close", listener: () => void): unknown;
|
|
11
|
+
on(event: "error", listener: (error: unknown) => void): unknown;
|
|
12
|
+
send(data: string): void;
|
|
13
|
+
close(): void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Structural subset of the WHATWG WebSocket (browser native, node >= 22
|
|
17
|
+
* global). Declared locally because this package compiles without DOM libs.
|
|
18
|
+
*/
|
|
19
|
+
export type WhatwgWebSocketLike = {
|
|
20
|
+
addEventListener(type: "open", listener: () => void): void;
|
|
21
|
+
addEventListener(type: "message", listener: (event: {
|
|
22
|
+
data: unknown;
|
|
23
|
+
}) => void): void;
|
|
24
|
+
addEventListener(type: "close", listener: () => void): void;
|
|
25
|
+
addEventListener(type: "error", listener: (event: unknown) => void): void;
|
|
26
|
+
send(data: string): void;
|
|
27
|
+
close(): void;
|
|
28
|
+
};
|
|
29
|
+
export type WhatwgWebSocketConstructor = new (url: string) => WhatwgWebSocketLike;
|
|
30
|
+
/** Adapt a WHATWG-style (addEventListener) WebSocket to the on()-style TransportSocket. */
|
|
31
|
+
export declare function adaptWhatwgSocket(socket: WhatwgWebSocketLike): TransportSocket;
|
|
32
|
+
/**
|
|
33
|
+
* Default socket factory for the transports: the global WHATWG WebSocket
|
|
34
|
+
* (browsers, node >= 22). Node callers that need the 'ws' package or custom
|
|
35
|
+
* agents pass their own factory — the CLI does (packages/cli/src/lib/ws-socket.ts).
|
|
36
|
+
*/
|
|
37
|
+
export declare function defaultSocketFactory(url: string): TransportSocket;
|
|
38
|
+
//# sourceMappingURL=socket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.d.ts","sourceRoot":"","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AC3F,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,GAAG,eAAe,CA0B9E;AAaD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAGjE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClientCommand, ServerFrame } from "../protocol/types.ts";
|
|
2
|
+
/** Client side of a session transport. Implementation: WebSocket over UDS (local) or TCP (remote). */
|
|
3
|
+
export interface ClientTransport {
|
|
4
|
+
send(command: ClientCommand): void;
|
|
5
|
+
/** Subscribe to frames. The transport MUST deliver a snapshot frame first (attach semantics). */
|
|
6
|
+
onFrame(listener: (frame: ServerFrame) => void): () => void;
|
|
7
|
+
close(): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/client/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEvE,sGAAsG;AACtG,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;IACnC,iGAAiG;IACjG,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5D,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TransportSocket } from "./socket.ts";
|
|
2
|
+
/**
|
|
3
|
+
* ws-over-UDS support (spec §7). `ws` connects to a Unix domain socket via the
|
|
4
|
+
* URL form `ws+unix://<absolute-socket-path>:<pathname>`. We always use the
|
|
5
|
+
* pathname "/" — the daemon's WebSocketServer accepts any path. The token
|
|
6
|
+
* NEVER appears here (it rides in the hello frame); this URL is purely a
|
|
7
|
+
* transport address.
|
|
8
|
+
*
|
|
9
|
+
* `udsUrl` is a STABLE synthetic URL safe to pass as `WebSocketTransport.url`;
|
|
10
|
+
* `udsSocketFactory` returns a factory that ignores the url argument the
|
|
11
|
+
* transport passes and dials the bound socket path, so reconnects re-dial the
|
|
12
|
+
* same socket.
|
|
13
|
+
*/
|
|
14
|
+
export declare function udsUrl(socketPath: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* A `socketFactory` for `createWebSocketTransport` / `createServerDirectory`
|
|
17
|
+
* that opens every connection over the given UDS path. The `url` argument the
|
|
18
|
+
* caller passes is ignored — the bound socket path is authoritative — so the
|
|
19
|
+
* transport's reconnect loop re-dials the same socket regardless of the
|
|
20
|
+
* synthetic url it was constructed with.
|
|
21
|
+
*/
|
|
22
|
+
export declare function udsSocketFactory(socketPath: string): (url: string) => TransportSocket;
|
|
23
|
+
//# sourceMappingURL=uds-socket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uds-socket.d.ts","sourceRoot":"","sources":["../../src/client/uds-socket.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;GAWG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEjD;AA8BD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,eAAe,CAMrF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type GetEndpoint } from "./endpoint.ts";
|
|
2
|
+
import { type TransportSocket } from "./socket.ts";
|
|
3
|
+
import type { ClientTransport } from "./transport.ts";
|
|
4
|
+
export type { TransportSocket } from "./socket.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Connection lifecycle for the status footer (spec §4.6). "replaying" covers
|
|
7
|
+
* the window between sending `attach` and receiving its replay/snapshot reply;
|
|
8
|
+
* "closed" is terminal (explicit close(), handshake rejection, or a
|
|
9
|
+
* server-initiated detach).
|
|
10
|
+
*/
|
|
11
|
+
export type WebSocketTransportState = "closed" | "connected" | "reconnecting" | "replaying";
|
|
12
|
+
export type WebSocketTransportOptions = {
|
|
13
|
+
/** ws:// or wss:// endpoint. MUST NOT carry the credential (spec §4.1). Required unless `getEndpoint` is set. */
|
|
14
|
+
url?: string;
|
|
15
|
+
/** Bearer token, sent inside the hello frame — never in the URL. Required unless `getEndpoint` is set. */
|
|
16
|
+
token?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Endpoint provider (relay spec §9.1): resolves a FRESH `{url, credential}`
|
|
19
|
+
* before every connection attempt. When set, `url`/`token` are ignored. A
|
|
20
|
+
* rejection counts as a failed attempt (normal backoff retry).
|
|
21
|
+
*/
|
|
22
|
+
getEndpoint?: GetEndpoint;
|
|
23
|
+
/** Session to attach to after the handshake. */
|
|
24
|
+
sessionId: string;
|
|
25
|
+
/** Test seam / socket override. Defaults to the global WHATWG WebSocket (browsers, node >= 22). */
|
|
26
|
+
socketFactory?: (url: string) => TransportSocket;
|
|
27
|
+
/** First reconnect delay (ms). Default 500. */
|
|
28
|
+
backoffInitialMs?: number;
|
|
29
|
+
/** Reconnect delay cap (ms). Default 30_000. */
|
|
30
|
+
backoffMaxMs?: number;
|
|
31
|
+
/** Exponential growth factor. Default 2. */
|
|
32
|
+
backoffFactor?: number;
|
|
33
|
+
/** Handshake refused (bad token / protocol mismatch). Terminal — retrying cannot fix it. */
|
|
34
|
+
onRejected?: (reason: "auth" | "version") => void;
|
|
35
|
+
/** The daemon detached this client (e.g. kill-session). Terminal. */
|
|
36
|
+
onDetached?: (reason: string) => void;
|
|
37
|
+
};
|
|
38
|
+
export interface WebSocketClientTransport extends ClientTransport {
|
|
39
|
+
connectionState(): WebSocketTransportState;
|
|
40
|
+
onConnectionState(listener: (state: WebSocketTransportState) => void): () => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* ClientTransport over a WebSocket (spec §4.6): hello/welcome handshake, then
|
|
44
|
+
* attach with the last seen seq. Auto-reconnects with exponential backoff and
|
|
45
|
+
* resumes via replay when the daemon still buffers the gap, snapshot first
|
|
46
|
+
* otherwise. Replay frames are unpacked into individual event frames — the
|
|
47
|
+
* SessionClient's microtask-batched notify keeps the catch-up atomic for
|
|
48
|
+
* subscribers (anti-flash, spec §4.5.2).
|
|
49
|
+
*
|
|
50
|
+
* Commands are at-most-once (spec §4.4): while disconnected, send() drops the
|
|
51
|
+
* frame. The unacked command surfaces in the UI as "not delivered" (step 6).
|
|
52
|
+
*/
|
|
53
|
+
export declare function createWebSocketTransport(options: WebSocketTransportOptions): WebSocketClientTransport;
|
|
54
|
+
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket.d.ts","sourceRoot":"","sources":["../../src/client/websocket.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAiD,MAAM,eAAe,CAAC;AAChG,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,WAAW,GAAG,cAAc,GAAG,WAAW,CAAC;AAE5F,MAAM,MAAM,yBAAyB,GAAG;IACtC,iHAAiH;IACjH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0GAA0G;IAC1G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,mGAAmG;IACnG,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,eAAe,CAAC;IACjD,+CAA+C;IAC/C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4FAA4F;IAC5F,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAClD,qEAAqE;IACrE,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,MAAM,WAAW,wBAAyB,SAAQ,eAAe;IAC/D,eAAe,IAAI,uBAAuB,CAAC;IAC3C,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACnF;AAyBD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GACjC,wBAAwB,CAyO1B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { AgentEvent, AskUserAnswers, AskUserQuestionRequest, Message, ToolRuntimeDispatchDecision, ToolUseBlock } from "@nuvin/agent-core/shared";
|
|
2
|
+
import type { DirAccessRequest } from "../protocol/types.ts";
|
|
3
|
+
import type { TuiMessage } from "../state/messages.ts";
|
|
4
|
+
/** Structural mirror of the CLI session store's LoadedSession. */
|
|
5
|
+
export type SessionLoadedPayload = {
|
|
6
|
+
agentMessages: Message[];
|
|
7
|
+
id: string;
|
|
8
|
+
messages: TuiMessage[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Optional context describing the delegated child agent that produced the
|
|
12
|
+
* event/tool-call. Set by the delegation wrapping in `root.tsx` so the UI
|
|
13
|
+
* can nest sub-agent activity under the originating `AssignTask`
|
|
14
|
+
* tool call. Coordinator (root) callbacks omit it.
|
|
15
|
+
*/
|
|
16
|
+
export type DelegationScope = {
|
|
17
|
+
agentId: string;
|
|
18
|
+
parentToolCallId: string;
|
|
19
|
+
};
|
|
20
|
+
export type AgentEventPayload = {
|
|
21
|
+
event: AgentEvent;
|
|
22
|
+
scope?: DelegationScope;
|
|
23
|
+
};
|
|
24
|
+
export type ToolCallRequest = {
|
|
25
|
+
agentId: string;
|
|
26
|
+
/** Set by the runtime pre-check when the call's path is outside allowedDirs. */
|
|
27
|
+
dirAccess?: DirAccessRequest;
|
|
28
|
+
parentToolCallId?: string;
|
|
29
|
+
toolCall: ToolUseBlock;
|
|
30
|
+
};
|
|
31
|
+
export type AgentEventListener = (payload: AgentEventPayload) => void;
|
|
32
|
+
export type SessionLoadedListener = (loaded: SessionLoadedPayload) => void;
|
|
33
|
+
export type ToolCallDecider = (request: ToolCallRequest) => Promise<ToolRuntimeDispatchDecision> | ToolRuntimeDispatchDecision;
|
|
34
|
+
export type UserQuestionHandler = (request: AskUserQuestionRequest) => Promise<AskUserAnswers> | AskUserAnswers;
|
|
35
|
+
/**
|
|
36
|
+
* In-process channel between the Agent (constructed in `main()`) and the
|
|
37
|
+
* React UI (`<App />`). Two distinct shapes:
|
|
38
|
+
* - One-way agent → UI events: fire-and-forget, many subscribers.
|
|
39
|
+
* - Two-way agent → UI tool-call requests: exactly one decider, returns
|
|
40
|
+
* a {@link ToolRuntimeDispatchDecision} (or a Promise for it).
|
|
41
|
+
*
|
|
42
|
+
* This replaces the earlier mutable callback "bridge" container with a
|
|
43
|
+
* typed, encapsulated, testable boundary.
|
|
44
|
+
*/
|
|
45
|
+
export declare class AgentChannel {
|
|
46
|
+
private readonly emitter;
|
|
47
|
+
private decider;
|
|
48
|
+
private questionHandler;
|
|
49
|
+
publishEvent(event: AgentEvent, scope?: DelegationScope): void;
|
|
50
|
+
publishSessionLoaded(loaded: SessionLoadedPayload): void;
|
|
51
|
+
requestToolDecision(request: ToolCallRequest): Promise<ToolRuntimeDispatchDecision> | ToolRuntimeDispatchDecision;
|
|
52
|
+
requestUserQuestion(request: AskUserQuestionRequest): Promise<AskUserAnswers>;
|
|
53
|
+
onEvent(listener: AgentEventListener): () => void;
|
|
54
|
+
onSessionLoaded(listener: SessionLoadedListener): () => void;
|
|
55
|
+
setToolDecider(decider: ToolCallDecider | null): void;
|
|
56
|
+
setQuestionHandler(handler: UserQuestionHandler | null): void;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=agent-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-channel.d.ts","sourceRoot":"","sources":["../../src/controller/agent-channel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,sBAAsB,EACtB,OAAO,EACP,2BAA2B,EAC3B,YAAY,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,kEAAkE;AAClE,MAAM,MAAM,oBAAoB,GAAG;IACjC,aAAa,EAAE,OAAO,EAAE,CAAC;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,gFAAgF;IAChF,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,CAAC;AACtE,MAAM,MAAM,qBAAqB,GAAG,CAAC,M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