@myagentroam/protocol 0.10.3 → 0.10.4

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.
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ export declare function isComposerAttachmentResourcePath(value: string): boolean;
2
3
  export declare const composerTagSchemas: {
3
4
  readonly mar_goal_start: z.ZodObject<{
4
5
  objective: z.ZodString;
@@ -12,7 +13,7 @@ export declare const composerTagSchemas: {
12
13
  files: z.ZodArray<z.ZodEffects<z.ZodObject<{
13
14
  name: z.ZodString;
14
15
  mime: z.ZodString;
15
- path: z.ZodEffects<z.ZodString, string, string>;
16
+ path: z.ZodString;
16
17
  workspacePath: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
17
18
  }, "strict", z.ZodTypeAny, {
18
19
  path: string;
@@ -4,17 +4,23 @@ const name = z.string().min(1).max(512);
4
4
  const MAX_COMPOSER_TAG_BYTES = 128 * 1024;
5
5
  const relativePath = path.refine((value) => !/^(?:[\\/]|[A-Za-z]:)/u.test(value));
6
6
  const workspacePath = relativePath.refine((value) => !value.split(/[\\/]/u).includes('..'));
7
+ export function isComposerAttachmentResourcePath(value) {
8
+ return (/^mar-attachment:\/\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\/[^/\\\0]+$/u.test(value) && !value.split('/').includes('..'));
9
+ }
7
10
  const attachment = z
8
11
  .object({
9
12
  name,
10
13
  mime: z.string().min(1).max(128),
11
- path: relativePath,
14
+ path,
12
15
  workspacePath: workspacePath.optional()
13
16
  })
14
17
  .strict()
15
18
  .refine((value) => {
16
19
  const target = value.workspacePath ?? value.path;
17
- return workspacePath.safeParse(target).success && target.startsWith('.mar/temp-files/');
20
+ return (isComposerAttachmentResourcePath(target) ||
21
+ (relativePath.safeParse(value.path).success &&
22
+ workspacePath.safeParse(target).success &&
23
+ target.startsWith('.mar/temp-files/')));
18
24
  });
19
25
  export const composerTagSchemas = {
20
26
  mar_goal_start: z.object({ objective: z.string().max(100_000) }).strict(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/protocol",
3
- "version": "0.10.3",
3
+ "version": "0.10.4",
4
4
  "description": "Shared runtime protocol schemas for MyAgentRoam.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",