@myagentroam/protocol 0.9.176 → 0.9.177

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,145 @@
1
+ import { z } from 'zod';
2
+ export declare const composerTagSchemas: {
3
+ readonly mar_goal_start: z.ZodObject<{
4
+ objective: z.ZodString;
5
+ }, "strict", z.ZodTypeAny, {
6
+ objective: string;
7
+ }, {
8
+ objective: string;
9
+ }>;
10
+ readonly mar_goal_continue: z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>;
11
+ readonly mar_attachments: z.ZodObject<{
12
+ files: z.ZodArray<z.ZodEffects<z.ZodObject<{
13
+ name: z.ZodString;
14
+ mime: z.ZodString;
15
+ path: z.ZodEffects<z.ZodString, string, string>;
16
+ workspacePath: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
17
+ }, "strict", z.ZodTypeAny, {
18
+ path: string;
19
+ name: string;
20
+ mime: string;
21
+ workspacePath?: string | undefined;
22
+ }, {
23
+ path: string;
24
+ name: string;
25
+ mime: string;
26
+ workspacePath?: string | undefined;
27
+ }>, {
28
+ path: string;
29
+ name: string;
30
+ mime: string;
31
+ workspacePath?: string | undefined;
32
+ }, {
33
+ path: string;
34
+ name: string;
35
+ mime: string;
36
+ workspacePath?: string | undefined;
37
+ }>, "many">;
38
+ }, "strict", z.ZodTypeAny, {
39
+ files: {
40
+ path: string;
41
+ name: string;
42
+ mime: string;
43
+ workspacePath?: string | undefined;
44
+ }[];
45
+ }, {
46
+ files: {
47
+ path: string;
48
+ name: string;
49
+ mime: string;
50
+ workspacePath?: string | undefined;
51
+ }[];
52
+ }>;
53
+ readonly mar_schedule: z.ZodObject<{
54
+ objective: z.ZodString;
55
+ }, "strict", z.ZodTypeAny, {
56
+ objective: string;
57
+ }, {
58
+ objective: string;
59
+ }>;
60
+ readonly mar_skills: z.ZodObject<{
61
+ action: z.ZodLiteral<"use">;
62
+ instruction: z.ZodString;
63
+ skills: z.ZodArray<z.ZodObject<{
64
+ name: z.ZodString;
65
+ source: z.ZodEnum<["NODE_HOME", "WORKSPACE"]>;
66
+ path: z.ZodString;
67
+ }, "strict", z.ZodTypeAny, {
68
+ path: string;
69
+ name: string;
70
+ source: "NODE_HOME" | "WORKSPACE";
71
+ }, {
72
+ path: string;
73
+ name: string;
74
+ source: "NODE_HOME" | "WORKSPACE";
75
+ }>, "many">;
76
+ }, "strict", z.ZodTypeAny, {
77
+ action: "use";
78
+ instruction: string;
79
+ skills: {
80
+ path: string;
81
+ name: string;
82
+ source: "NODE_HOME" | "WORKSPACE";
83
+ }[];
84
+ }, {
85
+ action: "use";
86
+ instruction: string;
87
+ skills: {
88
+ path: string;
89
+ name: string;
90
+ source: "NODE_HOME" | "WORKSPACE";
91
+ }[];
92
+ }>;
93
+ readonly mar_references: z.ZodObject<{
94
+ references: z.ZodArray<z.ZodObject<{
95
+ type: z.ZodEnum<["file", "directory"]>;
96
+ path: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
97
+ label: z.ZodString;
98
+ runnerPath: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
99
+ }, "strict", z.ZodTypeAny, {
100
+ path: string;
101
+ type: "file" | "directory";
102
+ label: string;
103
+ runnerPath?: string | undefined;
104
+ }, {
105
+ path: string;
106
+ type: "file" | "directory";
107
+ label: string;
108
+ runnerPath?: string | undefined;
109
+ }>, "many">;
110
+ }, "strict", z.ZodTypeAny, {
111
+ references: {
112
+ path: string;
113
+ type: "file" | "directory";
114
+ label: string;
115
+ runnerPath?: string | undefined;
116
+ }[];
117
+ }, {
118
+ references: {
119
+ path: string;
120
+ type: "file" | "directory";
121
+ label: string;
122
+ runnerPath?: string | undefined;
123
+ }[];
124
+ }>;
125
+ };
126
+ export type ComposerTagName = keyof typeof composerTagSchemas;
127
+ export type ComposerTagPayloads = {
128
+ [K in ComposerTagName]: z.infer<(typeof composerTagSchemas)[K]>;
129
+ };
130
+ export type ComposerAttachmentFile = ComposerTagPayloads['mar_attachments']['files'][number];
131
+ export type ComposerFileReference = ComposerTagPayloads['mar_references']['references'][number];
132
+ export type ComposerTagPart = {
133
+ readonly kind: 'text';
134
+ readonly text: string;
135
+ } | {
136
+ [K in ComposerTagName]: {
137
+ readonly kind: K;
138
+ readonly payload: ComposerTagPayloads[K];
139
+ readonly raw: string;
140
+ };
141
+ }[ComposerTagName];
142
+ export declare const COMPOSER_SKILL_INSTRUCTION = "Use the selected skills for this task; load them through the available skill mechanism.";
143
+ export declare function serializeComposerTag<K extends ComposerTagName>(kind: K, payload: ComposerTagPayloads[K]): string;
144
+ export declare function parseComposerTags(text: string): readonly ComposerTagPart[];
145
+ export declare function composerVisibleText(text: string): string;
@@ -0,0 +1,101 @@
1
+ import { z } from 'zod';
2
+ const path = z.string().min(1).max(4096);
3
+ const name = z.string().min(1).max(512);
4
+ const MAX_COMPOSER_TAG_BYTES = 128 * 1024;
5
+ const relativePath = path.refine((value) => !/^(?:[\\/]|[A-Za-z]:)/u.test(value));
6
+ const workspacePath = relativePath.refine((value) => !value.split(/[\\/]/u).includes('..'));
7
+ const attachment = z
8
+ .object({
9
+ name,
10
+ mime: z.string().min(1).max(128),
11
+ path: relativePath,
12
+ workspacePath: workspacePath.optional()
13
+ })
14
+ .strict()
15
+ .refine((value) => {
16
+ const target = value.workspacePath ?? value.path;
17
+ return workspacePath.safeParse(target).success && target.startsWith('.mar/temp-files/');
18
+ });
19
+ export const composerTagSchemas = {
20
+ mar_goal_start: z.object({ objective: z.string().max(100_000) }).strict(),
21
+ mar_goal_continue: z.object({}).strict(),
22
+ mar_attachments: z.object({ files: z.array(attachment).min(1).max(5) }).strict(),
23
+ mar_schedule: z.object({ objective: z.string().min(1).max(100_000) }).strict(),
24
+ mar_skills: z
25
+ .object({
26
+ action: z.literal('use'),
27
+ instruction: z.string().min(1).max(512),
28
+ skills: z
29
+ .array(z.object({ name, source: z.enum(['NODE_HOME', 'WORKSPACE']), path }).strict())
30
+ .min(1)
31
+ .max(128)
32
+ })
33
+ .strict(),
34
+ mar_references: z
35
+ .object({
36
+ references: z
37
+ .array(z
38
+ .object({
39
+ type: z.enum(['file', 'directory']),
40
+ path: workspacePath,
41
+ label: name,
42
+ runnerPath: relativePath.optional()
43
+ })
44
+ .strict())
45
+ .min(1)
46
+ .max(128)
47
+ })
48
+ .strict()
49
+ };
50
+ export const COMPOSER_SKILL_INSTRUCTION = 'Use the selected skills for this task; load them through the available skill mechanism.';
51
+ export function serializeComposerTag(kind, payload) {
52
+ const parsed = composerTagSchemas[kind].safeParse(payload);
53
+ if (!parsed.success)
54
+ throw new Error('COMPOSER_TAG_INVALID');
55
+ const encoded = JSON.stringify(parsed.data).replaceAll('<', '\\u003c');
56
+ if (new TextEncoder().encode(encoded).byteLength > MAX_COMPOSER_TAG_BYTES)
57
+ throw new Error('COMPOSER_TAG_INVALID');
58
+ return `<${kind}>\n${encoded}\n</${kind}>`;
59
+ }
60
+ export function parseComposerTags(text) {
61
+ const parts = [];
62
+ const pattern = /<(mar_goal_start|mar_goal_continue|mar_attachments|mar_schedule|mar_skills|mar_references)>([\s\S]*?)<\/\1>/gu;
63
+ let offset = 0;
64
+ for (const match of text.matchAll(pattern)) {
65
+ const kind = match[1];
66
+ const encoded = match[2];
67
+ if (new TextEncoder().encode(encoded).byteLength > MAX_COMPOSER_TAG_BYTES)
68
+ continue;
69
+ let payload;
70
+ try {
71
+ payload = JSON.parse(encoded);
72
+ }
73
+ catch {
74
+ continue;
75
+ }
76
+ const result = composerTagSchemas[kind].safeParse(payload);
77
+ if (!result.success)
78
+ continue;
79
+ if (match.index > offset)
80
+ parts.push({ kind: 'text', text: text.slice(offset, match.index) });
81
+ parts.push({ kind, payload: result.data, raw: match[0] });
82
+ offset = match.index + match[0].length;
83
+ }
84
+ if (offset < text.length)
85
+ parts.push({ kind: 'text', text: text.slice(offset) });
86
+ return parts;
87
+ }
88
+ export function composerVisibleText(text) {
89
+ return parseComposerTags(text)
90
+ .map((part) => {
91
+ if (part.kind === 'text')
92
+ return part.text;
93
+ if (part.kind === 'mar_goal_start')
94
+ return part.payload.objective;
95
+ if (part.kind === 'mar_schedule')
96
+ return part.payload.objective;
97
+ return '';
98
+ })
99
+ .join('')
100
+ .trim();
101
+ }
@@ -113,11 +113,11 @@ export declare const directTransferDescriptorSchema: z.ZodUnion<[z.ZodEffects<z.
113
113
  id: z.ZodString;
114
114
  mime: z.ZodString;
115
115
  }, "strict", z.ZodTypeAny, {
116
- id: string;
117
116
  mime: string;
118
- }, {
119
117
  id: string;
118
+ }, {
120
119
  mime: string;
120
+ id: string;
121
121
  }>>;
