From 1d57d5d9718ed553458197e6fee35e818710bb69 Mon Sep 17 00:00:00 2001 From: lx-1997 <13500790262@163.com> Date: Tue, 24 Nov 2026 20:10:49 +0800 Subject: [PATCH 1/3] ci: install camera test dependencies before running suites --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5e4820..4dce1f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,14 +30,14 @@ jobs: cache: npm - run: npm ci - run: npm run typecheck - - run: npm test - - name: Tool and plugin regressions - run: node --import tsx --test tools/*.test.mjs tools/*.test.mts plugins/rdk-camera-workshop/mcp/*.test.mjs - uses: actions/setup-python@v5 with: python-version: '3.12' - - name: Install numerical fixture dependency - run: python3 -m pip install 'numpy>=1.24,<3' + - name: Install Python test dependencies + run: python3 -m pip install 'numpy>=1.24,<3' Pillow + - run: npm test + - name: Tool and plugin regressions + run: node --import tsx --test tools/*.test.mjs tools/*.test.mts plugins/rdk-camera-workshop/mcp/*.test.mjs - name: Python camera and release controller regressions run: | set -eu From 3931adc9a2364c8de698439def4954f7c12c0237 Mon Sep 17 00:00:00 2001 From: lx-1997 <13500790262@163.com> Date: Tue, 24 Nov 2026 20:18:40 +0800 Subject: [PATCH 2/3] fix(deps): patch audited production dependencies --- package-lock.json | 170 ++---------------- package.json | 4 +- server/monitoring/alert-config.ts | 2 +- .../collection-workspace-service.ts | 2 +- server/monitoring/data-center-service.ts | 2 +- server/monitoring/edge-llm-service.ts | 2 +- server/monitoring/platform-assistant-tasks.ts | 2 +- server/monitoring/plugin-routes.ts | 2 +- server/monitoring/vision-workshop-ai-model.ts | 2 +- server/monitoring/vision-workshop-routes.ts | 6 +- server/plugins/plugin-types.ts | 2 +- 11 files changed, 27 insertions(+), 169 deletions(-) diff --git a/package-lock.json b/package-lock.json index 72d68fc..b675674 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,8 +15,8 @@ "@supabase/supabase-js": "^2.100.1", "express": "^4.22.2", "pg": "8.21.0", - "undici": "7.30.0", - "zod": "^3.24.0" + "undici": "7.30.1", + "zod": "4.6.7" }, "devDependencies": { "@types/express": "^5.0.0", @@ -276,15 +276,6 @@ "@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-commands/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-compaction": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-compaction/-/dsh-compaction-0.1.1-rc.2.tgz", @@ -322,16 +313,6 @@ "@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-cordis-host-runner/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-credentials": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-credentials/-/dsh-credentials-0.1.1-rc.2.tgz", @@ -359,16 +340,6 @@ "@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-file-reference/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-goal": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-goal/-/dsh-goal-0.1.1-rc.2.tgz", @@ -390,15 +361,6 @@ "@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-goal/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-home-paths": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-home-paths/-/dsh-home-paths-0.1.1-rc.2.tgz", @@ -452,15 +414,6 @@ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-host-apiproxy/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-host-directory-picker": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-host-directory-picker/-/dsh-host-directory-picker-0.1.1-rc.2.tgz", @@ -488,16 +441,6 @@ "@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-host-plugin-inventory/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-host-webserver": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-host-webserver/-/dsh-host-webserver-0.1.1-rc.2.tgz", @@ -575,16 +518,6 @@ "@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-message-feedback/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-native-command": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-native-command/-/dsh-native-command-0.1.1-rc.2.tgz", @@ -676,24 +609,6 @@ "@deepseek-ai/dsh-storage-domain": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-session-projection-cache/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, - "node_modules/@deepseek-ai/dsh-session-projection/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-session-query": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session-query/-/dsh-session-query-0.1.1-rc.2.tgz", @@ -736,16 +651,6 @@ "@deepseek-ai/dsh-typert-protocol": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-session-reference/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-session-title": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session-title/-/dsh-session-title-0.1.1-rc.2.tgz", @@ -764,15 +669,6 @@ "@deepseek-ai/dsh-session-projection": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-session-title/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-settings": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-settings/-/dsh-settings-0.1.1-rc.2.tgz", @@ -827,16 +723,6 @@ "@deepseek-ai/dsh-storage": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-storage-domain/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-subagent": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-subagent/-/dsh-subagent-0.1.1-rc.2.tgz", @@ -890,15 +776,6 @@ } } }, - "node_modules/@deepseek-ai/dsh-subagent/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-system-prompt": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-system-prompt/-/dsh-system-prompt-0.1.1-rc.2.tgz", @@ -971,16 +848,6 @@ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-typert-registry/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/dsh-user-approval": { "version": "0.1.1-rc.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-user-approval/-/dsh-user-approval-0.1.1-rc.2.tgz", @@ -1030,15 +897,6 @@ "@deepseek-ai/dsh-storage-domain": "^0.1.1-rc.2" } }, - "node_modules/@deepseek-ai/dsh-workspace/node_modules/zod": { - "version": "4.6.5", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.5.tgz", - "integrity": "sha512-v5l/aFXZQeai4awLbOpSoHecE9UiMrnfx75tEXLjNonXVARxQ5mOeipTjROUchszUNCqnE+hqAMujRsRHsut2Q==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } - }, "node_modules/@deepseek-ai/schemastery": { "version": "3.18.2", "resolved": "https://registry.npmjs.org/@deepseek-ai/schemastery/-/schemastery-3.18.2.tgz", @@ -1835,9 +1693,9 @@ "license": "MIT" }, "node_modules/body-parser": { - "version": "1.20.8", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.8.tgz", - "integrity": "sha512-JNcyFQ64OiijEkPzUBTCe+hyPXUD/3LEldGQ6iF5LR1w00mx9o7xtDWHXBY2iItjdCFGoilOLNQbH943ut7pHA==", + "version": "1.20.9", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.9.tgz", + "integrity": "sha512-FISIQxV5u91Y9gvuFq3q/tA/qTqLJn3AhRcEvyozyhJTh5OBFFtv827AdHU7Rbyct4r+Ba1/99oFa1Y3yuFsdw==", "license": "MIT", "dependencies": { "bytes": "~3.1.2", @@ -2709,9 +2567,9 @@ } }, "node_modules/qs": { - "version": "6.16.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", - "integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==", + "version": "6.16.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.2.tgz", + "integrity": "sha512-VYdnB5S7/0IeXzBacUtwNAaM6d7Y/PgYnNC7bJCI6meqA/OgnsQbZMtVW8Dt2D1PHgbHGtYmhSoEIgvt7xZ2ZA==", "license": "BSD-3-Clause", "dependencies": { "es-define-property": "^1.0.1", @@ -3012,9 +2870,9 @@ } }, "node_modules/undici": { - "version": "7.30.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-7.30.0.tgz", - "integrity": "sha512-dkrQXeHSaoamnItlYbmzG0wFYrM0ZwDxCIg0A7aKjTyyhh9svRzCNFEzV+Vm05/yehjCzjDZ31KXfGEjYSztDQ==", + "version": "7.30.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.30.1.tgz", + "integrity": "sha512-03KrMbjIFDWQR5RNPrSw3bd1r12JpyFQl9/yxjUbJtqkjmllqC5lFjZh6ujeuJCKr8EOQvRW872Oy/az+nLYxg==", "license": "MIT", "engines": { "node": ">=20.18.1" @@ -3138,9 +2996,9 @@ } }, "node_modules/zod": { - "version": "3.25.76", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz", - "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", + "version": "4.6.7", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz", + "integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" diff --git a/package.json b/package.json index 538340d..6651af4 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "@supabase/supabase-js": "^2.100.1", "express": "^4.22.2", "pg": "8.21.0", - "undici": "7.30.0", - "zod": "^3.24.0" + "undici": "7.30.1", + "zod": "4.6.7" }, "devDependencies": { "@types/express": "^5.0.0", diff --git a/server/monitoring/alert-config.ts b/server/monitoring/alert-config.ts index 8dc799d..d9fc82b 100644 --- a/server/monitoring/alert-config.ts +++ b/server/monitoring/alert-config.ts @@ -806,7 +806,7 @@ const alertConfigSchema = z postgres: z.array(z.string().trim().min(2).max(160)).max(30), }) .strict(), - rules: z.record(z.enum(ruleKeys), ruleSchema), + rules: z.partialRecord(z.enum(ruleKeys), ruleSchema), preservedRules: z.record(z.string(), z.unknown()).default({}), }) .strict() diff --git a/server/monitoring/collection-workspace-service.ts b/server/monitoring/collection-workspace-service.ts index a3f9285..d3cea15 100644 --- a/server/monitoring/collection-workspace-service.ts +++ b/server/monitoring/collection-workspace-service.ts @@ -83,7 +83,7 @@ function safeConfig(value: unknown): boolean { }; return !!value && typeof value === 'object' && !Array.isArray(value) && visit(value, 0) && Buffer.byteLength(JSON.stringify(value)) <= 16 * 1024; } -const configSchema = z.record(z.unknown()).refine(safeConfig); +const configSchema = z.record(z.string(), z.unknown()).refine(safeConfig); const filterSchema = z.object({ keywords: z.array(short(100)).min(1).max(20), mode: z.enum(['include', 'exclude']) }).strict(); const qualitySchema = z.object({ minBytes: z.number().int().min(0).max(MAX_ARTIFACT_BYTES) }).strict(); const recipeSchema = z.object({ name: short(160), project: short(120), source: z.enum(['cloud', 'edge']), moduleId: opaque, moduleVersion: z.literal('1.0.0'), config: configSchema, filter: filterSchema.optional(), quality: qualitySchema.optional(), createDataset: z.boolean() }).strict(); diff --git a/server/monitoring/data-center-service.ts b/server/monitoring/data-center-service.ts index 4fade01..f414539 100644 --- a/server/monitoring/data-center-service.ts +++ b/server/monitoring/data-center-service.ts @@ -41,7 +41,7 @@ const taskSchema = taskInputSchema.extend({ id: uuid, status: z.enum(['planned', const datasetSchema = datasetInputSchema.extend({ id: uuid, version: z.number().int().min(1), assets: z.array(assetSchema).min(1).max(MAX_DATASET_ASSETS), createdAt: stamp }).strict(); const evidenceSchema = evidenceInputSchema.extend({ id: uuid, sha256: sha, createdAt: stamp, measurementSource: z.literal('reported').optional(), improvement: z.number().finite().optional(), passed: z.boolean().optional(), criterion: criterionSchema.optional() }).strict(); const loopSchema = loopInputSchema.extend({ id: uuid, status: z.enum(['open', 'analyzed', 'evaluated', 'deployed', 'verified', 'verification_failed']), evidence: z.array(evidenceSchema).max(64), createdAt: stamp, updatedAt: stamp }).strict(); -const accountSchema = z.object({ ownerHash: sha, assets: z.array(assetSchema).max(10000), tasks: z.array(taskSchema).max(2000), datasets: z.array(datasetSchema).max(2000), loops: z.array(loopSchema).max(2000), collectionTokens: z.record(sha) }).strict(); +const accountSchema = z.object({ ownerHash: sha, assets: z.array(assetSchema).max(10000), tasks: z.array(taskSchema).max(2000), datasets: z.array(datasetSchema).max(2000), loops: z.array(loopSchema).max(2000), collectionTokens: z.record(z.string(), sha) }).strict(); const storeSchema = z.object({ schemaVersion: z.literal(1), accounts: z.array(accountSchema).max(2000) }).strict(); const envelopeSchema = z.object({ sha256: sha, payload: storeSchema }).strict(); type Store = z.infer; diff --git a/server/monitoring/edge-llm-service.ts b/server/monitoring/edge-llm-service.ts index 0159c96..fc00a31 100644 --- a/server/monitoring/edge-llm-service.ts +++ b/server/monitoring/edge-llm-service.ts @@ -15,7 +15,7 @@ const textSchema = z.string().trim().min(1).max(160).refine((value) => !/[\x00-\ const operationSchema = z.enum(EDGE_LLM_JOB_OPERATIONS); const runnerStatusSchema = z.enum(['queued', 'running', 'succeeded', 'failed', 'unknown']); const timestampSchema = z.string().max(40).refine((value) => /^\d{4}-\d\d-\d\dT/.test(value) && Number.isFinite(Date.parse(value))); -const jsonObjectSchema = z.record(z.unknown()); +const jsonObjectSchema = z.record(z.string(), z.unknown()); const terminal = (status: string) => status === 'succeeded' || status === 'failed' || status === 'superseded'; const hash = (value: string) => createHash('sha256').update(value).digest('hex'); function canonical(value: unknown): unknown { if (Array.isArray(value)) return value.map(canonical); if (value && typeof value === 'object') return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => [key, canonical(item)])); return value; } diff --git a/server/monitoring/platform-assistant-tasks.ts b/server/monitoring/platform-assistant-tasks.ts index 98d3294..cebc46a 100644 --- a/server/monitoring/platform-assistant-tasks.ts +++ b/server/monitoring/platform-assistant-tasks.ts @@ -22,7 +22,7 @@ const revision = z.number().int().positive().max(Number.MAX_SAFE_INTEGER); const stamp = z.string().datetime(); const statusSchema = z.enum(['running', 'awaiting_confirmation', 'completed', 'failed', 'interrupted']); const feedbackSchema = z.enum(['helpful', 'not_helpful']); -const contextSchema = z.record(z.unknown()); +const contextSchema = z.record(z.string(), z.unknown()); const historySchema = z.array(z.object({ role: z.enum(['user', 'assistant']), content: z.string().max(8_000) }).strict()).max(12); const operationSchema = z.object({ id: z.string().min(1).max(512), description: z.string().max(500), status: z.number().int().min(100).max(599), ok: z.boolean(), data: z.unknown() }).strict(); diff --git a/server/monitoring/plugin-routes.ts b/server/monitoring/plugin-routes.ts index 3a32d59..b126ae6 100644 --- a/server/monitoring/plugin-routes.ts +++ b/server/monitoring/plugin-routes.ts @@ -25,7 +25,7 @@ export async function disposeConfiguredPlugins(): Promise { } type Options = { runtime?: PluginRuntime; mcp?: PluginMcpClient; access?: RequestHandler; owner?: (req: Request) => string }; const revisionSchema = z.object({ expectedRevision: z.number().int().min(1) }).strict(); -const argsSchema = z.record(z.unknown()); +const argsSchema = z.record(z.string(), z.unknown()); const queryArgs = (req: Request) => { if (Object.keys(req.query).some(key => !['args', 'tenant'].includes(key)) || (req.query.tenant !== undefined && (typeof req.query.tenant !== 'string' || req.query.tenant.length > 128)) || (req.query.args !== undefined && (typeof req.query.args !== 'string' || req.query.args.length > 8192))) throw new PluginError('plugin_invalid_arguments', 400); if (req.query.args === undefined) return {}; diff --git a/server/monitoring/vision-workshop-ai-model.ts b/server/monitoring/vision-workshop-ai-model.ts index fe8dc16..0988d9e 100644 --- a/server/monitoring/vision-workshop-ai-model.ts +++ b/server/monitoring/vision-workshop-ai-model.ts @@ -30,7 +30,7 @@ type VisionMessage = { role: 'system' | 'user'; content: string | Array<{ type: export type VisionDebugModelCaller = (request: { messages: VisionMessage[]; tools: unknown[]; tool_choice: unknown; signal?: AbortSignal }) => Promise<{ model: string; toolCalls: Array<{ name: string; arguments: string }> }>; const decisionSchema = z.object({ action: z.enum(['adjust', 'keep', 'restore', 'stop']), - values: z.record(z.union([z.number().finite(), z.boolean()])).optional(), + values: z.record(z.string(), z.union([z.number().finite(), z.boolean()])).optional(), patches: z.array(z.object({ path: z.string(), value: z.number().finite(), reason: z.string().trim().min(1).max(240) }).strict()).min(1).max(3).optional(), notes: z.string().trim().min(1).max(1600), assessment: z.object({ improved: z.boolean(), sceneUsable: z.boolean(), goalSatisfied: z.boolean(), diff --git a/server/monitoring/vision-workshop-routes.ts b/server/monitoring/vision-workshop-routes.ts index f106644..4470fe7 100644 --- a/server/monitoring/vision-workshop-routes.ts +++ b/server/monitoring/vision-workshop-routes.ts @@ -44,7 +44,7 @@ const cameraIdentityFields = ['board', 'sensorVendor', 'sensorModel', 'sdkVersio // Only these operations can leave device state unconfirmed; a failed read or a // local storage rejection must not be reported as a possible pending ISP write. const deviceWriteOperations = new Set(['bringup', 'apply_tuning', 'tuning_load', 'controls_set', 'calibration_apply', 'restore_tuning']); -const baselineInput = z.object({ config: z.record(z.unknown()), rules: z.array(z.object({ path: z.string().min(1).max(300), label: shortText, min: z.number().finite(), max: z.number().finite(), step: z.number().finite().positive().optional(), precision: z.enum(['float32', 'seconds-float32-us']).optional() }).strict()).min(1).max(128) }).strict(); +const baselineInput = z.object({ config: z.record(z.string(), z.unknown()), rules: z.array(z.object({ path: z.string().min(1).max(300), label: shortText, min: z.number().finite(), max: z.number().finite(), step: z.number().finite().positive().optional(), precision: z.enum(['float32', 'seconds-float32-us']).optional() }).strict()).min(1).max(128) }).strict(); const candidateInput = z.object({ goal: goalSchema.optional(), frameIds: z.array(id).min(1).max(16).refine(values => new Set(values).size === values.length).optional(), targetAnalysisFrameId: id.optional() }).strict(); const resultInput = z.object({ sampleId: id, candidateId: id.optional(), filename: z.string().max(200).optional(), mimeType: z.enum(['image/png', 'image/jpeg']).optional() }).strict(); const rawMetadataInput = z.object({ scene: z.string().trim().min(1).max(120), width: z.number().int(), height: z.number().int(), bitDepth: z.union([z.literal(8), z.literal(10), z.literal(12), z.literal(14), z.literal(16)]), bayer: z.enum(['RGGB', 'BGGR', 'GRBG', 'GBRG']), packing: z.enum(['unpacked16le', 'mipi-raw10', 'mipi-raw12']), stride: z.number().int(), blackLevel: z.number().int(), whiteLevel: z.number().int(), exposureUs: z.number().finite().optional(), gain: z.number().finite().optional() }).strict(); @@ -169,7 +169,7 @@ export function buildVisionWorkshopMcpTools(router: Router, req: Request, res: R alias('vision_camera_preview_stop', '停止绑定相机的预览会话。', '/device/preview_stop', z.object(experiment).strict(), {}, []), alias('vision_camera_preview_frame', '读取预览会话的实际PNG/JPEG帧,不公开设备地址。', '/device/preview_frame', z.object(experiment).strict(), {}, []), alias('vision_camera_controls_get', '读取相机实际值、支持范围与可写状态;不推测USB gain的物理意义。', '/device/controls_get', z.object(experiment).strict(), {}, []), - alias('vision_camera_controls_set', '只修改设备已支持且可写的数值或布尔控制,核对实际回读。', '/device/controls_set', z.object({ ...experiment, values: z.record(z.union([z.number().finite(), z.boolean()])) }).strict(), { values: { type: 'object', additionalProperties: { type: ['number', 'boolean'] }, minProperties: 1, maxProperties: 64 } }, ['values']), + alias('vision_camera_controls_set', '只修改设备已支持且可写的数值或布尔控制,核对实际回读。', '/device/controls_set', z.object({ ...experiment, values: z.record(z.string(), z.union([z.number().finite(), z.boolean()])) }).strict(), { values: { type: 'object', additionalProperties: { type: ['number', 'boolean'] }, minProperties: 1, maxProperties: 64 } }, ['values']), alias('vision_camera_capture_frame', '归档实际相机PNG/JPEG、场景与控制上下文;明确区别于Bayer Raw。', '/device/capture_frame', z.object({ ...experiment, scene: shortText.optional(), candidateId: id.optional() }).strict(), { scene: { type: 'string', minLength: 1, maxLength: 100 }, candidateId: opaque }, []), alias('vision_raw_capture', '采集并归档一帧真实Raw;请求只包含场景,不接受命令或地址。', '/device/capture_raw', z.object({ ...experiment, scene: z.string().trim().min(1).max(120) }).strict(), { scene: { type: 'string', minLength: 1, maxLength: 120 } }, ['scene']), alias('vision_isp_generate', '根据已归档Raw或与当前基线匹配的PNG相机帧统计及数值规则生成AI候选,保持画质未经验证。', '/candidates', z.object({ ...experiment, goal: goalSchema.optional(), frameIds: z.array(id).min(1).max(16).refine(values => new Set(values).size === values.length).optional() }).strict(), { goal: { type: 'string', minLength: 1, maxLength: 2000 }, frameIds: { type: 'array', items: opaque, minItems: 1, maxItems: 16, uniqueItems: true } }, []), @@ -419,7 +419,7 @@ export function registerVisionWorkshopRoutes(router: Router, options: Options = res.attachment('vision-workshop-' + experimentId + '.zip').type('application/zip').send(createVisionArchive(entries)); }); for (const operation of VISION_DEVICE_OPERATIONS) post('/experiments/:id/device/' + operation, async (req, res) => { - const input = (operation === 'capture_raw' ? z.object({ scene: z.string().trim().min(1).max(120) }).strict() : operation === 'capture_frame' ? z.object({ scene: z.string().trim().min(1).max(120).optional(), candidateId: id.optional() }).strict() : operation === 'process_raw' ? z.object({ sampleId: id, candidateId: id.optional() }).strict() : operation === 'apply_tuning' ? z.object({ candidateId: id }).strict() : operation === 'restore_tuning' ? z.object({ baselineId: id.optional(), candidateId: id.optional() }).strict().refine(value => !(value.baselineId && value.candidateId)) : operation === 'controls_set' ? z.object({ values: z.record(z.union([z.number().finite(), z.boolean()])) }).strict() : operation === 'tuning_load' ? z.object({ contentBase64: z.string().max(24 * 1024 * 1024), sha256: z.string().regex(/^[a-f0-9]{64}$/), artifactRole: z.literal('vendor_effect_library_candidate').optional() }).strict() : operation === 'calibration_apply' ? z.object({ taskId: z.string().uuid(), options: z.object({ illuminantId: z.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/).optional() }).strict().optional() }).strict() : z.object({}).strict()).parse(req.body ?? {}) as { scene?: string; sampleId?: string; candidateId?: string; baselineId?: string; values?: Record; contentBase64?:string;sha256?:string;artifactRole?:'vendor_effect_library_candidate';taskId?:string;options?:{illuminantId?:string} }; + const input = (operation === 'capture_raw' ? z.object({ scene: z.string().trim().min(1).max(120) }).strict() : operation === 'capture_frame' ? z.object({ scene: z.string().trim().min(1).max(120).optional(), candidateId: id.optional() }).strict() : operation === 'process_raw' ? z.object({ sampleId: id, candidateId: id.optional() }).strict() : operation === 'apply_tuning' ? z.object({ candidateId: id }).strict() : operation === 'restore_tuning' ? z.object({ baselineId: id.optional(), candidateId: id.optional() }).strict().refine(value => !(value.baselineId && value.candidateId)) : operation === 'controls_set' ? z.object({ values: z.record(z.string(), z.union([z.number().finite(), z.boolean()])) }).strict() : operation === 'tuning_load' ? z.object({ contentBase64: z.string().max(24 * 1024 * 1024), sha256: z.string().regex(/^[a-f0-9]{64}$/), artifactRole: z.literal('vendor_effect_library_candidate').optional() }).strict() : operation === 'calibration_apply' ? z.object({ taskId: z.string().uuid(), options: z.object({ illuminantId: z.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/).optional() }).strict().optional() }).strict() : z.object({}).strict()).parse(req.body ?? {}) as { scene?: string; sampleId?: string; candidateId?: string; baselineId?: string; values?: Record; contentBase64?:string;sha256?:string;artifactRole?:'vendor_effect_library_candidate';taskId?:string;options?:{illuminantId?:string} }; const owner = visionWorkshopOwner(req); const experimentId = String(req.params.id); const experiment = await service().getExperiment(owner, experimentId); if (!experiment.targetId) throw new VisionWorkshopError('vision_device_adapter_required', 'Create the experiment with a configured adapter targetId', 409); const registry = requestDevices(req); const adapter = registry.get(experiment.targetId); const inputs: Record = {}; diff --git a/server/plugins/plugin-types.ts b/server/plugins/plugin-types.ts index d5880a7..faa3df7 100644 --- a/server/plugins/plugin-types.ts +++ b/server/plugins/plugin-types.ts @@ -9,7 +9,7 @@ export type JsonSchema = { }; const id = z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/); const version = z.string().regex(/^\d+\.\d+\.\d+(?:-[A-Za-z0-9][A-Za-z0-9.-]{0,63})?$/).max(100); -const jsonRecord = z.record(z.unknown()); +const jsonRecord = z.record(z.string(), z.unknown()); const schema = z.custom((v) => !!v && typeof v === 'object' && !Array.isArray(v)); export const pluginManifestSchema = z.object({ schemaVersion: z.literal(1), id, version, label: z.string().min(1).max(120), description: z.string().max(4000), From a23a8cb6d619e833468551a00fd873211bc404b2 Mon Sep 17 00:00:00 2001 From: lx-1997 <67778690+lx-1997@users.noreply.github.com> Date: Tue, 24 Nov 2026 20:24:08 +0800 Subject: [PATCH 3/3] test(camera): verify both offline host diagnostics --- tools/package-camera-workshop-hosts.test.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/package-camera-workshop-hosts.test.mts b/tools/package-camera-workshop-hosts.test.mts index c709e7b..d1f2095 100644 --- a/tools/package-camera-workshop-hosts.test.mts +++ b/tools/package-camera-workshop-hosts.test.mts @@ -36,7 +36,7 @@ test('host distributions remain relocatable with complete hashed payloads and se const child = spawnSync(process.execPath, args, { cwd: temporary, input: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2025-03-26' } }) + '\n', encoding: 'utf8' }); assert.equal(child.status, 0); assert.equal(JSON.parse(child.stdout).result.protocolVersion, '2025-03-26'); const onboarding = spawnSync(process.execPath, args, { cwd: temporary, env: { ...process.env, ...config.env, RDK_CAMERA_WORKSHOP_CONFIG: path.join(temporary, 'missing-config') }, input: JSON.stringify({ jsonrpc: '2.0', id: 2, method: 'tools/list' }) + '\n', encoding: 'utf8' }); - assert.equal(onboarding.status, 0); assert.deepEqual(JSON.parse(onboarding.stdout).result.tools.map((tool: {name: string}) => tool.name), ['vision_connection_status']); + assert.equal(onboarding.status, 0); assert.deepEqual(JSON.parse(onboarding.stdout).result.tools.map((tool: {name: string}) => tool.name), ['vision_connection_status', 'vision_plugin_version']); const fallback = spawnSync(process.execPath, [path.join(relocated, 'mcp/setup.mjs'), 'client-config'], { cwd: temporary, encoding: 'utf8' }); assert.equal(fallback.status, 0); assert.ok(JSON.parse(fallback.stdout).mcpServers['rdk-camera-workshop'].args[0].endsWith(path.join(host, 'mcp/bridge.mjs'))); assert.ok(!(await readdir(plugin)).includes('plugin.json'));