@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.
Files changed (72) hide show
  1. package/dist/chunk-3IPZO7LP.js +66 -0
  2. package/dist/chunk-7G3R25NS.js +6 -0
  3. package/dist/chunk-DGC7JSCG.js +0 -0
  4. package/dist/chunk-FR3R66RD.js +678 -0
  5. package/dist/chunk-UVJIG4DT.js +17 -0
  6. package/dist/client/directory.d.ts +141 -0
  7. package/dist/client/directory.d.ts.map +1 -0
  8. package/dist/client/endpoint.d.ts +33 -0
  9. package/dist/client/endpoint.d.ts.map +1 -0
  10. package/dist/client/index.d.ts +8 -0
  11. package/dist/client/index.d.ts.map +1 -0
  12. package/dist/client/index.js +1060 -0
  13. package/dist/client/session-client.d.ts +60 -0
  14. package/dist/client/session-client.d.ts.map +1 -0
  15. package/dist/client/socket.d.ts +38 -0
  16. package/dist/client/socket.d.ts.map +1 -0
  17. package/dist/client/transport.d.ts +9 -0
  18. package/dist/client/transport.d.ts.map +1 -0
  19. package/dist/client/uds-socket.d.ts +23 -0
  20. package/dist/client/uds-socket.d.ts.map +1 -0
  21. package/dist/client/websocket.d.ts +54 -0
  22. package/dist/client/websocket.d.ts.map +1 -0
  23. package/dist/controller/agent-channel.d.ts +58 -0
  24. package/dist/controller/agent-channel.d.ts.map +1 -0
  25. package/dist/controller/index.d.ts +3 -0
  26. package/dist/controller/index.d.ts.map +1 -0
  27. package/dist/controller/index.js +441 -0
  28. package/dist/controller/session-controller.d.ts +147 -0
  29. package/dist/controller/session-controller.d.ts.map +1 -0
  30. package/dist/controller/test-utils.d.ts +15 -0
  31. package/dist/controller/test-utils.d.ts.map +1 -0
  32. package/dist/grant/index.d.ts +33 -0
  33. package/dist/grant/index.d.ts.map +1 -0
  34. package/dist/grant/index.js +12 -0
  35. package/dist/protocol/index.d.ts +3 -0
  36. package/dist/protocol/index.d.ts.map +1 -0
  37. package/dist/protocol/index.js +7 -0
  38. package/dist/protocol/types.d.ts +855 -0
  39. package/dist/protocol/types.d.ts.map +1 -0
  40. package/dist/protocol/version.d.ts +8 -0
  41. package/dist/protocol/version.d.ts.map +1 -0
  42. package/dist/state/approvals.d.ts +34 -0
  43. package/dist/state/approvals.d.ts.map +1 -0
  44. package/dist/state/dir-access.d.ts +9 -0
  45. package/dist/state/dir-access.d.ts.map +1 -0
  46. package/dist/state/index.d.ts +6 -0
  47. package/dist/state/index.d.ts.map +1 -0
  48. package/dist/state/index.js +48 -0
  49. package/dist/state/json.d.ts +7 -0
  50. package/dist/state/json.d.ts.map +1 -0
  51. package/dist/state/messages.d.ts +105 -0
  52. package/dist/state/messages.d.ts.map +1 -0
  53. package/dist/state/session.d.ts +9 -0
  54. package/dist/state/session.d.ts.map +1 -0
  55. package/dist/state/tool-preview.d.ts +31 -0
  56. package/dist/state/tool-preview.d.ts.map +1 -0
  57. package/dist/state/tool-preview.js +300 -0
  58. package/dist/state/workflow-view.d.ts +10 -0
  59. package/dist/state/workflow-view.d.ts.map +1 -0
  60. package/dist/test-utils/fake-relay.d.ts +24 -0
  61. package/dist/test-utils/fake-relay.d.ts.map +1 -0
  62. package/dist/test-utils/index.d.ts +2 -0
  63. package/dist/test-utils/index.d.ts.map +1 -0
  64. package/dist/test-utils/index.js +250 -0
  65. package/dist/ui/history-grouping.d.ts +36 -0
  66. package/dist/ui/history-grouping.d.ts.map +1 -0
  67. package/dist/ui/index.d.ts +3 -0
  68. package/dist/ui/index.d.ts.map +1 -0
  69. package/dist/ui/index.js +135 -0
  70. package/dist/ui/picker-rows.d.ts +62 -0
  71. package/dist/ui/picker-rows.d.ts.map +1 -0
  72. package/package.json +70 -0
