stringray-ai 1.0.37 → 1.0.39

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.
Files changed (115) hide show
  1. package/dist/plugin/architectural-integrity.d.ts +21 -0
  2. package/dist/plugin/architectural-integrity.d.ts.map +1 -0
  3. package/dist/plugin/architectural-integrity.js +81 -0
  4. package/dist/plugin/architectural-integrity.js.map +1 -0
  5. package/dist/plugin/boot-orchestrator.d.ts +100 -0
  6. package/dist/plugin/boot-orchestrator.d.ts.map +1 -0
  7. package/dist/plugin/boot-orchestrator.js +606 -0
  8. package/dist/plugin/boot-orchestrator.js.map +1 -0
  9. package/dist/plugin/codex-injector.d.ts +72 -0
  10. package/dist/plugin/codex-injector.d.ts.map +1 -0
  11. package/dist/plugin/codex-injector.js +387 -0
  12. package/dist/plugin/codex-injector.js.map +1 -0
  13. package/dist/plugin/delegation/index.d.ts +16 -0
  14. package/dist/plugin/delegation/index.d.ts.map +1 -0
  15. package/dist/plugin/delegation/index.js +13 -0
  16. package/dist/plugin/delegation/index.js.map +1 -0
  17. package/dist/plugin/delegation/session-coordinator.d.ts +121 -0
  18. package/dist/plugin/delegation/session-coordinator.d.ts.map +1 -0
  19. package/dist/plugin/delegation/session-coordinator.js +346 -0
  20. package/dist/plugin/delegation/session-coordinator.js.map +1 -0
  21. package/dist/plugin/index.d.ts +3 -0
  22. package/dist/plugin/index.d.ts.map +1 -0
  23. package/dist/plugin/index.js +3 -0
  24. package/dist/plugin/index.js.map +1 -0
  25. package/dist/plugin/monitoring/memory-monitor.d.ts +113 -0
  26. package/dist/plugin/monitoring/memory-monitor.d.ts.map +1 -0
  27. package/dist/plugin/monitoring/memory-monitor.js +283 -0
  28. package/dist/plugin/monitoring/memory-monitor.js.map +1 -0
  29. package/dist/plugin/postprocessor/PostProcessor.d.ts +90 -0
  30. package/dist/plugin/postprocessor/PostProcessor.d.ts.map +1 -0
  31. package/dist/plugin/postprocessor/PostProcessor.js +631 -0
  32. package/dist/plugin/postprocessor/PostProcessor.js.map +1 -0
  33. package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.d.ts +40 -0
  34. package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.d.ts.map +1 -0
  35. package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.js +244 -0
  36. package/dist/plugin/postprocessor/analysis/FailureAnalysisEngine.js.map +1 -0
  37. package/dist/plugin/postprocessor/autofix/AutoFixEngine.d.ts +50 -0
  38. package/dist/plugin/postprocessor/autofix/AutoFixEngine.d.ts.map +1 -0
  39. package/dist/plugin/postprocessor/autofix/AutoFixEngine.js +246 -0
  40. package/dist/plugin/postprocessor/autofix/AutoFixEngine.js.map +1 -0
  41. package/dist/plugin/postprocessor/autofix/FixValidator.d.ts +27 -0
  42. package/dist/plugin/postprocessor/autofix/FixValidator.d.ts.map +1 -0
  43. package/dist/plugin/postprocessor/autofix/FixValidator.js +158 -0
  44. package/dist/plugin/postprocessor/autofix/FixValidator.js.map +1 -0
  45. package/dist/plugin/postprocessor/config.d.ts +7 -0
  46. package/dist/plugin/postprocessor/config.d.ts.map +1 -0
  47. package/dist/plugin/postprocessor/config.js +66 -0
  48. package/dist/plugin/postprocessor/config.js.map +1 -0
  49. package/dist/plugin/postprocessor/escalation/EscalationEngine.d.ts +73 -0
  50. package/dist/plugin/postprocessor/escalation/EscalationEngine.d.ts.map +1 -0
  51. package/dist/plugin/postprocessor/escalation/EscalationEngine.js +249 -0
  52. package/dist/plugin/postprocessor/escalation/EscalationEngine.js.map +1 -0
  53. package/dist/plugin/postprocessor/monitoring/MonitoringEngine.d.ts +19 -0
  54. package/dist/plugin/postprocessor/monitoring/MonitoringEngine.d.ts.map +1 -0
  55. package/dist/plugin/postprocessor/monitoring/MonitoringEngine.js +120 -0
  56. package/dist/plugin/postprocessor/monitoring/MonitoringEngine.js.map +1 -0
  57. package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.d.ts +92 -0
  58. package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.d.ts.map +1 -0
  59. package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.js +319 -0
  60. package/dist/plugin/postprocessor/redeploy/RedeployCoordinator.js.map +1 -0
  61. package/dist/plugin/postprocessor/success/SuccessHandler.d.ts +61 -0
  62. package/dist/plugin/postprocessor/success/SuccessHandler.d.ts.map +1 -0
  63. package/dist/plugin/postprocessor/success/SuccessHandler.js +148 -0
  64. package/dist/plugin/postprocessor/success/SuccessHandler.js.map +1 -0
  65. package/dist/plugin/postprocessor/triggers/APITrigger.d.ts +13 -0
  66. package/dist/plugin/postprocessor/triggers/APITrigger.d.ts.map +1 -0
  67. package/dist/plugin/postprocessor/triggers/APITrigger.js +20 -0
  68. package/dist/plugin/postprocessor/triggers/APITrigger.js.map +1 -0
  69. package/dist/plugin/postprocessor/triggers/GitHookTrigger.d.ts +17 -0
  70. package/dist/plugin/postprocessor/triggers/GitHookTrigger.d.ts.map +1 -0
  71. package/dist/plugin/postprocessor/triggers/GitHookTrigger.js +285 -0
  72. package/dist/plugin/postprocessor/triggers/GitHookTrigger.js.map +1 -0
  73. package/dist/plugin/postprocessor/triggers/WebhookTrigger.d.ts +13 -0
  74. package/dist/plugin/postprocessor/triggers/WebhookTrigger.d.ts.map +1 -0
  75. package/dist/plugin/postprocessor/triggers/WebhookTrigger.js +21 -0
  76. package/dist/plugin/postprocessor/triggers/WebhookTrigger.js.map +1 -0
  77. package/dist/plugin/postprocessor/types.d.ts +198 -0
  78. package/dist/plugin/postprocessor/types.d.ts.map +1 -0
  79. package/dist/plugin/postprocessor/types.js +5 -0
  80. package/dist/plugin/postprocessor/types.js.map +1 -0
  81. package/dist/plugin/security/security-auditor.d.ts +57 -0
  82. package/dist/plugin/security/security-auditor.d.ts.map +1 -0
  83. package/dist/plugin/security/security-auditor.js +583 -0
  84. package/dist/plugin/security/security-auditor.js.map +1 -0
  85. package/dist/plugin/security/security-hardener.d.ts +63 -0
  86. package/dist/plugin/security/security-hardener.d.ts.map +1 -0
  87. package/dist/plugin/security/security-hardener.js +181 -0
  88. package/dist/plugin/security/security-hardener.js.map +1 -0
  89. package/dist/plugin/security/security-headers.d.ts +52 -0
  90. package/dist/plugin/security/security-headers.d.ts.map +1 -0
  91. package/dist/plugin/security/security-headers.js +118 -0
  92. package/dist/plugin/security/security-headers.js.map +1 -0
  93. package/dist/plugin/session/session-cleanup-manager.d.ts +118 -0
  94. package/dist/plugin/session/session-cleanup-manager.d.ts.map +1 -0
  95. package/dist/plugin/session/session-cleanup-manager.js +324 -0
  96. package/dist/plugin/session/session-cleanup-manager.js.map +1 -0
  97. package/dist/plugin/session/session-monitor.d.ts +99 -0
  98. package/dist/plugin/session/session-monitor.d.ts.map +1 -0
  99. package/dist/plugin/session/session-monitor.js +363 -0
  100. package/dist/plugin/session/session-monitor.js.map +1 -0
  101. package/dist/plugin/session/session-state-manager.d.ts +142 -0
  102. package/dist/plugin/session/session-state-manager.d.ts.map +1 -0
  103. package/dist/plugin/session/session-state-manager.js +504 -0
  104. package/dist/plugin/session/session-state-manager.js.map +1 -0
  105. package/dist/plugin/strray-activation.d.ts +18 -0
  106. package/dist/plugin/strray-activation.d.ts.map +1 -0
  107. package/dist/plugin/strray-activation.js +114 -0
  108. package/dist/plugin/strray-activation.js.map +1 -0
  109. package/dist/plugin/validation/report-content-validator.d.ts +43 -0
  110. package/dist/plugin/validation/report-content-validator.d.ts.map +1 -0
  111. package/dist/plugin/validation/report-content-validator.js +219 -0
  112. package/dist/plugin/validation/report-content-validator.js.map +1 -0
  113. package/package.json +1 -1
  114. package/scripts/test-complex-orchestration.mjs +1 -1
  115. package/scripts/test-simple-prompt.mjs +1 -1
