@myagentroam/protocol 0.1.4 → 0.1.7

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.
@@ -0,0 +1,256 @@
1
+ import { z } from 'zod';
2
+ export declare const editionSchema: z.ZodEnum<["PERSONAL", "ENTERPRISE"]>;
3
+ export declare const licenseStateSchema: z.ZodEnum<["PERSONAL", "ENTERPRISE_VALID", "ENTERPRISE_FROZEN"]>;
4
+ export declare const userRoleSchema: z.ZodEnum<["ADMIN", "ORG_ADMIN", "MEMBER"]>;
5
+ export declare const permissionScopeSchema: z.ZodEnum<["ENTERPRISE", "ORG_SUBTREE", "PERSONAL", "GRANTED_RESOURCE"]>;
6
+ export type UserRole = z.infer<typeof userRoleSchema>;
7
+ export declare const enterpriseCapabilitySchema: z.ZodObject<{
8
+ edition: z.ZodEnum<["PERSONAL", "ENTERPRISE"]>;
9
+ licenseState: z.ZodEnum<["PERSONAL", "ENTERPRISE_VALID", "ENTERPRISE_FROZEN"]>;
10
+ role: z.ZodNullable<z.ZodEnum<["ADMIN", "ORG_ADMIN", "MEMBER"]>>;
11
+ organizationId: z.ZodNullable<z.ZodNumber>;
12
+ managementWritable: z.ZodBoolean;
13
+ }, "strict", z.ZodTypeAny, {
14
+ edition: "PERSONAL" | "ENTERPRISE";
15
+ licenseState: "PERSONAL" | "ENTERPRISE_VALID" | "ENTERPRISE_FROZEN";
16
+ role: "ADMIN" | "ORG_ADMIN" | "MEMBER" | null;
17
+ organizationId: number | null;
18
+ managementWritable: boolean;
19
+ }, {
20
+ edition: "PERSONAL" | "ENTERPRISE";
21
+ licenseState: "PERSONAL" | "ENTERPRISE_VALID" | "ENTERPRISE_FROZEN";
22
+ role: "ADMIN" | "ORG_ADMIN" | "MEMBER" | null;
23
+ organizationId: number | null;
24
+ managementWritable: boolean;
25
+ }>;
26
+ export type EnterpriseCapability = z.infer<typeof enterpriseCapabilitySchema>;
27
+ export declare const organizationSchema: z.ZodObject<{
28
+ id: z.ZodNumber;
29
+ name: z.ZodString;
30
+ parentOrganizationId: z.ZodNullable<z.ZodNumber>;
31
+ createdAt: z.ZodNumber;
32
+ updatedAt: z.ZodNumber;
33
+ }, "strict", z.ZodTypeAny, {
34
+ id: number;
35
+ name: string;
36
+ parentOrganizationId: number | null;
37
+ createdAt: number;
38
+ updatedAt: number;
39
+ }, {
40
+ id: number;
41
+ name: string;
42
+ parentOrganizationId: number | null;
43
+ createdAt: number;
44
+ updatedAt: number;
45
+ }>;
46
+ export declare const resourceOwnershipSchema: z.ZodDiscriminatedUnion<"ownerType", [z.ZodObject<{
47
+ ownerType: z.ZodLiteral<"PERSONAL">;
48
+ ownerUserId: z.ZodNumber;
49
+ }, "strict", z.ZodTypeAny, {
50
+ ownerType: "PERSONAL";
51
+ ownerUserId: number;
52
+ }, {
53
+ ownerType: "PERSONAL";
54
+ ownerUserId: number;
55
+ }>, z.ZodObject<{
56
+ ownerType: z.ZodLiteral<"ORGANIZATION">;
57
+ ownerOrganizationId: z.ZodNumber;
58
+ }, "strict", z.ZodTypeAny, {
59
+ ownerType: "ORGANIZATION";
60
+ ownerOrganizationId: number;
61
+ }, {
62
+ ownerType: "ORGANIZATION";
63
+ ownerOrganizationId: number;
64
+ }>]>;
65
+ export type ResourceOwnership = z.infer<typeof resourceOwnershipSchema>;
66
+ export declare const resourceGrantSchema: z.ZodEffects<z.ZodObject<{
67
+ id: z.ZodString;
68
+ resourceType: z.ZodEnum<["NODE", "WORKSPACE"]>;
69
+ nodeId: z.ZodString;
70
+ workspaceId: z.ZodOptional<z.ZodString>;
71
+ targetType: z.ZodEnum<["USER", "ORGANIZATION", "ENTERPRISE"]>;
72
+ targetUserId: z.ZodOptional<z.ZodNumber>;
73
+ targetOrganizationId: z.ZodOptional<z.ZodNumber>;
74
+ grantAuthority: z.ZodEnum<["ENTERPRISE", "ORG_SUBTREE"]>;
75
+ grantScopeOrganizationId: z.ZodOptional<z.ZodNumber>;
76
+ createdByUserId: z.ZodNumber;
77
+ createdAt: z.ZodNumber;
78
+ }, "strict", z.ZodTypeAny, {
79
+ id: string;
80
+ createdAt: number;
81
+ resourceType: "NODE" | "WORKSPACE";
82
+ nodeId: string;
83
+ targetType: "ENTERPRISE" | "ORGANIZATION" | "USER";
84
+ grantAuthority: "ENTERPRISE" | "ORG_SUBTREE";
85
+ createdByUserId: number;
86
+ workspaceId?: string | undefined;
87
+ targetUserId?: number | undefined;
88
+ targetOrganizationId?: number | undefined;
89
+ grantScopeOrganizationId?: number | undefined;
90
+ }, {
91
+ id: string;
92
+ createdAt: number;
93
+ resourceType: "NODE" | "WORKSPACE";
94
+ nodeId: string;
95
+ targetType: "ENTERPRISE" | "ORGANIZATION" | "USER";
96
+ grantAuthority: "ENTERPRISE" | "ORG_SUBTREE";
97
+ createdByUserId: number;
98
+ workspaceId?: string | undefined;
99
+ targetUserId?: number | undefined;
100
+ targetOrganizationId?: number | undefined;
101
+ grantScopeOrganizationId?: number | undefined;
102
+ }>, {
103
+ id: string;
104
+ createdAt: number;
105
+ resourceType: "NODE" | "WORKSPACE";
106
+ nodeId: string;
107
+ targetType: "ENTERPRISE" | "ORGANIZATION" | "USER";
108
+ grantAuthority: "ENTERPRISE" | "ORG_SUBTREE";
109
+ createdByUserId: number;
110
+ workspaceId?: string | undefined;
111
+ targetUserId?: number | undefined;
112
+ targetOrganizationId?: number | undefined;
113
+ grantScopeOrganizationId?: number | undefined;
114
+ }, {
115
+ id: string;
116
+ createdAt: number;
117
+ resourceType: "NODE" | "WORKSPACE";
118
+ nodeId: string;
119
+ targetType: "ENTERPRISE" | "ORGANIZATION" | "USER";
120
+ grantAuthority: "ENTERPRISE" | "ORG_SUBTREE";
121
+ createdByUserId: number;
122
+ workspaceId?: string | undefined;
123
+ targetUserId?: number | undefined;
124
+ targetOrganizationId?: number | undefined;
125
+ grantScopeOrganizationId?: number | undefined;
126
+ }>;
127
+ export declare const oauthProviderInputSchema: z.ZodObject<{
128
+ providerKey: z.ZodString;
129
+ name: z.ZodString;
130
+ clientId: z.ZodString;
131
+ clientSecret: z.ZodOptional<z.ZodString>;
132
+ authorizationEndpoint: z.ZodString;
133
+ tokenEndpoint: z.ZodString;
134
+ userinfoEndpoint: z.ZodString;
135
+ scopes: z.ZodArray<z.ZodString, "many">;
136
+ pkceMode: z.ZodEnum<["REQUIRED", "SUPPORTED", "DISABLED"]>;
137
+ tokenAuthMethod: z.ZodEnum<["client_secret_basic", "client_secret_post", "client_secret_json"]>;
138
+ autoProvisioningEnabled: z.ZodDefault<z.ZodBoolean>;
139
+ mappings: z.ZodObject<{
140
+ externalUserId: z.ZodString;
141
+ email: z.ZodOptional<z.ZodString>;
142
+ displayName: z.ZodOptional<z.ZodString>;
143
+ }, "strict", z.ZodTypeAny, {
144
+ externalUserId: string;
145
+ email?: string | undefined;
146
+ displayName?: string | undefined;
147
+ }, {
148
+ externalUserId: string;
149
+ email?: string | undefined;
150
+ displayName?: string | undefined;
151
+ }>;
152
+ }, "strict", z.ZodTypeAny, {
153
+ name: string;
154
+ providerKey: string;
155
+ clientId: string;
156
+ authorizationEndpoint: string;
157
+ tokenEndpoint: string;
158
+ userinfoEndpoint: string;
159
+ scopes: string[];
160
+ pkceMode: "REQUIRED" | "SUPPORTED" | "DISABLED";
161
+ tokenAuthMethod: "client_secret_basic" | "client_secret_post" | "client_secret_json";
162
+ autoProvisioningEnabled: boolean;
163
+ mappings: {
164
+ externalUserId: string;
165
+ email?: string | undefined;
166
+ displayName?: string | undefined;
167
+ };
168
+ clientSecret?: string | undefined;
169
+ }, {
170
+ name: string;
171
+ providerKey: string;
172
+ clientId: string;
173
+ authorizationEndpoint: string;
174
+ tokenEndpoint: string;
175
+ userinfoEndpoint: string;
176
+ scopes: string[];
177
+ pkceMode: "REQUIRED" | "SUPPORTED" | "DISABLED";
178
+ tokenAuthMethod: "client_secret_basic" | "client_secret_post" | "client_secret_json";
179
+ mappings: {
180
+ externalUserId: string;
181
+ email?: string | undefined;
182
+ displayName?: string | undefined;
183
+ };
184
+ clientSecret?: string | undefined;
185
+ autoProvisioningEnabled?: boolean | undefined;
186
+ }>;
187
+ export declare const auditEventSchema: z.ZodObject<{
188
+ id: z.ZodString;
189
+ eventType: z.ZodString;
190
+ occurredAt: z.ZodNumber;
191
+ result: z.ZodEnum<["SUCCESS", "DENIED", "FAILED"]>;
192
+ errorCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
193
+ actorUserId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
194
+ actorUsername: z.ZodOptional<z.ZodNullable<z.ZodString>>;
195
+ authenticationMethod: z.ZodEnum<["PASSWORD", "OAUTH2", "SYSTEM"]>;
196
+ providerId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
197
+ requestId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
198
+ operationId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
199
+ sessionPublicId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
200
+ targetType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
201
+ targetId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
202
+ organizationId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
203
+ nodeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
204
+ workspaceId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
205
+ agentSessionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
206
+ runId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
207
+ clientMessageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
208
+ inputMode: z.ZodOptional<z.ZodNullable<z.ZodEnum<["NEW_SESSION", "CONTINUE", "STEER", "QUEUE", "RUN_NOW", "USER_INPUT_RESPONSE"]>>>;
209
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
210
+ }, "strict", z.ZodTypeAny, {
211
+ id: string;
212
+ eventType: string;
213
+ occurredAt: number;
214
+ result: "SUCCESS" | "DENIED" | "FAILED";
215
+ authenticationMethod: "PASSWORD" | "OAUTH2" | "SYSTEM";
216
+ organizationId?: number | null | undefined;
217
+ nodeId?: string | null | undefined;
218
+ workspaceId?: string | null | undefined;
219
+ targetType?: string | null | undefined;
220
+ errorCode?: string | null | undefined;
221
+ actorUserId?: number | null | undefined;
222
+ actorUsername?: string | null | undefined;
223
+ providerId?: string | null | undefined;
224
+ requestId?: string | null | undefined;
225
+ operationId?: string | null | undefined;
226
+ sessionPublicId?: string | null | undefined;
227
+ targetId?: string | null | undefined;
228
+ agentSessionId?: string | null | undefined;
229
+ runId?: string | null | undefined;
230
+ clientMessageId?: string | null | undefined;
231
+ inputMode?: "NEW_SESSION" | "CONTINUE" | "STEER" | "QUEUE" | "RUN_NOW" | "USER_INPUT_RESPONSE" | null | undefined;
232
+ metadata?: Record<string, string | number | boolean | null> | undefined;
233
+ }, {
234
+ id: string;
235
+ eventType: string;
236
+ occurredAt: number;
237
+ result: "SUCCESS" | "DENIED" | "FAILED";
238
+ authenticationMethod: "PASSWORD" | "OAUTH2" | "SYSTEM";
239
+ organizationId?: number | null | undefined;
240
+ nodeId?: string | null | undefined;
241
+ workspaceId?: string | null | undefined;
242
+ targetType?: string | null | undefined;
243
+ errorCode?: string | null | undefined;
244
+ actorUserId?: number | null | undefined;
245
+ actorUsername?: string | null | undefined;
246
+ providerId?: string | null | undefined;
247
+ requestId?: string | null | undefined;
248
+ operationId?: string | null | undefined;
249
+ sessionPublicId?: string | null | undefined;
250
+ targetId?: string | null | undefined;
251
+ agentSessionId?: string | null | undefined;
252
+ runId?: string | null | undefined;
253
+ clientMessageId?: string | null | undefined;
254
+ inputMode?: "NEW_SESSION" | "CONTINUE" | "STEER" | "QUEUE" | "RUN_NOW" | "USER_INPUT_RESPONSE" | null | undefined;
255
+ metadata?: Record<string, string | number | boolean | null> | undefined;
256
+ }>;
@@ -0,0 +1,122 @@
1
+ import { z } from 'zod';
2
+ export const editionSchema = z.enum(['PERSONAL', 'ENTERPRISE']);
3
+ export const licenseStateSchema = z.enum(['PERSONAL', 'ENTERPRISE_VALID', 'ENTERPRISE_FROZEN']);
4
+ export const userRoleSchema = z.enum(['ADMIN', 'ORG_ADMIN', 'MEMBER']);
5
+ export const permissionScopeSchema = z.enum([
6
+ 'ENTERPRISE',
7
+ 'ORG_SUBTREE',
8
+ 'PERSONAL',
9
+ 'GRANTED_RESOURCE'
10
+ ]);
11
+ export const enterpriseCapabilitySchema = z
12
+ .object({
13
+ edition: editionSchema,
14
+ licenseState: licenseStateSchema,
15
+ role: userRoleSchema.nullable(),
16
+ organizationId: z.number().int().positive().nullable(),
17
+ managementWritable: z.boolean()
18
+ })
19
+ .strict();
20
+ export const organizationSchema = z
21
+ .object({
22
+ id: z.number().int().positive(),
23
+ name: z.string().trim().min(1).max(128),
24
+ parentOrganizationId: z.number().int().positive().nullable(),
25
+ createdAt: z.number().int().nonnegative(),
26
+ updatedAt: z.number().int().nonnegative()
27
+ })
28
+ .strict();
29
+ export const resourceOwnershipSchema = z.discriminatedUnion('ownerType', [
30
+ z.object({ ownerType: z.literal('PERSONAL'), ownerUserId: z.number().int().positive() }).strict(),
31
+ z
32
+ .object({
33
+ ownerType: z.literal('ORGANIZATION'),
34
+ ownerOrganizationId: z.number().int().positive()
35
+ })
36
+ .strict()
37
+ ]);
38
+ export const resourceGrantSchema = z
39
+ .object({
40
+ id: z.string().min(1).max(128),
41
+ resourceType: z.enum(['NODE', 'WORKSPACE']),
42
+ nodeId: z.string().min(1).max(128),
43
+ workspaceId: z.string().min(1).max(128).optional(),
44
+ targetType: z.enum(['USER', 'ORGANIZATION', 'ENTERPRISE']),
45
+ targetUserId: z.number().int().positive().optional(),
46
+ targetOrganizationId: z.number().int().positive().optional(),
47
+ grantAuthority: z.enum(['ENTERPRISE', 'ORG_SUBTREE']),
48
+ grantScopeOrganizationId: z.number().int().positive().optional(),
49
+ createdByUserId: z.number().int().positive(),
50
+ createdAt: z.number().int().nonnegative()
51
+ })
52
+ .strict()
53
+ .superRefine((grant, context) => {
54
+ if ((grant.resourceType === 'WORKSPACE') !== (grant.workspaceId !== undefined)) {
55
+ context.addIssue({ code: 'custom', message: 'workspaceId must match resourceType' });
56
+ }
57
+ if ((grant.targetType === 'USER') !== (grant.targetUserId !== undefined)) {
58
+ context.addIssue({ code: 'custom', message: 'targetUserId must match targetType' });
59
+ }
60
+ if ((grant.targetType === 'ORGANIZATION') !== (grant.targetOrganizationId !== undefined)) {
61
+ context.addIssue({ code: 'custom', message: 'targetOrganizationId must match targetType' });
62
+ }
63
+ if ((grant.grantAuthority === 'ORG_SUBTREE') !==
64
+ (grant.grantScopeOrganizationId !== undefined)) {
65
+ context.addIssue({ code: 'custom', message: 'grant scope must match authority' });
66
+ }
67
+ });
68
+ const jsonPointerSchema = z.string().regex(/^(?:|(?:\/(?:[^~/]|~[01])*)+)$/);
69
+ const requiredJsonPointerSchema = jsonPointerSchema.min(1);
70
+ export const oauthProviderInputSchema = z
71
+ .object({
72
+ providerKey: z.string().regex(/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/),
73
+ name: z.string().trim().min(1).max(128),
74
+ clientId: z.string().min(1).max(512),
75
+ clientSecret: z.string().min(1).max(4096).optional(),
76
+ authorizationEndpoint: z.string().url(),
77
+ tokenEndpoint: z.string().url(),
78
+ userinfoEndpoint: z.string().url(),
79
+ scopes: z.array(z.string().min(1).max(128)).max(32),
80
+ pkceMode: z.enum(['REQUIRED', 'SUPPORTED', 'DISABLED']),
81
+ tokenAuthMethod: z.enum(['client_secret_basic', 'client_secret_post', 'client_secret_json']),
82
+ autoProvisioningEnabled: z.boolean().default(false),
83
+ mappings: z
84
+ .object({
85
+ externalUserId: requiredJsonPointerSchema,
86
+ email: jsonPointerSchema.optional(),
87
+ displayName: jsonPointerSchema.optional()
88
+ })
89
+ .strict()
90
+ })
91
+ .strict();
92
+ export const auditEventSchema = z
93
+ .object({
94
+ id: z.string().min(1).max(128),
95
+ eventType: z.string().regex(/^[a-z0-9_.-]{1,80}$/),
96
+ occurredAt: z.number().int().nonnegative(),
97
+ result: z.enum(['SUCCESS', 'DENIED', 'FAILED']),
98
+ errorCode: z.string().max(80).nullable().optional(),
99
+ actorUserId: z.number().int().positive().nullable().optional(),
100
+ actorUsername: z.string().max(128).nullable().optional(),
101
+ authenticationMethod: z.enum(['PASSWORD', 'OAUTH2', 'SYSTEM']),
102
+ providerId: z.string().max(128).nullable().optional(),
103
+ requestId: z.string().max(128).nullable().optional(),
104
+ operationId: z.string().max(128).nullable().optional(),
105
+ sessionPublicId: z.string().max(128).nullable().optional(),
106
+ targetType: z.string().max(80).nullable().optional(),
107
+ targetId: z.string().max(128).nullable().optional(),
108
+ organizationId: z.number().int().positive().nullable().optional(),
109
+ nodeId: z.string().max(128).nullable().optional(),
110
+ workspaceId: z.string().max(128).nullable().optional(),
111
+ agentSessionId: z.string().max(128).nullable().optional(),
112
+ runId: z.string().max(128).nullable().optional(),
113
+ clientMessageId: z.string().max(128).nullable().optional(),
114
+ inputMode: z
115
+ .enum(['NEW_SESSION', 'CONTINUE', 'STEER', 'QUEUE', 'RUN_NOW', 'USER_INPUT_RESPONSE'])
116
+ .nullable()
117
+ .optional(),
118
+ metadata: z
119
+ .record(z.string(), z.union([z.string(), z.number(), z.boolean(), z.null()]))
120
+ .optional()
121
+ })
122
+ .strict();