@eum-agent/web-shell 0.0.0-stage → 1.0.1

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/schema.js ADDED
@@ -0,0 +1,236 @@
1
+ import { z } from "zod";
2
+ //#region src/schema.ts
3
+ /** WebShell's browser-safe wire contract; the host owns authentication and stream envelopes. */
4
+ /** Explicit workspace identity, independent of a selected chat. */
5
+ const WorkspaceId = z.string().min(1).max(1024).refine((value) => !/[/\\]/u.test(value) && !Array.from(value).some((c) => c.charCodeAt(0) < 32));
6
+ /** Full canonical-root digest. */
7
+ const RootId = z.string().regex(/^[a-f0-9]{64}$/);
8
+ /** Literal relative initial directory, with the empty path selecting its root. */
9
+ const RelativePath = z.string().max(4096).refine((value) => value === "" || value.split("/").every((part) => part !== "" && part !== "." && part !== ".." && !/[\\]/u.test(part) && !Array.from(part).some((c) => c.charCodeAt(0) < 32 || c.charCodeAt(0) === 127)));
10
+ /** Physical terminal dimensions. */
11
+ const Dimension = z.number().int().min(1).max(1e3);
12
+ /** A bounded public diagnostic; never contains output or exception details. */
13
+ const AccessError = z.object({
14
+ code: z.string().max(64),
15
+ message: z.string().max(256)
16
+ }).strict();
17
+ /** State of a retained terminal; runId identifies its current physical PTY, cwd its initial directory. */
18
+ const TerminalSummary = z.object({
19
+ id: z.uuid(),
20
+ runId: z.uuid(),
21
+ creationOperationId: z.uuid(),
22
+ title: z.string().max(80),
23
+ defaultTitleNumber: z.number().int().positive().optional(),
24
+ workspaceId: WorkspaceId,
25
+ instanceId: z.uuid(),
26
+ cwd: z.string(),
27
+ status: z.enum([
28
+ "running",
29
+ "closing",
30
+ "ended",
31
+ "close-failed"
32
+ ]),
33
+ hostAccount: z.string(),
34
+ inputOwner: z.uuid().nullable(),
35
+ cols: Dimension,
36
+ rows: Dimension,
37
+ cursor: z.number().int().nonnegative(),
38
+ exitCode: z.number().int().nullable().optional(),
39
+ cleanupScope: z.enum(["pty-process-group", "windows-job"]),
40
+ cleanupWarnings: z.array(z.string().max(256)).max(32).optional(),
41
+ truncated: z.boolean().optional()
42
+ }).strict();
43
+ /** Independent roots and current host capability. */
44
+ const RootsResult = z.object({
45
+ gatewayId: z.uuid(),
46
+ instanceId: z.uuid(),
47
+ available: z.boolean(),
48
+ reason: z.string().optional(),
49
+ roots: z.array(z.object({
50
+ id: RootId,
51
+ kind: z.enum(["own", "directory"]),
52
+ name: z.string(),
53
+ path: z.string()
54
+ }).strict())
55
+ }).strict();
56
+ /** Workspace terminal directory for this Gateway process. */
57
+ const ListResult = z.object({
58
+ gatewayId: z.uuid(),
59
+ instanceId: z.uuid(),
60
+ terminals: z.array(TerminalSummary).max(48)
61
+ }).strict();
62
+ /** A committed directory mutation; clients reread the matching workspace instead of replaying it. */
63
+ const Changed = z.object({
64
+ instanceId: z.uuid(),
65
+ workspaceId: WorkspaceId
66
+ }).strict();
67
+ /** UUID operation facts retained only within the bounded query window. */
68
+ const OperationResult = z.object({
69
+ operationId: z.uuid(),
70
+ instanceId: z.uuid(),
71
+ status: z.enum([
72
+ "pending",
73
+ "succeeded",
74
+ "failed",
75
+ "unknown"
76
+ ]),
77
+ terminal: TerminalSummary.optional(),
78
+ error: AccessError.optional()
79
+ }).strict();
80
+ /** Defaults to workspace HOME; an explicit root/path selects another admitted initial directory. */
81
+ const CreateParams = z.object({
82
+ workspaceId: WorkspaceId,
83
+ rootId: RootId.optional(),
84
+ path: RelativePath.optional(),
85
+ cols: Dimension,
86
+ rows: Dimension,
87
+ operationId: z.uuid()
88
+ }).strict();
89
+ /** Close selection; endedRunId limits automatic removal to that already ended run. */
90
+ const CloseParams = z.object({
91
+ instanceId: z.uuid(),
92
+ workspaceId: WorkspaceId,
93
+ terminalId: z.uuid(),
94
+ operationId: z.uuid(),
95
+ endedRunId: z.uuid().optional()
96
+ }).strict();
97
+ /** Metadata edit for the current Gateway/workspace; names are trimmed, nonblank and single-line. */
98
+ const RenameParams = z.object({
99
+ instanceId: z.uuid(),
100
+ workspaceId: WorkspaceId,
101
+ terminalId: z.uuid(),
102
+ title: z.string().trim().min(1).max(80).refine((value) => !Array.from(value).some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))
103
+ }).strict();
104
+ /** Restarts a cleaned ended record in its original directory; omitted dimensions retain its size. */
105
+ const RestartParams = z.object({
106
+ instanceId: z.uuid(),
107
+ workspaceId: WorkspaceId,
108
+ terminalId: z.uuid(),
109
+ operationId: z.uuid(),
110
+ cols: Dimension.optional(),
111
+ rows: Dimension.optional()
112
+ }).strict();
113
+ /** Read-only retained-operation query. */
114
+ const OperationStatusParams = z.object({
115
+ instanceId: z.uuid(),
116
+ operationId: z.uuid()
117
+ }).strict();
118
+ /** One authenticated observation of an existing terminal. */
119
+ const TerminalOpen = z.object({
120
+ instanceId: z.uuid(),
121
+ workspaceId: WorkspaceId,
122
+ terminalId: z.uuid(),
123
+ cursor: z.number().int().nonnegative().optional(),
124
+ desiredInput: z.boolean()
125
+ }).strict();
126
+ /** Atomic ready metadata preceding any replay or live output. */
127
+ const TerminalReady = z.object({
128
+ terminal: TerminalSummary,
129
+ subscriptionId: z.uuid(),
130
+ writer: z.boolean(),
131
+ leaseEpoch: z.number().int().nonnegative(),
132
+ firstCursor: z.number().int().positive(),
133
+ lastCursor: z.number().int().nonnegative(),
134
+ truncated: z.boolean()
135
+ }).strict();
136
+ /** Control messages are independent of output consumption. */
137
+ const TerminalInput = z.discriminatedUnion("kind", [
138
+ z.object({
139
+ kind: z.literal("write"),
140
+ leaseEpoch: z.number().int().nonnegative(),
141
+ text: z.string().max(32768)
142
+ }).strict(),
143
+ z.object({
144
+ kind: z.literal("resize"),
145
+ leaseEpoch: z.number().int().nonnegative(),
146
+ cols: Dimension,
147
+ rows: Dimension
148
+ }).strict(),
149
+ z.object({ kind: z.literal("takeover") }).strict(),
150
+ z.object({
151
+ kind: z.literal("ack"),
152
+ cursor: z.number().int().nonnegative()
153
+ }).strict()
154
+ ]);
155
+ /** Output blocks and explicit history/control state. */
156
+ const TerminalOutput = z.discriminatedUnion("kind", [
157
+ z.object({
158
+ kind: z.literal("output"),
159
+ cursor: z.number().int().positive(),
160
+ text: z.string().refine((text) => new TextEncoder().encode(text).length <= 16384)
161
+ }).strict(),
162
+ z.object({
163
+ kind: z.literal("gap"),
164
+ firstCursor: z.number().int().positive(),
165
+ requestedCursor: z.number().int().nonnegative()
166
+ }).strict(),
167
+ z.object({
168
+ kind: z.literal("writer"),
169
+ inputOwner: z.uuid().nullable(),
170
+ leaseEpoch: z.number().int().nonnegative()
171
+ }).strict(),
172
+ z.object({
173
+ kind: z.literal("status"),
174
+ terminal: TerminalSummary
175
+ }).strict(),
176
+ z.object({
177
+ kind: z.literal("error"),
178
+ error: AccessError
179
+ }).strict()
180
+ ]);
181
+ const encodedBytes = (value) => new TextEncoder().encode(JSON.stringify(value)).byteLength;
182
+ const CloseMember = CloseParams.omit({
183
+ instanceId: true,
184
+ workspaceId: true
185
+ });
186
+ /** Independent close intents retain their UUID and normalized input regardless of array position. */
187
+ const CloseTerminalsParams = z.object({
188
+ instanceId: z.uuid(),
189
+ workspaceId: WorkspaceId,
190
+ items: z.array(CloseMember).min(1).max(48)
191
+ }).strict().superRefine((input, ctx) => {
192
+ if (encodedBytes(input) * 2 > 8388608) ctx.addIssue({
193
+ code: "custom",
194
+ message: "Terminal input exceeds its byte budget"
195
+ });
196
+ const identities = /* @__PURE__ */ new Map();
197
+ for (const member of input.items) {
198
+ const value = JSON.stringify(member);
199
+ if (identities.has(member.operationId) && identities.get(member.operationId) !== value) ctx.addIssue({
200
+ code: "custom",
201
+ message: "Operation identity has conflicting members"
202
+ });
203
+ identities.set(member.operationId, value);
204
+ }
205
+ });
206
+ /** Read-only status collections reject declared response costs before reading any retained fact. */
207
+ const OperationStatusesParams = z.object({
208
+ instanceId: z.uuid(),
209
+ operationIds: z.array(z.uuid()).min(1).max(64),
210
+ maxItemBytes: z.number().int().min(1).max(8388608).default(262144),
211
+ maxTotalBytes: z.number().int().min(1).max(8388608).default(8388608)
212
+ }).strict().superRefine((input, ctx) => {
213
+ if (encodedBytes(input) * 2 > 8388608 || input.operationIds.length * input.maxItemBytes + 8192 > input.maxTotalBytes || input.operationIds.some((id) => encodedBytes(id) + 4096 > input.maxItemBytes)) ctx.addIssue({
214
+ code: "custom",
215
+ message: "Terminal collection exceeds its byte budget"
216
+ });
217
+ });
218
+ function collectionResult(target) {
219
+ return z.object({ results: z.array(z.discriminatedUnion("ok", [z.object({
220
+ index: z.number().int().nonnegative(),
221
+ target,
222
+ ok: z.literal(true),
223
+ value: OperationResult
224
+ }).strict(), z.object({
225
+ index: z.number().int().nonnegative(),
226
+ target,
227
+ ok: z.literal(false),
228
+ error: AccessError
229
+ }).strict()])).max(64) }).strict();
230
+ }
231
+ /** Ordered close outcomes preserve physical failure facts independently. */
232
+ const CloseTerminalsResult = collectionResult(CloseMember);
233
+ /** Ordered retained facts include unknown operations without replaying them. */
234
+ const OperationStatusesResult = collectionResult(z.uuid());
235
+ //#endregion
236
+ export { AccessError, Changed, CloseParams, CloseTerminalsParams, CloseTerminalsResult, CreateParams, Dimension, ListResult, OperationResult, OperationStatusParams, OperationStatusesParams, OperationStatusesResult, RelativePath, RenameParams, RestartParams, RootId, RootsResult, TerminalInput, TerminalOpen, TerminalOutput, TerminalReady, TerminalSummary, WorkspaceId };
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@eum-agent/web-shell",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "displayName": {
4
+ "en-US": "Terminal",
5
+ "zh-CN": "终端"
6
+ },
7
+ "version": "1.0.1",
8
+ "type": "module",
9
+ "description": "Sessionless host-account interactive terminals",
10
+ "license": "MIT",
11
+ "exports": {
12
+ ".": {
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./schema": {
16
+ "default": "./dist/schema.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "ui"
22
+ ],
23
+ "dependencies": {
24
+ "zod": "^4.4.3",
25
+ "@xterm/xterm": "6.0.0",
26
+ "@xterm/addon-fit": "0.11.0",
27
+ "@xterm/addon-search": "0.16.0",
28
+ "lucide-react": "^1.40.0"
29
+ },
30
+ "devDependencies": {
31
+ "@eum-agent/plugin": "1.0.1",
32
+ "@eum-agent/runtime": "1.0.0",
33
+ "@eum-agent/protocol": "1.0.0",
34
+ "@types/react": "^19.2.18",
35
+ "@types/react-dom": "^19.2.5",
36
+ "react": "^19.2.0",
37
+ "react-dom": "^19.2.0",
38
+ "vite": "^8.2.2",
39
+ "@testing-library/react": "^16.3.3",
40
+ "@eum-agent/infra-local": "1.0.1"
41
+ },
42
+ "yaoguang": {
43
+ "description": {
44
+ "en-US": "Sessionless host-account interactive terminals",
45
+ "zh-CN": "独立的主机账号交互终端"
46
+ },
47
+ "dependencies": {},
48
+ "kind": "extension",
49
+ "foundationDependencies": {
50
+ "@eum-agent/infra-local": "1.0.1"
51
+ }
52
+ },
53
+ "scripts": {
54
+ "build": "tsdown && vite build",
55
+ "test": "vitest run",
56
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.ui.json"
57
+ }
6
58
  }