@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,125 @@
1
+ /**
2
+ * Typed event map for hub protocol events.
3
+ *
4
+ * Maps each event name to its payload types so that registerEvent, sendMessage,
5
+ * and sendRequest can enforce correct signatures at compile time.
6
+ */
7
+ import type { HubEvents } from "./events.js";
8
+ import type { RotateAccessKeyRequest, RotateAccessKeyResponse } from "./schemas/admin.js";
9
+ import type { AgentPeekRequest, AgentPeekResponse, AgentStartRequest, AgentStartResponse, AgentStopRequest, AgentStopResponse } from "./schemas/agents.js";
10
+ import type { ConfigResponse } from "./schemas/config.js";
11
+ import type { CostControl, CostPush, CostWriteRequest, CostWriteResponse } from "./schemas/costs.js";
12
+ import type { AgentsStatus, Heartbeat } from "./schemas/heartbeat.js";
13
+ import type { HostList } from "./schemas/hosts.js";
14
+ import type { LogPush, LogWriteRequest } from "./schemas/logs.js";
15
+ import type { MailArchiveRequest, MailArchiveResponse, MailListRequest, MailListResponse, MailMarkReadRequest, MailMarkReadResponse, MailPeekRequest, MailPeekResponse, MailPush, MailReadPush, MailReceivedPush, MailSearchRequest, MailSearchResponse, MailSendRequest, MailSendResponse, MailUnreadRequest, MailUnreadResponse } from "./schemas/mail.js";
16
+ import type { ModelsResponse } from "./schemas/models.js";
17
+ import type { SessionCreateRequest, SessionCreateResponse, SessionIncrementRequest, SessionIncrementResponse, SessionPush } from "./schemas/sessions.js";
18
+ import type { UserListResponse } from "./schemas/users.js";
19
+ /** Events that follow a request → response pattern via Socket.IO ack */
20
+ export interface HubRequestEvents {
21
+ [HubEvents.AGENT_START]: {
22
+ request: AgentStartRequest;
23
+ response: AgentStartResponse;
24
+ };
25
+ [HubEvents.AGENT_STOP]: {
26
+ request: AgentStopRequest;
27
+ response: AgentStopResponse;
28
+ };
29
+ [HubEvents.AGENT_PEEK]: {
30
+ request: AgentPeekRequest;
31
+ response: AgentPeekResponse;
32
+ };
33
+ [HubEvents.SESSION_CREATE]: {
34
+ request: SessionCreateRequest;
35
+ response: SessionCreateResponse;
36
+ };
37
+ [HubEvents.SESSION_INCREMENT]: {
38
+ request: SessionIncrementRequest;
39
+ response: SessionIncrementResponse;
40
+ };
41
+ [HubEvents.MAIL_SEND]: {
42
+ request: MailSendRequest;
43
+ response: MailSendResponse;
44
+ };
45
+ [HubEvents.MAIL_LIST]: {
46
+ request: MailListRequest;
47
+ response: MailListResponse;
48
+ };
49
+ [HubEvents.MAIL_PEEK]: {
50
+ request: MailPeekRequest;
51
+ response: MailPeekResponse;
52
+ };
53
+ [HubEvents.MAIL_MARK_READ]: {
54
+ request: MailMarkReadRequest;
55
+ response: MailMarkReadResponse;
56
+ };
57
+ [HubEvents.MAIL_ARCHIVE]: {
58
+ request: MailArchiveRequest;
59
+ response: MailArchiveResponse;
60
+ };
61
+ [HubEvents.MAIL_SEARCH]: {
62
+ request: MailSearchRequest;
63
+ response: MailSearchResponse;
64
+ };
65
+ [HubEvents.MAIL_UNREAD]: {
66
+ request: MailUnreadRequest;
67
+ response: MailUnreadResponse;
68
+ };
69
+ [HubEvents.ROTATE_ACCESS_KEY]: {
70
+ request: RotateAccessKeyRequest;
71
+ response: RotateAccessKeyResponse;
72
+ };
73
+ [HubEvents.COST_WRITE]: {
74
+ request: CostWriteRequest;
75
+ response: CostWriteResponse;
76
+ };
77
+ }
78
+ /** Events sent from NAISYS to Hub with no response expected */
79
+ export interface HubFireAndForgetEvents {
80
+ [HubEvents.HEARTBEAT]: Heartbeat;
81
+ [HubEvents.LOG_WRITE]: LogWriteRequest;
82
+ }
83
+ /** Events pushed from Hub to NAISYS clients */
84
+ export interface HubPushEvents {
85
+ [HubEvents.USERS_UPDATED]: UserListResponse;
86
+ [HubEvents.HOSTS_UPDATED]: HostList;
87
+ [HubEvents.VARIABLES_UPDATED]: ConfigResponse;
88
+ [HubEvents.MODELS_UPDATED]: ModelsResponse;
89
+ [HubEvents.AGENTS_STATUS]: AgentsStatus;
90
+ [HubEvents.COST_CONTROL]: CostControl;
91
+ [HubEvents.MAIL_RECEIVED]: MailReceivedPush;
92
+ }
93
+ /** Events pushed from Hub to Supervisor connections only */
94
+ export interface HubSupervisorPushEvents {
95
+ [HubEvents.LOG_PUSH]: LogPush;
96
+ [HubEvents.MAIL_PUSH]: MailPush;
97
+ [HubEvents.MAIL_READ_PUSH]: MailReadPush;
98
+ [HubEvents.COST_PUSH]: CostPush;
99
+ [HubEvents.SESSION_PUSH]: SessionPush;
100
+ }
101
+ /** Events from Supervisor that trigger hub-side refresh + broadcast */
102
+ export interface HubTriggerEvents {
103
+ [HubEvents.USERS_CHANGED]: void;
104
+ [HubEvents.VARIABLES_CHANGED]: void;
105
+ [HubEvents.MODELS_CHANGED]: void;
106
+ [HubEvents.HOSTS_CHANGED]: void;
107
+ }
108
+ export type HubRequestEventName = keyof HubRequestEvents;
109
+ export type HubFireAndForgetEventName = keyof HubFireAndForgetEvents;
110
+ export type HubPushEventName = keyof HubPushEvents;
111
+ export type HubSupervisorPushEventName = keyof HubSupervisorPushEvents;
112
+ export type HubTriggerEventName = keyof HubTriggerEvents;
113
+ /** Events the supervisor listens for (hub → supervisor push events) */
114
+ export type SupervisorListenEvents = {
115
+ [E in HubPushEventName]: (data: HubPushEvents[E]) => void;
116
+ } & {
117
+ [E in HubSupervisorPushEventName]: (data: HubSupervisorPushEvents[E]) => void;
118
+ };
119
+ /** Events the supervisor emits (supervisor → hub) */
120
+ export type SupervisorEmitEvents = {
121
+ [E in HubRequestEventName]: (data: HubRequestEvents[E]["request"], ack: (response: HubRequestEvents[E]["response"]) => void) => void;
122
+ } & {
123
+ [E in HubTriggerEventName]: () => void;
124
+ };
125
+ //# sourceMappingURL=eventMap.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Typed event map for hub protocol events.
3
+ *
4
+ * Maps each event name to its payload types so that registerEvent, sendMessage,
5
+ * and sendRequest can enforce correct signatures at compile time.
6
+ */
7
+ export {};
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Hub Protocol Event Names
3
+ *
4
+ * Participants:
5
+ * NAISYS – AI agent host instances (Socket.IO clients)
6
+ * Hub – Central coordination server (Socket.IO server)
7
+ * Supervisor – Web admin backend (Socket.IO client, hostType: "supervisor")
8
+ */
9
+ export declare const HubEvents: {
10
+ /** Raised inside the hub when a Socket.IO client connects */
11
+ readonly CLIENT_CONNECTED: "client_connected";
12
+ /** Raised inside the hub when a Socket.IO client disconnects */
13
+ readonly CLIENT_DISCONNECTED: "client_disconnected";
14
+ /** Full user list, pushed on connect and when users change */
15
+ readonly USERS_UPDATED: "users_updated";
16
+ /** Connected host topology, pushed on connect and on host changes */
17
+ readonly HOSTS_UPDATED: "hosts_updated";
18
+ /** Global config (shell limits, variables, spend limits), pushed on connect and on variable changes */
19
+ readonly VARIABLES_UPDATED: "variables_updated";
20
+ /** LLM and image model definitions, pushed on connect and on model changes */
21
+ readonly MODELS_UPDATED: "models_updated";
22
+ /** Aggregate active-agent map and notification counters, pushed periodically and on agent changes */
23
+ readonly AGENTS_STATUS: "agents_status";
24
+ /** Full-data log push with entries and session deltas */
25
+ readonly LOG_PUSH: "log_push";
26
+ /** Full-data mail/chat push with message data */
27
+ readonly MAIL_PUSH: "mail_push";
28
+ /** Read-receipt push when messages are marked read */
29
+ readonly MAIL_READ_PUSH: "mail_read_push";
30
+ /** Cost delta push per session */
31
+ readonly COST_PUSH: "cost_push";
32
+ /** New session push with full RunSession data */
33
+ readonly SESSION_PUSH: "session_push";
34
+ /** Spending limit enforcement, pushed to the host running the affected agent */
35
+ readonly COST_CONTROL: "cost_control";
36
+ /** New mail notification, pushed to hosts running recipient agents */
37
+ readonly MAIL_RECEIVED: "mail_received";
38
+ /** Periodic heartbeat with active agent user IDs */
39
+ readonly HEARTBEAT: "heartbeat";
40
+ /** Batched log entries */
41
+ readonly LOG_WRITE: "log_write";
42
+ /** Batched cost/token entries */
43
+ readonly COST_WRITE: "cost_write";
44
+ /** Create a new run session */
45
+ readonly SESSION_CREATE: "session_create";
46
+ /** Increment session within an existing run */
47
+ readonly SESSION_INCREMENT: "session_increment";
48
+ /** Start an agent on its assigned host */
49
+ readonly AGENT_START: "agent_start";
50
+ /** Stop an agent on its current host */
51
+ readonly AGENT_STOP: "agent_stop";
52
+ /** Peek at an agent's output buffer */
53
+ readonly AGENT_PEEK: "agent_peek";
54
+ /** Rotate the hub access key */
55
+ readonly ROTATE_ACCESS_KEY: "rotate_access_key";
56
+ /** Send a mail message */
57
+ readonly MAIL_SEND: "mail_send";
58
+ /** List recent mail messages */
59
+ readonly MAIL_LIST: "mail_list";
60
+ /** Fetch a specific mail message (does not mark as read) */
61
+ readonly MAIL_PEEK: "mail_peek";
62
+ /** Mark messages as read */
63
+ readonly MAIL_MARK_READ: "mail_mark_read";
64
+ /** Archive mail messages */
65
+ readonly MAIL_ARCHIVE: "mail_archive";
66
+ /** Full-text search of mail */
67
+ readonly MAIL_SEARCH: "mail_search";
68
+ /** Get unread messages with full data */
69
+ readonly MAIL_UNREAD: "mail_unread";
70
+ /** Users changed — hub re-queries DB and broadcasts USERS_UPDATED */
71
+ readonly USERS_CHANGED: "users_changed";
72
+ /** Variables changed — hub rebuilds config and broadcasts VARIABLES_UPDATED */
73
+ readonly VARIABLES_CHANGED: "variables_changed";
74
+ /** Models changed — hub re-reads models and broadcasts MODELS_UPDATED */
75
+ readonly MODELS_CHANGED: "models_changed";
76
+ /** Hosts changed — hub refreshes host cache and broadcasts HOSTS_UPDATED */
77
+ readonly HOSTS_CHANGED: "hosts_changed";
78
+ };
79
+ export type HubEventName = (typeof HubEvents)[keyof typeof HubEvents];
80
+ //# sourceMappingURL=events.d.ts.map
package/dist/events.js ADDED
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Hub Protocol Event Names
3
+ *
4
+ * Participants:
5
+ * NAISYS – AI agent host instances (Socket.IO clients)
6
+ * Hub – Central coordination server (Socket.IO server)
7
+ * Supervisor – Web admin backend (Socket.IO client, hostType: "supervisor")
8
+ */
9
+ export const HubEvents = {
10
+ // ---------------------------------------------------------------------------
11
+ // Internal hub events (not sent over the wire)
12
+ // ---------------------------------------------------------------------------
13
+ /** Raised inside the hub when a Socket.IO client connects */
14
+ CLIENT_CONNECTED: "client_connected",
15
+ /** Raised inside the hub when a Socket.IO client disconnects */
16
+ CLIENT_DISCONNECTED: "client_disconnected",
17
+ // ---------------------------------------------------------------------------
18
+ // Hub -> NAISYS push (broadcast to all connected clients)
19
+ // ---------------------------------------------------------------------------
20
+ /** Full user list, pushed on connect and when users change */
21
+ USERS_UPDATED: "users_updated",
22
+ /** Connected host topology, pushed on connect and on host changes */
23
+ HOSTS_UPDATED: "hosts_updated",
24
+ /** Global config (shell limits, variables, spend limits), pushed on connect and on variable changes */
25
+ VARIABLES_UPDATED: "variables_updated",
26
+ /** LLM and image model definitions, pushed on connect and on model changes */
27
+ MODELS_UPDATED: "models_updated",
28
+ /** Aggregate active-agent map and notification counters, pushed periodically and on agent changes */
29
+ AGENTS_STATUS: "agents_status",
30
+ // ---------------------------------------------------------------------------
31
+ // Hub -> Supervisor push (targeted to supervisor connections only)
32
+ // ---------------------------------------------------------------------------
33
+ /** Full-data log push with entries and session deltas */
34
+ LOG_PUSH: "log_push",
35
+ /** Full-data mail/chat push with message data */
36
+ MAIL_PUSH: "mail_push",
37
+ /** Read-receipt push when messages are marked read */
38
+ MAIL_READ_PUSH: "mail_read_push",
39
+ /** Cost delta push per session */
40
+ COST_PUSH: "cost_push",
41
+ /** New session push with full RunSession data */
42
+ SESSION_PUSH: "session_push",
43
+ // ---------------------------------------------------------------------------
44
+ // Hub -> NAISYS push (targeted to specific host)
45
+ // ---------------------------------------------------------------------------
46
+ /** Spending limit enforcement, pushed to the host running the affected agent */
47
+ COST_CONTROL: "cost_control",
48
+ /** New mail notification, pushed to hosts running recipient agents */
49
+ MAIL_RECEIVED: "mail_received",
50
+ // ---------------------------------------------------------------------------
51
+ // NAISYS -> Hub (fire-and-forget)
52
+ // ---------------------------------------------------------------------------
53
+ /** Periodic heartbeat with active agent user IDs */
54
+ HEARTBEAT: "heartbeat",
55
+ /** Batched log entries */
56
+ LOG_WRITE: "log_write",
57
+ /** Batched cost/token entries */
58
+ COST_WRITE: "cost_write",
59
+ // ---------------------------------------------------------------------------
60
+ // NAISYS -> Hub (request/response)
61
+ // ---------------------------------------------------------------------------
62
+ /** Create a new run session */
63
+ SESSION_CREATE: "session_create",
64
+ /** Increment session within an existing run */
65
+ SESSION_INCREMENT: "session_increment",
66
+ // ---------------------------------------------------------------------------
67
+ // NAISYS/Supervisor -> Hub -> target NAISYS (request/response, two-hop relay)
68
+ // ---------------------------------------------------------------------------
69
+ /** Start an agent on its assigned host */
70
+ AGENT_START: "agent_start",
71
+ /** Stop an agent on its current host */
72
+ AGENT_STOP: "agent_stop",
73
+ /** Peek at an agent's output buffer */
74
+ AGENT_PEEK: "agent_peek",
75
+ // ---------------------------------------------------------------------------
76
+ // Supervisor -> Hub (request/response) – Admin
77
+ // ---------------------------------------------------------------------------
78
+ /** Rotate the hub access key */
79
+ ROTATE_ACCESS_KEY: "rotate_access_key",
80
+ // ---------------------------------------------------------------------------
81
+ // NAISYS/Supervisor -> Hub (request/response) – Mail
82
+ // ---------------------------------------------------------------------------
83
+ /** Send a mail message */
84
+ MAIL_SEND: "mail_send",
85
+ /** List recent mail messages */
86
+ MAIL_LIST: "mail_list",
87
+ /** Fetch a specific mail message (does not mark as read) */
88
+ MAIL_PEEK: "mail_peek",
89
+ /** Mark messages as read */
90
+ MAIL_MARK_READ: "mail_mark_read",
91
+ /** Archive mail messages */
92
+ MAIL_ARCHIVE: "mail_archive",
93
+ /** Full-text search of mail */
94
+ MAIL_SEARCH: "mail_search",
95
+ /** Get unread messages with full data */
96
+ MAIL_UNREAD: "mail_unread",
97
+ // ---------------------------------------------------------------------------
98
+ // Supervisor -> Hub (fire-and-forget, triggers broadcast)
99
+ // ---------------------------------------------------------------------------
100
+ /** Users changed — hub re-queries DB and broadcasts USERS_UPDATED */
101
+ USERS_CHANGED: "users_changed",
102
+ /** Variables changed — hub rebuilds config and broadcasts VARIABLES_UPDATED */
103
+ VARIABLES_CHANGED: "variables_changed",
104
+ /** Models changed — hub re-reads models and broadcasts MODELS_UPDATED */
105
+ MODELS_CHANGED: "models_changed",
106
+ /** Hosts changed — hub refreshes host cache and broadcasts HOSTS_UPDATED */
107
+ HOSTS_CHANGED: "hosts_changed",
108
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Hub Protocol
3
+ *
4
+ * Shared message types and event names between NAISYS instances (clients),
5
+ * the Hub server, and the Supervisor for multi-machine synchronization.
6
+ */
7
+ export * from "./eventMap.js";
8
+ export * from "./events.js";
9
+ export * from "./schemas/admin.js";
10
+ export * from "./schemas/agents.js";
11
+ export * from "./schemas/config.js";
12
+ export * from "./schemas/costs.js";
13
+ export * from "./schemas/heartbeat.js";
14
+ export * from "./schemas/hosts.js";
15
+ export * from "./schemas/logs.js";
16
+ export * from "./schemas/mail.js";
17
+ export * from "./schemas/models.js";
18
+ export * from "./schemas/sessions.js";
19
+ export * from "./schemas/users.js";
20
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Hub Protocol
3
+ *
4
+ * Shared message types and event names between NAISYS instances (clients),
5
+ * the Hub server, and the Supervisor for multi-machine synchronization.
6
+ */
7
+ export * from "./eventMap.js";
8
+ export * from "./events.js";
9
+ export * from "./schemas/admin.js";
10
+ export * from "./schemas/agents.js";
11
+ export * from "./schemas/config.js";
12
+ export * from "./schemas/costs.js";
13
+ export * from "./schemas/heartbeat.js";
14
+ export * from "./schemas/hosts.js";
15
+ export * from "./schemas/logs.js";
16
+ export * from "./schemas/mail.js";
17
+ export * from "./schemas/models.js";
18
+ export * from "./schemas/sessions.js";
19
+ export * from "./schemas/users.js";
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ /** Request to rotate the hub access key (empty payload) */
3
+ export declare const RotateAccessKeyRequestSchema: z.ZodObject<{}, z.core.$strip>;
4
+ export type RotateAccessKeyRequest = z.infer<typeof RotateAccessKeyRequestSchema>;
5
+ /** Response after rotating the hub access key */
6
+ export declare const RotateAccessKeyResponseSchema: z.ZodObject<{
7
+ success: z.ZodBoolean;
8
+ newAccessKey: z.ZodOptional<z.ZodString>;
9
+ error: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>;
11
+ export type RotateAccessKeyResponse = z.infer<typeof RotateAccessKeyResponseSchema>;
12
+ //# sourceMappingURL=admin.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ /** Request to rotate the hub access key (empty payload) */
3
+ export const RotateAccessKeyRequestSchema = z.object({});
4
+ /** Response after rotating the hub access key */
5
+ export const RotateAccessKeyResponseSchema = z.object({
6
+ success: z.boolean(),
7
+ newAccessKey: z.string().optional(),
8
+ error: z.string().optional(),
9
+ });
@@ -0,0 +1,46 @@
1
+ import { z } from "zod";
2
+ /** Request to start an agent on its assigned host */
3
+ export declare const AgentStartRequestSchema: z.ZodObject<{
4
+ startUserId: z.ZodNumber;
5
+ taskDescription: z.ZodOptional<z.ZodString>;
6
+ requesterUserId: z.ZodOptional<z.ZodNumber>;
7
+ sourceHostId: z.ZodOptional<z.ZodNumber>;
8
+ }, z.core.$strip>;
9
+ export type AgentStartRequest = z.infer<typeof AgentStartRequestSchema>;
10
+ /** Response to agent start request */
11
+ export declare const AgentStartResponseSchema: z.ZodObject<{
12
+ success: z.ZodBoolean;
13
+ error: z.ZodOptional<z.ZodString>;
14
+ hostname: z.ZodOptional<z.ZodString>;
15
+ }, z.core.$strip>;
16
+ export type AgentStartResponse = z.infer<typeof AgentStartResponseSchema>;
17
+ /** Request to stop an agent on its current host */
18
+ export declare const AgentStopRequestSchema: z.ZodObject<{
19
+ userId: z.ZodNumber;
20
+ reason: z.ZodString;
21
+ sourceHostId: z.ZodOptional<z.ZodNumber>;
22
+ }, z.core.$strip>;
23
+ export type AgentStopRequest = z.infer<typeof AgentStopRequestSchema>;
24
+ /** Response to agent stop request */
25
+ export declare const AgentStopResponseSchema: z.ZodObject<{
26
+ success: z.ZodBoolean;
27
+ error: z.ZodOptional<z.ZodString>;
28
+ }, z.core.$strip>;
29
+ export type AgentStopResponse = z.infer<typeof AgentStopResponseSchema>;
30
+ /** Request to peek at an agent's output buffer */
31
+ export declare const AgentPeekRequestSchema: z.ZodObject<{
32
+ userId: z.ZodNumber;
33
+ skip: z.ZodOptional<z.ZodNumber>;
34
+ take: z.ZodOptional<z.ZodNumber>;
35
+ sourceHostId: z.ZodOptional<z.ZodNumber>;
36
+ }, z.core.$strip>;
37
+ export type AgentPeekRequest = z.infer<typeof AgentPeekRequestSchema>;
38
+ /** Response to agent peek request */
39
+ export declare const AgentPeekResponseSchema: z.ZodObject<{
40
+ success: z.ZodBoolean;
41
+ error: z.ZodOptional<z.ZodString>;
42
+ lines: z.ZodOptional<z.ZodArray<z.ZodString>>;
43
+ totalLines: z.ZodOptional<z.ZodNumber>;
44
+ }, z.core.$strip>;
45
+ export type AgentPeekResponse = z.infer<typeof AgentPeekResponseSchema>;
46
+ //# sourceMappingURL=agents.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ /** Request to start an agent on its assigned host */
3
+ export const AgentStartRequestSchema = z.object({
4
+ startUserId: z.number(),
5
+ taskDescription: z.string().optional(),
6
+ // Used for permission validation
7
+ requesterUserId: z.number().optional(),
8
+ // Used to prevent redundant notification on loop back
9
+ sourceHostId: z.number().optional(),
10
+ });
11
+ /** Response to agent start request */
12
+ export const AgentStartResponseSchema = z.object({
13
+ success: z.boolean(),
14
+ error: z.string().optional(),
15
+ hostname: z.string().optional(),
16
+ });
17
+ /** Request to stop an agent on its current host */
18
+ export const AgentStopRequestSchema = z.object({
19
+ userId: z.number(),
20
+ reason: z.string(),
21
+ sourceHostId: z.number().optional(),
22
+ });
23
+ /** Response to agent stop request */
24
+ export const AgentStopResponseSchema = z.object({
25
+ success: z.boolean(),
26
+ error: z.string().optional(),
27
+ });
28
+ /** Request to peek at an agent's output buffer */
29
+ export const AgentPeekRequestSchema = z.object({
30
+ userId: z.number(),
31
+ skip: z.number().optional(),
32
+ take: z.number().optional(),
33
+ sourceHostId: z.number().optional(),
34
+ });
35
+ /** Response to agent peek request */
36
+ export const AgentPeekResponseSchema = z.object({
37
+ success: z.boolean(),
38
+ error: z.string().optional(),
39
+ lines: z.array(z.string()).optional(),
40
+ totalLines: z.number().optional(),
41
+ });
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ /** Pushed from hub to NAISYS instances on connect with global config */
3
+ export declare const ConfigResponseSchema: z.ZodObject<{
4
+ success: z.ZodBoolean;
5
+ error: z.ZodOptional<z.ZodString>;
6
+ config: z.ZodOptional<z.ZodObject<{
7
+ shellCommand: z.ZodObject<{
8
+ outputTokenMax: z.ZodNumber;
9
+ timeoutSeconds: z.ZodNumber;
10
+ maxTimeoutSeconds: z.ZodNumber;
11
+ }, z.core.$strip>;
12
+ retrySecondsMax: z.ZodNumber;
13
+ webTokenMax: z.ZodNumber;
14
+ compactSessionEnabled: z.ZodBoolean;
15
+ preemptiveCompactEnabled: z.ZodBoolean;
16
+ variableMap: z.ZodRecord<z.ZodString, z.ZodString>;
17
+ shellVariableMap: z.ZodRecord<z.ZodString, z.ZodString>;
18
+ googleSearchEngineId: z.ZodOptional<z.ZodString>;
19
+ spendLimitDollars: z.ZodOptional<z.ZodNumber>;
20
+ spendLimitHours: z.ZodOptional<z.ZodNumber>;
21
+ useToolsForLlmConsoleResponses: z.ZodBoolean;
22
+ autoStartAgentsOnMessage: z.ZodBoolean;
23
+ }, z.core.$strip>>;
24
+ }, z.core.$strip>;
25
+ export type ConfigResponse = z.infer<typeof ConfigResponseSchema>;
26
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ /** Pushed from hub to NAISYS instances on connect with global config */
3
+ export const ConfigResponseSchema = z.object({
4
+ success: z.boolean(),
5
+ error: z.string().optional(),
6
+ config: z
7
+ .object({
8
+ shellCommand: z.object({
9
+ outputTokenMax: z.number(),
10
+ timeoutSeconds: z.number(),
11
+ maxTimeoutSeconds: z.number(),
12
+ }),
13
+ retrySecondsMax: z.number(),
14
+ webTokenMax: z.number(),
15
+ compactSessionEnabled: z.boolean(),
16
+ preemptiveCompactEnabled: z.boolean(),
17
+ variableMap: z.record(z.string(), z.string()),
18
+ shellVariableMap: z.record(z.string(), z.string()),
19
+ googleSearchEngineId: z.string().optional(),
20
+ spendLimitDollars: z.number().optional(),
21
+ spendLimitHours: z.number().optional(),
22
+ useToolsForLlmConsoleResponses: z.boolean(),
23
+ autoStartAgentsOnMessage: z.boolean(),
24
+ })
25
+ .optional(),
26
+ });
@@ -0,0 +1,97 @@
1
+ import { z } from "zod";
2
+ /** How often NAISYS instances flush buffered cost entries to the hub (ms) */
3
+ export declare const COST_FLUSH_INTERVAL_MS = 100;
4
+ export declare const CostSourceEnum: z.ZodEnum<{
5
+ console: "console";
6
+ write_protection: "write_protection";
7
+ compact: "compact";
8
+ lynx: "lynx";
9
+ look: "look";
10
+ listen: "listen";
11
+ genimg: "genimg";
12
+ }>;
13
+ export type CostSource = z.infer<typeof CostSourceEnum>;
14
+ /** A single cost entry sent from NAISYS instance to hub */
15
+ export declare const CostWriteEntrySchema: z.ZodObject<{
16
+ userId: z.ZodNumber;
17
+ runId: z.ZodNumber;
18
+ sessionId: z.ZodNumber;
19
+ source: z.ZodEnum<{
20
+ console: "console";
21
+ write_protection: "write_protection";
22
+ compact: "compact";
23
+ lynx: "lynx";
24
+ look: "look";
25
+ listen: "listen";
26
+ genimg: "genimg";
27
+ }>;
28
+ model: z.ZodString;
29
+ cost: z.ZodNumber;
30
+ inputTokens: z.ZodNumber;
31
+ outputTokens: z.ZodNumber;
32
+ cacheWriteTokens: z.ZodNumber;
33
+ cacheReadTokens: z.ZodNumber;
34
+ }, z.core.$strip>;
35
+ export type CostWriteEntry = z.infer<typeof CostWriteEntrySchema>;
36
+ /** Batch of cost entries sent from NAISYS instance to hub */
37
+ export declare const CostWriteRequestSchema: z.ZodObject<{
38
+ entries: z.ZodArray<z.ZodObject<{
39
+ userId: z.ZodNumber;
40
+ runId: z.ZodNumber;
41
+ sessionId: z.ZodNumber;
42
+ source: z.ZodEnum<{
43
+ console: "console";
44
+ write_protection: "write_protection";
45
+ compact: "compact";
46
+ lynx: "lynx";
47
+ look: "look";
48
+ listen: "listen";
49
+ genimg: "genimg";
50
+ }>;
51
+ model: z.ZodString;
52
+ cost: z.ZodNumber;
53
+ inputTokens: z.ZodNumber;
54
+ outputTokens: z.ZodNumber;
55
+ cacheWriteTokens: z.ZodNumber;
56
+ cacheReadTokens: z.ZodNumber;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$strip>;
59
+ export type CostWriteRequest = z.infer<typeof CostWriteRequestSchema>;
60
+ /** Per-user budget entry in the COST_WRITE response */
61
+ export declare const CostWriteBudgetEntrySchema: z.ZodObject<{
62
+ userId: z.ZodNumber;
63
+ budgetLeft: z.ZodNullable<z.ZodNumber>;
64
+ }, z.core.$strip>;
65
+ /** Response to COST_WRITE — returns per-agent budget info for each user in the batch */
66
+ export declare const CostWriteResponseSchema: z.ZodObject<{
67
+ budgets: z.ZodArray<z.ZodObject<{
68
+ userId: z.ZodNumber;
69
+ budgetLeft: z.ZodNullable<z.ZodNumber>;
70
+ }, z.core.$strip>>;
71
+ }, z.core.$strip>;
72
+ export type CostWriteResponse = z.infer<typeof CostWriteResponseSchema>;
73
+ /** Cost delta pushed from hub to supervisor after DB write */
74
+ export declare const CostPushEntrySchema: z.ZodObject<{
75
+ userId: z.ZodNumber;
76
+ runId: z.ZodNumber;
77
+ sessionId: z.ZodNumber;
78
+ costDelta: z.ZodNumber;
79
+ }, z.core.$strip>;
80
+ export type CostPushEntry = z.infer<typeof CostPushEntrySchema>;
81
+ export declare const CostPushSchema: z.ZodObject<{
82
+ entries: z.ZodArray<z.ZodObject<{
83
+ userId: z.ZodNumber;
84
+ runId: z.ZodNumber;
85
+ sessionId: z.ZodNumber;
86
+ costDelta: z.ZodNumber;
87
+ }, z.core.$strip>>;
88
+ }, z.core.$strip>;
89
+ export type CostPush = z.infer<typeof CostPushSchema>;
90
+ /** Pushed from hub when an agent's spending status changes */
91
+ export declare const CostControlSchema: z.ZodObject<{
92
+ userId: z.ZodNumber;
93
+ enabled: z.ZodBoolean;
94
+ reason: z.ZodString;
95
+ }, z.core.$strip>;
96
+ export type CostControl = z.infer<typeof CostControlSchema>;
97
+ //# sourceMappingURL=costs.d.ts.map