@hienlh/ppm 0.8.4 → 0.8.6
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/CHANGELOG.md +13 -0
- package/package.json +1 -1
- package/src/providers/claude-agent-sdk.ts +10 -36
- package/src/server/ws/chat.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.6] - 2026-03-23
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **Actionable timeout error**: Timeout error now shows project path, exact `claude -p "hi"` debug command, and steps to check hooks/MCP/settings
|
|
7
|
+
- **SDK lifecycle logging**: All SDK `system` events (hook_started, init, etc.) now logged with full JSON — helps diagnose where SDK hangs
|
|
8
|
+
|
|
9
|
+
## [0.8.5] - 2026-03-23
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- **Diagnostic error messages for project-specific failures**: When SDK returns `assistant error: unknown`, error now includes project path and exact `claude` CLI command to run for diagnosis
|
|
13
|
+
- **Full SDK event dump on error**: Log complete assistant message JSON for debugging (visible in server logs)
|
|
14
|
+
- **Removed broken session retry**: Retry-as-fresh-session didn't help since fresh sessions also fail for the same project — removed to avoid masking the real error
|
|
15
|
+
|
|
3
16
|
## [0.8.4] - 2026-03-23
|
|
4
17
|
|
|
5
18
|
### Fixed
|
package/package.json
CHANGED
|
@@ -688,6 +688,11 @@ export class ClaudeAgentSdkProvider implements AIProvider {
|
|
|
688
688
|
yield approvalEvents.shift()!;
|
|
689
689
|
}
|
|
690
690
|
|
|
691
|
+
// Log all system events for debugging SDK lifecycle
|
|
692
|
+
if (msg.type === "system") {
|
|
693
|
+
console.log(`[sdk] session=${sessionId} system: subtype=${(msg as any).subtype ?? "none"} ${JSON.stringify(msg).slice(0, 500)}`);
|
|
694
|
+
}
|
|
695
|
+
|
|
691
696
|
// Capture SDK session metadata from init message
|
|
692
697
|
if (msg.type === "system" && (msg as any).subtype === "init") {
|
|
693
698
|
const initMsg = msg as any;
|
|
@@ -799,47 +804,16 @@ export class ClaudeAgentSdkProvider implements AIProvider {
|
|
|
799
804
|
// SDK assistant messages can carry an error field for auth/billing/rate-limit failures
|
|
800
805
|
const assistantError = (msg as any).error as string | undefined;
|
|
801
806
|
if (assistantError) {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
retryCount++;
|
|
806
|
-
console.warn(`[sdk] session=${sessionId} resume failed with assistant error "${assistantError}" — retrying as fresh session`);
|
|
807
|
-
yield { type: "text" as const, content: `Session resume failed (${assistantError}). Retrying with a fresh session...` };
|
|
808
|
-
// Re-create query without resume
|
|
809
|
-
const freshQ = query({
|
|
810
|
-
prompt: message,
|
|
811
|
-
options: {
|
|
812
|
-
cwd: effectiveCwd,
|
|
813
|
-
systemPrompt: systemPromptOpt,
|
|
814
|
-
settingSources: ["user", "project"],
|
|
815
|
-
env: queryEnv,
|
|
816
|
-
settings: { permissions: { allow: [], deny: [] } },
|
|
817
|
-
allowedTools,
|
|
818
|
-
permissionMode,
|
|
819
|
-
allowDangerouslySkipPermissions: isBypass,
|
|
820
|
-
...(permissionHooks && { hooks: permissionHooks }),
|
|
821
|
-
...(providerConfig.model && { model: providerConfig.model }),
|
|
822
|
-
...(providerConfig.effort && { effort: providerConfig.effort }),
|
|
823
|
-
maxTurns: providerConfig.max_turns ?? 100,
|
|
824
|
-
...(providerConfig.max_budget_usd && { maxBudgetUsd: providerConfig.max_budget_usd }),
|
|
825
|
-
...(providerConfig.thinking_budget_tokens != null && {
|
|
826
|
-
thinkingBudgetTokens: providerConfig.thinking_budget_tokens,
|
|
827
|
-
}),
|
|
828
|
-
canUseTool,
|
|
829
|
-
includePartialMessages: true,
|
|
830
|
-
} as any,
|
|
831
|
-
});
|
|
832
|
-
this.activeQueries.set(sessionId, freshQ);
|
|
833
|
-
eventSource = freshQ;
|
|
834
|
-
continue retryLoop;
|
|
835
|
-
}
|
|
807
|
+
// Dump full SDK message for debugging
|
|
808
|
+
console.error(`[sdk] session=${sessionId} cwd=${effectiveCwd} assistant error: ${assistantError} (isFirst=${isFirstMessage} retry=${retryCount})`);
|
|
809
|
+
console.error(`[sdk] assistant message dump: ${JSON.stringify(msg).slice(0, 2000)}`);
|
|
836
810
|
const errorHints: Record<string, string> = {
|
|
837
811
|
authentication_failed: "API authentication failed. Check your account credentials in Settings → Accounts.",
|
|
838
812
|
billing_error: "Billing error on this account. Check your subscription status.",
|
|
839
813
|
rate_limit: "Rate limited by the API. Please wait and try again.",
|
|
840
814
|
invalid_request: "Invalid request sent to the API.",
|
|
841
815
|
server_error: "Anthropic API server error. Try again shortly.",
|
|
842
|
-
unknown:
|
|
816
|
+
unknown: `API error in project "${effectiveCwd}". Debug: run \`cd ${effectiveCwd} && claude -p "hi"\` in your terminal. If that also fails, the issue is Claude CLI auth or project config (.claude/ folder). Try: 1) \`claude login\`, 2) Remove .claude/settings.local.json, 3) Create a new chat session.`,
|
|
843
817
|
};
|
|
844
818
|
const hint = errorHints[assistantError] ?? `API error: ${assistantError}`;
|
|
845
819
|
yield { type: "error", message: hint };
|
|
@@ -1020,7 +994,7 @@ export class ClaudeAgentSdkProvider implements AIProvider {
|
|
|
1020
994
|
} // end retryLoop
|
|
1021
995
|
} catch (e) {
|
|
1022
996
|
const msg = (e as Error).message ?? String(e);
|
|
1023
|
-
console.error(`[sdk] error: ${msg}`);
|
|
997
|
+
console.error(`[sdk] session=${sessionId} cwd=${meta.projectPath} error: ${msg}`);
|
|
1024
998
|
if (msg.includes("abort") || msg.includes("closed")) {
|
|
1025
999
|
// User-initiated abort or WS closed — nothing to report
|
|
1026
1000
|
} else if (!isFirstMessage && msg.includes("exited with code")) {
|
package/src/server/ws/chat.ts
CHANGED
|
@@ -135,9 +135,10 @@ async function runStreamLoop(sessionId: string, providerId: string, content: str
|
|
|
135
135
|
const wslHint = isWSL
|
|
136
136
|
? "\n\nWSL detected — this is likely a network issue. Try from your WSL terminal:\n curl -s https://api.anthropic.com\nIf that fails, check WSL DNS settings (/etc/resolv.conf) or proxy configuration."
|
|
137
137
|
: "";
|
|
138
|
+
const debugCmd = projectPath ? `cd ${projectPath} && claude -p "hi"` : `claude -p "hi"`;
|
|
138
139
|
safeSend(sessionId, {
|
|
139
140
|
type: "error",
|
|
140
|
-
message: `Claude SDK
|
|
141
|
+
message: `Claude SDK timed out after ${elapsed}s for project "${projectPath || "(no project)"}".${wslHint}\n\nDebug steps:\n1. Run in your terminal: \`${debugCmd}\`\n2. Check for hanging hooks/MCP servers: \`cat ${projectPath}/.claude/settings.local.json\`\n3. Try removing project Claude config: \`mv ${projectPath}/.claude ${projectPath}/.claude.bak\`\n4. If none of the above helps, try: \`claude login\` to refresh auth`,
|
|
141
142
|
});
|
|
142
143
|
abortController.abort();
|
|
143
144
|
return;
|