@naisys/supervisor-shared 3.0.0-beta.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.
- package/dist/admin-types.js +57 -0
- package/dist/agent-config-types.js +56 -0
- package/dist/agents-types.js +161 -0
- package/dist/api-types.js +4 -0
- package/dist/auth-types.js +19 -0
- package/dist/chat-types.js +64 -0
- package/dist/controls-types.js +3 -0
- package/dist/costs-types.js +24 -0
- package/dist/error-types.js +6 -0
- package/dist/index.js +15 -0
- package/dist/log-types.js +25 -0
- package/dist/mail-types.js +64 -0
- package/dist/models-types.js +86 -0
- package/dist/runs-types.js +53 -0
- package/dist/status-types.js +27 -0
- package/dist/user-types.js +43 -0
- package/dist/variables-types.js +26 -0
- package/package.json +32 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { HateoasActionSchema, HateoasLinkSchema } from "@naisys/common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const AdminInfoResponseSchema = z.object({
|
|
4
|
+
supervisorDbPath: z.string(),
|
|
5
|
+
supervisorDbSize: z.number().optional(),
|
|
6
|
+
hubDbPath: z.string(),
|
|
7
|
+
hubDbSize: z.number().optional(),
|
|
8
|
+
hubConnected: z.boolean(),
|
|
9
|
+
hubAccessKey: z.string().optional(),
|
|
10
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
11
|
+
});
|
|
12
|
+
export const AdminAttachmentItemSchema = z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
filename: z.string(),
|
|
15
|
+
fileSize: z.number(),
|
|
16
|
+
fileHash: z.string(),
|
|
17
|
+
purpose: z.string(),
|
|
18
|
+
uploadedBy: z.string(),
|
|
19
|
+
createdAt: z.string(),
|
|
20
|
+
});
|
|
21
|
+
export const AdminAttachmentListRequestSchema = z.object({
|
|
22
|
+
page: z.coerce.number().optional().default(1),
|
|
23
|
+
pageSize: z.coerce.number().optional().default(50),
|
|
24
|
+
});
|
|
25
|
+
export const AdminAttachmentListResponseSchema = z.object({
|
|
26
|
+
attachments: z.array(AdminAttachmentItemSchema),
|
|
27
|
+
total: z.number(),
|
|
28
|
+
page: z.number(),
|
|
29
|
+
pageSize: z.number(),
|
|
30
|
+
_links: z.array(HateoasLinkSchema),
|
|
31
|
+
});
|
|
32
|
+
export const RotateAccessKeyResultSchema = z.object({
|
|
33
|
+
success: z.boolean(),
|
|
34
|
+
newAccessKey: z.string().optional(),
|
|
35
|
+
error: z.string().optional(),
|
|
36
|
+
});
|
|
37
|
+
export const ServerLogFileSchema = z.enum([
|
|
38
|
+
"supervisor",
|
|
39
|
+
"hub-server",
|
|
40
|
+
"hub-client",
|
|
41
|
+
]);
|
|
42
|
+
export const ServerLogRequestSchema = z.object({
|
|
43
|
+
file: ServerLogFileSchema,
|
|
44
|
+
lines: z.coerce.number().optional().default(200),
|
|
45
|
+
minLevel: z.coerce.number().optional(),
|
|
46
|
+
});
|
|
47
|
+
export const PinoLogEntrySchema = z.object({
|
|
48
|
+
level: z.number(),
|
|
49
|
+
time: z.number(),
|
|
50
|
+
msg: z.string(),
|
|
51
|
+
detail: z.string().optional(),
|
|
52
|
+
});
|
|
53
|
+
export const ServerLogResponseSchema = z.object({
|
|
54
|
+
entries: z.array(PinoLogEntrySchema),
|
|
55
|
+
fileName: z.string(),
|
|
56
|
+
fileSize: z.number().optional(),
|
|
57
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AgentConfigFileSchema, HateoasActionSchema, HateoasLinkSchema, URL_SAFE_KEY_MESSAGE, URL_SAFE_KEY_REGEX, } from "@naisys/common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// Zod schemas for agent config operations
|
|
4
|
+
export const CreateAgentConfigRequestSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
name: z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(100)
|
|
10
|
+
.regex(URL_SAFE_KEY_REGEX, URL_SAFE_KEY_MESSAGE),
|
|
11
|
+
title: z.string().max(200).optional(),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
export const CreateAgentConfigResponseSchema = z.object({
|
|
15
|
+
success: z.boolean(),
|
|
16
|
+
message: z.string(),
|
|
17
|
+
name: z.string().optional(),
|
|
18
|
+
_links: z.array(HateoasLinkSchema).optional(),
|
|
19
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
20
|
+
});
|
|
21
|
+
export const UpdateAgentConfigRequestSchema = z
|
|
22
|
+
.object({
|
|
23
|
+
config: AgentConfigFileSchema,
|
|
24
|
+
})
|
|
25
|
+
.strict();
|
|
26
|
+
export const UpdateAgentConfigResponseSchema = z.object({
|
|
27
|
+
success: z.boolean(),
|
|
28
|
+
message: z.string(),
|
|
29
|
+
config: AgentConfigFileSchema.optional(),
|
|
30
|
+
});
|
|
31
|
+
export const ImportAgentConfigRequestSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
yaml: z.string().min(1),
|
|
34
|
+
})
|
|
35
|
+
.strict();
|
|
36
|
+
export const ImportAgentConfigResponseSchema = z.object({
|
|
37
|
+
success: z.boolean(),
|
|
38
|
+
message: z.string(),
|
|
39
|
+
config: AgentConfigFileSchema.optional(),
|
|
40
|
+
});
|
|
41
|
+
export const GetAgentConfigResponseSchema = z.object({
|
|
42
|
+
config: AgentConfigFileSchema,
|
|
43
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
44
|
+
});
|
|
45
|
+
export const ExportAgentConfigResponseSchema = z.object({
|
|
46
|
+
yaml: z.string(),
|
|
47
|
+
});
|
|
48
|
+
export const ConfigRevisionSchema = z.object({
|
|
49
|
+
id: z.number(),
|
|
50
|
+
config: z.string(),
|
|
51
|
+
changedByUsername: z.string(),
|
|
52
|
+
createdAt: z.string(),
|
|
53
|
+
});
|
|
54
|
+
export const ConfigRevisionListResponseSchema = z.object({
|
|
55
|
+
items: z.array(ConfigRevisionSchema),
|
|
56
|
+
});
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { AgentConfigFileSchema, HateoasActionSchema, HateoasActionTemplateSchema, HateoasLinkTemplateSchema, URL_SAFE_KEY_MESSAGE, URL_SAFE_KEY_REGEX, } from "@naisys/common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const LinkSchema = z.object({
|
|
4
|
+
rel: z.string(),
|
|
5
|
+
href: z.string(),
|
|
6
|
+
title: z.string().optional(),
|
|
7
|
+
});
|
|
8
|
+
// Zod schemas
|
|
9
|
+
export const AgentSchema = z.object({
|
|
10
|
+
id: z.number(),
|
|
11
|
+
uuid: z.string(),
|
|
12
|
+
name: z.string(),
|
|
13
|
+
title: z.string(),
|
|
14
|
+
host: z.string(),
|
|
15
|
+
lastActive: z.string().optional(),
|
|
16
|
+
leadUsername: z.string().optional(),
|
|
17
|
+
latestLogId: z.number(),
|
|
18
|
+
latestMailId: z.number(),
|
|
19
|
+
enabled: z.boolean().optional(),
|
|
20
|
+
archived: z.boolean().optional(),
|
|
21
|
+
budgetLeft: z.number().nullable().optional(),
|
|
22
|
+
status: z
|
|
23
|
+
.enum(["active", "available", "disabled", "offline", "suspended"])
|
|
24
|
+
.optional(),
|
|
25
|
+
});
|
|
26
|
+
export const HostSchema = z.object({
|
|
27
|
+
id: z.number(),
|
|
28
|
+
name: z.string(),
|
|
29
|
+
lastActive: z.string().nullable(),
|
|
30
|
+
agentCount: z.number(),
|
|
31
|
+
restricted: z.boolean().optional(),
|
|
32
|
+
hostType: z.string().optional(),
|
|
33
|
+
online: z.boolean().optional(),
|
|
34
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
35
|
+
});
|
|
36
|
+
export const HostNameParamsSchema = z.object({
|
|
37
|
+
hostname: z.string(),
|
|
38
|
+
});
|
|
39
|
+
export const AgentListRequestSchema = z.object({
|
|
40
|
+
updatedSince: z.string().optional(),
|
|
41
|
+
});
|
|
42
|
+
export const AgentListResponseSchema = z.object({
|
|
43
|
+
items: z.array(AgentSchema),
|
|
44
|
+
timestamp: z.string(),
|
|
45
|
+
_links: z.array(LinkSchema),
|
|
46
|
+
_linkTemplates: z.array(HateoasLinkTemplateSchema).optional(),
|
|
47
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
48
|
+
});
|
|
49
|
+
export const AgentUsernameParamsSchema = z.object({
|
|
50
|
+
username: z.string(),
|
|
51
|
+
});
|
|
52
|
+
export const AgentDetailResponseSchema = z.object({
|
|
53
|
+
id: z.number(),
|
|
54
|
+
name: z.string(),
|
|
55
|
+
title: z.string(),
|
|
56
|
+
host: z.string(),
|
|
57
|
+
lastActive: z.string().optional(),
|
|
58
|
+
leadUsername: z.string().optional(),
|
|
59
|
+
latestLogId: z.number(),
|
|
60
|
+
latestMailId: z.number(),
|
|
61
|
+
enabled: z.boolean().optional(),
|
|
62
|
+
archived: z.boolean().optional(),
|
|
63
|
+
status: z
|
|
64
|
+
.enum(["active", "available", "disabled", "offline", "suspended"])
|
|
65
|
+
.optional(),
|
|
66
|
+
costSuspendedReason: z.string().optional(),
|
|
67
|
+
currentSpend: z.number().optional(),
|
|
68
|
+
spendLimitResetAt: z.string().optional(),
|
|
69
|
+
config: AgentConfigFileSchema,
|
|
70
|
+
assignedHosts: z
|
|
71
|
+
.array(z.object({ id: z.number(), name: z.string() }))
|
|
72
|
+
.optional(),
|
|
73
|
+
_links: z.array(LinkSchema),
|
|
74
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
75
|
+
});
|
|
76
|
+
export const HostListResponseSchema = z.object({
|
|
77
|
+
items: z.array(HostSchema),
|
|
78
|
+
_links: z.array(LinkSchema),
|
|
79
|
+
_linkTemplates: z.array(HateoasLinkTemplateSchema).optional(),
|
|
80
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
81
|
+
});
|
|
82
|
+
export const SetLeadAgentRequestSchema = z
|
|
83
|
+
.object({
|
|
84
|
+
leadAgentUsername: z.string().nullable(),
|
|
85
|
+
})
|
|
86
|
+
.strict();
|
|
87
|
+
export const AgentActionResultSchema = z.object({
|
|
88
|
+
success: z.boolean(),
|
|
89
|
+
message: z.string(),
|
|
90
|
+
});
|
|
91
|
+
export const AgentStartRequestSchema = z
|
|
92
|
+
.object({
|
|
93
|
+
task: z.string().optional(),
|
|
94
|
+
})
|
|
95
|
+
.strict();
|
|
96
|
+
export const AgentStartResultSchema = z.object({
|
|
97
|
+
success: z.boolean(),
|
|
98
|
+
message: z.string(),
|
|
99
|
+
hostname: z.string().optional(),
|
|
100
|
+
});
|
|
101
|
+
export const AgentToggleRequestSchema = z
|
|
102
|
+
.object({
|
|
103
|
+
recursive: z.boolean().optional(),
|
|
104
|
+
})
|
|
105
|
+
.strict();
|
|
106
|
+
export const AgentStopRequestSchema = z
|
|
107
|
+
.object({
|
|
108
|
+
recursive: z.boolean().optional(),
|
|
109
|
+
})
|
|
110
|
+
.strict();
|
|
111
|
+
export const AgentStopResultSchema = z.object({
|
|
112
|
+
success: z.boolean(),
|
|
113
|
+
message: z.string(),
|
|
114
|
+
});
|
|
115
|
+
// --- Host CRUD schemas ---
|
|
116
|
+
const AssignedAgentSchema = z.object({
|
|
117
|
+
id: z.number(),
|
|
118
|
+
name: z.string(),
|
|
119
|
+
title: z.string(),
|
|
120
|
+
});
|
|
121
|
+
export const HostDetailResponseSchema = z.object({
|
|
122
|
+
id: z.number(),
|
|
123
|
+
name: z.string(),
|
|
124
|
+
lastActive: z.string().nullable(),
|
|
125
|
+
lastIp: z.string().nullable(),
|
|
126
|
+
restricted: z.boolean(),
|
|
127
|
+
hostType: z.string(),
|
|
128
|
+
online: z.boolean(),
|
|
129
|
+
assignedAgents: z.array(AssignedAgentSchema),
|
|
130
|
+
_links: z.array(LinkSchema),
|
|
131
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
132
|
+
_actionTemplates: z.array(HateoasActionTemplateSchema).optional(),
|
|
133
|
+
});
|
|
134
|
+
export const UpdateHostRequestSchema = z
|
|
135
|
+
.object({
|
|
136
|
+
name: z
|
|
137
|
+
.string()
|
|
138
|
+
.min(1)
|
|
139
|
+
.max(64)
|
|
140
|
+
.regex(URL_SAFE_KEY_REGEX, URL_SAFE_KEY_MESSAGE)
|
|
141
|
+
.optional(),
|
|
142
|
+
restricted: z.boolean().optional(),
|
|
143
|
+
})
|
|
144
|
+
.strict();
|
|
145
|
+
export const CreateHostRequestSchema = z
|
|
146
|
+
.object({
|
|
147
|
+
name: z
|
|
148
|
+
.string()
|
|
149
|
+
.min(1)
|
|
150
|
+
.max(64)
|
|
151
|
+
.regex(URL_SAFE_KEY_REGEX, URL_SAFE_KEY_MESSAGE),
|
|
152
|
+
})
|
|
153
|
+
.strict();
|
|
154
|
+
export const AssignAgentToHostRequestSchema = z
|
|
155
|
+
.object({
|
|
156
|
+
agentId: z.number().int(),
|
|
157
|
+
})
|
|
158
|
+
.strict();
|
|
159
|
+
export const AgentNameParamSchema = z.object({
|
|
160
|
+
agentName: z.string(),
|
|
161
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const LoginRequestSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
username: z.string().min(1),
|
|
5
|
+
password: z.string().min(1),
|
|
6
|
+
})
|
|
7
|
+
.strict();
|
|
8
|
+
export const AuthUserSchema = z.object({
|
|
9
|
+
id: z.number(),
|
|
10
|
+
username: z.string(),
|
|
11
|
+
permissions: z.array(z.string()),
|
|
12
|
+
});
|
|
13
|
+
export const LoginResponseSchema = z.object({
|
|
14
|
+
user: AuthUserSchema,
|
|
15
|
+
});
|
|
16
|
+
export const LogoutResponseSchema = z.object({
|
|
17
|
+
success: z.boolean(),
|
|
18
|
+
message: z.string(),
|
|
19
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { HateoasActionSchema } from "@naisys/common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const ChatConversationSchema = z.object({
|
|
4
|
+
participants: z.string(),
|
|
5
|
+
participantNames: z.array(z.string()),
|
|
6
|
+
participantTitles: z.array(z.string()),
|
|
7
|
+
lastMessage: z.string(),
|
|
8
|
+
lastMessageAt: z.string(),
|
|
9
|
+
lastMessageFrom: z.string(),
|
|
10
|
+
isArchived: z.boolean().optional(),
|
|
11
|
+
});
|
|
12
|
+
export const ChatAttachmentSchema = z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
filename: z.string(),
|
|
15
|
+
fileSize: z.number(),
|
|
16
|
+
});
|
|
17
|
+
export const ChatMessageSchema = z.object({
|
|
18
|
+
id: z.number(),
|
|
19
|
+
fromUserId: z.number(),
|
|
20
|
+
fromUsername: z.string(),
|
|
21
|
+
fromTitle: z.string(),
|
|
22
|
+
body: z.string(),
|
|
23
|
+
createdAt: z.string(),
|
|
24
|
+
attachments: z.array(ChatAttachmentSchema).optional(),
|
|
25
|
+
readBy: z.array(z.number()).optional(), // user IDs who have read
|
|
26
|
+
});
|
|
27
|
+
export const ChatConversationsRequestSchema = z.object({
|
|
28
|
+
page: z.coerce.number().optional().default(1),
|
|
29
|
+
count: z.coerce.number().optional().default(50),
|
|
30
|
+
});
|
|
31
|
+
export const ChatConversationsResponseSchema = z.object({
|
|
32
|
+
success: z.boolean(),
|
|
33
|
+
conversations: z.array(ChatConversationSchema),
|
|
34
|
+
total: z.number().optional(),
|
|
35
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
36
|
+
});
|
|
37
|
+
export const ChatMessagesRequestSchema = z.object({
|
|
38
|
+
updatedSince: z.string().optional(),
|
|
39
|
+
page: z.coerce.number().optional().default(1),
|
|
40
|
+
count: z.coerce.number().optional().default(50),
|
|
41
|
+
});
|
|
42
|
+
export const ChatMessagesResponseSchema = z.object({
|
|
43
|
+
success: z.boolean(),
|
|
44
|
+
messages: z.array(ChatMessageSchema),
|
|
45
|
+
total: z.number().optional(),
|
|
46
|
+
timestamp: z.string(),
|
|
47
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
48
|
+
});
|
|
49
|
+
export const SendChatRequestSchema = z
|
|
50
|
+
.object({
|
|
51
|
+
fromId: z.number(),
|
|
52
|
+
toIds: z.array(z.number()),
|
|
53
|
+
message: z.string(),
|
|
54
|
+
})
|
|
55
|
+
.strict();
|
|
56
|
+
export const SendChatResponseSchema = z.object({
|
|
57
|
+
success: z.boolean(),
|
|
58
|
+
message: z.string().optional(),
|
|
59
|
+
});
|
|
60
|
+
export const ArchiveChatResponseSchema = z.object({
|
|
61
|
+
success: z.boolean(),
|
|
62
|
+
archivedCount: z.number().optional(),
|
|
63
|
+
message: z.string().optional(),
|
|
64
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const CostsHistogramRequestSchema = z.object({
|
|
3
|
+
start: z.string().optional(),
|
|
4
|
+
end: z.string().optional(),
|
|
5
|
+
bucketHours: z.coerce.number().optional(),
|
|
6
|
+
leadUsername: z.string().optional(),
|
|
7
|
+
});
|
|
8
|
+
export const CostBucketSchema = z.object({
|
|
9
|
+
start: z.string(),
|
|
10
|
+
end: z.string(),
|
|
11
|
+
cost: z.number(),
|
|
12
|
+
byAgent: z.record(z.string(), z.number()),
|
|
13
|
+
});
|
|
14
|
+
export const CostByAgentSchema = z.object({
|
|
15
|
+
username: z.string(),
|
|
16
|
+
title: z.string(),
|
|
17
|
+
cost: z.number(),
|
|
18
|
+
});
|
|
19
|
+
export const CostsHistogramResponseSchema = z.object({
|
|
20
|
+
spendLimitDollars: z.number().nullable(),
|
|
21
|
+
spendLimitHours: z.number().nullable(),
|
|
22
|
+
buckets: z.array(CostBucketSchema),
|
|
23
|
+
byAgent: z.array(CostByAgentSchema),
|
|
24
|
+
});
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./admin-types.js";
|
|
2
|
+
export * from "./agent-config-types.js";
|
|
3
|
+
export * from "./agents-types.js";
|
|
4
|
+
export * from "./api-types.js";
|
|
5
|
+
export * from "./auth-types.js";
|
|
6
|
+
export * from "./chat-types.js";
|
|
7
|
+
export * from "./costs-types.js";
|
|
8
|
+
export * from "./error-types.js";
|
|
9
|
+
export * from "./log-types.js";
|
|
10
|
+
export * from "./mail-types.js";
|
|
11
|
+
export * from "./models-types.js";
|
|
12
|
+
export * from "./runs-types.js";
|
|
13
|
+
export * from "./status-types.js";
|
|
14
|
+
export * from "./user-types.js";
|
|
15
|
+
export * from "./variables-types.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Zod schemas
|
|
3
|
+
export const LogSourceSchema = z.enum([
|
|
4
|
+
"startPrompt",
|
|
5
|
+
"endPrompt",
|
|
6
|
+
"console",
|
|
7
|
+
"llm",
|
|
8
|
+
]);
|
|
9
|
+
export const LogTypeSchema = z.enum(["comment", "error", "system", "tool"]);
|
|
10
|
+
export const LogRoleSchema = z.enum(["NAISYS", "LLM"]);
|
|
11
|
+
export const LogAttachmentSchema = z.object({
|
|
12
|
+
id: z.string(),
|
|
13
|
+
filename: z.string(),
|
|
14
|
+
fileSize: z.number(),
|
|
15
|
+
});
|
|
16
|
+
export const LogEntrySchema = z.object({
|
|
17
|
+
id: z.number(),
|
|
18
|
+
username: z.string(),
|
|
19
|
+
role: LogRoleSchema,
|
|
20
|
+
source: LogSourceSchema.nullable(),
|
|
21
|
+
type: LogTypeSchema.nullable(),
|
|
22
|
+
message: z.string(),
|
|
23
|
+
createdAt: z.string(),
|
|
24
|
+
attachment: LogAttachmentSchema.optional(),
|
|
25
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { HateoasActionSchema, HateoasLinkSchema } from "@naisys/common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
// Zod schemas for the new flat message model
|
|
4
|
+
export const RecipientTypeEnum = z.enum(["to", "cc", "bcc", "from"]);
|
|
5
|
+
export const MailRecipientSchema = z.object({
|
|
6
|
+
userId: z.number(),
|
|
7
|
+
username: z.string(),
|
|
8
|
+
title: z.string(),
|
|
9
|
+
type: RecipientTypeEnum,
|
|
10
|
+
readAt: z.string().nullable(), // ISO date or null
|
|
11
|
+
archivedAt: z.string().nullable().optional(), // ISO date or null
|
|
12
|
+
});
|
|
13
|
+
export const MailAttachmentSchema = z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
filename: z.string(),
|
|
16
|
+
fileSize: z.number(),
|
|
17
|
+
});
|
|
18
|
+
export const MailMessageSchema = z.object({
|
|
19
|
+
id: z.number(),
|
|
20
|
+
fromUserId: z.number(),
|
|
21
|
+
fromUsername: z.string(),
|
|
22
|
+
fromTitle: z.string(),
|
|
23
|
+
subject: z.string(),
|
|
24
|
+
body: z.string(),
|
|
25
|
+
createdAt: z.string(),
|
|
26
|
+
recipients: z.array(MailRecipientSchema),
|
|
27
|
+
attachments: z.array(MailAttachmentSchema).optional(),
|
|
28
|
+
});
|
|
29
|
+
export const SendMailRequestSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
fromId: z.number(),
|
|
32
|
+
toIds: z.array(z.number()),
|
|
33
|
+
subject: z.string(),
|
|
34
|
+
message: z.string(),
|
|
35
|
+
})
|
|
36
|
+
.strict();
|
|
37
|
+
export const SendMailResponseSchema = z.object({
|
|
38
|
+
success: z.boolean(),
|
|
39
|
+
message: z.string().optional(),
|
|
40
|
+
messageId: z.number().optional(),
|
|
41
|
+
});
|
|
42
|
+
export const MailDataRequestSchema = z.object({
|
|
43
|
+
updatedSince: z.string().optional(),
|
|
44
|
+
page: z.coerce.number().optional().default(1),
|
|
45
|
+
count: z.coerce.number().optional().default(50),
|
|
46
|
+
});
|
|
47
|
+
export const MailDataResponseSchema = z.object({
|
|
48
|
+
success: z.boolean(),
|
|
49
|
+
message: z.string(),
|
|
50
|
+
data: z
|
|
51
|
+
.object({
|
|
52
|
+
mail: z.array(MailMessageSchema),
|
|
53
|
+
timestamp: z.string(),
|
|
54
|
+
total: z.number().optional(),
|
|
55
|
+
})
|
|
56
|
+
.optional(),
|
|
57
|
+
_links: z.array(HateoasLinkSchema).optional(),
|
|
58
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
59
|
+
});
|
|
60
|
+
export const ArchiveMailResponseSchema = z.object({
|
|
61
|
+
success: z.boolean(),
|
|
62
|
+
archivedCount: z.number().optional(),
|
|
63
|
+
message: z.string().optional(),
|
|
64
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { HateoasActionSchema } from "@naisys/common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const ModelOptionSchema = z.object({
|
|
4
|
+
value: z.string(),
|
|
5
|
+
label: z.string(),
|
|
6
|
+
});
|
|
7
|
+
export const LlmModelDetailSchema = z.object({
|
|
8
|
+
key: z.string(),
|
|
9
|
+
label: z.string(),
|
|
10
|
+
versionName: z.string(),
|
|
11
|
+
apiType: z.string(),
|
|
12
|
+
maxTokens: z.number(),
|
|
13
|
+
baseUrl: z.string().optional(),
|
|
14
|
+
apiKeyVar: z.string(),
|
|
15
|
+
inputCost: z.number(),
|
|
16
|
+
outputCost: z.number(),
|
|
17
|
+
cacheWriteCost: z.number().optional(),
|
|
18
|
+
cacheReadCost: z.number().optional(),
|
|
19
|
+
cacheTtlSeconds: z.number().int().positive().optional(),
|
|
20
|
+
supportsVision: z.boolean().optional(),
|
|
21
|
+
supportsHearing: z.boolean().optional(),
|
|
22
|
+
isCustom: z.boolean(),
|
|
23
|
+
});
|
|
24
|
+
export const ImageModelDetailSchema = z.object({
|
|
25
|
+
key: z.string(),
|
|
26
|
+
label: z.string(),
|
|
27
|
+
versionName: z.string(),
|
|
28
|
+
size: z.string(),
|
|
29
|
+
baseUrl: z.string().optional(),
|
|
30
|
+
apiKeyVar: z.string(),
|
|
31
|
+
cost: z.number(),
|
|
32
|
+
quality: z.string().optional(),
|
|
33
|
+
isCustom: z.boolean(),
|
|
34
|
+
});
|
|
35
|
+
export const ModelsResponseSchema = z.object({
|
|
36
|
+
llmModels: z.array(ModelOptionSchema),
|
|
37
|
+
imageModels: z.array(ModelOptionSchema),
|
|
38
|
+
llmModelDetails: z.array(LlmModelDetailSchema),
|
|
39
|
+
imageModelDetails: z.array(ImageModelDetailSchema),
|
|
40
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
41
|
+
});
|
|
42
|
+
// --- Save / Delete schemas ---
|
|
43
|
+
export const SaveLlmModelRequestSchema = z.object({
|
|
44
|
+
model: z.object({
|
|
45
|
+
key: z.string().min(1),
|
|
46
|
+
label: z.string().min(1),
|
|
47
|
+
versionName: z.string().min(1),
|
|
48
|
+
apiType: z.string().min(1),
|
|
49
|
+
maxTokens: z.number().int().positive(),
|
|
50
|
+
baseUrl: z.string().optional(),
|
|
51
|
+
apiKeyVar: z.string(),
|
|
52
|
+
inputCost: z.number().default(0),
|
|
53
|
+
outputCost: z.number().default(0),
|
|
54
|
+
cacheWriteCost: z.number().optional(),
|
|
55
|
+
cacheReadCost: z.number().optional(),
|
|
56
|
+
cacheTtlSeconds: z.number().int().positive().optional(),
|
|
57
|
+
supportsVision: z.boolean().optional(),
|
|
58
|
+
supportsHearing: z.boolean().optional(),
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
export const SaveImageModelRequestSchema = z.object({
|
|
62
|
+
model: z.object({
|
|
63
|
+
key: z.string().min(1),
|
|
64
|
+
label: z.string().min(1),
|
|
65
|
+
versionName: z.string().min(1),
|
|
66
|
+
size: z.string().min(1),
|
|
67
|
+
baseUrl: z.string().optional(),
|
|
68
|
+
apiKeyVar: z.string(),
|
|
69
|
+
cost: z.number(),
|
|
70
|
+
quality: z.string().optional(),
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
export const SaveModelResponseSchema = z.object({
|
|
74
|
+
success: z.boolean(),
|
|
75
|
+
message: z.string(),
|
|
76
|
+
});
|
|
77
|
+
export const ModelTypeEnum = z.enum(["llm", "image"]);
|
|
78
|
+
export const DeleteModelParamsSchema = z.object({
|
|
79
|
+
type: ModelTypeEnum,
|
|
80
|
+
key: z.string(),
|
|
81
|
+
});
|
|
82
|
+
export const DeleteModelResponseSchema = z.object({
|
|
83
|
+
success: z.boolean(),
|
|
84
|
+
message: z.string(),
|
|
85
|
+
revertedToBuiltIn: z.boolean().optional(),
|
|
86
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { HateoasLinkSchema, HateoasLinkTemplateSchema } from "@naisys/common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { LogEntrySchema } from "./log-types.js";
|
|
4
|
+
// Zod schemas
|
|
5
|
+
export const RunSessionSchema = z.object({
|
|
6
|
+
userId: z.number(),
|
|
7
|
+
runId: z.number(),
|
|
8
|
+
sessionId: z.number(),
|
|
9
|
+
createdAt: z.string(),
|
|
10
|
+
lastActive: z.string(),
|
|
11
|
+
modelName: z.string(),
|
|
12
|
+
latestLogId: z.number(),
|
|
13
|
+
totalLines: z.number(),
|
|
14
|
+
totalCost: z.number(),
|
|
15
|
+
});
|
|
16
|
+
export const RunsDataRequestSchema = z.object({
|
|
17
|
+
updatedSince: z.string().optional(),
|
|
18
|
+
page: z.coerce.number().optional().default(1),
|
|
19
|
+
count: z.coerce.number().optional().default(50),
|
|
20
|
+
});
|
|
21
|
+
export const RunsDataResponseSchema = z.object({
|
|
22
|
+
success: z.boolean(),
|
|
23
|
+
message: z.string(),
|
|
24
|
+
data: z
|
|
25
|
+
.object({
|
|
26
|
+
runs: z.array(RunSessionSchema),
|
|
27
|
+
timestamp: z.string(),
|
|
28
|
+
total: z.number().optional(),
|
|
29
|
+
})
|
|
30
|
+
.optional(),
|
|
31
|
+
_links: z.array(HateoasLinkSchema).optional(),
|
|
32
|
+
_linkTemplates: z.array(HateoasLinkTemplateSchema).optional(),
|
|
33
|
+
});
|
|
34
|
+
export const ContextLogParamsSchema = z.object({
|
|
35
|
+
username: z.string(),
|
|
36
|
+
runId: z.coerce.number(),
|
|
37
|
+
sessionId: z.coerce.number(),
|
|
38
|
+
});
|
|
39
|
+
export const ContextLogRequestSchema = z.object({
|
|
40
|
+
logsAfter: z.coerce.number().optional(),
|
|
41
|
+
logsBefore: z.coerce.number().optional(),
|
|
42
|
+
});
|
|
43
|
+
export const ContextLogResponseSchema = z.object({
|
|
44
|
+
success: z.boolean(),
|
|
45
|
+
message: z.string(),
|
|
46
|
+
data: z
|
|
47
|
+
.object({
|
|
48
|
+
logs: z.array(LogEntrySchema),
|
|
49
|
+
timestamp: z.string(),
|
|
50
|
+
})
|
|
51
|
+
.optional(),
|
|
52
|
+
_links: z.array(HateoasLinkSchema).optional(),
|
|
53
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const StatusResponseSchema = z.object({
|
|
3
|
+
hubConnected: z.boolean(),
|
|
4
|
+
});
|
|
5
|
+
export const AgentStatusEventSchema = z.object({
|
|
6
|
+
agents: z.record(z.string(), z.object({
|
|
7
|
+
status: z.enum([
|
|
8
|
+
"active",
|
|
9
|
+
"available",
|
|
10
|
+
"disabled",
|
|
11
|
+
"offline",
|
|
12
|
+
"suspended",
|
|
13
|
+
]),
|
|
14
|
+
latestLogId: z.number(),
|
|
15
|
+
latestMailId: z.number(),
|
|
16
|
+
})),
|
|
17
|
+
agentsListChanged: z.boolean().optional(),
|
|
18
|
+
});
|
|
19
|
+
export const HostStatusEventSchema = z.object({
|
|
20
|
+
hosts: z.record(z.string(), z.object({
|
|
21
|
+
online: z.boolean(),
|
|
22
|
+
})),
|
|
23
|
+
hostsListChanged: z.boolean().optional(),
|
|
24
|
+
});
|
|
25
|
+
export const HubStatusEventSchema = z.object({
|
|
26
|
+
hubConnected: z.boolean(),
|
|
27
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { URL_SAFE_KEY_MESSAGE, URL_SAFE_KEY_REGEX } from "@naisys/common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const PermissionEnum = z.enum([
|
|
4
|
+
"supervisor_admin",
|
|
5
|
+
"manage_agents",
|
|
6
|
+
"manage_hosts",
|
|
7
|
+
"agent_communication",
|
|
8
|
+
"manage_models",
|
|
9
|
+
"manage_variables",
|
|
10
|
+
"view_run_logs",
|
|
11
|
+
]);
|
|
12
|
+
const urlSafeUsername = z
|
|
13
|
+
.string()
|
|
14
|
+
.min(1)
|
|
15
|
+
.max(64)
|
|
16
|
+
.regex(URL_SAFE_KEY_REGEX, URL_SAFE_KEY_MESSAGE);
|
|
17
|
+
export const CreateUserSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
username: urlSafeUsername,
|
|
20
|
+
password: z.string().min(6),
|
|
21
|
+
})
|
|
22
|
+
.strict();
|
|
23
|
+
export const UpdateUserSchema = z
|
|
24
|
+
.object({
|
|
25
|
+
username: urlSafeUsername.optional(),
|
|
26
|
+
password: z.string().min(6).optional(),
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
export const GrantPermissionSchema = z
|
|
30
|
+
.object({
|
|
31
|
+
permission: PermissionEnum,
|
|
32
|
+
})
|
|
33
|
+
.strict();
|
|
34
|
+
export const ChangePasswordSchema = z
|
|
35
|
+
.object({
|
|
36
|
+
password: z.string().min(6),
|
|
37
|
+
})
|
|
38
|
+
.strict();
|
|
39
|
+
export const CreateAgentUserSchema = z
|
|
40
|
+
.object({
|
|
41
|
+
agentId: z.number().int(),
|
|
42
|
+
})
|
|
43
|
+
.strict();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { HateoasActionSchema } from "@naisys/common";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const VariableSchema = z.object({
|
|
4
|
+
key: z.string(),
|
|
5
|
+
value: z.string(),
|
|
6
|
+
exportToShell: z.boolean(),
|
|
7
|
+
});
|
|
8
|
+
export const VariablesResponseSchema = z.object({
|
|
9
|
+
items: z.array(VariableSchema),
|
|
10
|
+
_actions: z.array(HateoasActionSchema).optional(),
|
|
11
|
+
});
|
|
12
|
+
export const SaveVariableRequestSchema = z.object({
|
|
13
|
+
value: z.string(),
|
|
14
|
+
exportToShell: z.boolean(),
|
|
15
|
+
});
|
|
16
|
+
export const SaveVariableResponseSchema = z.object({
|
|
17
|
+
success: z.boolean(),
|
|
18
|
+
message: z.string(),
|
|
19
|
+
});
|
|
20
|
+
export const DeleteVariableParamsSchema = z.object({
|
|
21
|
+
key: z.string(),
|
|
22
|
+
});
|
|
23
|
+
export const DeleteVariableResponseSchema = z.object({
|
|
24
|
+
success: z.boolean(),
|
|
25
|
+
message: z.string(),
|
|
26
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@naisys/supervisor-shared",
|
|
3
|
+
"version": "3.0.0-beta.10",
|
|
4
|
+
"description": "[internal] NAISYS Supervisor shared types and validation schemas",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"!dist/**/*.map",
|
|
9
|
+
"!dist/**/*.d.ts",
|
|
10
|
+
"!dist/**/*.d.ts.map"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"clean": "rimraf dist",
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"type-check": "tsc --noEmit",
|
|
16
|
+
"npm:publish:dryrun": "npm publish --dry-run",
|
|
17
|
+
"npm:publish": "npm publish --access public"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.9.3"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@naisys/common": "3.0.0-beta.10",
|
|
24
|
+
"zod": "^4.3.6"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|