@supaku/agentfactory-nextjs 0.6.1 → 0.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/handlers/sessions/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/handlers/sessions/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAmBvD,UAAU,WAAW;IACnB,MAAM,EAAE,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAChC;AAYD,wBAAgB,8BAA8B,KACjB,SAAS,WAAW,EAAE,YAAY,WAAW,oCAqIzE;AAED,wBAAgB,6BAA6B,KACjB,SAAS,WAAW,EAAE,YAAY,WAAW;;;4EAsBxE"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { NextResponse } from 'next/server';
|
|
7
7
|
import { requireWorkerAuth } from '../../middleware/worker-auth.js';
|
|
8
|
-
import { getSessionState, updateSessionStatus, updateClaudeSessionId, startSession, removeWorkerSession, releaseClaim, markAgentWorked, releaseIssueLock, promoteNextPendingWork, createLogger, } from '@supaku/agentfactory-server';
|
|
8
|
+
import { getSessionState, updateSessionStatus, updateSessionCostData, updateClaudeSessionId, startSession, removeWorkerSession, releaseClaim, markAgentWorked, releaseIssueLock, promoteNextPendingWork, createLogger, } from '@supaku/agentfactory-server';
|
|
9
9
|
const log = createLogger('api:sessions:status');
|
|
10
10
|
const VALID_STATUSES = [
|
|
11
11
|
'running',
|
|
@@ -23,7 +23,7 @@ export function createSessionStatusPostHandler() {
|
|
|
23
23
|
const { id: sessionId } = await params;
|
|
24
24
|
try {
|
|
25
25
|
const body = await request.json();
|
|
26
|
-
const { workerId, status, claudeSessionId, worktreePath, error: errorInfo } = body;
|
|
26
|
+
const { workerId, status, claudeSessionId, worktreePath, error: errorInfo, totalCostUsd, inputTokens, outputTokens } = body;
|
|
27
27
|
if (!workerId || typeof workerId !== 'string') {
|
|
28
28
|
return NextResponse.json({ error: 'Bad Request', message: 'workerId is required' }, { status: 400 });
|
|
29
29
|
}
|
|
@@ -56,6 +56,9 @@ export function createSessionStatusPostHandler() {
|
|
|
56
56
|
}
|
|
57
57
|
else if (TERMINAL_STATUSES.includes(status)) {
|
|
58
58
|
await updateSessionStatus(sessionId, status);
|
|
59
|
+
if (totalCostUsd != null || inputTokens != null || outputTokens != null) {
|
|
60
|
+
await updateSessionCostData(sessionId, { totalCostUsd, inputTokens, outputTokens }).catch((err) => log.error('Failed to persist cost data', { sessionId, error: err }));
|
|
61
|
+
}
|
|
59
62
|
if (status === 'completed' && session.issueId) {
|
|
60
63
|
try {
|
|
61
64
|
await markAgentWorked(session.issueId, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-orchestrator.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/webhook-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"webhook-orchestrator.d.ts","sourceRoot":"","sources":["../../../src/orchestrator/webhook-orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA4BH,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,YAAY,CAAA;AAyFnB;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,CAAC,EAAE,yBAAyB,EAClC,KAAK,CAAC,EAAE,wBAAwB,GAC/B,2BAA2B,CA8O7B"}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { createOrchestrator, } from '@supaku/agentfactory';
|
|
12
12
|
import { withRetry, AgentSpawnError, isRetryableError, createAgentSession, createLinearAgentClient, } from '@supaku/agentfactory-linear';
|
|
13
|
-
import { createLogger, generateIdempotencyKey, isWebhookProcessed, markWebhookProcessed, unmarkWebhookProcessed, storeSessionState, getSessionState, updateClaudeSessionId, updateSessionStatus, } from '@supaku/agentfactory-server';
|
|
13
|
+
import { createLogger, generateIdempotencyKey, isWebhookProcessed, markWebhookProcessed, unmarkWebhookProcessed, storeSessionState, getSessionState, updateClaudeSessionId, updateSessionStatus, updateSessionCostData, } from '@supaku/agentfactory-server';
|
|
14
14
|
import { formatErrorForComment } from './error-formatting.js';
|
|
15
15
|
const log = createLogger('webhook-orchestrator');
|
|
16
16
|
const DEFAULT_RETRY_CONFIG = {
|
|
@@ -134,7 +134,15 @@ export function createWebhookOrchestrator(config, hooks) {
|
|
|
134
134
|
agentIdentifier: agent.identifier,
|
|
135
135
|
issueId: agent.issueId,
|
|
136
136
|
sessionId: agent.sessionId,
|
|
137
|
+
totalCostUsd: agent.totalCostUsd,
|
|
137
138
|
});
|
|
139
|
+
if (agent.sessionId && (agent.totalCostUsd != null || agent.inputTokens != null || agent.outputTokens != null)) {
|
|
140
|
+
await updateSessionCostData(agent.sessionId, {
|
|
141
|
+
totalCostUsd: agent.totalCostUsd,
|
|
142
|
+
inputTokens: agent.inputTokens,
|
|
143
|
+
outputTokens: agent.outputTokens,
|
|
144
|
+
}).catch((err) => log.error('Failed to persist cost data', { error: err }));
|
|
145
|
+
}
|
|
138
146
|
try {
|
|
139
147
|
await hooks?.onAgentComplete?.(agent);
|
|
140
148
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supaku/agentfactory-nextjs",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Next.js API route handlers for AgentFactory — webhook processor, worker/session management, public stats",
|
|
6
6
|
"author": "Supaku (https://supaku.com)",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"LICENSE"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@supaku/agentfactory": "0.6.
|
|
52
|
-
"@supaku/agentfactory-
|
|
53
|
-
"@supaku/agentfactory
|
|
51
|
+
"@supaku/agentfactory-linear": "0.6.2",
|
|
52
|
+
"@supaku/agentfactory-server": "0.6.2",
|
|
53
|
+
"@supaku/agentfactory": "0.6.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"next": ">=14.0.0"
|