@myagentroam/protocol 0.10.7 → 0.10.9

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,123 @@
1
+ import { z } from 'zod';
2
+ export const MODEL_USAGE_VERSION = 1;
3
+ export const MODEL_USAGE_RETENTION_MS = 90 * 86_400_000;
4
+ export const MODEL_USAGE_OUTBOX_RETENTION_MS = 7 * 86_400_000;
5
+ export const MODEL_USAGE_BATCH_LIMIT = 64;
6
+ export const MODEL_USAGE_BATCH_BYTES = 262_144;
7
+ const identifier = z.string().min(1).max(256);
8
+ const time = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
9
+ export const usageCountSchema = z.string().regex(/^(0|[1-9][0-9]{0,37})$/);
10
+ export const usageRunnerSchema = z.enum(['mar-agent', 'codex', 'claude-code', 'opencode']);
11
+ export const usagePurposeSchema = z.enum(['conversation', 'compact', 'title', 'other']);
12
+ export const modelUsageCapabilitySchema = z.object({ apiVersion: z.literal(1) }).strict();
13
+ /** A non-executable assertion, signed and verified only by the Server. */
14
+ export const modelUsageGrantClaimsSchema = z
15
+ .object({
16
+ audience: z.literal('model-usage-v1'),
17
+ scopeId: z.string().uuid(),
18
+ nodeId: identifier,
19
+ userId: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
20
+ mode: z.enum(['work', 'conversation']),
21
+ issuedAt: time,
22
+ expiresAt: time
23
+ })
24
+ .strict();
25
+ export const modelUsageGrantSchema = z
26
+ .object({
27
+ scopeId: z.string().uuid(),
28
+ token: z.string().min(1).max(2048)
29
+ })
30
+ .strict();
31
+ export const modelUsageRecordSchema = z
32
+ .object({
33
+ schemaVersion: z.literal(1),
34
+ recordId: identifier,
35
+ requestId: identifier,
36
+ revision: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
37
+ scopeId: z.string().uuid(),
38
+ runner: usageRunnerSchema,
39
+ sessionId: identifier,
40
+ runId: identifier,
41
+ modelConfigurationId: identifier.optional(),
42
+ modelName: identifier.optional(),
43
+ provider: identifier.optional(),
44
+ requestedModel: identifier.optional(),
45
+ actualModel: identifier.optional(),
46
+ responseId: identifier.optional(),
47
+ purpose: usagePurposeSchema,
48
+ agentRole: z.enum(['root', 'subagent']),
49
+ startedAt: time,
50
+ endedAt: time.optional(),
51
+ state: z.enum(['running', 'succeeded', 'failed', 'cancelled', 'interrupted']),
52
+ inputTokens: usageCountSchema.optional(),
53
+ outputTokens: usageCountSchema.optional(),
54
+ cacheReadTokens: usageCountSchema.optional(),
55
+ cacheWriteTokens: usageCountSchema.optional(),
56
+ reasoningTokens: usageCountSchema.optional(),
57
+ coverage: z.enum(['request', 'partial']).default('request')
58
+ })
59
+ .strict()
60
+ .superRefine((record, context) => {
61
+ if ((record.state === 'running') !== (record.endedAt === undefined))
62
+ context.addIssue({ code: 'custom', message: 'Usage outcome and end time do not match.' });
63
+ if (record.endedAt !== undefined && record.endedAt < record.startedAt)
64
+ context.addIssue({ code: 'custom', message: 'Usage end time precedes its start.' });
65
+ });
66
+ export const modelUsageBatchSchema = z
67
+ .object({
68
+ apiVersion: z.literal(1),
69
+ entries: z
70
+ .array(z.object({ grant: modelUsageGrantSchema, record: modelUsageRecordSchema }).strict())
71
+ .min(1)
72
+ .max(MODEL_USAGE_BATCH_LIMIT)
73
+ })
74
+ .strict();
75
+ export const modelUsageAckSchema = z
76
+ .object({
77
+ apiVersion: z.literal(1),
78
+ results: z
79
+ .array(z
80
+ .object({
81
+ recordId: identifier,
82
+ revision: z.number().int().positive(),
83
+ status: z.enum(['accepted', 'rejected']),
84
+ code: z
85
+ .enum([
86
+ 'USAGE_GRANT_INVALID',
87
+ 'USAGE_EXPIRED',
88
+ 'USAGE_USER_DELETED',
89
+ 'USAGE_CONFLICT',
90
+ 'USAGE_TIME_INVALID'
91
+ ])
92
+ .optional()
93
+ })
94
+ .strict())
95
+ .max(MODEL_USAGE_BATCH_LIMIT)
96
+ })
97
+ .strict();
98
+ export const personalUsageQuerySchema = z
99
+ .object({
100
+ from: z.coerce.number().int().nonnegative(),
101
+ to: z.coerce.number().int().nonnegative(),
102
+ timeZone: z
103
+ .string()
104
+ .min(1)
105
+ .max(100)
106
+ .refine((value) => {
107
+ try {
108
+ new Intl.DateTimeFormat('en', { timeZone: value });
109
+ return true;
110
+ }
111
+ catch {
112
+ return false;
113
+ }
114
+ }),
115
+ runner: usageRunnerSchema.optional(),
116
+ model: z.string().min(1).max(800).optional(),
117
+ mode: z.enum(['work', 'conversation']).optional(),
118
+ purpose: usagePurposeSchema.optional()
119
+ })
120
+ .strict()
121
+ .refine((value) => value.to > value.from && value.to - value.from <= MODEL_USAGE_RETENTION_MS, {
122
+ message: 'Usage range must be positive and no longer than 90 days.'
123
+ });
package/dist/skill.d.ts CHANGED
@@ -272,16 +272,16 @@ export declare const skillInstallMetadataSchema: z.ZodObject<{
272
272
  contentHash: z.ZodString;
273
273
  installedAt: z.ZodNumber;
274
274
  }, "strict", z.ZodTypeAny, {
275
+ schemaVersion: 1;
275
276
  commitSha: string;
276
277
  contentHash: string;
277
- schemaVersion: 1;
278
278
  favoriteId: string;
279
279
  versionId: string;
280
280
  installedAt: number;
281
281
  }, {
282
+ schemaVersion: 1;
282
283
  commitSha: string;
283
284
  contentHash: string;
284
- schemaVersion: 1;
285
285
  favoriteId: string;
286
286
  versionId: string;
287
287
  installedAt: number;
@@ -0,0 +1,76 @@
1
+ import { z } from 'zod';
2
+ export declare const toolResultResourceInputSchema: z.ZodObject<{
3
+ resourceRef: z.ZodString;
4
+ cursor: z.ZodOptional<z.ZodString>;
5
+ maxBytes: z.ZodOptional<z.ZodNumber>;
6
+ }, "strict", z.ZodTypeAny, {
7
+ resourceRef: string;
8
+ cursor?: string | undefined;
9
+ maxBytes?: number | undefined;
10
+ }, {
11
+ resourceRef: string;
12
+ cursor?: string | undefined;
13
+ maxBytes?: number | undefined;
14
+ }>;
15
+ export type ToolResultResourceInput = z.infer<typeof toolResultResourceInputSchema>;
16
+ export declare const toolResultResourcePageSchema: z.ZodObject<{
17
+ resourceRef: z.ZodString;
18
+ type: z.ZodLiteral<"file_changes">;
19
+ version: z.ZodLiteral<1>;
20
+ format: z.ZodLiteral<"unified-diff">;
21
+ sha256: z.ZodString;
22
+ byteSize: z.ZodNumber;
23
+ content: z.ZodString;
24
+ nextCursor: z.ZodOptional<z.ZodString>;
25
+ }, "strict", z.ZodTypeAny, {
26
+ type: "file_changes";
27
+ resourceRef: string;
28
+ version: 1;
29
+ format: "unified-diff";
30
+ sha256: string;
31
+ byteSize: number;
32
+ content: string;
33
+ nextCursor?: string | undefined;
34
+ }, {
35
+ type: "file_changes";
36
+ resourceRef: string;
37
+ version: 1;
38
+ format: "unified-diff";
39
+ sha256: string;
40
+ byteSize: number;
41
+ content: string;
42
+ nextCursor?: string | undefined;
43
+ }>;
44
+ export type ToolResultResourcePage = z.infer<typeof toolResultResourcePageSchema>;
45
+ export declare const fileChangeDiffSchema: z.ZodDiscriminatedUnion<"status", [z.ZodObject<{
46
+ status: z.ZodLiteral<"available">;
47
+ source: z.ZodLiteral<"TOOL_CHANGE">;
48
+ resourceRef: z.ZodString;
49
+ format: z.ZodLiteral<"unified-diff">;
50
+ byteSize: z.ZodNumber;
51
+ sha256: z.ZodString;
52
+ }, "strict", z.ZodTypeAny, {
53
+ status: "available";
54
+ source: "TOOL_CHANGE";
55
+ resourceRef: string;
56
+ format: "unified-diff";
57
+ sha256: string;
58
+ byteSize: number;
59
+ }, {
60
+ status: "available";
61
+ source: "TOOL_CHANGE";
62
+ resourceRef: string;
63
+ format: "unified-diff";
64
+ sha256: string;
65
+ byteSize: number;
66
+ }>, z.ZodObject<{
67
+ status: z.ZodLiteral<"unavailable">;
68
+ reason: z.ZodEnum<["binary", "limit-exceeded", "capture-failed", "storage-failed"]>;
69
+ }, "strict", z.ZodTypeAny, {
70
+ status: "unavailable";
71
+ reason: "binary" | "limit-exceeded" | "capture-failed" | "storage-failed";
72
+ }, {
73
+ status: "unavailable";
74
+ reason: "binary" | "limit-exceeded" | "capture-failed" | "storage-failed";
75
+ }>]>;
76
+ export type FileChangeDiff = z.infer<typeof fileChangeDiffSchema>;
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+ export const toolResultResourceInputSchema = z
3
+ .object({
4
+ resourceRef: z.string().uuid(),
5
+ cursor: z.string().min(1).max(1024).optional(),
6
+ maxBytes: z
7
+ .number()
8
+ .int()
9
+ .min(4)
10
+ .max(256 * 1024)
11
+ .optional()
12
+ })
13
+ .strict();
14
+ export const toolResultResourcePageSchema = z
15
+ .object({
16
+ resourceRef: z.string().uuid(),
17
+ type: z.literal('file_changes'),
18
+ version: z.literal(1),
19
+ format: z.literal('unified-diff'),
20
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u),
21
+ byteSize: z
22
+ .number()
23
+ .int()
24
+ .min(0)
25
+ .max(16 * 1024 * 1024),
26
+ content: z.string().max(256 * 1024),
27
+ nextCursor: z.string().min(1).max(1024).optional()
28
+ })
29
+ .strict();
30
+ export const fileChangeDiffSchema = z.discriminatedUnion('status', [
31
+ z
32
+ .object({
33
+ status: z.literal('available'),
34
+ source: z.literal('TOOL_CHANGE'),
35
+ resourceRef: z.string().uuid(),
36
+ format: z.literal('unified-diff'),
37
+ byteSize: z
38
+ .number()
39
+ .int()
40
+ .min(0)
41
+ .max(16 * 1024 * 1024),
42
+ sha256: z.string().regex(/^[a-f0-9]{64}$/u)
43
+ })
44
+ .strict(),
45
+ z
46
+ .object({
47
+ status: z.literal('unavailable'),
48
+ reason: z.enum(['binary', 'limit-exceeded', 'capture-failed', 'storage-failed'])
49
+ })
50
+ .strict()
51
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/protocol",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
4
4
  "description": "Shared runtime protocol schemas for MyAgentRoam.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",