@naisys/hub-protocol 3.0.0-beta.3

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.

Potentially problematic release.


This version of @naisys/hub-protocol might be problematic. Click here for more details.

@@ -0,0 +1,177 @@
1
+ import { z } from "zod";
2
+ // =============================================================================
3
+ // Common
4
+ // =============================================================================
5
+ export const MessageKindSchema = z.enum(["mail", "chat"]);
6
+ export const AttachmentPurposeEnum = z.enum(["mail", "context"]);
7
+ // =============================================================================
8
+ // Send
9
+ // =============================================================================
10
+ /** Request to send a mail message */
11
+ export const MailSendRequestSchema = z.object({
12
+ fromUserId: z.number(),
13
+ toUserIds: z.array(z.number()),
14
+ subject: z.string(),
15
+ body: z.string(),
16
+ kind: MessageKindSchema,
17
+ attachmentIds: z.array(z.number()).optional(),
18
+ });
19
+ /** Response to mail send request */
20
+ export const MailSendResponseSchema = z.object({
21
+ success: z.boolean(),
22
+ error: z.string().optional(),
23
+ });
24
+ // =============================================================================
25
+ // List
26
+ // =============================================================================
27
+ /** Request to list mail messages */
28
+ export const MailListRequestSchema = z.object({
29
+ userId: z.number(),
30
+ filter: z.enum(["received", "sent"]).optional(),
31
+ kind: MessageKindSchema,
32
+ skip: z.number().optional(),
33
+ take: z.number().optional(),
34
+ withUserIds: z.array(z.number()).optional(),
35
+ });
36
+ /** Attachment metadata included in message responses */
37
+ export const MailAttachmentDataSchema = z.object({
38
+ id: z.string(),
39
+ filename: z.string(),
40
+ fileSize: z.number(),
41
+ });
42
+ /** A single message in a mail list response */
43
+ export const MailListMessageDataSchema = z.object({
44
+ id: z.number(),
45
+ fromUsername: z.string(),
46
+ fromTitle: z.string(),
47
+ recipientUsernames: z.array(z.string()),
48
+ subject: z.string(),
49
+ createdAt: z.string(),
50
+ isUnread: z.boolean(),
51
+ body: z.string().optional(),
52
+ attachments: z.array(MailAttachmentDataSchema).optional(),
53
+ });
54
+ /** Response to mail list request */
55
+ export const MailListResponseSchema = z.object({
56
+ success: z.boolean(),
57
+ messages: z.array(MailListMessageDataSchema).optional(),
58
+ error: z.string().optional(),
59
+ });
60
+ // =============================================================================
61
+ // Peek (fetch without marking as read)
62
+ // =============================================================================
63
+ /** Request to peek at a specific mail message */
64
+ export const MailPeekRequestSchema = z.object({
65
+ userId: z.number(),
66
+ messageId: z.number(),
67
+ });
68
+ /** Full message data returned when fetching a message */
69
+ export const MailMessageDataSchema = z.object({
70
+ id: z.number(),
71
+ subject: z.string(),
72
+ fromUsername: z.string(),
73
+ fromTitle: z.string(),
74
+ recipientUsernames: z.array(z.string()),
75
+ createdAt: z.string(),
76
+ body: z.string(),
77
+ attachments: z.array(MailAttachmentDataSchema).optional(),
78
+ });
79
+ /** Response to mail peek request */
80
+ export const MailPeekResponseSchema = z.object({
81
+ success: z.boolean(),
82
+ message: MailMessageDataSchema.optional(),
83
+ error: z.string().optional(),
84
+ });
85
+ // =============================================================================
86
+ // Archive
87
+ // =============================================================================
88
+ /** Request to archive mail messages */
89
+ export const MailArchiveRequestSchema = z.object({
90
+ userId: z.number(),
91
+ messageIds: z.array(z.number()),
92
+ });
93
+ /** Response to mail archive request */
94
+ export const MailArchiveResponseSchema = z.object({
95
+ success: z.boolean(),
96
+ archivedIds: z.array(z.number()).optional(),
97
+ error: z.string().optional(),
98
+ });
99
+ // =============================================================================
100
+ // Search
101
+ // =============================================================================
102
+ /** Request to search mail messages */
103
+ export const MailSearchRequestSchema = z.object({
104
+ userId: z.number(),
105
+ terms: z.string(),
106
+ includeArchived: z.boolean().optional(),
107
+ subjectOnly: z.boolean().optional(),
108
+ });
109
+ /** A single message in a mail search response */
110
+ export const MailSearchMessageDataSchema = z.object({
111
+ id: z.number(),
112
+ subject: z.string(),
113
+ fromUsername: z.string(),
114
+ createdAt: z.string(),
115
+ });
116
+ /** Response to mail search request */
117
+ export const MailSearchResponseSchema = z.object({
118
+ success: z.boolean(),
119
+ messages: z.array(MailSearchMessageDataSchema).optional(),
120
+ error: z.string().optional(),
121
+ });
122
+ // =============================================================================
123
+ // Mark Read
124
+ // =============================================================================
125
+ /** Request to mark messages as read */
126
+ export const MailMarkReadRequestSchema = z.object({
127
+ userId: z.number(),
128
+ messageIds: z.array(z.number()),
129
+ kind: MessageKindSchema,
130
+ });
131
+ /** Response to mark-read request */
132
+ export const MailMarkReadResponseSchema = z.object({
133
+ success: z.boolean(),
134
+ error: z.string().optional(),
135
+ });
136
+ // =============================================================================
137
+ // Unread
138
+ // =============================================================================
139
+ /** Request to get unread messages */
140
+ export const MailUnreadRequestSchema = z.object({
141
+ userId: z.number(),
142
+ kind: MessageKindSchema,
143
+ afterId: z.number().optional(),
144
+ });
145
+ /** Response to unread messages request */
146
+ export const MailUnreadResponseSchema = z.object({
147
+ success: z.boolean(),
148
+ messages: z.array(MailMessageDataSchema).optional(),
149
+ error: z.string().optional(),
150
+ });
151
+ // =============================================================================
152
+ // Push notification
153
+ // =============================================================================
154
+ /** Push notification from hub to NAISYS when mail is received */
155
+ export const MailReceivedPushSchema = z.object({
156
+ recipientUserIds: z.array(z.number()),
157
+ kind: MessageKindSchema,
158
+ });
159
+ /** Full-data mail/chat push from hub to supervisor after DB write */
160
+ export const MailPushSchema = z.object({
161
+ recipientUserIds: z.array(z.number()),
162
+ fromUserId: z.number(),
163
+ kind: MessageKindSchema,
164
+ messageId: z.number(),
165
+ subject: z.string().optional(),
166
+ body: z.string(),
167
+ createdAt: z.string(),
168
+ participants: z.string(),
169
+ attachments: z.array(MailAttachmentDataSchema).optional(),
170
+ });
171
+ /** Read-receipt push from hub to supervisor when messages are marked read */
172
+ export const MailReadPushSchema = z.object({
173
+ messageIds: z.array(z.number()),
174
+ userId: z.number(),
175
+ kind: MessageKindSchema,
176
+ participants: z.array(z.string()),
177
+ });
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ /** Pushed from hub to NAISYS instances with all model definitions */
3
+ export declare const ModelsResponseSchema: z.ZodObject<{
4
+ success: z.ZodBoolean;
5
+ error: z.ZodOptional<z.ZodString>;
6
+ llmModels: z.ZodOptional<z.ZodArray<z.ZodObject<{
7
+ key: z.ZodString;
8
+ label: z.ZodString;
9
+ versionName: z.ZodString;
10
+ apiType: z.ZodEnum<typeof import("@naisys/common").LlmApiType>;
11
+ maxTokens: z.ZodNumber;
12
+ baseUrl: z.ZodOptional<z.ZodString>;
13
+ apiKeyVar: z.ZodString;
14
+ inputCost: z.ZodDefault<z.ZodNumber>;
15
+ outputCost: z.ZodDefault<z.ZodNumber>;
16
+ cacheWriteCost: z.ZodOptional<z.ZodNumber>;
17
+ cacheReadCost: z.ZodOptional<z.ZodNumber>;
18
+ cacheTtlSeconds: z.ZodOptional<z.ZodNumber>;
19
+ supportsVision: z.ZodOptional<z.ZodBoolean>;
20
+ supportsHearing: z.ZodOptional<z.ZodBoolean>;
21
+ supportsComputerUse: z.ZodOptional<z.ZodBoolean>;
22
+ }, z.core.$strip>>>;
23
+ imageModels: z.ZodOptional<z.ZodArray<z.ZodObject<{
24
+ key: z.ZodString;
25
+ label: z.ZodString;
26
+ versionName: z.ZodString;
27
+ size: z.ZodString;
28
+ baseUrl: z.ZodOptional<z.ZodString>;
29
+ apiKeyVar: z.ZodString;
30
+ cost: z.ZodNumber;
31
+ quality: z.ZodOptional<z.ZodEnum<{
32
+ standard: "standard";
33
+ hd: "hd";
34
+ high: "high";
35
+ medium: "medium";
36
+ low: "low";
37
+ }>>;
38
+ }, z.core.$strip>>>;
39
+ }, z.core.$strip>;
40
+ export type ModelsResponse = z.infer<typeof ModelsResponseSchema>;
41
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { ImageModelSchema, LlmModelSchema } from "@naisys/common";
2
+ import { z } from "zod";
3
+ /** Pushed from hub to NAISYS instances with all model definitions */
4
+ export const ModelsResponseSchema = z.object({
5
+ success: z.boolean(),
6
+ error: z.string().optional(),
7
+ llmModels: z.array(LlmModelSchema).optional(),
8
+ imageModels: z.array(ImageModelSchema).optional(),
9
+ });
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ /** Full session data pushed from hub to supervisor after creation */
3
+ export declare const SessionPushSchema: z.ZodObject<{
4
+ session: z.ZodObject<{
5
+ userId: z.ZodNumber;
6
+ runId: z.ZodNumber;
7
+ sessionId: z.ZodNumber;
8
+ modelName: z.ZodString;
9
+ createdAt: z.ZodString;
10
+ lastActive: z.ZodString;
11
+ latestLogId: z.ZodNumber;
12
+ totalLines: z.ZodNumber;
13
+ totalCost: z.ZodNumber;
14
+ }, z.core.$strip>;
15
+ }, z.core.$strip>;
16
+ export type SessionPush = z.infer<typeof SessionPushSchema>;
17
+ /** Request to create a new run session */
18
+ export declare const SessionCreateRequestSchema: z.ZodObject<{
19
+ userId: z.ZodNumber;
20
+ modelName: z.ZodString;
21
+ }, z.core.$strip>;
22
+ export type SessionCreateRequest = z.infer<typeof SessionCreateRequestSchema>;
23
+ /** Response to session create request */
24
+ export declare const SessionCreateResponseSchema: z.ZodObject<{
25
+ success: z.ZodBoolean;
26
+ runId: z.ZodOptional<z.ZodNumber>;
27
+ sessionId: z.ZodOptional<z.ZodNumber>;
28
+ error: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strip>;
30
+ export type SessionCreateResponse = z.infer<typeof SessionCreateResponseSchema>;
31
+ /** Request to increment session for an existing run */
32
+ export declare const SessionIncrementRequestSchema: z.ZodObject<{
33
+ userId: z.ZodNumber;
34
+ runId: z.ZodNumber;
35
+ modelName: z.ZodString;
36
+ }, z.core.$strip>;
37
+ export type SessionIncrementRequest = z.infer<typeof SessionIncrementRequestSchema>;
38
+ /** Response to session increment request */
39
+ export declare const SessionIncrementResponseSchema: z.ZodObject<{
40
+ success: z.ZodBoolean;
41
+ sessionId: z.ZodOptional<z.ZodNumber>;
42
+ error: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strip>;
44
+ export type SessionIncrementResponse = z.infer<typeof SessionIncrementResponseSchema>;
45
+ //# sourceMappingURL=sessions.d.ts.map
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ /** Full session data pushed from hub to supervisor after creation */
3
+ export const SessionPushSchema = z.object({
4
+ session: z.object({
5
+ userId: z.number(),
6
+ runId: z.number(),
7
+ sessionId: z.number(),
8
+ modelName: z.string(),
9
+ createdAt: z.string(),
10
+ lastActive: z.string(),
11
+ latestLogId: z.number(),
12
+ totalLines: z.number(),
13
+ totalCost: z.number(),
14
+ }),
15
+ });
16
+ /** Request to create a new run session */
17
+ export const SessionCreateRequestSchema = z.object({
18
+ userId: z.number(),
19
+ modelName: z.string(),
20
+ });
21
+ /** Response to session create request */
22
+ export const SessionCreateResponseSchema = z.object({
23
+ success: z.boolean(),
24
+ runId: z.number().optional(),
25
+ sessionId: z.number().optional(),
26
+ error: z.string().optional(),
27
+ });
28
+ /** Request to increment session for an existing run */
29
+ export const SessionIncrementRequestSchema = z.object({
30
+ userId: z.number(),
31
+ runId: z.number(),
32
+ modelName: z.string(),
33
+ });
34
+ /** Response to session increment request */
35
+ export const SessionIncrementResponseSchema = z.object({
36
+ success: z.boolean(),
37
+ sessionId: z.number().optional(),
38
+ error: z.string().optional(),
39
+ });
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ /** Response to user_list request - returns all users registered on the hub */
3
+ export declare const UserListResponseSchema: z.ZodObject<{
4
+ success: z.ZodBoolean;
5
+ error: z.ZodOptional<z.ZodString>;
6
+ users: z.ZodOptional<z.ZodArray<z.ZodObject<{
7
+ userId: z.ZodNumber;
8
+ username: z.ZodString;
9
+ enabled: z.ZodBoolean;
10
+ leadUserId: z.ZodOptional<z.ZodNumber>;
11
+ config: z.ZodObject<{
12
+ username: z.ZodString;
13
+ title: z.ZodString;
14
+ agentPrompt: z.ZodString;
15
+ spendLimitDollars: z.ZodOptional<z.ZodNumber>;
16
+ spendLimitHours: z.ZodOptional<z.ZodNumber>;
17
+ tokenMax: z.ZodNumber;
18
+ shellModel: z.ZodString;
19
+ imageModel: z.ZodOptional<z.ZodString>;
20
+ mailEnabled: z.ZodOptional<z.ZodBoolean>;
21
+ chatEnabled: z.ZodOptional<z.ZodBoolean>;
22
+ webEnabled: z.ZodOptional<z.ZodBoolean>;
23
+ completeSessionEnabled: z.ZodOptional<z.ZodBoolean>;
24
+ debugPauseSeconds: z.ZodOptional<z.ZodNumber>;
25
+ wakeOnMessage: z.ZodOptional<z.ZodBoolean>;
26
+ commandProtection: z.ZodOptional<z.ZodEnum<{
27
+ none: "none";
28
+ manual: "manual";
29
+ "semi-auto": "semi-auto";
30
+ auto: "auto";
31
+ }>>;
32
+ initialCommands: z.ZodOptional<z.ZodArray<z.ZodString>>;
33
+ multipleCommandsEnabled: z.ZodOptional<z.ZodBoolean>;
34
+ workspacesEnabled: z.ZodOptional<z.ZodBoolean>;
35
+ controlDesktop: z.ZodOptional<z.ZodBoolean>;
36
+ }, z.core.$strip>;
37
+ assignedHostIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
38
+ apiKey: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strip>>>;
40
+ }, z.core.$strip>;
41
+ export type UserListResponse = z.infer<typeof UserListResponseSchema>;
42
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { AgentConfigFileSchema } from "@naisys/common";
2
+ import { z } from "zod";
3
+ /** Response to user_list request - returns all users registered on the hub */
4
+ export const UserListResponseSchema = z.object({
5
+ success: z.boolean(),
6
+ error: z.string().optional(),
7
+ users: z
8
+ .array(z.object({
9
+ userId: z.number(),
10
+ username: z.string(),
11
+ enabled: z.boolean(),
12
+ leadUserId: z.number().optional(),
13
+ config: AgentConfigFileSchema,
14
+ assignedHostIds: z.array(z.number()).optional(),
15
+ apiKey: z.string().optional(),
16
+ }))
17
+ .optional(),
18
+ });
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@naisys/hub-protocol",
3
+ "version": "3.0.0-beta.3",
4
+ "type": "module",
5
+ "description": "[internal] Protocol types and schemas for NAISYS Hub communication",
6
+ "files": [
7
+ "dist",
8
+ "!dist/**/*.map"
9
+ ],
10
+ "scripts": {
11
+ "clean": "rimraf dist",
12
+ "build": "tsc",
13
+ "npm:publish:dryrun": "npm publish --dry-run",
14
+ "npm:publish": "npm publish --access public"
15
+ },
16
+ "devDependencies": {
17
+ "typescript": "^5.9.3"
18
+ },
19
+ "dependencies": {
20
+ "@naisys/common": "3.0.0-beta.3",
21
+ "zod": "^4.3.6"
22
+ },
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ }
28
+ }
29
+ }