@meetopenbot/claude-code 0.1.9 → 0.1.11
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/dist/index.js +58 -48
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19383,7 +19383,7 @@ var buildCreditsAnthropicEnv = () => {
|
|
|
19383
19383
|
if (!config) return void 0;
|
|
19384
19384
|
const apiKey = config.token || CREDITS_API_KEY_PLACEHOLDER;
|
|
19385
19385
|
return {
|
|
19386
|
-
ANTHROPIC_BASE_URL: `${config.baseUrl}/anthropic
|
|
19386
|
+
ANTHROPIC_BASE_URL: `${config.baseUrl}/anthropic`,
|
|
19387
19387
|
ANTHROPIC_CUSTOM_HEADERS: `${INTEGRATIONS_TOKEN_HEADER}: ${config.token}`,
|
|
19388
19388
|
ANTHROPIC_API_KEY: apiKey,
|
|
19389
19389
|
// Prevent the CLI from preferring stored OAuth over gateway routing.
|
|
@@ -19730,13 +19730,34 @@ var claudeCodeRuntime = (options = {}) => (builder) => {
|
|
|
19730
19730
|
...allowedTools ? { allowedTools } : {},
|
|
19731
19731
|
...sdkEnv ? { env: sdkEnv } : {}
|
|
19732
19732
|
};
|
|
19733
|
+
let creditsFailureYielded = false;
|
|
19733
19734
|
try {
|
|
19734
19735
|
let lastSessionId = resumeId;
|
|
19735
19736
|
let authWidgetYielded = false;
|
|
19736
|
-
let creditsFailureYielded = false;
|
|
19737
19737
|
const emittedToolCallIds = /* @__PURE__ */ new Set();
|
|
19738
19738
|
const emittedToolResultIds = /* @__PURE__ */ new Set();
|
|
19739
19739
|
const toolTitleByUseId = /* @__PURE__ */ new Map();
|
|
19740
|
+
const emitAssistantText = function* (text) {
|
|
19741
|
+
if (!text) return;
|
|
19742
|
+
if (authMode === "credits") {
|
|
19743
|
+
const creditsMessage = creditsErrorMessage(text);
|
|
19744
|
+
if (creditsMessage) {
|
|
19745
|
+
if (creditsFailureYielded) return;
|
|
19746
|
+
creditsFailureYielded = true;
|
|
19747
|
+
yield agentOutput({
|
|
19748
|
+
agentId: context.state.agentId,
|
|
19749
|
+
threadId,
|
|
19750
|
+
content: creditsMessage
|
|
19751
|
+
});
|
|
19752
|
+
return;
|
|
19753
|
+
}
|
|
19754
|
+
}
|
|
19755
|
+
yield agentOutput({
|
|
19756
|
+
agentId: context.state.agentId,
|
|
19757
|
+
threadId,
|
|
19758
|
+
content: text
|
|
19759
|
+
});
|
|
19760
|
+
};
|
|
19740
19761
|
for await (const message of QA$({ prompt: userContent, options: sdkOptions })) {
|
|
19741
19762
|
if ("session_id" in message && typeof message.session_id === "string") {
|
|
19742
19763
|
lastSessionId = message.session_id;
|
|
@@ -19770,11 +19791,7 @@ var claudeCodeRuntime = (options = {}) => (builder) => {
|
|
|
19770
19791
|
const joined = textParts.join("\n");
|
|
19771
19792
|
textParts.length = 0;
|
|
19772
19793
|
if (joined.length > 0) {
|
|
19773
|
-
yield
|
|
19774
|
-
agentId: context.state.agentId,
|
|
19775
|
-
threadId,
|
|
19776
|
-
content: joined
|
|
19777
|
-
});
|
|
19794
|
+
yield* emitAssistantText(joined);
|
|
19778
19795
|
}
|
|
19779
19796
|
}
|
|
19780
19797
|
if (!emittedToolCallIds.has(tool.toolUseId)) {
|
|
@@ -19807,23 +19824,7 @@ var claudeCodeRuntime = (options = {}) => (builder) => {
|
|
|
19807
19824
|
}
|
|
19808
19825
|
}
|
|
19809
19826
|
if (textParts.length > 0) {
|
|
19810
|
-
|
|
19811
|
-
if (joined.length > 0) {
|
|
19812
|
-
if (authMode === "credits" && !creditsFailureYielded && isIntegrationsProviderError(joined)) {
|
|
19813
|
-
creditsFailureYielded = true;
|
|
19814
|
-
yield agentOutput({
|
|
19815
|
-
agentId: context.state.agentId,
|
|
19816
|
-
threadId,
|
|
19817
|
-
content: CREDITS_PROVIDER_UNAVAILABLE_MESSAGE
|
|
19818
|
-
});
|
|
19819
|
-
} else {
|
|
19820
|
-
yield agentOutput({
|
|
19821
|
-
agentId: context.state.agentId,
|
|
19822
|
-
threadId,
|
|
19823
|
-
content: joined
|
|
19824
|
-
});
|
|
19825
|
-
}
|
|
19826
|
-
}
|
|
19827
|
+
yield* emitAssistantText(textParts.join("\n"));
|
|
19827
19828
|
}
|
|
19828
19829
|
}
|
|
19829
19830
|
}
|
|
@@ -19865,25 +19866,29 @@ var claudeCodeRuntime = (options = {}) => (builder) => {
|
|
|
19865
19866
|
const errorText = resultText || subtype;
|
|
19866
19867
|
if (authMode === "credits") {
|
|
19867
19868
|
const creditsMessage = creditsErrorMessage(errorText);
|
|
19868
|
-
if (creditsMessage
|
|
19869
|
-
creditsFailureYielded
|
|
19870
|
-
|
|
19871
|
-
|
|
19872
|
-
|
|
19873
|
-
|
|
19874
|
-
|
|
19875
|
-
|
|
19869
|
+
if (creditsMessage) {
|
|
19870
|
+
if (!creditsFailureYielded) {
|
|
19871
|
+
creditsFailureYielded = true;
|
|
19872
|
+
yield agentOutput({
|
|
19873
|
+
agentId: context.state.agentId,
|
|
19874
|
+
threadId,
|
|
19875
|
+
content: creditsMessage
|
|
19876
|
+
});
|
|
19877
|
+
}
|
|
19878
|
+
continue;
|
|
19876
19879
|
}
|
|
19877
|
-
if (creditsFailureYielded) return;
|
|
19878
19880
|
}
|
|
19879
19881
|
if (!authWidgetYielded && (isAuthErrorMessage(subtype) || isAuthErrorMessage(resultText))) {
|
|
19880
19882
|
authWidgetYielded = true;
|
|
19881
19883
|
if (authMode === "credits") {
|
|
19882
|
-
|
|
19883
|
-
|
|
19884
|
-
|
|
19885
|
-
|
|
19886
|
-
|
|
19884
|
+
if (!creditsFailureYielded) {
|
|
19885
|
+
creditsFailureYielded = true;
|
|
19886
|
+
yield agentOutput({
|
|
19887
|
+
agentId: context.state.agentId,
|
|
19888
|
+
threadId,
|
|
19889
|
+
content: creditsErrorMessage(errorText) ?? CREDITS_AUTH_FAILED_MESSAGE
|
|
19890
|
+
});
|
|
19891
|
+
}
|
|
19887
19892
|
} else {
|
|
19888
19893
|
yield buildApiKeyWidget(context.state.agentId, threadId, subtype);
|
|
19889
19894
|
}
|
|
@@ -19906,21 +19911,26 @@ ${details}` : `[claude-code] run ended with error: ${subtype}`
|
|
|
19906
19911
|
if (authMode === "credits") {
|
|
19907
19912
|
const creditsMessage = creditsErrorMessage(errorMessage);
|
|
19908
19913
|
if (creditsMessage) {
|
|
19909
|
-
|
|
19910
|
-
|
|
19911
|
-
|
|
19912
|
-
|
|
19913
|
-
|
|
19914
|
+
if (!creditsFailureYielded) {
|
|
19915
|
+
yield agentOutput({
|
|
19916
|
+
agentId: context.state.agentId,
|
|
19917
|
+
threadId,
|
|
19918
|
+
content: creditsMessage
|
|
19919
|
+
});
|
|
19920
|
+
}
|
|
19914
19921
|
return;
|
|
19915
19922
|
}
|
|
19916
19923
|
}
|
|
19917
19924
|
if (isAuthErrorMessage(errorMessage)) {
|
|
19918
19925
|
if (authMode === "credits") {
|
|
19919
|
-
|
|
19920
|
-
|
|
19921
|
-
|
|
19922
|
-
|
|
19923
|
-
|
|
19926
|
+
if (!creditsFailureYielded) {
|
|
19927
|
+
creditsFailureYielded = true;
|
|
19928
|
+
yield agentOutput({
|
|
19929
|
+
agentId: context.state.agentId,
|
|
19930
|
+
threadId,
|
|
19931
|
+
content: creditsErrorMessage(errorMessage) ?? CREDITS_AUTH_FAILED_MESSAGE
|
|
19932
|
+
});
|
|
19933
|
+
}
|
|
19924
19934
|
} else {
|
|
19925
19935
|
yield buildApiKeyWidget(context.state.agentId, threadId, errorMessage);
|
|
19926
19936
|
}
|