@crossworks/client-types 0.239.85 → 0.239.87

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossworks/client-types",
3
- "version": "0.239.85",
3
+ "version": "0.239.87",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Workspace management on the wire (workspaces plan page 4887b8e7, phase
3
+ * W5a): /api/workspaces and the two fields /api/shell adds. Users are flat;
4
+ * every permission is set on a workspace screen (users, Moderator ticks,
5
+ * resources) or, from W5b, on an item's Grant Access panel.
6
+ *
7
+ * Every refusal is `{ error, code }` with 400, 403, 404 or 409. A workspace
8
+ * or login the caller may not see answers 404, never 403.
9
+ */
10
+
11
+ /** The Admin areas (plan 1.4). An Admin workspace user has all of them
12
+ * unless a per-user switch turns one off (none can be switched off yet). */
13
+ export type WorkspaceArea = 'settings' | 'users' | 'assistants' | 'connectors' | 'keys';
14
+
15
+ export const WORKSPACE_AREAS: readonly WorkspaceArea[] = [
16
+ 'settings',
17
+ 'users',
18
+ 'assistants',
19
+ 'connectors',
20
+ 'keys',
21
+ ];
22
+
23
+ /** One workspace as a list row and as the head of its screen. */
24
+ export type Workspace = {
25
+ id: string;
26
+ name: string;
27
+ description: string;
28
+ /** A contact node: who this workspace represents. Information only. */
29
+ contactNodeId: string | null;
30
+ /** The workspace's one assistant, if any. */
31
+ assistant: { id: string; name: string } | null;
32
+ /** The Admin workspace: its users manage the brain (requireArea). */
33
+ isAdmin: boolean;
34
+ /** Admin or Team, the built-in workspaces: they cannot be renamed or
35
+ * archived, and their connectors follow each connector's level until
36
+ * W5b (locked). Hide Archive, rename and the connector picker there. */
37
+ builtIn: boolean;
38
+ /** Every Admin workspace user is a Moderator here (the Team workspace);
39
+ * only an Admin user may remove or demote one of them. */
40
+ adminModerated: boolean;
41
+ archived: boolean;
42
+ userCount: number;
43
+ resourceCount: number;
44
+ /** The caller's own place in it. */
45
+ me: { member: boolean; moderator: boolean };
46
+ };
47
+
48
+ /** GET /api/workspaces: an Admin user gets every workspace (archived ones
49
+ * too); any other login the live ones it is a user of. */
50
+ export type WorkspaceListResponse = { workspaces: Workspace[] };
51
+
52
+ /** POST /api/workspaces. Any login may make one; the maker is its only user
53
+ * and a Moderator. */
54
+ export type WorkspaceCreateBody = { name: string; description?: string };
55
+
56
+ /** A user of a workspace, on its screen. */
57
+ export type WorkspaceUser = {
58
+ loginId: string;
59
+ name: string | null;
60
+ email: string;
61
+ moderator: boolean;
62
+ /** A Moderator here because they are an Admin user and the workspace is
63
+ * Admin-moderated: nobody may remove or demote them here (409
64
+ * admin_kept); they stop being one by leaving the Admin workspace. */
65
+ adminViaArea: boolean;
66
+ /** Who added them ("Added by NAME on DATE", plan S1): `name` is the
67
+ * display name or else the email. null when unknown (the adder's login
68
+ * is gone, or a migration or bridge added them). */
69
+ addedBy: { loginId: string; name: string } | null;
70
+ /** When they were added (ISO 8601). */
71
+ addedAt: string;
72
+ };
73
+
74
+ /** A resource kind on the workspace screen (plan 1.4). */
75
+ export type WorkspaceResourceKind = 'assistant' | 'connector';
76
+
77
+ /** One resource: the assistant (an agent id) or a connector (its tool group
78
+ * slug). `write` is the connector's Write tick: a connector tool that can
79
+ * change data runs only when it is on AND the person asking is a Moderator. */
80
+ export type WorkspaceResource = {
81
+ kind: WorkspaceResourceKind;
82
+ id: string;
83
+ name: string;
84
+ write: boolean;
85
+ /** Owned by a level bridge until W5b (the Admin and Team workspaces'
86
+ * connectors follow each connector's level): shown, not editable here. */
87
+ locked: boolean;
88
+ };
89
+
90
+ /** GET /api/workspaces/:id. */
91
+ export type WorkspaceDetailResponse = {
92
+ workspace: Workspace;
93
+ users: WorkspaceUser[];
94
+ resources: WorkspaceResource[];
95
+ /** The assistant has history (threads or messages): it cannot be swapped
96
+ * or removed, only cloned to use elsewhere. */
97
+ hasHistory: boolean;
98
+ };
99
+
100
+ /** PATCH /api/workspaces/:id. Name and description: a Moderator or an Admin
101
+ * user. Contact and assistant: an Admin user (assistant: area
102
+ * 'assistants'). `null` clears. Answers the updated Workspace. */
103
+ export type WorkspacePatchBody = {
104
+ name?: string;
105
+ description?: string;
106
+ contactNodeId?: string | null;
107
+ assistantId?: string | null;
108
+ };
109
+
110
+ /** GET /api/workspaces/:id/archive-preview: what archiving would do.
111
+ * `itemCount` items have their home here: while it is above 0 the archive
112
+ * is refused (move them first). `grantCount` items are only shared here and
113
+ * lose that share. */
114
+ export type WorkspaceArchivePreview = { grantCount: number; itemCount: number };
115
+
116
+ /** POST /api/workspaces/:id/archive answers the archived Workspace plus the
117
+ * counts it applied. */
118
+ export type WorkspaceArchiveResponse = {
119
+ workspace: Workspace;
120
+ grantCount: number;
121
+ itemCount: number;
122
+ };
123
+
124
+ /** POST /api/workspaces/:id/users. */
125
+ export type WorkspaceUserAddBody = { loginId: string; moderator?: boolean };
126
+
127
+ /** PATCH /api/workspaces/:id/users/:loginId. */
128
+ export type WorkspaceUserPatchBody = { moderator: boolean };
129
+
130
+ /** POST, PATCH and DELETE on users answer the workspace screen again. */
131
+ export type WorkspaceUsersResponse = WorkspaceDetailResponse;
132
+
133
+ /** GET /api/workspaces/user-search?q=&offset=: logins by email or name. A
134
+ * non-Admin Moderator needs at least 3 characters and gets at most 10 (no
135
+ * paging: offset > 0 answers 400 invalid). An Admin user may send an empty
136
+ * q (everyone) and gets pages of 50: a full page may have more, so ask
137
+ * again with offset + 50. Disabled and client logins are left out. */
138
+ export type WorkspaceUserSearchHit = { loginId: string; name: string | null; email: string };
139
+ export type WorkspaceUserSearchResponse = WorkspaceUserSearchHit[];
140
+
141
+ /** POST /api/workspaces/:id/resources. */
142
+ export type WorkspaceResourceAddBody = {
143
+ kind: WorkspaceResourceKind;
144
+ id: string;
145
+ write?: boolean;
146
+ };
147
+
148
+ /** PATCH /api/workspaces/:id/resources/:kind/:id. */
149
+ export type WorkspaceResourcePatchBody = { write: boolean };
150
+
151
+ /** What /api/shell adds for the signed-in login: its live workspaces (for
152
+ * the switcher) and its Admin areas ([] when it is not an Admin user). */
153
+ export type ShellWorkspace = { id: string; name: string; isAdmin: boolean; moderator: boolean };
154
+ export type ShellWorkspaces = { workspaces: ShellWorkspace[]; areas: WorkspaceArea[] };
155
+
156
+ /** Every `code` a /api/workspaces refusal carries. */
157
+ export type WorkspaceErrorCode =
158
+ | 'invalid'
159
+ | 'not_migrated'
160
+ | 'query_too_short'
161
+ | 'not_found'
162
+ | 'forbidden'
163
+ | 'admin_only'
164
+ | 'reserved_name'
165
+ | 'archived'
166
+ | 'admin_workspace'
167
+ | 'bridge_owned'
168
+ | 'workspace_holds_items'
169
+ | 'already_user'
170
+ | 'not_user'
171
+ | 'last_moderator'
172
+ | 'admin_kept'
173
+ | 'owner_stays_admin'
174
+ | 'self_demote'
175
+ | 'client_login'
176
+ | 'assistant_has_history'
177
+ | 'assistant_in_use'
178
+ | 'resource_exists'
179
+ | 'rate_limited';
180
+
181
+ export type WorkspaceError = { error: string; code: WorkspaceErrorCode };
package/src/index.ts CHANGED
@@ -217,3 +217,28 @@ export type {
217
217
  TreeVisibilityChange,
218
218
  TreeVisibilityRefusal,
219
219
  } from './tree';
220
+ // Types only; WORKSPACE_AREAS (runtime) is the `@mantle/client-types/dto/workspaces` subpath.
221
+ export type {
222
+ ShellWorkspace,
223
+ ShellWorkspaces,
224
+ Workspace,
225
+ WorkspaceArchivePreview,
226
+ WorkspaceArchiveResponse,
227
+ WorkspaceArea,
228
+ WorkspaceCreateBody,
229
+ WorkspaceDetailResponse,
230
+ WorkspaceError,
231
+ WorkspaceErrorCode,
232
+ WorkspaceListResponse,
233
+ WorkspacePatchBody,
234
+ WorkspaceResource,
235
+ WorkspaceResourceAddBody,
236
+ WorkspaceResourceKind,
237
+ WorkspaceResourcePatchBody,
238
+ WorkspaceUser,
239
+ WorkspaceUserAddBody,
240
+ WorkspaceUserPatchBody,
241
+ WorkspaceUserSearchHit,
242
+ WorkspaceUserSearchResponse,
243
+ WorkspaceUsersResponse,
244
+ } from './dto/workspaces';