@@ -0,0 +1,141 @@
1
+ import type { HistorySummary, ProfileSummary, ProviderSummary, SessionDescriptor, WorkspaceSummary } from "../protocol/types.ts";
2
+ import type { GetEndpoint } from "./endpoint.ts";
3
+ import { type TransportSocket } from "./socket.ts";
4
+ /**
5
+ * A configured daemon endpoint. Two forms (web spec §6):
6
+ * - static: `{url, token}` resolved upfront (local UDS / LAN TCP, unchanged);
7
+ * - endpoint provider: `getEndpoint()` resolves a FRESH `{url, credential}`
8
+ * per connection attempt (cloud relay: POST /api/daemons/:id/connect).
9
+ */
10
+ export type DirectoryServerConfig = {
11
+ name: string;
12
+ url?: string;
13
+ token?: string;
14
+ getEndpoint?: GetEndpoint;
15
+ /** Per-server socket factory (e.g. ws-over-UDS for the local daemon, spec §7). */
16
+ socketFactory?: (url: string) => TransportSocket;
17
+ };
18
+ /**
19
+ * Per-server panel status (spec §7): the merged view fills in incrementally
20
+ * and an unreachable server never blocks the panel.
21
+ */
22
+ export type DirectoryServerStatus = {
23
+ state: "connecting";
24
+ } | {
25
+ state: "online";
26
+ sessions: SessionDescriptor[];
27
+ } | {
28
+ state: "offline";
29
+ error: string;
30
+ };
31
+ export type DirectoryServerView = {
32
+ name: string;
33
+ url: string;
34
+ status: DirectoryServerStatus;
35
+ };
36
+ export type DirectoryView = {
37
+ servers: DirectoryServerView[];
38
+ };
39
+ export type ServerDirectoryOptions = {
40
+ servers: DirectoryServerConfig[];
41
+ /** Test seam / socket override. Defaults to the global WHATWG WebSocket (browsers, node >= 22). */
42
+ socketFactory?: (url: string) => TransportSocket;
43
+ /** Connect + handshake deadline per server (ms). Default 5000. */
44
+ connectTimeoutMs?: number;
45
+ };
46
+ /**
47
+ * Multi-server session listing for the picker (spec §7). One directory socket
48
+ * per configured server: hello/welcome handshake (token in the hello frame,
49
+ * NEVER the URL — spec §4.1), then `list-sessions` and the pre-attach
50
+ * management commands. Directory sockets never carry session traffic —
51
+ * attaching to a picked session opens a fresh WebSocketTransport.
52
+ *
53
+ * Failure policy (spec §8): auth/version rejections, timeouts, and dropped
54
+ * connections mark THAT server offline with an actionable message and reject
55
+ * its in-flight commands; other servers are untouched. There is no automatic
56
+ * reconnect loop — `refresh()` retries offline servers on demand.
57
+ */
58
+ export interface ServerDirectory {
59
+ /** Stable reference between change notifications — safe for useSyncExternalStore. */
60
+ getView(): DirectoryView;
61
+ subscribe(listener: () => void): () => void;
62
+ /** Reconnect offline servers and re-issue list-sessions on online ones. */
63
+ refresh(): void;
64
+ /**
65
+ * Diff-update the server set (web cloud spec §6: the daemon list is re-polled).
66
+ * New names are added and connected; missing names are closed and removed
67
+ * (pending commands reject); kept names get their config replaced so future
68
+ * reconnects use the fresh endpoint provider. Live sockets of kept servers
69
+ * are untouched.
70
+ */
71
+ setServers(configs: DirectoryServerConfig[]): void;
72
+ createSession(server: string, options: {
73
+ cwd: string;
74
+ name?: string;
75
+ workspace?: string;
76
+ profile?: string;
77
+ }): Promise<SessionDescriptor>;
78
+ /**
79
+ * Switch-and-resume a cold session (spec §3/§5): issues `resume-session` and
80
+ * resolves the live `SessionDescriptor` the daemon rehydrated. The cold
81
+ * transcript carries no cwd, so the caller supplies the cwd the rehydrated
82
+ * runtime runs in. Idempotent daemon-side (an already-live id resolves to the
83
+ * existing live session).
84
+ */
85
+ resumeSession(server: string, historyId: string, options: {
86
+ cwd: string;
87
+ name?: string;
88
+ workspace?: string;
89
+ profile?: string;
90
+ }): Promise<SessionDescriptor>;
91
+ killSession(server: string, sessionId: string, options?: {
92
+ delete?: boolean;
93
+ }): Promise<void>;
94
+ /** Remote cwd completion for the new-session flow (spec §7). */
95
+ completePath(server: string, prefix: string): Promise<string[]>;
96
+ /**
97
+ * One-shot cold/resumable history for a server (spec §8): issues
98
+ * `list-history` and resolves the `history-list` reply. The local picker uses
99
+ * this for its "Local" section instead of a second in-process runtime.
100
+ */
101
+ listHistory(server: string, opts?: {
102
+ profile?: string;
103
+ cwd?: string;
104
+ }): Promise<{
105
+ sessions: HistorySummary[];
106
+ currentWorkspace?: string;
107
+ }>;
108
+ /**
109
+ * Permanently delete a cold session transcript (spec §8): issues
110
+ * `delete-history` and resolves on an ok ack. Rejects when the daemon reports
111
+ * the id is unknown or currently live. After resolving, callers should
112
+ * re-fetch `listHistory` for an authoritative refresh.
113
+ */
114
+ deleteHistory(server: string, historyId: string, opts: {
115
+ workspace: string;
116
+ profile?: string;
117
+ }): Promise<void>;
118
+ /** List the SELECTED server's workspaces for a profile (spec §7). */
119
+ listWorkspaces(server: string, opts?: {
120
+ profile?: string;
121
+ }): Promise<WorkspaceSummary[]>;
122
+ /** Create a named workspace under a profile; `root` omitted ⇒ daemon provisions workdir/. */
123
+ createWorkspace(server: string, opts: {
124
+ name: string;
125
+ root?: string;
126
+ profile?: string;
127
+ }): Promise<WorkspaceSummary>;
128
+ /** List the SELECTED server's config profiles (per-daemon) for the new-session screen. */
129
+ listProfiles(server: string): Promise<ProfileSummary[]>;
130
+ /** List the SELECTED server's configured providers (web spec §7). */
131
+ listProviders(server: string): Promise<ProviderSummary[]>;
132
+ /** Set the server's default provider; the daemon reloads running sessions like reload-config. */
133
+ setDefaultProvider(server: string, providerId: string): Promise<void>;
134
+ /** Store a provider credential on the daemon (transits the wire; stored only daemon-side). */
135
+ setProviderAuth(server: string, providerId: string, credential: string): Promise<void>;
136
+ /** Remove a provider's stored credential on the daemon. */
137
+ clearProviderAuth(server: string, providerId: string): Promise<void>;
138
+ close(): void;
139
+ }
140
+ export declare function createServerDirectory(options: ServerDirectoryOptions): ServerDirectory;
141
+ //# sourceMappingURL=directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../src/client/directory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,cAAc,EACd,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAqB,MAAM,eAAe,CAAC;AACpE,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAA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AAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACzF,6FAA6F;IAC7F,eAAe,CACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GACtD,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC7B,0FAA0F;IAC1F,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACxD,qEAAqE;IACrE,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAC1D,iGAAiG;IACjG,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,8FAA8F;IAC9F,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvF,2DAA2D;IAC3D,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,KAAK,IAAI,IAAI,CAAC;CACf;AAgFD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CA6kBtF"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Endpoint-provider seam (relay spec §9.1, web spec §6). Relay connections
3
+ * cannot know their URL or credential upfront: every attempt POSTs the
4
+ * server's connect endpoint for a fresh single-use channel URL + grant.
5
+ * `getEndpoint()` is that hook — the transport/directory call it before EVERY
6
+ * connection attempt (initial and each reconnect) so the reconnect loop itself
7
+ * stays unchanged. Static LAN/UDS configs keep passing `{url, token}` and
8
+ * never touch this. The credential is an opaque string either way — grant
9
+ * crypto never enters browser-safe client code.
10
+ */
11
+ export type TransportCredential = {
12
+ token: string;
13
+ } | {
14
+ grant: string;
15
+ };
16
+ export type TransportEndpoint = {
17
+ url: string;
18
+ credential: TransportCredential;
19
+ };
20
+ export type GetEndpoint = () => Promise<TransportEndpoint>;
21
+ /**
22
+ * Thrown by a GetEndpoint when the failure is PERMANENT — the daemon is
23
+ * revoked/unregistered (connect endpoint 404s), so backoff retries can never
24
+ * succeed (web spec §10 "Revoked daemon"). The transport treats it like a
25
+ * server-initiated detach: terminal close + onDetached(reason). Transient
26
+ * failures (network, 409 daemon-offline, 5xx) stay plain errors and keep the
27
+ * normal retry-with-backoff behavior.
28
+ */
29
+ export declare class TerminalEndpointError extends Error {
30
+ readonly reason: string;
31
+ constructor(reason: string, message?: string);
32
+ }
33
+ //# sourceMappingURL=endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../src/client/endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,iBAAiB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAEjF,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE3D;;;;;;;GAOG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAK7C"}
@@ -0,0 +1,8 @@
1
+ export * from "./directory.ts";
2
+ export * from "./endpoint.ts";
3
+ export * from "./session-client.ts";
4
+ export * from "./socket.ts";
5
+ export * from "./transport.ts";
6
+ export * from "./uds-socket.ts";
7
+ export * from "./websocket.ts";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}