@rayu-dev/rayu-cli 1.4.475 → 1.4.477
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/rayu.js +889 -117
- package/package.json +1 -1
package/dist/rayu.js
CHANGED
|
@@ -144577,6 +144577,24 @@ var init_bedrock = __esm(() => {
|
|
|
144577
144577
|
});
|
|
144578
144578
|
|
|
144579
144579
|
// src/utils/model/configs.ts
|
|
144580
|
+
function modelFamilyOf(model) {
|
|
144581
|
+
const m2 = model.toLowerCase();
|
|
144582
|
+
if (m2.includes("opus"))
|
|
144583
|
+
return "opus";
|
|
144584
|
+
if (m2.includes("sonnet"))
|
|
144585
|
+
return "sonnet";
|
|
144586
|
+
if (m2.includes("haiku"))
|
|
144587
|
+
return "haiku";
|
|
144588
|
+
return "other";
|
|
144589
|
+
}
|
|
144590
|
+
function isFamilyConsistentOverride(canonicalId, override) {
|
|
144591
|
+
const keyFamily = modelFamilyOf(canonicalId);
|
|
144592
|
+
const valueFamily = modelFamilyOf(override);
|
|
144593
|
+
if (keyFamily === "other" || valueFamily === "other") {
|
|
144594
|
+
return true;
|
|
144595
|
+
}
|
|
144596
|
+
return keyFamily === valueFamily;
|
|
144597
|
+
}
|
|
144580
144598
|
var CLAUDE_3_7_SONNET_CONFIG, CLAUDE_3_5_V2_SONNET_CONFIG, CLAUDE_3_5_HAIKU_CONFIG, CLAUDE_HAIKU_4_5_CONFIG, CLAUDE_SONNET_4_CONFIG, CLAUDE_SONNET_4_5_CONFIG, CLAUDE_OPUS_4_CONFIG, CLAUDE_OPUS_4_1_CONFIG, CLAUDE_OPUS_4_5_CONFIG, CLAUDE_OPUS_4_6_CONFIG, CLAUDE_SONNET_4_6_CONFIG, ALL_MODEL_CONFIGS, CANONICAL_MODEL_IDS, CANONICAL_ID_TO_KEY;
|
|
144581
144599
|
var init_configs = __esm(() => {
|
|
144582
144600
|
CLAUDE_3_7_SONNET_CONFIG = {
|
|
@@ -144641,7 +144659,7 @@ var init_configs = __esm(() => {
|
|
|
144641
144659
|
};
|
|
144642
144660
|
CLAUDE_SONNET_4_6_CONFIG = {
|
|
144643
144661
|
anthropic: "claude-sonnet-4-6",
|
|
144644
|
-
bedrock: "us.anthropic.claude-sonnet-4-6",
|
|
144662
|
+
bedrock: "us.anthropic.claude-sonnet-4-6-v1",
|
|
144645
144663
|
vertex: "claude-sonnet-4-6",
|
|
144646
144664
|
foundry: "claude-sonnet-4-6"
|
|
144647
144665
|
};
|
|
@@ -144689,6 +144707,17 @@ async function getBedrockModelStrings() {
|
|
|
144689
144707
|
}
|
|
144690
144708
|
return out;
|
|
144691
144709
|
}
|
|
144710
|
+
function overridePassesFidelity(canonicalId, override) {
|
|
144711
|
+
if (isFamilyConsistentOverride(canonicalId, override)) {
|
|
144712
|
+
return true;
|
|
144713
|
+
}
|
|
144714
|
+
const sig = `${canonicalId}\x00${override}`;
|
|
144715
|
+
if (!warnedMismatchedOverrides.has(sig)) {
|
|
144716
|
+
warnedMismatchedOverrides.add(sig);
|
|
144717
|
+
logError2(new Error(`Ignoring cross-family modelOverride "${canonicalId}" -> "${override}": ` + `the override targets a different model family than the model it overrides. ` + `Falling back to the default wire model for "${canonicalId}" to preserve model fidelity.`));
|
|
144718
|
+
}
|
|
144719
|
+
return false;
|
|
144720
|
+
}
|
|
144692
144721
|
function applyModelOverrides(ms) {
|
|
144693
144722
|
const overrides = getInitialSettings().modelOverrides;
|
|
144694
144723
|
if (!overrides) {
|
|
@@ -144697,7 +144726,7 @@ function applyModelOverrides(ms) {
|
|
|
144697
144726
|
const out = { ...ms };
|
|
144698
144727
|
for (const [canonicalId, override] of Object.entries(overrides)) {
|
|
144699
144728
|
const key = CANONICAL_ID_TO_KEY[canonicalId];
|
|
144700
|
-
if (key && override) {
|
|
144729
|
+
if (key && override && overridePassesFidelity(canonicalId, override)) {
|
|
144701
144730
|
out[key] = override;
|
|
144702
144731
|
}
|
|
144703
144732
|
}
|
|
@@ -144714,7 +144743,7 @@ function resolveOverriddenModel(modelId) {
|
|
|
144714
144743
|
return modelId;
|
|
144715
144744
|
}
|
|
144716
144745
|
for (const [canonicalId, override] of Object.entries(overrides)) {
|
|
144717
|
-
if (override === modelId) {
|
|
144746
|
+
if (override === modelId && isFamilyConsistentOverride(canonicalId, override)) {
|
|
144718
144747
|
return canonicalId;
|
|
144719
144748
|
}
|
|
144720
144749
|
}
|
|
@@ -144750,7 +144779,7 @@ async function ensureModelStringsInitialized() {
|
|
|
144750
144779
|
}
|
|
144751
144780
|
await updateBedrockModelStrings();
|
|
144752
144781
|
}
|
|
144753
|
-
var MODEL_KEYS, updateBedrockModelStrings;
|
|
144782
|
+
var MODEL_KEYS, warnedMismatchedOverrides, updateBedrockModelStrings;
|
|
144754
144783
|
var init_modelStrings = __esm(() => {
|
|
144755
144784
|
init_state();
|
|
144756
144785
|
init_log2();
|
|
@@ -144759,6 +144788,7 @@ var init_modelStrings = __esm(() => {
|
|
|
144759
144788
|
init_configs();
|
|
144760
144789
|
init_providers();
|
|
144761
144790
|
MODEL_KEYS = Object.keys(ALL_MODEL_CONFIGS);
|
|
144791
|
+
warnedMismatchedOverrides = new Set;
|
|
144762
144792
|
updateBedrockModelStrings = sequential(async () => {
|
|
144763
144793
|
if (getModelStrings() !== null) {
|
|
144764
144794
|
return;
|
|
@@ -148992,7 +149022,7 @@ var init_isEqual = __esm(() => {
|
|
|
148992
149022
|
|
|
148993
149023
|
// src/utils/userAgent.ts
|
|
148994
149024
|
function getRayuUserAgent() {
|
|
148995
|
-
return `rayu/${"1.4.
|
|
149025
|
+
return `rayu/${"1.4.477"}`;
|
|
148996
149026
|
}
|
|
148997
149027
|
var getClaudeCodeUserAgent;
|
|
148998
149028
|
var init_userAgent = __esm(() => {
|
|
@@ -149018,7 +149048,7 @@ function getUserAgent() {
|
|
|
149018
149048
|
const clientApp = process.env.RAYU_AGENT_SDK_CLIENT_APP ? `, client-app/${process.env.RAYU_AGENT_SDK_CLIENT_APP}` : "";
|
|
149019
149049
|
const workload = getWorkload();
|
|
149020
149050
|
const workloadSuffix = workload ? `, workload/${workload}` : "";
|
|
149021
|
-
return `rayu/${"1.4.
|
|
149051
|
+
return `rayu/${"1.4.477"} (${"external"}, ${process.env.RAYU_ENTRYPOINT ?? "cli"}${agentSdkVersion}${clientApp}${workloadSuffix})`;
|
|
149022
149052
|
}
|
|
149023
149053
|
function getMCPUserAgent() {
|
|
149024
149054
|
const parts = [];
|
|
@@ -149032,7 +149062,7 @@ function getMCPUserAgent() {
|
|
|
149032
149062
|
parts.push(`client-app/${process.env.RAYU_AGENT_SDK_CLIENT_APP}`);
|
|
149033
149063
|
}
|
|
149034
149064
|
const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
149035
|
-
return `rayu/${"1.4.
|
|
149065
|
+
return `rayu/${"1.4.477"}${suffix}`;
|
|
149036
149066
|
}
|
|
149037
149067
|
function getWebFetchUserAgent() {
|
|
149038
149068
|
return `Rayu-User (${getRayuUserAgent()})`;
|
|
@@ -158000,6 +158030,55 @@ var init_rayuSession = __esm(() => {
|
|
|
158000
158030
|
REFRESH_SKEW_MS = 60 * 1000;
|
|
158001
158031
|
});
|
|
158002
158032
|
|
|
158033
|
+
// src/services/api/rayuHosted/gatewayHeaders.ts
|
|
158034
|
+
function modelFromBedrockUrl(url3) {
|
|
158035
|
+
const m2 = url3.match(/\/model\/([^/]+)\/invoke(?:-with-response-stream)?(?:$|\?|#)/);
|
|
158036
|
+
return m2?.[1] ? decodeURIComponent(m2[1]) : "";
|
|
158037
|
+
}
|
|
158038
|
+
function modelFromBody(body) {
|
|
158039
|
+
if (typeof body !== "string" || body.length === 0) {
|
|
158040
|
+
return "";
|
|
158041
|
+
}
|
|
158042
|
+
try {
|
|
158043
|
+
const parsed = JSON.parse(body);
|
|
158044
|
+
return typeof parsed.model === "string" ? parsed.model : "";
|
|
158045
|
+
} catch {
|
|
158046
|
+
return "";
|
|
158047
|
+
}
|
|
158048
|
+
}
|
|
158049
|
+
function resolvedModelFromRequest(upstreamUrl, body) {
|
|
158050
|
+
return modelFromBedrockUrl(upstreamUrl) || modelFromBody(body);
|
|
158051
|
+
}
|
|
158052
|
+
function buildModelMetadataHeaders(params) {
|
|
158053
|
+
const resolved = resolvedModelFromRequest(params.upstreamUrl, params.body);
|
|
158054
|
+
const canonical = resolved ? safeCanonical(resolved) : "";
|
|
158055
|
+
const intended = (params.intended || canonical || resolved || "").trim();
|
|
158056
|
+
const out = {
|
|
158057
|
+
[RAYU_REQUEST_ID_HEADER]: params.requestId,
|
|
158058
|
+
[RAYU_LOGICAL_REQUEST_ID_HEADER]: (params.logicalRequestId || params.requestId).trim()
|
|
158059
|
+
};
|
|
158060
|
+
if (resolved)
|
|
158061
|
+
out[RAYU_RESOLVED_MODEL_HEADER] = resolved;
|
|
158062
|
+
if (canonical)
|
|
158063
|
+
out[RAYU_CANONICAL_MODEL_HEADER] = canonical;
|
|
158064
|
+
if (intended)
|
|
158065
|
+
out[RAYU_INTENDED_MODEL_HEADER] = intended;
|
|
158066
|
+
if (params.querySource)
|
|
158067
|
+
out[RAYU_QUERY_SOURCE_HEADER] = params.querySource;
|
|
158068
|
+
return out;
|
|
158069
|
+
}
|
|
158070
|
+
function safeCanonical(model) {
|
|
158071
|
+
try {
|
|
158072
|
+
return getCanonicalName(model);
|
|
158073
|
+
} catch {
|
|
158074
|
+
return "";
|
|
158075
|
+
}
|
|
158076
|
+
}
|
|
158077
|
+
var RAYU_REQUEST_ID_HEADER = "x-rayu-request-id", RAYU_LOGICAL_REQUEST_ID_HEADER = "x-rayu-logical-request-id", RAYU_INTENDED_MODEL_HEADER = "x-rayu-intended-model", RAYU_RESOLVED_MODEL_HEADER = "x-rayu-resolved-model", RAYU_CANONICAL_MODEL_HEADER = "x-rayu-canonical-model", RAYU_QUERY_SOURCE_HEADER = "x-rayu-query-source";
|
|
158078
|
+
var init_gatewayHeaders = __esm(() => {
|
|
158079
|
+
init_model();
|
|
158080
|
+
});
|
|
158081
|
+
|
|
158003
158082
|
// src/services/api/rayuHosted/rayuHostedAuth.ts
|
|
158004
158083
|
function rayuHostedBaseURL() {
|
|
158005
158084
|
return `${getRayuGatewayBaseUrl()}/v1`;
|
|
@@ -158026,12 +158105,24 @@ function makeRayuHostedFetch() {
|
|
|
158026
158105
|
}
|
|
158027
158106
|
const headers = new Headers(init?.headers);
|
|
158028
158107
|
headers.set("Authorization", `Bearer ${token}`);
|
|
158108
|
+
const meta3 = buildModelMetadataHeaders({
|
|
158109
|
+
upstreamUrl: url3,
|
|
158110
|
+
body: init?.body,
|
|
158111
|
+
requestId: globalThis.crypto.randomUUID(),
|
|
158112
|
+
intended: headers.get(RAYU_INTENDED_MODEL_HEADER),
|
|
158113
|
+
logicalRequestId: headers.get(RAYU_LOGICAL_REQUEST_ID_HEADER),
|
|
158114
|
+
querySource: headers.get(RAYU_QUERY_SOURCE_HEADER)
|
|
158115
|
+
});
|
|
158116
|
+
for (const [k2, v] of Object.entries(meta3)) {
|
|
158117
|
+
headers.set(k2, v);
|
|
158118
|
+
}
|
|
158029
158119
|
return inner(input, { ...init, headers });
|
|
158030
158120
|
};
|
|
158031
158121
|
return wrapped;
|
|
158032
158122
|
}
|
|
158033
158123
|
var init_rayuHostedAuth = __esm(() => {
|
|
158034
158124
|
init_rayuSession();
|
|
158125
|
+
init_gatewayHeaders();
|
|
158035
158126
|
});
|
|
158036
158127
|
|
|
158037
158128
|
// src/services/rayuAuth/rayuHostedProvider.ts
|
|
@@ -158348,6 +158439,17 @@ function makeGatewayRoutingFetch(provider, inner = globalThis.fetch) {
|
|
|
158348
158439
|
headers.set("X-Rayu-Token", token);
|
|
158349
158440
|
headers.set("X-Rayu-Upstream-URL", originalUrl);
|
|
158350
158441
|
headers.set("X-Rayu-Provider", provider.id);
|
|
158442
|
+
const meta3 = buildModelMetadataHeaders({
|
|
158443
|
+
upstreamUrl: originalUrl,
|
|
158444
|
+
body: init?.body,
|
|
158445
|
+
requestId: globalThis.crypto.randomUUID(),
|
|
158446
|
+
intended: headers.get(RAYU_INTENDED_MODEL_HEADER),
|
|
158447
|
+
logicalRequestId: headers.get(RAYU_LOGICAL_REQUEST_ID_HEADER),
|
|
158448
|
+
querySource: headers.get(RAYU_QUERY_SOURCE_HEADER)
|
|
158449
|
+
});
|
|
158450
|
+
for (const [k2, v] of Object.entries(meta3)) {
|
|
158451
|
+
headers.set(k2, v);
|
|
158452
|
+
}
|
|
158351
158453
|
const callbackToDirect = isGatewayCallbackEnabled();
|
|
158352
158454
|
try {
|
|
158353
158455
|
const res = await inner(gatewayUrl, { ...init, headers });
|
|
@@ -158371,6 +158473,7 @@ var init_gatewayRouting = __esm(() => {
|
|
|
158371
158473
|
init_rayuSession();
|
|
158372
158474
|
init_rayuEntitlements();
|
|
158373
158475
|
init_envUtils();
|
|
158476
|
+
init_gatewayHeaders();
|
|
158374
158477
|
P2P_ELIGIBLE_PLAN_CODES = new Set([
|
|
158375
158478
|
"basic",
|
|
158376
158479
|
"pro",
|
|
@@ -176835,8 +176938,11 @@ __export(exports_model, {
|
|
|
176835
176938
|
getBestModel: () => getBestModel,
|
|
176836
176939
|
anthropicNameToCanonical: () => anthropicNameToCanonical
|
|
176837
176940
|
});
|
|
176941
|
+
function activeProviderUsesOwnModelStrings() {
|
|
176942
|
+
return isRayuNonAnthropicActive() && getAPIProvider() === "anthropic";
|
|
176943
|
+
}
|
|
176838
176944
|
function getSmallFastModel() {
|
|
176839
|
-
if (
|
|
176945
|
+
if (activeProviderUsesOwnModelStrings()) {
|
|
176840
176946
|
const { getActiveProvider: getActiveProvider2, getValidDefaultModel: getValidDefaultModel2 } = (init_rayuConfig(), __toCommonJS(exports_rayuConfig));
|
|
176841
176947
|
const p = getActiveProvider2();
|
|
176842
176948
|
if (process.env.ANTHROPIC_SMALL_FAST_MODEL) {
|
|
@@ -176925,7 +177031,7 @@ function getRuntimeMainLoopModel(params) {
|
|
|
176925
177031
|
return mainLoopModel;
|
|
176926
177032
|
}
|
|
176927
177033
|
function getDefaultMainLoopModelSetting() {
|
|
176928
|
-
if (
|
|
177034
|
+
if (activeProviderUsesOwnModelStrings() || getAPIProvider() === "bedrock") {
|
|
176929
177035
|
try {
|
|
176930
177036
|
const { getActiveProvider: getActiveProvider2, getValidDefaultModel: getValidDefaultModel2 } = (init_rayuConfig(), __toCommonJS(exports_rayuConfig));
|
|
176931
177037
|
const m2 = getValidDefaultModel2(getActiveProvider2());
|
|
@@ -205400,7 +205506,7 @@ function getAttributionHeader(fingerprint) {
|
|
|
205400
205506
|
if (!isAttributionHeaderEnabled()) {
|
|
205401
205507
|
return "";
|
|
205402
205508
|
}
|
|
205403
|
-
const version2 = `${"1.4.
|
|
205509
|
+
const version2 = `${"1.4.477"}.${fingerprint}`;
|
|
205404
205510
|
const entrypoint = process.env.CLAUDE_CODE_ENTRYPOINT ?? "unknown";
|
|
205405
205511
|
const cch = "";
|
|
205406
205512
|
const workload = getWorkload();
|
|
@@ -240456,7 +240562,7 @@ function modelSupportsThinking(model) {
|
|
|
240456
240562
|
if (supported3P !== undefined) {
|
|
240457
240563
|
return supported3P;
|
|
240458
240564
|
}
|
|
240459
|
-
if (isOpenAICompatibleActive() || isRayuNonAnthropicActive()) {
|
|
240565
|
+
if (isOpenAICompatibleActive() || isRayuNonAnthropicActive() && !isClaudeModelOrAlias(model)) {
|
|
240460
240566
|
return true;
|
|
240461
240567
|
}
|
|
240462
240568
|
if (false) {}
|
|
@@ -240478,7 +240584,7 @@ function modelSupportsAdaptiveThinking(model) {
|
|
|
240478
240584
|
if (isRayuAnthropicCompatibleActive()) {
|
|
240479
240585
|
return false;
|
|
240480
240586
|
}
|
|
240481
|
-
if (isRayuNonAnthropicActive()) {
|
|
240587
|
+
if (isRayuNonAnthropicActive() && !isClaudeModelOrAlias(model)) {
|
|
240482
240588
|
return true;
|
|
240483
240589
|
}
|
|
240484
240590
|
const canonical = getCanonicalName(model);
|
|
@@ -240508,6 +240614,7 @@ function shouldEnableThinkingByDefault() {
|
|
|
240508
240614
|
var RAINBOW_COLORS, RAINBOW_SHIMMER_COLORS;
|
|
240509
240615
|
var init_thinking = __esm(() => {
|
|
240510
240616
|
init_model();
|
|
240617
|
+
init_aliases();
|
|
240511
240618
|
init_antModels();
|
|
240512
240619
|
init_modelSupportOverrides();
|
|
240513
240620
|
init_providers();
|
|
@@ -240534,7 +240641,7 @@ var init_thinking = __esm(() => {
|
|
|
240534
240641
|
|
|
240535
240642
|
// src/utils/effort.ts
|
|
240536
240643
|
function modelSupportsEffort(model) {
|
|
240537
|
-
if (isOpenAICompatibleActive() || isRayuNonAnthropicActive()) {
|
|
240644
|
+
if (isOpenAICompatibleActive() || isRayuNonAnthropicActive() && !isClaudeModelOrAlias(model)) {
|
|
240538
240645
|
return true;
|
|
240539
240646
|
}
|
|
240540
240647
|
const m2 = model.toLowerCase();
|
|
@@ -240554,7 +240661,7 @@ function modelSupportsEffort(model) {
|
|
|
240554
240661
|
return getAPIProvider() === "anthropic";
|
|
240555
240662
|
}
|
|
240556
240663
|
function modelSupportsMaxEffort(model) {
|
|
240557
|
-
if (isOpenAICompatibleActive() || isRayuNonAnthropicActive()) {
|
|
240664
|
+
if (isOpenAICompatibleActive() || isRayuNonAnthropicActive() && !isClaudeModelOrAlias(model)) {
|
|
240558
240665
|
return true;
|
|
240559
240666
|
}
|
|
240560
240667
|
const supported3P = get3PModelCapabilityOverride(model, "max_effort");
|
|
@@ -240685,6 +240792,7 @@ var init_effort = __esm(() => {
|
|
|
240685
240792
|
init_settings2();
|
|
240686
240793
|
init_auth();
|
|
240687
240794
|
init_providers();
|
|
240795
|
+
init_aliases();
|
|
240688
240796
|
init_antModels();
|
|
240689
240797
|
init_modelSupportOverrides();
|
|
240690
240798
|
init_envUtils();
|
|
@@ -259369,7 +259477,7 @@ var init_metadata = __esm(() => {
|
|
|
259369
259477
|
COMPOUND_OPERATOR_REGEX = /\s*(?:&&|\|\||[;|])\s*/;
|
|
259370
259478
|
WHITESPACE_REGEX = /\s+/;
|
|
259371
259479
|
getVersionBase = memoize_default(() => {
|
|
259372
|
-
const match = "1.4.
|
|
259480
|
+
const match = "1.4.477".match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);
|
|
259373
259481
|
return match ? match[0] : undefined;
|
|
259374
259482
|
});
|
|
259375
259483
|
buildEnvContext = memoize_default(async () => {
|
|
@@ -259408,7 +259516,7 @@ var init_metadata = __esm(() => {
|
|
|
259408
259516
|
},
|
|
259409
259517
|
isGithubAction: isEnvTruthy(process.env.GITHUB_ACTIONS),
|
|
259410
259518
|
isRayuAction: isEnvTruthy(process.env.RAYU_ACTION),
|
|
259411
|
-
version: "1.4.
|
|
259519
|
+
version: "1.4.477",
|
|
259412
259520
|
versionBase: getVersionBase(),
|
|
259413
259521
|
buildTime: "",
|
|
259414
259522
|
deploymentEnvironment: env3.detectDeploymentEnvironment(),
|
|
@@ -260728,6 +260836,17 @@ function formatAPIError(error54) {
|
|
|
260728
260836
|
return `Unable to connect to API: SSL error (${code})`;
|
|
260729
260837
|
}
|
|
260730
260838
|
}
|
|
260839
|
+
switch (code) {
|
|
260840
|
+
case "ECONNREFUSED":
|
|
260841
|
+
return "Unable to connect to the API — the connection was refused. Check your network, VPN, or proxy, then try again";
|
|
260842
|
+
case "ECONNRESET":
|
|
260843
|
+
case "EPIPE":
|
|
260844
|
+
case "ECONNABORTED":
|
|
260845
|
+
return "The connection dropped mid-request (a network blip, a proxy, or the server closing the connection). Retrying usually works";
|
|
260846
|
+
case "ENOTFOUND":
|
|
260847
|
+
case "EAI_AGAIN":
|
|
260848
|
+
return "DNS lookup failed — the API hostname could not be resolved. Check your network/DNS or proxy settings";
|
|
260849
|
+
}
|
|
260731
260850
|
}
|
|
260732
260851
|
if (error54.message === "Connection error.") {
|
|
260733
260852
|
if (connectionDetails?.code) {
|
|
@@ -260969,6 +261088,22 @@ function isRayuCreditLimitError(error54) {
|
|
|
260969
261088
|
}
|
|
260970
261089
|
return /credit limit reached|period_limit/i.test(error54.message ?? "");
|
|
260971
261090
|
}
|
|
261091
|
+
function isRayuDailyTurnLimitError(error54) {
|
|
261092
|
+
if (!(error54 instanceof import_sdk11.APIError) || error54.status !== 429) {
|
|
261093
|
+
return false;
|
|
261094
|
+
}
|
|
261095
|
+
const limitHeader = error54.headers?.get?.("x-rayu-limit");
|
|
261096
|
+
if (String(limitHeader ?? "") === "daily_turn_limit") {
|
|
261097
|
+
return true;
|
|
261098
|
+
}
|
|
261099
|
+
const body = error54.error;
|
|
261100
|
+
if (body && typeof body === "object") {
|
|
261101
|
+
if ("reason" in body && String(body.reason ?? "") === "daily_turn_limit") {
|
|
261102
|
+
return true;
|
|
261103
|
+
}
|
|
261104
|
+
}
|
|
261105
|
+
return /daily[ _]turn[ _]limit/i.test(error54.message ?? "");
|
|
261106
|
+
}
|
|
260972
261107
|
function getRayuCreditResetSeconds(error54) {
|
|
260973
261108
|
const body = error54.error;
|
|
260974
261109
|
if (body && typeof body === "object" && "resetSeconds" in body) {
|
|
@@ -260994,6 +261129,29 @@ function formatCreditResetHint(seconds) {
|
|
|
260994
261129
|
const mins = Math.max(1, Math.round(seconds / 60));
|
|
260995
261130
|
return `in about ${mins} minute${mins === 1 ? "" : "s"}`;
|
|
260996
261131
|
}
|
|
261132
|
+
function isRayuHostedActive() {
|
|
261133
|
+
try {
|
|
261134
|
+
return getActiveProvider()?.kind === "rayu-hosted";
|
|
261135
|
+
} catch {
|
|
261136
|
+
return false;
|
|
261137
|
+
}
|
|
261138
|
+
}
|
|
261139
|
+
function isRayuHostedProviderUnavailable(error54) {
|
|
261140
|
+
if (!(error54 instanceof import_sdk11.APIError) || !isRayuHostedActive())
|
|
261141
|
+
return false;
|
|
261142
|
+
if (typeof error54.status === "number" && error54.status >= 500)
|
|
261143
|
+
return true;
|
|
261144
|
+
const body = error54.error;
|
|
261145
|
+
if (body && typeof body === "object") {
|
|
261146
|
+
if (String(body.type ?? "") === "provider_unavailable")
|
|
261147
|
+
return true;
|
|
261148
|
+
const nested = body.error;
|
|
261149
|
+
if (nested && typeof nested === "object" && String(nested.type ?? "") === "provider_unavailable") {
|
|
261150
|
+
return true;
|
|
261151
|
+
}
|
|
261152
|
+
}
|
|
261153
|
+
return /provider_unavailable/i.test(error54.message ?? "");
|
|
261154
|
+
}
|
|
260997
261155
|
function getAssistantMessageFromError(error54, model, options) {
|
|
260998
261156
|
if (error54 instanceof import_sdk11.APIConnectionTimeoutError || error54 instanceof import_sdk11.APIConnectionError && error54.message.toLowerCase().includes("timeout")) {
|
|
260999
261157
|
return createAssistantAPIErrorMessage({
|
|
@@ -261001,6 +261159,21 @@ function getAssistantMessageFromError(error54, model, options) {
|
|
|
261001
261159
|
error: "unknown"
|
|
261002
261160
|
});
|
|
261003
261161
|
}
|
|
261162
|
+
if (isRayuHostedActive()) {
|
|
261163
|
+
const switchCmd = getIsNonInteractiveSession() ? "--model" : "/model";
|
|
261164
|
+
if (error54 instanceof import_sdk11.APIConnectionError && !(error54 instanceof import_sdk11.APIConnectionTimeoutError)) {
|
|
261165
|
+
return createAssistantAPIErrorMessage({
|
|
261166
|
+
error: "unknown",
|
|
261167
|
+
content: `⚠️ Can't reach Rayu right now — the service may be temporarily down, or your connection dropped. Please try again in a little while.`
|
|
261168
|
+
});
|
|
261169
|
+
}
|
|
261170
|
+
if (isRayuHostedProviderUnavailable(error54)) {
|
|
261171
|
+
return createAssistantAPIErrorMessage({
|
|
261172
|
+
error: "invalid_request",
|
|
261173
|
+
content: `⚠️ Rayu's AI provider for "${model}" is temporarily unavailable. Try a smaller model with ${switchCmd}, or try again in a little while.`
|
|
261174
|
+
});
|
|
261175
|
+
}
|
|
261176
|
+
}
|
|
261004
261177
|
if (error54 instanceof ImageSizeError || error54 instanceof ImageResizeError) {
|
|
261005
261178
|
return createAssistantAPIErrorMessage({
|
|
261006
261179
|
content: getImageTooLargeErrorMessage()
|
|
@@ -261022,6 +261195,15 @@ function getAssistantMessageFromError(error54, model, options) {
|
|
|
261022
261195
|
content: `\uD83D\uDCB3 You've reached your plan's credit limit for this billing period.${resetHint} Renew or upgrade your plan, or add more credits, to keep using Rayu-hosted models: ${plansUrl}${switchHint}`
|
|
261023
261196
|
});
|
|
261024
261197
|
}
|
|
261198
|
+
if (isRayuDailyTurnLimitError(error54)) {
|
|
261199
|
+
const plansUrl = `${getRayuWebBaseUrl()}/plans`;
|
|
261200
|
+
const resetSeconds = getRayuCreditResetSeconds(error54);
|
|
261201
|
+
const resetHint = resetSeconds ? ` It resets ${formatCreditResetHint(resetSeconds)}.` : " It resets at the start of the next day (UTC).";
|
|
261202
|
+
return createAssistantAPIErrorMessage({
|
|
261203
|
+
error: "rate_limit",
|
|
261204
|
+
content: `\uD83D\uDEA6 You've reached your plan's daily request limit.${resetHint} Upgrade for a higher daily limit: ${plansUrl}`
|
|
261205
|
+
});
|
|
261206
|
+
}
|
|
261025
261207
|
if (error54 instanceof import_sdk11.APIError && error54.status === 429 && shouldProcessRateLimits(false)) {
|
|
261026
261208
|
const rateLimitType = error54.headers?.get?.("anthropic-ratelimit-unified-representative-claim");
|
|
261027
261209
|
const overageStatus = error54.headers?.get?.("anthropic-ratelimit-unified-overage-status");
|
|
@@ -261360,7 +261542,21 @@ function classifyAPIError(error54) {
|
|
|
261360
261542
|
if (connectionDetails?.isSSLError) {
|
|
261361
261543
|
return "ssl_cert_error";
|
|
261362
261544
|
}
|
|
261363
|
-
|
|
261545
|
+
switch (connectionDetails?.code) {
|
|
261546
|
+
case "ENOTFOUND":
|
|
261547
|
+
case "EAI_AGAIN":
|
|
261548
|
+
return "dns_error";
|
|
261549
|
+
case "ECONNREFUSED":
|
|
261550
|
+
return "connection_refused";
|
|
261551
|
+
case "ECONNRESET":
|
|
261552
|
+
case "EPIPE":
|
|
261553
|
+
case "ECONNABORTED":
|
|
261554
|
+
return "connection_reset";
|
|
261555
|
+
case "ETIMEDOUT":
|
|
261556
|
+
return "api_timeout";
|
|
261557
|
+
default:
|
|
261558
|
+
return "connection_error";
|
|
261559
|
+
}
|
|
261364
261560
|
}
|
|
261365
261561
|
return "unknown";
|
|
261366
261562
|
}
|
|
@@ -261895,6 +262091,12 @@ async function* withRetry(getClient, operation, options) {
|
|
|
261895
262091
|
});
|
|
261896
262092
|
throw new CannotRetryError(error54, retryContext);
|
|
261897
262093
|
}
|
|
262094
|
+
if (isRayuDailyTurnLimitError(error54)) {
|
|
262095
|
+
logEvent("tengu_api_rayu_daily_turn_limit_reached", {
|
|
262096
|
+
provider: getAPIProviderForStatsig()
|
|
262097
|
+
});
|
|
262098
|
+
throw new CannotRetryError(error54, retryContext);
|
|
262099
|
+
}
|
|
261898
262100
|
if (wasFastModeActive && !isPersistentRetryEnabled() && error54 instanceof import_sdk12.APIError && (error54.status === 429 || is529Error(error54))) {
|
|
261899
262101
|
const overageReason = error54.headers?.get("anthropic-ratelimit-unified-overage-disabled-reason");
|
|
261900
262102
|
if (overageReason !== null && overageReason !== undefined) {
|
|
@@ -261926,6 +262128,12 @@ async function* withRetry(getClient, operation, options) {
|
|
|
261926
262128
|
});
|
|
261927
262129
|
throw new CannotRetryError(error54, retryContext);
|
|
261928
262130
|
}
|
|
262131
|
+
if (error54 instanceof import_sdk12.APIError && error54.status === 429 && !shouldRetry529(options.querySource)) {
|
|
262132
|
+
logEvent("tengu_api_429_background_dropped", {
|
|
262133
|
+
query_source: options.querySource
|
|
262134
|
+
});
|
|
262135
|
+
throw new CannotRetryError(error54, retryContext);
|
|
262136
|
+
}
|
|
261929
262137
|
if (is529Error(error54) && (process.env.FALLBACK_FOR_ALL_PRIMARY_MODELS || isNonCustomOpusModel(options.model))) {
|
|
261930
262138
|
consecutive529Errors++;
|
|
261931
262139
|
if (consecutive529Errors >= MAX_529_RETRIES) {
|
|
@@ -291424,7 +291632,7 @@ function getTelemetryAttributes() {
|
|
|
291424
291632
|
attributes["session.id"] = sessionId;
|
|
291425
291633
|
}
|
|
291426
291634
|
if (shouldIncludeAttribute("OTEL_METRICS_INCLUDE_VERSION")) {
|
|
291427
|
-
attributes["app.version"] = "1.4.
|
|
291635
|
+
attributes["app.version"] = "1.4.477";
|
|
291428
291636
|
}
|
|
291429
291637
|
const oauthAccount = getOauthAccountInfo();
|
|
291430
291638
|
if (oauthAccount) {
|
|
@@ -401781,7 +401989,7 @@ function getInstallationEnv() {
|
|
|
401781
401989
|
return;
|
|
401782
401990
|
}
|
|
401783
401991
|
function getClaudeCodeVersion() {
|
|
401784
|
-
return "1.4.
|
|
401992
|
+
return "1.4.477";
|
|
401785
401993
|
}
|
|
401786
401994
|
async function getInstalledVSCodeExtensionVersion(command) {
|
|
401787
401995
|
const { stdout } = await execFileNoThrow(command, ["--list-extensions", "--show-versions"], {
|
|
@@ -407019,7 +407227,7 @@ async function setupSdkMcpClients(sdkMcpConfigs, sendMcpMessage) {
|
|
|
407019
407227
|
const client3 = new Client({
|
|
407020
407228
|
name: "claude-code",
|
|
407021
407229
|
title: "RAYU",
|
|
407022
|
-
version: "1.4.
|
|
407230
|
+
version: "1.4.477",
|
|
407023
407231
|
description: "Anthropic's agentic coding tool",
|
|
407024
407232
|
websiteUrl: PRODUCT_URL
|
|
407025
407233
|
}, {
|
|
@@ -407336,7 +407544,7 @@ var init_client7 = __esm(() => {
|
|
|
407336
407544
|
const client3 = new Client({
|
|
407337
407545
|
name: "claude-code",
|
|
407338
407546
|
title: "RAYU",
|
|
407339
|
-
version: "1.4.
|
|
407547
|
+
version: "1.4.477",
|
|
407340
407548
|
description: "Anthropic's agentic coding tool",
|
|
407341
407549
|
websiteUrl: PRODUCT_URL
|
|
407342
407550
|
}, {
|
|
@@ -422155,7 +422363,7 @@ function computeFingerprint(messageText, version2) {
|
|
|
422155
422363
|
}
|
|
422156
422364
|
function computeFingerprintFromMessages(messages) {
|
|
422157
422365
|
const firstMessageText = extractFirstMessageText(messages);
|
|
422158
|
-
return computeFingerprint(firstMessageText, "1.4.
|
|
422366
|
+
return computeFingerprint(firstMessageText, "1.4.477");
|
|
422159
422367
|
}
|
|
422160
422368
|
var FINGERPRINT_SALT = "59cf53e54c78";
|
|
422161
422369
|
var init_fingerprint = () => {};
|
|
@@ -422197,7 +422405,7 @@ async function sideQuery(opts) {
|
|
|
422197
422405
|
betas.push(STRUCTURED_OUTPUTS_BETA_HEADER);
|
|
422198
422406
|
}
|
|
422199
422407
|
const messageText = extractFirstUserMessageText(messages);
|
|
422200
|
-
const fingerprint = computeFingerprint(messageText, "1.4.
|
|
422408
|
+
const fingerprint = computeFingerprint(messageText, "1.4.477");
|
|
422201
422409
|
const attributionHeader = getAttributionHeader(fingerprint);
|
|
422202
422410
|
const systemBlocks = [
|
|
422203
422411
|
attributionHeader ? { type: "text", text: attributionHeader } : null,
|
|
@@ -498695,6 +498903,9 @@ function getContentText(content) {
|
|
|
498695
498903
|
}
|
|
498696
498904
|
return null;
|
|
498697
498905
|
}
|
|
498906
|
+
function finalizeStreamingThinkingOnTurnEnd(current) {
|
|
498907
|
+
return current && current.isStreaming ? null : current;
|
|
498908
|
+
}
|
|
498698
498909
|
function handleMessageFromStream(message, onMessage2, onUpdateLength, onSetStreamMode, onStreamingToolUses, onTombstone, onStreamingThinking, onApiMetrics, onStreamingText) {
|
|
498699
498910
|
if (message.type !== "stream_event" && message.type !== "stream_request_start") {
|
|
498700
498911
|
if (message.type === "tombstone") {
|
|
@@ -510922,6 +511133,7 @@ ${deferredToolList}
|
|
|
510922
511133
|
let stream4 = undefined;
|
|
510923
511134
|
let streamRequestId = undefined;
|
|
510924
511135
|
let clientRequestId = undefined;
|
|
511136
|
+
const logicalRequestId = randomUUID27();
|
|
510925
511137
|
let streamResponse = undefined;
|
|
510926
511138
|
function releaseStreamResources() {
|
|
510927
511139
|
cleanupStream(stream4);
|
|
@@ -511109,10 +511321,30 @@ ${deferredToolList}
|
|
|
511109
511321
|
headlessProfilerCheckpoint("api_request_sent");
|
|
511110
511322
|
}
|
|
511111
511323
|
clientRequestId = getAPIProvider() === "anthropic" && !isOpenAICompatibleActive() && isFirstPartyAnthropicBaseUrl() ? randomUUID27() : undefined;
|
|
511324
|
+
const rayuMetaHeaders = {
|
|
511325
|
+
[RAYU_LOGICAL_REQUEST_ID_HEADER]: logicalRequestId
|
|
511326
|
+
};
|
|
511327
|
+
{
|
|
511328
|
+
let intendedCanonical = "";
|
|
511329
|
+
try {
|
|
511330
|
+
intendedCanonical = getCanonicalName(options.model);
|
|
511331
|
+
} catch {
|
|
511332
|
+
intendedCanonical = "";
|
|
511333
|
+
}
|
|
511334
|
+
if (intendedCanonical) {
|
|
511335
|
+
rayuMetaHeaders[RAYU_INTENDED_MODEL_HEADER] = intendedCanonical;
|
|
511336
|
+
}
|
|
511337
|
+
if (options.querySource) {
|
|
511338
|
+
rayuMetaHeaders[RAYU_QUERY_SOURCE_HEADER] = options.querySource;
|
|
511339
|
+
}
|
|
511340
|
+
}
|
|
511112
511341
|
const result = await anthropic.beta.messages.create({ ...params, stream: true }, {
|
|
511113
511342
|
signal,
|
|
511114
|
-
|
|
511115
|
-
|
|
511343
|
+
headers: {
|
|
511344
|
+
...rayuMetaHeaders,
|
|
511345
|
+
...clientRequestId && {
|
|
511346
|
+
[CLIENT_REQUEST_ID_HEADER]: clientRequestId
|
|
511347
|
+
}
|
|
511116
511348
|
}
|
|
511117
511349
|
}).withResponse();
|
|
511118
511350
|
queryCheckpoint("query_response_headers_received");
|
|
@@ -512025,6 +512257,7 @@ var init_claude = __esm(() => {
|
|
|
512025
512257
|
init_manager();
|
|
512026
512258
|
init_vcr();
|
|
512027
512259
|
init_client4();
|
|
512260
|
+
init_gatewayHeaders();
|
|
512028
512261
|
init_errors7();
|
|
512029
512262
|
init_logging();
|
|
512030
512263
|
init_promptCacheBreakDetection();
|
|
@@ -521603,9 +521836,9 @@ async function assertMinVersion() {
|
|
|
521603
521836
|
if (false) {}
|
|
521604
521837
|
try {
|
|
521605
521838
|
const versionConfig = await getDynamicConfig_BLOCKS_ON_INIT("tengu_version_config", { minVersion: "0.0.0" });
|
|
521606
|
-
if (versionConfig.minVersion && lt("1.4.
|
|
521839
|
+
if (versionConfig.minVersion && lt("1.4.477", versionConfig.minVersion)) {
|
|
521607
521840
|
console.error(`
|
|
521608
|
-
It looks like your version of RAYU (${"1.4.
|
|
521841
|
+
It looks like your version of RAYU (${"1.4.477"}) needs an update.
|
|
521609
521842
|
A newer version (${versionConfig.minVersion} or higher) is required to continue.
|
|
521610
521843
|
|
|
521611
521844
|
To update, please run:
|
|
@@ -521831,7 +522064,7 @@ async function installGlobalPackage(specificVersion) {
|
|
|
521831
522064
|
logError2(new AutoUpdaterError("Another process is currently installing an update"));
|
|
521832
522065
|
logEvent("tengu_auto_updater_lock_contention", {
|
|
521833
522066
|
pid: process.pid,
|
|
521834
|
-
currentVersion: "1.4.
|
|
522067
|
+
currentVersion: "1.4.477"
|
|
521835
522068
|
});
|
|
521836
522069
|
return "in_progress";
|
|
521837
522070
|
}
|
|
@@ -521840,7 +522073,7 @@ async function installGlobalPackage(specificVersion) {
|
|
|
521840
522073
|
if (!env3.isRunningWithBun() && env3.isNpmFromWindowsPath()) {
|
|
521841
522074
|
logError2(new Error("Windows NPM detected in WSL environment"));
|
|
521842
522075
|
logEvent("tengu_auto_updater_windows_npm_in_wsl", {
|
|
521843
|
-
currentVersion: "1.4.
|
|
522076
|
+
currentVersion: "1.4.477"
|
|
521844
522077
|
});
|
|
521845
522078
|
console.error(`
|
|
521846
522079
|
Error: Windows NPM detected in WSL
|
|
@@ -522368,7 +522601,7 @@ function detectLinuxGlobPatternWarnings() {
|
|
|
522368
522601
|
}
|
|
522369
522602
|
async function getDoctorDiagnostic() {
|
|
522370
522603
|
const installationType = await getCurrentInstallationType();
|
|
522371
|
-
const version2 = typeof MACRO !== "undefined" ? "1.4.
|
|
522604
|
+
const version2 = typeof MACRO !== "undefined" ? "1.4.477" : "unknown";
|
|
522372
522605
|
const installationPath = await getInstallationPath();
|
|
522373
522606
|
const invokedBinary = getInvokedBinary();
|
|
522374
522607
|
const multipleInstallations = await detectMultipleInstallations();
|
|
@@ -523159,8 +523392,8 @@ async function updateLatest(channelOrVersion, forceReinstall = false) {
|
|
|
523159
523392
|
const maxVersion = await getMaxVersion();
|
|
523160
523393
|
if (maxVersion && gt(version2, maxVersion)) {
|
|
523161
523394
|
logForDebugging(`Native installer: maxVersion ${maxVersion} is set, capping update from ${version2} to ${maxVersion}`);
|
|
523162
|
-
if (gte("1.4.
|
|
523163
|
-
logForDebugging(`Native installer: current version ${"1.4.
|
|
523395
|
+
if (gte("1.4.477", maxVersion)) {
|
|
523396
|
+
logForDebugging(`Native installer: current version ${"1.4.477"} is already at or above maxVersion ${maxVersion}, skipping update`);
|
|
523164
523397
|
logEvent("tengu_native_update_skipped_max_version", {
|
|
523165
523398
|
latency_ms: Date.now() - startTime2,
|
|
523166
523399
|
max_version: maxVersion,
|
|
@@ -523171,7 +523404,7 @@ async function updateLatest(channelOrVersion, forceReinstall = false) {
|
|
|
523171
523404
|
version2 = maxVersion;
|
|
523172
523405
|
}
|
|
523173
523406
|
}
|
|
523174
|
-
if (!forceReinstall && version2 === "1.4.
|
|
523407
|
+
if (!forceReinstall && version2 === "1.4.477" && await versionIsAvailable(version2) && await isPossibleClaudeBinary(executablePath)) {
|
|
523175
523408
|
logForDebugging(`Found ${version2} at ${executablePath}, skipping install`);
|
|
523176
523409
|
logEvent("tengu_native_update_complete", {
|
|
523177
523410
|
latency_ms: Date.now() - startTime2,
|
|
@@ -524379,7 +524612,7 @@ function buildPrimarySection() {
|
|
|
524379
524612
|
});
|
|
524380
524613
|
return [{
|
|
524381
524614
|
label: "Version",
|
|
524382
|
-
value: "1.4.
|
|
524615
|
+
value: "1.4.477"
|
|
524383
524616
|
}, {
|
|
524384
524617
|
label: "Session name",
|
|
524385
524618
|
value: nameValue
|
|
@@ -528050,7 +528283,7 @@ function Config({
|
|
|
528050
528283
|
}
|
|
528051
528284
|
})
|
|
528052
528285
|
}) : showSubmenu === "ChannelDowngrade" ? /* @__PURE__ */ jsx_runtime168.jsx(ChannelDowngradeDialog, {
|
|
528053
|
-
currentVersion: "1.4.
|
|
528286
|
+
currentVersion: "1.4.477",
|
|
528054
528287
|
onChoice: (choice) => {
|
|
528055
528288
|
setShowSubmenu(null);
|
|
528056
528289
|
setTabsHidden(false);
|
|
@@ -528062,7 +528295,7 @@ function Config({
|
|
|
528062
528295
|
autoUpdatesChannel: "stable"
|
|
528063
528296
|
};
|
|
528064
528297
|
if (choice === "stay") {
|
|
528065
|
-
newSettings.minimumVersion = "1.4.
|
|
528298
|
+
newSettings.minimumVersion = "1.4.477";
|
|
528066
528299
|
}
|
|
528067
528300
|
updateSettingsForSource("userSettings", newSettings);
|
|
528068
528301
|
setSettingsData((prev_27) => ({
|
|
@@ -536123,7 +536356,7 @@ function HelpV2(t0) {
|
|
|
536123
536356
|
let t6;
|
|
536124
536357
|
if ($3[31] !== tabs) {
|
|
536125
536358
|
t6 = /* @__PURE__ */ jsx_runtime195.jsx(Tabs, {
|
|
536126
|
-
title: `Rayu-CLI v${"1.4.
|
|
536359
|
+
title: `Rayu-CLI v${"1.4.477"}`,
|
|
536127
536360
|
color: "professionalBlue",
|
|
536128
536361
|
defaultTab: "general",
|
|
536129
536362
|
children: tabs
|
|
@@ -554231,6 +554464,23 @@ import { join as join137 } from "path";
|
|
|
554231
554464
|
function configPath2() {
|
|
554232
554465
|
return join137(getRayuConfigHomeDir(), "telegram.json");
|
|
554233
554466
|
}
|
|
554467
|
+
function getTelegramMode() {
|
|
554468
|
+
const cfg = readTelegramConfig();
|
|
554469
|
+
if (cfg.mode === "hosted" || cfg.mode === "byo")
|
|
554470
|
+
return cfg.mode;
|
|
554471
|
+
return cfg.botToken && cfg.botToken.trim().length > 0 ? "byo" : "hosted";
|
|
554472
|
+
}
|
|
554473
|
+
function setTelegramMode(mode) {
|
|
554474
|
+
const cfg = readTelegramConfig();
|
|
554475
|
+
cfg.mode = mode;
|
|
554476
|
+
writeTelegramConfig(cfg);
|
|
554477
|
+
}
|
|
554478
|
+
function setLinkedChat(chatId, username) {
|
|
554479
|
+
const cfg = readTelegramConfig();
|
|
554480
|
+
cfg.linkedChatId = chatId;
|
|
554481
|
+
cfg.linkedUsername = username;
|
|
554482
|
+
writeTelegramConfig(cfg);
|
|
554483
|
+
}
|
|
554234
554484
|
function getBotToken() {
|
|
554235
554485
|
const cfg = readTelegramConfig();
|
|
554236
554486
|
if (cfg.botToken && cfg.botToken.trim().length > 0)
|
|
@@ -554243,6 +554493,14 @@ function saveBotToken(token) {
|
|
|
554243
554493
|
cfg.botToken = token.trim();
|
|
554244
554494
|
writeTelegramConfig(cfg);
|
|
554245
554495
|
}
|
|
554496
|
+
function clearBotToken() {
|
|
554497
|
+
const cfg = readTelegramConfig();
|
|
554498
|
+
delete cfg.botToken;
|
|
554499
|
+
delete cfg.pendingToken;
|
|
554500
|
+
delete cfg.linkedChatId;
|
|
554501
|
+
delete cfg.linkedUsername;
|
|
554502
|
+
writeTelegramConfig(cfg);
|
|
554503
|
+
}
|
|
554246
554504
|
function readTelegramConfig() {
|
|
554247
554505
|
const path27 = configPath2();
|
|
554248
554506
|
if (!existsSync25(path27))
|
|
@@ -554294,6 +554552,9 @@ var init_telegramConfig = __esm(() => {
|
|
|
554294
554552
|
// src/telegram/telegramApi.ts
|
|
554295
554553
|
import { readFile as readFile45 } from "fs/promises";
|
|
554296
554554
|
import { existsSync as existsSync26, statSync as statSync13 } from "fs";
|
|
554555
|
+
function setHostedRouter(router) {
|
|
554556
|
+
hostedRouter = router;
|
|
554557
|
+
}
|
|
554297
554558
|
function escapeHtml(text2) {
|
|
554298
554559
|
return text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
554299
554560
|
}
|
|
@@ -554301,6 +554562,8 @@ function url3(token, method) {
|
|
|
554301
554562
|
return `${API_BASE2}/bot${token}/${method}`;
|
|
554302
554563
|
}
|
|
554303
554564
|
async function callApi(token, method, body) {
|
|
554565
|
+
if (hostedRouter)
|
|
554566
|
+
return hostedRouter.call(method, body);
|
|
554304
554567
|
const res = await fetch(url3(token, method), {
|
|
554305
554568
|
method: "POST",
|
|
554306
554569
|
headers: { "content-type": "application/json" },
|
|
@@ -554318,6 +554581,8 @@ async function callApi(token, method, body) {
|
|
|
554318
554581
|
return json2.result;
|
|
554319
554582
|
}
|
|
554320
554583
|
async function getBotUsername(token) {
|
|
554584
|
+
if (hostedRouter)
|
|
554585
|
+
return hostedRouter.botUsername();
|
|
554321
554586
|
try {
|
|
554322
554587
|
const result = await callApi(token, "getMe", {});
|
|
554323
554588
|
return result.username;
|
|
@@ -554326,6 +554591,13 @@ async function getBotUsername(token) {
|
|
|
554326
554591
|
}
|
|
554327
554592
|
}
|
|
554328
554593
|
async function getUpdates(token, offset, timeoutSec = 50) {
|
|
554594
|
+
if (hostedRouter) {
|
|
554595
|
+
try {
|
|
554596
|
+
return await hostedRouter.getUpdates(offset);
|
|
554597
|
+
} catch {
|
|
554598
|
+
return [];
|
|
554599
|
+
}
|
|
554600
|
+
}
|
|
554329
554601
|
try {
|
|
554330
554602
|
const result = await callApi(token, "getUpdates", { offset, timeout: timeoutSec });
|
|
554331
554603
|
return Array.isArray(result) ? result : [];
|
|
@@ -554377,6 +554649,10 @@ async function editMessageText(token, chatId, messageId, text2, parseMode) {
|
|
|
554377
554649
|
}
|
|
554378
554650
|
}
|
|
554379
554651
|
async function sendPhoto(token, chatId, base64Data, mediaType, caption) {
|
|
554652
|
+
if (hostedRouter) {
|
|
554653
|
+
await sendMessage3(token, chatId, caption ?? "\uD83D\uDDBC Image generated (view it in the CLI).");
|
|
554654
|
+
return;
|
|
554655
|
+
}
|
|
554380
554656
|
const ext = mediaType.includes("jpeg") || mediaType.includes("jpg") ? "jpg" : "png";
|
|
554381
554657
|
const buffer = Buffer.from(base64Data, "base64");
|
|
554382
554658
|
const blob2 = new Blob([buffer], { type: mediaType });
|
|
@@ -554392,6 +554668,10 @@ async function sendPhoto(token, chatId, base64Data, mediaType, caption) {
|
|
|
554392
554668
|
}
|
|
554393
554669
|
}
|
|
554394
554670
|
async function sendVideo(token, chatId, filePath, caption) {
|
|
554671
|
+
if (hostedRouter) {
|
|
554672
|
+
await sendMessage3(token, chatId, caption ?? "\uD83C\uDFAC Video generated (view it in the CLI).");
|
|
554673
|
+
return;
|
|
554674
|
+
}
|
|
554395
554675
|
if (!existsSync26(filePath)) {
|
|
554396
554676
|
await sendMessage3(token, chatId, `\uD83C\uDFAC Video generated but file not found: ${filePath}`);
|
|
554397
554677
|
return;
|
|
@@ -554470,6 +554750,8 @@ async function setMyCommands(token, commands) {
|
|
|
554470
554750
|
} catch {}
|
|
554471
554751
|
}
|
|
554472
554752
|
async function getFile(token, fileId) {
|
|
554753
|
+
if (hostedRouter)
|
|
554754
|
+
return;
|
|
554473
554755
|
try {
|
|
554474
554756
|
const result = await callApi(token, "getFile", { file_id: fileId });
|
|
554475
554757
|
return result.file_path;
|
|
@@ -554478,6 +554760,8 @@ async function getFile(token, fileId) {
|
|
|
554478
554760
|
}
|
|
554479
554761
|
}
|
|
554480
554762
|
async function downloadFileAsBase64(token, filePath) {
|
|
554763
|
+
if (hostedRouter)
|
|
554764
|
+
return;
|
|
554481
554765
|
try {
|
|
554482
554766
|
const fileUrl = `${API_BASE2}/file/bot${token}/${filePath}`;
|
|
554483
554767
|
const res = await fetch(fileUrl);
|
|
@@ -554503,31 +554787,321 @@ async function downloadFileAsBase64(token, filePath) {
|
|
|
554503
554787
|
return;
|
|
554504
554788
|
}
|
|
554505
554789
|
}
|
|
554506
|
-
var API_BASE2 = "https://api.telegram.org", MAX_MESSAGE_CHARS = 4096, MAX_FILE_BYTES;
|
|
554790
|
+
var API_BASE2 = "https://api.telegram.org", MAX_MESSAGE_CHARS = 4096, hostedRouter = null, MAX_FILE_BYTES;
|
|
554507
554791
|
var init_telegramApi = __esm(() => {
|
|
554508
554792
|
MAX_FILE_BYTES = 50 * 1024 * 1024;
|
|
554509
554793
|
});
|
|
554510
554794
|
|
|
554795
|
+
// src/telegram/telegramHostedApi.ts
|
|
554796
|
+
async function authedFetch(path27, init2) {
|
|
554797
|
+
const token = await getValidRayuAccessToken();
|
|
554798
|
+
if (!token)
|
|
554799
|
+
throw new Error("Not signed in to Rayu");
|
|
554800
|
+
return globalThis.fetch(`${getRayuApiBaseUrl()}${path27}`, {
|
|
554801
|
+
method: init2?.method ?? "GET",
|
|
554802
|
+
headers: {
|
|
554803
|
+
Authorization: `Bearer ${token}`,
|
|
554804
|
+
...init2?.body ? { "content-type": "application/json" } : {}
|
|
554805
|
+
},
|
|
554806
|
+
...init2?.body ? { body: init2.body } : {}
|
|
554807
|
+
});
|
|
554808
|
+
}
|
|
554809
|
+
async function getHostedBotInfo() {
|
|
554810
|
+
try {
|
|
554811
|
+
const res = await authedFetch("/telegram/bot");
|
|
554812
|
+
if (!res.ok)
|
|
554813
|
+
return { configured: false, username: null };
|
|
554814
|
+
return await res.json();
|
|
554815
|
+
} catch {
|
|
554816
|
+
return { configured: false, username: null };
|
|
554817
|
+
}
|
|
554818
|
+
}
|
|
554819
|
+
async function createHostedPairing() {
|
|
554820
|
+
try {
|
|
554821
|
+
const res = await authedFetch("/telegram/pair", { method: "POST" });
|
|
554822
|
+
if (!res.ok)
|
|
554823
|
+
return null;
|
|
554824
|
+
return await res.json();
|
|
554825
|
+
} catch {
|
|
554826
|
+
return null;
|
|
554827
|
+
}
|
|
554828
|
+
}
|
|
554829
|
+
async function getHostedLink() {
|
|
554830
|
+
try {
|
|
554831
|
+
const res = await authedFetch("/telegram/link");
|
|
554832
|
+
if (!res.ok)
|
|
554833
|
+
return { linked: false };
|
|
554834
|
+
return await res.json();
|
|
554835
|
+
} catch {
|
|
554836
|
+
return { linked: false };
|
|
554837
|
+
}
|
|
554838
|
+
}
|
|
554839
|
+
async function deleteHostedLink() {
|
|
554840
|
+
try {
|
|
554841
|
+
await authedFetch("/telegram/link", { method: "DELETE" });
|
|
554842
|
+
} catch {}
|
|
554843
|
+
}
|
|
554844
|
+
async function getHostedUpdates(after) {
|
|
554845
|
+
try {
|
|
554846
|
+
const res = await authedFetch(`/telegram/updates?after=${after}`);
|
|
554847
|
+
if (!res.ok)
|
|
554848
|
+
return { linked: false, updates: [] };
|
|
554849
|
+
return await res.json();
|
|
554850
|
+
} catch {
|
|
554851
|
+
return { linked: false, updates: [] };
|
|
554852
|
+
}
|
|
554853
|
+
}
|
|
554854
|
+
async function relayHostedSend(method, params) {
|
|
554855
|
+
const res = await authedFetch("/telegram/send", {
|
|
554856
|
+
method: "POST",
|
|
554857
|
+
body: JSON.stringify({ method, params })
|
|
554858
|
+
});
|
|
554859
|
+
if (!res.ok)
|
|
554860
|
+
throw new Error(`hosted relay ${method} failed: ${res.status}`);
|
|
554861
|
+
const json2 = await res.json();
|
|
554862
|
+
return json2.result;
|
|
554863
|
+
}
|
|
554864
|
+
var init_telegramHostedApi = __esm(() => {
|
|
554865
|
+
init_rayuSession();
|
|
554866
|
+
});
|
|
554867
|
+
|
|
554511
554868
|
// src/commands/telegram-bot/telegram-bot.tsx
|
|
554512
554869
|
var exports_telegram_bot = {};
|
|
554513
554870
|
__export(exports_telegram_bot, {
|
|
554514
554871
|
call: () => call20
|
|
554515
554872
|
});
|
|
554516
554873
|
import { randomUUID as randomUUID29 } from "crypto";
|
|
554517
|
-
function
|
|
554518
|
-
|
|
554874
|
+
function useKeyPress(target, handler) {
|
|
554875
|
+
import_react132.useEffect(() => {
|
|
554876
|
+
const onData = (data) => {
|
|
554877
|
+
const ch2 = data.toString().trim().toLowerCase();
|
|
554878
|
+
if (ch2 === target)
|
|
554879
|
+
handler();
|
|
554880
|
+
};
|
|
554881
|
+
process.stdin.on("data", onData);
|
|
554882
|
+
return () => {
|
|
554883
|
+
process.stdin.off("data", onData);
|
|
554884
|
+
};
|
|
554885
|
+
}, [target, handler]);
|
|
554886
|
+
}
|
|
554887
|
+
function HostedStep({
|
|
554888
|
+
onDone,
|
|
554889
|
+
onUseByo
|
|
554890
|
+
}) {
|
|
554891
|
+
const [status, setStatus] = import_react132.useState("loading");
|
|
554892
|
+
const [pairing, setPairing] = import_react132.useState(null);
|
|
554893
|
+
const [qr, setQr] = import_react132.useState("");
|
|
554894
|
+
const setAppState = useSetAppState();
|
|
554895
|
+
useKeyPress("b", onUseByo);
|
|
554896
|
+
import_react132.useEffect(() => {
|
|
554897
|
+
let cancelled = false;
|
|
554898
|
+
(async () => {
|
|
554899
|
+
if (!hasRayuSession()) {
|
|
554900
|
+
if (!cancelled)
|
|
554901
|
+
setStatus("nosession");
|
|
554902
|
+
return;
|
|
554903
|
+
}
|
|
554904
|
+
const info = await getHostedBotInfo();
|
|
554905
|
+
if (cancelled)
|
|
554906
|
+
return;
|
|
554907
|
+
if (!info.configured) {
|
|
554908
|
+
setStatus("unconfigured");
|
|
554909
|
+
return;
|
|
554910
|
+
}
|
|
554911
|
+
const p = await createHostedPairing();
|
|
554912
|
+
if (cancelled)
|
|
554913
|
+
return;
|
|
554914
|
+
if (!p) {
|
|
554915
|
+
setStatus("error");
|
|
554916
|
+
return;
|
|
554917
|
+
}
|
|
554918
|
+
setTelegramMode("hosted");
|
|
554919
|
+
setPairing(p);
|
|
554920
|
+
setStatus("ready");
|
|
554921
|
+
if (p.deepLink) {
|
|
554922
|
+
try {
|
|
554923
|
+
setQr(await $toString(p.deepLink, { type: "utf8", errorCorrectionLevel: "L" }));
|
|
554924
|
+
} catch {}
|
|
554925
|
+
}
|
|
554926
|
+
})();
|
|
554927
|
+
return () => {
|
|
554928
|
+
cancelled = true;
|
|
554929
|
+
};
|
|
554930
|
+
}, []);
|
|
554931
|
+
import_react132.useEffect(() => {
|
|
554932
|
+
if (status !== "ready")
|
|
554933
|
+
return;
|
|
554934
|
+
const timer = setInterval(() => {
|
|
554935
|
+
getHostedLink().then((link5) => {
|
|
554936
|
+
if (!link5.linked)
|
|
554937
|
+
return;
|
|
554938
|
+
clearInterval(timer);
|
|
554939
|
+
if (link5.chatId)
|
|
554940
|
+
setLinkedChat(Number(link5.chatId), link5.username ?? undefined);
|
|
554941
|
+
setAppState((prev) => ({ ...prev, telegramBridgeActive: true }));
|
|
554942
|
+
onDone();
|
|
554943
|
+
});
|
|
554944
|
+
}, 1500);
|
|
554945
|
+
return () => clearInterval(timer);
|
|
554946
|
+
}, [status, onDone, setAppState]);
|
|
554947
|
+
if (status === "loading") {
|
|
554948
|
+
return /* @__PURE__ */ jsx_runtime222.jsx(Pane, {
|
|
554949
|
+
children: /* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554950
|
+
dimColor: true,
|
|
554951
|
+
children: "Connecting to the Rayu Telegram bot…"
|
|
554952
|
+
})
|
|
554953
|
+
});
|
|
554954
|
+
}
|
|
554955
|
+
if (status === "nosession") {
|
|
554956
|
+
return /* @__PURE__ */ jsx_runtime222.jsx(Pane, {
|
|
554957
|
+
children: /* @__PURE__ */ jsx_runtime222.jsxs(ThemedBox_default, {
|
|
554958
|
+
flexDirection: "column",
|
|
554959
|
+
children: [
|
|
554960
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554961
|
+
bold: true,
|
|
554962
|
+
children: "\uD83D\uDCF1 Connect Telegram"
|
|
554963
|
+
}),
|
|
554964
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554965
|
+
children: " "
|
|
554966
|
+
}),
|
|
554967
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554968
|
+
color: "yellow",
|
|
554969
|
+
children: "Sign in first: run /login to use the shared Rayu bot."
|
|
554970
|
+
}),
|
|
554971
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554972
|
+
children: " "
|
|
554973
|
+
}),
|
|
554974
|
+
/* @__PURE__ */ jsx_runtime222.jsxs(ThemedText, {
|
|
554975
|
+
dimColor: true,
|
|
554976
|
+
children: [
|
|
554977
|
+
"Or press ",
|
|
554978
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554979
|
+
bold: true,
|
|
554980
|
+
children: "b"
|
|
554981
|
+
}),
|
|
554982
|
+
" to connect your own bot token instead."
|
|
554983
|
+
]
|
|
554984
|
+
})
|
|
554985
|
+
]
|
|
554986
|
+
})
|
|
554987
|
+
});
|
|
554988
|
+
}
|
|
554989
|
+
if (status === "unconfigured" || status === "error") {
|
|
554990
|
+
return /* @__PURE__ */ jsx_runtime222.jsx(Pane, {
|
|
554991
|
+
children: /* @__PURE__ */ jsx_runtime222.jsxs(ThemedBox_default, {
|
|
554992
|
+
flexDirection: "column",
|
|
554993
|
+
children: [
|
|
554994
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554995
|
+
bold: true,
|
|
554996
|
+
children: "\uD83D\uDCF1 Connect Telegram"
|
|
554997
|
+
}),
|
|
554998
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554999
|
+
children: " "
|
|
555000
|
+
}),
|
|
555001
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555002
|
+
color: "yellow",
|
|
555003
|
+
children: status === "unconfigured" ? "The shared Rayu Telegram bot isn't available right now." : "Couldn't reach the Rayu Telegram service."
|
|
555004
|
+
}),
|
|
555005
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555006
|
+
children: " "
|
|
555007
|
+
}),
|
|
555008
|
+
/* @__PURE__ */ jsx_runtime222.jsxs(ThemedText, {
|
|
555009
|
+
children: [
|
|
555010
|
+
"Press ",
|
|
555011
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555012
|
+
bold: true,
|
|
555013
|
+
children: "b"
|
|
555014
|
+
}),
|
|
555015
|
+
" to connect your own bot token instead."
|
|
555016
|
+
]
|
|
555017
|
+
})
|
|
555018
|
+
]
|
|
555019
|
+
})
|
|
555020
|
+
});
|
|
555021
|
+
}
|
|
555022
|
+
const lines2 = qr.split(`
|
|
555023
|
+
`).filter((l3) => l3.length > 0);
|
|
555024
|
+
const bot = pairing?.botUsername;
|
|
555025
|
+
return /* @__PURE__ */ jsx_runtime222.jsx(Pane, {
|
|
555026
|
+
children: /* @__PURE__ */ jsx_runtime222.jsxs(ThemedBox_default, {
|
|
555027
|
+
flexDirection: "column",
|
|
555028
|
+
children: [
|
|
555029
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555030
|
+
bold: true,
|
|
555031
|
+
children: "\uD83D\uDCF1 Connect Telegram (Rayu bot — no setup needed)"
|
|
555032
|
+
}),
|
|
555033
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555034
|
+
children: " "
|
|
555035
|
+
}),
|
|
555036
|
+
lines2.map((line, i4) => /* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555037
|
+
children: line
|
|
555038
|
+
}, i4)),
|
|
555039
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555040
|
+
children: " "
|
|
555041
|
+
}),
|
|
555042
|
+
/* @__PURE__ */ jsx_runtime222.jsxs(ThemedText, {
|
|
555043
|
+
children: [
|
|
555044
|
+
"Scan the QR",
|
|
555045
|
+
bot ? ` to open @${bot}` : "",
|
|
555046
|
+
", or open the bot and send:"
|
|
555047
|
+
]
|
|
555048
|
+
}),
|
|
555049
|
+
/* @__PURE__ */ jsx_runtime222.jsxs(ThemedText, {
|
|
555050
|
+
bold: true,
|
|
555051
|
+
children: [
|
|
555052
|
+
" /start ",
|
|
555053
|
+
pairing?.code
|
|
555054
|
+
]
|
|
555055
|
+
}),
|
|
555056
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555057
|
+
children: " "
|
|
555058
|
+
}),
|
|
555059
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555060
|
+
dimColor: true,
|
|
555061
|
+
children: "Waiting for you to link… (code valid 10 min)"
|
|
555062
|
+
}),
|
|
555063
|
+
/* @__PURE__ */ jsx_runtime222.jsxs(ThemedText, {
|
|
555064
|
+
dimColor: true,
|
|
555065
|
+
children: [
|
|
555066
|
+
"Press ",
|
|
555067
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555068
|
+
bold: true,
|
|
555069
|
+
children: "b"
|
|
555070
|
+
}),
|
|
555071
|
+
" to use your own bot token instead."
|
|
555072
|
+
]
|
|
555073
|
+
})
|
|
555074
|
+
]
|
|
555075
|
+
})
|
|
555076
|
+
});
|
|
555077
|
+
}
|
|
555078
|
+
function TokenInputStep({ onReady }) {
|
|
555079
|
+
const [existing, setExisting] = import_react132.useState(() => getBotToken());
|
|
554519
555080
|
const [error54, setError] = import_react132.useState("");
|
|
554520
555081
|
const [waiting, setWaiting] = import_react132.useState(false);
|
|
554521
555082
|
import_react132.useEffect(() => {
|
|
554522
555083
|
const handler = (data) => {
|
|
554523
555084
|
const line = data.toString().trim();
|
|
555085
|
+
if (existing) {
|
|
555086
|
+
if (line === "") {
|
|
555087
|
+
setTelegramMode("byo");
|
|
555088
|
+
onReady();
|
|
555089
|
+
return;
|
|
555090
|
+
}
|
|
555091
|
+
if (line.toLowerCase() === "d") {
|
|
555092
|
+
clearBotToken();
|
|
555093
|
+
setExisting(undefined);
|
|
555094
|
+
setError("");
|
|
555095
|
+
return;
|
|
555096
|
+
}
|
|
555097
|
+
}
|
|
554524
555098
|
if (!line)
|
|
554525
555099
|
return;
|
|
554526
|
-
setInput(line);
|
|
554527
555100
|
if (/^\d+:[A-Za-z0-9_-]+$/.test(line)) {
|
|
554528
|
-
setWaiting(true);
|
|
554529
555101
|
saveBotToken(line);
|
|
554530
|
-
|
|
555102
|
+
setTelegramMode("byo");
|
|
555103
|
+
setWaiting(true);
|
|
555104
|
+
setTimeout(() => onReady(), 300);
|
|
554531
555105
|
} else {
|
|
554532
555106
|
setError("That doesn't look like a valid bot token. It should be like: 123456789:ABCDefGHI...");
|
|
554533
555107
|
}
|
|
@@ -554536,7 +555110,7 @@ function TokenInputStep({ onTokenSaved }) {
|
|
|
554536
555110
|
return () => {
|
|
554537
555111
|
process.stdin.off("data", handler);
|
|
554538
555112
|
};
|
|
554539
|
-
}, [
|
|
555113
|
+
}, [existing, onReady]);
|
|
554540
555114
|
if (waiting) {
|
|
554541
555115
|
return /* @__PURE__ */ jsx_runtime222.jsx(Pane, {
|
|
554542
555116
|
children: /* @__PURE__ */ jsx_runtime222.jsxs(ThemedBox_default, {
|
|
@@ -554554,19 +555128,65 @@ function TokenInputStep({ onTokenSaved }) {
|
|
|
554554
555128
|
})
|
|
554555
555129
|
});
|
|
554556
555130
|
}
|
|
555131
|
+
if (existing) {
|
|
555132
|
+
return /* @__PURE__ */ jsx_runtime222.jsx(Pane, {
|
|
555133
|
+
children: /* @__PURE__ */ jsx_runtime222.jsxs(ThemedBox_default, {
|
|
555134
|
+
flexDirection: "column",
|
|
555135
|
+
children: [
|
|
555136
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555137
|
+
bold: true,
|
|
555138
|
+
children: "\uD83D\uDCF1 Your Telegram bot token"
|
|
555139
|
+
}),
|
|
555140
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555141
|
+
children: " "
|
|
555142
|
+
}),
|
|
555143
|
+
/* @__PURE__ */ jsx_runtime222.jsxs(ThemedText, {
|
|
555144
|
+
children: [
|
|
555145
|
+
"A bot token is already saved (…",
|
|
555146
|
+
existing.slice(-6),
|
|
555147
|
+
")."
|
|
555148
|
+
]
|
|
555149
|
+
}),
|
|
555150
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555151
|
+
children: " "
|
|
555152
|
+
}),
|
|
555153
|
+
/* @__PURE__ */ jsx_runtime222.jsxs(ThemedText, {
|
|
555154
|
+
children: [
|
|
555155
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555156
|
+
bold: true,
|
|
555157
|
+
children: "Enter"
|
|
555158
|
+
}),
|
|
555159
|
+
" connect with it",
|
|
555160
|
+
" ",
|
|
555161
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555162
|
+
bold: true,
|
|
555163
|
+
children: "d"
|
|
555164
|
+
}),
|
|
555165
|
+
" remove it",
|
|
555166
|
+
" ",
|
|
555167
|
+
"or paste a ",
|
|
555168
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555169
|
+
bold: true,
|
|
555170
|
+
children: "new"
|
|
555171
|
+
}),
|
|
555172
|
+
" token to replace it."
|
|
555173
|
+
]
|
|
555174
|
+
}),
|
|
555175
|
+
error54 ? /* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555176
|
+
color: "red",
|
|
555177
|
+
children: error54
|
|
555178
|
+
}) : null
|
|
555179
|
+
]
|
|
555180
|
+
})
|
|
555181
|
+
});
|
|
555182
|
+
}
|
|
554557
555183
|
return /* @__PURE__ */ jsx_runtime222.jsx(Pane, {
|
|
554558
555184
|
children: /* @__PURE__ */ jsx_runtime222.jsxs(ThemedBox_default, {
|
|
554559
555185
|
flexDirection: "column",
|
|
554560
555186
|
children: [
|
|
554561
555187
|
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554562
555188
|
bold: true,
|
|
554563
|
-
children: "\uD83D\uDCF1 Connect Telegram
|
|
554564
|
-
}),
|
|
554565
|
-
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554566
|
-
children: " "
|
|
554567
|
-
}),
|
|
554568
|
-
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554569
|
-
children: "To connect rayu-cli to Telegram, you need a bot token:"
|
|
555189
|
+
children: "\uD83D\uDCF1 Connect your own Telegram bot"
|
|
554570
555190
|
}),
|
|
554571
555191
|
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
554572
555192
|
children: " "
|
|
@@ -554680,18 +555300,116 @@ function LinkStep({ onDone }) {
|
|
|
554680
555300
|
})
|
|
554681
555301
|
});
|
|
554682
555302
|
}
|
|
555303
|
+
function ChooseModeStep({
|
|
555304
|
+
onChoose
|
|
555305
|
+
}) {
|
|
555306
|
+
const [sel, setSel] = import_react132.useState(0);
|
|
555307
|
+
import_react132.useEffect(() => {
|
|
555308
|
+
const onData = (data) => {
|
|
555309
|
+
const s2 = data.toString();
|
|
555310
|
+
const t2 = s2.trim();
|
|
555311
|
+
if (t2 === "1")
|
|
555312
|
+
onChoose("hosted");
|
|
555313
|
+
else if (t2 === "2")
|
|
555314
|
+
onChoose("byo");
|
|
555315
|
+
else if (s2 === "\r" || s2 === `
|
|
555316
|
+
` || t2 === "")
|
|
555317
|
+
onChoose(sel === 0 ? "hosted" : "byo");
|
|
555318
|
+
else if (s2 === "\x1B[A" || s2 === "\x1B[B" || t2 === "j" || t2 === "k") {
|
|
555319
|
+
setSel((p) => p === 0 ? 1 : 0);
|
|
555320
|
+
}
|
|
555321
|
+
};
|
|
555322
|
+
process.stdin.on("data", onData);
|
|
555323
|
+
return () => {
|
|
555324
|
+
process.stdin.off("data", onData);
|
|
555325
|
+
};
|
|
555326
|
+
}, [onChoose, sel]);
|
|
555327
|
+
return /* @__PURE__ */ jsx_runtime222.jsx(Pane, {
|
|
555328
|
+
children: /* @__PURE__ */ jsx_runtime222.jsxs(ThemedBox_default, {
|
|
555329
|
+
flexDirection: "column",
|
|
555330
|
+
children: [
|
|
555331
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555332
|
+
bold: true,
|
|
555333
|
+
children: "\uD83D\uDCF1 Connect Telegram — choose how"
|
|
555334
|
+
}),
|
|
555335
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555336
|
+
children: " "
|
|
555337
|
+
}),
|
|
555338
|
+
/* @__PURE__ */ jsx_runtime222.jsxs(ThemedText, {
|
|
555339
|
+
color: sel === 0 ? "cyan" : undefined,
|
|
555340
|
+
children: [
|
|
555341
|
+
sel === 0 ? "▶ " : " ",
|
|
555342
|
+
"1. Rayu shared bot",
|
|
555343
|
+
" ",
|
|
555344
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555345
|
+
dimColor: true,
|
|
555346
|
+
children: "(recommended — no setup, hosted by Rayu)"
|
|
555347
|
+
})
|
|
555348
|
+
]
|
|
555349
|
+
}),
|
|
555350
|
+
/* @__PURE__ */ jsx_runtime222.jsxs(ThemedText, {
|
|
555351
|
+
color: sel === 1 ? "cyan" : undefined,
|
|
555352
|
+
children: [
|
|
555353
|
+
sel === 1 ? "▶ " : " ",
|
|
555354
|
+
"2. Your own bot token",
|
|
555355
|
+
" ",
|
|
555356
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555357
|
+
dimColor: true,
|
|
555358
|
+
children: "(private — direct to Telegram, no server)"
|
|
555359
|
+
})
|
|
555360
|
+
]
|
|
555361
|
+
}),
|
|
555362
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555363
|
+
children: " "
|
|
555364
|
+
}),
|
|
555365
|
+
/* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555366
|
+
dimColor: true,
|
|
555367
|
+
children: "Press 1 or 2 (or ↑/↓ then Enter). Enter = shared bot."
|
|
555368
|
+
})
|
|
555369
|
+
]
|
|
555370
|
+
})
|
|
555371
|
+
});
|
|
555372
|
+
}
|
|
554683
555373
|
function TelegramBotConnect({ onDone }) {
|
|
554684
|
-
const
|
|
555374
|
+
const alreadyLinked = readTelegramConfig().linkedChatId !== undefined;
|
|
554685
555375
|
const setAppState = useSetAppState();
|
|
555376
|
+
const [screen, setScreen] = import_react132.useState("choose");
|
|
554686
555377
|
import_react132.useEffect(() => {
|
|
554687
|
-
if (
|
|
555378
|
+
if (alreadyLinked) {
|
|
554688
555379
|
setAppState((prev) => ({ ...prev, telegramBridgeActive: true }));
|
|
554689
555380
|
onDone();
|
|
554690
555381
|
}
|
|
554691
|
-
}, [
|
|
554692
|
-
if (
|
|
555382
|
+
}, [alreadyLinked, onDone, setAppState]);
|
|
555383
|
+
if (alreadyLinked) {
|
|
555384
|
+
return /* @__PURE__ */ jsx_runtime222.jsx(Pane, {
|
|
555385
|
+
children: /* @__PURE__ */ jsx_runtime222.jsx(ThemedText, {
|
|
555386
|
+
dimColor: true,
|
|
555387
|
+
children: "Reconnecting Telegram…"
|
|
555388
|
+
})
|
|
555389
|
+
});
|
|
555390
|
+
}
|
|
555391
|
+
if (screen === "choose") {
|
|
555392
|
+
return /* @__PURE__ */ jsx_runtime222.jsx(ChooseModeStep, {
|
|
555393
|
+
onChoose: (mode) => {
|
|
555394
|
+
if (mode === "hosted") {
|
|
555395
|
+
setTelegramMode("hosted");
|
|
555396
|
+
setScreen("hosted");
|
|
555397
|
+
} else {
|
|
555398
|
+
setTelegramMode("byo");
|
|
555399
|
+
setScreen("byo-token");
|
|
555400
|
+
}
|
|
555401
|
+
}
|
|
555402
|
+
});
|
|
555403
|
+
}
|
|
555404
|
+
if (screen === "hosted") {
|
|
555405
|
+
return /* @__PURE__ */ jsx_runtime222.jsx(HostedStep, {
|
|
555406
|
+
onDone,
|
|
555407
|
+
onUseByo: () => setScreen("byo-token")
|
|
555408
|
+
});
|
|
555409
|
+
}
|
|
555410
|
+
if (screen === "byo-token") {
|
|
554693
555411
|
return /* @__PURE__ */ jsx_runtime222.jsx(TokenInputStep, {
|
|
554694
|
-
|
|
555412
|
+
onReady: () => setScreen("byo-link")
|
|
554695
555413
|
});
|
|
554696
555414
|
}
|
|
554697
555415
|
return /* @__PURE__ */ jsx_runtime222.jsx(LinkStep, {
|
|
@@ -554710,6 +555428,8 @@ var init_telegram_bot = __esm(() => {
|
|
|
554710
555428
|
init_ink2();
|
|
554711
555429
|
init_telegramConfig();
|
|
554712
555430
|
init_telegramApi();
|
|
555431
|
+
init_telegramHostedApi();
|
|
555432
|
+
init_rayuSession();
|
|
554713
555433
|
init_AppState();
|
|
554714
555434
|
import_react132 = __toESM(require_react(), 1);
|
|
554715
555435
|
jsx_runtime222 = __toESM(require_jsx_runtime(), 1);
|
|
@@ -554740,9 +555460,16 @@ async function call21() {
|
|
|
554740
555460
|
return { type: "text", value: "Telegram bot is not currently linked." };
|
|
554741
555461
|
}
|
|
554742
555462
|
const username = config5.linkedUsername ? `@${config5.linkedUsername}` : "the linked chat";
|
|
554743
|
-
|
|
554744
|
-
|
|
554745
|
-
|
|
555463
|
+
if (getTelegramMode() === "hosted") {
|
|
555464
|
+
await relayHostedSend("sendMessage", {
|
|
555465
|
+
text: "\uD83D\uDD0C CLI disconnected. Run /telegram-bot to link again."
|
|
555466
|
+
}).catch(() => {});
|
|
555467
|
+
await deleteHostedLink();
|
|
555468
|
+
} else {
|
|
555469
|
+
const token = getBotToken();
|
|
555470
|
+
if (token) {
|
|
555471
|
+
sendMessage3(token, config5.linkedChatId, "\uD83D\uDD0C CLI disconnected. Run `/telegram-bot` to link again.").catch(() => {});
|
|
555472
|
+
}
|
|
554746
555473
|
}
|
|
554747
555474
|
unlink18();
|
|
554748
555475
|
return { type: "text", value: `Disconnected Telegram bot (was linked to ${username}).` };
|
|
@@ -554750,6 +555477,7 @@ async function call21() {
|
|
|
554750
555477
|
var init_disconnect = __esm(() => {
|
|
554751
555478
|
init_telegramConfig();
|
|
554752
555479
|
init_telegramApi();
|
|
555480
|
+
init_telegramHostedApi();
|
|
554753
555481
|
});
|
|
554754
555482
|
|
|
554755
555483
|
// src/commands/telegram-bot/disconnect-index.ts
|
|
@@ -556206,7 +556934,7 @@ function getRecentReleaseNotes(currentVersion, previousVersion, changelogContent
|
|
|
556206
556934
|
}
|
|
556207
556935
|
return [];
|
|
556208
556936
|
}
|
|
556209
|
-
async function checkForReleaseNotes(lastSeenVersion, currentVersion = "1.4.
|
|
556937
|
+
async function checkForReleaseNotes(lastSeenVersion, currentVersion = "1.4.477") {
|
|
556210
556938
|
if (false) {}
|
|
556211
556939
|
const cachedChangelog = await getStoredChangelog();
|
|
556212
556940
|
if (lastSeenVersion !== currentVersion || !cachedChangelog) {
|
|
@@ -556219,7 +556947,7 @@ async function checkForReleaseNotes(lastSeenVersion, currentVersion = "1.4.475")
|
|
|
556219
556947
|
releaseNotes
|
|
556220
556948
|
};
|
|
556221
556949
|
}
|
|
556222
|
-
function checkForReleaseNotesSync(lastSeenVersion, currentVersion = "1.4.
|
|
556950
|
+
function checkForReleaseNotesSync(lastSeenVersion, currentVersion = "1.4.477") {
|
|
556223
556951
|
if (false) {}
|
|
556224
556952
|
const releaseNotes = getRecentReleaseNotes(currentVersion, lastSeenVersion);
|
|
556225
556953
|
return {
|
|
@@ -556347,7 +557075,7 @@ function getRecentActivitySync() {
|
|
|
556347
557075
|
return cachedActivity;
|
|
556348
557076
|
}
|
|
556349
557077
|
function getLogoDisplayData() {
|
|
556350
|
-
const version2 = process.env.DEMO_VERSION ?? "1.4.
|
|
557078
|
+
const version2 = process.env.DEMO_VERSION ?? "1.4.477";
|
|
556351
557079
|
const serverUrl = getDirectConnectServerUrl();
|
|
556352
557080
|
const displayPath = process.env.DEMO_VERSION ? "/code/claude" : getDisplayPath(getCwd());
|
|
556353
557081
|
const cwd2 = serverUrl ? `${displayPath} in ${serverUrl.replace(/^https?:\/\//, "")}` : displayPath;
|
|
@@ -557512,7 +558240,7 @@ function LogoV2() {
|
|
|
557512
558240
|
if ($3[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
557513
558241
|
t2 = () => {
|
|
557514
558242
|
const currentConfig = getGlobalConfig();
|
|
557515
|
-
if (currentConfig.lastReleaseNotesSeen === "1.4.
|
|
558243
|
+
if (currentConfig.lastReleaseNotesSeen === "1.4.477") {
|
|
557516
558244
|
return;
|
|
557517
558245
|
}
|
|
557518
558246
|
saveGlobalConfig(_temp327);
|
|
@@ -557991,7 +558719,7 @@ function LogoV2() {
|
|
|
557991
558719
|
t24 = $3[61];
|
|
557992
558720
|
}
|
|
557993
558721
|
const _latestNpm = getCachedLatestNpmVersionSync();
|
|
557994
|
-
const _updateFeeds = _latestNpm && gt(_latestNpm, "1.4.
|
|
558722
|
+
const _updateFeeds = _latestNpm && gt(_latestNpm, "1.4.477") ? [createUpdateAvailableFeed("1.4.477", _latestNpm)] : [];
|
|
557995
558723
|
const t25 = layoutMode === "horizontal" && /* @__PURE__ */ jsx_runtime236.jsx(FeedColumn, {
|
|
557996
558724
|
feeds: showOnboarding ? [createProjectOnboardingFeed(getSteps()), createRecentActivityFeed(activities)] : showGuestPassesUpsell ? [createRecentActivityFeed(activities), createGuestPassesFeed()] : showOverageCreditUpsell ? [createRecentActivityFeed(activities), createOverageCreditFeed()] : [createRecentActivityFeed(activities), ..._updateFeeds, createWhatsNewFeed(changelog)],
|
|
557997
558725
|
maxWidth: rightWidth
|
|
@@ -558191,12 +558919,12 @@ function LogoV2() {
|
|
|
558191
558919
|
return t41;
|
|
558192
558920
|
}
|
|
558193
558921
|
function _temp327(current) {
|
|
558194
|
-
if (current.lastReleaseNotesSeen === "1.4.
|
|
558922
|
+
if (current.lastReleaseNotesSeen === "1.4.477") {
|
|
558195
558923
|
return current;
|
|
558196
558924
|
}
|
|
558197
558925
|
return {
|
|
558198
558926
|
...current,
|
|
558199
|
-
lastReleaseNotesSeen: "1.4.
|
|
558927
|
+
lastReleaseNotesSeen: "1.4.477"
|
|
558200
558928
|
};
|
|
558201
558929
|
}
|
|
558202
558930
|
function _temp241(s_0) {
|
|
@@ -583195,7 +583923,7 @@ async function captureMemoryDiagnostics(trigger, dumpNumber = 0) {
|
|
|
583195
583923
|
smapsRollup,
|
|
583196
583924
|
platform: process.platform,
|
|
583197
583925
|
nodeVersion: process.version,
|
|
583198
|
-
ccVersion: "1.4.
|
|
583926
|
+
ccVersion: "1.4.477"
|
|
583199
583927
|
};
|
|
583200
583928
|
}
|
|
583201
583929
|
async function performHeapDump(trigger = "manual", dumpNumber = 0) {
|
|
@@ -583717,7 +584445,7 @@ var init_bridge_kick = __esm(() => {
|
|
|
583717
584445
|
var call50 = async () => {
|
|
583718
584446
|
return {
|
|
583719
584447
|
type: "text",
|
|
583720
|
-
value: "1.4.
|
|
584448
|
+
value: "1.4.477"
|
|
583721
584449
|
};
|
|
583722
584450
|
}, version2, version_default;
|
|
583723
584451
|
var init_version = __esm(() => {
|
|
@@ -594213,7 +594941,7 @@ function generateHtmlReport(data, insights) {
|
|
|
594213
594941
|
</html>`;
|
|
594214
594942
|
}
|
|
594215
594943
|
function buildExportData(data, insights, facets, remoteStats) {
|
|
594216
|
-
const version3 = typeof MACRO !== "undefined" ? "1.4.
|
|
594944
|
+
const version3 = typeof MACRO !== "undefined" ? "1.4.477" : "unknown";
|
|
594217
594945
|
const remote_hosts_collected = remoteStats?.hosts.filter((h3) => h3.sessionCount > 0).map((h3) => h3.name);
|
|
594218
594946
|
const facets_summary = {
|
|
594219
594947
|
total: facets.size,
|
|
@@ -598127,7 +598855,7 @@ var init_sessionStorage = __esm(() => {
|
|
|
598127
598855
|
init_settings2();
|
|
598128
598856
|
init_slowOperations();
|
|
598129
598857
|
init_uuid();
|
|
598130
|
-
VERSION6 = typeof MACRO !== "undefined" ? "1.4.
|
|
598858
|
+
VERSION6 = typeof MACRO !== "undefined" ? "1.4.477" : "unknown";
|
|
598131
598859
|
MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
|
|
598132
598860
|
SKIP_FIRST_PROMPT_PATTERN = /^(?:\s*<[a-z][\w-]*[\s>]|\[Request interrupted by user[^\]]*\])/;
|
|
598133
598861
|
EPHEMERAL_PROGRESS_TYPES = new Set([
|
|
@@ -599345,7 +600073,7 @@ var init_filesystem = __esm(() => {
|
|
|
599345
600073
|
});
|
|
599346
600074
|
getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
|
|
599347
600075
|
const nonce = randomBytes19(16).toString("hex");
|
|
599348
|
-
return join153(getClaudeTempDir(), "bundled-skills", "1.4.
|
|
600076
|
+
return join153(getClaudeTempDir(), "bundled-skills", "1.4.477", nonce);
|
|
599349
600077
|
});
|
|
599350
600078
|
getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
|
|
599351
600079
|
});
|
|
@@ -604515,7 +605243,7 @@ __export(exports_update, {
|
|
|
604515
605243
|
update: () => update
|
|
604516
605244
|
});
|
|
604517
605245
|
async function update() {
|
|
604518
|
-
writeToStdout(`Current version: ${"1.4.
|
|
605246
|
+
writeToStdout(`Current version: ${"1.4.477"}
|
|
604519
605247
|
`);
|
|
604520
605248
|
const isBundled = isInBundledMode();
|
|
604521
605249
|
if (isBundled) {
|
|
@@ -604546,13 +605274,13 @@ Manual check: npm view ${"@rayu-dev/rayu-cli"} version
|
|
|
604546
605274
|
process.exit(1);
|
|
604547
605275
|
return;
|
|
604548
605276
|
}
|
|
604549
|
-
if (latestVersion === "1.4.
|
|
605277
|
+
if (latestVersion === "1.4.477") {
|
|
604550
605278
|
writeToStdout(source_default.green(`
|
|
604551
|
-
Rayu CLI is up to date (${"1.4.
|
|
605279
|
+
Rayu CLI is up to date (${"1.4.477"})
|
|
604552
605280
|
`));
|
|
604553
605281
|
process.exit(0);
|
|
604554
605282
|
}
|
|
604555
|
-
writeToStdout(`New version available: ${latestVersion} (current: ${"1.4.
|
|
605283
|
+
writeToStdout(`New version available: ${latestVersion} (current: ${"1.4.477"})
|
|
604556
605284
|
`);
|
|
604557
605285
|
writeToStdout(`Installing update...
|
|
604558
605286
|
|
|
@@ -604619,14 +605347,14 @@ async function updateNativeBinary() {
|
|
|
604619
605347
|
} catch {
|
|
604620
605348
|
latestVersion = "";
|
|
604621
605349
|
}
|
|
604622
|
-
if (latestVersion && latestVersion === "1.4.
|
|
605350
|
+
if (latestVersion && latestVersion === "1.4.477") {
|
|
604623
605351
|
writeToStdout(source_default.green(`
|
|
604624
|
-
Rayu CLI is up to date (1.4.
|
|
605352
|
+
Rayu CLI is up to date (1.4.477)
|
|
604625
605353
|
`));
|
|
604626
605354
|
process.exit(0);
|
|
604627
605355
|
}
|
|
604628
605356
|
if (latestVersion) {
|
|
604629
|
-
writeToStdout(`New version available: ${latestVersion} (current: 1.4.
|
|
605357
|
+
writeToStdout(`New version available: ${latestVersion} (current: 1.4.477)
|
|
604630
605358
|
`);
|
|
604631
605359
|
}
|
|
604632
605360
|
writeToStdout(`Downloading and installing update...
|
|
@@ -604641,13 +605369,13 @@ Rayu CLI is up to date (1.4.475)
|
|
|
604641
605369
|
return;
|
|
604642
605370
|
}
|
|
604643
605371
|
writeToStdout(source_default.green(`
|
|
604644
|
-
Rayu CLI is up to date (1.4.
|
|
605372
|
+
Rayu CLI is up to date (1.4.477)
|
|
604645
605373
|
`));
|
|
604646
605374
|
process.exit(0);
|
|
604647
605375
|
}
|
|
604648
605376
|
const updatedTo = result.latestVersion ?? latestVersion ?? "latest";
|
|
604649
605377
|
writeToStdout(source_default.green(`
|
|
604650
|
-
Successfully updated from 1.4.
|
|
605378
|
+
Successfully updated from 1.4.477 to ${updatedTo}
|
|
604651
605379
|
`));
|
|
604652
605380
|
writeToStdout(`Restart your terminal to use the new version.
|
|
604653
605381
|
`);
|
|
@@ -604712,7 +605440,7 @@ async function removeDataDir(dir) {
|
|
|
604712
605440
|
async function uninstall(args = []) {
|
|
604713
605441
|
const yes = args.includes("--yes") || args.includes("-y");
|
|
604714
605442
|
const keepData = args.includes("--keep-data");
|
|
604715
|
-
writeToStdout(`Uninstalling Rayu CLI (${"1.4.
|
|
605443
|
+
writeToStdout(`Uninstalling Rayu CLI (${"1.4.477"})...
|
|
604716
605444
|
`);
|
|
604717
605445
|
writeToStdout(`Running: npm uninstall -g ${"@rayu-dev/rayu-cli"}
|
|
604718
605446
|
|
|
@@ -604746,7 +605474,7 @@ This looks like a permissions error on npm's global install
|
|
|
604746
605474
|
return;
|
|
604747
605475
|
}
|
|
604748
605476
|
writeToStdout(source_default.green(`
|
|
604749
|
-
Successfully uninstalled ${"@rayu-dev/rayu-cli"} ${"1.4.
|
|
605477
|
+
Successfully uninstalled ${"@rayu-dev/rayu-cli"} ${"1.4.477"}
|
|
604750
605478
|
`));
|
|
604751
605479
|
const configDir = getRayuConfigHomeDir();
|
|
604752
605480
|
const dataExists = existsSync28(configDir);
|
|
@@ -604829,7 +605557,7 @@ function showFirstRunWelcome() {
|
|
|
604829
605557
|
`);
|
|
604830
605558
|
try {
|
|
604831
605559
|
mkdirSync16(getRayuConfigHomeDir(), { recursive: true });
|
|
604832
|
-
writeFileSync18(markerPath(), "1.4.
|
|
605560
|
+
writeFileSync18(markerPath(), "1.4.477", "utf8");
|
|
604833
605561
|
} catch {}
|
|
604834
605562
|
}
|
|
604835
605563
|
var init_firstRun = __esm(() => {
|
|
@@ -621015,7 +621743,7 @@ async function initializeBetaTracing(resource) {
|
|
|
621015
621743
|
});
|
|
621016
621744
|
import_api_logs.logs.setGlobalLoggerProvider(loggerProvider);
|
|
621017
621745
|
setLoggerProvider(loggerProvider);
|
|
621018
|
-
const eventLogger = import_api_logs.logs.getLogger("com.anthropic.claude_code.events", "1.4.
|
|
621746
|
+
const eventLogger = import_api_logs.logs.getLogger("com.anthropic.claude_code.events", "1.4.477");
|
|
621019
621747
|
setEventLogger(eventLogger);
|
|
621020
621748
|
process.on("beforeExit", async () => {
|
|
621021
621749
|
await loggerProvider?.forceFlush();
|
|
@@ -621055,7 +621783,7 @@ async function initializeTelemetry() {
|
|
|
621055
621783
|
const platform4 = getPlatform();
|
|
621056
621784
|
const baseAttributes = {
|
|
621057
621785
|
[import_semantic_conventions.ATTR_SERVICE_NAME]: "claude-code",
|
|
621058
|
-
[import_semantic_conventions.ATTR_SERVICE_VERSION]: "1.4.
|
|
621786
|
+
[import_semantic_conventions.ATTR_SERVICE_VERSION]: "1.4.477"
|
|
621059
621787
|
};
|
|
621060
621788
|
if (platform4 === "wsl") {
|
|
621061
621789
|
const wslVersion = getWslVersion();
|
|
@@ -621100,7 +621828,7 @@ async function initializeTelemetry() {
|
|
|
621100
621828
|
} catch {}
|
|
621101
621829
|
};
|
|
621102
621830
|
registerCleanup(shutdownTelemetry2);
|
|
621103
|
-
return meterProvider2.getMeter("com.anthropic.claude_code", "1.4.
|
|
621831
|
+
return meterProvider2.getMeter("com.anthropic.claude_code", "1.4.477");
|
|
621104
621832
|
}
|
|
621105
621833
|
const meterProvider = new import_sdk_metrics2.MeterProvider({
|
|
621106
621834
|
resource,
|
|
@@ -621120,7 +621848,7 @@ async function initializeTelemetry() {
|
|
|
621120
621848
|
});
|
|
621121
621849
|
import_api_logs.logs.setGlobalLoggerProvider(loggerProvider);
|
|
621122
621850
|
setLoggerProvider(loggerProvider);
|
|
621123
|
-
const eventLogger = import_api_logs.logs.getLogger("com.anthropic.claude_code.events", "1.4.
|
|
621851
|
+
const eventLogger = import_api_logs.logs.getLogger("com.anthropic.claude_code.events", "1.4.477");
|
|
621124
621852
|
setEventLogger(eventLogger);
|
|
621125
621853
|
logForDebugging("[3P telemetry] Event logger set successfully");
|
|
621126
621854
|
process.on("beforeExit", async () => {
|
|
@@ -621182,7 +621910,7 @@ Current timeout: ${timeoutMs}ms
|
|
|
621182
621910
|
}
|
|
621183
621911
|
};
|
|
621184
621912
|
registerCleanup(shutdownTelemetry);
|
|
621185
|
-
return meterProvider.getMeter("com.anthropic.claude_code", "1.4.
|
|
621913
|
+
return meterProvider.getMeter("com.anthropic.claude_code", "1.4.477");
|
|
621186
621914
|
}
|
|
621187
621915
|
async function flushTelemetry() {
|
|
621188
621916
|
const meterProvider = getMeterProvider();
|
|
@@ -622684,7 +623412,7 @@ function buildSystemInitMessage(inputs) {
|
|
|
622684
623412
|
slash_commands: inputs.commands.filter((c4) => c4.userInvocable !== false).map((c4) => c4.name),
|
|
622685
623413
|
apiKeySource: getAnthropicApiKeyWithSource().source,
|
|
622686
623414
|
betas: getSdkBetas(),
|
|
622687
|
-
claude_code_version: "1.4.
|
|
623415
|
+
claude_code_version: "1.4.477",
|
|
622688
623416
|
output_style: outputStyle2,
|
|
622689
623417
|
agents: inputs.agents.map((agent) => agent.agentType),
|
|
622690
623418
|
skills: inputs.skills.filter((s2) => s2.userInvocable !== false).map((skill) => skill.name),
|
|
@@ -624097,6 +624825,37 @@ var init_telegramBridge = __esm(() => {
|
|
|
624097
624825
|
]);
|
|
624098
624826
|
});
|
|
624099
624827
|
|
|
624828
|
+
// src/telegram/telegramTransport.ts
|
|
624829
|
+
function createHostedRouter() {
|
|
624830
|
+
let after = 0;
|
|
624831
|
+
return {
|
|
624832
|
+
async getUpdates() {
|
|
624833
|
+
const batch = await getHostedUpdates(after);
|
|
624834
|
+
for (const row of batch.updates) {
|
|
624835
|
+
if (row.id > after)
|
|
624836
|
+
after = row.id;
|
|
624837
|
+
}
|
|
624838
|
+
return batch.updates.map((row) => row.update);
|
|
624839
|
+
},
|
|
624840
|
+
async call(method, params) {
|
|
624841
|
+
if (method === "getMe") {
|
|
624842
|
+
const info = await getHostedBotInfo();
|
|
624843
|
+
return { username: info.username ?? undefined };
|
|
624844
|
+
}
|
|
624845
|
+
if (method === "setMyCommands")
|
|
624846
|
+
return {};
|
|
624847
|
+
return relayHostedSend(method, params);
|
|
624848
|
+
},
|
|
624849
|
+
async botUsername() {
|
|
624850
|
+
const info = await getHostedBotInfo();
|
|
624851
|
+
return info.username ?? undefined;
|
|
624852
|
+
}
|
|
624853
|
+
};
|
|
624854
|
+
}
|
|
624855
|
+
var init_telegramTransport = __esm(() => {
|
|
624856
|
+
init_telegramHostedApi();
|
|
624857
|
+
});
|
|
624858
|
+
|
|
624100
624859
|
// src/hooks/useTelegramBridge.tsx
|
|
624101
624860
|
function isToolResultMessage2(msg) {
|
|
624102
624861
|
if (msg.type !== "user")
|
|
@@ -624115,19 +624874,29 @@ function useTelegramBridge(messages) {
|
|
|
624115
624874
|
import_react187.useEffect(() => {
|
|
624116
624875
|
if (!bridgeActive)
|
|
624117
624876
|
return;
|
|
624118
|
-
const
|
|
624119
|
-
|
|
624120
|
-
|
|
624877
|
+
const mode = getTelegramMode();
|
|
624878
|
+
let token;
|
|
624879
|
+
if (mode === "hosted") {
|
|
624880
|
+
if (!hasRayuSession())
|
|
624881
|
+
return;
|
|
624882
|
+
setHostedRouter(createHostedRouter());
|
|
624883
|
+
token = "hosted";
|
|
624884
|
+
} else {
|
|
624885
|
+
const byo = getBotToken();
|
|
624886
|
+
if (!byo)
|
|
624887
|
+
return;
|
|
624888
|
+
setHostedRouter(null);
|
|
624889
|
+
token = byo;
|
|
624890
|
+
}
|
|
624121
624891
|
const handle = initTelegramBridge({ token });
|
|
624122
624892
|
handleRef.current = handle;
|
|
624123
624893
|
setAppState((prev) => ({ ...prev, telegramPermissionCallbacks: handle.permissionCallbacks }));
|
|
624124
624894
|
return () => {
|
|
624125
624895
|
handle.endTurn();
|
|
624126
624896
|
const chatId = readTelegramConfig().linkedChatId;
|
|
624127
|
-
|
|
624128
|
-
sendMessage3(token, chatId, "\uD83D\uDD0C Session closed — rayu-cli disconnected.").catch(() => {});
|
|
624129
|
-
}
|
|
624897
|
+
const notice = chatId !== undefined ? sendMessage3(token, chatId, "\uD83D\uDD0C Session closed — rayu-cli disconnected.").catch(() => {}) : Promise.resolve();
|
|
624130
624898
|
handle.stop();
|
|
624899
|
+
notice.finally(() => setHostedRouter(null));
|
|
624131
624900
|
handleRef.current = null;
|
|
624132
624901
|
lastSentIndexRef.current = 0;
|
|
624133
624902
|
inTurnRef.current = false;
|
|
@@ -624185,6 +624954,8 @@ var init_useTelegramBridge = __esm(() => {
|
|
|
624185
624954
|
init_telegramBridge();
|
|
624186
624955
|
init_formatActivity();
|
|
624187
624956
|
init_telegramApi();
|
|
624957
|
+
init_telegramTransport();
|
|
624958
|
+
init_rayuSession();
|
|
624188
624959
|
init_AppState();
|
|
624189
624960
|
import_react187 = __toESM(require_react(), 1);
|
|
624190
624961
|
});
|
|
@@ -639015,7 +639786,7 @@ var init_useVoiceEnabled = __esm(() => {
|
|
|
639015
639786
|
function getSemverPart(version3) {
|
|
639016
639787
|
return `${import_semver12.major(version3, { loose: true })}.${import_semver12.minor(version3, { loose: true })}.${import_semver12.patch(version3, { loose: true })}`;
|
|
639017
639788
|
}
|
|
639018
|
-
function useUpdateNotification(updatedVersion, initialVersion = "1.4.
|
|
639789
|
+
function useUpdateNotification(updatedVersion, initialVersion = "1.4.477") {
|
|
639019
639790
|
const [lastNotifiedSemver, setLastNotifiedSemver] = import_react217.useState(() => getSemverPart(initialVersion));
|
|
639020
639791
|
if (!updatedVersion) {
|
|
639021
639792
|
return null;
|
|
@@ -639055,7 +639826,7 @@ function AutoUpdater({
|
|
|
639055
639826
|
return;
|
|
639056
639827
|
}
|
|
639057
639828
|
if (false) {}
|
|
639058
|
-
const currentVersion = "1.4.
|
|
639829
|
+
const currentVersion = "1.4.477";
|
|
639059
639830
|
const channel2 = getInitialSettings()?.autoUpdatesChannel ?? "latest";
|
|
639060
639831
|
let latestVersion = await getLatestVersion(channel2);
|
|
639061
639832
|
const isDisabled = isAutoUpdaterDisabled();
|
|
@@ -639268,12 +640039,12 @@ function NativeAutoUpdater({
|
|
|
639268
640039
|
logEvent("tengu_native_auto_updater_start", {});
|
|
639269
640040
|
try {
|
|
639270
640041
|
const maxVersion = await getMaxVersion();
|
|
639271
|
-
if (maxVersion && gt("1.4.
|
|
640042
|
+
if (maxVersion && gt("1.4.477", maxVersion)) {
|
|
639272
640043
|
const msg = await getMaxVersionMessage();
|
|
639273
640044
|
setMaxVersionIssue(msg ?? "affects your version");
|
|
639274
640045
|
}
|
|
639275
640046
|
const result = await installLatest(channel2);
|
|
639276
|
-
const currentVersion = "1.4.
|
|
640047
|
+
const currentVersion = "1.4.477";
|
|
639277
640048
|
const latencyMs = Date.now() - startTime2;
|
|
639278
640049
|
if (result.lockFailed) {
|
|
639279
640050
|
logEvent("tengu_native_auto_updater_lock_contention", {
|
|
@@ -639410,17 +640181,17 @@ function PackageManagerAutoUpdater(t0) {
|
|
|
639410
640181
|
const maxVersion = await getMaxVersion();
|
|
639411
640182
|
if (maxVersion && latest && gt(latest, maxVersion)) {
|
|
639412
640183
|
logForDebugging(`PackageManagerAutoUpdater: maxVersion ${maxVersion} is set, capping update from ${latest} to ${maxVersion}`);
|
|
639413
|
-
if (gte("1.4.
|
|
639414
|
-
logForDebugging(`PackageManagerAutoUpdater: current version ${"1.4.
|
|
640184
|
+
if (gte("1.4.477", maxVersion)) {
|
|
640185
|
+
logForDebugging(`PackageManagerAutoUpdater: current version ${"1.4.477"} is already at or above maxVersion ${maxVersion}, skipping update`);
|
|
639415
640186
|
setUpdateAvailable(false);
|
|
639416
640187
|
return;
|
|
639417
640188
|
}
|
|
639418
640189
|
latest = maxVersion;
|
|
639419
640190
|
}
|
|
639420
|
-
const hasUpdate = latest && !gte("1.4.
|
|
640191
|
+
const hasUpdate = latest && !gte("1.4.477", latest) && !shouldSkipVersion(latest);
|
|
639421
640192
|
setUpdateAvailable(!!hasUpdate);
|
|
639422
640193
|
if (hasUpdate) {
|
|
639423
|
-
logForDebugging(`PackageManagerAutoUpdater: Update available ${"1.4.
|
|
640194
|
+
logForDebugging(`PackageManagerAutoUpdater: Update available ${"1.4.477"} -> ${latest}`);
|
|
639424
640195
|
}
|
|
639425
640196
|
};
|
|
639426
640197
|
$3[0] = t1;
|
|
@@ -639454,7 +640225,7 @@ function PackageManagerAutoUpdater(t0) {
|
|
|
639454
640225
|
wrap: "truncate",
|
|
639455
640226
|
children: [
|
|
639456
640227
|
"currentVersion: ",
|
|
639457
|
-
"1.4.
|
|
640228
|
+
"1.4.477"
|
|
639458
640229
|
]
|
|
639459
640230
|
});
|
|
639460
640231
|
$3[3] = verbose;
|
|
@@ -647618,7 +648389,7 @@ function buildStatusLineCommandInput(permissionMode, exceeds200kTokens, settings
|
|
|
647618
648389
|
project_dir: getOriginalCwd(),
|
|
647619
648390
|
added_dirs: addedDirs
|
|
647620
648391
|
},
|
|
647621
|
-
version: "1.4.
|
|
648392
|
+
version: "1.4.477",
|
|
647622
648393
|
output_style: {
|
|
647623
648394
|
name: outputStyleName
|
|
647624
648395
|
},
|
|
@@ -649797,7 +650568,7 @@ var init_user = __esm(() => {
|
|
|
649797
650568
|
deviceId,
|
|
649798
650569
|
sessionId: getSessionId(),
|
|
649799
650570
|
email: getEmail(),
|
|
649800
|
-
appVersion: "1.4.
|
|
650571
|
+
appVersion: "1.4.477",
|
|
649801
650572
|
platform: getHostPlatformForAnalytics(),
|
|
649802
650573
|
organizationUuid,
|
|
649803
650574
|
accountUuid,
|
|
@@ -659236,7 +660007,7 @@ async function submitTranscriptShare(messages, trigger, appearanceId) {
|
|
|
659236
660007
|
} catch {}
|
|
659237
660008
|
const data = {
|
|
659238
660009
|
trigger,
|
|
659239
|
-
version: "1.4.
|
|
660010
|
+
version: "1.4.477",
|
|
659240
660011
|
platform: process.platform,
|
|
659241
660012
|
transcript,
|
|
659242
660013
|
subagentTranscripts: Object.keys(subagentTranscripts).length > 0 ? subagentTranscripts : undefined,
|
|
@@ -667514,6 +668285,7 @@ function REPL({
|
|
|
667514
668285
|
apiMetricsRef2.current = [];
|
|
667515
668286
|
setStreamingText(null);
|
|
667516
668287
|
setStreamingToolUses([]);
|
|
668288
|
+
setStreamingThinking(finalizeStreamingThinkingOnTurnEnd);
|
|
667517
668289
|
setSpinnerMessage(null);
|
|
667518
668290
|
setSpinnerColor(null);
|
|
667519
668291
|
setSpinnerShimmerColor(null);
|
|
@@ -671204,7 +671976,7 @@ function WelcomeV2() {
|
|
|
671204
671976
|
dimColor: true,
|
|
671205
671977
|
children: [
|
|
671206
671978
|
"v",
|
|
671207
|
-
"1.4.
|
|
671979
|
+
"1.4.477"
|
|
671208
671980
|
]
|
|
671209
671981
|
})
|
|
671210
671982
|
]
|
|
@@ -672211,7 +672983,7 @@ function completeOnboarding() {
|
|
|
672211
672983
|
saveGlobalConfig((current) => ({
|
|
672212
672984
|
...current,
|
|
672213
672985
|
hasCompletedOnboarding: true,
|
|
672214
|
-
lastOnboardingVersion: "1.4.
|
|
672986
|
+
lastOnboardingVersion: "1.4.477"
|
|
672215
672987
|
}));
|
|
672216
672988
|
}
|
|
672217
672989
|
function showDialog(root2, renderer) {
|
|
@@ -677144,7 +677916,7 @@ function appendToLog(path29, message) {
|
|
|
677144
677916
|
cwd: getFsImplementation().cwd(),
|
|
677145
677917
|
userType: "external",
|
|
677146
677918
|
sessionId: getSessionId(),
|
|
677147
|
-
version: "1.4.
|
|
677919
|
+
version: "1.4.477"
|
|
677148
677920
|
};
|
|
677149
677921
|
getLogWriter(path29).write(messageWithTimestamp);
|
|
677150
677922
|
}
|
|
@@ -681249,8 +682021,8 @@ async function getEnvLessBridgeConfig() {
|
|
|
681249
682021
|
}
|
|
681250
682022
|
async function checkEnvLessBridgeMinVersion() {
|
|
681251
682023
|
const cfg = await getEnvLessBridgeConfig();
|
|
681252
|
-
if (cfg.min_version && lt("1.4.
|
|
681253
|
-
return `Your version of RAYU (${"1.4.
|
|
682024
|
+
if (cfg.min_version && lt("1.4.477", cfg.min_version)) {
|
|
682025
|
+
return `Your version of RAYU (${"1.4.477"}) is too old for Remote Control.
|
|
681254
682026
|
Version ${cfg.min_version} or higher is required. Run \`claude update\` to update.`;
|
|
681255
682027
|
}
|
|
681256
682028
|
return null;
|
|
@@ -681723,7 +682495,7 @@ async function initBridgeCore(params) {
|
|
|
681723
682495
|
const rawApi = createBridgeApiClient({
|
|
681724
682496
|
baseUrl,
|
|
681725
682497
|
getAccessToken,
|
|
681726
|
-
runnerVersion: "1.4.
|
|
682498
|
+
runnerVersion: "1.4.477",
|
|
681727
682499
|
onDebug: logForDebugging,
|
|
681728
682500
|
onAuth401,
|
|
681729
682501
|
getTrustedDeviceToken
|
|
@@ -687078,7 +687850,7 @@ async function startMCPServer(cwd3, debug4, verbose) {
|
|
|
687078
687850
|
setCwd(cwd3);
|
|
687079
687851
|
const server = new Server({
|
|
687080
687852
|
name: "claude/tengu",
|
|
687081
|
-
version: "1.4.
|
|
687853
|
+
version: "1.4.477"
|
|
687082
687854
|
}, {
|
|
687083
687855
|
capabilities: {
|
|
687084
687856
|
tools: {}
|
|
@@ -689607,7 +690379,7 @@ ${customInstructions}` : customInstructions;
|
|
|
689607
690379
|
}
|
|
689608
690380
|
}
|
|
689609
690381
|
logForDiagnosticsNoPII("info", "started", {
|
|
689610
|
-
version: "1.4.
|
|
690382
|
+
version: "1.4.477",
|
|
689611
690383
|
is_native_binary: isInBundledMode()
|
|
689612
690384
|
});
|
|
689613
690385
|
registerCleanup(async () => {
|
|
@@ -690326,7 +691098,7 @@ Usage: rayu --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
690326
691098
|
pendingHookMessages
|
|
690327
691099
|
}, renderAndRun);
|
|
690328
691100
|
}
|
|
690329
|
-
}).version(`1.4.
|
|
691101
|
+
}).version(`1.4.477 (${PRODUCT_NAME})`, "-v, --version", "Output the version number");
|
|
690330
691102
|
program.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
|
|
690331
691103
|
program.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
|
|
690332
691104
|
if (canUserConfigureAdvisor()) {
|
|
@@ -690786,7 +691558,7 @@ if (false) {}
|
|
|
690786
691558
|
async function main2() {
|
|
690787
691559
|
const args = process.argv.slice(2);
|
|
690788
691560
|
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
|
|
690789
|
-
console.log(`${"1.4.
|
|
691561
|
+
console.log(`${"1.4.477"} (Rayu-CLI)`);
|
|
690790
691562
|
return;
|
|
690791
691563
|
}
|
|
690792
691564
|
if (!isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_TERMINAL_TITLE)) {
|