agentic-qe 3.3.4 → 3.4.0
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.
- package/.claude/agents/v3/qe-queen-coordinator.md +332 -166
- package/.claude/helpers/statusline-v3.cjs +85 -42
- package/.claude/skills/qcsd-ideation-swarm/SKILL.md +7 -4
- package/README.md +71 -2
- package/package.json +1 -1
- package/scripts/cloud-db-config.json +10 -5
- package/scripts/merge-v3-to-root.sql +48 -0
- package/v3/CHANGELOG.md +156 -0
- package/v3/README.md +118 -1
- package/v3/assets/agents/v3/qe-queen-coordinator.md +332 -166
- package/v3/assets/skills/qcsd-ideation-swarm/SKILL.md +7 -4
- package/v3/dist/adapters/a2a/agent-cards/generator.d.ts +153 -0
- package/v3/dist/adapters/a2a/agent-cards/generator.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/agent-cards/generator.js +478 -0
- package/v3/dist/adapters/a2a/agent-cards/generator.js.map +1 -0
- package/v3/dist/adapters/a2a/agent-cards/schema.d.ts +274 -0
- package/v3/dist/adapters/a2a/agent-cards/schema.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/agent-cards/schema.js +135 -0
- package/v3/dist/adapters/a2a/agent-cards/schema.js.map +1 -0
- package/v3/dist/adapters/a2a/agent-cards/validator.d.ts +514 -0
- package/v3/dist/adapters/a2a/agent-cards/validator.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/agent-cards/validator.js +555 -0
- package/v3/dist/adapters/a2a/agent-cards/validator.js.map +1 -0
- package/v3/dist/adapters/a2a/auth/index.d.ts +23 -0
- package/v3/dist/adapters/a2a/auth/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/auth/index.js +85 -0
- package/v3/dist/adapters/a2a/auth/index.js.map +1 -0
- package/v3/dist/adapters/a2a/auth/jwt-utils.d.ts +215 -0
- package/v3/dist/adapters/a2a/auth/jwt-utils.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/auth/jwt-utils.js +314 -0
- package/v3/dist/adapters/a2a/auth/jwt-utils.js.map +1 -0
- package/v3/dist/adapters/a2a/auth/middleware.d.ts +173 -0
- package/v3/dist/adapters/a2a/auth/middleware.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/auth/middleware.js +300 -0
- package/v3/dist/adapters/a2a/auth/middleware.js.map +1 -0
- package/v3/dist/adapters/a2a/auth/oauth-provider.d.ts +308 -0
- package/v3/dist/adapters/a2a/auth/oauth-provider.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/auth/oauth-provider.js +573 -0
- package/v3/dist/adapters/a2a/auth/oauth-provider.js.map +1 -0
- package/v3/dist/adapters/a2a/auth/routes.d.ts +244 -0
- package/v3/dist/adapters/a2a/auth/routes.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/auth/routes.js +496 -0
- package/v3/dist/adapters/a2a/auth/routes.js.map +1 -0
- package/v3/dist/adapters/a2a/auth/scopes.d.ts +219 -0
- package/v3/dist/adapters/a2a/auth/scopes.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/auth/scopes.js +292 -0
- package/v3/dist/adapters/a2a/auth/scopes.js.map +1 -0
- package/v3/dist/adapters/a2a/auth/token-store.d.ts +278 -0
- package/v3/dist/adapters/a2a/auth/token-store.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/auth/token-store.js +453 -0
- package/v3/dist/adapters/a2a/auth/token-store.js.map +1 -0
- package/v3/dist/adapters/a2a/discovery/agent-health.d.ts +226 -0
- package/v3/dist/adapters/a2a/discovery/agent-health.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/discovery/agent-health.js +426 -0
- package/v3/dist/adapters/a2a/discovery/agent-health.js.map +1 -0
- package/v3/dist/adapters/a2a/discovery/discovery-service.d.ts +296 -0
- package/v3/dist/adapters/a2a/discovery/discovery-service.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/discovery/discovery-service.js +520 -0
- package/v3/dist/adapters/a2a/discovery/discovery-service.js.map +1 -0
- package/v3/dist/adapters/a2a/discovery/file-watcher.d.ts +166 -0
- package/v3/dist/adapters/a2a/discovery/file-watcher.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/discovery/file-watcher.js +385 -0
- package/v3/dist/adapters/a2a/discovery/file-watcher.js.map +1 -0
- package/v3/dist/adapters/a2a/discovery/hot-reload-service.d.ts +226 -0
- package/v3/dist/adapters/a2a/discovery/hot-reload-service.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/discovery/hot-reload-service.js +433 -0
- package/v3/dist/adapters/a2a/discovery/hot-reload-service.js.map +1 -0
- package/v3/dist/adapters/a2a/discovery/index.d.ts +18 -0
- package/v3/dist/adapters/a2a/discovery/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/discovery/index.js +54 -0
- package/v3/dist/adapters/a2a/discovery/index.js.map +1 -0
- package/v3/dist/adapters/a2a/discovery/metrics.d.ts +200 -0
- package/v3/dist/adapters/a2a/discovery/metrics.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/discovery/metrics.js +371 -0
- package/v3/dist/adapters/a2a/discovery/metrics.js.map +1 -0
- package/v3/dist/adapters/a2a/discovery/routes.d.ts +184 -0
- package/v3/dist/adapters/a2a/discovery/routes.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/discovery/routes.js +453 -0
- package/v3/dist/adapters/a2a/discovery/routes.js.map +1 -0
- package/v3/dist/adapters/a2a/index.d.ts +18 -0
- package/v3/dist/adapters/a2a/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/index.js +139 -0
- package/v3/dist/adapters/a2a/index.js.map +1 -0
- package/v3/dist/adapters/a2a/jsonrpc/envelope.d.ts +312 -0
- package/v3/dist/adapters/a2a/jsonrpc/envelope.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/jsonrpc/envelope.js +554 -0
- package/v3/dist/adapters/a2a/jsonrpc/envelope.js.map +1 -0
- package/v3/dist/adapters/a2a/jsonrpc/errors.d.ts +244 -0
- package/v3/dist/adapters/a2a/jsonrpc/errors.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/jsonrpc/errors.js +365 -0
- package/v3/dist/adapters/a2a/jsonrpc/errors.js.map +1 -0
- package/v3/dist/adapters/a2a/jsonrpc/index.d.ts +14 -0
- package/v3/dist/adapters/a2a/jsonrpc/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/jsonrpc/index.js +59 -0
- package/v3/dist/adapters/a2a/jsonrpc/index.js.map +1 -0
- package/v3/dist/adapters/a2a/jsonrpc/methods.d.ts +400 -0
- package/v3/dist/adapters/a2a/jsonrpc/methods.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/jsonrpc/methods.js +249 -0
- package/v3/dist/adapters/a2a/jsonrpc/methods.js.map +1 -0
- package/v3/dist/adapters/a2a/notifications/index.d.ts +60 -0
- package/v3/dist/adapters/a2a/notifications/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/notifications/index.js +99 -0
- package/v3/dist/adapters/a2a/notifications/index.js.map +1 -0
- package/v3/dist/adapters/a2a/notifications/retry-queue.d.ts +225 -0
- package/v3/dist/adapters/a2a/notifications/retry-queue.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/notifications/retry-queue.js +449 -0
- package/v3/dist/adapters/a2a/notifications/retry-queue.js.map +1 -0
- package/v3/dist/adapters/a2a/notifications/signature.d.ts +133 -0
- package/v3/dist/adapters/a2a/notifications/signature.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/notifications/signature.js +244 -0
- package/v3/dist/adapters/a2a/notifications/signature.js.map +1 -0
- package/v3/dist/adapters/a2a/notifications/subscription-store.d.ts +243 -0
- package/v3/dist/adapters/a2a/notifications/subscription-store.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/notifications/subscription-store.js +486 -0
- package/v3/dist/adapters/a2a/notifications/subscription-store.js.map +1 -0
- package/v3/dist/adapters/a2a/notifications/webhook-service.d.ts +257 -0
- package/v3/dist/adapters/a2a/notifications/webhook-service.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/notifications/webhook-service.js +542 -0
- package/v3/dist/adapters/a2a/notifications/webhook-service.js.map +1 -0
- package/v3/dist/adapters/a2a/tasks/index.d.ts +16 -0
- package/v3/dist/adapters/a2a/tasks/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/tasks/index.js +33 -0
- package/v3/dist/adapters/a2a/tasks/index.js.map +1 -0
- package/v3/dist/adapters/a2a/tasks/task-manager.d.ts +306 -0
- package/v3/dist/adapters/a2a/tasks/task-manager.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/tasks/task-manager.js +562 -0
- package/v3/dist/adapters/a2a/tasks/task-manager.js.map +1 -0
- package/v3/dist/adapters/a2a/tasks/task-router.d.ts +270 -0
- package/v3/dist/adapters/a2a/tasks/task-router.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/tasks/task-router.js +574 -0
- package/v3/dist/adapters/a2a/tasks/task-router.js.map +1 -0
- package/v3/dist/adapters/a2a/tasks/task-store.d.ts +251 -0
- package/v3/dist/adapters/a2a/tasks/task-store.d.ts.map +1 -0
- package/v3/dist/adapters/a2a/tasks/task-store.js +468 -0
- package/v3/dist/adapters/a2a/tasks/task-store.js.map +1 -0
- package/v3/dist/adapters/a2ui/accessibility/aria-attributes.d.ts +294 -0
- package/v3/dist/adapters/a2ui/accessibility/aria-attributes.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/accessibility/aria-attributes.js +447 -0
- package/v3/dist/adapters/a2ui/accessibility/aria-attributes.js.map +1 -0
- package/v3/dist/adapters/a2ui/accessibility/index.d.ts +83 -0
- package/v3/dist/adapters/a2ui/accessibility/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/accessibility/index.js +155 -0
- package/v3/dist/adapters/a2ui/accessibility/index.js.map +1 -0
- package/v3/dist/adapters/a2ui/accessibility/keyboard-nav.d.ts +177 -0
- package/v3/dist/adapters/a2ui/accessibility/keyboard-nav.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/accessibility/keyboard-nav.js +638 -0
- package/v3/dist/adapters/a2ui/accessibility/keyboard-nav.js.map +1 -0
- package/v3/dist/adapters/a2ui/accessibility/wcag-validator.d.ts +186 -0
- package/v3/dist/adapters/a2ui/accessibility/wcag-validator.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/accessibility/wcag-validator.js +816 -0
- package/v3/dist/adapters/a2ui/accessibility/wcag-validator.js.map +1 -0
- package/v3/dist/adapters/a2ui/catalog/component-schemas.d.ts +227 -0
- package/v3/dist/adapters/a2ui/catalog/component-schemas.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/catalog/component-schemas.js +1090 -0
- package/v3/dist/adapters/a2ui/catalog/component-schemas.js.map +1 -0
- package/v3/dist/adapters/a2ui/catalog/index.d.ts +55 -0
- package/v3/dist/adapters/a2ui/catalog/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/catalog/index.js +100 -0
- package/v3/dist/adapters/a2ui/catalog/index.js.map +1 -0
- package/v3/dist/adapters/a2ui/catalog/qe-catalog.d.ts +456 -0
- package/v3/dist/adapters/a2ui/catalog/qe-catalog.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/catalog/qe-catalog.js +413 -0
- package/v3/dist/adapters/a2ui/catalog/qe-catalog.js.map +1 -0
- package/v3/dist/adapters/a2ui/catalog/standard-catalog.d.ts +581 -0
- package/v3/dist/adapters/a2ui/catalog/standard-catalog.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/catalog/standard-catalog.js +409 -0
- package/v3/dist/adapters/a2ui/catalog/standard-catalog.js.map +1 -0
- package/v3/dist/adapters/a2ui/data/bound-value.d.ts +252 -0
- package/v3/dist/adapters/a2ui/data/bound-value.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/data/bound-value.js +403 -0
- package/v3/dist/adapters/a2ui/data/bound-value.js.map +1 -0
- package/v3/dist/adapters/a2ui/data/index.d.ts +14 -0
- package/v3/dist/adapters/a2ui/data/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/data/index.js +41 -0
- package/v3/dist/adapters/a2ui/data/index.js.map +1 -0
- package/v3/dist/adapters/a2ui/data/json-pointer-resolver.d.ts +187 -0
- package/v3/dist/adapters/a2ui/data/json-pointer-resolver.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/data/json-pointer-resolver.js +425 -0
- package/v3/dist/adapters/a2ui/data/json-pointer-resolver.js.map +1 -0
- package/v3/dist/adapters/a2ui/data/reactive-store.d.ts +241 -0
- package/v3/dist/adapters/a2ui/data/reactive-store.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/data/reactive-store.js +461 -0
- package/v3/dist/adapters/a2ui/data/reactive-store.js.map +1 -0
- package/v3/dist/adapters/a2ui/index.d.ts +17 -0
- package/v3/dist/adapters/a2ui/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/index.js +119 -0
- package/v3/dist/adapters/a2ui/index.js.map +1 -0
- package/v3/dist/adapters/a2ui/integration/agui-sync.d.ts +259 -0
- package/v3/dist/adapters/a2ui/integration/agui-sync.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/integration/agui-sync.js +559 -0
- package/v3/dist/adapters/a2ui/integration/agui-sync.js.map +1 -0
- package/v3/dist/adapters/a2ui/integration/index.d.ts +11 -0
- package/v3/dist/adapters/a2ui/integration/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/integration/index.js +23 -0
- package/v3/dist/adapters/a2ui/integration/index.js.map +1 -0
- package/v3/dist/adapters/a2ui/integration/surface-state-bridge.d.ts +209 -0
- package/v3/dist/adapters/a2ui/integration/surface-state-bridge.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/integration/surface-state-bridge.js +545 -0
- package/v3/dist/adapters/a2ui/integration/surface-state-bridge.js.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/component-builder.d.ts +227 -0
- package/v3/dist/adapters/a2ui/renderer/component-builder.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/component-builder.js +488 -0
- package/v3/dist/adapters/a2ui/renderer/component-builder.js.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/index.d.ts +16 -0
- package/v3/dist/adapters/a2ui/renderer/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/index.js +50 -0
- package/v3/dist/adapters/a2ui/renderer/index.js.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/message-types.d.ts +299 -0
- package/v3/dist/adapters/a2ui/renderer/message-types.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/message-types.js +187 -0
- package/v3/dist/adapters/a2ui/renderer/message-types.js.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/surface-generator.d.ts +210 -0
- package/v3/dist/adapters/a2ui/renderer/surface-generator.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/surface-generator.js +586 -0
- package/v3/dist/adapters/a2ui/renderer/surface-generator.js.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/templates/accessibility-surface.d.ts +149 -0
- package/v3/dist/adapters/a2ui/renderer/templates/accessibility-surface.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/templates/accessibility-surface.js +414 -0
- package/v3/dist/adapters/a2ui/renderer/templates/accessibility-surface.js.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/templates/coverage-surface.d.ts +95 -0
- package/v3/dist/adapters/a2ui/renderer/templates/coverage-surface.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/templates/coverage-surface.js +231 -0
- package/v3/dist/adapters/a2ui/renderer/templates/coverage-surface.js.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/templates/index.d.ts +12 -0
- package/v3/dist/adapters/a2ui/renderer/templates/index.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/templates/index.js +16 -0
- package/v3/dist/adapters/a2ui/renderer/templates/index.js.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/templates/security-surface.d.ts +121 -0
- package/v3/dist/adapters/a2ui/renderer/templates/security-surface.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/templates/security-surface.js +367 -0
- package/v3/dist/adapters/a2ui/renderer/templates/security-surface.js.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/templates/test-results-surface.d.ts +104 -0
- package/v3/dist/adapters/a2ui/renderer/templates/test-results-surface.d.ts.map +1 -0
- package/v3/dist/adapters/a2ui/renderer/templates/test-results-surface.js +294 -0
- package/v3/dist/adapters/a2ui/renderer/templates/test-results-surface.js.map +1 -0
- package/v3/dist/adapters/ag-ui/backpressure-handler.d.ts +201 -0
- package/v3/dist/adapters/ag-ui/backpressure-handler.d.ts.map +1 -0
- package/v3/dist/adapters/ag-ui/backpressure-handler.js +399 -0
- package/v3/dist/adapters/ag-ui/backpressure-handler.js.map +1 -0
- package/v3/dist/adapters/ag-ui/event-adapter.d.ts +360 -0
- package/v3/dist/adapters/ag-ui/event-adapter.d.ts.map +1 -0
- package/v3/dist/adapters/ag-ui/event-adapter.js +1083 -0
- package/v3/dist/adapters/ag-ui/event-adapter.js.map +1 -0
- package/v3/dist/adapters/ag-ui/event-batcher.d.ts +242 -0
- package/v3/dist/adapters/ag-ui/event-batcher.d.ts.map +1 -0
- package/v3/dist/adapters/ag-ui/event-batcher.js +444 -0
- package/v3/dist/adapters/ag-ui/event-batcher.js.map +1 -0
- package/v3/dist/adapters/ag-ui/event-types.d.ts +450 -0
- package/v3/dist/adapters/ag-ui/event-types.d.ts.map +1 -0
- package/v3/dist/adapters/ag-ui/event-types.js +173 -0
- package/v3/dist/adapters/ag-ui/event-types.js.map +1 -0
- package/v3/dist/adapters/ag-ui/index.d.ts +17 -0
- package/v3/dist/adapters/ag-ui/index.d.ts.map +1 -0
- package/v3/dist/adapters/ag-ui/index.js +47 -0
- package/v3/dist/adapters/ag-ui/index.js.map +1 -0
- package/v3/dist/adapters/ag-ui/json-patch-utils.d.ts +136 -0
- package/v3/dist/adapters/ag-ui/json-patch-utils.d.ts.map +1 -0
- package/v3/dist/adapters/ag-ui/json-patch-utils.js +574 -0
- package/v3/dist/adapters/ag-ui/json-patch-utils.js.map +1 -0
- package/v3/dist/adapters/ag-ui/json-patch.d.ts +241 -0
- package/v3/dist/adapters/ag-ui/json-patch.d.ts.map +1 -0
- package/v3/dist/adapters/ag-ui/json-patch.js +726 -0
- package/v3/dist/adapters/ag-ui/json-patch.js.map +1 -0
- package/v3/dist/adapters/ag-ui/state-delta-cache.d.ts +218 -0
- package/v3/dist/adapters/ag-ui/state-delta-cache.d.ts.map +1 -0
- package/v3/dist/adapters/ag-ui/state-delta-cache.js +422 -0
- package/v3/dist/adapters/ag-ui/state-delta-cache.js.map +1 -0
- package/v3/dist/adapters/ag-ui/state-manager.d.ts +249 -0
- package/v3/dist/adapters/ag-ui/state-manager.d.ts.map +1 -0
- package/v3/dist/adapters/ag-ui/state-manager.js +511 -0
- package/v3/dist/adapters/ag-ui/state-manager.js.map +1 -0
- package/v3/dist/adapters/ag-ui/stream-controller.d.ts +195 -0
- package/v3/dist/adapters/ag-ui/stream-controller.d.ts.map +1 -0
- package/v3/dist/adapters/ag-ui/stream-controller.js +481 -0
- package/v3/dist/adapters/ag-ui/stream-controller.js.map +1 -0
- package/v3/dist/adapters/index.d.ts +4 -0
- package/v3/dist/adapters/index.d.ts.map +1 -1
- package/v3/dist/adapters/index.js +89 -0
- package/v3/dist/adapters/index.js.map +1 -1
- package/v3/dist/cli/bundle.js +1507 -425
- package/v3/dist/coordination/consensus/providers/claude-provider.js +1 -1
- package/v3/dist/coordination/consensus/providers/gemini-provider.js +1 -1
- package/v3/dist/coordination/consensus/providers/openai-provider.js +1 -1
- package/v3/dist/init/init-wizard.d.ts.map +1 -1
- package/v3/dist/init/init-wizard.js +19 -4
- package/v3/dist/init/init-wizard.js.map +1 -1
- package/v3/dist/init/migration/config-migrator.d.ts.map +1 -1
- package/v3/dist/init/migration/config-migrator.js +15 -1
- package/v3/dist/init/migration/config-migrator.js.map +1 -1
- package/v3/dist/init/phases/05-learning.js +1 -1
- package/v3/dist/init/phases/05-learning.js.map +1 -1
- package/v3/dist/init/self-configurator.d.ts +7 -0
- package/v3/dist/init/self-configurator.d.ts.map +1 -1
- package/v3/dist/init/self-configurator.js +23 -27
- package/v3/dist/init/self-configurator.js.map +1 -1
- package/v3/dist/integrations/ruvector/interfaces.js +1 -1
- package/v3/dist/integrations/ruvector/interfaces.js.map +1 -1
- package/v3/dist/kernel/index.d.ts +1 -1
- package/v3/dist/kernel/index.d.ts.map +1 -1
- package/v3/dist/kernel/index.js +3 -1
- package/v3/dist/kernel/index.js.map +1 -1
- package/v3/dist/kernel/plugin-loader.d.ts.map +1 -1
- package/v3/dist/kernel/plugin-loader.js +6 -1
- package/v3/dist/kernel/plugin-loader.js.map +1 -1
- package/v3/dist/kernel/unified-memory.d.ts +123 -0
- package/v3/dist/kernel/unified-memory.d.ts.map +1 -1
- package/v3/dist/kernel/unified-memory.js +258 -2
- package/v3/dist/kernel/unified-memory.js.map +1 -1
- package/v3/dist/learning/qe-unified-memory.js +1 -1
- package/v3/dist/learning/qe-unified-memory.js.map +1 -1
- package/v3/dist/learning/real-qe-reasoning-bank.js +2 -2
- package/v3/dist/learning/real-qe-reasoning-bank.js.map +1 -1
- package/v3/dist/learning/sqlite-persistence.d.ts +1 -1
- package/v3/dist/learning/sqlite-persistence.js +1 -1
- package/v3/dist/learning/sqlite-persistence.js.map +1 -1
- package/v3/dist/learning/v2-to-v3-migration.d.ts +2 -2
- package/v3/dist/learning/v2-to-v3-migration.d.ts.map +1 -1
- package/v3/dist/learning/v2-to-v3-migration.js +2 -2
- package/v3/dist/learning/v2-to-v3-migration.js.map +1 -1
- package/v3/dist/mcp/bundle.js +63075 -53304
- package/v3/dist/mcp/entry.d.ts +5 -0
- package/v3/dist/mcp/entry.d.ts.map +1 -1
- package/v3/dist/mcp/entry.js +36 -0
- package/v3/dist/mcp/entry.js.map +1 -1
- package/v3/dist/mcp/http-server.d.ts +95 -0
- package/v3/dist/mcp/http-server.d.ts.map +1 -0
- package/v3/dist/mcp/http-server.js +833 -0
- package/v3/dist/mcp/http-server.js.map +1 -0
- package/v3/dist/mcp/protocol-server.d.ts +6 -0
- package/v3/dist/mcp/protocol-server.d.ts.map +1 -1
- package/v3/dist/mcp/protocol-server.js +40 -0
- package/v3/dist/mcp/protocol-server.js.map +1 -1
- package/v3/dist/mcp/transport/index.d.ts +25 -3
- package/v3/dist/mcp/transport/index.d.ts.map +1 -1
- package/v3/dist/mcp/transport/index.js +22 -4
- package/v3/dist/mcp/transport/index.js.map +1 -1
- package/v3/dist/mcp/transport/sse/connection-manager.d.ts +84 -0
- package/v3/dist/mcp/transport/sse/connection-manager.d.ts.map +1 -0
- package/v3/dist/mcp/transport/sse/connection-manager.js +271 -0
- package/v3/dist/mcp/transport/sse/connection-manager.js.map +1 -0
- package/v3/dist/mcp/transport/sse/index.d.ts +10 -0
- package/v3/dist/mcp/transport/sse/index.d.ts.map +1 -0
- package/v3/dist/mcp/transport/sse/index.js +15 -0
- package/v3/dist/mcp/transport/sse/index.js.map +1 -0
- package/v3/dist/mcp/transport/sse/sse-transport.d.ts +56 -0
- package/v3/dist/mcp/transport/sse/sse-transport.d.ts.map +1 -0
- package/v3/dist/mcp/transport/sse/sse-transport.js +381 -0
- package/v3/dist/mcp/transport/sse/sse-transport.js.map +1 -0
- package/v3/dist/mcp/transport/sse/types.d.ts +237 -0
- package/v3/dist/mcp/transport/sse/types.d.ts.map +1 -0
- package/v3/dist/mcp/transport/sse/types.js +37 -0
- package/v3/dist/mcp/transport/sse/types.js.map +1 -0
- package/v3/dist/mcp/transport/websocket/connection-manager.d.ts +143 -0
- package/v3/dist/mcp/transport/websocket/connection-manager.d.ts.map +1 -0
- package/v3/dist/mcp/transport/websocket/connection-manager.js +522 -0
- package/v3/dist/mcp/transport/websocket/connection-manager.js.map +1 -0
- package/v3/dist/mcp/transport/websocket/index.d.ts +10 -0
- package/v3/dist/mcp/transport/websocket/index.d.ts.map +1 -0
- package/v3/dist/mcp/transport/websocket/index.js +19 -0
- package/v3/dist/mcp/transport/websocket/index.js.map +1 -0
- package/v3/dist/mcp/transport/websocket/types.d.ts +354 -0
- package/v3/dist/mcp/transport/websocket/types.d.ts.map +1 -0
- package/v3/dist/mcp/transport/websocket/types.js +49 -0
- package/v3/dist/mcp/transport/websocket/types.js.map +1 -0
- package/v3/dist/mcp/transport/websocket/websocket-transport.d.ts +77 -0
- package/v3/dist/mcp/transport/websocket/websocket-transport.d.ts.map +1 -0
- package/v3/dist/mcp/transport/websocket/websocket-transport.js +622 -0
- package/v3/dist/mcp/transport/websocket/websocket-transport.js.map +1 -0
- package/v3/dist/memory/crdt/convergence-tracker.d.ts +59 -0
- package/v3/dist/memory/crdt/convergence-tracker.d.ts.map +1 -0
- package/v3/dist/memory/crdt/convergence-tracker.js +325 -0
- package/v3/dist/memory/crdt/convergence-tracker.js.map +1 -0
- package/v3/dist/memory/crdt/crdt-store.d.ts +55 -0
- package/v3/dist/memory/crdt/crdt-store.d.ts.map +1 -0
- package/v3/dist/memory/crdt/crdt-store.js +582 -0
- package/v3/dist/memory/crdt/crdt-store.js.map +1 -0
- package/v3/dist/memory/crdt/g-counter.d.ts +47 -0
- package/v3/dist/memory/crdt/g-counter.d.ts.map +1 -0
- package/v3/dist/memory/crdt/g-counter.js +134 -0
- package/v3/dist/memory/crdt/g-counter.js.map +1 -0
- package/v3/dist/memory/crdt/index.d.ts +52 -0
- package/v3/dist/memory/crdt/index.d.ts.map +1 -0
- package/v3/dist/memory/crdt/index.js +66 -0
- package/v3/dist/memory/crdt/index.js.map +1 -0
- package/v3/dist/memory/crdt/lww-register.d.ts +40 -0
- package/v3/dist/memory/crdt/lww-register.d.ts.map +1 -0
- package/v3/dist/memory/crdt/lww-register.js +133 -0
- package/v3/dist/memory/crdt/lww-register.js.map +1 -0
- package/v3/dist/memory/crdt/or-set.d.ts +62 -0
- package/v3/dist/memory/crdt/or-set.d.ts.map +1 -0
- package/v3/dist/memory/crdt/or-set.js +336 -0
- package/v3/dist/memory/crdt/or-set.js.map +1 -0
- package/v3/dist/memory/crdt/pn-counter.d.ts +53 -0
- package/v3/dist/memory/crdt/pn-counter.d.ts.map +1 -0
- package/v3/dist/memory/crdt/pn-counter.js +147 -0
- package/v3/dist/memory/crdt/pn-counter.js.map +1 -0
- package/v3/dist/memory/crdt/types.d.ts +397 -0
- package/v3/dist/memory/crdt/types.d.ts.map +1 -0
- package/v3/dist/memory/crdt/types.js +12 -0
- package/v3/dist/memory/crdt/types.js.map +1 -0
- package/v3/dist/memory/index.d.ts +5 -2
- package/v3/dist/memory/index.d.ts.map +1 -1
- package/v3/dist/memory/index.js +5 -2
- package/v3/dist/memory/index.js.map +1 -1
- package/v3/dist/performance/benchmarks.d.ts +215 -0
- package/v3/dist/performance/benchmarks.d.ts.map +1 -0
- package/v3/dist/performance/benchmarks.js +516 -0
- package/v3/dist/performance/benchmarks.js.map +1 -0
- package/v3/dist/performance/ci-gates.d.ts +149 -0
- package/v3/dist/performance/ci-gates.d.ts.map +1 -0
- package/v3/dist/performance/ci-gates.js +425 -0
- package/v3/dist/performance/ci-gates.js.map +1 -0
- package/v3/dist/performance/index.d.ts +18 -0
- package/v3/dist/performance/index.d.ts.map +1 -0
- package/v3/dist/performance/index.js +26 -0
- package/v3/dist/performance/index.js.map +1 -0
- package/v3/dist/performance/optimizer.d.ts +323 -0
- package/v3/dist/performance/optimizer.d.ts.map +1 -0
- package/v3/dist/performance/optimizer.js +592 -0
- package/v3/dist/performance/optimizer.js.map +1 -0
- package/v3/dist/performance/profiler.d.ts +195 -0
- package/v3/dist/performance/profiler.d.ts.map +1 -0
- package/v3/dist/performance/profiler.js +369 -0
- package/v3/dist/performance/profiler.js.map +1 -0
- package/v3/dist/performance/run-gates.d.ts +23 -0
- package/v3/dist/performance/run-gates.d.ts.map +1 -0
- package/v3/dist/performance/run-gates.js +122 -0
- package/v3/dist/performance/run-gates.js.map +1 -0
- package/v3/dist/sync/claude-flow-bridge.d.ts +1 -1
- package/v3/dist/sync/claude-flow-bridge.js +1 -1
- package/v3/dist/sync/interfaces.d.ts +6 -0
- package/v3/dist/sync/interfaces.d.ts.map +1 -1
- package/v3/dist/sync/interfaces.js +34 -47
- package/v3/dist/sync/interfaces.js.map +1 -1
- package/v3/dist/sync/readers/sqlite-reader.d.ts +1 -1
- package/v3/dist/sync/readers/sqlite-reader.js +1 -1
- package/v3/dist/testing/index.d.ts +6 -0
- package/v3/dist/testing/index.d.ts.map +1 -0
- package/v3/dist/testing/index.js +7 -0
- package/v3/dist/testing/index.js.map +1 -0
- package/v3/dist/testing/load/agent-load-tester.d.ts +221 -0
- package/v3/dist/testing/load/agent-load-tester.d.ts.map +1 -0
- package/v3/dist/testing/load/agent-load-tester.js +566 -0
- package/v3/dist/testing/load/agent-load-tester.js.map +1 -0
- package/v3/dist/testing/load/bottleneck-analyzer.d.ts +150 -0
- package/v3/dist/testing/load/bottleneck-analyzer.d.ts.map +1 -0
- package/v3/dist/testing/load/bottleneck-analyzer.js +442 -0
- package/v3/dist/testing/load/bottleneck-analyzer.js.map +1 -0
- package/v3/dist/testing/load/index.d.ts +17 -0
- package/v3/dist/testing/load/index.d.ts.map +1 -0
- package/v3/dist/testing/load/index.js +23 -0
- package/v3/dist/testing/load/index.js.map +1 -0
- package/v3/dist/testing/load/metrics-collector.d.ts +275 -0
- package/v3/dist/testing/load/metrics-collector.d.ts.map +1 -0
- package/v3/dist/testing/load/metrics-collector.js +475 -0
- package/v3/dist/testing/load/metrics-collector.js.map +1 -0
- package/v3/package.json +5 -1
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Patch Wrapper (RFC 6902)
|
|
3
|
+
*
|
|
4
|
+
* Provides a unified interface for JSON Patch operations using fast-json-patch
|
|
5
|
+
* for RFC 6902 compliance. This module wraps fast-json-patch with additional
|
|
6
|
+
* validation, error handling, and AQE-specific types.
|
|
7
|
+
*
|
|
8
|
+
* Reference: https://datatracker.ietf.org/doc/html/rfc6902
|
|
9
|
+
*
|
|
10
|
+
* @module adapters/ag-ui/json-patch
|
|
11
|
+
*/
|
|
12
|
+
import * as fastJsonPatch from 'fast-json-patch';
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// Path Utilities (RFC 6901 JSON Pointer)
|
|
15
|
+
// ============================================================================
|
|
16
|
+
/**
|
|
17
|
+
* Escape special characters in a JSON Pointer token (RFC 6901)
|
|
18
|
+
* ~ becomes ~0
|
|
19
|
+
* / becomes ~1
|
|
20
|
+
*/
|
|
21
|
+
export function escapePathToken(token) {
|
|
22
|
+
return token.replace(/~/g, '~0').replace(/\//g, '~1');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Unescape special characters in a JSON Pointer token (RFC 6901)
|
|
26
|
+
* ~0 becomes ~
|
|
27
|
+
* ~1 becomes /
|
|
28
|
+
*/
|
|
29
|
+
export function unescapePathToken(token) {
|
|
30
|
+
return token.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parse a JSON Pointer path into tokens
|
|
34
|
+
*/
|
|
35
|
+
export function parsePath(path) {
|
|
36
|
+
if (path === '') {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
if (!path.startsWith('/')) {
|
|
40
|
+
throw new JsonPatchError(`Invalid JSON Pointer: path must start with '/' or be empty, got '${path}'`, 'INVALID_PATH', { path });
|
|
41
|
+
}
|
|
42
|
+
return path.slice(1).split('/').map(unescapePathToken);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Build a JSON Pointer path from tokens
|
|
46
|
+
*/
|
|
47
|
+
export function buildPath(tokens) {
|
|
48
|
+
if (tokens.length === 0) {
|
|
49
|
+
return '';
|
|
50
|
+
}
|
|
51
|
+
return '/' + tokens.map(escapePathToken).join('/');
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Get a value from an object using a JSON Pointer path
|
|
55
|
+
*/
|
|
56
|
+
export function getValueAtPath(document, path) {
|
|
57
|
+
if (path === '') {
|
|
58
|
+
return document;
|
|
59
|
+
}
|
|
60
|
+
const tokens = parsePath(path);
|
|
61
|
+
let current = document;
|
|
62
|
+
for (const token of tokens) {
|
|
63
|
+
if (current === null || current === undefined) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(current)) {
|
|
67
|
+
const index = token === '-' ? current.length : parseInt(token, 10);
|
|
68
|
+
if (isNaN(index) || index < 0) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
current = current[index];
|
|
72
|
+
}
|
|
73
|
+
else if (typeof current === 'object') {
|
|
74
|
+
current = current[token];
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return current;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Check if a path exists in the document
|
|
84
|
+
*/
|
|
85
|
+
export function pathExists(document, path) {
|
|
86
|
+
if (path === '') {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
const tokens = parsePath(path);
|
|
90
|
+
let current = document;
|
|
91
|
+
for (const token of tokens) {
|
|
92
|
+
if (current === null || current === undefined) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (Array.isArray(current)) {
|
|
96
|
+
const index = parseInt(token, 10);
|
|
97
|
+
if (isNaN(index) || index < 0 || index >= current.length) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
current = current[index];
|
|
101
|
+
}
|
|
102
|
+
else if (typeof current === 'object') {
|
|
103
|
+
if (!(token in current)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
current = current[token];
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Set a value at a JSON Pointer path (mutates the document)
|
|
116
|
+
*/
|
|
117
|
+
export function setValueAtPath(document, path, value) {
|
|
118
|
+
if (path === '') {
|
|
119
|
+
throw new JsonPatchError('Cannot replace root document via setValueAtPath', 'INVALID_OPERATION');
|
|
120
|
+
}
|
|
121
|
+
const tokens = parsePath(path);
|
|
122
|
+
const lastToken = tokens.pop();
|
|
123
|
+
let current = document;
|
|
124
|
+
for (const token of tokens) {
|
|
125
|
+
if (current === null || current === undefined) {
|
|
126
|
+
throw new JsonPatchError(`Path does not exist: ${path}`, 'PATH_NOT_FOUND', { path });
|
|
127
|
+
}
|
|
128
|
+
if (Array.isArray(current)) {
|
|
129
|
+
const index = parseInt(token, 10);
|
|
130
|
+
if (isNaN(index) || index < 0 || index >= current.length) {
|
|
131
|
+
throw new JsonPatchError(`Invalid array index: ${token}`, 'INVALID_INDEX', { token, path });
|
|
132
|
+
}
|
|
133
|
+
current = current[index];
|
|
134
|
+
}
|
|
135
|
+
else if (typeof current === 'object') {
|
|
136
|
+
if (!(token in current)) {
|
|
137
|
+
throw new JsonPatchError(`Path does not exist: ${path}`, 'PATH_NOT_FOUND', { path });
|
|
138
|
+
}
|
|
139
|
+
current = current[token];
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
throw new JsonPatchError(`Cannot traverse non-object: ${path}`, 'INVALID_PATH', { path });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (Array.isArray(current)) {
|
|
146
|
+
const index = lastToken === '-' ? current.length : parseInt(lastToken, 10);
|
|
147
|
+
if (isNaN(index) || index < 0) {
|
|
148
|
+
throw new JsonPatchError(`Invalid array index: ${lastToken}`, 'INVALID_INDEX', { token: lastToken, path });
|
|
149
|
+
}
|
|
150
|
+
current[index] = value;
|
|
151
|
+
}
|
|
152
|
+
else if (typeof current === 'object' && current !== null) {
|
|
153
|
+
current[lastToken] = value;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
throw new JsonPatchError(`Cannot set value at path: ${path}`, 'INVALID_OPERATION', { path });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Delete a value at a JSON Pointer path (mutates the document)
|
|
161
|
+
*/
|
|
162
|
+
export function deleteValueAtPath(document, path) {
|
|
163
|
+
if (path === '') {
|
|
164
|
+
throw new JsonPatchError('Cannot remove root document', 'INVALID_OPERATION');
|
|
165
|
+
}
|
|
166
|
+
const tokens = parsePath(path);
|
|
167
|
+
const lastToken = tokens.pop();
|
|
168
|
+
let current = document;
|
|
169
|
+
for (const token of tokens) {
|
|
170
|
+
if (current === null || current === undefined) {
|
|
171
|
+
throw new JsonPatchError(`Path does not exist: ${path}`, 'PATH_NOT_FOUND', { path });
|
|
172
|
+
}
|
|
173
|
+
if (Array.isArray(current)) {
|
|
174
|
+
const index = parseInt(token, 10);
|
|
175
|
+
if (isNaN(index) || index < 0 || index >= current.length) {
|
|
176
|
+
throw new JsonPatchError(`Invalid array index: ${token}`, 'INVALID_INDEX', { token, path });
|
|
177
|
+
}
|
|
178
|
+
current = current[index];
|
|
179
|
+
}
|
|
180
|
+
else if (typeof current === 'object') {
|
|
181
|
+
current = current[token];
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
throw new JsonPatchError(`Cannot traverse non-object: ${path}`, 'INVALID_PATH', { path });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (Array.isArray(current)) {
|
|
188
|
+
const index = parseInt(lastToken, 10);
|
|
189
|
+
if (isNaN(index) || index < 0 || index >= current.length) {
|
|
190
|
+
throw new JsonPatchError(`Invalid array index: ${lastToken}`, 'INVALID_INDEX', { token: lastToken, path });
|
|
191
|
+
}
|
|
192
|
+
current.splice(index, 1);
|
|
193
|
+
}
|
|
194
|
+
else if (typeof current === 'object' && current !== null) {
|
|
195
|
+
if (!(lastToken in current)) {
|
|
196
|
+
throw new JsonPatchError(`Path does not exist: ${path}`, 'PATH_NOT_FOUND', { path });
|
|
197
|
+
}
|
|
198
|
+
delete current[lastToken];
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
throw new JsonPatchError(`Cannot delete value at path: ${path}`, 'INVALID_OPERATION', { path });
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Custom error class for JSON Patch operations
|
|
206
|
+
*/
|
|
207
|
+
export class JsonPatchError extends Error {
|
|
208
|
+
code;
|
|
209
|
+
details;
|
|
210
|
+
constructor(message, code, details) {
|
|
211
|
+
super(message);
|
|
212
|
+
this.code = code;
|
|
213
|
+
this.details = details;
|
|
214
|
+
this.name = 'JsonPatchError';
|
|
215
|
+
// Ensure proper prototype chain for instanceof checks
|
|
216
|
+
Object.setPrototypeOf(this, JsonPatchError.prototype);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Create error from fast-json-patch error
|
|
220
|
+
*/
|
|
221
|
+
static fromFastJsonPatch(error, operationIndex) {
|
|
222
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
223
|
+
return new JsonPatchError(message, 'APPLICATION_FAILED', {
|
|
224
|
+
originalError: message,
|
|
225
|
+
operationIndex,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Create test failure error
|
|
230
|
+
*/
|
|
231
|
+
static testFailed(path, expected, actual) {
|
|
232
|
+
return new JsonPatchError(`Test failed at path ${path}: expected ${JSON.stringify(expected)}, got ${JSON.stringify(actual)}`, 'TEST_FAILED', { path, expected, actual });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// ============================================================================
|
|
236
|
+
// Validation
|
|
237
|
+
// ============================================================================
|
|
238
|
+
/**
|
|
239
|
+
* Valid operation types per RFC 6902
|
|
240
|
+
*/
|
|
241
|
+
const VALID_OPERATIONS = ['add', 'remove', 'replace', 'move', 'copy', 'test'];
|
|
242
|
+
/**
|
|
243
|
+
* Operations that require a 'value' field
|
|
244
|
+
*/
|
|
245
|
+
const VALUE_REQUIRED_OPS = ['add', 'replace', 'test'];
|
|
246
|
+
/**
|
|
247
|
+
* Operations that require a 'from' field
|
|
248
|
+
*/
|
|
249
|
+
const FROM_REQUIRED_OPS = ['move', 'copy'];
|
|
250
|
+
/**
|
|
251
|
+
* Validate a JSON Pointer path format (RFC 6901)
|
|
252
|
+
*/
|
|
253
|
+
export function validatePath(path) {
|
|
254
|
+
// Empty string is valid (refers to whole document)
|
|
255
|
+
if (path === '') {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
// Must start with /
|
|
259
|
+
if (!path.startsWith('/')) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
// Check for valid escape sequences
|
|
263
|
+
const tokens = path.slice(1).split('/');
|
|
264
|
+
for (const token of tokens) {
|
|
265
|
+
// Check for invalid escape sequences (~ not followed by 0 or 1)
|
|
266
|
+
for (let i = 0; i < token.length; i++) {
|
|
267
|
+
if (token[i] === '~') {
|
|
268
|
+
const next = token[i + 1];
|
|
269
|
+
if (next !== '0' && next !== '1') {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Validate a single patch operation against RFC 6902
|
|
279
|
+
*/
|
|
280
|
+
export function validateOperation(op) {
|
|
281
|
+
const errors = [];
|
|
282
|
+
// Check operation type
|
|
283
|
+
if (!VALID_OPERATIONS.includes(op.op)) {
|
|
284
|
+
errors.push(`Invalid operation type: '${op.op}'. Valid types are: ${VALID_OPERATIONS.join(', ')}`);
|
|
285
|
+
}
|
|
286
|
+
// Check path
|
|
287
|
+
if (typeof op.path !== 'string') {
|
|
288
|
+
errors.push('Path must be a string');
|
|
289
|
+
}
|
|
290
|
+
else if (!validatePath(op.path)) {
|
|
291
|
+
errors.push(`Invalid JSON Pointer path: '${op.path}'. Path must be empty or start with '/'`);
|
|
292
|
+
}
|
|
293
|
+
// Check value for operations that require it
|
|
294
|
+
if (VALUE_REQUIRED_OPS.includes(op.op) && !('value' in op)) {
|
|
295
|
+
errors.push(`Operation '${op.op}' requires a 'value' field`);
|
|
296
|
+
}
|
|
297
|
+
// Check from for move/copy operations
|
|
298
|
+
if (FROM_REQUIRED_OPS.includes(op.op)) {
|
|
299
|
+
if (!('from' in op) || typeof op.from !== 'string') {
|
|
300
|
+
errors.push(`Operation '${op.op}' requires a 'from' path`);
|
|
301
|
+
}
|
|
302
|
+
else if (!validatePath(op.from)) {
|
|
303
|
+
errors.push(`Invalid 'from' JSON Pointer path: '${op.from}'`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
valid: errors.length === 0,
|
|
308
|
+
error: errors.length > 0 ? errors[0] : undefined,
|
|
309
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Validate an array of patch operations
|
|
314
|
+
*/
|
|
315
|
+
export function validatePatch(patch) {
|
|
316
|
+
const allErrors = [];
|
|
317
|
+
for (let i = 0; i < patch.length; i++) {
|
|
318
|
+
const result = validateOperation(patch[i]);
|
|
319
|
+
if (!result.valid && result.errors) {
|
|
320
|
+
for (const error of result.errors) {
|
|
321
|
+
allErrors.push(`Operation ${i}: ${error}`);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
valid: allErrors.length === 0,
|
|
327
|
+
error: allErrors.length > 0 ? allErrors[0] : undefined,
|
|
328
|
+
errors: allErrors.length > 0 ? allErrors : undefined,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Check RFC 6902 compliance of a patch
|
|
333
|
+
*/
|
|
334
|
+
export function checkCompliance(patch) {
|
|
335
|
+
const issues = [];
|
|
336
|
+
for (let i = 0; i < patch.length; i++) {
|
|
337
|
+
const op = patch[i];
|
|
338
|
+
// Check operation type (RFC 6902 Section 4)
|
|
339
|
+
if (!VALID_OPERATIONS.includes(op.op)) {
|
|
340
|
+
issues.push({
|
|
341
|
+
type: 'invalid_op',
|
|
342
|
+
operationIndex: i,
|
|
343
|
+
message: `Invalid operation '${op.op}'. RFC 6902 defines: add, remove, replace, move, copy, test`,
|
|
344
|
+
rfcSection: '4',
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
// Check path (RFC 6902 Section 4, RFC 6901)
|
|
348
|
+
if (typeof op.path !== 'string') {
|
|
349
|
+
issues.push({
|
|
350
|
+
type: 'missing_path',
|
|
351
|
+
operationIndex: i,
|
|
352
|
+
message: 'Missing required \'path\' member',
|
|
353
|
+
rfcSection: '4',
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
else if (!validatePath(op.path)) {
|
|
357
|
+
issues.push({
|
|
358
|
+
type: 'invalid_path',
|
|
359
|
+
operationIndex: i,
|
|
360
|
+
message: `Invalid JSON Pointer: '${op.path}'`,
|
|
361
|
+
rfcSection: '4 (referencing RFC 6901)',
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
// Check value requirement (RFC 6902 Sections 4.1, 4.3, 4.6)
|
|
365
|
+
if (VALUE_REQUIRED_OPS.includes(op.op) && !('value' in op)) {
|
|
366
|
+
issues.push({
|
|
367
|
+
type: 'missing_value',
|
|
368
|
+
operationIndex: i,
|
|
369
|
+
message: `Operation '${op.op}' requires 'value' member`,
|
|
370
|
+
rfcSection: op.op === 'add' ? '4.1' : op.op === 'replace' ? '4.3' : '4.6',
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
// Check from requirement (RFC 6902 Sections 4.4, 4.5)
|
|
374
|
+
if (FROM_REQUIRED_OPS.includes(op.op)) {
|
|
375
|
+
if (!('from' in op) || typeof op.from !== 'string') {
|
|
376
|
+
issues.push({
|
|
377
|
+
type: 'missing_from',
|
|
378
|
+
operationIndex: i,
|
|
379
|
+
message: `Operation '${op.op}' requires 'from' member`,
|
|
380
|
+
rfcSection: op.op === 'move' ? '4.4' : '4.5',
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
else if (!validatePath(op.from)) {
|
|
384
|
+
issues.push({
|
|
385
|
+
type: 'invalid_from',
|
|
386
|
+
operationIndex: i,
|
|
387
|
+
message: `Invalid 'from' JSON Pointer: '${op.from}'`,
|
|
388
|
+
rfcSection: op.op === 'move' ? '4.4' : '4.5',
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return {
|
|
394
|
+
compliant: issues.length === 0,
|
|
395
|
+
issues,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Validate compliance and throw if not compliant
|
|
400
|
+
*/
|
|
401
|
+
export function ensureCompliance(patch) {
|
|
402
|
+
const result = checkCompliance(patch);
|
|
403
|
+
if (!result.compliant) {
|
|
404
|
+
const messages = result.issues.map((i) => `[Op ${i.operationIndex}] ${i.message}`);
|
|
405
|
+
throw new JsonPatchError(`Patch is not RFC 6902 compliant: ${messages.join('; ')}`, 'COMPLIANCE_FAILED', { issues: result.issues });
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
// ============================================================================
|
|
409
|
+
// Patch Application
|
|
410
|
+
// ============================================================================
|
|
411
|
+
/**
|
|
412
|
+
* Convert AQE patch operations to fast-json-patch format
|
|
413
|
+
*/
|
|
414
|
+
function toFastJsonPatchOperations(patch) {
|
|
415
|
+
return patch.map((op) => {
|
|
416
|
+
const result = {
|
|
417
|
+
op: op.op,
|
|
418
|
+
path: op.path,
|
|
419
|
+
};
|
|
420
|
+
if ('value' in op) {
|
|
421
|
+
result.value = op.value;
|
|
422
|
+
}
|
|
423
|
+
if ('from' in op && op.from !== undefined) {
|
|
424
|
+
result.from = op.from;
|
|
425
|
+
}
|
|
426
|
+
return result;
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Apply a single patch operation to a document
|
|
431
|
+
* Returns a new document (immutable)
|
|
432
|
+
*/
|
|
433
|
+
export function applyOperation(document, op) {
|
|
434
|
+
// Validate first
|
|
435
|
+
const validation = validateOperation(op);
|
|
436
|
+
if (!validation.valid) {
|
|
437
|
+
throw new JsonPatchError(validation.error ?? 'Invalid operation', 'VALIDATION_FAILED', { operation: op });
|
|
438
|
+
}
|
|
439
|
+
// Deep clone to avoid mutation
|
|
440
|
+
const cloned = structuredClone(document);
|
|
441
|
+
try {
|
|
442
|
+
const result = fastJsonPatch.applyOperation(cloned, toFastJsonPatchOperations([op])[0], true, true);
|
|
443
|
+
return result.newDocument;
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
throw JsonPatchError.fromFastJsonPatch(error, 0);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Apply a JSON Patch to a document
|
|
451
|
+
* Returns result with success status and either new document or error info
|
|
452
|
+
*/
|
|
453
|
+
export function applyPatch(document, patch) {
|
|
454
|
+
// Validate first
|
|
455
|
+
const validation = validatePatch(patch);
|
|
456
|
+
if (!validation.valid) {
|
|
457
|
+
return {
|
|
458
|
+
success: false,
|
|
459
|
+
document,
|
|
460
|
+
error: validation.error,
|
|
461
|
+
validationErrors: validation.errors,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
// Check compliance
|
|
465
|
+
const compliance = checkCompliance(patch);
|
|
466
|
+
if (!compliance.compliant) {
|
|
467
|
+
const messages = compliance.issues.map((i) => `[Op ${i.operationIndex}] ${i.message}`);
|
|
468
|
+
return {
|
|
469
|
+
success: false,
|
|
470
|
+
document,
|
|
471
|
+
error: `RFC 6902 compliance error: ${messages[0]}`,
|
|
472
|
+
validationErrors: messages,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
// Deep clone to avoid mutation
|
|
476
|
+
const cloned = structuredClone(document);
|
|
477
|
+
try {
|
|
478
|
+
const operations = toFastJsonPatchOperations(patch);
|
|
479
|
+
const result = fastJsonPatch.applyPatch(cloned, operations, true, true);
|
|
480
|
+
return {
|
|
481
|
+
success: true,
|
|
482
|
+
document: result.newDocument,
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
catch (error) {
|
|
486
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
487
|
+
// Try to extract operation index from error message
|
|
488
|
+
const indexMatch = message.match(/Operation resulted in error.*index (\d+)/);
|
|
489
|
+
const failedIndex = indexMatch ? parseInt(indexMatch[1], 10) : undefined;
|
|
490
|
+
return {
|
|
491
|
+
success: false,
|
|
492
|
+
document, // Return original document (rollback)
|
|
493
|
+
error: message,
|
|
494
|
+
failedOperationIndex: failedIndex,
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Apply a JSON Patch atomically with automatic rollback on failure
|
|
500
|
+
* Returns the new document if successful, throws on error
|
|
501
|
+
*/
|
|
502
|
+
export function applyPatchAtomic(document, patch) {
|
|
503
|
+
const result = applyPatch(document, patch);
|
|
504
|
+
if (!result.success) {
|
|
505
|
+
throw new JsonPatchError(result.error ?? 'Patch application failed', 'APPLICATION_FAILED', { failedOperationIndex: result.failedOperationIndex });
|
|
506
|
+
}
|
|
507
|
+
return result.document;
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Validate a patch against a document (dry run)
|
|
511
|
+
* Returns true if the patch would apply successfully
|
|
512
|
+
*/
|
|
513
|
+
export function validate(document, patch) {
|
|
514
|
+
// First validate syntax
|
|
515
|
+
const syntaxValidation = validatePatch(patch);
|
|
516
|
+
if (!syntaxValidation.valid) {
|
|
517
|
+
return false;
|
|
518
|
+
}
|
|
519
|
+
// Check compliance
|
|
520
|
+
const compliance = checkCompliance(patch);
|
|
521
|
+
if (!compliance.compliant) {
|
|
522
|
+
return false;
|
|
523
|
+
}
|
|
524
|
+
// Try to apply (on a clone)
|
|
525
|
+
const cloned = structuredClone(document);
|
|
526
|
+
try {
|
|
527
|
+
const operations = toFastJsonPatchOperations(patch);
|
|
528
|
+
fastJsonPatch.applyPatch(cloned, operations, true, true);
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
catch {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
// ============================================================================
|
|
536
|
+
// Diff Computation
|
|
537
|
+
// ============================================================================
|
|
538
|
+
/**
|
|
539
|
+
* Deep equality comparison for JSON values
|
|
540
|
+
*/
|
|
541
|
+
export function deepEqual(a, b) {
|
|
542
|
+
if (a === b)
|
|
543
|
+
return true;
|
|
544
|
+
if (a === null || b === null)
|
|
545
|
+
return a === b;
|
|
546
|
+
if (typeof a !== typeof b)
|
|
547
|
+
return false;
|
|
548
|
+
if (typeof a !== 'object')
|
|
549
|
+
return a === b;
|
|
550
|
+
if (Array.isArray(a)) {
|
|
551
|
+
if (!Array.isArray(b))
|
|
552
|
+
return false;
|
|
553
|
+
if (a.length !== b.length)
|
|
554
|
+
return false;
|
|
555
|
+
return a.every((val, i) => deepEqual(val, b[i]));
|
|
556
|
+
}
|
|
557
|
+
const aObj = a;
|
|
558
|
+
const bObj = b;
|
|
559
|
+
const aKeys = Object.keys(aObj);
|
|
560
|
+
const bKeys = Object.keys(bObj);
|
|
561
|
+
if (aKeys.length !== bKeys.length)
|
|
562
|
+
return false;
|
|
563
|
+
return aKeys.every((key) => key in bObj && deepEqual(aObj[key], bObj[key]));
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Compute the JSON Patch to transform oldState into newState
|
|
567
|
+
* Uses fast-json-patch's compare function for optimal diff generation
|
|
568
|
+
*/
|
|
569
|
+
export function computeDiff(oldState, newState, config = {}) {
|
|
570
|
+
const { maxDepth = Infinity, invertible = false } = config;
|
|
571
|
+
// Use fast-json-patch compare for optimal diff generation
|
|
572
|
+
// It automatically detects moves and generates minimal patches
|
|
573
|
+
const operations = fastJsonPatch.compare(oldState, newState);
|
|
574
|
+
// Convert to AQE format
|
|
575
|
+
let result = operations.map((op) => {
|
|
576
|
+
const baseOp = {
|
|
577
|
+
op: op.op,
|
|
578
|
+
path: op.path,
|
|
579
|
+
};
|
|
580
|
+
if ('value' in op) {
|
|
581
|
+
return { ...baseOp, value: op.value };
|
|
582
|
+
}
|
|
583
|
+
if ('from' in op) {
|
|
584
|
+
return { ...baseOp, from: op.from };
|
|
585
|
+
}
|
|
586
|
+
return baseOp;
|
|
587
|
+
});
|
|
588
|
+
// Apply maxDepth filtering if specified
|
|
589
|
+
if (maxDepth < Infinity) {
|
|
590
|
+
result = applyMaxDepthFilter(oldState, newState, result, maxDepth);
|
|
591
|
+
}
|
|
592
|
+
// Generate invertible patch if requested
|
|
593
|
+
if (invertible && config.generateTestOps) {
|
|
594
|
+
result = addTestOperations(oldState, result);
|
|
595
|
+
}
|
|
596
|
+
return result;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Apply max depth filtering - replace deep nested changes with higher-level replaces
|
|
600
|
+
*/
|
|
601
|
+
function applyMaxDepthFilter(oldState, newState, operations, maxDepth) {
|
|
602
|
+
const replacedPaths = new Set();
|
|
603
|
+
const filtered = [];
|
|
604
|
+
for (const op of operations) {
|
|
605
|
+
const depth = op.path.split('/').length - 1;
|
|
606
|
+
if (depth > maxDepth) {
|
|
607
|
+
// Find the path at maxDepth
|
|
608
|
+
const tokens = parsePath(op.path);
|
|
609
|
+
const truncatedTokens = tokens.slice(0, maxDepth);
|
|
610
|
+
const truncatedPath = buildPath(truncatedTokens);
|
|
611
|
+
// Only add one replace operation per truncated path
|
|
612
|
+
if (!replacedPaths.has(truncatedPath)) {
|
|
613
|
+
replacedPaths.add(truncatedPath);
|
|
614
|
+
const newValue = getValueAtPath(newState, truncatedPath);
|
|
615
|
+
filtered.push({ op: 'replace', path: truncatedPath, value: newValue });
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
filtered.push(op);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return filtered;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Add test operations before each modification for invertibility
|
|
626
|
+
*/
|
|
627
|
+
function addTestOperations(document, operations) {
|
|
628
|
+
const result = [];
|
|
629
|
+
for (const op of operations) {
|
|
630
|
+
if (op.op === 'replace' || op.op === 'remove') {
|
|
631
|
+
const currentValue = getValueAtPath(document, op.path);
|
|
632
|
+
result.push({ op: 'test', path: op.path, value: currentValue });
|
|
633
|
+
}
|
|
634
|
+
result.push(op);
|
|
635
|
+
}
|
|
636
|
+
return result;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Generate an observer for watching document changes
|
|
640
|
+
* Returns a function to call when you want to generate the patch
|
|
641
|
+
*/
|
|
642
|
+
export function observe(document
|
|
643
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
644
|
+
) {
|
|
645
|
+
// Cast to object to satisfy fast-json-patch's generic constraint
|
|
646
|
+
const observer = fastJsonPatch.observe(document);
|
|
647
|
+
return {
|
|
648
|
+
observer,
|
|
649
|
+
generate: () => {
|
|
650
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
651
|
+
const ops = fastJsonPatch.generate(observer);
|
|
652
|
+
return ops.map((op) => ({
|
|
653
|
+
op: op.op,
|
|
654
|
+
path: op.path,
|
|
655
|
+
...('value' in op ? { value: op.value } : {}),
|
|
656
|
+
...('from' in op ? { from: op.from } : {}),
|
|
657
|
+
}));
|
|
658
|
+
},
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Unobserve a document (cleanup)
|
|
663
|
+
*/
|
|
664
|
+
export function unobserve(document,
|
|
665
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
666
|
+
observer) {
|
|
667
|
+
fastJsonPatch.unobserve(document, observer);
|
|
668
|
+
}
|
|
669
|
+
// ============================================================================
|
|
670
|
+
// Operation Factories
|
|
671
|
+
// ============================================================================
|
|
672
|
+
/**
|
|
673
|
+
* Create a test operation to validate state before applying patches
|
|
674
|
+
*/
|
|
675
|
+
export function createTestOperation(path, value) {
|
|
676
|
+
return { op: 'test', path, value };
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Create an add operation
|
|
680
|
+
*/
|
|
681
|
+
export function createAddOperation(path, value) {
|
|
682
|
+
return { op: 'add', path, value };
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Create a remove operation
|
|
686
|
+
*/
|
|
687
|
+
export function createRemoveOperation(path) {
|
|
688
|
+
return { op: 'remove', path };
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Create a replace operation
|
|
692
|
+
*/
|
|
693
|
+
export function createReplaceOperation(path, value) {
|
|
694
|
+
return { op: 'replace', path, value };
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Create a move operation
|
|
698
|
+
*/
|
|
699
|
+
export function createMoveOperation(from, path) {
|
|
700
|
+
return { op: 'move', from, path };
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Create a copy operation
|
|
704
|
+
*/
|
|
705
|
+
export function createCopyOperation(from, path) {
|
|
706
|
+
return { op: 'copy', from, path };
|
|
707
|
+
}
|
|
708
|
+
// ============================================================================
|
|
709
|
+
// Utility Exports
|
|
710
|
+
// ============================================================================
|
|
711
|
+
/**
|
|
712
|
+
* Re-export fast-json-patch internals for advanced usage
|
|
713
|
+
*/
|
|
714
|
+
export const fastJsonPatchLib = {
|
|
715
|
+
compare: fastJsonPatch.compare,
|
|
716
|
+
generate: fastJsonPatch.generate,
|
|
717
|
+
observe: fastJsonPatch.observe,
|
|
718
|
+
unobserve: fastJsonPatch.unobserve,
|
|
719
|
+
applyPatch: fastJsonPatch.applyPatch,
|
|
720
|
+
applyOperation: fastJsonPatch.applyOperation,
|
|
721
|
+
validate: fastJsonPatch.validate,
|
|
722
|
+
getValueByPointer: fastJsonPatch.getValueByPointer,
|
|
723
|
+
escapePathComponent: fastJsonPatch.escapePathComponent,
|
|
724
|
+
unescapePathComponent: fastJsonPatch.unescapePathComponent,
|
|
725
|
+
};
|
|
726
|
+
//# sourceMappingURL=json-patch.js.map
|