@floegence/floe-webapp-protocol 0.14.3 → 0.15.0

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/index9.js ADDED
@@ -0,0 +1,124 @@
1
+ import { bytesFromBase64 as i, bytesToBase64 as o } from "./index10.js";
2
+ function t(e) {
3
+ return {
4
+ id: String(e?.id ?? ""),
5
+ name: String(e?.name ?? ""),
6
+ workingDir: String(e?.working_dir ?? ""),
7
+ createdAtMs: Number(e?.created_at_ms ?? 0),
8
+ lastActiveAtMs: Number(e?.last_active_at_ms ?? 0),
9
+ isActive: !!(e?.is_active ?? !1)
10
+ };
11
+ }
12
+ function u(e) {
13
+ return {
14
+ name: e.name?.trim() ? e.name.trim() : void 0,
15
+ working_dir: e.workingDir?.trim() ? e.workingDir.trim() : void 0,
16
+ cols: e.cols,
17
+ rows: e.rows
18
+ };
19
+ }
20
+ function m(e) {
21
+ return { session: t(e.session) };
22
+ }
23
+ function a(e) {
24
+ return { sessions: (Array.isArray(e?.sessions) ? e.sessions : []).map(t).filter((s) => s.id) };
25
+ }
26
+ function c(e) {
27
+ return {
28
+ session_id: e.sessionId,
29
+ conn_id: e.connId,
30
+ cols: e.cols,
31
+ rows: e.rows
32
+ };
33
+ }
34
+ function f(e) {
35
+ return { ok: !!(e?.ok ?? !1) };
36
+ }
37
+ function l(e) {
38
+ return {
39
+ session_id: e.sessionId,
40
+ start_seq: e.startSeq,
41
+ end_seq: e.endSeq
42
+ };
43
+ }
44
+ function d(e) {
45
+ return {
46
+ chunks: (Array.isArray(e?.chunks) ? e.chunks : []).map((s) => ({
47
+ sequence: Number(s?.sequence ?? 0),
48
+ timestampMs: Number(s?.timestamp_ms ?? 0),
49
+ data: i(String(s?.data_b64 ?? ""))
50
+ })).filter((s) => s.data.length > 0)
51
+ };
52
+ }
53
+ function _(e) {
54
+ return { session_id: e.sessionId };
55
+ }
56
+ function S(e) {
57
+ return { ok: !!(e?.ok ?? !1) };
58
+ }
59
+ function T(e) {
60
+ return { session_id: e.sessionId };
61
+ }
62
+ function k(e) {
63
+ return { ok: !!(e?.ok ?? !1) };
64
+ }
65
+ function W(e) {
66
+ return { session_id: e.sessionId };
67
+ }
68
+ function b(e) {
69
+ const n = Number(e?.history?.total_bytes ?? 0);
70
+ return { history: { totalBytes: Number.isFinite(n) && n > 0 ? n : 0 } };
71
+ }
72
+ function g(e) {
73
+ const n = String(e?.session_id ?? "").trim(), s = String(e?.data_b64 ?? "");
74
+ return !n || !s ? null : {
75
+ sessionId: n,
76
+ data: i(s),
77
+ sequence: typeof e.sequence == "number" ? e.sequence : void 0,
78
+ timestampMs: typeof e.timestamp_ms == "number" ? e.timestamp_ms : void 0,
79
+ echoOfInput: typeof e.echo_of_input == "boolean" ? e.echo_of_input : void 0,
80
+ originalSource: typeof e.original_source == "string" ? e.original_source : void 0
81
+ };
82
+ }
83
+ function w(e) {
84
+ const n = String(e?.session_id ?? "").trim();
85
+ return n ? {
86
+ sessionId: n,
87
+ newName: String(e?.new_name ?? ""),
88
+ workingDir: String(e?.working_dir ?? "")
89
+ } : null;
90
+ }
91
+ function I(e) {
92
+ return {
93
+ session_id: e.sessionId,
94
+ conn_id: e.connId,
95
+ cols: e.cols,
96
+ rows: e.rows
97
+ };
98
+ }
99
+ function R(e) {
100
+ return {
101
+ session_id: e.sessionId,
102
+ conn_id: e.connId,
103
+ data_b64: o(e.data)
104
+ };
105
+ }
106
+ export {
107
+ S as fromWireTerminalClearResponse,
108
+ d as fromWireTerminalHistoryResponse,
109
+ w as fromWireTerminalNameUpdateNotify,
110
+ g as fromWireTerminalOutputNotify,
111
+ f as fromWireTerminalSessionAttachResponse,
112
+ m as fromWireTerminalSessionCreateResponse,
113
+ k as fromWireTerminalSessionDeleteResponse,
114
+ a as fromWireTerminalSessionListResponse,
115
+ b as fromWireTerminalSessionStatsResponse,
116
+ _ as toWireTerminalClearRequest,
117
+ l as toWireTerminalHistoryRequest,
118
+ R as toWireTerminalInputNotify,
119
+ I as toWireTerminalResizeNotify,
120
+ c as toWireTerminalSessionAttachRequest,
121
+ u as toWireTerminalSessionCreateRequest,
122
+ T as toWireTerminalSessionDeleteRequest,
123
+ W as toWireTerminalSessionStatsRequest
124
+ };
package/dist/rpc.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- import { type ListRequest, type ListResponse, type ReadFileRequest, type ReadFileResponse, type WriteFileRequest, type WriteFileResponse, type DeleteRequest, type DeleteResponse } from './types';
1
+ import type { ProtocolContract, RpcHelpers } from './contract';
2
+ import { type RedevenV1Rpc } from './contracts/redeven_v1';
2
3
  /**
3
- * RPC wrapper for type-safe remote calls
4
+ * RPC wrapper for typed remote calls.
5
+ *
6
+ * This module is contract-driven: a contract defines TypeIds + wire codecs + domain surface.
4
7
  */
