@nuvin/session 0.1.0-rc.10

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 (83) hide show
  1. package/LICENSE +202 -0
  2. package/dist/chunk-2LIGD6UP.js +11 -0
  3. package/dist/chunk-3IPZO7LP.js +66 -0
  4. package/dist/chunk-3S4DZMX3.js +681 -0
  5. package/dist/chunk-HJ666YLF.js +6 -0
  6. package/dist/chunk-UVJIG4DT.js +17 -0
  7. package/dist/client/daemon-client.d.ts +50 -0
  8. package/dist/client/daemon-client.d.ts.map +1 -0
  9. package/dist/client/data-client.d.ts +79 -0
  10. package/dist/client/data-client.d.ts.map +1 -0
  11. package/dist/client/directory.d.ts +99 -0
  12. package/dist/client/directory.d.ts.map +1 -0
  13. package/dist/client/endpoint.d.ts +39 -0
  14. package/dist/client/endpoint.d.ts.map +1 -0
  15. package/dist/client/http-data-client.d.ts +23 -0
  16. package/dist/client/http-data-client.d.ts.map +1 -0
  17. package/dist/client/index.d.ts +11 -0
  18. package/dist/client/index.d.ts.map +1 -0
  19. package/dist/client/index.js +1418 -0
  20. package/dist/client/session-client.d.ts +76 -0
  21. package/dist/client/session-client.d.ts.map +1 -0
  22. package/dist/client/socket.d.ts +38 -0
  23. package/dist/client/socket.d.ts.map +1 -0
  24. package/dist/client/transport.d.ts +9 -0
  25. package/dist/client/transport.d.ts.map +1 -0
  26. package/dist/client/uds-socket.d.ts +23 -0
  27. package/dist/client/uds-socket.d.ts.map +1 -0
  28. package/dist/client/websocket.d.ts +54 -0
  29. package/dist/client/websocket.d.ts.map +1 -0
  30. package/dist/controller/agent-channel.d.ts +58 -0
  31. package/dist/controller/agent-channel.d.ts.map +1 -0
  32. package/dist/controller/index.d.ts +3 -0
  33. package/dist/controller/index.d.ts.map +1 -0
  34. package/dist/controller/index.js +447 -0
  35. package/dist/controller/session-controller.d.ts +158 -0
  36. package/dist/controller/session-controller.d.ts.map +1 -0
  37. package/dist/controller/test-utils.d.ts +15 -0
  38. package/dist/controller/test-utils.d.ts.map +1 -0
  39. package/dist/grant/index.d.ts +33 -0
  40. package/dist/grant/index.d.ts.map +1 -0
  41. package/dist/grant/index.js +12 -0
  42. package/dist/protocol/daemon-directory.d.ts +30 -0
  43. package/dist/protocol/daemon-directory.d.ts.map +1 -0
  44. package/dist/protocol/data-rpc.d.ts +122 -0
  45. package/dist/protocol/data-rpc.d.ts.map +1 -0
  46. package/dist/protocol/index.d.ts +5 -0
  47. package/dist/protocol/index.d.ts.map +1 -0
  48. package/dist/protocol/index.js +10 -0
  49. package/dist/protocol/types.d.ts +971 -0
  50. package/dist/protocol/types.d.ts.map +1 -0
  51. package/dist/protocol/version.d.ts +8 -0
  52. package/dist/protocol/version.d.ts.map +1 -0
  53. package/dist/state/approvals.d.ts +34 -0
  54. package/dist/state/approvals.d.ts.map +1 -0
  55. package/dist/state/dir-access.d.ts +9 -0
  56. package/dist/state/dir-access.d.ts.map +1 -0
  57. package/dist/state/index.d.ts +6 -0
  58. package/dist/state/index.d.ts.map +1 -0
  59. package/dist/state/index.js +48 -0
  60. package/dist/state/json.d.ts +7 -0
  61. package/dist/state/json.d.ts.map +1 -0
  62. package/dist/state/messages.d.ts +105 -0
  63. package/dist/state/messages.d.ts.map +1 -0
  64. package/dist/state/session.d.ts +9 -0
  65. package/dist/state/session.d.ts.map +1 -0
  66. package/dist/state/tool-preview.d.ts +31 -0
  67. package/dist/state/tool-preview.d.ts.map +1 -0
  68. package/dist/state/tool-preview.js +300 -0
  69. package/dist/state/workflow-view.d.ts +10 -0
  70. package/dist/state/workflow-view.d.ts.map +1 -0
  71. package/dist/test-utils/fake-relay.d.ts +24 -0
  72. package/dist/test-utils/fake-relay.d.ts.map +1 -0
  73. package/dist/test-utils/index.d.ts +2 -0
  74. package/dist/test-utils/index.d.ts.map +1 -0
  75. package/dist/test-utils/index.js +250 -0
  76. package/dist/ui/history-grouping.d.ts +36 -0
  77. package/dist/ui/history-grouping.d.ts.map +1 -0
  78. package/dist/ui/index.d.ts +3 -0
  79. package/dist/ui/index.d.ts.map +1 -0
  80. package/dist/ui/index.js +135 -0
  81. package/dist/ui/picker-rows.d.ts +62 -0
  82. package/dist/ui/picker-rows.d.ts.map +1 -0
  83. package/package.json +71 -0
