claude-flow-novice 1.6.1 → 1.6.2
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/cfn-loop/product-owner.md +54 -4
- package/.claude/commands/cfn-claude-sync.md +303 -0
- package/.claude/commands/cfn-loop-epic.md +290 -0
- package/.claude/commands/cfn-loop-single.md +168 -0
- package/.claude/commands/cfn-loop-sprints.md +384 -0
- package/.claude/commands/cfn-loop.md +180 -0
- package/.claude/commands/metrics-summary.md +58 -0
- package/.claude/commands/parse-epic.md +357 -0
- package/.claude/settings.json +4 -4
- package/.claude/settings.local.json +9 -2
- package/.claude-flow-novice/.claude/agents/cfn-loop/product-owner.md +792 -0
- package/.claude-flow-novice/dist/mcp/server.js +21 -2
- package/.claude-flow-novice/dist/src/api/claude-client.js +138 -3
- package/.claude-flow-novice/dist/src/api/claude-client.js.map +1 -1
- package/.claude-flow-novice/dist/src/cfn-loop/phase-orchestrator-example.js +1 -1
- package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js +247 -0
- package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/commands/swarm.js +32 -15
- package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
- package/.claude-flow-novice/dist/src/cli/commands/transparency.js +455 -0
- package/.claude-flow-novice/dist/src/cli/commands/transparency.js.map +1 -0
- package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +129 -13
- package/.claude-flow-novice/dist/src/components/visualizations/index.js +9 -0
- package/.claude-flow-novice/dist/src/components/visualizations/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +462 -0
- package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/config-translator.js +248 -0
- package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +287 -0
- package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js +68 -9
- package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/feature-flags.js +166 -0
- package/.claude-flow-novice/dist/src/coordination/feature-flags.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/queen-agent.js +18 -4
- package/.claude-flow-novice/dist/src/coordination/queen-agent.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/role-assignment.js +6 -110
- package/.claude-flow-novice/dist/src/coordination/role-assignment.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js +632 -0
- package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js +11 -0
- package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js +318 -0
- package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js +364 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js +492 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js +786 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js +16 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js +342 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js +601 -0
- package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js +211 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/index.js +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js +365 -6
- package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js +478 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js +5 -2
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js +189 -0
- package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js +424 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js +9 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js +669 -0
- package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js +451 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js +271 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js +335 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js +439 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js +92 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js +21 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js +223 -0
- package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js +436 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js +278 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js +317 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js +273 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js +15 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js +512 -0
- package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/index.js +6 -0
- package/.claude-flow-novice/dist/src/coordination/v2/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js +557 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js +212 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js +552 -0
- package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js +367 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js +371 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js +355 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js +424 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js +16 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js +295 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js +411 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js +14 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js +387 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js +589 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js +444 -0
- package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js +29 -8
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js +470 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js +450 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js +5 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js +545 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js +44 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js.map +1 -1
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js +415 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js +615 -0
- package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js +259 -0
- package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js +17 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js +357 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js.map +1 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js +679 -0
- package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js.map +1 -0
- package/.claude-flow-novice/dist/src/core/agent-manager.js +30 -0
- package/.claude-flow-novice/dist/src/core/agent-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/mcp/server.js +21 -2
- package/.claude-flow-novice/dist/src/mcp/server.js.map +1 -1
- package/.claude-flow-novice/dist/src/observability/metrics-counter.js +268 -0
- package/.claude-flow-novice/dist/src/observability/metrics-counter.js.map +1 -0
- package/.claude-flow-novice/dist/src/observability/metrics-storage.js +265 -0
- package/.claude-flow-novice/dist/src/observability/metrics-storage.js.map +1 -0
- package/.claude-flow-novice/dist/src/observability/telemetry.js +26 -0
- package/.claude-flow-novice/dist/src/observability/telemetry.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/tiered-router.js +64 -10
- package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
- package/.claude-flow-novice/dist/src/providers/zai-provider.js +196 -97
- package/.claude-flow-novice/dist/src/providers/zai-provider.js.map +1 -1
- package/.claude-flow-novice/dist/src/slash-commands/cfn-claude-sync.js +533 -0
- package/.claude-flow-novice/dist/src/slash-commands/index.js +5 -0
- package/.claude-flow-novice/dist/src/slash-commands/metrics-summary-class.js +74 -0
- package/.claude-flow-novice/dist/src/slash-commands/metrics-summary.js +335 -0
- package/.claude-flow-novice/dist/src/slash-commands/register-all-commands.js +12 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js +96 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js.map +1 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js +406 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js.map +1 -0
- package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js +35 -5
- package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js.map +1 -1
- package/.claude-flow-novice/dist/src/web/api/config/api-config.js +186 -0
- package/.claude-flow-novice/dist/src/web/api/config/api-config.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/auth.js +205 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/auth.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/cache.js +262 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/cache.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js +250 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js +217 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/validation.js +325 -0
- package/.claude-flow-novice/dist/src/web/api/middleware/validation.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/events.js +465 -0
- package/.claude-flow-novice/dist/src/web/api/routes/events.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js +302 -0
- package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/index.js +14 -0
- package/.claude-flow-novice/dist/src/web/api/routes/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/metrics.js +561 -0
- package/.claude-flow-novice/dist/src/web/api/routes/metrics.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/routes/status.js +450 -0
- package/.claude-flow-novice/dist/src/web/api/routes/status.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/api/server.js +451 -0
- package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js +385 -0
- package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/dashboard/index.js +87 -0
- package/.claude-flow-novice/dist/src/web/dashboard/index.js.map +1 -0
- package/.claude-flow-novice/dist/src/web/dashboard/types.js +6 -0
- package/.claude-flow-novice/dist/src/web/dashboard/types.js.map +1 -0
- package/.claude-flow-novice/metrics.db +0 -0
- package/.claude-flow-novice/metrics.db-shm +0 -0
- package/.claude-flow-novice/metrics.db-wal +0 -0
- package/CLAUDE.md +29 -0
- package/README.md +27 -0
- package/config/hooks/post-edit-pipeline.js +36 -2
- package/examples/metrics-counter-demo.ts +106 -0
- package/examples/persistent-metrics-demo.ts +83 -0
- package/examples/phase-5-multi-level-control.ts +282 -0
- package/examples/session-pool-optimizer-example.ts +311 -0
- package/package.json +15 -3
- package/scripts/check-routing-stats.cjs +122 -0
- package/scripts/pre-publish-validation.cjs +212 -0
- package/scripts/test-provider-routing.cjs +228 -0
- package/scripts/test-routing-telemetry.cjs +147 -0
- package/scripts/test-zai-10k.cjs +81 -0
- package/scripts/test-zai-api.cjs +191 -0
- package/scripts/test-zai-diagnostic.cjs +151 -0
- package/scripts/test-zai-final.cjs +128 -0
- package/scripts/test-zai-with-env.cjs +85 -0
- package/scripts/validate-coordination-cli.js +69 -0
- package/scripts/validate-coordination-toggle-integration.cjs +501 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md +29 -0
- package/src/observability/metrics-counter.ts +347 -0
- package/src/observability/metrics-storage.ts +356 -0
- package/src/observability/telemetry.ts +658 -0
- package/src/slash-commands/cfn-claude-sync.js +533 -0
- package/src/slash-commands/index.js +5 -0
- package/src/slash-commands/metrics-summary-class.js +74 -0
- package/src/slash-commands/metrics-summary.js +335 -0
- package/src/slash-commands/register-all-commands.js +12 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload Validator - SEC-INJ-001 Mitigation
|
|
3
|
+
*
|
|
4
|
+
* Validates and sanitizes message payloads to prevent:
|
|
5
|
+
* - Prototype pollution attacks
|
|
6
|
+
* - Code injection via eval/Function
|
|
7
|
+
* - Memory bombs (deeply nested objects)
|
|
8
|
+
* - Oversized payloads
|
|
9
|
+
*
|
|
10
|
+
* @module coordination/v2/security/payload-validator
|
|
11
|
+
*/ /**
|
|
12
|
+
* Payload validation rule configuration.
|
|
13
|
+
*/ /**
|
|
14
|
+
* Payload validation error.
|
|
15
|
+
*/ export class PayloadValidationError extends Error {
|
|
16
|
+
constructor(message){
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = 'PayloadValidationError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Payload Validator Implementation.
|
|
23
|
+
*
|
|
24
|
+
* Provides comprehensive validation and sanitization of message payloads
|
|
25
|
+
* to prevent injection attacks and resource exhaustion.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const validator = new PayloadValidator({
|
|
30
|
+
* maxDepth: 5,
|
|
31
|
+
* maxSize: 1024 * 1024,
|
|
32
|
+
* forbiddenKeys: ['__proto__', 'constructor', 'prototype'],
|
|
33
|
+
* allowedTypes: ['string', 'number', 'boolean', 'object', 'array']
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* const result = validator.validate(userPayload);
|
|
37
|
+
* if (!result.valid) {
|
|
38
|
+
* throw new Error(`Validation failed: ${result.errors.join(', ')}`);
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* const sanitized = validator.sanitize(userPayload);
|
|
42
|
+
* ```
|
|
43
|
+
*/ export class PayloadValidator {
|
|
44
|
+
rules;
|
|
45
|
+
/**
|
|
46
|
+
* Default validation rules (secure defaults).
|
|
47
|
+
*/ static DEFAULT_RULES = {
|
|
48
|
+
maxDepth: 5,
|
|
49
|
+
maxSize: 1024 * 1024,
|
|
50
|
+
allowedTypes: [
|
|
51
|
+
'string',
|
|
52
|
+
'number',
|
|
53
|
+
'boolean',
|
|
54
|
+
'object',
|
|
55
|
+
'array',
|
|
56
|
+
'null'
|
|
57
|
+
],
|
|
58
|
+
forbiddenKeys: [
|
|
59
|
+
'__proto__',
|
|
60
|
+
'constructor',
|
|
61
|
+
'prototype',
|
|
62
|
+
'eval',
|
|
63
|
+
'Function'
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new payload validator.
|
|
68
|
+
*
|
|
69
|
+
* @param rules - Validation rules (uses secure defaults if not provided)
|
|
70
|
+
*/ constructor(rules){
|
|
71
|
+
this.rules = {
|
|
72
|
+
...PayloadValidator.DEFAULT_RULES,
|
|
73
|
+
...rules
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validates a payload against configured rules.
|
|
78
|
+
*
|
|
79
|
+
* @param payload - Payload to validate
|
|
80
|
+
* @returns Validation result with errors if any
|
|
81
|
+
*/ validate(payload) {
|
|
82
|
+
const errors = [];
|
|
83
|
+
try {
|
|
84
|
+
// SEC-INJ-001-BYPASS: Check for prototype chain pollution BEFORE serialization
|
|
85
|
+
// Object literals with __proto__ can pollute the prototype chain before validation runs
|
|
86
|
+
if (typeof payload === 'object' && payload !== null) {
|
|
87
|
+
const proto = Object.getPrototypeOf(payload);
|
|
88
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
89
|
+
errors.push(`Prototype pollution detected: object has modified prototype chain`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// SEC-INJ-001: Check payload size
|
|
93
|
+
const serialized = JSON.stringify(payload);
|
|
94
|
+
const size = Buffer.byteLength(serialized, 'utf8');
|
|
95
|
+
if (size > this.rules.maxSize) {
|
|
96
|
+
errors.push(`Payload size ${size} bytes exceeds maximum ${this.rules.maxSize} bytes`);
|
|
97
|
+
}
|
|
98
|
+
// SEC-INJ-001: Check object depth
|
|
99
|
+
const depth = this.getObjectDepth(payload);
|
|
100
|
+
if (depth > this.rules.maxDepth) {
|
|
101
|
+
errors.push(`Payload depth ${depth} exceeds maximum depth ${this.rules.maxDepth}`);
|
|
102
|
+
}
|
|
103
|
+
// SEC-INJ-001: Check for forbidden keys (prototype pollution vectors)
|
|
104
|
+
const allKeys = this.getAllKeys(payload);
|
|
105
|
+
const foundForbidden = allKeys.filter((key)=>this.rules.forbiddenKeys.includes(key));
|
|
106
|
+
if (foundForbidden.length > 0) {
|
|
107
|
+
errors.push(`Forbidden keys detected: ${foundForbidden.join(', ')}`);
|
|
108
|
+
}
|
|
109
|
+
// SEC-INJ-001: Check for dangerous type patterns
|
|
110
|
+
const typeErrors = this.validateTypes(payload);
|
|
111
|
+
errors.push(...typeErrors);
|
|
112
|
+
return {
|
|
113
|
+
valid: errors.length === 0,
|
|
114
|
+
errors,
|
|
115
|
+
depth,
|
|
116
|
+
size
|
|
117
|
+
};
|
|
118
|
+
} catch (error) {
|
|
119
|
+
// Catch circular reference or serialization errors
|
|
120
|
+
return {
|
|
121
|
+
valid: false,
|
|
122
|
+
errors: [
|
|
123
|
+
`Validation error: ${error instanceof Error ? error.message : String(error)}`
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Sanitizes a payload by removing dangerous keys and normalizing structure.
|
|
130
|
+
*
|
|
131
|
+
* Creates a deep clone with prototype chain stripped to prevent pollution attacks.
|
|
132
|
+
*
|
|
133
|
+
* @param payload - Payload to sanitize
|
|
134
|
+
* @returns Sanitized payload (deep frozen)
|
|
135
|
+
*/ sanitize(payload) {
|
|
136
|
+
if (payload === null || payload === undefined) {
|
|
137
|
+
return payload;
|
|
138
|
+
}
|
|
139
|
+
// SEC-INJ-001: JSON round-trip removes prototype chain and functions
|
|
140
|
+
const serialized = JSON.stringify(payload);
|
|
141
|
+
const parsed = JSON.parse(serialized);
|
|
142
|
+
// SEC-INJ-001: Remove forbidden keys recursively
|
|
143
|
+
const cleaned = this.removeForbiddenKeys(parsed);
|
|
144
|
+
// SEC-INJ-001: Deep freeze to prevent modification
|
|
145
|
+
return this.deepFreeze(cleaned);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Gets the maximum depth of an object.
|
|
149
|
+
*
|
|
150
|
+
* @param obj - Object to measure
|
|
151
|
+
* @param currentDepth - Current recursion depth (internal)
|
|
152
|
+
* @returns Maximum nesting depth
|
|
153
|
+
*/ getObjectDepth(obj, currentDepth = 0) {
|
|
154
|
+
if (obj === null || typeof obj !== 'object') {
|
|
155
|
+
return currentDepth;
|
|
156
|
+
}
|
|
157
|
+
if (Array.isArray(obj)) {
|
|
158
|
+
if (obj.length === 0) return currentDepth + 1;
|
|
159
|
+
return Math.max(...obj.map((item)=>this.getObjectDepth(item, currentDepth + 1)));
|
|
160
|
+
}
|
|
161
|
+
const keys = Object.keys(obj);
|
|
162
|
+
if (keys.length === 0) return currentDepth + 1;
|
|
163
|
+
return Math.max(...keys.map((key)=>this.getObjectDepth(obj[key], currentDepth + 1)));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Extracts all keys from an object recursively.
|
|
167
|
+
*
|
|
168
|
+
* @param obj - Object to extract keys from
|
|
169
|
+
* @returns Array of all keys (including nested)
|
|
170
|
+
*/ getAllKeys(obj) {
|
|
171
|
+
if (obj === null || typeof obj !== 'object') {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
const keys = [];
|
|
175
|
+
if (Array.isArray(obj)) {
|
|
176
|
+
obj.forEach((item)=>{
|
|
177
|
+
keys.push(...this.getAllKeys(item));
|
|
178
|
+
});
|
|
179
|
+
} else {
|
|
180
|
+
// FIX SEC-INJ-001: Use getOwnPropertyNames + getOwnPropertySymbols
|
|
181
|
+
// to detect non-enumerable properties like __proto__, constructor
|
|
182
|
+
const propertyNames = Object.getOwnPropertyNames(obj);
|
|
183
|
+
const propertySymbols = Object.getOwnPropertySymbols(obj);
|
|
184
|
+
propertyNames.forEach((key)=>{
|
|
185
|
+
keys.push(key);
|
|
186
|
+
keys.push(...this.getAllKeys(obj[key]));
|
|
187
|
+
});
|
|
188
|
+
// Include symbol properties for comprehensive coverage
|
|
189
|
+
propertySymbols.forEach((sym)=>{
|
|
190
|
+
keys.push(sym.toString());
|
|
191
|
+
keys.push(...this.getAllKeys(obj[sym]));
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return keys;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Validates payload types recursively.
|
|
198
|
+
*
|
|
199
|
+
* @param obj - Object to validate
|
|
200
|
+
* @returns Array of type validation errors
|
|
201
|
+
*/ validateTypes(obj) {
|
|
202
|
+
const errors = [];
|
|
203
|
+
if (obj === null) {
|
|
204
|
+
return errors; // null is allowed
|
|
205
|
+
}
|
|
206
|
+
const type = Array.isArray(obj) ? 'array' : typeof obj;
|
|
207
|
+
if (!this.rules.allowedTypes.includes(type)) {
|
|
208
|
+
errors.push(`Type '${type}' not allowed in payload`);
|
|
209
|
+
return errors; // Don't recurse into invalid types
|
|
210
|
+
}
|
|
211
|
+
if (type === 'object' || type === 'array') {
|
|
212
|
+
const values = Array.isArray(obj) ? obj : Object.values(obj);
|
|
213
|
+
values.forEach((value)=>{
|
|
214
|
+
errors.push(...this.validateTypes(value));
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
return errors;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Removes forbidden keys from object recursively.
|
|
221
|
+
*
|
|
222
|
+
* @param obj - Object to clean
|
|
223
|
+
* @returns Cleaned object
|
|
224
|
+
*/ removeForbiddenKeys(obj) {
|
|
225
|
+
if (obj === null || typeof obj !== 'object') {
|
|
226
|
+
return obj;
|
|
227
|
+
}
|
|
228
|
+
if (Array.isArray(obj)) {
|
|
229
|
+
return obj.map((item)=>this.removeForbiddenKeys(item));
|
|
230
|
+
}
|
|
231
|
+
const cleaned = {};
|
|
232
|
+
Object.keys(obj).forEach((key)=>{
|
|
233
|
+
if (!this.rules.forbiddenKeys.includes(key)) {
|
|
234
|
+
cleaned[key] = this.removeForbiddenKeys(obj[key]);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
return cleaned;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Deep freezes an object to prevent modification.
|
|
241
|
+
*
|
|
242
|
+
* @param obj - Object to freeze
|
|
243
|
+
* @returns Frozen object
|
|
244
|
+
*/ deepFreeze(obj) {
|
|
245
|
+
if (obj === null || typeof obj !== 'object') {
|
|
246
|
+
return obj;
|
|
247
|
+
}
|
|
248
|
+
if (Array.isArray(obj)) {
|
|
249
|
+
obj.forEach((item)=>this.deepFreeze(item));
|
|
250
|
+
} else {
|
|
251
|
+
Object.keys(obj).forEach((key)=>{
|
|
252
|
+
this.deepFreeze(obj[key]);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return Object.freeze(obj);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
//# sourceMappingURL=payload-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/coordination/v2/security/payload-validator.ts"],"names":["PayloadValidationError","Error","message","name","PayloadValidator","rules","DEFAULT_RULES","maxDepth","maxSize","allowedTypes","forbiddenKeys","validate","payload","errors","proto","Object","getPrototypeOf","prototype","push","serialized","JSON","stringify","size","Buffer","byteLength","depth","getObjectDepth","allKeys","getAllKeys","foundForbidden","filter","key","includes","length","join","typeErrors","validateTypes","valid","error","String","sanitize","undefined","parsed","parse","cleaned","removeForbiddenKeys","deepFreeze","obj","currentDepth","Array","isArray","Math","max","map","item","keys","forEach","propertyNames","getOwnPropertyNames","propertySymbols","getOwnPropertySymbols","sym","toString","type","values","value","freeze"],"mappings":"AAAA;;;;;;;;;;CAUC,GAED;;CAEC,GAgCD;;CAEC,GACD,OAAO,MAAMA,+BAA+BC;IAC1C,YAAYC,OAAe,CAAE;QAC3B,KAAK,CAACA;QACN,IAAI,CAACC,IAAI,GAAG;IACd;AACF;AAEA;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,MAAMC;IACHC,MAA6B;IAErC;;GAEC,GACD,OAAOC,gBAAuC;QAC5CC,UAAU;QACVC,SAAS,OAAO;QAChBC,cAAc;YAAC;YAAU;YAAU;YAAW;YAAU;YAAS;SAAO;QACxEC,eAAe;YAAC;YAAa;YAAe;YAAa;YAAQ;SAAW;IAC9E,EAAE;IAEF;;;;GAIC,GACD,YAAYL,KAAsC,CAAE;QAClD,IAAI,CAACA,KAAK,GAAG;YACX,GAAGD,iBAAiBE,aAAa;YACjC,GAAGD,KAAK;QACV;IACF;IAEA;;;;;GAKC,GACDM,SAASC,OAAY,EAAoB;QACvC,MAAMC,SAAmB,EAAE;QAE3B,IAAI;YACF,+EAA+E;YAC/E,wFAAwF;YACxF,IAAI,OAAOD,YAAY,YAAYA,YAAY,MAAM;gBACnD,MAAME,QAAQC,OAAOC,cAAc,CAACJ;gBACpC,IAAIE,UAAUC,OAAOE,SAAS,IAAIH,UAAU,MAAM;oBAChDD,OAAOK,IAAI,CAAC,CAAC,iEAAiE,CAAC;gBACjF;YACF;YAEA,kCAAkC;YAClC,MAAMC,aAAaC,KAAKC,SAAS,CAACT;YAClC,MAAMU,OAAOC,OAAOC,UAAU,CAACL,YAAY;YAE3C,IAAIG,OAAO,IAAI,CAACjB,KAAK,CAACG,OAAO,EAAE;gBAC7BK,OAAOK,IAAI,CACT,CAAC,aAAa,EAAEI,KAAK,uBAAuB,EAAE,IAAI,CAACjB,KAAK,CAACG,OAAO,CAAC,MAAM,CAAC;YAE5E;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,GAAQ,EAAO;QAChC,IAAIA,QAAQ,QAAQ,OAAOA,QAAQ,UAAU;YAC3C,OAAOA;QACT;QAEA,IAAIE,MAAMC,OAAO,CAACH,MAAM;YACtBA,IAAIS,OAAO,CAACF,CAAAA,OAAQ,IAAI,CAACR,UAAU,CAACQ;QACtC,OAAO;YACLvC,OAAOwC,IAAI,CAACR,KAAKS,OAAO,CAACzB,CAAAA;gBACvB,IAAI,CAACe,UAAU,CAACC,GAAG,CAAChB,IAAI;YAC1B;QACF;QAEA,OAAOhB,OAAOmD,MAAM,CAACnB;IACvB;AACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V2 Coordination Transparency System
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive transparency and monitoring for multi-level agent coordination.
|
|
5
|
+
* Provides real-time visibility into agent operations, hierarchy relationships,
|
|
6
|
+
* and performance metrics.
|
|
7
|
+
*
|
|
8
|
+
* @module coordination/v2/transparency
|
|
9
|
+
*/ // Core interfaces and types
|
|
10
|
+
// Core implementation
|
|
11
|
+
export { TransparencySystem } from './transparency-system.js';
|
|
12
|
+
// Integration layer
|
|
13
|
+
export { TransparentCoordinator, withTransparency } from './transparency-integration.js';
|
|
14
|
+
// CLI interface
|
|
15
|
+
export { createTransparencyCommand } from '../../cli/commands/transparency.js';
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/coordination/v2/transparency/index.ts"],"names":["TransparencySystem","TransparentCoordinator","withTransparency","createTransparencyCommand"],"mappings":"AAAA;;;;;;;;CAQC,GAED,4BAA4B;AAW5B,sBAAsB;AACtB,SAASA,kBAAkB,QAAQ,2BAA2B;AAE9D,oBAAoB;AACpB,SAASC,sBAAsB,EAAEC,gBAAgB,QAAQ,gCAAgC;AAEzF,gBAAgB;AAChB,SAASC,yBAAyB,QAAQ,qCAAqC"}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transparency System Integration
|
|
3
|
+
*
|
|
4
|
+
* Integrates transparency monitoring with V2 coordinator for real-time
|
|
5
|
+
* agent visibility, hierarchy tracking, and performance metrics.
|
|
6
|
+
*
|
|
7
|
+
* @module coordination/v2/transparency/transparency-integration
|
|
8
|
+
*/ import { TransparencySystem } from './transparency-system.js';
|
|
9
|
+
import { Logger } from '../../../core/logger.js';
|
|
10
|
+
/**
|
|
11
|
+
* Enhanced coordinator with transparency integration
|
|
12
|
+
*
|
|
13
|
+
* Wraps any ICoordinator implementation to add transparency features:
|
|
14
|
+
* - Automatic agent registration/deregistration
|
|
15
|
+
* - State change tracking
|
|
16
|
+
* - Performance monitoring
|
|
17
|
+
* - Event streaming
|
|
18
|
+
*/ export class TransparentCoordinator {
|
|
19
|
+
logger = new Logger({
|
|
20
|
+
level: 'info',
|
|
21
|
+
format: 'text',
|
|
22
|
+
destination: 'console'
|
|
23
|
+
});
|
|
24
|
+
baseCoordinator;
|
|
25
|
+
transparency;
|
|
26
|
+
agentMetadata = new Map();
|
|
27
|
+
constructor(baseCoordinator){
|
|
28
|
+
this.baseCoordinator = baseCoordinator;
|
|
29
|
+
this.transparency = new TransparencySystem();
|
|
30
|
+
}
|
|
31
|
+
// ===========================
|
|
32
|
+
// Coordinator Lifecycle
|
|
33
|
+
// ===========================
|
|
34
|
+
async initialize() {
|
|
35
|
+
this.logger.info('Initializing TransparentCoordinator');
|
|
36
|
+
// Initialize base coordinator
|
|
37
|
+
await this.baseCoordinator.initialize();
|
|
38
|
+
// Initialize transparency system
|
|
39
|
+
await this.transparency.initialize({
|
|
40
|
+
enableRealTimeMonitoring: true,
|
|
41
|
+
enableEventStreaming: true,
|
|
42
|
+
enablePerformanceTracking: true,
|
|
43
|
+
enableDependencyTracking: true,
|
|
44
|
+
metricsUpdateIntervalMs: 5000,
|
|
45
|
+
heartbeatIntervalMs: 10000
|
|
46
|
+
});
|
|
47
|
+
// Start transparency monitoring
|
|
48
|
+
await this.transparency.startMonitoring();
|
|
49
|
+
// Register transparency event listeners
|
|
50
|
+
this.registerTransparencyListeners();
|
|
51
|
+
this.logger.info('TransparentCoordinator initialized successfully');
|
|
52
|
+
}
|
|
53
|
+
async cleanup() {
|
|
54
|
+
this.logger.info('Cleaning up TransparentCoordinator');
|
|
55
|
+
// Stop transparency monitoring
|
|
56
|
+
await this.transparency.cleanup();
|
|
57
|
+
// Cleanup base coordinator
|
|
58
|
+
await this.baseCoordinator.cleanup();
|
|
59
|
+
this.logger.info('TransparentCoordinator cleanup complete');
|
|
60
|
+
}
|
|
61
|
+
isReady() {
|
|
62
|
+
return this.baseCoordinator.isReady();
|
|
63
|
+
}
|
|
64
|
+
// ===========================
|
|
65
|
+
// Agent Lifecycle (Enhanced with Transparency)
|
|
66
|
+
// ===========================
|
|
67
|
+
async spawnAgent(config) {
|
|
68
|
+
const startTime = Date.now();
|
|
69
|
+
// Spawn agent through base coordinator
|
|
70
|
+
const agent = await this.baseCoordinator.spawnAgent(config);
|
|
71
|
+
// Calculate spawn time
|
|
72
|
+
const spawnTimeMs = Date.now() - startTime;
|
|
73
|
+
// Determine parent agent from metadata or hierarchy
|
|
74
|
+
const parentAgentId = this.determineParentAgentId(agent);
|
|
75
|
+
// Register agent with transparency system
|
|
76
|
+
this.transparency.registerAgent(agent, parentAgentId);
|
|
77
|
+
// Store additional metadata
|
|
78
|
+
this.agentMetadata.set(agent.agentId, {
|
|
79
|
+
...config,
|
|
80
|
+
spawnTimeMs,
|
|
81
|
+
parentAgentId,
|
|
82
|
+
registeredAt: new Date()
|
|
83
|
+
});
|
|
84
|
+
this.logger.info(`Agent ${agent.agentId} spawned and registered with transparency`, {
|
|
85
|
+
type: agent.type,
|
|
86
|
+
level: await this.getAgentLevel(agent.agentId),
|
|
87
|
+
spawnTimeMs,
|
|
88
|
+
parentAgentId
|
|
89
|
+
});
|
|
90
|
+
return agent;
|
|
91
|
+
}
|
|
92
|
+
async pauseAgent(agentId, reason) {
|
|
93
|
+
const pauseStartTime = Date.now();
|
|
94
|
+
// Get current state for transparency tracking
|
|
95
|
+
const currentState = await this.baseCoordinator.getAgentState(agentId);
|
|
96
|
+
// Pause agent through base coordinator
|
|
97
|
+
await this.baseCoordinator.pauseAgent(agentId, reason);
|
|
98
|
+
// Record pause in transparency
|
|
99
|
+
this.transparency.updateAgentState(agentId, 'paused', reason);
|
|
100
|
+
const pauseLatencyMs = Date.now() - pauseStartTime;
|
|
101
|
+
this.logger.info(`Agent ${agentId} paused`, {
|
|
102
|
+
reason,
|
|
103
|
+
pauseLatencyMs,
|
|
104
|
+
previousState: currentState
|
|
105
|
+
});
|
|
106
|
+
// Update performance metrics
|
|
107
|
+
this.updatePerformanceMetrics(agentId, {
|
|
108
|
+
pauseLatencyMs
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
async resumeAgent(agentId, checkpointId, messageUUID) {
|
|
112
|
+
const resumeStartTime = Date.now();
|
|
113
|
+
// Resume agent through base coordinator
|
|
114
|
+
await this.baseCoordinator.resumeAgent(agentId, checkpointId, messageUUID);
|
|
115
|
+
// Record resume in transparency
|
|
116
|
+
this.transparency.updateAgentState(agentId, 'active', 'Resumed from checkpoint');
|
|
117
|
+
const resumeLatencyMs = Date.now() - resumeStartTime;
|
|
118
|
+
this.logger.info(`Agent ${agentId} resumed`, {
|
|
119
|
+
checkpointId,
|
|
120
|
+
messageUUID,
|
|
121
|
+
resumeLatencyMs
|
|
122
|
+
});
|
|
123
|
+
// Update performance metrics
|
|
124
|
+
this.updatePerformanceMetrics(agentId, {
|
|
125
|
+
resumeLatencyMs
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async terminateAgent(agentId, reason) {
|
|
129
|
+
// Get final state for transparency tracking
|
|
130
|
+
const finalState = await this.baseCoordinator.getAgentState(agentId);
|
|
131
|
+
// Terminate agent through base coordinator
|
|
132
|
+
await this.baseCoordinator.terminateAgent(agentId, reason);
|
|
133
|
+
// Record termination in transparency
|
|
134
|
+
this.transparency.updateAgentState(agentId, 'terminated', reason);
|
|
135
|
+
// Cleanup agent metadata
|
|
136
|
+
this.agentMetadata.delete(agentId);
|
|
137
|
+
this.logger.info(`Agent ${agentId} terminated`, {
|
|
138
|
+
reason,
|
|
139
|
+
finalState
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
// ===========================
|
|
143
|
+
// State Management (Enhanced with Transparency)
|
|
144
|
+
// ===========================
|
|
145
|
+
async getAgentState(agentId) {
|
|
146
|
+
const state = await this.baseCoordinator.getAgentState(agentId);
|
|
147
|
+
// Update transparency state tracking
|
|
148
|
+
this.transparency.updateAgentState(agentId, state);
|
|
149
|
+
return state;
|
|
150
|
+
}
|
|
151
|
+
async getAgentSession(agentId) {
|
|
152
|
+
return await this.baseCoordinator.getAgentSession(agentId);
|
|
153
|
+
}
|
|
154
|
+
async createCheckpoint(agentId, reason, metadata) {
|
|
155
|
+
// Create checkpoint through base coordinator
|
|
156
|
+
const checkpoint = await this.baseCoordinator.createCheckpoint(agentId, reason, metadata);
|
|
157
|
+
// Record checkpoint creation in transparency
|
|
158
|
+
this.transparency.updateAgentState(agentId, 'checkpointing', reason);
|
|
159
|
+
this.logger.debug(`Checkpoint created for agent ${agentId}`, {
|
|
160
|
+
checkpointId: checkpoint.id,
|
|
161
|
+
reason
|
|
162
|
+
});
|
|
163
|
+
return checkpoint;
|
|
164
|
+
}
|
|
165
|
+
async restoreCheckpoint(checkpointId) {
|
|
166
|
+
// Restore checkpoint through base coordinator
|
|
167
|
+
const agent = await this.baseCoordinator.restoreCheckpoint(checkpointId);
|
|
168
|
+
// Record checkpoint restoration in transparency
|
|
169
|
+
this.transparency.updateAgentState(agent.agentId, 'active', 'Restored from checkpoint');
|
|
170
|
+
this.logger.info(`Checkpoint restored for agent ${agent.agentId}`, {
|
|
171
|
+
checkpointId
|
|
172
|
+
});
|
|
173
|
+
return agent;
|
|
174
|
+
}
|
|
175
|
+
async listCheckpoints(agentId, limit) {
|
|
176
|
+
return await this.baseCoordinator.listCheckpoints(agentId, limit);
|
|
177
|
+
}
|
|
178
|
+
// ===========================
|
|
179
|
+
// Metrics & Monitoring (Enhanced with Transparency)
|
|
180
|
+
// ===========================
|
|
181
|
+
getMetrics() {
|
|
182
|
+
const baseMetrics = this.baseCoordinator.getMetrics();
|
|
183
|
+
// Add transparency-specific metrics
|
|
184
|
+
return {
|
|
185
|
+
...baseMetrics,
|
|
186
|
+
transparency: {
|
|
187
|
+
// These will be populated asynchronously
|
|
188
|
+
agentHierarchyDepth: 0,
|
|
189
|
+
agentDistribution: {},
|
|
190
|
+
eventStreamStats: {
|
|
191
|
+
totalEvents: 0,
|
|
192
|
+
eventsPerSecond: 0
|
|
193
|
+
},
|
|
194
|
+
performanceAlerts: 0
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
getActiveAgents() {
|
|
199
|
+
return this.baseCoordinator.getActiveAgents();
|
|
200
|
+
}
|
|
201
|
+
getPausedAgents() {
|
|
202
|
+
return this.baseCoordinator.getPausedAgents();
|
|
203
|
+
}
|
|
204
|
+
async updateTokenUsage(agentId, tokensUsed) {
|
|
205
|
+
// Update base coordinator
|
|
206
|
+
await this.baseCoordinator.updateTokenUsage(agentId, tokensUsed);
|
|
207
|
+
// Update transparency tracking
|
|
208
|
+
this.transparency.updateTokenUsage(agentId, tokensUsed);
|
|
209
|
+
}
|
|
210
|
+
// ===========================
|
|
211
|
+
// Transparency-Specific Methods
|
|
212
|
+
// ===========================
|
|
213
|
+
/**
|
|
214
|
+
* Get transparency system instance
|
|
215
|
+
*/ getTransparencySystem() {
|
|
216
|
+
return this.transparency;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Get agent hierarchy information
|
|
220
|
+
*/ async getAgentHierarchy() {
|
|
221
|
+
return await this.transparency.getAgentHierarchy();
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get real-time agent statuses
|
|
225
|
+
*/ async getAgentStatuses() {
|
|
226
|
+
return await this.transparency.getAllAgentStatuses();
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Get recent lifecycle events
|
|
230
|
+
*/ async getRecentEvents(limit = 100) {
|
|
231
|
+
return await this.transparency.getRecentEvents(limit);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Get transparency metrics
|
|
235
|
+
*/ async getTransparencyMetrics() {
|
|
236
|
+
return await this.transparency.getTransparencyMetrics();
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Get performance metrics for specific agent
|
|
240
|
+
*/ async getAgentPerformanceMetrics(agentId) {
|
|
241
|
+
return await this.transparency.getAgentPerformanceMetrics(agentId);
|
|
242
|
+
}
|
|
243
|
+
// ===========================
|
|
244
|
+
// Private Helper Methods
|
|
245
|
+
// ===========================
|
|
246
|
+
determineParentAgentId(agent) {
|
|
247
|
+
// Try to determine parent from agent metadata
|
|
248
|
+
const metadata = this.agentMetadata.get(agent.agentId);
|
|
249
|
+
if (metadata?.parentAgentId) {
|
|
250
|
+
return metadata.parentAgentId;
|
|
251
|
+
}
|
|
252
|
+
// Try to determine from agent type and session
|
|
253
|
+
// This is a simplified heuristic - in practice, you'd have
|
|
254
|
+
// more sophisticated parent-child relationship tracking
|
|
255
|
+
const agentType = agent.type;
|
|
256
|
+
const sessionId = agent.sessionId;
|
|
257
|
+
// For certain agent types, we can infer hierarchy
|
|
258
|
+
if (agentType.includes('helper') || agentType.includes('-helper')) {
|
|
259
|
+
// Helper agents usually have parent workers
|
|
260
|
+
return this.findAgentInSession(sessionId, agentType.replace('-helper', '').replace('helper-', ''));
|
|
261
|
+
}
|
|
262
|
+
if (agentType.includes('worker')) {
|
|
263
|
+
// Workers might have root orchestrator as parent
|
|
264
|
+
return this.findAgentInSession(sessionId, 'orchestrator');
|
|
265
|
+
}
|
|
266
|
+
return undefined; // No parent found (root level)
|
|
267
|
+
}
|
|
268
|
+
async findAgentInSession(sessionId, type) {
|
|
269
|
+
try {
|
|
270
|
+
const allAgents = await this.transparency.getAgentHierarchy();
|
|
271
|
+
const found = allAgents.find((agent)=>agent.sessionId === sessionId && agent.type === type && agent.state !== 'terminated');
|
|
272
|
+
return found?.agentId;
|
|
273
|
+
} catch (error) {
|
|
274
|
+
this.logger.warn('Error finding parent agent', error);
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
async getAgentLevel(agentId) {
|
|
279
|
+
try {
|
|
280
|
+
const hierarchy = await this.transparency.getAgentHierarchy();
|
|
281
|
+
const agent = hierarchy.find((a)=>a.agentId === agentId);
|
|
282
|
+
return agent?.level || 1;
|
|
283
|
+
} catch (error) {
|
|
284
|
+
this.logger.warn('Error getting agent level', error);
|
|
285
|
+
return 1;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
updatePerformanceMetrics(agentId, metrics) {
|
|
289
|
+
// Store performance metrics in agent metadata
|
|
290
|
+
const existing = this.agentMetadata.get(agentId) || {};
|
|
291
|
+
const performance = existing.performance || {};
|
|
292
|
+
this.agentMetadata.set(agentId, {
|
|
293
|
+
...existing,
|
|
294
|
+
performance: {
|
|
295
|
+
...performance,
|
|
296
|
+
...metrics,
|
|
297
|
+
lastUpdated: new Date()
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
registerTransparencyListeners() {
|
|
302
|
+
// Register for hierarchy changes
|
|
303
|
+
this.transparency.registerEventListener({
|
|
304
|
+
onHierarchyChange: (change)=>{
|
|
305
|
+
this.logger.info('Agent hierarchy changed', {
|
|
306
|
+
type: change.type,
|
|
307
|
+
agentId: change.agentId
|
|
308
|
+
});
|
|
309
|
+
},
|
|
310
|
+
onAgentStateChange: (change)=>{
|
|
311
|
+
this.logger.debug('Agent state changed', {
|
|
312
|
+
agentId: change.agentId,
|
|
313
|
+
previousState: change.previousState,
|
|
314
|
+
newState: change.newState
|
|
315
|
+
});
|
|
316
|
+
},
|
|
317
|
+
onMetricsUpdate: (metrics)=>{
|
|
318
|
+
// Update coordinator metrics with transparency data
|
|
319
|
+
this.updateCoordinatorMetrics(metrics);
|
|
320
|
+
},
|
|
321
|
+
onLifecycleEvent: (event)=>{
|
|
322
|
+
this.logger.debug('Agent lifecycle event', {
|
|
323
|
+
agentId: event.agentId,
|
|
324
|
+
eventType: event.eventType
|
|
325
|
+
});
|
|
326
|
+
},
|
|
327
|
+
onPerformanceAlert: (alert)=>{
|
|
328
|
+
this.logger.warn('Performance alert', {
|
|
329
|
+
agentId: alert.agentId,
|
|
330
|
+
metric: alert.metric,
|
|
331
|
+
value: alert.value,
|
|
332
|
+
threshold: alert.threshold,
|
|
333
|
+
severity: alert.severity
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
updateCoordinatorMetrics(transparencyMetrics) {
|
|
339
|
+
// This would update the base coordinator's metrics
|
|
340
|
+
// to include transparency information
|
|
341
|
+
// Implementation depends on the specific coordinator type
|
|
342
|
+
this.logger.debug('Updating coordinator metrics with transparency data', {
|
|
343
|
+
totalAgents: transparencyMetrics.totalAgents,
|
|
344
|
+
eventStreamStats: transparencyMetrics.eventStreamStats
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Factory function to wrap any coordinator with transparency
|
|
350
|
+
*
|
|
351
|
+
* @param baseCoordinator - Base coordinator to wrap
|
|
352
|
+
* @returns Transparent coordinator instance
|
|
353
|
+
*/ export function withTransparency(baseCoordinator) {
|
|
354
|
+
return new TransparentCoordinator(baseCoordinator);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
//# sourceMappingURL=transparency-integration.js.map
|
package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/coordination/v2/transparency/transparency-integration.ts"],"names":["TransparencySystem","Logger","TransparentCoordinator","logger","level","format","destination","baseCoordinator","transparency","agentMetadata","Map","initialize","info","enableRealTimeMonitoring","enableEventStreaming","enablePerformanceTracking","enableDependencyTracking","metricsUpdateIntervalMs","heartbeatIntervalMs","startMonitoring","registerTransparencyListeners","cleanup","isReady","spawnAgent","config","startTime","Date","now","agent","spawnTimeMs","parentAgentId","determineParentAgentId","registerAgent","set","agentId","registeredAt","type","getAgentLevel","pauseAgent","reason","pauseStartTime","currentState","getAgentState","updateAgentState","pauseLatencyMs","previousState","updatePerformanceMetrics","resumeAgent","checkpointId","messageUUID","resumeStartTime","resumeLatencyMs","terminateAgent","finalState","delete","state","getAgentSession","createCheckpoint","metadata","checkpoint","debug","id","restoreCheckpoint","listCheckpoints","limit","getMetrics","baseMetrics","agentHierarchyDepth","agentDistribution","eventStreamStats","totalEvents","eventsPerSecond","performanceAlerts","getActiveAgents","getPausedAgents","updateTokenUsage","tokensUsed","getTransparencySystem","getAgentHierarchy","getAgentStatuses","getAllAgentStatuses","getRecentEvents","getTransparencyMetrics","getAgentPerformanceMetrics","get","agentType","sessionId","includes","findAgentInSession","replace","undefined","allAgents","found","find","error","warn","hierarchy","a","metrics","existing","performance","lastUpdated","registerEventListener","onHierarchyChange","change","onAgentStateChange","newState","onMetricsUpdate","updateCoordinatorMetrics","onLifecycleEvent","event","eventType","onPerformanceAlert","alert","metric","value","threshold","severity","transparencyMetrics","totalAgents","withTransparency"],"mappings":"AAAA;;;;;;;CAOC,GAID,SAASA,kBAAkB,QAAQ,2BAA2B;AAE9D,SAASC,MAAM,QAAQ,0BAA0B;AAEjD;;;;;;;;CAQC,GACD,OAAO,MAAMC;IACMC,SAAS,IAAIF,OAAO;QACnCG,OAAO;QACPC,QAAQ;QACRC,aAAa;IACf,GAAG;IAEcC,gBAA8B;IAC9BC,aAAiC;IACjCC,gBAAgB,IAAIC,MAAmB;IAExD,YAAYH,eAA6B,CAAE;QACzC,IAAI,CAACA,eAAe,GAAGA;QACvB,IAAI,CAACC,YAAY,GAAG,IAAIR;IAC1B;IAEA,8BAA8B;IAC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