@funnycode/myclaude 0.1.269 → 0.1.275
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/myclaude.js +128 -33
- package/dist/myclaude.mjs +128 -33
- package/package.json +1 -1
package/dist/myclaude.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// MACRO - build-time constants (injected by build.ts)
|
|
5
5
|
// MACRO injected by build script
|
|
6
6
|
globalThis.MACRO = {
|
|
7
|
-
VERSION: "0.1.
|
|
8
|
-
BUILD_TIME: "2026-08-
|
|
7
|
+
VERSION: "0.1.275",
|
|
8
|
+
BUILD_TIME: "2026-08-18T07:41:26.160Z",
|
|
9
9
|
PACKAGE_URL: "@funnycode/myclaude",
|
|
10
10
|
NATIVE_PACKAGE_URL: "@funnycode/myclaude",
|
|
11
11
|
VERSION_CHANGELOG: '',
|
|
@@ -120027,7 +120027,7 @@ var package_default;
|
|
|
120027
120027
|
var init_package = __esm(() => {
|
|
120028
120028
|
package_default = {
|
|
120029
120029
|
name: "@funnycode/myclaude",
|
|
120030
|
-
version: "0.1.
|
|
120030
|
+
version: "0.1.275",
|
|
120031
120031
|
private: false,
|
|
120032
120032
|
description: "An open-source AI coding assistant in your terminal - powered by Claude",
|
|
120033
120033
|
license: "MIT",
|
|
@@ -282571,15 +282571,21 @@ __export(exports_sessionIdCompat, {
|
|
|
282571
282571
|
toInfraSessionId: () => toInfraSessionId,
|
|
282572
282572
|
toCompatSessionId: () => toCompatSessionId,
|
|
282573
282573
|
setCseShimGate: () => setCseShimGate,
|
|
282574
|
-
resetCseShimGateForTesting: () => resetCseShimGateForTesting
|
|
282574
|
+
resetCseShimGateForTesting: () => resetCseShimGateForTesting,
|
|
282575
|
+
getCseShimGate: () => getCseShimGate
|
|
282575
282576
|
});
|
|
282576
282577
|
function setCseShimGate(gate) {
|
|
282577
|
-
if (
|
|
282578
|
-
|
|
282579
|
-
|
|
282578
|
+
if (_gateLocked)
|
|
282579
|
+
return;
|
|
282580
|
+
_gateLocked = true;
|
|
282581
|
+
_isCseShimEnabled = gate;
|
|
282582
|
+
}
|
|
282583
|
+
function getCseShimGate() {
|
|
282584
|
+
return _isCseShimEnabled;
|
|
282580
282585
|
}
|
|
282581
282586
|
function resetCseShimGateForTesting() {
|
|
282582
282587
|
_isCseShimEnabled = undefined;
|
|
282588
|
+
_gateLocked = false;
|
|
282583
282589
|
}
|
|
282584
282590
|
function toCompatSessionId(id) {
|
|
282585
282591
|
if (!id.startsWith("cse_"))
|
|
@@ -282595,7 +282601,7 @@ function toInfraSessionId(id) {
|
|
|
282595
282601
|
return id;
|
|
282596
282602
|
return "cse_" + id.slice("session_".length);
|
|
282597
282603
|
}
|
|
282598
|
-
var _isCseShimEnabled;
|
|
282604
|
+
var _isCseShimEnabled, _gateLocked = false;
|
|
282599
282605
|
|
|
282600
282606
|
// src/constants/product.ts
|
|
282601
282607
|
function isRemoteSessionStaging(sessionId, ingressUrl) {
|
|
@@ -303915,6 +303921,20 @@ var init_grove = __esm(() => {
|
|
|
303915
303921
|
});
|
|
303916
303922
|
|
|
303917
303923
|
// src/services/policyLimits/index.ts
|
|
303924
|
+
var exports_policyLimits = {};
|
|
303925
|
+
__export(exports_policyLimits, {
|
|
303926
|
+
waitForPolicyLimitsToLoad: () => waitForPolicyLimitsToLoad,
|
|
303927
|
+
stopBackgroundPolling: () => stopBackgroundPolling,
|
|
303928
|
+
startBackgroundPolling: () => startBackgroundPolling,
|
|
303929
|
+
refreshPolicyLimits: () => refreshPolicyLimits,
|
|
303930
|
+
loadPolicyLimits: () => loadPolicyLimits,
|
|
303931
|
+
isPolicyLimitsEligible: () => isPolicyLimitsEligible,
|
|
303932
|
+
isPolicyAllowed: () => isPolicyAllowed,
|
|
303933
|
+
initializePolicyLimitsLoadingPromise: () => initializePolicyLimitsLoadingPromise,
|
|
303934
|
+
clearPolicyLimitsCache: () => clearPolicyLimitsCache,
|
|
303935
|
+
_resetPolicyLimitsForTesting: () => _resetPolicyLimitsForTesting
|
|
303936
|
+
});
|
|
303937
|
+
function _resetPolicyLimitsForTesting() {}
|
|
303918
303938
|
function initializePolicyLimitsLoadingPromise() {}
|
|
303919
303939
|
function isPolicyLimitsEligible() {
|
|
303920
303940
|
return false;
|
|
@@ -303926,6 +303946,8 @@ function isPolicyAllowed(_policy) {
|
|
|
303926
303946
|
async function loadPolicyLimits() {}
|
|
303927
303947
|
async function refreshPolicyLimits() {}
|
|
303928
303948
|
async function clearPolicyLimitsCache() {}
|
|
303949
|
+
function startBackgroundPolling() {}
|
|
303950
|
+
function stopBackgroundPolling() {}
|
|
303929
303951
|
|
|
303930
303952
|
// src/services/remoteManagedSettings/index.ts
|
|
303931
303953
|
function initializeRemoteManagedSettingsLoadingPromise() {}
|
|
@@ -480159,6 +480181,35 @@ var init_definitions = __esm(() => {
|
|
|
480159
480181
|
});
|
|
480160
480182
|
|
|
480161
480183
|
// src/flows/executor.ts
|
|
480184
|
+
function sanitizeCommand(command6) {
|
|
480185
|
+
if (typeof command6 !== "string" || command6.trim().length === 0) {
|
|
480186
|
+
throw new Error("Invalid command: empty or non-string command");
|
|
480187
|
+
}
|
|
480188
|
+
const parsed = import_shell_quote4.parse(command6);
|
|
480189
|
+
const argv = [];
|
|
480190
|
+
for (const node of parsed) {
|
|
480191
|
+
if (typeof node === "string") {
|
|
480192
|
+
if (/[`$<>|;&\\\n\r]/.test(node)) {
|
|
480193
|
+
throw new Error(`Invalid command: shell metacharacter in token "${node}" is not allowed: "${command6}"`);
|
|
480194
|
+
}
|
|
480195
|
+
argv.push(node);
|
|
480196
|
+
continue;
|
|
480197
|
+
}
|
|
480198
|
+
if (node && typeof node === "object") {
|
|
480199
|
+
const kind = node.op || node.pattern || "shell metacharacter";
|
|
480200
|
+
throw new Error(`Invalid command: shell metacharacter/operator (${kind}) is not allowed: "${command6}"`);
|
|
480201
|
+
}
|
|
480202
|
+
throw new Error(`Invalid command: unexpected token in command: "${command6}"`);
|
|
480203
|
+
}
|
|
480204
|
+
if (argv.length === 0) {
|
|
480205
|
+
throw new Error("Invalid command: no program specified");
|
|
480206
|
+
}
|
|
480207
|
+
const program = argv[0];
|
|
480208
|
+
if (!ALLOWED_COMMANDS.has(program)) {
|
|
480209
|
+
throw new Error(`Invalid command: program "${program}" is not on the allowlist of permitted commands`);
|
|
480210
|
+
}
|
|
480211
|
+
return argv;
|
|
480212
|
+
}
|
|
480162
480213
|
async function executeFlow(flow, context2, onStepStart, onStepComplete, onStepFail, onComplete) {
|
|
480163
480214
|
const state = {
|
|
480164
480215
|
currentStepIndex: 0,
|
|
@@ -480193,7 +480244,11 @@ async function executeFlow(flow, context2, onStepStart, onStepComplete, onStepFa
|
|
|
480193
480244
|
} catch (error52) {
|
|
480194
480245
|
state.failedSteps.push(step.id);
|
|
480195
480246
|
if (onStepFail) {
|
|
480196
|
-
|
|
480247
|
+
try {
|
|
480248
|
+
await onStepFail(step, state, error52);
|
|
480249
|
+
} catch (callbackError) {
|
|
480250
|
+
console.error(`onStepFail callback failed for step "${step.id}":`, callbackError);
|
|
480251
|
+
}
|
|
480197
480252
|
}
|
|
480198
480253
|
const shouldContinue = await shouldContinueOnError(error52, step);
|
|
480199
480254
|
if (!shouldContinue) {
|
|
@@ -480202,13 +480257,18 @@ async function executeFlow(flow, context2, onStepStart, onStepComplete, onStepFa
|
|
|
480202
480257
|
}
|
|
480203
480258
|
}
|
|
480204
480259
|
if (onComplete) {
|
|
480205
|
-
|
|
480260
|
+
try {
|
|
480261
|
+
await onComplete(state);
|
|
480262
|
+
} catch (callbackError) {
|
|
480263
|
+
console.error("onComplete callback failed:", callbackError);
|
|
480264
|
+
}
|
|
480206
480265
|
}
|
|
480207
480266
|
return state;
|
|
480208
480267
|
}
|
|
480209
480268
|
async function executeCommand(command6, context2) {
|
|
480269
|
+
const argv = sanitizeCommand(command6);
|
|
480210
480270
|
if (context2?.bridge?.runCommand) {
|
|
480211
|
-
await context2.bridge.runCommand(
|
|
480271
|
+
await context2.bridge.runCommand(argv);
|
|
480212
480272
|
return;
|
|
480213
480273
|
}
|
|
480214
480274
|
throw new Error("No bridge.runCommand available to execute: " + command6);
|
|
@@ -480221,13 +480281,39 @@ async function executeFileOperation(file2, context2) {
|
|
|
480221
480281
|
throw new Error("No bridge.editFile available to edit: " + file2);
|
|
480222
480282
|
}
|
|
480223
480283
|
async function shouldContinueOnError(error52, step) {
|
|
480224
|
-
const
|
|
480225
|
-
|
|
480226
|
-
|
|
480227
|
-
|
|
480228
|
-
|
|
480229
|
-
|
|
480284
|
+
const transientCodes = ["ETIMEDOUT"];
|
|
480285
|
+
const err2 = error52;
|
|
480286
|
+
if (err2.code && transientCodes.includes(err2.code)) {
|
|
480287
|
+
return true;
|
|
480288
|
+
}
|
|
480289
|
+
if (transientCodes.some((code) => error52.message.includes(code))) {
|
|
480290
|
+
return true;
|
|
480291
|
+
}
|
|
480292
|
+
if (error52.message.includes("No bridge")) {
|
|
480293
|
+
return true;
|
|
480294
|
+
}
|
|
480295
|
+
return false;
|
|
480230
480296
|
}
|
|
480297
|
+
var import_shell_quote4, ALLOWED_COMMANDS;
|
|
480298
|
+
var init_executor = __esm(() => {
|
|
480299
|
+
import_shell_quote4 = __toESM(require_shell_quote(), 1);
|
|
480300
|
+
ALLOWED_COMMANDS = new Set([
|
|
480301
|
+
"npm",
|
|
480302
|
+
"npx",
|
|
480303
|
+
"node",
|
|
480304
|
+
"bun",
|
|
480305
|
+
"yarn",
|
|
480306
|
+
"pnpm",
|
|
480307
|
+
"mkdir",
|
|
480308
|
+
"touch",
|
|
480309
|
+
"cp",
|
|
480310
|
+
"mv",
|
|
480311
|
+
"echo",
|
|
480312
|
+
"git",
|
|
480313
|
+
"tsc",
|
|
480314
|
+
"vitest"
|
|
480315
|
+
]);
|
|
480316
|
+
});
|
|
480231
480317
|
|
|
480232
480318
|
// src/commands/flow.ts
|
|
480233
480319
|
function getPromptContent3(args) {
|
|
@@ -480285,6 +480371,7 @@ var ALLOWED_TOOLS3, command6, flow_default;
|
|
|
480285
480371
|
var init_flow = __esm(() => {
|
|
480286
480372
|
init_attribution();
|
|
480287
480373
|
init_definitions();
|
|
480374
|
+
init_executor();
|
|
480288
480375
|
ALLOWED_TOOLS3 = [
|
|
480289
480376
|
"Bash(*)",
|
|
480290
480377
|
"Edit(*)",
|
|
@@ -540688,7 +540775,7 @@ function createSearcher(pattern, options) {
|
|
|
540688
540775
|
}
|
|
540689
540776
|
return new BitapSearch(pattern, options);
|
|
540690
540777
|
}
|
|
540691
|
-
function
|
|
540778
|
+
function parse15(query3, options, { auto = true } = {}) {
|
|
540692
540779
|
const next = (query4) => {
|
|
540693
540780
|
let keys2 = Object.keys(query4);
|
|
540694
540781
|
const isQueryPath = isPath(query4);
|
|
@@ -540875,7 +540962,7 @@ class Fuse {
|
|
|
540875
540962
|
return results;
|
|
540876
540963
|
}
|
|
540877
540964
|
_searchLogical(query3) {
|
|
540878
|
-
const expression =
|
|
540965
|
+
const expression = parse15(query3, this.options);
|
|
540879
540966
|
const evaluate = (node, item, idx) => {
|
|
540880
540967
|
if (!node.children) {
|
|
540881
540968
|
const { keyId, searcher } = node;
|
|
@@ -541253,7 +541340,7 @@ var init_fuse = __esm(() => {
|
|
|
541253
541340
|
Fuse.parseIndex = parseIndex;
|
|
541254
541341
|
Fuse.config = Config2;
|
|
541255
541342
|
{
|
|
541256
|
-
Fuse.parseQuery =
|
|
541343
|
+
Fuse.parseQuery = parse15;
|
|
541257
541344
|
}
|
|
541258
541345
|
{
|
|
541259
541346
|
register(ExtendedSearch);
|
|
@@ -582669,6 +582756,17 @@ async function initReplBridge(options) {
|
|
|
582669
582756
|
tags
|
|
582670
582757
|
} = options ?? {};
|
|
582671
582758
|
setCseShimGate(isCseShimEnabled);
|
|
582759
|
+
const [
|
|
582760
|
+
{ getFeatureValue_CACHED_WITH_REFRESH: getFeatureValue_CACHED_WITH_REFRESH4 },
|
|
582761
|
+
{ getOrganizationUUID: getOrganizationUUID2 },
|
|
582762
|
+
{ isPolicyAllowed: isPolicyAllowed2, waitForPolicyLimitsToLoad: waitForPolicyLimitsToLoad2 },
|
|
582763
|
+
{ checkAndRefreshOAuthTokenIfNeeded: checkAndRefreshOAuthTokenIfNeeded2, getClaudeAIOAuthTokens: getClaudeAIOAuthTokens2, handleOAuth401Error: handleOAuth401Error2 }
|
|
582764
|
+
] = await Promise.all([
|
|
582765
|
+
Promise.resolve().then(() => (init_growthbook(), exports_growthbook)),
|
|
582766
|
+
Promise.resolve().then(() => (init_client2(), exports_client)),
|
|
582767
|
+
Promise.resolve().then(() => exports_policyLimits),
|
|
582768
|
+
Promise.resolve().then(() => (init_auth(), exports_auth))
|
|
582769
|
+
]);
|
|
582672
582770
|
if (!await isBridgeEnabledBlocking()) {
|
|
582673
582771
|
logBridgeSkip("not_enabled", "[bridge:repl] Skipping: bridge not enabled");
|
|
582674
582772
|
return null;
|
|
@@ -582678,26 +582776,26 @@ async function initReplBridge(options) {
|
|
|
582678
582776
|
onStateChange?.("failed", "/login");
|
|
582679
582777
|
return null;
|
|
582680
582778
|
}
|
|
582681
|
-
await
|
|
582682
|
-
if (!
|
|
582779
|
+
await waitForPolicyLimitsToLoad2();
|
|
582780
|
+
if (!isPolicyAllowed2("allow_remote_control")) {
|
|
582683
582781
|
logBridgeSkip("policy_denied", "[bridge:repl] Skipping: allow_remote_control policy not allowed");
|
|
582684
582782
|
onStateChange?.("failed", "disabled by your organization's policy");
|
|
582685
582783
|
return null;
|
|
582686
582784
|
}
|
|
582687
582785
|
if (!getBridgeTokenOverride()) {
|
|
582688
582786
|
const cfg = getGlobalConfig();
|
|
582689
|
-
if (cfg.bridgeOauthDeadExpiresAt != null && (cfg.bridgeOauthDeadFailCount ?? 0) >= 3 &&
|
|
582787
|
+
if (cfg.bridgeOauthDeadExpiresAt != null && (cfg.bridgeOauthDeadFailCount ?? 0) >= 3 && getClaudeAIOAuthTokens2()?.expiresAt === cfg.bridgeOauthDeadExpiresAt) {
|
|
582690
582788
|
logForDebugging(`[bridge:repl] Skipping: cross-process backoff (dead token seen ${cfg.bridgeOauthDeadFailCount} times)`);
|
|
582691
582789
|
return null;
|
|
582692
582790
|
}
|
|
582693
582791
|
try {
|
|
582694
|
-
await
|
|
582792
|
+
await checkAndRefreshOAuthTokenIfNeeded2();
|
|
582695
582793
|
} catch (error52) {
|
|
582696
582794
|
logBridgeSkip("oauth_refresh_failed", `[bridge:repl] Skipping: OAuth token refresh failed - ${errorMessage(error52)}`);
|
|
582697
582795
|
onStateChange?.("failed", errorMessage(error52));
|
|
582698
582796
|
return null;
|
|
582699
582797
|
}
|
|
582700
|
-
const tokens =
|
|
582798
|
+
const tokens = getClaudeAIOAuthTokens2();
|
|
582701
582799
|
if (tokens && tokens.expiresAt !== null && tokens.expiresAt <= Date.now()) {
|
|
582702
582800
|
logBridgeSkip("oauth_expired_unrefreshable", "[bridge:repl] Skipping: OAuth token expired and refresh failed (re-login required)");
|
|
582703
582801
|
onStateChange?.("failed", "/login");
|
|
@@ -582761,7 +582859,7 @@ async function initReplBridge(options) {
|
|
|
582761
582859
|
if (generated && gen === genSeq && lastBridgeSessionId === bridgeSessionId && !getCurrentSessionTitle(getSessionId())) {
|
|
582762
582860
|
patch2(generated, bridgeSessionId, atCount);
|
|
582763
582861
|
}
|
|
582764
|
-
});
|
|
582862
|
+
}).catch(() => {});
|
|
582765
582863
|
};
|
|
582766
582864
|
const onUserMessage = (text2, bridgeSessionId) => {
|
|
582767
582865
|
if (hasExplicitTitle || getCurrentSessionTitle(getSessionId())) {
|
|
@@ -582784,10 +582882,10 @@ async function initReplBridge(options) {
|
|
|
582784
582882
|
}
|
|
582785
582883
|
return userMessageCount >= 3;
|
|
582786
582884
|
};
|
|
582787
|
-
const initialHistoryCap =
|
|
582885
|
+
const initialHistoryCap = getFeatureValue_CACHED_WITH_REFRESH4("tengu_bridge_initial_history_cap", 200, 5 * 60 * 1000);
|
|
582788
582886
|
let orgUUID;
|
|
582789
582887
|
try {
|
|
582790
|
-
orgUUID = await
|
|
582888
|
+
orgUUID = await getOrganizationUUID2();
|
|
582791
582889
|
} catch (error52) {
|
|
582792
582890
|
logBridgeSkip("get_org_uuid_failed", `[bridge:repl] Skipping: failed to get organization UUID - ${errorMessage(error52)}`);
|
|
582793
582891
|
onStateChange?.("failed", errorMessage(error52));
|
|
@@ -582812,7 +582910,7 @@ async function initReplBridge(options) {
|
|
|
582812
582910
|
orgUUID,
|
|
582813
582911
|
title,
|
|
582814
582912
|
getAccessToken: getBridgeAccessToken,
|
|
582815
|
-
onAuth401:
|
|
582913
|
+
onAuth401: handleOAuth401Error2,
|
|
582816
582914
|
toSDKMessages,
|
|
582817
582915
|
initialHistoryCap,
|
|
582818
582916
|
initialMessages,
|
|
@@ -582865,7 +582963,7 @@ async function initReplBridge(options) {
|
|
|
582865
582963
|
getCurrentTitle: () => getCurrentSessionTitle(getSessionId()) ?? title,
|
|
582866
582964
|
onUserMessage,
|
|
582867
582965
|
toSDKMessages,
|
|
582868
|
-
onAuth401:
|
|
582966
|
+
onAuth401: handleOAuth401Error2,
|
|
582869
582967
|
getPollIntervalConfig,
|
|
582870
582968
|
initialHistoryCap,
|
|
582871
582969
|
initialMessages,
|
|
@@ -582891,9 +582989,6 @@ function deriveTitle(raw) {
|
|
|
582891
582989
|
var TITLE_MAX_LEN = 50;
|
|
582892
582990
|
var init_initReplBridge = __esm(() => {
|
|
582893
582991
|
init_state();
|
|
582894
|
-
init_growthbook();
|
|
582895
|
-
init_client2();
|
|
582896
|
-
init_auth();
|
|
582897
582992
|
init_config();
|
|
582898
582993
|
init_debug();
|
|
582899
582994
|
init_displayTags();
|
package/dist/myclaude.mjs
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
// MACRO - build-time constants (injected by build.ts)
|
|
5
5
|
// MACRO injected by build script
|
|
6
6
|
globalThis.MACRO = {
|
|
7
|
-
VERSION: "0.1.
|
|
8
|
-
BUILD_TIME: "2026-08-
|
|
7
|
+
VERSION: "0.1.275",
|
|
8
|
+
BUILD_TIME: "2026-08-18T07:41:26.160Z",
|
|
9
9
|
PACKAGE_URL: "@funnycode/myclaude",
|
|
10
10
|
NATIVE_PACKAGE_URL: "@funnycode/myclaude",
|
|
11
11
|
VERSION_CHANGELOG: '',
|
|
@@ -120027,7 +120027,7 @@ var package_default;
|
|
|
120027
120027
|
var init_package = __esm(() => {
|
|
120028
120028
|
package_default = {
|
|
120029
120029
|
name: "@funnycode/myclaude",
|
|
120030
|
-
version: "0.1.
|
|
120030
|
+
version: "0.1.275",
|
|
120031
120031
|
private: false,
|
|
120032
120032
|
description: "An open-source AI coding assistant in your terminal - powered by Claude",
|
|
120033
120033
|
license: "MIT",
|
|
@@ -282571,15 +282571,21 @@ __export(exports_sessionIdCompat, {
|
|
|
282571
282571
|
toInfraSessionId: () => toInfraSessionId,
|
|
282572
282572
|
toCompatSessionId: () => toCompatSessionId,
|
|
282573
282573
|
setCseShimGate: () => setCseShimGate,
|
|
282574
|
-
resetCseShimGateForTesting: () => resetCseShimGateForTesting
|
|
282574
|
+
resetCseShimGateForTesting: () => resetCseShimGateForTesting,
|
|
282575
|
+
getCseShimGate: () => getCseShimGate
|
|
282575
282576
|
});
|
|
282576
282577
|
function setCseShimGate(gate) {
|
|
282577
|
-
if (
|
|
282578
|
-
|
|
282579
|
-
|
|
282578
|
+
if (_gateLocked)
|
|
282579
|
+
return;
|
|
282580
|
+
_gateLocked = true;
|
|
282581
|
+
_isCseShimEnabled = gate;
|
|
282582
|
+
}
|
|
282583
|
+
function getCseShimGate() {
|
|
282584
|
+
return _isCseShimEnabled;
|
|
282580
282585
|
}
|
|
282581
282586
|
function resetCseShimGateForTesting() {
|
|
282582
282587
|
_isCseShimEnabled = undefined;
|
|
282588
|
+
_gateLocked = false;
|
|
282583
282589
|
}
|
|
282584
282590
|
function toCompatSessionId(id) {
|
|
282585
282591
|
if (!id.startsWith("cse_"))
|
|
@@ -282595,7 +282601,7 @@ function toInfraSessionId(id) {
|
|
|
282595
282601
|
return id;
|
|
282596
282602
|
return "cse_" + id.slice("session_".length);
|
|
282597
282603
|
}
|
|
282598
|
-
var _isCseShimEnabled;
|
|
282604
|
+
var _isCseShimEnabled, _gateLocked = false;
|
|
282599
282605
|
|
|
282600
282606
|
// src/constants/product.ts
|
|
282601
282607
|
function isRemoteSessionStaging(sessionId, ingressUrl) {
|
|
@@ -303915,6 +303921,20 @@ var init_grove = __esm(() => {
|
|
|
303915
303921
|
});
|
|
303916
303922
|
|
|
303917
303923
|
// src/services/policyLimits/index.ts
|
|
303924
|
+
var exports_policyLimits = {};
|
|
303925
|
+
__export(exports_policyLimits, {
|
|
303926
|
+
waitForPolicyLimitsToLoad: () => waitForPolicyLimitsToLoad,
|
|
303927
|
+
stopBackgroundPolling: () => stopBackgroundPolling,
|
|
303928
|
+
startBackgroundPolling: () => startBackgroundPolling,
|
|
303929
|
+
refreshPolicyLimits: () => refreshPolicyLimits,
|
|
303930
|
+
loadPolicyLimits: () => loadPolicyLimits,
|
|
303931
|
+
isPolicyLimitsEligible: () => isPolicyLimitsEligible,
|
|
303932
|
+
isPolicyAllowed: () => isPolicyAllowed,
|
|
303933
|
+
initializePolicyLimitsLoadingPromise: () => initializePolicyLimitsLoadingPromise,
|
|
303934
|
+
clearPolicyLimitsCache: () => clearPolicyLimitsCache,
|
|
303935
|
+
_resetPolicyLimitsForTesting: () => _resetPolicyLimitsForTesting
|
|
303936
|
+
});
|
|
303937
|
+
function _resetPolicyLimitsForTesting() {}
|
|
303918
303938
|
function initializePolicyLimitsLoadingPromise() {}
|
|
303919
303939
|
function isPolicyLimitsEligible() {
|
|
303920
303940
|
return false;
|
|
@@ -303926,6 +303946,8 @@ function isPolicyAllowed(_policy) {
|
|
|
303926
303946
|
async function loadPolicyLimits() {}
|
|
303927
303947
|
async function refreshPolicyLimits() {}
|
|
303928
303948
|
async function clearPolicyLimitsCache() {}
|
|
303949
|
+
function startBackgroundPolling() {}
|
|
303950
|
+
function stopBackgroundPolling() {}
|
|
303929
303951
|
|
|
303930
303952
|
// src/services/remoteManagedSettings/index.ts
|
|
303931
303953
|
function initializeRemoteManagedSettingsLoadingPromise() {}
|
|
@@ -480159,6 +480181,35 @@ var init_definitions = __esm(() => {
|
|
|
480159
480181
|
});
|
|
480160
480182
|
|
|
480161
480183
|
// src/flows/executor.ts
|
|
480184
|
+
function sanitizeCommand(command6) {
|
|
480185
|
+
if (typeof command6 !== "string" || command6.trim().length === 0) {
|
|
480186
|
+
throw new Error("Invalid command: empty or non-string command");
|
|
480187
|
+
}
|
|
480188
|
+
const parsed = import_shell_quote4.parse(command6);
|
|
480189
|
+
const argv = [];
|
|
480190
|
+
for (const node of parsed) {
|
|
480191
|
+
if (typeof node === "string") {
|
|
480192
|
+
if (/[`$<>|;&\\\n\r]/.test(node)) {
|
|
480193
|
+
throw new Error(`Invalid command: shell metacharacter in token "${node}" is not allowed: "${command6}"`);
|
|
480194
|
+
}
|
|
480195
|
+
argv.push(node);
|
|
480196
|
+
continue;
|
|
480197
|
+
}
|
|
480198
|
+
if (node && typeof node === "object") {
|
|
480199
|
+
const kind = node.op || node.pattern || "shell metacharacter";
|
|
480200
|
+
throw new Error(`Invalid command: shell metacharacter/operator (${kind}) is not allowed: "${command6}"`);
|
|
480201
|
+
}
|
|
480202
|
+
throw new Error(`Invalid command: unexpected token in command: "${command6}"`);
|
|
480203
|
+
}
|
|
480204
|
+
if (argv.length === 0) {
|
|
480205
|
+
throw new Error("Invalid command: no program specified");
|
|
480206
|
+
}
|
|
480207
|
+
const program = argv[0];
|
|
480208
|
+
if (!ALLOWED_COMMANDS.has(program)) {
|
|
480209
|
+
throw new Error(`Invalid command: program "${program}" is not on the allowlist of permitted commands`);
|
|
480210
|
+
}
|
|
480211
|
+
return argv;
|
|
480212
|
+
}
|
|
480162
480213
|
async function executeFlow(flow, context2, onStepStart, onStepComplete, onStepFail, onComplete) {
|
|
480163
480214
|
const state = {
|
|
480164
480215
|
currentStepIndex: 0,
|
|
@@ -480193,7 +480244,11 @@ async function executeFlow(flow, context2, onStepStart, onStepComplete, onStepFa
|
|
|
480193
480244
|
} catch (error52) {
|
|
480194
480245
|
state.failedSteps.push(step.id);
|
|
480195
480246
|
if (onStepFail) {
|
|
480196
|
-
|
|
480247
|
+
try {
|
|
480248
|
+
await onStepFail(step, state, error52);
|
|
480249
|
+
} catch (callbackError) {
|
|
480250
|
+
console.error(`onStepFail callback failed for step "${step.id}":`, callbackError);
|
|
480251
|
+
}
|
|
480197
480252
|
}
|
|
480198
480253
|
const shouldContinue = await shouldContinueOnError(error52, step);
|
|
480199
480254
|
if (!shouldContinue) {
|
|
@@ -480202,13 +480257,18 @@ async function executeFlow(flow, context2, onStepStart, onStepComplete, onStepFa
|
|
|
480202
480257
|
}
|
|
480203
480258
|
}
|
|
480204
480259
|
if (onComplete) {
|
|
480205
|
-
|
|
480260
|
+
try {
|
|
480261
|
+
await onComplete(state);
|
|
480262
|
+
} catch (callbackError) {
|
|
480263
|
+
console.error("onComplete callback failed:", callbackError);
|
|
480264
|
+
}
|
|
480206
480265
|
}
|
|
480207
480266
|
return state;
|
|
480208
480267
|
}
|
|
480209
480268
|
async function executeCommand(command6, context2) {
|
|
480269
|
+
const argv = sanitizeCommand(command6);
|
|
480210
480270
|
if (context2?.bridge?.runCommand) {
|
|
480211
|
-
await context2.bridge.runCommand(
|
|
480271
|
+
await context2.bridge.runCommand(argv);
|
|
480212
480272
|
return;
|
|
480213
480273
|
}
|
|
480214
480274
|
throw new Error("No bridge.runCommand available to execute: " + command6);
|
|
@@ -480221,13 +480281,39 @@ async function executeFileOperation(file2, context2) {
|
|
|
480221
480281
|
throw new Error("No bridge.editFile available to edit: " + file2);
|
|
480222
480282
|
}
|
|
480223
480283
|
async function shouldContinueOnError(error52, step) {
|
|
480224
|
-
const
|
|
480225
|
-
|
|
480226
|
-
|
|
480227
|
-
|
|
480228
|
-
|
|
480229
|
-
|
|
480284
|
+
const transientCodes = ["ETIMEDOUT"];
|
|
480285
|
+
const err2 = error52;
|
|
480286
|
+
if (err2.code && transientCodes.includes(err2.code)) {
|
|
480287
|
+
return true;
|
|
480288
|
+
}
|
|
480289
|
+
if (transientCodes.some((code) => error52.message.includes(code))) {
|
|
480290
|
+
return true;
|
|
480291
|
+
}
|
|
480292
|
+
if (error52.message.includes("No bridge")) {
|
|
480293
|
+
return true;
|
|
480294
|
+
}
|
|
480295
|
+
return false;
|
|
480230
480296
|
}
|
|
480297
|
+
var import_shell_quote4, ALLOWED_COMMANDS;
|
|
480298
|
+
var init_executor = __esm(() => {
|
|
480299
|
+
import_shell_quote4 = __toESM(require_shell_quote(), 1);
|
|
480300
|
+
ALLOWED_COMMANDS = new Set([
|
|
480301
|
+
"npm",
|
|
480302
|
+
"npx",
|
|
480303
|
+
"node",
|
|
480304
|
+
"bun",
|
|
480305
|
+
"yarn",
|
|
480306
|
+
"pnpm",
|
|
480307
|
+
"mkdir",
|
|
480308
|
+
"touch",
|
|
480309
|
+
"cp",
|
|
480310
|
+
"mv",
|
|
480311
|
+
"echo",
|
|
480312
|
+
"git",
|
|
480313
|
+
"tsc",
|
|
480314
|
+
"vitest"
|
|
480315
|
+
]);
|
|
480316
|
+
});
|
|
480231
480317
|
|
|
480232
480318
|
// src/commands/flow.ts
|
|
480233
480319
|
function getPromptContent3(args) {
|
|
@@ -480285,6 +480371,7 @@ var ALLOWED_TOOLS3, command6, flow_default;
|
|
|
480285
480371
|
var init_flow = __esm(() => {
|
|
480286
480372
|
init_attribution();
|
|
480287
480373
|
init_definitions();
|
|
480374
|
+
init_executor();
|
|
480288
480375
|
ALLOWED_TOOLS3 = [
|
|
480289
480376
|
"Bash(*)",
|
|
480290
480377
|
"Edit(*)",
|
|
@@ -540688,7 +540775,7 @@ function createSearcher(pattern, options) {
|
|
|
540688
540775
|
}
|
|
540689
540776
|
return new BitapSearch(pattern, options);
|
|
540690
540777
|
}
|
|
540691
|
-
function
|
|
540778
|
+
function parse15(query3, options, { auto = true } = {}) {
|
|
540692
540779
|
const next = (query4) => {
|
|
540693
540780
|
let keys2 = Object.keys(query4);
|
|
540694
540781
|
const isQueryPath = isPath(query4);
|
|
@@ -540875,7 +540962,7 @@ class Fuse {
|
|
|
540875
540962
|
return results;
|
|
540876
540963
|
}
|
|
540877
540964
|
_searchLogical(query3) {
|
|
540878
|
-
const expression =
|
|
540965
|
+
const expression = parse15(query3, this.options);
|
|
540879
540966
|
const evaluate = (node, item, idx) => {
|
|
540880
540967
|
if (!node.children) {
|
|
540881
540968
|
const { keyId, searcher } = node;
|
|
@@ -541253,7 +541340,7 @@ var init_fuse = __esm(() => {
|
|
|
541253
541340
|
Fuse.parseIndex = parseIndex;
|
|
541254
541341
|
Fuse.config = Config2;
|
|
541255
541342
|
{
|
|
541256
|
-
Fuse.parseQuery =
|
|
541343
|
+
Fuse.parseQuery = parse15;
|
|
541257
541344
|
}
|
|
541258
541345
|
{
|
|
541259
541346
|
register(ExtendedSearch);
|
|
@@ -582669,6 +582756,17 @@ async function initReplBridge(options) {
|
|
|
582669
582756
|
tags
|
|
582670
582757
|
} = options ?? {};
|
|
582671
582758
|
setCseShimGate(isCseShimEnabled);
|
|
582759
|
+
const [
|
|
582760
|
+
{ getFeatureValue_CACHED_WITH_REFRESH: getFeatureValue_CACHED_WITH_REFRESH4 },
|
|
582761
|
+
{ getOrganizationUUID: getOrganizationUUID2 },
|
|
582762
|
+
{ isPolicyAllowed: isPolicyAllowed2, waitForPolicyLimitsToLoad: waitForPolicyLimitsToLoad2 },
|
|
582763
|
+
{ checkAndRefreshOAuthTokenIfNeeded: checkAndRefreshOAuthTokenIfNeeded2, getClaudeAIOAuthTokens: getClaudeAIOAuthTokens2, handleOAuth401Error: handleOAuth401Error2 }
|
|
582764
|
+
] = await Promise.all([
|
|
582765
|
+
Promise.resolve().then(() => (init_growthbook(), exports_growthbook)),
|
|
582766
|
+
Promise.resolve().then(() => (init_client2(), exports_client)),
|
|
582767
|
+
Promise.resolve().then(() => exports_policyLimits),
|
|
582768
|
+
Promise.resolve().then(() => (init_auth(), exports_auth))
|
|
582769
|
+
]);
|
|
582672
582770
|
if (!await isBridgeEnabledBlocking()) {
|
|
582673
582771
|
logBridgeSkip("not_enabled", "[bridge:repl] Skipping: bridge not enabled");
|
|
582674
582772
|
return null;
|
|
@@ -582678,26 +582776,26 @@ async function initReplBridge(options) {
|
|
|
582678
582776
|
onStateChange?.("failed", "/login");
|
|
582679
582777
|
return null;
|
|
582680
582778
|
}
|
|
582681
|
-
await
|
|
582682
|
-
if (!
|
|
582779
|
+
await waitForPolicyLimitsToLoad2();
|
|
582780
|
+
if (!isPolicyAllowed2("allow_remote_control")) {
|
|
582683
582781
|
logBridgeSkip("policy_denied", "[bridge:repl] Skipping: allow_remote_control policy not allowed");
|
|
582684
582782
|
onStateChange?.("failed", "disabled by your organization's policy");
|
|
582685
582783
|
return null;
|
|
582686
582784
|
}
|
|
582687
582785
|
if (!getBridgeTokenOverride()) {
|
|
582688
582786
|
const cfg = getGlobalConfig();
|
|
582689
|
-
if (cfg.bridgeOauthDeadExpiresAt != null && (cfg.bridgeOauthDeadFailCount ?? 0) >= 3 &&
|
|
582787
|
+
if (cfg.bridgeOauthDeadExpiresAt != null && (cfg.bridgeOauthDeadFailCount ?? 0) >= 3 && getClaudeAIOAuthTokens2()?.expiresAt === cfg.bridgeOauthDeadExpiresAt) {
|
|
582690
582788
|
logForDebugging(`[bridge:repl] Skipping: cross-process backoff (dead token seen ${cfg.bridgeOauthDeadFailCount} times)`);
|
|
582691
582789
|
return null;
|
|
582692
582790
|
}
|
|
582693
582791
|
try {
|
|
582694
|
-
await
|
|
582792
|
+
await checkAndRefreshOAuthTokenIfNeeded2();
|
|
582695
582793
|
} catch (error52) {
|
|
582696
582794
|
logBridgeSkip("oauth_refresh_failed", `[bridge:repl] Skipping: OAuth token refresh failed - ${errorMessage(error52)}`);
|
|
582697
582795
|
onStateChange?.("failed", errorMessage(error52));
|
|
582698
582796
|
return null;
|
|
582699
582797
|
}
|
|
582700
|
-
const tokens =
|
|
582798
|
+
const tokens = getClaudeAIOAuthTokens2();
|
|
582701
582799
|
if (tokens && tokens.expiresAt !== null && tokens.expiresAt <= Date.now()) {
|
|
582702
582800
|
logBridgeSkip("oauth_expired_unrefreshable", "[bridge:repl] Skipping: OAuth token expired and refresh failed (re-login required)");
|
|
582703
582801
|
onStateChange?.("failed", "/login");
|
|
@@ -582761,7 +582859,7 @@ async function initReplBridge(options) {
|
|
|
582761
582859
|
if (generated && gen === genSeq && lastBridgeSessionId === bridgeSessionId && !getCurrentSessionTitle(getSessionId())) {
|
|
582762
582860
|
patch2(generated, bridgeSessionId, atCount);
|
|
582763
582861
|
}
|
|
582764
|
-
});
|
|
582862
|
+
}).catch(() => {});
|
|
582765
582863
|
};
|
|
582766
582864
|
const onUserMessage = (text2, bridgeSessionId) => {
|
|
582767
582865
|
if (hasExplicitTitle || getCurrentSessionTitle(getSessionId())) {
|
|
@@ -582784,10 +582882,10 @@ async function initReplBridge(options) {
|
|
|
582784
582882
|
}
|
|
582785
582883
|
return userMessageCount >= 3;
|
|
582786
582884
|
};
|
|
582787
|
-
const initialHistoryCap =
|
|
582885
|
+
const initialHistoryCap = getFeatureValue_CACHED_WITH_REFRESH4("tengu_bridge_initial_history_cap", 200, 5 * 60 * 1000);
|
|
582788
582886
|
let orgUUID;
|
|
582789
582887
|
try {
|
|
582790
|
-
orgUUID = await
|
|
582888
|
+
orgUUID = await getOrganizationUUID2();
|
|
582791
582889
|
} catch (error52) {
|
|
582792
582890
|
logBridgeSkip("get_org_uuid_failed", `[bridge:repl] Skipping: failed to get organization UUID - ${errorMessage(error52)}`);
|
|
582793
582891
|
onStateChange?.("failed", errorMessage(error52));
|
|
@@ -582812,7 +582910,7 @@ async function initReplBridge(options) {
|
|
|
582812
582910
|
orgUUID,
|
|
582813
582911
|
title,
|
|
582814
582912
|
getAccessToken: getBridgeAccessToken,
|
|
582815
|
-
onAuth401:
|
|
582913
|
+
onAuth401: handleOAuth401Error2,
|
|
582816
582914
|
toSDKMessages,
|
|
582817
582915
|
initialHistoryCap,
|
|
582818
582916
|
initialMessages,
|
|
@@ -582865,7 +582963,7 @@ async function initReplBridge(options) {
|
|
|
582865
582963
|
getCurrentTitle: () => getCurrentSessionTitle(getSessionId()) ?? title,
|
|
582866
582964
|
onUserMessage,
|
|
582867
582965
|
toSDKMessages,
|
|
582868
|
-
onAuth401:
|
|
582966
|
+
onAuth401: handleOAuth401Error2,
|
|
582869
582967
|
getPollIntervalConfig,
|
|
582870
582968
|
initialHistoryCap,
|
|
582871
582969
|
initialMessages,
|
|
@@ -582891,9 +582989,6 @@ function deriveTitle(raw) {
|
|
|
582891
582989
|
var TITLE_MAX_LEN = 50;
|
|
582892
582990
|
var init_initReplBridge = __esm(() => {
|
|
582893
582991
|
init_state();
|
|
582894
|
-
init_growthbook();
|
|
582895
|
-
init_client2();
|
|
582896
|
-
init_auth();
|
|
582897
582992
|
init_config();
|
|
582898
582993
|
init_debug();
|
|
582899
582994
|
init_displayTags();
|