@@ -0,0 +1,50 @@
1
+ import type { DaemonDataClient } from "./data-client.ts";
2
+ import type { DirectoryServerConfig } from "./directory.ts";
3
+ import { type SessionClient } from "./session-client.ts";
4
+ import { type TransportSocket } from "./socket.ts";
5
+ import { type WebSocketClientTransport, type WebSocketTransportOptions } from "./websocket.ts";
6
+ export type DaemonTarget = {
7
+ kind: "local";
8
+ id: string;
9
+ name: string;
10
+ socketPath: string;
11
+ token: string;
12
+ } | {
13
+ kind: "direct";
14
+ id: string;
15
+ name: string;
16
+ wsUrl: string;
17
+ token: string;
18
+ } | {
19
+ kind: "relay";
20
+ id: string;
21
+ name: string;
22
+ apiBaseUrl: string;
23
+ getAccessToken: () => Promise<string>;
24
+ refreshAccessToken: () => Promise<string>;
25
+ };
26
+ export type DaemonClientDeps = {
27
+ udsFetch?: (socketPath: string) => typeof fetch;
28
+ fetchImpl?: typeof fetch;
29
+ socketFactory?: (url: string) => TransportSocket;
30
+ };
31
+ export type DropDaemonId<F> = F extends (daemonId: string, ...args: infer A) => infer R ? (...args: A) => R : never;
32
+ export type BoundDaemonDataClient = {
33
+ [K in keyof DaemonDataClient]: DropDaemonId<DaemonDataClient[K]>;
34
+ };
35
+ export type SessionConnection = {
36
+ client: SessionClient;
37
+ transport: WebSocketClientTransport;
38
+ close(): void;
39
+ };
40
+ export type SessionConnectionOptions = Pick<WebSocketTransportOptions, "onDetached" | "onRejected">;
41
+ export interface DaemonClient {
42
+ readonly target: DaemonTarget;
43
+ readonly data: BoundDaemonDataClient;
44
+ directoryEndpoint(): DirectoryServerConfig;
45
+ openSession(sessionId: string, options?: SessionConnectionOptions): SessionConnection;
46
+ close(): void;
47
+ }
48
+ export declare function bindDaemonDataClient(client: DaemonDataClient, daemonId: string): BoundDaemonDataClient;
49
+ export declare function createDaemonClient(target: DaemonTarget, deps?: DaemonClientDeps): DaemonClient;
50
+ //# sourceMappingURL=daemon-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemon-client.d.ts","sourceRoot":"","sources":["../../src/client/daemon-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC/B,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IACtC,kBAAkB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C,CAAC;AAEN,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,KAAK,CAAC;IAChD,SAAS,CAAC,EAAE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apshot, UpdateWorkspaceInput, WorkspaceConfigSummary } from "../protocol/index.ts";
2
+ import type { TransportCredential } from "./endpoint.ts";
3
+ /** Discovery payload: the daemon directory (account-scoped cloud, machine-scoped local). */
4
+ export type DaemonDirectory = {
5
+ daemons: DaemonDirectoryRow[];
6
+ defaultSessionId?: string;
7
+ };
8
+ /**
9
+ * Live-attach endpoint for one daemon: ws URL + credential for the session
10
+ * socket. `credential` is exactly the transport's `TransportCredential`
11
+ * ({token} local / {grant} cloud), so a directory `getEndpoint` is a trivial
12
+ * wrapper over `acquireEndpoint`.
13
+ */
14
+ export type DaemonEndpoint = {
15
+ url: string;
16
+ credential: TransportCredential;
17
+ };
18
+ /**
19
+ * Discovery: where daemons come from and how to dial them. Implemented by the
20
+ * HTTP client for both web modes (GET /api/daemons + POST /connect). The TUI
21
+ * does NOT use this half — its discovery is config `servers:` + UDS conventions.
22
+ */
23
+ export interface DaemonDirectoryClient {
24
+ listDaemons(): Promise<DaemonDirectory>;
25
+ acquireEndpoint(daemonId: string): Promise<DaemonEndpoint>;
26
+ }
27
+ /**
28
+ * Per-daemon reads + stateless management — the plane shared by ALL clients
29
+ * (spec: data-plane unification). Method-for-method the client projection of
30
+ * DataRpcSchema. No HTTP status codes, URL shapes, or fetch types appear here.
31
+ * Terminal conditions throw `TerminalEndpointError` with a
32
+ * `DataClientTerminalReason`; `createWorkspace` failures carry the server's
33
+ * message; everything else is a plain `Error`.
34
+ */
35
+ export interface DaemonDataClient {
36
+ fetchTranscript(daemonId: string, historyId: string, opts?: {
37
+ workspace?: string;
38
+ profile?: string;
39
+ }): Promise<SessionSnapshot>;
40
+ fetchHistory(daemonId: string, opts?: {
41
+ profile?: string;
42
+ cwd?: string;
43
+ limit?: number;
44
+ cursor?: string;
45
+ }): Promise<HistoryPage>;
46
+ listWorkspaces(daemonId: string, opts?: {
47
+ profile?: string;
48
+ }): Promise<WorkspaceConfigSummary[]>;
49
+ createWorkspace(daemonId: string, opts: {
50
+ name: string;
51
+ root?: string;
52
+ profile?: string;
53
+ }): Promise<WorkspaceConfigSummary>;
54
+ deleteSession(daemonId: string, historyId: string, opts?: {
55
+ workspace?: string;
56
+ profile?: string;
57
+ }): Promise<void>;
58
+ listProfiles(daemonId: string): Promise<ProfileSummary[]>;
59
+ listProviders(daemonId: string, opts?: {
60
+ profile?: string;
61
+ }): Promise<ProviderConfigSummary[]>;
62
+ addProvider(daemonId: string, input: AddProviderInput): Promise<ConfigMutationResult<ProviderConfigSummary>>;
63
+ removeProvider(daemonId: string, providerId: string, opts?: {
64
+ profile?: string;
65
+ }): Promise<ConfigMutationResult<null>>;
66
+ setDefaultProvider(daemonId: string, providerId: string, opts?: {
67
+ profile?: string;
68
+ }): Promise<ConfigMutationResult<null>>;
69
+ setProviderAuth(daemonId: string, providerId: string, credential: ProviderCredentialInput, opts?: {
70
+ profile?: string;
71
+ }): Promise<ConfigMutationResult<null>>;
72
+ clearProviderAuth(daemonId: string, providerId: string, opts?: {
73
+ profile?: string;
74
+ }): Promise<ConfigMutationResult<null>>;
75
+ updateWorkspace(daemonId: string, name: string, patch: UpdateWorkspaceInput): Promise<ConfigMutationResult<WorkspaceConfigSummary>>;
76
+ }
77
+ /** The full client both web modes compose (spec §4.2). */
78
+ export type DataClient = DaemonDirectoryClient & DaemonDataClient;
79
+ //# sourceMappingURL=data-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-client.d.ts","sourceRoot":"","sources":["../../src/client/data-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,4FAA4F;AAC5F,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,EAAE,kBAAkB,E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,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,eAAe,CACb,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,sBAAsB,CAAC,CAAC,CAAC;CAC1D;AAED,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,qBAAqB,GAAG,gBAAgB,CAAC"}
@@ -0,0 +1,99 @@
1
+ import type { SessionDescriptor } 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
+ * 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
+ close(): void;
97
+ }
98
+ export declare function createServerDirectory(options: ServerDirectoryOptions): ServerDirectory;
99
+ //# 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,EAAuB,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,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,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,kFAAkF;IAClF,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,eAAe,CAAC;CAClD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,GACvB;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAClD;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExC,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,qBAAqB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,mBAAmB,EAAE,CAAA;CAAE,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,mGAAmG;IACnG,aAAa,CAAC,EAAE,C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BAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CA8YtF"}
@@ -0,0 +1,39 @@
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
+ /**
34
+ * Terminal reasons a DataClient method may throw (as TerminalEndpointError):
35
+ * conditions where retry can never succeed. "unauthorized" = auth expired
36
+ * (cloud) or daemon token rotated (local) — re-auth, don't retry.
37
+ */
38
+ export type DataClientTerminalReason = "transcript-not-found" | "session-not-found" | "daemon-revoked" | "unauthorized";
39
+ //# 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;AAED;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAChC,sBAAsB,GACtB,mBAAmB,GACnB,gBAAgB,GAChB,cAAc,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { DataClient } from "./data-client.ts";
2
+ export type HttpDataClientOptions = {
3
+ /** "" / absent ⇒ same-origin (local). Absolute relay origin ⇒ cloud. */
4
+ baseUrl?: string;
5
+ /** Cloud: fresh Clerk JWT per request. Absent ⇒ no bearer on discovery. */
6
+ getToken?: () => Promise<string | null>;
7
+ /** Cloud relay: force-refresh after the first rejected /connect token. */
8
+ refreshAccessToken?: () => Promise<string | null>;
9
+ /** Cloud: 401 anywhere ⇒ route to /sign-in with return-to. */
10
+ onUnauthorized?: () => void;
11
+ fetchImpl?: typeof fetch;
12
+ };
13
+ /** Derive the daemon's HTTP origin from its ws url: ws→http, wss→https. */
14
+ export declare function httpBaseFromWsUrl(wsUrl: string): string;
15
+ /**
16
+ * The single HTTP DataClient for BOTH web modes (spec §4.3). Local: same-origin
17
+ * discovery, per-row daemon base + static bearer for data methods, static
18
+ * endpoints. Cloud: relay base, Clerk bearer, POST /connect for endpoints.
19
+ * Mode is entirely captured in `options` + the row shapes returned by
20
+ * GET /api/daemons; there is one code path.
21
+ */
22
+ export declare function createHttpDataClient(options?: HttpDataClientOptions): DataClient;
23
+ //# sourceMappingURL=http-data-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-data-client.d.ts","sourceRoot":"","sources":["../../src/client/http-data-client.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAmC,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGpF,MAAM,MAAM,qBAAqB,GAAG;IAClC,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACxC,0EAA0E;IAC1E,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAClD,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B,CAAC;AAEF,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIvD;AA0CD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B,GAAG,UAAU,CAuSpF"}
@@ -0,0 +1,11 @@
1
+ export * from "./daemon-client.ts";
2
+ export * from "./data-client.ts";
3
+ export * from "./directory.ts";
4
+ export * from "./endpoint.ts";
5
+ export * from "./http-data-client.ts";
6
+ export * from "./session-client.ts";
7
+ export * from "./socket.ts";
8
+ export * from "./transport.ts";
9
+ export * from "./uds-socket.ts";
10
+ export * from "./websocket.ts";
11
+ //# 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,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}