feat: Add intelligent auto-router and enhanced integrations

- Add intelligent-router.sh hook for automatic agent routing
- Add AUTO-TRIGGER-SUMMARY.md documentation
- Add FINAL-INTEGRATION-SUMMARY.md documentation
- Complete Prometheus integration (6 commands + 4 tools)
- Complete Dexto integration (12 commands + 5 tools)
- Enhanced Ralph with access to all agents
- Fix /clawd command (removed disable-model-invocation)
- Update hooks.json to v5 with intelligent routing
- 291 total skills now available
- All 21 commands with automatic routing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
admin
2026-01-28 00:27:56 +04:00
Unverified
parent 3b128ba3bd
commit b52318eeae
1724 changed files with 351216 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
// TODO: Add fallback strategy for non-Node.js environments (browsers, edge workers)
// For now, this will work in Node.js (CLI API server, standalone deployments).
// Future: Consider session metadata fallback when AsyncLocalStorage is unavailable.
import { AsyncLocalStorage } from 'async_hooks';
/**
* Context data stored in AsyncLocalStorage
* Used for multi-tenant deployments to propagate tenant/user information
*/
export interface AsyncContext {
/** Tenant ID for multi-tenant deployments */
tenantId?: string;
/** User ID for tracking which user is making the request */
userId?: string;
}
/**
* AsyncLocalStorage instance for storing request context
* This automatically propagates across async boundaries in Node.js
*/
const asyncContext = new AsyncLocalStorage<AsyncContext>();
/**
* Set the current async context
* Should be called at the entry point of a request (e.g., Express middleware)
*
* @param ctx - Context to set
*
* @example
* ```typescript
* // In Express middleware
* app.use((req, res, next) => {
* const { tenantId, userId } = extractAuthFromRequest(req);
* setContext({ tenantId, userId });
* next();
* });
* ```
*/
export function setContext(ctx: AsyncContext): void {
asyncContext.enterWith(ctx);
}
/**
* Get the current async context
* Returns undefined if no context is set
*
* @returns Current context or undefined
*
* @example
* ```typescript
* // In plugin or service
* const ctx = getContext();
* if (ctx?.tenantId) {
* // Use tenant ID for scoped operations
* }
* ```
*/
export function getContext(): AsyncContext | undefined {
return asyncContext.getStore();
}
/**
* Run a function with a specific context
* Useful for testing or when you need to override context temporarily
*
* @param ctx - Context to run with
* @param fn - Function to execute
* @returns Result of the function
*
* @example
* ```typescript
* await runWithContext({ tenantId: 'test-tenant' }, async () => {
* // This code runs with the specified context
* await someOperation();
* });
* ```
*/
export async function runWithContext<T>(ctx: AsyncContext, fn: () => Promise<T>): Promise<T> {
return asyncContext.run(ctx, fn);
}
/**
* Check if AsyncLocalStorage is available in the current environment
* Returns false in non-Node.js environments (browsers, edge workers)
*
* @returns true if AsyncLocalStorage is available
*/
export function isAsyncContextAvailable(): boolean {
try {
// Check if async_hooks module exists
return typeof AsyncLocalStorage !== 'undefined';
} catch {
return false;
}
}