5
8
  export declare class ProtocolNotConnectedError extends Error {
6
9
  constructor();
@@ -15,15 +18,7 @@ export declare class RpcError extends Error {
15
18
  cause?: unknown;
16
19
  });
17
20
  }
18
- export declare function useRpc(): {
19
- fs: {
20
- list: (req: ListRequest) => Promise<ListResponse>;
21
- readFile: (req: ReadFileRequest) => Promise<ReadFileResponse>;
22
- writeFile: (req: WriteFileRequest) => Promise<WriteFileResponse>;
23
- delete: (req: DeleteRequest) => Promise<DeleteResponse>;
24
- getHome: () => Promise<{
25
- path: string;
26
- }>;
27
- };
28
- call: <Req, Res>(typeId: number, request: Req) => Promise<Res>;
21
+ export type UseRpcOptions<TApi extends object> = {
22
+ contract?: ProtocolContract<TApi>;
29
23
  };
24
+ export declare function useRpc<TApi extends object = RedevenV1Rpc>(options?: UseRpcOptions<TApi>): TApi & RpcHelpers;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-protocol",
3
- "version": "0.14.3",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -1,99 +0,0 @@
1
- /**
2
- * Common type definitions for the protocol layer
3
- */
4
- /**
5
- * Type IDs that are currently implemented by `useRpc()`.
6
- *
7
- * Keep this list aligned with `packages/protocol/src/rpc.ts` to avoid misleading downstream users.
8
- */
9
- export declare const TypeIds: {
10
- readonly FS_LIST: 1001;
11
- readonly FS_READ_FILE: 1002;
12
- readonly FS_WRITE_FILE: 1003;
13
- readonly FS_DELETE: 1006;
14
- readonly FS_GET_HOME: 1010;
15
- };
16
- /**
17
- * Reserved Type IDs for future protocol domains.
18
- *
19
- * These are part of the protocol contract, but are not yet exposed via `useRpc()`.
20
- */
21
- export declare const ReservedTypeIds: {
22
- readonly FS_CREATE_FILE: 1004;
23
- readonly FS_CREATE_DIR: 1005;
24
- readonly FS_RENAME: 1007;
25
- readonly FS_MOVE: 1008;
26
- readonly FS_COPY: 1009;
27
- readonly TERMINAL_SESSION_CREATE: 2001;
28
- readonly TERMINAL_SESSION_LIST: 2002;
29
- readonly TERMINAL_SESSION_ATTACH: 2003;
30
- readonly TERMINAL_DATA: 2004;
31
- readonly SYSTEM_INFO: 3001;
32
- readonly SYSTEM_EXEC: 3002;
33
- };
34
- export interface FileInfo {
35
- name: string;
36
- path: string;
37
- isDirectory: boolean;
38
- size: number;
39
- modifiedAt: number;
40
- createdAt: number;
41
- permissions?: string;
42
- }
43
- export interface ListRequest {
44
- path: string;
45
- showHidden?: boolean;
46
- }
47
- export interface ListResponse {
48
- entries: FileInfo[];
49
- }
50
- export interface ReadFileRequest {
51
- path: string;
52
- encoding?: 'utf8' | 'base64';
53
- }
54
- export interface ReadFileResponse {
55
- content: string;
56
- encoding: string;
57
- }
58
- export interface WriteFileRequest {
59
- path: string;
60
- content: string;
61
- encoding?: 'utf8' | 'base64';
62
- createDirs?: boolean;
63
- }
64
- export interface WriteFileResponse {
65
- success: boolean;
66
- }
67
- export interface DeleteRequest {
68
- path: string;
69
- recursive?: boolean;
70
- }
71
- export interface DeleteResponse {
72
- success: boolean;
73
- }
74
- export interface TerminalSession {
75
- id: string;
76
- name?: string;
77
- cols: number;
78
- rows: number;
79
- pid?: number;
80
- }
81
- export interface CreateTerminalRequest {
82
- name?: string;
83
- cols: number;
84
- rows: number;
85
- cwd?: string;
86
- env?: Record<string, string>;
87
- }
88
- export interface CreateTerminalResponse {
89
- session: TerminalSession;
90
- }
91
- export interface TerminalDataPayload {
92
- sessionId: string;
93
- data: Uint8Array;
94
- }
95
- export interface TerminalResizePayload {
96
- sessionId: string;
97
- cols: number;
98
- rows: number;
99
- }
@@ -1 +0,0 @@
1
- export * from './common';