charness 3.12.0 β 3.14.0
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/.env.example +5 -0
- package/CHANGELOG.md +40 -0
- package/DEVELOPMENT.md +80 -16
- package/README.md +2 -1
- package/SETUP.md +65 -20
- package/agent-plugin/skills/charness-delegate-claude/SKILL.md +14 -5
- package/dist/accessControl.d.ts +43 -0
- package/dist/accessControl.d.ts.map +1 -1
- package/dist/accessControl.js +50 -1
- package/dist/accessControl.js.map +1 -1
- package/dist/adapters/claudeCliAdapter.d.ts.map +1 -1
- package/dist/adapters/claudeCliAdapter.js +17 -19
- package/dist/adapters/claudeCliAdapter.js.map +1 -1
- package/dist/adapters/claudeJsonStreamAdapter.d.ts +29 -10
- package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
- package/dist/adapters/claudeJsonStreamAdapter.js +73 -28
- package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
- package/dist/adapters/claudePlatformFlags.d.ts +4 -3
- package/dist/adapters/claudePlatformFlags.d.ts.map +1 -1
- package/dist/adapters/claudePlatformFlags.js +4 -3
- package/dist/adapters/claudePlatformFlags.js.map +1 -1
- package/dist/adapters/openCodeAdapter.d.ts +111 -24
- package/dist/adapters/openCodeAdapter.d.ts.map +1 -1
- package/dist/adapters/openCodeAdapter.js +288 -83
- package/dist/adapters/openCodeAdapter.js.map +1 -1
- package/dist/adapters/terminalAdapter.d.ts.map +1 -1
- package/dist/adapters/terminalAdapter.js +5 -3
- package/dist/adapters/terminalAdapter.js.map +1 -1
- package/dist/agentLogin/agentLogin.d.ts.map +1 -1
- package/dist/agentLogin/agentLogin.js +2 -14
- package/dist/agentLogin/agentLogin.js.map +1 -1
- package/dist/bot.d.ts +12 -3
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +504 -144
- package/dist/bot.js.map +1 -1
- package/dist/cli/claudeProfiles.js +2 -2
- package/dist/cli/claudeProfiles.js.map +1 -1
- package/dist/connectors/jira/client.js +1 -1
- package/dist/connectors/jira/client.js.map +1 -1
- package/dist/connectors/jira/config.d.ts +7 -0
- package/dist/connectors/jira/config.d.ts.map +1 -1
- package/dist/connectors/jira/config.js +12 -1
- package/dist/connectors/jira/config.js.map +1 -1
- package/dist/connectors/jira/connector.d.ts +7 -0
- package/dist/connectors/jira/connector.d.ts.map +1 -1
- package/dist/connectors/jira/connector.js +20 -3
- package/dist/connectors/jira/connector.js.map +1 -1
- package/dist/connectors/jira/inbound.d.ts.map +1 -1
- package/dist/connectors/jira/inbound.js +4 -3
- package/dist/connectors/jira/inbound.js.map +1 -1
- package/dist/connectors/jira/issueBlocks.d.ts +1 -1
- package/dist/connectors/jira/trustedGroup.d.ts +21 -6
- package/dist/connectors/jira/trustedGroup.d.ts.map +1 -1
- package/dist/connectors/jira/trustedGroup.js +46 -6
- package/dist/connectors/jira/trustedGroup.js.map +1 -1
- package/dist/connectors/telegram/commands/botCore.d.ts +19 -2
- package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/compaction.d.ts +5 -3
- package/dist/connectors/telegram/commands/compaction.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/compaction.js +21 -6
- package/dist/connectors/telegram/commands/compaction.js.map +1 -1
- package/dist/connectors/telegram/commands/todo.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/todo.js +2 -2
- package/dist/connectors/telegram/commands/todo.js.map +1 -1
- package/dist/connectors/telegram/commands/topicAccess.d.ts +30 -0
- package/dist/connectors/telegram/commands/topicAccess.d.ts.map +1 -0
- package/dist/connectors/telegram/commands/topicAccess.js +399 -0
- package/dist/connectors/telegram/commands/topicAccess.js.map +1 -0
- package/dist/connectors/telegram/inbound.d.ts +44 -7
- package/dist/connectors/telegram/inbound.d.ts.map +1 -1
- package/dist/connectors/telegram/inbound.js +142 -24
- package/dist/connectors/telegram/inbound.js.map +1 -1
- package/dist/i18n/de.d.ts.map +1 -1
- package/dist/i18n/de.js +68 -0
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +68 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +68 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +68 -0
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/hi.d.ts.map +1 -1
- package/dist/i18n/hi.js +68 -0
- package/dist/i18n/hi.js.map +1 -1
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ja.js +68 -0
- package/dist/i18n/ja.js.map +1 -1
- package/dist/i18n/ka.d.ts.map +1 -1
- package/dist/i18n/ka.js +68 -0
- package/dist/i18n/ka.js.map +1 -1
- package/dist/i18n/pt.d.ts.map +1 -1
- package/dist/i18n/pt.js +68 -0
- package/dist/i18n/pt.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +68 -0
- package/dist/i18n/ru.js.map +1 -1
- package/dist/i18n/uk.d.ts.map +1 -1
- package/dist/i18n/uk.js +68 -0
- package/dist/i18n/uk.js.map +1 -1
- package/dist/i18n/uz.d.ts.map +1 -1
- package/dist/i18n/uz.js +68 -0
- package/dist/i18n/uz.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +68 -0
- package/dist/i18n/zh.js.map +1 -1
- package/dist/installManager.d.ts +37 -1
- package/dist/installManager.d.ts.map +1 -1
- package/dist/installManager.js +205 -14
- package/dist/installManager.js.map +1 -1
- package/dist/legacyNames.d.ts +8 -0
- package/dist/legacyNames.d.ts.map +1 -1
- package/dist/legacyNames.js +9 -1
- package/dist/legacyNames.js.map +1 -1
- package/dist/mcpConfig.d.ts +4 -1
- package/dist/mcpConfig.d.ts.map +1 -1
- package/dist/mcpConfig.js +27 -2
- package/dist/mcpConfig.js.map +1 -1
- package/dist/platform/commandRouter.d.ts +13 -1
- package/dist/platform/commandRouter.d.ts.map +1 -1
- package/dist/platform/commandRouter.js +14 -2
- package/dist/platform/commandRouter.js.map +1 -1
- package/dist/platform/inbound.d.ts +2 -0
- package/dist/platform/inbound.d.ts.map +1 -1
- package/dist/runnerUtility/launcher.d.ts.map +1 -1
- package/dist/runnerUtility/launcher.js +11 -3
- package/dist/runnerUtility/launcher.js.map +1 -1
- package/dist/runners/runnerLock.d.ts +36 -1
- package/dist/runners/runnerLock.d.ts.map +1 -1
- package/dist/runners/runnerLock.js +94 -30
- package/dist/runners/runnerLock.js.map +1 -1
- package/dist/scheduler/checkRun.d.ts +0 -2
- package/dist/scheduler/checkRun.d.ts.map +1 -1
- package/dist/scheduler/checkRun.js +0 -10
- package/dist/scheduler/checkRun.js.map +1 -1
- package/dist/scheduler/injection.d.ts +7 -3
- package/dist/scheduler/injection.d.ts.map +1 -1
- package/dist/scheduler/injection.js +7 -3
- package/dist/scheduler/injection.js.map +1 -1
- package/dist/scheduler/mcpBoot.d.ts +10 -1
- package/dist/scheduler/mcpBoot.d.ts.map +1 -1
- package/dist/scheduler/mcpBoot.js +6 -1
- package/dist/scheduler/mcpBoot.js.map +1 -1
- package/dist/scheduler/mcpSurface.js +1 -1
- package/dist/scheduler/mcpSurface.js.map +1 -1
- package/dist/scheduler/workerActivity.d.ts.map +1 -1
- package/dist/scheduler/workerActivity.js +2 -1
- package/dist/scheduler/workerActivity.js.map +1 -1
- package/dist/selfUpdate/bootRollback.d.ts.map +1 -1
- package/dist/selfUpdate/bootRollback.js +3 -2
- package/dist/selfUpdate/bootRollback.js.map +1 -1
- package/dist/selfUpdate/updateRuntime.d.ts.map +1 -1
- package/dist/selfUpdate/updateRuntime.js +6 -3
- package/dist/selfUpdate/updateRuntime.js.map +1 -1
- package/dist/state.d.ts +50 -1
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +112 -0
- package/dist/state.js.map +1 -1
- package/dist/stateFile.d.ts.map +1 -1
- package/dist/stateFile.js +2 -1
- package/dist/stateFile.js.map +1 -1
- package/dist/testTimings.d.ts +3 -2
- package/dist/testTimings.d.ts.map +1 -1
- package/dist/testTimings.js +8 -1
- package/dist/testTimings.js.map +1 -1
- package/dist/threadContextPreamble.d.ts +15 -1
- package/dist/threadContextPreamble.d.ts.map +1 -1
- package/dist/threadContextPreamble.js +15 -3
- package/dist/threadContextPreamble.js.map +1 -1
- package/dist/threadRouting.d.ts +47 -4
- package/dist/threadRouting.d.ts.map +1 -1
- package/dist/threadRouting.js +31 -4
- package/dist/threadRouting.js.map +1 -1
- package/dist/todos/projects.d.ts +1 -1
- package/dist/todos/projects.d.ts.map +1 -1
- package/dist/todos/projects.js +3 -14
- package/dist/todos/projects.js.map +1 -1
- package/dist/topicTalkerMemory.d.ts +37 -0
- package/dist/topicTalkerMemory.d.ts.map +1 -0
- package/dist/topicTalkerMemory.js +61 -0
- package/dist/topicTalkerMemory.js.map +1 -0
- package/dist/topicTalkers.d.ts +123 -0
- package/dist/topicTalkers.d.ts.map +1 -0
- package/dist/topicTalkers.js +276 -0
- package/dist/topicTalkers.js.map +1 -0
- package/dist/types.d.ts +16 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/adoptReplayGate.d.ts +7 -5
- package/dist/utils/adoptReplayGate.d.ts.map +1 -1
- package/dist/utils/adoptReplayGate.js +7 -5
- package/dist/utils/adoptReplayGate.js.map +1 -1
- package/dist/utils/agentEnvironment.d.ts +23 -0
- package/dist/utils/agentEnvironment.d.ts.map +1 -1
- package/dist/utils/agentEnvironment.js +33 -1
- package/dist/utils/agentEnvironment.js.map +1 -1
- package/dist/utils/agentPlugin.d.ts +7 -2
- package/dist/utils/agentPlugin.d.ts.map +1 -1
- package/dist/utils/agentPlugin.js +11 -5
- package/dist/utils/agentPlugin.js.map +1 -1
- package/dist/utils/authorMark.d.ts +59 -0
- package/dist/utils/authorMark.d.ts.map +1 -0
- package/dist/utils/authorMark.js +86 -0
- package/dist/utils/authorMark.js.map +1 -0
- package/dist/utils/checkIsRecord.d.ts +6 -0
- package/dist/utils/checkIsRecord.d.ts.map +1 -0
- package/dist/utils/checkIsRecord.js +11 -0
- package/dist/utils/checkIsRecord.js.map +1 -0
- package/dist/utils/claudeCompactSummary.js +4 -4
- package/dist/utils/claudeCompactSummary.js.map +1 -1
- package/dist/utils/claudeLimitSwitch.d.ts +5 -1
- package/dist/utils/claudeLimitSwitch.d.ts.map +1 -1
- package/dist/utils/claudeLimitSwitch.js +6 -2
- package/dist/utils/claudeLimitSwitch.js.map +1 -1
- package/dist/utils/claudeMcpHeal.d.ts +18 -3
- package/dist/utils/claudeMcpHeal.d.ts.map +1 -1
- package/dist/utils/claudeMcpHeal.js +19 -4
- package/dist/utils/claudeMcpHeal.js.map +1 -1
- package/dist/utils/claudeProfileUsageLines.d.ts +1 -1
- package/dist/utils/claudeProfileUsageLines.js +3 -3
- package/dist/utils/claudeProfileUsageLines.js.map +1 -1
- package/dist/utils/claudeProfiles.d.ts +7 -0
- package/dist/utils/claudeProfiles.d.ts.map +1 -1
- package/dist/utils/claudeProfiles.js +15 -0
- package/dist/utils/claudeProfiles.js.map +1 -1
- package/dist/utils/claudeRuntimeInfo.d.ts.map +1 -1
- package/dist/utils/claudeRuntimeInfo.js +4 -6
- package/dist/utils/claudeRuntimeInfo.js.map +1 -1
- package/dist/utils/claudeStreamJson.d.ts +0 -3
- package/dist/utils/claudeStreamJson.d.ts.map +1 -1
- package/dist/utils/claudeStreamJson.js +21 -26
- package/dist/utils/claudeStreamJson.js.map +1 -1
- package/dist/utils/claudeSubagentTail.d.ts.map +1 -1
- package/dist/utils/claudeSubagentTail.js +4 -11
- package/dist/utils/claudeSubagentTail.js.map +1 -1
- package/dist/utils/claudeUsage.d.ts +56 -20
- package/dist/utils/claudeUsage.d.ts.map +1 -1
- package/dist/utils/claudeUsage.js +89 -48
- package/dist/utils/claudeUsage.js.map +1 -1
- package/dist/utils/fallbackChain.d.ts.map +1 -1
- package/dist/utils/fallbackChain.js +8 -4
- package/dist/utils/fallbackChain.js.map +1 -1
- package/dist/utils/folderGit.d.ts +9 -0
- package/dist/utils/folderGit.d.ts.map +1 -0
- package/dist/utils/folderGit.js +33 -0
- package/dist/utils/folderGit.js.map +1 -0
- package/dist/utils/forwardedMark.d.ts +8 -0
- package/dist/utils/forwardedMark.d.ts.map +1 -1
- package/dist/utils/forwardedMark.js +2 -0
- package/dist/utils/forwardedMark.js.map +1 -1
- package/dist/utils/jsonStreamHost.d.ts +2 -1
- package/dist/utils/jsonStreamHost.d.ts.map +1 -1
- package/dist/utils/jsonStreamHost.js +4 -2
- package/dist/utils/jsonStreamHost.js.map +1 -1
- package/dist/utils/messageContext.d.ts +22 -7
- package/dist/utils/messageContext.d.ts.map +1 -1
- package/dist/utils/messageContext.js +19 -5
- package/dist/utils/messageContext.js.map +1 -1
- package/dist/utils/openCodeUsage.d.ts.map +1 -1
- package/dist/utils/openCodeUsage.js +8 -10
- package/dist/utils/openCodeUsage.js.map +1 -1
- package/dist/utils/personLabel.d.ts +13 -0
- package/dist/utils/personLabel.d.ts.map +1 -0
- package/dist/utils/personLabel.js +15 -0
- package/dist/utils/personLabel.js.map +1 -0
- package/dist/utils/replyQuote.d.ts +17 -3
- package/dist/utils/replyQuote.d.ts.map +1 -1
- package/dist/utils/replyQuote.js +25 -2
- package/dist/utils/replyQuote.js.map +1 -1
- package/dist/utils/talkerAccess.d.ts +9 -0
- package/dist/utils/talkerAccess.d.ts.map +1 -0
- package/dist/utils/talkerAccess.js +20 -0
- package/dist/utils/talkerAccess.js.map +1 -0
- package/dist/utils/telegramError.d.ts.map +1 -1
- package/dist/utils/telegramError.js +5 -7
- package/dist/utils/telegramError.js.map +1 -1
- package/dist/utils/tmuxExec.d.ts +20 -8
- package/dist/utils/tmuxExec.d.ts.map +1 -1
- package/dist/utils/tmuxExec.js +27 -7
- package/dist/utils/tmuxExec.js.map +1 -1
- package/dist/utils/topicAccessScreenPlan.d.ts +253 -0
- package/dist/utils/topicAccessScreenPlan.d.ts.map +1 -0
- package/dist/utils/topicAccessScreenPlan.js +287 -0
- package/dist/utils/topicAccessScreenPlan.js.map +1 -0
- package/dist/utils/topicLabel.d.ts +12 -0
- package/dist/utils/topicLabel.d.ts.map +1 -0
- package/dist/utils/topicLabel.js +12 -0
- package/dist/utils/topicLabel.js.map +1 -0
- package/dist/utils/topicRequest.d.ts +8 -5
- package/dist/utils/topicRequest.d.ts.map +1 -1
- package/dist/utils/topicRequest.js +9 -7
- package/dist/utils/topicRequest.js.map +1 -1
- package/npm-shrinkwrap.json +1003 -0
- package/package.json +4 -2
|
@@ -29,6 +29,7 @@ exports.getOpenCodeAgentConfigDir = getOpenCodeAgentConfigDir;
|
|
|
29
29
|
exports.prepareOpenCodeAgentConfigDir = prepareOpenCodeAgentConfigDir;
|
|
30
30
|
exports.getOpenCodeAgentConfigEnv = getOpenCodeAgentConfigEnv;
|
|
31
31
|
exports.getPidlessServerLaunchReading = getPidlessServerLaunchReading;
|
|
32
|
+
exports.checkIsOpenCodeServeCommand = checkIsOpenCodeServeCommand;
|
|
32
33
|
exports.parseOpenCodeServerLaunch = parseOpenCodeServerLaunch;
|
|
33
34
|
exports.getOpenCodeAgentSkillsExpectation = getOpenCodeAgentSkillsExpectation;
|
|
34
35
|
exports.getOpenCodeAgentSkillsServerAction = getOpenCodeAgentSkillsServerAction;
|
|
@@ -157,11 +158,16 @@ function getPidlessServerLaunchReading(isServerAnswering) {
|
|
|
157
158
|
const openCodeServeCommand = 'serve';
|
|
158
159
|
const openCodeExecutableNamePrefix = 'opencode';
|
|
159
160
|
const procEntrySeparator = '\0';
|
|
160
|
-
/**
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
/**
|
|
162
|
+
* @description Whether a process's argv is an `opencode β¦ serve` (the executable's name starts with `opencode`): a test's
|
|
163
|
+
* stand-in, a runner holding a fixture server or another tool on the port is not β and is never stopped.
|
|
164
|
+
*/
|
|
165
|
+
function checkIsOpenCodeServeCommand(argv) {
|
|
166
|
+
return path_1.default.basename(argv[0] ?? '').startsWith(openCodeExecutableNamePrefix) && argv.includes(openCodeServeCommand);
|
|
167
|
+
}
|
|
168
|
+
/** @description Read a server's launch from its argv and its `/proc/<pid>/environ` contents. */
|
|
169
|
+
function parseOpenCodeServerLaunch(argv, environ) {
|
|
170
|
+
if (!checkIsOpenCodeServeCommand(argv))
|
|
165
171
|
return { kind: 'unknown' };
|
|
166
172
|
const prefix = `${exports.openCodeConfigDirEnvName}=`;
|
|
167
173
|
const entry = environ.split(procEntrySeparator).find((variable) => variable.startsWith(prefix));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentPlugin.js","sourceRoot":"","sources":["../../src/utils/agentPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;AAoBH,sDAGC;AAMD,sDAYC;AAUD,8DAgBC;AAOD,8DAEC;AAQD,sEAoBC;AASD,8DAWC;AAmBD,sEAEC;
|
|
1
|
+
{"version":3,"file":"agentPlugin.js","sourceRoot":"","sources":["../../src/utils/agentPlugin.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;AAoBH,sDAGC;AAMD,sDAYC;AAUD,8DAgBC;AAOD,8DAEC;AAQD,sEAoBC;AASD,8DAWC;AAmBD,sEAEC;AAaD,kEAEC;AAGD,8DAKC;AAmBD,8EAKC;AAWD,gFAMC;AA/MD,iDAAyC;AACzC,4CAAoB;AACpB,gDAAwB;AACxB,+BAAiC;AACjC,2DAAqG;AAErG,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,wBAAQ,CAAC,CAAC;AAC1C,uHAAuH;AACvH,MAAM,0BAA0B,GAAG,MAAM,CAAC;AAE1C,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAC7B,QAAA,wBAAwB,GAAG,QAAQ,CAAC;AAEjD;;;;GAIG;AACH,SAAgB,qBAAqB;IACnC,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI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,IAAI,EAAE,WAAW,EAAE,CAAC;IAChE,IAAI,CAAC,kBAAkB;QAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,yBAAyB,CAAC,OAAO,CAAC,EAAE,CAAC;IACpG,MAAM,SAAS,GAAG,6BAA6B,CAAC,OAAO,CAAC,CAAC;IACzD,OAAO,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AACrF,CAAC;AAUD,6GAA6G;AAC7G,SAAgB,kCAAkC,CAAC,OAAoC,EAAE,WAA2C;IAClI,IAAI,WAAW,CAAC,IAAI,KAAK,WAAW,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IAC/E,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,kBAAkB,CAAC;IAC1D,MAAM,mBAAmB,GAAG,OAAO,CAAC,SAAS,KAAK,WAAW,CAAC,SAAS,CAAC;IACxE,IAAI,mBAAmB,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,SAAS,CAAC;QAAE,OAAO,MAAM,CAAC;IAC5E,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Pure helpers for how the agent is told WHO wrote a message that is not the operator's: the mark glued
|
|
3
|
+
* ahead of such a message, and the description the reply-quote header and the request header reuse.
|
|
4
|
+
*
|
|
5
|
+
* In a topic where an admin let other people talk to the agent (`topicTalkers.ts`), everything the agent reads looks the
|
|
6
|
+
* same unless the bot says whose words they are β and a talker's words must never pass for the operator's (an
|
|
7
|
+
* instruction to read a secret, to change its own rules). Plain English (agent-facing, NOT i18n) and structural, like
|
|
8
|
+
* `forwardedMark.ts`, whose cleaning of third-party text it reuses: a name is chosen by its owner and must not take part
|
|
9
|
+
* in the mark's own syntax.
|
|
10
|
+
*/
|
|
11
|
+
/** The two kinds of author who are not the operator: what each is called to the agent. */
|
|
12
|
+
declare const authorKindLabels: {
|
|
13
|
+
/** On the list of the topic (or General's group-wide one): allowed to talk to the agent here. */
|
|
14
|
+
readonly talker: "topic member";
|
|
15
|
+
/** A member of the group nobody allowed to talk to the agent: its words are only ever quoted, as untrusted text. */
|
|
16
|
+
readonly other: "group member";
|
|
17
|
+
};
|
|
18
|
+
/** @name NonOperatorAuthorKind @description Who wrote a message that is not the operator's. */
|
|
19
|
+
export type NonOperatorAuthorKind = keyof typeof authorKindLabels;
|
|
20
|
+
/** What the bot knows of an author: the name Telegram shows and the @username, when there is one. */
|
|
21
|
+
export interface MessageAuthorSource {
|
|
22
|
+
/** The display name; empty when Telegram gave none (a channel's post carries the channel's title instead). */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Without a leading `@`. */
|
|
25
|
+
username?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* @description Who wrote a message, as the agent reads it: `topic member "Alice Smith" (@alice)`. The name is quoted, so
|
|
29
|
+
* the author cannot be told apart from what they say.
|
|
30
|
+
*/
|
|
31
|
+
export declare function describeMessageAuthor(kind: NonOperatorAuthorKind, source: MessageAuthorSource): string;
|
|
32
|
+
/**
|
|
33
|
+
* @description The mark that leads a message of a non-operator author:
|
|
34
|
+
* `[Message from topic member "Alice Smith" (@alice) Β· not the operator]`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildMessageAuthorMark(kind: NonOperatorAuthorKind, source: MessageAuthorSource): string;
|
|
37
|
+
/**
|
|
38
|
+
* @description The words of somebody who is not the operator, made unable to pass for the bot's own lines. The bot's headers
|
|
39
|
+
* always open a line with `[`, and a message's words end only where the next such header begins β so a person's words must
|
|
40
|
+
* never hold a line that opens with `[`: a forged `[Request β¦]` or `[Replying to an earlier message Β· from: user]` would
|
|
41
|
+
* read as a separate message of the operator's in the same prompt. Every kind of line break becomes `\n` first (so a header
|
|
42
|
+
* after a carriage return is a line of its own to the pattern, as it is to a reader), the other control characters go, then
|
|
43
|
+
* each line-leading `[` is escaped as `\[` β still readable as what they wrote, never a header. Idempotent.
|
|
44
|
+
*/
|
|
45
|
+
export declare function neutraliseHeaderLookalikes(text: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* @description What an answer to the agent's own question carries when somebody other than the operator gave it:
|
|
48
|
+
* `(answered by topic member "Alice Smith" (@alice), not the operator)`. The agent's question is its way to ask the operator
|
|
49
|
+
* before it acts, so an answer must say who chose it β a plain label would read as the operator's Β«yesΒ».
|
|
50
|
+
*/
|
|
51
|
+
export declare function buildAnswerAttribution(senderDescription: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* @description The chosen option label(s) of one question with the attribution after the last one β one per answer, so in a
|
|
54
|
+
* question of several parts each part says who chose it. The agent (Claude's answers map, OpenCode's reply matrix) takes a
|
|
55
|
+
* label that is no option as the answer's own text.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getAnswerWithAttribution(labels: readonly string[], senderDescription: string): string[];
|
|
58
|
+
export {};
|
|
59
|
+
//# sourceMappingURL=authorMark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorMark.d.ts","sourceRoot":"","sources":["../../src/utils/authorMark.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,0FAA0F;AAC1F,QAAA,MAAM,gBAAgB;IACpB,iGAAiG;;IAEjG,oHAAoH;;CAE5G,CAAC;AAEX,+FAA+F;AAC/F,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAElE,qGAAqG;AACrG,MAAM,WAAW,mBAAmB;IAClC,8GAA8G;IAC9G,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAQD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAKtG;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAEvG;AAYD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,iBAAiB,EAAE,MAAM,GAAG,MAAM,EAAE,CAIvG"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description Pure helpers for how the agent is told WHO wrote a message that is not the operator's: the mark glued
|
|
4
|
+
* ahead of such a message, and the description the reply-quote header and the request header reuse.
|
|
5
|
+
*
|
|
6
|
+
* In a topic where an admin let other people talk to the agent (`topicTalkers.ts`), everything the agent reads looks the
|
|
7
|
+
* same unless the bot says whose words they are β and a talker's words must never pass for the operator's (an
|
|
8
|
+
* instruction to read a secret, to change its own rules). Plain English (agent-facing, NOT i18n) and structural, like
|
|
9
|
+
* `forwardedMark.ts`, whose cleaning of third-party text it reuses: a name is chosen by its owner and must not take part
|
|
10
|
+
* in the mark's own syntax.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.describeMessageAuthor = describeMessageAuthor;
|
|
14
|
+
exports.buildMessageAuthorMark = buildMessageAuthorMark;
|
|
15
|
+
exports.neutraliseHeaderLookalikes = neutraliseHeaderLookalikes;
|
|
16
|
+
exports.buildAnswerAttribution = buildAnswerAttribution;
|
|
17
|
+
exports.getAnswerWithAttribution = getAnswerWithAttribution;
|
|
18
|
+
const forwardedMark_1 = require("./forwardedMark");
|
|
19
|
+
const stripControlCharacters_1 = require("./stripControlCharacters");
|
|
20
|
+
/** The two kinds of author who are not the operator: what each is called to the agent. */
|
|
21
|
+
const authorKindLabels = {
|
|
22
|
+
/** On the list of the topic (or General's group-wide one): allowed to talk to the agent here. */
|
|
23
|
+
talker: 'topic member',
|
|
24
|
+
/** A member of the group nobody allowed to talk to the agent: its words are only ever quoted, as untrusted text. */
|
|
25
|
+
other: 'group member',
|
|
26
|
+
};
|
|
27
|
+
/** Fallback for an author with no name at all. */
|
|
28
|
+
const unknownAuthorName = 'unknown';
|
|
29
|
+
/** Tail of the mark: what the agent must take from it. */
|
|
30
|
+
const authorMarkTail = 'not the operator';
|
|
31
|
+
/**
|
|
32
|
+
* @description Who wrote a message, as the agent reads it: `topic member "Alice Smith" (@alice)`. The name is quoted, so
|
|
33
|
+
* the author cannot be told apart from what they say.
|
|
34
|
+
*/
|
|
35
|
+
function describeMessageAuthor(kind, source) {
|
|
36
|
+
const cleanName = (0, forwardedMark_1.cleanThirdPartyText)(source.name);
|
|
37
|
+
const name = cleanName ? (0, forwardedMark_1.quoteCleanText)(cleanName) : unknownAuthorName;
|
|
38
|
+
const cleanUsername = source.username ? (0, forwardedMark_1.cleanThirdPartyText)(source.username) : '';
|
|
39
|
+
return `${authorKindLabels[kind]} ${name}${cleanUsername ? ` (@${cleanUsername})` : ''}`;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @description The mark that leads a message of a non-operator author:
|
|
43
|
+
* `[Message from topic member "Alice Smith" (@alice) Β· not the operator]`.
|
|
44
|
+
*/
|
|
45
|
+
function buildMessageAuthorMark(kind, source) {
|
|
46
|
+
return `[Message from ${describeMessageAuthor(kind, source)} Β· ${authorMarkTail}]`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A line that opens with `[`, after any horizontal whitespace or invisible characters (zero-width spaces, a byte-order mark):
|
|
50
|
+
* the shape of every header the bot itself puts into a prompt (`[Request β¦]`, `[Replying to β¦]`, `[Telegram thread context]`,
|
|
51
|
+
* `[Held over β¦]`). The leading part is kept in group 1.
|
|
52
|
+
*/
|
|
53
|
+
const headerLookalikePattern = /^((?:[^\S\n]|[\u200b-\u200d\u2060\ufeff])*)\[/gm;
|
|
54
|
+
/** The line breaks other than `\n` β a carriage return, NEL, the Unicode line and paragraph separators β which a reader takes for one. */
|
|
55
|
+
const otherLineBreakPattern = /\r\n|[\r\u0085\u2028\u2029]/g;
|
|
56
|
+
/**
|
|
57
|
+
* @description The words of somebody who is not the operator, made unable to pass for the bot's own lines. The bot's headers
|
|
58
|
+
* always open a line with `[`, and a message's words end only where the next such header begins β so a person's words must
|
|
59
|
+
* never hold a line that opens with `[`: a forged `[Request β¦]` or `[Replying to an earlier message Β· from: user]` would
|
|
60
|
+
* read as a separate message of the operator's in the same prompt. Every kind of line break becomes `\n` first (so a header
|
|
61
|
+
* after a carriage return is a line of its own to the pattern, as it is to a reader), the other control characters go, then
|
|
62
|
+
* each line-leading `[` is escaped as `\[` β still readable as what they wrote, never a header. Idempotent.
|
|
63
|
+
*/
|
|
64
|
+
function neutraliseHeaderLookalikes(text) {
|
|
65
|
+
return (0, stripControlCharacters_1.stripControlCharacters)(text.replace(otherLineBreakPattern, '\n')).replace(headerLookalikePattern, '$1\\[');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @description What an answer to the agent's own question carries when somebody other than the operator gave it:
|
|
69
|
+
* `(answered by topic member "Alice Smith" (@alice), not the operator)`. The agent's question is its way to ask the operator
|
|
70
|
+
* before it acts, so an answer must say who chose it β a plain label would read as the operator's Β«yesΒ».
|
|
71
|
+
*/
|
|
72
|
+
function buildAnswerAttribution(senderDescription) {
|
|
73
|
+
return `(answered by ${senderDescription}, ${authorMarkTail})`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @description The chosen option label(s) of one question with the attribution after the last one β one per answer, so in a
|
|
77
|
+
* question of several parts each part says who chose it. The agent (Claude's answers map, OpenCode's reply matrix) takes a
|
|
78
|
+
* label that is no option as the answer's own text.
|
|
79
|
+
*/
|
|
80
|
+
function getAnswerWithAttribution(labels, senderDescription) {
|
|
81
|
+
const attribution = buildAnswerAttribution(senderDescription);
|
|
82
|
+
if (labels.length === 0)
|
|
83
|
+
return [attribution];
|
|
84
|
+
return labels.map((label, index) => (index === labels.length - 1 ? `${label} ${attribution}` : label));
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=authorMark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorMark.js","sourceRoot":"","sources":["../../src/utils/authorMark.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAkCH,sDAKC;AAMD,wDAEC;AAoBD,gEAEC;AAOD,wDAEC;AAOD,4DAIC;AAvFD,mDAAsE;AACtE,qEAAkE;AAElE,0FAA0F;AAC1F,MAAM,gBAAgB,GAAG;IACvB,iGAAiG;IACjG,MAAM,EAAE,cAAc;IACtB,oHAAoH;IACpH,KAAK,EAAE,cAAc;CACb,CAAC;AAaX,kDAAkD;AAClD,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC,0DAA0D;AAC1D,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAE1C;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,IAA2B,EAAE,MAA2B;IAC5F,MAAM,SAAS,GAAG,IAAA,mCAAmB,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,IAAA,8BAAc,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC;IACvE,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAA,mCAAmB,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAClF,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC3F,CAAC;AAED;;;GAGG;AACH,SAAgB,sBAAsB,CAAC,IAA2B,EAAE,MAA2B;IAC7F,OAAO,iBAAiB,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;AACrF,CAAC;AAED;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,iDAAiD,CAAC;AAEjF,0IAA0I;AAC1I,MAAM,qBAAqB,GAAG,8BAA8B,CAAC;AAE7D;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CAAC,IAAY;IACrD,OAAO,IAAA,+CAAsB,EAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;AACpH,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,iBAAyB;IAC9D,OAAO,gBAAgB,iBAAiB,KAAK,cAAc,GAAG,CAAC;AACjE,CAAC;AAED;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,MAAyB,EAAE,iBAAyB;IAC3F,MAAM,WAAW,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;IAC9D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC9C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;AACzG,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Narrow an untyped value (a `JSON.parse` result, a control-channel payload) to a plain object β not `null`, not an
|
|
3
|
+
* array. The parse-boundary guard for data the bot does not control.
|
|
4
|
+
*/
|
|
5
|
+
export declare function checkIsRecord(value: unknown): value is Record<string, unknown>;
|
|
6
|
+
//# sourceMappingURL=checkIsRecord.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkIsRecord.d.ts","sourceRoot":"","sources":["../../src/utils/checkIsRecord.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE9E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIsRecord = checkIsRecord;
|
|
4
|
+
/**
|
|
5
|
+
* @description Narrow an untyped value (a `JSON.parse` result, a control-channel payload) to a plain object β not `null`, not an
|
|
6
|
+
* array. The parse-boundary guard for data the bot does not control.
|
|
7
|
+
*/
|
|
8
|
+
function checkIsRecord(value) {
|
|
9
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=checkIsRecord.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkIsRecord.js","sourceRoot":"","sources":["../../src/utils/checkIsRecord.ts"],"names":[],"mappings":";;AAIA,sCAEC;AAND;;;GAGG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -40,7 +40,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.readLatestCompactSummaryFromTranscript = readLatestCompactSummaryFromTranscript;
|
|
42
42
|
const fs = __importStar(require("fs"));
|
|
43
|
-
const
|
|
43
|
+
const checkIsRecord_1 = require("./checkIsRecord");
|
|
44
44
|
/**
|
|
45
45
|
* The key a line must carry to be a compaction summary. Checked on the raw line BEFORE `JSON.parse`: a transcript can be
|
|
46
46
|
* a hundred megabytes, almost none of it a summary, and parsing every line blocks the bot's event loop for seconds.
|
|
@@ -73,9 +73,9 @@ function readLatestCompactSummaryFromTranscript(filePath) {
|
|
|
73
73
|
catch {
|
|
74
74
|
continue;
|
|
75
75
|
}
|
|
76
|
-
if (!(0,
|
|
76
|
+
if (!(0, checkIsRecord_1.checkIsRecord)(obj) || obj.isCompactSummary !== true)
|
|
77
77
|
continue;
|
|
78
|
-
const message = (0,
|
|
78
|
+
const message = (0, checkIsRecord_1.checkIsRecord)(obj.message) ? obj.message : null;
|
|
79
79
|
const content = message?.content;
|
|
80
80
|
if (typeof content === 'string' && content.trim()) {
|
|
81
81
|
summary = content;
|
|
@@ -83,7 +83,7 @@ function readLatestCompactSummaryFromTranscript(filePath) {
|
|
|
83
83
|
else if (Array.isArray(content)) {
|
|
84
84
|
const chunks = [];
|
|
85
85
|
for (const block of content) {
|
|
86
|
-
if ((0,
|
|
86
|
+
if ((0, checkIsRecord_1.checkIsRecord)(block) && block.type === 'text' && typeof block.text === 'string') {
|
|
87
87
|
chunks.push(block.text);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeCompactSummary.js","sourceRoot":"","sources":["../../src/utils/claudeCompactSummary.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBH,wFA4BC;AA7CD,uCAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"claudeCompactSummary.js","sourceRoot":"","sources":["../../src/utils/claudeCompactSummary.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBH,wFA4BC;AA7CD,uCAAyB;AACzB,mDAAgD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KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACpF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBAC1B,CAAC;YACH,CAAC;YACD,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE;gBAAE,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -18,7 +18,11 @@ export { resolveClaudeAutoSwitchOnLimitEnabled } from './autoContinueOnLimit';
|
|
|
18
18
|
* below the launch ceiling (`checkIsClaudeProfileLaunchable`) β and not the profile that just hit the limit. The order is
|
|
19
19
|
* the launch pick's: the account whose weekly window resets soonest first (`sortClaudeProfilesByLaunchRank`), the one
|
|
20
20
|
* ranking a new agent's account too. A profile whose usage is unknown or stale is left out on purpose β the switch is sold
|
|
21
|
-
* as "this one has room", and a guess could land the topic in a second limit
|
|
21
|
+
* as "this one has room", and a guess could land the topic in a second limit β except a stale one whose every window has
|
|
22
|
+
* since passed its reset: only the old windows are known to be over (what the account has used since, through a login on
|
|
23
|
+
* another machine or host user, is not visible here), but an idle account whose token expired (no CLI run renews it, no poll
|
|
24
|
+
* can re-read it) would otherwise stay out for good; if it was used elsewhere in the meantime, the topic meets the limit
|
|
25
|
+
* again and the chain moves it on. An account billed to API credits is never
|
|
22
26
|
* one of them: it has no windows to have room on, and only the operator decides to spend money (the chain's rung).
|
|
23
27
|
*/
|
|
24
28
|
export declare function pickClaudeLimitSwitchCandidates(input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeLimitSwitch.d.ts","sourceRoot":"","sources":["../../src/utils/claudeLimitSwitch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"claudeLimitSwitch.d.ts","sourceRoot":"","sources":["../../src/utils/claudeLimitSwitch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAML,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAC;AAEvB,gHAAgH;AAChH,OAAO,EAAE,qCAAqC,EAAE,MAAM,uBAAuB,CAAC;AAE9E;;;;;;;;;;;;GAYG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE;IACrD,QAAQ,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC5C,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,EAAE,CAQX;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE;IAC/C,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACvC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB,GAAG,MAAM,CAWT"}
|
|
@@ -24,14 +24,18 @@ Object.defineProperty(exports, "resolveClaudeAutoSwitchOnLimitEnabled", { enumer
|
|
|
24
24
|
* below the launch ceiling (`checkIsClaudeProfileLaunchable`) β and not the profile that just hit the limit. The order is
|
|
25
25
|
* the launch pick's: the account whose weekly window resets soonest first (`sortClaudeProfilesByLaunchRank`), the one
|
|
26
26
|
* ranking a new agent's account too. A profile whose usage is unknown or stale is left out on purpose β the switch is sold
|
|
27
|
-
* as "this one has room", and a guess could land the topic in a second limit
|
|
27
|
+
* as "this one has room", and a guess could land the topic in a second limit β except a stale one whose every window has
|
|
28
|
+
* since passed its reset: only the old windows are known to be over (what the account has used since, through a login on
|
|
29
|
+
* another machine or host user, is not visible here), but an idle account whose token expired (no CLI run renews it, no poll
|
|
30
|
+
* can re-read it) would otherwise stay out for good; if it was used elsewhere in the meantime, the topic meets the limit
|
|
31
|
+
* again and the chain moves it on. An account billed to API credits is never
|
|
28
32
|
* one of them: it has no windows to have room on, and only the operator decides to spend money (the chain's rung).
|
|
29
33
|
*/
|
|
30
34
|
function pickClaudeLimitSwitchCandidates(input) {
|
|
31
35
|
const kinds = (0, claudeUsage_1.getRelevantClaudeUsageKinds)(input.model);
|
|
32
36
|
const candidates = input.profiles.filter((profile) => profile.name !== input.currentName
|
|
33
37
|
&& profile.loggedIn === true
|
|
34
|
-
&& profile.usage?.isStale !== true
|
|
38
|
+
&& (profile.usage?.isStale !== true || (0, claudeUsage_1.checkHaveClaudeUsageWindowsReset)(profile.usage, input.model, input.nowMs))
|
|
35
39
|
&& kinds.some((kind) => (0, claudeUsage_1.getClaudeUsageBucket)(profile.usage, kind) !== null)
|
|
36
40
|
&& (0, claudeUsage_1.checkIsClaudeProfileLaunchable)(profile, input.model, input.nowMs));
|
|
37
41
|
return (0, claudeUsage_1.sortClaudeProfilesByLaunchRank)(candidates, input.model, input.nowMs).map((profile) => profile.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeLimitSwitch.js","sourceRoot":"","sources":["../../src/utils/claudeLimitSwitch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;
|
|
1
|
+
{"version":3,"file":"claudeLimitSwitch.js","sourceRoot":"","sources":["../../src/utils/claudeLimitSwitch.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AA4BH,0EAcC;AAOD,8DAiBC;AAhED,+CAQuB;AAEvB,gHAAgH;AAChH,6DAA8E;AAArE,4IAAA,qCAAqC,OAAA;AAE9C;;;;;;;;;;;;GAYG;AACH,SAAgB,+BAA+B,CAAC,KAM/C;IACC,MAAM,KAAK,GAAG,IAAA,yCAA2B,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvD,MAAM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AI,cAAc,GAAG,KAAK,CAAC,KAAK;YAC/D,CAAC,CAAC,cAAc;YAChB,CAAC,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC;IACrC,MAAM,UAAU,GAAG,KAAK,CAAC,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAC7G,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,OAAO;QAAE,OAAO,GAAG,UAAU,CAAC;IAC9E,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description The wire shapes + the decision behind healing a `claude` session
|
|
3
|
-
* whose bot-injected MCP server (`
|
|
3
|
+
* whose bot-injected MCP server (`charness`) has latched `failed`.
|
|
4
4
|
*
|
|
5
5
|
* WHY this exists: a json-stream session is an EXTERNAL process, so it survives
|
|
6
6
|
* every bot restart β but the MCP client inside it does not retry a server it
|
|
7
7
|
* once failed to reach. A session that was alive across a restart therefore kept
|
|
8
|
-
* reporting `{name:'
|
|
8
|
+
* reporting `{name:'charness', status:'failed'}` for the rest of its life and
|
|
9
9
|
* lost `schedule_*` / `compact_conversation` / `send_file_to_user` /
|
|
10
10
|
* `send_messages_to_user` with nothing short of replacing the session to bring
|
|
11
11
|
* them back. The CLI answers `mcp_status` / `mcp_reconnect` on the SAME stdio
|
|
@@ -55,11 +55,14 @@ export type McpHealDecision = 'reconnect' | 'healthy' | 'skip';
|
|
|
55
55
|
* - `healthy` β nothing was wrong, no frame written beyond the status ask.
|
|
56
56
|
* - `skipped` β the status says a reconnect is not the right move
|
|
57
57
|
* ({@link decideMcpHeal}).
|
|
58
|
+
* - `healedLegacy` β as `healed`, but it was the server's pre-rename name that
|
|
59
|
+
* was listed and reconnected: an agent started before the rename (see
|
|
60
|
+
* `legacySchedulerMcpServerName`).
|
|
58
61
|
* - `unavailable` β the heal could not be completed: no live session, the CLI
|
|
59
62
|
* never answered (or refused) the status ask, or the reconnect itself was
|
|
60
63
|
* refused. In every case the server is still whatever it was.
|
|
61
64
|
*/
|
|
62
|
-
export type McpHealOutcome = 'healed' | 'healthy' | 'skipped' | 'unavailable';
|
|
65
|
+
export type McpHealOutcome = 'healed' | 'healedLegacy' | 'healthy' | 'skipped' | 'unavailable';
|
|
63
66
|
/** Build the `mcp_status` control request (`requestId` is echoed back in the
|
|
64
67
|
* response's `request_id`, which is how the reply is matched). */
|
|
65
68
|
export declare function buildMcpStatusControlRequest(requestId: string): McpStatusControlRequest;
|
|
@@ -74,6 +77,18 @@ export declare function buildMcpReconnectControlRequest(requestId: string, serve
|
|
|
74
77
|
* {@link decideMcpHeal} deliberately refuses to act on.
|
|
75
78
|
*/
|
|
76
79
|
export declare function getMcpServerStatus(payload: Record<string, unknown> | null, serverName: string): string | null;
|
|
80
|
+
/** One server a status payload lists, under the name it was found by. */
|
|
81
|
+
export interface ListedMcpServer {
|
|
82
|
+
name: string;
|
|
83
|
+
status: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* @description The first of `serverNames` that the status payload lists with a readable status. The caller gives the current name
|
|
87
|
+
* first and the pre-rename one after it: an agent started before the rename still holds its server under the old name, and the
|
|
88
|
+
* decision must not read its absence under the new one as "nothing to repair". `null` when none is listed β "unknown", which
|
|
89
|
+
* {@link decideMcpHeal} deliberately refuses to act on.
|
|
90
|
+
*/
|
|
91
|
+
export declare function findListedMcpServer(payload: Record<string, unknown> | null, serverNames: readonly string[]): ListedMcpServer | null;
|
|
77
92
|
/**
|
|
78
93
|
* @description Decide what a reported MCP server status calls for.
|
|
79
94
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeMcpHeal.d.ts","sourceRoot":"","sources":["../../src/utils/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;;;;GAcG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,cAAc,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAC;AAO/F;mEACmE;AACnE,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,uBAAuB,CAEvF;AAED;qEACqE;AACrE,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,0BAA0B,CAEjH;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS7G;AAED,yEAAyE;AACzE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EAAE,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,eAAe,GAAG,IAAI,CAMnI;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,eAAe,CAIpE"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @description The wire shapes + the decision behind healing a `claude` session
|
|
4
|
-
* whose bot-injected MCP server (`
|
|
4
|
+
* whose bot-injected MCP server (`charness`) has latched `failed`.
|
|
5
5
|
*
|
|
6
6
|
* WHY this exists: a json-stream session is an EXTERNAL process, so it survives
|
|
7
7
|
* every bot restart β but the MCP client inside it does not retry a server it
|
|
8
8
|
* once failed to reach. A session that was alive across a restart therefore kept
|
|
9
|
-
* reporting `{name:'
|
|
9
|
+
* reporting `{name:'charness', status:'failed'}` for the rest of its life and
|
|
10
10
|
* lost `schedule_*` / `compact_conversation` / `send_file_to_user` /
|
|
11
11
|
* `send_messages_to_user` with nothing short of replacing the session to bring
|
|
12
12
|
* them back. The CLI answers `mcp_status` / `mcp_reconnect` on the SAME stdio
|
|
@@ -23,8 +23,9 @@ exports.mcpControlRequestTimeoutMs = void 0;
|
|
|
23
23
|
exports.buildMcpStatusControlRequest = buildMcpStatusControlRequest;
|
|
24
24
|
exports.buildMcpReconnectControlRequest = buildMcpReconnectControlRequest;
|
|
25
25
|
exports.getMcpServerStatus = getMcpServerStatus;
|
|
26
|
+
exports.findListedMcpServer = findListedMcpServer;
|
|
26
27
|
exports.decideMcpHeal = decideMcpHeal;
|
|
27
|
-
const
|
|
28
|
+
const checkIsRecord_1 = require("./checkIsRecord");
|
|
28
29
|
/**
|
|
29
30
|
* @description How long to wait for ONE control round-trip before treating the
|
|
30
31
|
* server status as unknown. The channel is loopback stdio answered by a process
|
|
@@ -61,12 +62,26 @@ function getMcpServerStatus(payload, serverName) {
|
|
|
61
62
|
if (!Array.isArray(servers))
|
|
62
63
|
return null;
|
|
63
64
|
for (const entry of servers) {
|
|
64
|
-
if (!(0,
|
|
65
|
+
if (!(0, checkIsRecord_1.checkIsRecord)(entry) || entry.name !== serverName)
|
|
65
66
|
continue;
|
|
66
67
|
return typeof entry.status === 'string' ? entry.status : null;
|
|
67
68
|
}
|
|
68
69
|
return null;
|
|
69
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* @description The first of `serverNames` that the status payload lists with a readable status. The caller gives the current name
|
|
73
|
+
* first and the pre-rename one after it: an agent started before the rename still holds its server under the old name, and the
|
|
74
|
+
* decision must not read its absence under the new one as "nothing to repair". `null` when none is listed β "unknown", which
|
|
75
|
+
* {@link decideMcpHeal} deliberately refuses to act on.
|
|
76
|
+
*/
|
|
77
|
+
function findListedMcpServer(payload, serverNames) {
|
|
78
|
+
for (const name of serverNames) {
|
|
79
|
+
const status = getMcpServerStatus(payload, name);
|
|
80
|
+
if (status !== null)
|
|
81
|
+
return { name, status };
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
70
85
|
/**
|
|
71
86
|
* @description Decide what a reported MCP server status calls for.
|
|
72
87
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeMcpHeal.js","sourceRoot":"","sources":["../../src/utils/claudeMcpHeal.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;
|
|
1
|
+
{"version":3,"file":"claudeMcpHeal.js","sourceRoot":"","sources":["../../src/utils/claudeMcpHeal.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAyDH,oEAEC;AAID,0EAEC;AASD,gDASC;AAcD,kDAMC;AAgBD,sCAIC;AAzHD,mDAAgD;AAEhD;;;;;;GAMG;AACU,QAAA,0BAA0B,GAAG,KAAK,CAAC;AAuChD,2EAA2E;AAC3E,MAAM,kBAAkB,GAAG,WAAW,CAAC;AACvC,mFAAmF;AACnF,MAAM,eAAe,GAAG,QAAQ,CAAC;AAEjC;mEACmE;AACnE,SAAgB,4BAA4B,CAAC,SAAiB;IAC5D,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE,CAAC;AAChG,CAAC;AAED;qEACqE;AACrE,SAAgB,+BAA+B,CAAC,SAAiB,EAAE,UAAkB;IACnF,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,CAAC;AAC/G,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,OAAuC,EAAE,UAAkB;IAC5F,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACzC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAA,6BAAa,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;YAAE,SAAS;QACjE,OAAO,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IAChE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAQD;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,OAAuC,EAAE,WAA8B;IACzG,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,kBAAkB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACjD,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC/C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,aAAa,CAAC,MAAqB;IACjD,IAAI,MAAM,KAAK,kBAAkB;QAAE,OAAO,SAAS,CAAC;IACpD,IAAI,MAAM,KAAK,eAAe;QAAE,OAAO,WAAW,CAAC;IACnD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -25,7 +25,7 @@ export interface ClaudeProfileUsageSource {
|
|
|
25
25
|
/**
|
|
26
26
|
* @description The profile's usage as display lines: the windows as `used% π reset` β 5h and weekly always (`β`
|
|
27
27
|
* for one the snapshot lacks), Fable only when the account HAS that window (a corporate seat has none: nothing
|
|
28
|
-
* is written about it) β `(stale)` when the last poll could not refresh, and the limit mark while it holds, the
|
|
28
|
+
* is written about it; a window whose reset has passed since it was read shows a bare `0%`, no countdown) β `(stale)` when the last poll could not refresh, and the limit mark while it holds, the
|
|
29
29
|
* reset instant in `timezone`, and the used-up-credits mark while it holds. An account billed to API credits has no
|
|
30
30
|
* windows (its row already says it pays per use): what it spent through the bot and the one credit line
|
|
31
31
|
* (`utils/claudeApiCredit.ts`: the spend of the credit period, the operator's figure when there is one, and the Β«probably
|
|
@@ -19,7 +19,7 @@ function getRelativeResetWords() {
|
|
|
19
19
|
/**
|
|
20
20
|
* @description The profile's usage as display lines: the windows as `used% π reset` β 5h and weekly always (`β`
|
|
21
21
|
* for one the snapshot lacks), Fable only when the account HAS that window (a corporate seat has none: nothing
|
|
22
|
-
* is written about it) β `(stale)` when the last poll could not refresh, and the limit mark while it holds, the
|
|
22
|
+
* is written about it; a window whose reset has passed since it was read shows a bare `0%`, no countdown) β `(stale)` when the last poll could not refresh, and the limit mark while it holds, the
|
|
23
23
|
* reset instant in `timezone`, and the used-up-credits mark while it holds. An account billed to API credits has no
|
|
24
24
|
* windows (its row already says it pays per use): what it spent through the bot and the one credit line
|
|
25
25
|
* (`utils/claudeApiCredit.ts`: the spend of the credit period, the operator's figure when there is one, and the Β«probably
|
|
@@ -34,10 +34,10 @@ function formatClaudeProfileUsageLines(source, timezone, nowMs) {
|
|
|
34
34
|
if (usage && usage.buckets.length > 0) {
|
|
35
35
|
const words = getRelativeResetWords();
|
|
36
36
|
// An unknown 5h reset shows the weekly window's instead (with neither, the bare percent).
|
|
37
|
-
const
|
|
37
|
+
const weeklyBucket = (0, claudeUsage_1.getClaudeUsageBucket)(usage, 'weekly_all');
|
|
38
38
|
const read = (kind) => (0, claudeUsage_1.formatClaudeUsageBucket)((0, claudeUsage_1.getClaudeUsageBucket)(usage, kind), nowMs, {
|
|
39
39
|
words,
|
|
40
|
-
|
|
40
|
+
fallbackBucket: kind === 'session' ? weeklyBucket : null,
|
|
41
41
|
});
|
|
42
42
|
const stale = usage.isStale ? (0, i18n_1.t)('account.row.usageStale') : '';
|
|
43
43
|
const hasFable = (0, claudeUsage_1.getClaudeUsageBucket)(usage, 'weekly_scoped') !== null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeProfileUsageLines.js","sourceRoot":"","sources":["../../src/utils/claudeProfileUsageLines.ts"],"names":[],"mappings":";;AAwDA,sEAuBC;AA8ED,8DAEC;AA/JD;;;GAGG;AACH,kCAA4B;AAE5B,qDAAuF;AACvF,uDAAoJ;AACpJ,+CAOuB;AAuBvB,wHAAwH;AACxH,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAEvC,4DAA4D;AAC5D,SAAS,qBAAqB;IAC5B,OAAO,EAAE,OAAO,EAAE,IAAA,QAAC,EAAC,eAAe,CAAC,EAAE,GAAG,EAAE,IAAA,QAAC,EAAC,eAAe,CAAC,EAAE,IAAI,EAAE,IAAA,QAAC,EAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAA,QAAC,EAAC,kBAAkB,CAAC,EAAE,CAAC;AAC5H,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,6BAA6B,CAAC,MAA4C,EAAE,QAAgB,EAAE,KAAa;IACzH,IAAI,MAAM,EAAE,OAAO,KAAK,KAAK;QAAE,OAAO,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IACrF,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC;IAC5B,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAC;QACtC,0FAA0F;QAC1F,MAAM,
|
|
1
|
+
{"version":3,"file":"claudeProfileUsageLines.js","sourceRoot":"","sources":["../../src/utils/claudeProfileUsageLines.ts"],"names":[],"mappings":";;AAwDA,sEAuBC;AA8ED,8DAEC;AA/JD;;;GAGG;AACH,kCAA4B;AAE5B,qDAAuF;AACvF,uDAAoJ;AACpJ,+CAOuB;AAuBvB,wHAAwH;AACxH,MAAM,kBAAkB,GAAG,WAAW,CAAC;AAEvC,4DAA4D;AA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,EAAE,KAAK,CAAC,EAAE,CAAC;SACrI,CAAC,CAAC;IACL,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI;YACxD,CAAC,CAAC,IAAA,QAAC,EAAC,sCAAsC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAA,0BAAS,EAAC,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,IAAA,0BAAS,EAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;YACjI,CAAC,CAAC,IAAA,QAAC,EAAC,8BAA8B,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,oHAAoH;AACpH,SAAgB,yBAAyB,CAAC,KAAqB,EAAE,QAAgB,EAAE,KAAa;IAC9F,OAAO,EAAE,KAAK,EAAE,IAAA,0BAAS,EAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAA,oCAAmB,EAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,IAAA,0BAAS,EAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC;AAC5I,CAAC"}
|
|
@@ -181,6 +181,13 @@ export type ClaudeAccountKind = 'personal' | 'corporate' | 'unknown';
|
|
|
181
181
|
/** Personal (`pro`, `max`) versus corporate (`team`, `enterprise`) subscription, from the CLI's `subscriptionType`. */
|
|
182
182
|
export declare function getClaudeAccountKind(subscriptionType: string | null): ClaudeAccountKind;
|
|
183
183
|
export declare const claudeConfigDirVariableName = "CLAUDE_CONFIG_DIR";
|
|
184
|
+
/**
|
|
185
|
+
* @description The environment a `claude auth β¦` process runs with (a sign-in, an auth-status probe): the bot's own
|
|
186
|
+
* without its secrets and without `ANTHROPIC_API_KEY` (the subscription login, never the metered console path), plus
|
|
187
|
+
* `CLAUDE_CONFIG_DIR` for a profile's directory (`null` = `~/.claude`) β the login must land in THAT directory, and the
|
|
188
|
+
* status probe must read the same one.
|
|
189
|
+
*/
|
|
190
|
+
export declare function getClaudeAuthCommandEnvironment(configDir: string | null): NodeJS.ProcessEnv;
|
|
184
191
|
/**
|
|
185
192
|
* @description Whether two `CLAUDE_CONFIG_DIR` values name the same directory: equal strings, or paths that
|
|
186
193
|
* resolve to the same real directory. A process adopted after the data dir was moved to its new name keeps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeProfiles.d.ts","sourceRoot":"","sources":["../../src/utils/claudeProfiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"claudeProfiles.d.ts","sourceRoot":"","sources":["../../src/utils/claudeProfiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,uEAAuE;AACvE,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAElD,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,6DAA8D,CAAC;AACtG,eAAO,MAAM,kCAAkC,wBAAyB,CAAC;AAEzE,iGAAiG;AACjG,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAG7C,wHAAwH;AACxH,eAAO,MAAM,2BAA2B,UAAU,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED,2GAA2G;AAC3G,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,IAA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B,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGjE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAM7D;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAKjF;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;AAErE,uHAAuH;AACvH,wBAAgB,oBAAoB,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAAG,iBAAiB,CAMvF;AAID,eAAO,MAAM,2BAA2B,sBAAsB,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,UAAU,CAK3F;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAQ7F;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM9E"}
|
|
@@ -79,11 +79,13 @@ exports.removeClaudeProfileApiKey = removeClaudeProfileApiKey;
|
|
|
79
79
|
exports.readProcessErrorStdout = readProcessErrorStdout;
|
|
80
80
|
exports.getProcessFailureReason = getProcessFailureReason;
|
|
81
81
|
exports.getClaudeAccountKind = getClaudeAccountKind;
|
|
82
|
+
exports.getClaudeAuthCommandEnvironment = getClaudeAuthCommandEnvironment;
|
|
82
83
|
exports.checkIsSameClaudeConfigDir = checkIsSameClaudeConfigDir;
|
|
83
84
|
exports.parseClaudeConfigDirFromCommand = parseClaudeConfigDirFromCommand;
|
|
84
85
|
const fs = __importStar(require("fs"));
|
|
85
86
|
const os = __importStar(require("os"));
|
|
86
87
|
const path = __importStar(require("path"));
|
|
88
|
+
const agentEnvironment_1 = require("./agentEnvironment");
|
|
87
89
|
/** The profile that is `~/.claude` itself (no `CLAUDE_CONFIG_DIR`). */
|
|
88
90
|
exports.defaultClaudeProfileName = 'default';
|
|
89
91
|
/** Subdirectory of `DATA_DIR` that holds every profile's config directory. */
|
|
@@ -428,6 +430,19 @@ function getClaudeAccountKind(subscriptionType) {
|
|
|
428
430
|
}
|
|
429
431
|
// ββ the spawn-side variable ββ
|
|
430
432
|
exports.claudeConfigDirVariableName = 'CLAUDE_CONFIG_DIR';
|
|
433
|
+
/**
|
|
434
|
+
* @description The environment a `claude auth β¦` process runs with (a sign-in, an auth-status probe): the bot's own
|
|
435
|
+
* without its secrets and without `ANTHROPIC_API_KEY` (the subscription login, never the metered console path), plus
|
|
436
|
+
* `CLAUDE_CONFIG_DIR` for a profile's directory (`null` = `~/.claude`) β the login must land in THAT directory, and the
|
|
437
|
+
* status probe must read the same one.
|
|
438
|
+
*/
|
|
439
|
+
function getClaudeAuthCommandEnvironment(configDir) {
|
|
440
|
+
const environment = (0, agentEnvironment_1.getChildProcessEnvironment)();
|
|
441
|
+
delete environment.ANTHROPIC_API_KEY;
|
|
442
|
+
if (configDir !== null)
|
|
443
|
+
environment[exports.claudeConfigDirVariableName] = configDir;
|
|
444
|
+
return environment;
|
|
445
|
+
}
|
|
431
446
|
/**
|
|
432
447
|
* @description Whether two `CLAUDE_CONFIG_DIR` values name the same directory: equal strings, or paths that
|
|
433
448
|
* resolve to the same real directory. A process adopted after the data dir was moved to its new name keeps
|