fix(#14,#16): stub mode for executeWorkStreaming + SSE race condition
Fix #14 — AgentService stub mode for executeWorkStreaming: - Remove static import of @workspace/integrations-anthropic-ai (throws on module load when env vars absent) - Add STUB_MODE detection at startup using AI_INTEGRATIONS_ANTHROPIC_API_KEY and AI_INTEGRATIONS_ANTHROPIC_BASE_URL presence - Lazy getClient() uses dynamic import, only called in live mode - stub executeWork() and executeWorkStreaming() return canned responses; streaming stub emits word-by-word with 40 ms delay to exercise SSE path - Define local AnthropicLike interface — no dependency on @anthropic-ai/sdk types or unbuilt integrations-anthropic-ai dist Fix #16 — SSE stream registry race condition: - After bus-listener wait, refresh BOTH stream registry AND job state from DB - If job completed while waiting (stream already gone), replay full result immediately instead of emitting 'Stream not available' error - Increase wait timeout from 60 s to 90 s for mainnet payment latency - Cleaner event bus filter: any jobId event resolves the wait (not just job:state and job:paid) so job:completed also unblocks waiting clients - Named branches with comments for each resolution path Fix pre-existing typecheck errors (bonus): - event-bus.ts: EventEmitter overload uses any[] not unknown[] - testkit.ts: escape bash ${ELAPSED_T14} in TS template literal
This commit is contained in:
@@ -383,7 +383,7 @@ if [[ -n "$SESSION_MACAROON" && "$SESSION_MACAROON" != "null" ]]; then
|
||||
END_T14=$(date +%s)
|
||||
ELAPSED_T14=$((END_T14 - START_T14))
|
||||
if [[ "$T14_CODE" == "200" && ("$T14_STATE" == "complete" || "$T14_STATE" == "rejected") && -n "$T14_DEBITED" && "$T14_DEBITED" != "null" && -n "$T14_BAL" ]]; then
|
||||
note PASS "state=$T14_STATE in ${ELAPSED_T14}s, debitedSats=$T14_DEBITED, balanceRemaining=$T14_BAL"
|
||||
note PASS "state=$T14_STATE in \${ELAPSED_T14}s, debitedSats=$T14_DEBITED, balanceRemaining=$T14_BAL"
|
||||
PASS=$((PASS+1))
|
||||
else
|
||||
note FAIL "code=$T14_CODE body=$T14_BODY"
|
||||
|
||||
Reference in New Issue
Block a user