Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ yarn.lock
run.sh
*.tmp
*.log

# Dist folders in tools
/tools/**/dist/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@buf:registry=https://buf.build/gen/npm/v1
19 changes: 16 additions & 3 deletions buf.gen.ts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ plugins:
- outputClientImpl=grpc-js # Generate client implementations
- env=node # Node.js environment
- esModuleInterop=true # Better import compatibility

# Index generation
- outputIndex=true # Generate index.ts files
- exportCommonSymbols=false # Don't re-export common protobuf symbols

# Type safety
- useOptionals=messages # Optional fields as T | undefined
- useDate=true # Use Date instead of Timestamp
Expand All @@ -42,3 +41,17 @@ plugins:

# Code style
- esLintDisable=true # Add eslint-disable comments

# ==========================================
# Zod Schema Generation (with buf.validate support)
# ==========================================

# protoc-gen-zod generates Zod schemas from proto definitions
# Reads buf.validate annotations and converts them to Zod validations
- local:
- node
- ./tools/zod/dist/index.js
out: gen/typescript
opt:
- target=ts
- include_responses=true
44 changes: 24 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
"name": "@digitalkin/agentic-mesh-protocol",
"version": "1.0.0",
"description": "Node.js gRPC interfaces for Agentic Mesh Protocol - Protocol Buffer definitions for multi-agent systems",
"type": "module",
"type": "commonjs",
"main": "index.ts",
"types": "index.ts",
"files": [
"index.ts",
"gen/typescript/**/*.ts",
"gen/typescript/**/*.js",
"gen/typescript/**/*.d.ts",
"gen/descriptor.bin",
"gen/descriptor.json",
"proto/**/*.proto",
"buf.yaml",
"buf.gen.ts.yaml"
"gen/typescript/**/*.ts",
"gen/typescript/**/*.js",
"gen/typescript/**/*.d.ts",
"gen/descriptor.bin",
"gen/descriptor.json",
"proto/**/*.proto",
"buf.gen.ts.yaml"
],
"scripts": {
"deps:update": "npx buf dep update proto",
"generate": "npx buf generate --template buf.gen.ts.yaml && tsc -p tsconfig.gen.json",
"generate:reflection": "npx buf build proto -o gen/descriptor.bin && npx buf build proto -o gen/descriptor.json",
"build:zod-plugin": "tsc --project ./tools/zod/tsconfig.json",
"generate": "npm run build:zod-plugin && npx buf generate --template buf.gen.ts.yaml && tsc -p tsconfig.gen.json",
"generate:reflection": "npx buf build proto -o gen/descriptor.bin && npx buf build proto -o gen/descriptor.json",
"build": "npm run generate",
"prepare": "npm run generate && npm run generate:reflection",
"clean": "rm -rf gen/",
"clean": "rm -rf gen/ && rm -rf tools/zod/dist/",
"prepublishOnly": "npm run build"
},
"keywords": [
Expand All @@ -45,18 +44,23 @@
},
"homepage": "https://github.com/DigitalKin-ai/agentic-mesh-protocol#readme",
"dependencies": {
"@grpc/grpc-js": "^1.14.2",
"google-protobuf": "^4.0.1"
"@grpc/grpc-js": "^1.14.3",
"google-protobuf": "^4.0.1",
"zod": "^4.3.6"
},
"peerDependencies": {
"@bufbuild/protobuf": "^2.0.0"
"@bufbuild/protobuf": "^2.11.0",
"zod": "^4.3.6"
},
"devDependencies": {
"@bufbuild/buf": "1.61.0",
"@buf/bufbuild_protovalidate.bufbuild_es": "^2.11.0-20251209175733-2a1774d88802.1",
"@bufbuild/buf": "1.65.0",
"@bufbuild/protobuf": "^2.11.0",
"@bufbuild/protoplugin": "^2.11.0",
"@types/google-protobuf": "^3.15.12",
"@types/node": "^24.10.1",
"ts-proto": "^2.8.3",
"typescript": "^5.8.0"
"@types/node": "^25.2.0",
"ts-proto": "^2.11.2",
"typescript": "^5.9.3"
},
"engines": {
"node": ">=18.0.0"
Expand Down
20 changes: 10 additions & 10 deletions proto/agentic_mesh_protocol/filesystem/v1/filesystem.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ enum FileStatus {

// File represents a stored file with comprehensive metadata.
message File {
// file_id: Unique identifier for the file (UUID)
// file_id: Unique identifier for the file
string file_id = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
(buf.validate.field).string.pattern = "^files:.*$"
];

// context: Context ID linked to the file
Expand Down Expand Up @@ -131,7 +131,7 @@ message FileFilter {
repeated string names = 1;

// file_ids: Filter by file IDs
repeated string file_ids = 2 [(buf.validate.field).repeated.items.string.uuid = true];
repeated string file_ids = 2 [(buf.validate.field).repeated.items.string.pattern = "^files:.*$"];

// file_types: Filter by file types
repeated FileType file_types = 3 [(buf.validate.field).repeated.items.enum.not_in = 0];
Expand Down Expand Up @@ -166,8 +166,8 @@ message FileFilter {
// max_size_bytes: Filter files with maximum size
int64 max_size_bytes = 12 [(buf.validate.field).int64.gte = 0];

// prefix: Filter by path prefix (e.g., "folder1/")
string prefix = 13 [(buf.validate.field).string.pattern = "^[^/]*/?[^/]*$"];
// prefix: Filter by path prefix (e.g., "/folder1/"). Prevents path traversal (no ".." allowed).
string prefix = 13 [(buf.validate.field).string.pattern = "^[^.]*([.][^.]+)*[.]?$"];

// content_type: Filter by content type
string content_type = 14;
Expand All @@ -189,13 +189,14 @@ message UploadFileData {
// context: Context ID for the file
string context = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.pattern = "^(missions:|setups:).*$"
(buf.validate.field).string.pattern = "(^(missions:|setups:).*$|^default$)"
];

// name: Name of the file
string name = 2 [
(buf.validate.field).required = true,
(buf.validate.field).string.min_len = 1
(buf.validate.field).string.min_len = 1,
(buf.validate.field).string.pattern = "^[^.]*([.][^.]+)*[.]?$"
];

// file_type: Type classification of the file
Expand Down Expand Up @@ -254,14 +255,13 @@ message UploadFilesResponse {
message GetFileRequest {
// context: Context ID for the file
string context = 1 [
(buf.validate.field).required = true,
(buf.validate.field).string.pattern = "^(missions:|setups:).*$"
];

// file_id: File ID
string file_id = 2 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
(buf.validate.field).string.pattern = "^files:.*$"
];

// include_content: Whether to include file content in response
Expand All @@ -288,7 +288,7 @@ message UpdateFileRequest {
// file_id: Current id of the file
string file_id = 2 [
(buf.validate.field).required = true,
(buf.validate.field).string.uuid = true
(buf.validate.field).string.pattern = "^files:.*$"
];

// new_name: New name for the file (optional)
Expand Down
Loading