@renseiai/agentfactory-server 0.8.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/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/src/a2a-server.d.ts +88 -0
- package/dist/src/a2a-server.d.ts.map +1 -0
- package/dist/src/a2a-server.integration.test.d.ts +9 -0
- package/dist/src/a2a-server.integration.test.d.ts.map +1 -0
- package/dist/src/a2a-server.integration.test.js +397 -0
- package/dist/src/a2a-server.js +235 -0
- package/dist/src/a2a-server.test.d.ts +2 -0
- package/dist/src/a2a-server.test.d.ts.map +1 -0
- package/dist/src/a2a-server.test.js +311 -0
- package/dist/src/a2a-types.d.ts +125 -0
- package/dist/src/a2a-types.d.ts.map +1 -0
- package/dist/src/a2a-types.js +8 -0
- package/dist/src/agent-tracking.d.ts +201 -0
- package/dist/src/agent-tracking.d.ts.map +1 -0
- package/dist/src/agent-tracking.js +349 -0
- package/dist/src/env-validation.d.ts +65 -0
- package/dist/src/env-validation.d.ts.map +1 -0
- package/dist/src/env-validation.js +134 -0
- package/dist/src/governor-dedup.d.ts +15 -0
- package/dist/src/governor-dedup.d.ts.map +1 -0
- package/dist/src/governor-dedup.js +31 -0
- package/dist/src/governor-event-bus.d.ts +54 -0
- package/dist/src/governor-event-bus.d.ts.map +1 -0
- package/dist/src/governor-event-bus.js +152 -0
- package/dist/src/governor-storage.d.ts +28 -0
- package/dist/src/governor-storage.d.ts.map +1 -0
- package/dist/src/governor-storage.js +52 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +50 -0
- package/dist/src/issue-lock.d.ts +129 -0
- package/dist/src/issue-lock.d.ts.map +1 -0
- package/dist/src/issue-lock.js +508 -0
- package/dist/src/logger.d.ts +76 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +218 -0
- package/dist/src/orphan-cleanup.d.ts +64 -0
- package/dist/src/orphan-cleanup.d.ts.map +1 -0
- package/dist/src/orphan-cleanup.js +369 -0
- package/dist/src/pending-prompts.d.ts +67 -0
- package/dist/src/pending-prompts.d.ts.map +1 -0
- package/dist/src/pending-prompts.js +176 -0
- package/dist/src/processing-state-storage.d.ts +38 -0
- package/dist/src/processing-state-storage.d.ts.map +1 -0
- package/dist/src/processing-state-storage.js +61 -0
- package/dist/src/quota-tracker.d.ts +62 -0
- package/dist/src/quota-tracker.d.ts.map +1 -0
- package/dist/src/quota-tracker.js +155 -0
- package/dist/src/rate-limit.d.ts +111 -0
- package/dist/src/rate-limit.d.ts.map +1 -0
- package/dist/src/rate-limit.js +171 -0
- package/dist/src/redis-circuit-breaker.d.ts +67 -0
- package/dist/src/redis-circuit-breaker.d.ts.map +1 -0
- package/dist/src/redis-circuit-breaker.js +290 -0
- package/dist/src/redis-rate-limiter.d.ts +51 -0
- package/dist/src/redis-rate-limiter.d.ts.map +1 -0
- package/dist/src/redis-rate-limiter.js +168 -0
- package/dist/src/redis.d.ts +146 -0
- package/dist/src/redis.d.ts.map +1 -0
- package/dist/src/redis.js +343 -0
- package/dist/src/session-hash.d.ts +48 -0
- package/dist/src/session-hash.d.ts.map +1 -0
- package/dist/src/session-hash.js +80 -0
- package/dist/src/session-storage.d.ts +166 -0
- package/dist/src/session-storage.d.ts.map +1 -0
- package/dist/src/session-storage.js +397 -0
- package/dist/src/token-storage.d.ts +118 -0
- package/dist/src/token-storage.d.ts.map +1 -0
- package/dist/src/token-storage.js +263 -0
- package/dist/src/types.d.ts +11 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +7 -0
- package/dist/src/webhook-idempotency.d.ts +44 -0
- package/dist/src/webhook-idempotency.d.ts.map +1 -0
- package/dist/src/webhook-idempotency.js +148 -0
- package/dist/src/work-queue.d.ts +120 -0
- package/dist/src/work-queue.d.ts.map +1 -0
- package/dist/src/work-queue.js +384 -0
- package/dist/src/worker-auth.d.ts +29 -0
- package/dist/src/worker-auth.d.ts.map +1 -0
- package/dist/src/worker-auth.js +49 -0
- package/dist/src/worker-storage.d.ts +108 -0
- package/dist/src/worker-storage.d.ts.map +1 -0
- package/dist/src/worker-storage.js +295 -0
- package/dist/src/workflow-state-integration.test.d.ts +2 -0
- package/dist/src/workflow-state-integration.test.d.ts.map +1 -0
- package/dist/src/workflow-state-integration.test.js +342 -0
- package/dist/src/workflow-state.test.d.ts +2 -0
- package/dist/src/workflow-state.test.d.ts.map +1 -0
- package/dist/src/workflow-state.test.js +113 -0
- package/package.json +72 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { computeStrategy, extractFailureReason } from './agent-tracking.js';
|
|
3
|
+
describe('computeStrategy', () => {
|
|
4
|
+
it('returns normal for cycle 0', () => {
|
|
5
|
+
expect(computeStrategy(0)).toBe('normal');
|
|
6
|
+
});
|
|
7
|
+
it('returns normal for cycle 1', () => {
|
|
8
|
+
expect(computeStrategy(1)).toBe('normal');
|
|
9
|
+
});
|
|
10
|
+
it('returns context-enriched for cycle 2', () => {
|
|
11
|
+
expect(computeStrategy(2)).toBe('context-enriched');
|
|
12
|
+
});
|
|
13
|
+
it('returns decompose for cycle 3', () => {
|
|
14
|
+
expect(computeStrategy(3)).toBe('decompose');
|
|
15
|
+
});
|
|
16
|
+
it('returns escalate-human for cycle 4', () => {
|
|
17
|
+
expect(computeStrategy(4)).toBe('escalate-human');
|
|
18
|
+
});
|
|
19
|
+
it('returns escalate-human for cycle 5+', () => {
|
|
20
|
+
expect(computeStrategy(5)).toBe('escalate-human');
|
|
21
|
+
expect(computeStrategy(10)).toBe('escalate-human');
|
|
22
|
+
expect(computeStrategy(100)).toBe('escalate-human');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('extractFailureReason', () => {
|
|
26
|
+
it('returns default message for undefined input', () => {
|
|
27
|
+
expect(extractFailureReason(undefined)).toBe('No result message provided');
|
|
28
|
+
});
|
|
29
|
+
it('extracts from ## QA Failed section', () => {
|
|
30
|
+
const msg = `## QA Failed
|
|
31
|
+
|
|
32
|
+
The build is broken because the new function does not handle null inputs correctly.
|
|
33
|
+
Tests in packages/core are failing with TypeError.
|
|
34
|
+
|
|
35
|
+
<!-- WORK_RESULT:failed -->`;
|
|
36
|
+
const result = extractFailureReason(msg);
|
|
37
|
+
expect(result).toContain('build is broken');
|
|
38
|
+
expect(result).toContain('null inputs');
|
|
39
|
+
});
|
|
40
|
+
it('extracts from Failure Reason: pattern', () => {
|
|
41
|
+
const msg = `QA Status: Failed
|
|
42
|
+
|
|
43
|
+
Failure Reason: The API endpoint returns 500 when called with an empty payload. The validation middleware is not catching the missing required field.`;
|
|
44
|
+
const result = extractFailureReason(msg);
|
|
45
|
+
expect(result).toContain('API endpoint returns 500');
|
|
46
|
+
});
|
|
47
|
+
it('extracts from Issues Found pattern', () => {
|
|
48
|
+
const msg = `## QA Report
|
|
49
|
+
|
|
50
|
+
Issues Found:
|
|
51
|
+
1. Missing error handling in the login flow
|
|
52
|
+
2. CSS layout broken on mobile viewport
|
|
53
|
+
3. Unit test for UserService is failing`;
|
|
54
|
+
const result = extractFailureReason(msg);
|
|
55
|
+
expect(result).toContain('Missing error handling');
|
|
56
|
+
});
|
|
57
|
+
it('falls back to last paragraph for unstructured messages', () => {
|
|
58
|
+
const msg = `I looked at the code and ran the tests.
|
|
59
|
+
|
|
60
|
+
Some things worked but others did not.
|
|
61
|
+
|
|
62
|
+
The main issue is that the database migration was not applied correctly and the new column is missing from the users table, causing all queries to fail with a column not found error.`;
|
|
63
|
+
const result = extractFailureReason(msg);
|
|
64
|
+
expect(result).toContain('database migration');
|
|
65
|
+
});
|
|
66
|
+
it('truncates very long failure reasons', () => {
|
|
67
|
+
const longReason = 'x'.repeat(3000);
|
|
68
|
+
const msg = `## QA Failed\n${longReason}`;
|
|
69
|
+
const result = extractFailureReason(msg);
|
|
70
|
+
expect(result.length).toBeLessThanOrEqual(2003); // 2000 + '...'
|
|
71
|
+
expect(result.endsWith('...')).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
it('handles short result messages gracefully', () => {
|
|
74
|
+
const msg = 'Failed';
|
|
75
|
+
const result = extractFailureReason(msg);
|
|
76
|
+
expect(result).toBe('Failed');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
describe('escalation ladder progression', () => {
|
|
80
|
+
it('follows the correct strategy progression through 5 cycles', () => {
|
|
81
|
+
const expected = [
|
|
82
|
+
'normal', // cycle 0 (first attempt)
|
|
83
|
+
'normal', // cycle 1
|
|
84
|
+
'context-enriched', // cycle 2
|
|
85
|
+
'decompose', // cycle 3
|
|
86
|
+
'escalate-human', // cycle 4
|
|
87
|
+
];
|
|
88
|
+
for (let cycle = 0; cycle < expected.length; cycle++) {
|
|
89
|
+
expect(computeStrategy(cycle)).toBe(expected[cycle]);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
it('never returns a strategy weaker than escalate-human once reached', () => {
|
|
93
|
+
// Once at escalate-human, it stays there
|
|
94
|
+
for (let cycle = 4; cycle <= 20; cycle++) {
|
|
95
|
+
expect(computeStrategy(cycle)).toBe('escalate-human');
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
it('strategy always increases or stays at ceiling', () => {
|
|
99
|
+
const strategyOrder = {
|
|
100
|
+
'normal': 0,
|
|
101
|
+
'context-enriched': 1,
|
|
102
|
+
'decompose': 2,
|
|
103
|
+
'escalate-human': 3,
|
|
104
|
+
};
|
|
105
|
+
let previousLevel = -1;
|
|
106
|
+
for (let cycle = 0; cycle <= 10; cycle++) {
|
|
107
|
+
const strategy = computeStrategy(cycle);
|
|
108
|
+
const level = strategyOrder[strategy];
|
|
109
|
+
expect(level).toBeGreaterThanOrEqual(previousLevel);
|
|
110
|
+
previousLevel = level;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@renseiai/agentfactory-server",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Webhook server and distributed worker pool for AgentFactory — Redis queues, issue locks, session management",
|
|
6
|
+
"author": "Rensei AI (https://rensei.ai)",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.0.0"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/renseiai/agentfactory",
|
|
14
|
+
"directory": "packages/server"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/renseiai/agentfactory/tree/main/packages/server",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/renseiai/agentfactory/issues"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/src/index.d.ts",
|
|
25
|
+
"import": "./dist/src/index.js",
|
|
26
|
+
"default": "./dist/src/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"main": "./dist/src/index.js",
|
|
30
|
+
"types": "./dist/src/index.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"webhook",
|
|
34
|
+
"worker-pool",
|
|
35
|
+
"redis",
|
|
36
|
+
"agent-server",
|
|
37
|
+
"distributed"
|
|
38
|
+
],
|
|
39
|
+
"main": "./dist/src/index.js",
|
|
40
|
+
"module": "./dist/src/index.js",
|
|
41
|
+
"types": "./dist/src/index.d.ts",
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./src/index.ts",
|
|
45
|
+
"import": "./dist/src/index.js",
|
|
46
|
+
"default": "./dist/src/index.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"README.md",
|
|
52
|
+
"LICENSE"
|
|
53
|
+
],
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@renseiai/agentfactory": "workspace:*",
|
|
56
|
+
"@renseiai/agentfactory-linear": "workspace:*",
|
|
57
|
+
"ioredis": "^5.4.2"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@types/node": "^22.5.4",
|
|
61
|
+
"typescript": "^5.7.3",
|
|
62
|
+
"vitest": "^3.2.3"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsc",
|
|
66
|
+
"typecheck": "tsc --noEmit",
|
|
67
|
+
"test": "vitest run --passWithNoTests",
|
|
68
|
+
"test:watch": "vitest",
|
|
69
|
+
"clean": "rm -rf dist",
|
|
70
|
+
"prepublishOnly": "pnpm clean && pnpm build"
|
|
71
|
+
}
|
|
72
|
+
}
|