122
122
  }, "strict", z.ZodTypeAny, {
123
123
  resource: {
@@ -139,8 +139,8 @@ export declare const directTransferDescriptorSchema: z.ZodUnion<[z.ZodEffects<z.
139
139
  overwrite?: boolean | undefined;
140
140
  resumeOffset?: number | undefined;
141
141
  composerAttachment?: {
142
- id: string;
143
142
  mime: string;
143
+ id: string;
144
144
  } | undefined;
145
145
  }, {
146
146
  resource: {
@@ -162,8 +162,8 @@ export declare const directTransferDescriptorSchema: z.ZodUnion<[z.ZodEffects<z.
162
162
  overwrite?: boolean | undefined;
163
163
  resumeOffset?: number | undefined;
164
164
  composerAttachment?: {
165
- id: string;
166
165
  mime: string;
166
+ id: string;
167
167
  } | undefined;
168
168
  }>, {
169
169
  resource: {
@@ -185,8 +185,8 @@ export declare const directTransferDescriptorSchema: z.ZodUnion<[z.ZodEffects<z.
185
185
  overwrite?: boolean | undefined;
186
186
  resumeOffset?: number | undefined;
187
187
  composerAttachment?: {
188
- id: string;
189
188
  mime: string;
189
+ id: string;
190
190
  } | undefined;
191
191
  }, {
192
192
  resource: {
@@ -208,8 +208,8 @@ export declare const directTransferDescriptorSchema: z.ZodUnion<[z.ZodEffects<z.
208
208
  overwrite?: boolean | undefined;
209
209
  resumeOffset?: number | undefined;
210
210
  composerAttachment?: {
211
- id: string;
212
211
  mime: string;
212
+ id: string;
213
213
  } | undefined;
214
214
  }>, z.ZodEffects<z.ZodObject<{
215
215
  resource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
@@ -429,11 +429,11 @@ export declare const directPrepareRequestSchema: z.ZodDiscriminatedUnion<"purpos
429
429
  id: z.ZodString;
430
430
  mime: z.ZodString;
431
431
  }, "strict", z.ZodTypeAny, {
432
- id: string;
433
432
  mime: string;
434
- }, {
435
433
  id: string;
434
+ }, {
436
435
  mime: string;
436
+ id: string;
437
437
  }>>;
438
438
  }, "strict", z.ZodTypeAny, {
439
439
  resource: {
@@ -455,8 +455,8 @@ export declare const directPrepareRequestSchema: z.ZodDiscriminatedUnion<"purpos
455
455
  overwrite?: boolean | undefined;
456
456
  resumeOffset?: number | undefined;
457
457
  composerAttachment?: {
458
- id: string;
459
458
  mime: string;
459
+ id: string;
460
460
  } | undefined;
461
461
  }, {
462
462
  resource: {
@@ -478,8 +478,8 @@ export declare const directPrepareRequestSchema: z.ZodDiscriminatedUnion<"purpos
478
478
  overwrite?: boolean | undefined;
479
479
  resumeOffset?: number | undefined;
480
480
  composerAttachment?: {
481
- id: string;
482
481
  mime: string;
482
+ id: string;
483
483
  } | undefined;
484
484
  }>, {
485
485
  resource: {
@@ -501,8 +501,8 @@ export declare const directPrepareRequestSchema: z.ZodDiscriminatedUnion<"purpos
501
501
  overwrite?: boolean | undefined;
502
502
  resumeOffset?: number | undefined;
503
503
  composerAttachment?: {
504
- id: string;
505
504
  mime: string;
505
+ id: string;
506
506
  } | undefined;
507
507
  }, {
508
508
  resource: {
@@ -524,8 +524,8 @@ export declare const directPrepareRequestSchema: z.ZodDiscriminatedUnion<"purpos
524
524
  overwrite?: boolean | undefined;
525
525
  resumeOffset?: number | undefined;
526
526
  composerAttachment?: {
527
- id: string;
528
527
  mime: string;
528
+ id: string;
529
529
  } | undefined;
530
530
  }>, z.ZodEffects<z.ZodObject<{
531
531
  resource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
@@ -696,8 +696,8 @@ export declare const directPrepareRequestSchema: z.ZodDiscriminatedUnion<"purpos
696
696
  overwrite?: boolean | undefined;
697
697
  resumeOffset?: number | undefined;
698
698
  composerAttachment?: {
699
- id: string;
700
699
  mime: string;
700
+ id: string;
701
701
  } | undefined;
702
702
  } | {
703
703
  resource: {
@@ -749,8 +749,8 @@ export declare const directPrepareRequestSchema: z.ZodDiscriminatedUnion<"purpos
749
749
  overwrite?: boolean | undefined;
750
750
  resumeOffset?: number | undefined;
751
751
  composerAttachment?: {
752
- id: string;
753
752
  mime: string;
753
+ id: string;
754
754
  } | undefined;
755
755
  } | {
756
756
  resource: {
@@ -927,11 +927,11 @@ export declare const directBrowserMessageSchema: z.ZodUnion<[z.ZodDiscriminatedU
927
927
  id: z.ZodString;
928
928
  mime: z.ZodString;
929
929
  }, "strict", z.ZodTypeAny, {
930
- id: string;
931
930
  mime: string;
932
- }, {
933
931
  id: string;
932
+ }, {
934
933
  mime: string;
934
+ id: string;
935
935
  }>>;
936
936
  }, "strict", z.ZodTypeAny, {
937
937
  resource: {
@@ -953,8 +953,8 @@ export declare const directBrowserMessageSchema: z.ZodUnion<[z.ZodDiscriminatedU
953
953
  overwrite?: boolean | undefined;
954
954
  resumeOffset?: number | undefined;
955
955
  composerAttachment?: {
956
- id: string;
957
956
  mime: string;
957
+ id: string;
958
958
  } | undefined;
959
959
  }, {
960
960
  resource: {
@@ -976,8 +976,8 @@ export declare const directBrowserMessageSchema: z.ZodUnion<[z.ZodDiscriminatedU
976
976
  overwrite?: boolean | undefined;
977
977
  resumeOffset?: number | undefined;
978
978
  composerAttachment?: {
979
- id: string;
980
979
  mime: string;
980
+ id: string;
981
981
  } | undefined;
982
982
  }>, {
983
983
  resource: {
@@ -999,8 +999,8 @@ export declare const directBrowserMessageSchema: z.ZodUnion<[z.ZodDiscriminatedU
999
999
  overwrite?: boolean | undefined;
1000
1000
  resumeOffset?: number | undefined;
1001
1001
  composerAttachment?: {
1002
- id: string;
1003
1002
  mime: string;
1003
+ id: string;
1004
1004
  } | undefined;
1005
1005
  }, {
1006
1006
  resource: {
@@ -1022,8 +1022,8 @@ export declare const directBrowserMessageSchema: z.ZodUnion<[z.ZodDiscriminatedU
1022
1022
  overwrite?: boolean | undefined;
1023
1023
  resumeOffset?: number | undefined;
1024
1024
  composerAttachment?: {
1025
- id: string;
1026
1025
  mime: string;
1026
+ id: string;
1027
1027
  } | undefined;
1028
1028
  }>, z.ZodEffects<z.ZodObject<{
1029
1029
  resource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
@@ -1194,8 +1194,8 @@ export declare const directBrowserMessageSchema: z.ZodUnion<[z.ZodDiscriminatedU
1194
1194
  overwrite?: boolean | undefined;
1195
1195
  resumeOffset?: number | undefined;
1196
1196
  composerAttachment?: {
1197
- id: string;
1198
1197
  mime: string;
1198
+ id: string;
1199
1199
  } | undefined;
1200
1200
  } | {
1201
1201
  resource: {
@@ -1247,8 +1247,8 @@ export declare const directBrowserMessageSchema: z.ZodUnion<[z.ZodDiscriminatedU
1247
1247
  overwrite?: boolean | undefined;
1248
1248
  resumeOffset?: number | undefined;
1249
1249
  composerAttachment?: {
1250
- id: string;
1251
1250
  mime: string;
1251
+ id: string;
1252
1252
  } | undefined;
1253
1253
  } | {
1254
1254
  resource: {
@@ -1737,11 +1737,11 @@ export declare const directNodeCommandSchema: z.ZodUnion<[z.ZodObject<{
1737
1737
  id: z.ZodString;
1738
1738
  mime: z.ZodString;
1739
1739
  }, "strict", z.ZodTypeAny, {
1740
- id: string;
1741
1740
  mime: string;
1742
- }, {
1743
1741
  id: string;
1742
+ }, {
1744
1743
  mime: string;
1744
+ id: string;
1745
1745
  }>>;
1746
1746
  }, "strict", z.ZodTypeAny, {
1747
1747
  resource: {
@@ -1763,8 +1763,8 @@ export declare const directNodeCommandSchema: z.ZodUnion<[z.ZodObject<{
1763
1763
  overwrite?: boolean | undefined;
1764
1764
  resumeOffset?: number | undefined;
1765
1765
  composerAttachment?: {
1766
- id: string;
1767
1766
  mime: string;
1767
+ id: string;
1768
1768
  } | undefined;
1769
1769
  }, {
1770
1770
  resource: {
@@ -1786,8 +1786,8 @@ export declare const directNodeCommandSchema: z.ZodUnion<[z.ZodObject<{
1786
1786
  overwrite?: boolean | undefined;
1787
1787
  resumeOffset?: number | undefined;
1788
1788
  composerAttachment?: {
1789
- id: string;
1790
1789
  mime: string;
1790
+ id: string;
1791
1791
  } | undefined;
1792
1792
  }>, {
1793
1793
  resource: {
@@ -1809,8 +1809,8 @@ export declare const directNodeCommandSchema: z.ZodUnion<[z.ZodObject<{
1809
1809
  overwrite?: boolean | undefined;
1810
1810
  resumeOffset?: number | undefined;
1811
1811
  composerAttachment?: {
1812
- id: string;
1813
1812
  mime: string;
1813
+ id: string;
1814
1814
  } | undefined;
1815
1815
  }, {
1816
1816
  resource: {
@@ -1832,8 +1832,8 @@ export declare const directNodeCommandSchema: z.ZodUnion<[z.ZodObject<{
1832
1832
  overwrite?: boolean | undefined;
1833
1833
  resumeOffset?: number | undefined;
1834
1834
  composerAttachment?: {
1835
- id: string;
1836
1835
  mime: string;
1836
+ id: string;
1837
1837
  } | undefined;
1838
1838
  }>, z.ZodEffects<z.ZodObject<{
1839
1839
  resource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
@@ -2004,8 +2004,8 @@ export declare const directNodeCommandSchema: z.ZodUnion<[z.ZodObject<{
2004
2004
  overwrite?: boolean | undefined;
2005
2005
  resumeOffset?: number | undefined;
2006
2006
  composerAttachment?: {
2007
- id: string;
2008
2007
  mime: string;
2008
+ id: string;
2009
2009
  } | undefined;
2010
2010
  } | {
2011
2011
  resource: {
@@ -2059,8 +2059,8 @@ export declare const directNodeCommandSchema: z.ZodUnion<[z.ZodObject<{
2059
2059
  overwrite?: boolean | undefined;
2060
2060
  resumeOffset?: number | undefined;
2061
2061
  composerAttachment?: {
2062
- id: string;
2063
2062
  mime: string;
2063
+ id: string;
2064
2064
  } | undefined;
2065
2065
  } | {
2066
2066
  resource: {
@@ -80,7 +80,7 @@ export declare const resourceGrantSchema: z.ZodEffects<z.ZodObject<{
80
80
  }, "strict", z.ZodTypeAny, {
81
81
  id: string;
82
82
  createdAt: number;
83
- resourceType: "NODE" | "WORKSPACE" | "MODEL" | "IMAGE_MODEL" | "TEMPLATE";
83
+ resourceType: "WORKSPACE" | "NODE" | "MODEL" | "IMAGE_MODEL" | "TEMPLATE";
84
84
  targetType: "ORGANIZATION" | "USER";
85
85
  grantScopeOrganizationId: number;
86
86
  createdByUserId: number;
@@ -94,7 +94,7 @@ export declare const resourceGrantSchema: z.ZodEffects<z.ZodObject<{
94
94
  }, {
95
95
  id: string;
96
96
  createdAt: number;
97
- resourceType: "NODE" | "WORKSPACE" | "MODEL" | "IMAGE_MODEL" | "TEMPLATE";
97
+ resourceType: "WORKSPACE" | "NODE" | "MODEL" | "IMAGE_MODEL" | "TEMPLATE";
98
98
  targetType: "ORGANIZATION" | "USER";
99
99
  grantScopeOrganizationId: number;
100
100
  createdByUserId: number;
@@ -108,7 +108,7 @@ export declare const resourceGrantSchema: z.ZodEffects<z.ZodObject<{
108
108
  }>, {
109
109
  id: string;
110
110
  createdAt: number;
111
- resourceType: "NODE" | "WORKSPACE" | "MODEL" | "IMAGE_MODEL" | "TEMPLATE";
111
+ resourceType: "WORKSPACE" | "NODE" | "MODEL" | "IMAGE_MODEL" | "TEMPLATE";
112
112
  targetType: "ORGANIZATION" | "USER";
113
113
  grantScopeOrganizationId: number;
114
114
  createdByUserId: number;
@@ -122,7 +122,7 @@ export declare const resourceGrantSchema: z.ZodEffects<z.ZodObject<{
122
122
  }, {
123
123
  id: string;
124
124
  createdAt: number;
125
- resourceType: "NODE" | "WORKSPACE" | "MODEL" | "IMAGE_MODEL" | "TEMPLATE";
125
+ resourceType: "WORKSPACE" | "NODE" | "MODEL" | "IMAGE_MODEL" | "TEMPLATE";
126
126
  targetType: "ORGANIZATION" | "USER";
127
127
  grantScopeOrganizationId: number;
128
128
  createdByUserId: number;