@@ -0,0 +1,72 @@
1
+ /**
2
+ * StringRay Codex Context Injector Hook
3
+ *
4
+ * Injects Universal Development Codex v1.2.20 context into agent operations.
5
+ * Follows production-tested pattern from rules-injector.
6
+ *
7
+ * @version 1.0.0
8
+ * @since 2026-01-06
9
+ */
10
+ /**
11
+ * Create strray-codex-injector hook
12
+ *
13
+ * This hook injects codex context into tool outputs and displays
14
+ * a welcome message on agent startup, following the production-tested
15
+ * pattern from oh-my-opencode's rules-injector.
16
+ */
17
+ export declare function createStringRayCodexInjectorHook(): {
18
+ name: "strray-codex-injector";
19
+ hooks: {
20
+ "agent.start": (sessionId: string) => Promise<void>;
21
+ "tool.execute.before": (input: {
22
+ tool: string;
23
+ args?: Record<string, unknown>;
24
+ }, sessionId: string) => Promise<void>;
25
+ "tool.execute.after": (input: {
26
+ tool: string;
27
+ args?: Record<string, unknown>;
28
+ }, output: {
29
+ output?: string;
30
+ [key: string]: unknown;
31
+ }, sessionId: string) => Promise<{
32
+ [key: string]: unknown;
33
+ output?: string;
34
+ } | {
35
+ output: string;
36
+ }>;
37
+ };
38
+ };
39
+ /**
40
+ * Get codex statistics for debugging
41
+ */
42
+ export declare function getCodexStats(sessionId: string): {
43
+ loaded: boolean;
44
+ fileCount: number;
45
+ totalTerms: number;
46
+ version: string;
47
+ };
48
+ /**
49
+ * Clear codex cache (useful for testing or forced reload)
50
+ */
51
+ export declare function clearCodexCache(sessionId?: string): void;
52
+ /**
53
+ * CodexInjector class for plugin compatibility
54
+ */
55
+ export declare class CodexInjector {
56
+ injectCodexRules(context: any, options: any): any;
57
+ getCodexStats(): {
58
+ loaded: boolean;
59
+ fileCount: number;
60
+ totalTerms: number;
61
+ version: string;
62
+ };
63
+ /**
64
+ * Permissive comment validation - recognizes that comments are beneficial
65
+ * Only flags truly problematic patterns, provides guidance not requirements
66
+ */
67
+ validateCommentsPermissively(content: string): {
68
+ guidance: string[];
69
+ concerns: string[];
70
+ };
71
+ }
72
+ //# sourceMappingURL=codex-injector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-injector.d.ts","sourceRoot":"","sources":["../../src/codex-injector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0JH;;;;;;GAMG;AACH,wBAAgB,gCAAgC;;;mCAIT,MAAM;uCA4C9B;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAAE,aAC5C,MAAM;sCAuKV;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAAE,UAC/C;YAAE,MAAM,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;SAAE,aACxC,MAAM;;qBADE,MAAM;;;;;EA8FhC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG;IAChD,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAuBA;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAMxD;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG;IAK3C,aAAa;;;;;;IAqBb;;;OAGG;IACH,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG;QAC7C,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB;CAiEF"}
@@ -0,0 +1,387 @@
1
+ /**
2
+ * StringRay Codex Context Injector Hook
3
+ *
4
+ * Injects Universal Development Codex v1.2.20 context into agent operations.
5
+ * Follows production-tested pattern from rules-injector.
6
+ *
7
+ * @version 1.0.0
8
+ * @since 2026-01-06
9
+ */
10
+ import * as fs from "fs";
11
+ import * as path from "path";
12
+ import { frameworkLogger } from "./framework-logger.js";
13
+ // Dynamic imports for cross-environment compatibility
14
+ let extractCodexMetadata;
15
+ let StringRayContextLoader;
16
+ let importsInitialized = false;
17
+ async function initializeImports() {
18
+ if (importsInitialized)
19
+ return;
20
+ try {
21
+ // Try import with .js extension first (for Node.js/test environment)
22
+ ({ extractCodexMetadata } = await import("./utils/codex-parser.js"));
23
+ ({ StringRayContextLoader } = await import("./context-loader.js"));
24
+ }
25
+ catch (error) {
26
+ // Fallback to import without .js extension (for oh-my-opencode plugin environment)
27
+ ({ extractCodexMetadata } = await import("./utils/codex-parser"));
28
+ ({ StringRayContextLoader } = await import("./context-loader"));
29
+ }
30
+ importsInitialized = true;
31
+ }
32
+ /**
33
+ * Session cache for codex context
34
+ */
35
+ const codexCache = new Map();
36
+ /**
37
+ * Codex file locations to search
38
+ */
39
+ const CODEX_FILE_LOCATIONS = [
40
+ ".strray/codex.json",
41
+ "codex.json",
42
+ "src/codex.json",
43
+ "docs/agents/codex.json",
44
+ ];
45
+ /**
46
+ * Read file content safely
47
+ */
48
+ function readFileContent(filePath) {
49
+ try {
50
+ if (fs.existsSync(filePath)) {
51
+ return fs.readFileSync(filePath, "utf-8");
52
+ }
53
+ }
54
+ catch (error) {
55
+ console.error(`StringRay Codex Hook Error:`, error);
56
+ }
57
+ return null;
58
+ }
59
+ /**
60
+ * Create codex context entry
61
+ */
62
+ async function createCodexContextEntry(filePath, content) {
63
+ await initializeImports();
64
+ const metadata = extractCodexMetadata(content);
65
+ return {
66
+ id: `strray-codex-${path.basename(filePath)}`,
67
+ source: filePath,
68
+ content,
69
+ priority: "critical",
70
+ metadata: {
71
+ version: metadata.version,
72
+ termCount: metadata.termCount,
73
+ loadedAt: new Date().toISOString(),
74
+ },
75
+ };
76
+ }
77
+ /**
78
+ * Load codex context for current session
79
+ */
80
+ async function loadCodexContext(sessionId) {
81
+ if (codexCache.has(sessionId)) {
82
+ return codexCache.get(sessionId);
83
+ }
84
+ const codexContexts = [];
85
+ for (const relativePath of CODEX_FILE_LOCATIONS) {
86
+ try {
87
+ const fullPath = path.join(process.cwd(), relativePath);
88
+ const content = readFileContent(fullPath);
89
+ if (content) {
90
+ const entry = await createCodexContextEntry(fullPath, content);
91
+ codexContexts.push(entry);
92
+ }
93
+ }
94
+ catch (error) {
95
+ console.error(`StringRay Codex Hook Error:`, error);
96
+ }
97
+ }
98
+ codexCache.set(sessionId, codexContexts);
99
+ return codexContexts;
100
+ }
101
+ /**
102
+ * Format codex context for display
103
+ */
104
+ function formatCodexContext(contexts, sessionId) {
105
+ const parts = [
106
+ "═════════════════════════════════════════════════════════════",
107
+ "✨ StringRay Codex Context Loaded Successfully",
108
+ "═════════════════════════════════════════════════════════════",
109
+ "",
110
+ ];
111
+ for (const context of contexts) {
112
+ parts.push(`✅ StringRay Codex loaded: ${context.source} (${context.metadata.termCount} terms)`);
113
+ }
114
+ const stats = getCodexStats(sessionId);
115
+ parts.push(`📁 Sources: ${stats.fileCount} file(s)`, `🎯 Error Prevention Target: 90% runtime error prevention`, "═════════════════════════════════════════════════════════════", "");
116
+ return parts.join("\n");
117
+ }
118
+ /**
119
+ * Create strray-codex-injector hook
120
+ *
121
+ * This hook injects codex context into tool outputs and displays
122
+ * a welcome message on agent startup, following the production-tested
123
+ * pattern from oh-my-opencode's rules-injector.
124
+ */
125
+ export function createStringRayCodexInjectorHook() {
126
+ return {
127
+ name: "strray-codex-injector",
128
+ hooks: {
129
+ "agent.start": async (sessionId) => {
130
+ try {
131
+ await frameworkLogger.log("codex-injector", "agent.start hook triggered", "info", { sessionId });
132
+ // Load codex context to ensure it's available for the session
133
+ await loadCodexContext(sessionId);
134
+ const stats = getCodexStats(sessionId);
135
+ if (stats.loaded) {
136
+ console.log(`✅ StringRay Codex loaded: ${stats.totalTerms} terms, ${stats.fileCount} sources`);
137
+ await frameworkLogger.log("codex-injector", "codex context loaded successfully", "success", stats);
138
+ }
139
+ else {
140
+ console.log("⚠️ No codex files found. Checked: .strray/codex.json, codex.json, src/codex.json, docs/agents/codex.json");
141
+ await frameworkLogger.log("codex-injector", "no codex files found", "error");
142
+ }
143
+ }
144
+ catch (error) {
145
+ await frameworkLogger.log("codex-injector", "agent.start hook failed", "error", error);
146
+ console.error(`❌ StringRay: Error in agent.start hook:`, error);
147
+ throw error;
148
+ }
149
+ },
150
+ "tool.execute.before": async (input, sessionId) => {
151
+ try {
152
+ await frameworkLogger.log("codex-injector", "tool.execute.before hook triggered", "info", { tool: input.tool, sessionId });
153
+ // Log ALL tool usage for framework transparency
154
+ await frameworkLogger.log("framework-activity", `tool called: ${input.tool}`, "info", {
155
+ tool: input.tool,
156
+ args: input.args,
157
+ sessionId,
158
+ });
159
+ // Skip codex enforcement during testing
160
+ if (process.env.NODE_ENV === "test" ||
161
+ process.env.STRRAY_TEST_MODE === "true") {
162
+ await frameworkLogger.log("codex-injector", "skipping enforcement in test mode", "info");
163
+ return;
164
+ }
165
+ // Only enforce on critical tools that could violate codex terms
166
+ const criticalTools = ["write", "edit", "multiedit", "batch"];
167
+ if (!criticalTools.includes(input.tool)) {
168
+ await frameworkLogger.log("codex-injector", "non-critical tool allowed", "info", { tool: input.tool });
169
+ return; // Allow non-critical tools
170
+ }
171
+ await frameworkLogger.log("codex-injector", "enforcing codex on critical tool", "info", { tool: input.tool });
172
+ // Load codex context for validation
173
+ const codexContexts = await loadCodexContext(sessionId);
174
+ if (codexContexts.length === 0) {
175
+ console.log("⚠️ No codex loaded - allowing action but enforcement disabled");
176
+ await frameworkLogger.log("codex-injector", "no codex context available", "error", { sessionId });
177
+ return;
178
+ }
179
+ await frameworkLogger.log("codex-injector", "codex context loaded for validation", "success", { contextCount: codexContexts.length });
180
+ // Use the initialized context loader
181
+ await initializeImports();
182
+ const contextLoader = new StringRayContextLoader();
183
+ const loadResult = await contextLoader.loadCodexContext(sessionId);
184
+ if (!loadResult.success || !loadResult.context) {
185
+ console.log("⚠️ No codex context available - allowing action");
186
+ return;
187
+ }
188
+ // Validate action against codex
189
+ const actionDescription = `${input.tool} ${JSON.stringify(input.args || {})}`;
190
+ const validation = contextLoader.validateAgainstCodex(loadResult.context, actionDescription, {
191
+ strictMode: true,
192
+ blockOnViolations: true,
193
+ });
194
+ if (!validation.compliant) {
195
+ // Check for blocking violations
196
+ const blockingViolations = validation.violations.filter((v) => v.severity === "blocking");
197
+ if (blockingViolations.length > 0) {
198
+ const errorMsg = `🚫 BLOCKED: Codex violation detected\n${blockingViolations.map((v) => `• ${v.reason}`).join("\n")}`;
199
+ console.error(errorMsg);
200
+ frameworkLogger.log("codex-injector", "blocking codex violation detected", "error", {
201
+ violationCount: blockingViolations.length,
202
+ tool: input.tool,
203
+ });
204
+ throw new Error(`Codex enforcement blocked action: ${blockingViolations[0]?.reason || "Unknown violation"}`);
205
+ }
206
+ // Log non-blocking violations but allow action
207
+ console.log(`⚠️ Codex warnings detected:`);
208
+ validation.violations.forEach((v) => {
209
+ console.log(` • ${v.reason}`);
210
+ });
211
+ console.log(`💡 Recommendations: ${validation.recommendations.join(", ")}`);
212
+ frameworkLogger.log("codex-injector", "non-blocking codex warnings", "info", {
213
+ warningCount: validation.violations.length,
214
+ tool: input.tool,
215
+ });
216
+ }
217
+ else {
218
+ frameworkLogger.log("codex-injector", "codex validation passed", "success", { tool: input.tool });
219
+ }
220
+ }
221
+ catch (error) {
222
+ frameworkLogger.log("codex-injector", "tool.execute.before hook error", "error", {
223
+ error: error instanceof Error ? error.message : String(error),
224
+ tool: input.tool,
225
+ });
226
+ console.error(`❌ StringRay: Error in tool.execute.before hook:`, error);
227
+ // For blocking violations, re-throw to prevent action
228
+ if (error instanceof Error &&
229
+ error.message.includes("Codex enforcement blocked action")) {
230
+ throw error;
231
+ }
232
+ // For other errors, log but allow action to prevent breaking workflow
233
+ }
234
+ },
235
+ "tool.execute.after": async (input, output, sessionId) => {
236
+ try {
237
+ frameworkLogger.log("codex-injector", "tool.execute.after hook triggered", "info", { tool: input.tool, sessionId });
238
+ // Skip codex enforcement during testing
239
+ if (process.env.NODE_ENV === "test" ||
240
+ process.env.STRRAY_TEST_MODE === "true") {
241
+ frameworkLogger.log("codex-injector", "skipping injection in test mode", "info");
242
+ return output;
243
+ }
244
+ if (!["read", "write", "edit", "multiedit", "batch"].includes(input.tool)) {
245
+ frameworkLogger.log("codex-injector", "non-critical tool - no injection", "info", { tool: input.tool });
246
+ return output;
247
+ }
248
+ console.log(`🔧 StringRay: Tool execution hook triggered for ${input.tool}`);
249
+ const codexContexts = await loadCodexContext(sessionId);
250
+ console.log(`📚 StringRay: Loaded ${codexContexts.length} codex contexts`);
251
+ frameworkLogger.log("codex-injector", "codex contexts loaded for injection", "success", {
252
+ contextCount: codexContexts.length,
253
+ tool: input.tool,
254
+ });
255
+ if (codexContexts.length === 0) {
256
+ return output;
257
+ }
258
+ const formattedCodex = formatCodexContext(codexContexts, sessionId);
259
+ const injectedOutput = {
260
+ ...output,
261
+ output: `${formattedCodex}\n${output.output || ""}`,
262
+ };
263
+ frameworkLogger.log("codex-injector", "codex context injected into output", "success", {
264
+ tool: input.tool,
265
+ outputLength: injectedOutput.output?.length,
266
+ });
267
+ return injectedOutput;
268
+ }
269
+ catch (error) {
270
+ frameworkLogger.log("codex-injector", "tool.execute.after hook error", "error", {
271
+ error: error instanceof Error ? error.message : String(error),
272
+ tool: input.tool,
273
+ });
274
+ console.error(`❌ StringRay: Error in tool.execute.after hook:`, error);
275
+ // Return original output on error to not break the session
276
+ return output;
277
+ }
278
+ },
279
+ },
280
+ };
281
+ }
282
+ /**
283
+ * Get codex statistics for debugging
284
+ */
285
+ export function getCodexStats(sessionId) {
286
+ const contexts = codexCache.get(sessionId);
287
+ if (!contexts || contexts.length === 0) {
288
+ return {
289
+ loaded: false,
290
+ fileCount: 0,
291
+ totalTerms: 0,
292
+ version: "unknown",
293
+ };
294
+ }
295
+ const totalTerms = contexts.reduce((sum, ctx) => sum + ctx.metadata.termCount, 0);
296
+ return {
297
+ loaded: true,
298
+ fileCount: contexts.length,
299
+ totalTerms,
300
+ version: contexts[0].metadata.version,
301
+ };
302
+ }
303
+ /**
304
+ * Clear codex cache (useful for testing or forced reload)
305
+ */
306
+ export function clearCodexCache(sessionId) {
307
+ if (sessionId) {
308
+ codexCache.delete(sessionId);
309
+ }
310
+ else {
311
+ codexCache.clear();
312
+ }
313
+ }
314
+ /**
315
+ * CodexInjector class for plugin compatibility
316
+ */
317
+ export class CodexInjector {
318
+ injectCodexRules(context, options) {
319
+ // Implementation for plugin compatibility
320
+ return context;
321
+ }
322
+ getCodexStats() {
323
+ // Return aggregated stats for plugin
324
+ const allContexts = [];
325
+ for (const contexts of Array.from(codexCache.values())) {
326
+ allContexts.push(...contexts);
327
+ }
328
+ const totalTerms = allContexts.reduce((sum, ctx) => sum + ctx.metadata.termCount, 0);
329
+ return {
330
+ loaded: allContexts.length > 0,
331
+ fileCount: allContexts.length,
332
+ totalTerms,
333
+ version: allContexts.length > 0 ? allContexts[0].metadata.version : "unknown",
334
+ };
335
+ }
336
+ /**
337
+ * Permissive comment validation - recognizes that comments are beneficial
338
+ * Only flags truly problematic patterns, provides guidance not requirements
339
+ */
340
+ validateCommentsPermissively(content) {
341
+ const guidance = [];
342
+ const concerns = [];
343
+ const lines = content.split("\n");
344
+ let commentLines = 0;
345
+ let codeLines = 0;
346
+ let todoCount = 0;
347
+ for (const line of lines) {
348
+ const trimmed = line.trim();
349
+ // Skip empty lines
350
+ if (!trimmed)
351
+ continue;
352
+ // Count code vs comments
353
+ if (trimmed.startsWith("//") ||
354
+ trimmed.startsWith("/*") ||
355
+ trimmed.startsWith("*") ||
356
+ trimmed.startsWith("*/")) {
357
+ commentLines++;
358
+ }
359
+ else {
360
+ codeLines++;
361
+ }
362
+ // Check for problematic patterns
363
+ if (trimmed.includes("TODO") ||
364
+ trimmed.includes("FIXME") ||
365
+ trimmed.includes("XXX")) {
366
+ todoCount++;
367
+ }
368
+ }
369
+ // Provide helpful guidance (not requirements)
370
+ const commentRatio = commentLines / (commentLines + codeLines);
371
+ if (commentLines === 0 && codeLines > 30) {
372
+ guidance.push("💡 Consider adding comments for complex logic - they improve maintainability");
373
+ }
374
+ if (commentRatio > 0.4) {
375
+ guidance.push("💡 High comment ratio detected - consider if code can be made more self-explanatory");
376
+ }
377
+ if (todoCount > 3) {
378
+ concerns.push("⚠️ Multiple unresolved tasks detected - consider addressing or documenting timelines");
379
+ }
380
+ // Recognize good commenting practices
381
+ if (commentRatio > 0.1 && commentRatio < 0.3) {
382
+ guidance.push("✅ Good balance of code and comments detected");
383
+ }
384
+ return { guidance, concerns };
385
+ }
386
+ }
387
+ //# sourceMappingURL=codex-injector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codex-injector.js","sourceRoot":"","sources":["../../src/codex-injector.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,sDAAsD;AACtD,IAAI,oBAAyB,CAAC;AAC9B,IAAI,sBAA2B,CAAC;AAChC,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAE/B,KAAK,UAAU,iBAAiB;IAC9B,IAAI,kBAAkB;QAAE,OAAO;IAE/B,IAAI,CAAC;QACH,qEAAqE;QACrE,CAAC,EAAE,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC,CAAC;QACrE,CAAC,EAAE,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC;IACrE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,mFAAmF;QACnF,CAAC,EAAE,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC;QAClE,CAAC,EAAE,sBAAsB,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,kBAAkB,GAAG,IAAI,CAAC;AAC5B,CAAC;AAiBD;;GAEG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,EAA+B,CAAC;AAE1D;;GAEG;AACH,MAAM,oBAAoB,GAAG;IAC3B,oBAA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S,CAAC,CAAC;QAE/D,IAAI,YAAY,KAAK,CAAC,IAAI,SAAS,GAAG,EAAE,EAAE,CAAC;YACzC,QAAQ,CAAC,IAAI,CACX,8EAA8E,CAC/E,CAAC;QACJ,CAAC;QAED,IAAI,YAAY,GAAG,GAAG,EAAE,CAAC;YACvB,QAAQ,CAAC,IAAI,CACX,qFAAqF,CACtF,CAAC;QACJ,CAAC;QAED,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;YAClB,QAAQ,CAAC,IAAI,CACX,sFAAsF,CACvF,CAAC;QACJ,CAAC;QAED,sCAAsC;QACtC,IAAI,YAAY,GAAG,GAAG,IAAI,YAAY,GAAG,GAAG,EAAE,CAAC;YAC7C,QAAQ,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;QAChE,CAAC;QAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * StringRay Framework v1.0.0 - Delegation System
3
+ *
4
+ * Complete automatic multi-agent delegation system with complexity assessment
5
+ * and session-based coordination.
6
+ *
7
+ * @version 1.0.0
8
+ * @since 2026-01-07
9
+ */
10
+ export { ComplexityAnalyzer, complexityAnalyzer, } from "./complexity-analyzer.js";
11
+ export { AgentDelegator, createAgentDelegator } from "./agent-delegator.js";
12
+ export { SessionCoordinator, createSessionCoordinator, } from "./session-coordinator.js";
13
+ export type { ComplexityMetrics, ComplexityScore, ComplexityThresholds, } from "./complexity-analyzer.js";
14
+ export type { DelegationRequest, DelegationResult, AgentCapability, DelegationMetrics, } from "./agent-delegator.js";
15
+ export type { SessionContext, AgentInteraction, ConflictRecord, CoordinationState, Communication, SessionMetrics, } from "./session-coordinator.js";
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/delegation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * StringRay Framework v1.0.0 - Delegation System
3
+ *
4
+ * Complete automatic multi-agent delegation system with complexity assessment
5
+ * and session-based coordination.
6
+ *
7
+ * @version 1.0.0
8
+ * @since 2026-01-07
9
+ */
10
+ export { ComplexityAnalyzer, complexityAnalyzer, } from "./complexity-analyzer.js";
11
+ export { AgentDelegator, createAgentDelegator } from "./agent-delegator.js";
12
+ export { SessionCoordinator, createSessionCoordinator, } from "./session-coordinator.js";
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/delegation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,121 @@
1
+ /**
2
+ * StringRay Framework v1.0.0 - Session Coordinator
3
+ *
4
+ * Manages cross-agent communication and coordination within sessions.
5
+ * Tracks delegation state, agent interactions, and conflict resolution.
6
+ *
7
+ * @version 1.0.0
8
+ * @since 2026-01-07
9
+ */
10
+ import { StringRayStateManager } from "../state/state-manager";
11
+ import { DelegationResult } from "./agent-delegator.js";
12
+ export interface SessionContext {
13
+ sessionId: string;
14
+ startTime: number;
15
+ activeDelegations: Map<string, DelegationResult>;
16
+ agentInteractions: Map<string, AgentInteraction[]>;
17
+ conflictHistory: ConflictRecord[];
18
+ coordinationState: CoordinationState;
19
+ isActive: boolean;
20
+ }
21
+ export interface AgentInteraction {
22
+ agentName: string;
23
+ timestamp: number;
24
+ action: string;
25
+ result: any;
26
+ duration: number;
27
+ success: boolean;
28
+ }
29
+ export interface ConflictRecord {
30
+ conflictId: string;
31
+ timestamp: number;
32
+ agents: string[];
33
+ resolution: "consensus" | "majority_vote" | "expert_priority" | "manual";
34
+ outcome: any;
35
+ }
36
+ export interface CoordinationState {
37
+ activeAgents: Set<string>;
38
+ pendingCommunications: Communication[];
39
+ sharedContext: Map<string, any>;
40
+ sessionMetrics: SessionMetrics;
41
+ }
42
+ export interface Communication {
43
+ id: string;
44
+ fromAgent: string;
45
+ toAgent: string;
46
+ message: any;
47
+ timestamp: number;
48
+ priority: "low" | "medium" | "high";
49
+ }
50
+ export interface SessionMetrics {
51
+ totalInteractions: number;
52
+ successfulInteractions: number;
53
+ failedInteractions: number;
54
+ averageResponseTime: number;
55
+ conflictResolutionRate: number;
56
+ coordinationEfficiency: number;
57
+ }
58
+ export declare class SessionCoordinator {
59
+ private stateManager;
60
+ private sessions;
61
+ constructor(stateManager: StringRayStateManager);
62
+ /**
63
+ * Initialize session coordination for a new session
64
+ */
65
+ initializeSession(sessionId: string): {
66
+ sessionId: string;
67
+ createdAt: Date;
68
+ active: boolean;
69
+ agentCount: number;
70
+ };
71
+ /**
72
+ * Register delegation execution in session
73
+ */
74
+ registerDelegation(sessionId: string, delegationId: string, delegation: DelegationResult): void;
75
+ /**
76
+ * Record agent interaction within session
77
+ */
78
+ recordInteraction(sessionId: string, agentName: string, interaction: Omit<AgentInteraction, "timestamp">): void;
79
+ /**
80
+ * Send message between agents within session
81
+ */
82
+ sendMessage(sessionId: string, fromAgent: string, toAgent: string, message: any, priority?: "low" | "medium" | "high"): Promise<void>;
83
+ /**
84
+ * Receive pending messages for an agent
85
+ */
86
+ receiveMessages(sessionId: string, agentName: string): Communication[];
87
+ /**
88
+ * Share context data between agents
89
+ */
90
+ shareContext(sessionId: string, key: string, value: any, fromAgent: string): void;
91
+ /**
92
+ * Get shared context data
93
+ */
94
+ getSharedContext(sessionId: string, key: string): any;
95
+ /**
96
+ * Record conflict and resolution
97
+ */
98
+ recordConflict(sessionId: string, agents: string[], resolution: ConflictRecord["resolution"], outcome: any): void;
99
+ /**
100
+ * Complete delegation and cleanup
101
+ */
102
+ completeDelegation(sessionId: string, delegationId: string, result: any): void;
103
+ /**
104
+ * Get session coordination status
105
+ */
106
+ getSessionStatus(sessionId: string): {
107
+ active: boolean;
108
+ agentCount: number;
109
+ } | null;
110
+ /**
111
+ * Resolve conflicts using specified strategy
112
+ */
113
+ resolveConflict(sessionId: string, conflictKey: string, strategy: "majority_vote" | "expert_priority" | "consensus"): any;
114
+ /**
115
+ * Cleanup session coordination data
116
+ */
117
+ cleanupSession(sessionId: string): void;
118
+ private updateSessionMetrics;
119
+ }
120
+ export declare const createSessionCoordinator: (stateManager: StringRayStateManager) => SessionCoordinator;
121
+ //# sourceMappingURL=session-coordinator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-coordinator.d.ts","sourceRoot":"","sources":["../../../src/delegation/session-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,GAAG,CAAC,MAAM,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