charness 3.9.1 → 3.11.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/CHANGELOG.md +155 -0
- package/DEVELOPMENT.md +4 -1
- package/README.md +2 -1
- package/SETUP.md +6 -4
- package/agent-plugin/README.md +2 -2
- package/agent-plugin/skills/charness-delegate-opencode/SKILL.md +1 -1
- package/agent-plugin/skills/charness-manager/SKILL.md +11 -6
- package/dist/bot.d.ts +27 -18
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +390 -231
- package/dist/bot.js.map +1 -1
- package/dist/connectors/jira/adf.d.ts.map +1 -1
- package/dist/connectors/jira/adf.js +2 -3
- package/dist/connectors/jira/adf.js.map +1 -1
- package/dist/connectors/telegram/commands/botCore.d.ts +17 -0
- package/dist/connectors/telegram/commands/botCore.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/claudeAccounts.js +3 -3
- package/dist/connectors/telegram/commands/claudeAccounts.js.map +1 -1
- package/dist/connectors/telegram/commands/runners.d.ts +10 -1
- package/dist/connectors/telegram/commands/runners.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/runners.js +85 -17
- package/dist/connectors/telegram/commands/runners.js.map +1 -1
- package/dist/connectors/telegram/foldedMessage.d.ts +24 -0
- package/dist/connectors/telegram/foldedMessage.d.ts.map +1 -0
- package/dist/connectors/telegram/foldedMessage.js +39 -0
- package/dist/connectors/telegram/foldedMessage.js.map +1 -0
- package/dist/connectors/telegram/inbound.d.ts +24 -1
- package/dist/connectors/telegram/inbound.d.ts.map +1 -1
- package/dist/connectors/telegram/inbound.js +77 -1
- package/dist/connectors/telegram/inbound.js.map +1 -1
- package/dist/connectors/telegram/renderAgentHtml.d.ts +15 -0
- package/dist/connectors/telegram/renderAgentHtml.d.ts.map +1 -1
- package/dist/connectors/telegram/renderAgentHtml.js +11 -1
- package/dist/connectors/telegram/renderAgentHtml.js.map +1 -1
- package/dist/connectors/telegram/runnerLinkNotices.d.ts +24 -0
- package/dist/connectors/telegram/runnerLinkNotices.d.ts.map +1 -0
- package/dist/connectors/telegram/runnerLinkNotices.js +95 -0
- package/dist/connectors/telegram/runnerLinkNotices.js.map +1 -0
- package/dist/connectors/telegram/runnerPairingMessages.d.ts +9 -0
- package/dist/connectors/telegram/runnerPairingMessages.d.ts.map +1 -1
- package/dist/connectors/telegram/runnerPairingMessages.js +17 -1
- package/dist/connectors/telegram/runnerPairingMessages.js.map +1 -1
- package/dist/connectors/telegram/unpinMessages.d.ts +12 -0
- package/dist/connectors/telegram/unpinMessages.d.ts.map +1 -0
- package/dist/connectors/telegram/unpinMessages.js +44 -0
- package/dist/connectors/telegram/unpinMessages.js.map +1 -0
- package/dist/i18n/de.d.ts.map +1 -1
- package/dist/i18n/de.js +30 -3
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +30 -3
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +30 -3
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +30 -3
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/hi.d.ts.map +1 -1
- package/dist/i18n/hi.js +30 -3
- package/dist/i18n/hi.js.map +1 -1
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ja.js +30 -3
- package/dist/i18n/ja.js.map +1 -1
- package/dist/i18n/ka.d.ts.map +1 -1
- package/dist/i18n/ka.js +30 -3
- package/dist/i18n/ka.js.map +1 -1
- package/dist/i18n/pt.d.ts.map +1 -1
- package/dist/i18n/pt.js +30 -3
- package/dist/i18n/pt.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +30 -3
- package/dist/i18n/ru.js.map +1 -1
- package/dist/i18n/uk.d.ts.map +1 -1
- package/dist/i18n/uk.js +30 -3
- package/dist/i18n/uk.js.map +1 -1
- package/dist/i18n/uz.d.ts.map +1 -1
- package/dist/i18n/uz.js +30 -3
- package/dist/i18n/uz.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +30 -3
- package/dist/i18n/zh.js.map +1 -1
- package/dist/outputTrace.d.ts +6 -0
- package/dist/outputTrace.d.ts.map +1 -1
- package/dist/outputTrace.js +15 -9
- package/dist/outputTrace.js.map +1 -1
- package/dist/rateLimiter.d.ts +3 -1
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/rateLimiter.js +3 -1
- package/dist/rateLimiter.js.map +1 -1
- package/dist/remoteRun/cliArgs.d.ts +6 -1
- package/dist/remoteRun/cliArgs.d.ts.map +1 -1
- package/dist/remoteRun/cliArgs.js +39 -2
- package/dist/remoteRun/cliArgs.js.map +1 -1
- package/dist/remoteRun/exitCodes.d.ts +12 -2
- package/dist/remoteRun/exitCodes.d.ts.map +1 -1
- package/dist/remoteRun/exitCodes.js +3 -0
- package/dist/remoteRun/exitCodes.js.map +1 -1
- package/dist/remoteRun/foreground.d.ts +13 -0
- package/dist/remoteRun/foreground.d.ts.map +1 -1
- package/dist/remoteRun/foreground.js +15 -2
- package/dist/remoteRun/foreground.js.map +1 -1
- package/dist/remoteRun/heldBackNotice.d.ts +7 -0
- package/dist/remoteRun/heldBackNotice.d.ts.map +1 -0
- package/dist/remoteRun/heldBackNotice.js +92 -0
- package/dist/remoteRun/heldBackNotice.js.map +1 -0
- package/dist/remoteRun/interrupts.d.ts +6 -2
- package/dist/remoteRun/interrupts.d.ts.map +1 -1
- package/dist/remoteRun/interrupts.js +18 -3
- package/dist/remoteRun/interrupts.js.map +1 -1
- package/dist/remoteRun/leaseTiming.d.ts +1 -2
- package/dist/remoteRun/leaseTiming.d.ts.map +1 -1
- package/dist/remoteRun/leaseTiming.js +3 -17
- package/dist/remoteRun/leaseTiming.js.map +1 -1
- package/dist/remoteRun/output.d.ts +16 -1
- package/dist/remoteRun/output.d.ts.map +1 -1
- package/dist/remoteRun/output.js +28 -2
- package/dist/remoteRun/output.js.map +1 -1
- package/dist/remoteRun/probe.d.ts +40 -2
- package/dist/remoteRun/probe.d.ts.map +1 -1
- package/dist/remoteRun/probe.js +58 -2
- package/dist/remoteRun/probe.js.map +1 -1
- package/dist/remoteRun/project.d.ts +2 -2
- package/dist/remoteRun/project.d.ts.map +1 -1
- package/dist/remoteRun/project.js +5 -4
- package/dist/remoteRun/project.js.map +1 -1
- package/dist/remoteRun/remoteRunCli.d.ts +1 -1
- package/dist/remoteRun/remoteRunCli.d.ts.map +1 -1
- package/dist/remoteRun/remoteRunCli.js +6 -3
- package/dist/remoteRun/remoteRunCli.js.map +1 -1
- package/dist/remoteRun/runnerWait.d.ts +3 -3
- package/dist/remoteRun/runnerWait.d.ts.map +1 -1
- package/dist/remoteRun/runnerWait.js +12 -6
- package/dist/remoteRun/runnerWait.js.map +1 -1
- package/dist/remoteRun/runnerWaitTiming.d.ts +1 -1
- package/dist/remoteRun/runnerWaitTiming.d.ts.map +1 -1
- package/dist/remoteRun/runnerWaitTiming.js +3 -16
- package/dist/remoteRun/runnerWaitTiming.js.map +1 -1
- package/dist/remoteRun/runners.d.ts +16 -3
- package/dist/remoteRun/runners.d.ts.map +1 -1
- package/dist/remoteRun/runners.js +42 -4
- package/dist/remoteRun/runners.js.map +1 -1
- package/dist/remoteRun/sendPlan.d.ts +11 -1
- package/dist/remoteRun/sendPlan.d.ts.map +1 -1
- package/dist/remoteRun/sendPlan.js +29 -5
- package/dist/remoteRun/sendPlan.js.map +1 -1
- package/dist/remoteRun/submit.d.ts.map +1 -1
- package/dist/remoteRun/submit.js +13 -3
- package/dist/remoteRun/submit.js.map +1 -1
- package/dist/runnerUtility/adminService.d.ts +30 -2
- package/dist/runnerUtility/adminService.d.ts.map +1 -1
- package/dist/runnerUtility/adminService.js +104 -6
- package/dist/runnerUtility/adminService.js.map +1 -1
- package/dist/runnerUtility/appInstall.d.ts +13 -4
- package/dist/runnerUtility/appInstall.d.ts.map +1 -1
- package/dist/runnerUtility/appInstall.js +46 -19
- package/dist/runnerUtility/appInstall.js.map +1 -1
- package/dist/runnerUtility/appUpdate.js +1 -1
- package/dist/runnerUtility/appUpdate.js.map +1 -1
- package/dist/runnerUtility/execEnv.d.ts +2 -0
- package/dist/runnerUtility/execEnv.d.ts.map +1 -1
- package/dist/runnerUtility/execEnv.js +6 -2
- package/dist/runnerUtility/execEnv.js.map +1 -1
- package/dist/runnerUtility/guiAgent.d.ts +126 -0
- package/dist/runnerUtility/guiAgent.d.ts.map +1 -0
- package/dist/runnerUtility/guiAgent.js +591 -0
- package/dist/runnerUtility/guiAgent.js.map +1 -0
- package/dist/runnerUtility/guiAgentHeal.d.ts +128 -0
- package/dist/runnerUtility/guiAgentHeal.d.ts.map +1 -0
- package/dist/runnerUtility/guiAgentHeal.js +284 -0
- package/dist/runnerUtility/guiAgentHeal.js.map +1 -0
- package/dist/runnerUtility/homeFolders.d.ts +33 -0
- package/dist/runnerUtility/homeFolders.d.ts.map +1 -0
- package/dist/runnerUtility/homeFolders.js +158 -0
- package/dist/runnerUtility/homeFolders.js.map +1 -0
- package/dist/runnerUtility/hubClient.d.ts +12 -2
- package/dist/runnerUtility/hubClient.d.ts.map +1 -1
- package/dist/runnerUtility/hubClient.js +24 -3
- package/dist/runnerUtility/hubClient.js.map +1 -1
- package/dist/runnerUtility/iosCheck.d.ts +7 -1
- package/dist/runnerUtility/iosCheck.d.ts.map +1 -1
- package/dist/runnerUtility/iosCheck.js +14 -5
- package/dist/runnerUtility/iosCheck.js.map +1 -1
- package/dist/runnerUtility/isolatedCommand.d.ts +31 -0
- package/dist/runnerUtility/isolatedCommand.d.ts.map +1 -0
- package/dist/runnerUtility/isolatedCommand.js +132 -0
- package/dist/runnerUtility/isolatedCommand.js.map +1 -0
- package/dist/runnerUtility/keepAwake.d.ts +67 -0
- package/dist/runnerUtility/keepAwake.d.ts.map +1 -0
- package/dist/runnerUtility/keepAwake.js +211 -0
- package/dist/runnerUtility/keepAwake.js.map +1 -0
- package/dist/runnerUtility/lidPollTiming.d.ts +11 -0
- package/dist/runnerUtility/lidPollTiming.d.ts.map +1 -0
- package/dist/runnerUtility/lidPollTiming.js +18 -0
- package/dist/runnerUtility/lidPollTiming.js.map +1 -0
- package/dist/runnerUtility/lidState.d.ts +57 -0
- package/dist/runnerUtility/lidState.d.ts.map +1 -0
- package/dist/runnerUtility/lidState.js +195 -0
- package/dist/runnerUtility/lidState.js.map +1 -0
- package/dist/runnerUtility/linkLoop.d.ts +5 -0
- package/dist/runnerUtility/linkLoop.d.ts.map +1 -1
- package/dist/runnerUtility/linkLoop.js +37 -1
- package/dist/runnerUtility/linkLoop.js.map +1 -1
- package/dist/runnerUtility/packageManagerShims.d.ts +44 -0
- package/dist/runnerUtility/packageManagerShims.d.ts.map +1 -0
- package/dist/runnerUtility/packageManagerShims.js +130 -0
- package/dist/runnerUtility/packageManagerShims.js.map +1 -0
- package/dist/runnerUtility/progress.d.ts +43 -0
- package/dist/runnerUtility/progress.d.ts.map +1 -0
- package/dist/runnerUtility/progress.js +78 -0
- package/dist/runnerUtility/progress.js.map +1 -0
- package/dist/runnerUtility/pueueDaemon.d.ts +8 -4
- package/dist/runnerUtility/pueueDaemon.d.ts.map +1 -1
- package/dist/runnerUtility/pueueDaemon.js +12 -7
- package/dist/runnerUtility/pueueDaemon.js.map +1 -1
- package/dist/runnerUtility/rootServiceCli.d.ts +23 -3
- package/dist/runnerUtility/rootServiceCli.d.ts.map +1 -1
- package/dist/runnerUtility/rootServiceCli.js +56 -10
- package/dist/runnerUtility/rootServiceCli.js.map +1 -1
- package/dist/runnerUtility/runnerCli.d.ts +1 -0
- package/dist/runnerUtility/runnerCli.d.ts.map +1 -1
- package/dist/runnerUtility/runnerCli.js +14 -7
- package/dist/runnerUtility/runnerCli.js.map +1 -1
- package/dist/runnerUtility/runnerCommands.d.ts +45 -0
- package/dist/runnerUtility/runnerCommands.d.ts.map +1 -1
- package/dist/runnerUtility/runnerCommands.js +188 -21
- package/dist/runnerUtility/runnerCommands.js.map +1 -1
- package/dist/runnerUtility/runnerHome.d.ts +8 -0
- package/dist/runnerUtility/runnerHome.d.ts.map +1 -1
- package/dist/runnerUtility/runnerHome.js +7 -0
- package/dist/runnerUtility/runnerHome.js.map +1 -1
- package/dist/runnerUtility/serviceCommon.d.ts +4 -0
- package/dist/runnerUtility/serviceCommon.d.ts.map +1 -1
- package/dist/runnerUtility/serviceCommon.js +8 -1
- package/dist/runnerUtility/serviceCommon.js.map +1 -1
- package/dist/runnerUtility/serviceManager.d.ts +5 -2
- package/dist/runnerUtility/serviceManager.d.ts.map +1 -1
- package/dist/runnerUtility/serviceManager.js +40 -17
- package/dist/runnerUtility/serviceManager.js.map +1 -1
- package/dist/runnerUtility/serviceUnits.d.ts +11 -0
- package/dist/runnerUtility/serviceUnits.d.ts.map +1 -1
- package/dist/runnerUtility/serviceUnits.js +8 -2
- package/dist/runnerUtility/serviceUnits.js.map +1 -1
- package/dist/runnerUtility/simulatorSilencer.d.ts +55 -0
- package/dist/runnerUtility/simulatorSilencer.d.ts.map +1 -0
- package/dist/runnerUtility/simulatorSilencer.js +203 -0
- package/dist/runnerUtility/simulatorSilencer.js.map +1 -0
- package/dist/runnerUtility/stopSignals.d.ts +10 -0
- package/dist/runnerUtility/stopSignals.d.ts.map +1 -0
- package/dist/runnerUtility/stopSignals.js +27 -0
- package/dist/runnerUtility/stopSignals.js.map +1 -0
- package/dist/runnerUtility/versionPollTiming.d.ts +2 -3
- package/dist/runnerUtility/versionPollTiming.d.ts.map +1 -1
- package/dist/runnerUtility/versionPollTiming.js +4 -18
- package/dist/runnerUtility/versionPollTiming.js.map +1 -1
- package/dist/runners/bootstrapLine.d.ts.map +1 -1
- package/dist/runners/bootstrapLine.js +35 -19
- package/dist/runners/bootstrapLine.js.map +1 -1
- package/dist/runners/gate.d.ts.map +1 -1
- package/dist/runners/gate.js +28 -1
- package/dist/runners/gate.js.map +1 -1
- package/dist/runners/gateLink.d.ts +7 -0
- package/dist/runners/gateLink.d.ts.map +1 -1
- package/dist/runners/gateLink.js +36 -3
- package/dist/runners/gateLink.js.map +1 -1
- package/dist/runners/gateProtocol.d.ts +37 -2
- package/dist/runners/gateProtocol.d.ts.map +1 -1
- package/dist/runners/gateProtocol.js +45 -4
- package/dist/runners/gateProtocol.js.map +1 -1
- package/dist/runners/hubPackage.d.ts +2 -1
- package/dist/runners/hubPackage.d.ts.map +1 -1
- package/dist/runners/hubPackage.js +32 -11
- package/dist/runners/hubPackage.js.map +1 -1
- package/dist/runners/hubPairing.d.ts +1 -1
- package/dist/runners/hubPairing.d.ts.map +1 -1
- package/dist/runners/hubPairing.js +8 -1
- package/dist/runners/hubPairing.js.map +1 -1
- package/dist/runners/hubPaths.d.ts +2 -0
- package/dist/runners/hubPaths.d.ts.map +1 -1
- package/dist/runners/hubPaths.js +1 -1
- package/dist/runners/hubPaths.js.map +1 -1
- package/dist/runners/linkConcern.d.ts +75 -0
- package/dist/runners/linkConcern.d.ts.map +1 -0
- package/dist/runners/linkConcern.js +85 -0
- package/dist/runners/linkConcern.js.map +1 -0
- package/dist/runners/linkControl.d.ts +25 -1
- package/dist/runners/linkControl.d.ts.map +1 -1
- package/dist/runners/linkControl.js +46 -4
- package/dist/runners/linkControl.js.map +1 -1
- package/dist/runners/pairingTiming.d.ts +2 -3
- package/dist/runners/pairingTiming.d.ts.map +1 -1
- package/dist/runners/pairingTiming.js +4 -18
- package/dist/runners/pairingTiming.js.map +1 -1
- package/dist/runners/runnerLock.d.ts +112 -0
- package/dist/runners/runnerLock.d.ts.map +1 -0
- package/dist/runners/runnerLock.js +292 -0
- package/dist/runners/runnerLock.js.map +1 -0
- package/dist/runners/runnersCli.d.ts +6 -3
- package/dist/runners/runnersCli.d.ts.map +1 -1
- package/dist/runners/runnersCli.js +33 -6
- package/dist/runners/runnersCli.js.map +1 -1
- package/dist/runners/runnersList.d.ts +3 -3
- package/dist/runners/runnersList.d.ts.map +1 -1
- package/dist/runners/runnersList.js +9 -2
- package/dist/runners/runnersList.js.map +1 -1
- package/dist/runners/runnersOverview.d.ts +29 -3
- package/dist/runners/runnersOverview.d.ts.map +1 -1
- package/dist/runners/runnersOverview.js +71 -6
- package/dist/runners/runnersOverview.js.map +1 -1
- package/dist/runners/serviceRemoval.d.ts +43 -0
- package/dist/runners/serviceRemoval.d.ts.map +1 -0
- package/dist/runners/serviceRemoval.js +114 -0
- package/dist/runners/serviceRemoval.js.map +1 -0
- package/dist/scheduler/checkRun.d.ts +9 -10
- package/dist/scheduler/checkRun.d.ts.map +1 -1
- package/dist/scheduler/checkRun.js +8 -16
- package/dist/scheduler/checkRun.js.map +1 -1
- package/dist/scheduler/checkStatus.d.ts +75 -0
- package/dist/scheduler/checkStatus.d.ts.map +1 -0
- package/dist/scheduler/checkStatus.js +117 -0
- package/dist/scheduler/checkStatus.js.map +1 -0
- package/dist/scheduler/delivery.d.ts +106 -38
- package/dist/scheduler/delivery.d.ts.map +1 -1
- package/dist/scheduler/delivery.js +199 -73
- package/dist/scheduler/delivery.js.map +1 -1
- package/dist/scheduler/mcpSurface.d.ts +8 -2
- package/dist/scheduler/mcpSurface.d.ts.map +1 -1
- package/dist/scheduler/mcpSurface.js +96 -20
- package/dist/scheduler/mcpSurface.js.map +1 -1
- package/dist/scheduler/recurrence.d.ts +32 -0
- package/dist/scheduler/recurrence.d.ts.map +1 -1
- package/dist/scheduler/recurrence.js +56 -18
- package/dist/scheduler/recurrence.js.map +1 -1
- package/dist/scheduler/scheduleText.d.ts +7 -0
- package/dist/scheduler/scheduleText.d.ts.map +1 -0
- package/dist/scheduler/scheduleText.js +55 -0
- package/dist/scheduler/scheduleText.js.map +1 -0
- package/dist/scheduler/store.d.ts +23 -2
- package/dist/scheduler/store.d.ts.map +1 -1
- package/dist/scheduler/store.js +57 -3
- package/dist/scheduler/store.js.map +1 -1
- package/dist/scheduler/types.d.ts +26 -10
- package/dist/scheduler/types.d.ts.map +1 -1
- package/dist/scheduler/unbindPause.d.ts +27 -0
- package/dist/scheduler/unbindPause.d.ts.map +1 -0
- package/dist/scheduler/unbindPause.js +21 -0
- package/dist/scheduler/unbindPause.js.map +1 -0
- package/dist/scheduler/workerActivity.d.ts +25 -0
- package/dist/scheduler/workerActivity.d.ts.map +1 -0
- package/dist/scheduler/workerActivity.js +195 -0
- package/dist/scheduler/workerActivity.js.map +1 -0
- package/dist/scheduler/workerWatch.d.ts +36 -9
- package/dist/scheduler/workerWatch.d.ts.map +1 -1
- package/dist/scheduler/workerWatch.js +41 -11
- package/dist/scheduler/workerWatch.js.map +1 -1
- package/dist/state.d.ts +8 -0
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +30 -0
- package/dist/state.js.map +1 -1
- package/dist/stt/sttRuntime.d.ts.map +1 -1
- package/dist/stt/sttRuntime.js +8 -1
- package/dist/stt/sttRuntime.js.map +1 -1
- package/dist/stt/sttSettings.d.ts +56 -6
- package/dist/stt/sttSettings.d.ts.map +1 -1
- package/dist/stt/sttSettings.js +128 -7
- package/dist/stt/sttSettings.js.map +1 -1
- package/dist/stt/sttSidecarOwner.d.ts +13 -5
- package/dist/stt/sttSidecarOwner.d.ts.map +1 -1
- package/dist/stt/sttSidecarOwner.js +72 -31
- package/dist/stt/sttSidecarOwner.js.map +1 -1
- package/dist/stt/transcribeChain.d.ts +23 -1
- package/dist/stt/transcribeChain.d.ts.map +1 -1
- package/dist/stt/transcribeChain.js +59 -4
- package/dist/stt/transcribeChain.js.map +1 -1
- package/dist/testTimings.d.ts +4 -2
- package/dist/testTimings.d.ts.map +1 -1
- package/dist/testTimings.js +7 -1
- package/dist/testTimings.js.map +1 -1
- package/dist/testTimingsSeam.d.ts +10 -0
- package/dist/testTimingsSeam.d.ts.map +1 -0
- package/dist/testTimingsSeam.js +29 -0
- package/dist/testTimingsSeam.js.map +1 -0
- package/dist/utils/claudeUsage.d.ts +3 -0
- package/dist/utils/claudeUsage.d.ts.map +1 -1
- package/dist/utils/claudeUsage.js +8 -1
- package/dist/utils/claudeUsage.js.map +1 -1
- package/dist/utils/claudeUsageRefresher.d.ts +27 -3
- package/dist/utils/claudeUsageRefresher.d.ts.map +1 -1
- package/dist/utils/claudeUsageRefresher.js +113 -14
- package/dist/utils/claudeUsageRefresher.js.map +1 -1
- package/dist/utils/forwardedMark.d.ts +54 -0
- package/dist/utils/forwardedMark.d.ts.map +1 -0
- package/dist/utils/forwardedMark.js +80 -0
- package/dist/utils/forwardedMark.js.map +1 -0
- package/dist/utils/limitHeldPrompts.d.ts +8 -2
- package/dist/utils/limitHeldPrompts.d.ts.map +1 -1
- package/dist/utils/limitHeldPrompts.js +11 -4
- package/dist/utils/limitHeldPrompts.js.map +1 -1
- package/dist/utils/messageContext.d.ts +54 -0
- package/dist/utils/messageContext.d.ts.map +1 -0
- package/dist/utils/messageContext.js +58 -0
- package/dist/utils/messageContext.js.map +1 -0
- package/dist/utils/openCodeUsage.d.ts +10 -3
- package/dist/utils/openCodeUsage.d.ts.map +1 -1
- package/dist/utils/openCodeUsage.js +19 -5
- package/dist/utils/openCodeUsage.js.map +1 -1
- package/dist/utils/replyQuote.d.ts +11 -26
- package/dist/utils/replyQuote.d.ts.map +1 -1
- package/dist/utils/replyQuote.js +9 -31
- package/dist/utils/replyQuote.js.map +1 -1
- package/dist/utils/runnersScreenPlan.d.ts +14 -0
- package/dist/utils/runnersScreenPlan.d.ts.map +1 -1
- package/dist/utils/runnersScreenPlan.js +49 -5
- package/dist/utils/runnersScreenPlan.js.map +1 -1
- package/dist/utils/stripControlCharacters.d.ts +8 -0
- package/dist/utils/stripControlCharacters.d.ts.map +1 -0
- package/dist/utils/stripControlCharacters.js +16 -0
- package/dist/utils/stripControlCharacters.js.map +1 -0
- package/dist/utils/surrogateSafeCut.d.ts +14 -0
- package/dist/utils/surrogateSafeCut.d.ts.map +1 -0
- package/dist/utils/surrogateSafeCut.js +30 -0
- package/dist/utils/surrogateSafeCut.js.map +1 -0
- package/dist/utils/telegramError.d.ts +13 -0
- package/dist/utils/telegramError.d.ts.map +1 -1
- package/dist/utils/telegramError.js +45 -0
- package/dist/utils/telegramError.js.map +1 -1
- package/dist/utils/topicRequest.d.ts +13 -0
- package/dist/utils/topicRequest.d.ts.map +1 -1
- package/dist/utils/topicRequest.js +10 -0
- package/dist/utils/topicRequest.js.map +1 -1
- package/dist/utils/transientFrames.d.ts +51 -6
- package/dist/utils/transientFrames.d.ts.map +1 -1
- package/dist/utils/transientFrames.js +52 -2
- package/dist/utils/transientFrames.js.map +1 -1
- package/dist/utils/usageRefreshBudget.d.ts.map +1 -1
- package/dist/utils/usageRefreshBudget.js +4 -10
- package/dist/utils/usageRefreshBudget.js.map +1 -1
- package/dist/utils/waitUpTo.d.ts +8 -0
- package/dist/utils/waitUpTo.d.ts.map +1 -0
- package/dist/utils/waitUpTo.js +20 -0
- package/dist/utils/waitUpTo.js.map +1 -0
- package/dist/voiceProgressNote.d.ts +73 -0
- package/dist/voiceProgressNote.d.ts.map +1 -0
- package/dist/voiceProgressNote.js +142 -0
- package/dist/voiceProgressNote.js.map +1 -0
- package/package.json +4 -1
- package/remoteRun/pickNode.sh +65 -0
- package/remoteRun/runner-package-lock.json +59 -0
- package/remoteRun/runner.sh +304 -6
|
@@ -11,19 +11,40 @@
|
|
|
11
11
|
* injected, so the unit test drives it without the network, the file system or a `StateStore`.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.claudeUsageOnDemandMaxAgeMs = exports.claudeUsageRefreshIntervalMs = void 0;
|
|
14
|
+
exports.claudeLaunchRefreshBudgetMs = exports.claudeUsagePollDeadlineMs = exports.claudeUsageOnDemandMaxAgeMs = exports.claudeUsageRefreshIntervalMs = void 0;
|
|
15
15
|
exports.createClaudeUsageRefresher = createClaudeUsageRefresher;
|
|
16
16
|
exports.refreshClaudeUsageForLaunch = refreshClaudeUsageForLaunch;
|
|
17
|
+
const waitUpTo_1 = require("./waitUpTo");
|
|
17
18
|
const claudeUsage_1 = require("./claudeUsage");
|
|
18
19
|
exports.claudeUsageRefreshIntervalMs = 10 * 60_000;
|
|
19
20
|
/** A snapshot younger than this is served as is by the on-demand readers (`/account`, the MCP tool). */
|
|
20
21
|
exports.claudeUsageOnDemandMaxAgeMs = 60_000;
|
|
22
|
+
/**
|
|
23
|
+
* The longest ONE poll (a profile's, or the OpenCode providers') may run before the refresher gives up on it. Above the
|
|
24
|
+
* fetch's own 15 s timeout, so a healthy abort is never cut short: it only fires when a poll outlives every timeout it has.
|
|
25
|
+
* Without it the poll in flight is shared by every caller (the timer, `/limits`, the `claude_profiles` tool), so ONE poll
|
|
26
|
+
* that never settles keeps all of them waiting for the rest of the process's life.
|
|
27
|
+
*/
|
|
28
|
+
exports.claudeUsagePollDeadlineMs = 30_000;
|
|
29
|
+
/**
|
|
30
|
+
* The longest the `claude_profiles` answer waits for fresh figures. A poll is ~0.5 s (6 s at its slowest in the tool's
|
|
31
|
+
* history); past this the tool answers from the cached figures — each profile carries when they were read — and the refresh
|
|
32
|
+
* goes on in the background. Well under the 300 s after which the agent's own client drops a silent tool call.
|
|
33
|
+
*/
|
|
34
|
+
exports.claudeLaunchRefreshBudgetMs = 10_000;
|
|
35
|
+
/** The stale mark a poll that was given up on leaves on its figures. */
|
|
36
|
+
const usagePollGaveUpReason = 'usage poll did not finish';
|
|
37
|
+
/** The key of the OpenCode providers' poll beside the profiles' (a profile is keyed by its name). */
|
|
38
|
+
const openCodePollLabel = 'OpenCode providers';
|
|
39
|
+
const millisecondsPerMinute = 60_000;
|
|
21
40
|
function createClaudeUsageRefresher(deps) {
|
|
22
41
|
const now = deps.now ?? (() => Date.now());
|
|
23
42
|
const log = deps.log ?? ((line) => console.log(line));
|
|
43
|
+
const pollDeadlineMs = deps.pollDeadlineMs ?? exports.claudeUsagePollDeadlineMs;
|
|
44
|
+
const pendingPolls = new Map();
|
|
24
45
|
let inFlight = null;
|
|
25
46
|
let timer = null;
|
|
26
|
-
async function pollProfile(profile) {
|
|
47
|
+
async function pollProfile(profile, signal) {
|
|
27
48
|
const previous = deps.getSnapshot(profile.name);
|
|
28
49
|
const token = deps.readToken(profile.configDir);
|
|
29
50
|
if (token === null) {
|
|
@@ -38,7 +59,10 @@ function createClaudeUsageRefresher(deps) {
|
|
|
38
59
|
}
|
|
39
60
|
return;
|
|
40
61
|
}
|
|
41
|
-
const result = await deps.fetchUsage(token.accessToken);
|
|
62
|
+
const result = await deps.fetchUsage(token.accessToken, signal);
|
|
63
|
+
// The refresher gave up on this poll while it ran: a newer reading may have been stored since, so this one writes nothing.
|
|
64
|
+
if (signal.aborted)
|
|
65
|
+
return;
|
|
42
66
|
if (!result.ok) {
|
|
43
67
|
log(`[usage] ${profile.name}: usage poll failed (${result.error})`);
|
|
44
68
|
deps.saveSnapshot(profile.name, (0, claudeUsage_1.markClaudeUsageSnapshotStale)(previous, result.error, now()));
|
|
@@ -46,6 +70,69 @@ function createClaudeUsageRefresher(deps) {
|
|
|
46
70
|
}
|
|
47
71
|
deps.saveSnapshot(profile.name, (0, claudeUsage_1.mergeClaudeUsageSnapshot)(previous, result.buckets, 'api', now()));
|
|
48
72
|
}
|
|
73
|
+
/** Run a poll and log how it ended — whenever that is, so a failure after the deadline is seen too. Never rejects. */
|
|
74
|
+
async function runLoggingFailure(label, poll, signal) {
|
|
75
|
+
try {
|
|
76
|
+
await poll(signal);
|
|
77
|
+
return 'finished';
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
log(`[usage] ${label}: usage poll threw: ${e instanceof Error ? e.message : String(e)}`);
|
|
81
|
+
return 'threw';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Run the poll of one target, waiting for it at most {@link claudeUsagePollDeadlineMs}. At the deadline the poll is given
|
|
86
|
+
* up on: its request is cancelled, `markStale` (told when the poll started) leaves a stale mark on the figures, and it is
|
|
87
|
+
* left pending until it finally settles — saving nothing, and logging when and how it ended — so a stuck target is not
|
|
88
|
+
* polled twice at once. A call for a target whose earlier poll was given up on returns at once, until that poll has been
|
|
89
|
+
* pending for a whole refresh interval: a poll the cancel cannot reach must not block its target for good, so the next
|
|
90
|
+
* call says so in one line and polls afresh (the old poll's cleanup leaves the new entry alone). A call for a target whose
|
|
91
|
+
* poll is still within its deadline joins it.
|
|
92
|
+
*/
|
|
93
|
+
function runPoll(label, poll, markStale) {
|
|
94
|
+
const pending = pendingPolls.get(label);
|
|
95
|
+
if (pending) {
|
|
96
|
+
if (!pending.isAbandoned)
|
|
97
|
+
return pending.done;
|
|
98
|
+
const pendingForMs = now() - pending.startedAtMs;
|
|
99
|
+
if (pendingForMs < exports.claudeUsageRefreshIntervalMs)
|
|
100
|
+
return Promise.resolve();
|
|
101
|
+
log(`[usage] ${label}: the abandoned usage poll is still pending after ${Math.round(pendingForMs / millisecondsPerMinute)} min; polling afresh`);
|
|
102
|
+
}
|
|
103
|
+
const controller = new AbortController();
|
|
104
|
+
const startedAtMs = now();
|
|
105
|
+
const entry = { startedAtMs, isAbandoned: false, done: Promise.resolve() };
|
|
106
|
+
pendingPolls.set(label, entry);
|
|
107
|
+
const ended = runLoggingFailure(label, poll, controller.signal);
|
|
108
|
+
void ended.then((end) => {
|
|
109
|
+
if (pendingPolls.get(label) === entry)
|
|
110
|
+
pendingPolls.delete(label);
|
|
111
|
+
if (!entry.isAbandoned)
|
|
112
|
+
return;
|
|
113
|
+
const duration = `${((now() - startedAtMs) / 1000).toFixed(1)} s`;
|
|
114
|
+
log(`[usage] ${label}: the abandoned usage poll ${end === 'finished' ? `finished after ${duration}; its answer was dropped` : `failed after ${duration}`}`);
|
|
115
|
+
});
|
|
116
|
+
entry.done = (0, waitUpTo_1.waitUpTo)(ended.then(() => undefined), pollDeadlineMs).then((isSettled) => {
|
|
117
|
+
if (isSettled)
|
|
118
|
+
return;
|
|
119
|
+
entry.isAbandoned = true;
|
|
120
|
+
controller.abort();
|
|
121
|
+
markStale(startedAtMs);
|
|
122
|
+
log(`[usage] ${label}: usage poll did not finish within ${pollDeadlineMs / 1000} s; not waiting for it any more`);
|
|
123
|
+
});
|
|
124
|
+
return entry.done;
|
|
125
|
+
}
|
|
126
|
+
/** A reading stored since the poll began (a json-stream frame) is newer than anything the poll could have told: it stays as it is. */
|
|
127
|
+
function markProfileStale(name, pollStartedAtMs) {
|
|
128
|
+
const snapshot = deps.getSnapshot(name);
|
|
129
|
+
if (snapshot && Date.parse(snapshot.fetchedAt) > pollStartedAtMs)
|
|
130
|
+
return;
|
|
131
|
+
deps.saveSnapshot(name, (0, claudeUsage_1.markClaudeUsageSnapshotStale)(snapshot, usagePollGaveUpReason, now()));
|
|
132
|
+
}
|
|
133
|
+
function runProfilePoll(profile) {
|
|
134
|
+
return runPoll(profile.name, (signal) => pollProfile(profile, signal), (pollStartedAtMs) => markProfileStale(profile.name, pollStartedAtMs));
|
|
135
|
+
}
|
|
49
136
|
function checkNeedsPoll(profile, maxAgeMs) {
|
|
50
137
|
if (profile.loggedIn === false || profile.billing === 'api')
|
|
51
138
|
return false;
|
|
@@ -61,13 +148,10 @@ function createClaudeUsageRefresher(deps) {
|
|
|
61
148
|
return inFlight;
|
|
62
149
|
inFlight = (async () => {
|
|
63
150
|
const due = deps.listProfiles().filter((profile) => checkNeedsPoll(profile, options.maxAgeMs));
|
|
151
|
+
const refreshOpenCode = deps.refreshOpenCode;
|
|
64
152
|
await Promise.all([
|
|
65
|
-
...due.map((profile) =>
|
|
66
|
-
|
|
67
|
-
})),
|
|
68
|
-
deps.refreshOpenCode?.(options).catch((e) => {
|
|
69
|
-
log(`[usage] OpenCode providers: usage poll threw: ${e instanceof Error ? e.message : String(e)}`);
|
|
70
|
-
}),
|
|
153
|
+
...due.map((profile) => runProfilePoll(profile)),
|
|
154
|
+
refreshOpenCode && runPoll(openCodePollLabel, (signal) => refreshOpenCode({ ...options, signal }), () => deps.markOpenCodeStale?.(usagePollGaveUpReason)),
|
|
71
155
|
]);
|
|
72
156
|
})().finally(() => { inFlight = null; });
|
|
73
157
|
return inFlight;
|
|
@@ -75,7 +159,7 @@ function createClaudeUsageRefresher(deps) {
|
|
|
75
159
|
async function refreshOne(name) {
|
|
76
160
|
const profile = deps.listProfiles().find((candidate) => candidate.name === name);
|
|
77
161
|
if (profile && profile.billing !== 'api')
|
|
78
|
-
await
|
|
162
|
+
await runProfilePoll(profile);
|
|
79
163
|
}
|
|
80
164
|
function noteStreamWindows(name, windows) {
|
|
81
165
|
const buckets = (0, claudeUsage_1.buildBucketsFromRateLimitWindows)(windows);
|
|
@@ -101,11 +185,26 @@ function createClaudeUsageRefresher(deps) {
|
|
|
101
185
|
/**
|
|
102
186
|
* @description The readings behind a launch pick (`claude_profiles`): when the session being resumed was STOPPED BY A
|
|
103
187
|
* LIMIT, its account is re-read first, unconditionally — its cached figures may lag the limit that just hit — then every
|
|
104
|
-
* other profile whose snapshot is older than `maxAgeMs`.
|
|
188
|
+
* other profile whose snapshot is older than `maxAgeMs`. Waits at most `budgetMs` ({@link claudeLaunchRefreshBudgetMs}) for the
|
|
189
|
+
* whole of it; past that it logs one line and returns, and the caller answers from the cached figures. The refresh is not
|
|
190
|
+
* cancelled: it finishes in the background.
|
|
105
191
|
*/
|
|
106
192
|
async function refreshClaudeUsageForLaunch(refresher, options) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
193
|
+
const budgetMs = options.budgetMs ?? exports.claudeLaunchRefreshBudgetMs;
|
|
194
|
+
const log = options.log ?? ((line) => console.log(line));
|
|
195
|
+
const refresh = async () => {
|
|
196
|
+
try {
|
|
197
|
+
if (options.isStoppedByLimit && options.currentProfile !== null)
|
|
198
|
+
await refresher.refreshOne(options.currentProfile);
|
|
199
|
+
await refresher.refreshAll({ maxAgeMs: options.maxAgeMs });
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
// Whenever it fails — inside the budget or long after it — the answer is the cached figures, and the failure is on record.
|
|
203
|
+
log(`[usage] claude_profiles: the usage refresh threw: ${e instanceof Error ? e.message : String(e)}`);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
if (!(await (0, waitUpTo_1.waitUpTo)(refresh(), budgetMs))) {
|
|
207
|
+
log(`[usage] claude_profiles: the usage refresh did not finish within ${budgetMs / 1000} s; answering from the cached figures`);
|
|
208
|
+
}
|
|
110
209
|
}
|
|
111
210
|
//# sourceMappingURL=claudeUsageRefresher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeUsageRefresher.js","sourceRoot":"","sources":["../../src/utils/claudeUsageRefresher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;
|
|
1
|
+
{"version":3,"file":"claudeUsageRefresher.js","sourceRoot":"","sources":["../../src/utils/claudeUsageRefresher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;GAUG;;;AAiGH,gEA+IC;AASD,kEAkBC;AAxQD,yCAAsC;AACtC,+CAUuB;AAEV,QAAA,4BAA4B,GAAG,EAAE,GAAG,MAAM,CAAC;AAExD,wGAAwG;AAC3F,QAAA,2BAA2B,GAAG,MAAM,CAAC;AAElD;;;;;GAKG;AACU,QAAA,yBAAyB,GAAG,MAAM,CAAC;AAEhD;;;;GAIG;AACU,QAAA,2BAA2B,GAAG,MAAM,CAAC;AA8ClD,wEAAwE;AACxE,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAE1D,qGAAqG;AACrG,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAS/C,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAIrC,SAAgB,0BAA0B,CAAC,IAA8B;IACvE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,IAAI,iCAAyB,CAAC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,UAAU,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC7D,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,2HAA2H;YAC3H,GAAG,CAAC,qDAAqD,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACzG,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,CAAC,MAAM,IAAA,mBAAQ,EAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC;QAC3C,GAAG,CAAC,oEAAoE,QAAQ,GAAG,IAAI,uCAAuC,CAAC,CAAC;IAClI,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Pure helper for the forwarded-message mark — the agent-facing
|
|
3
|
+
* `[Forwarded message · from: … · originally sent: …]` line the bot glues ahead
|
|
4
|
+
* of a prompt when the operator FORWARDS a message into a bound, agent-active
|
|
5
|
+
* topic. Without it the agent reads the forwarded words as the operator's own
|
|
6
|
+
* (it once took two forwarded bot alerts, sent as examples, for a report).
|
|
7
|
+
*
|
|
8
|
+
* Plain English (agent-facing, NOT i18n) and folded ahead of the prompt by the
|
|
9
|
+
* same rule as the reply quote (`getPromptWithMessageContext`): a forwarded text,
|
|
10
|
+
* a caption, a voice note's transcript and a file announcement all carry it.
|
|
11
|
+
*
|
|
12
|
+
* The input is STRUCTURAL (no telegraf imports) so the helper is unit-testable;
|
|
13
|
+
* the bridge that reads a real telegraf message lives in the Telegram connector
|
|
14
|
+
* (`getTelegramForwardedMark`).
|
|
15
|
+
*/
|
|
16
|
+
/** What the origin's name stands for, as it reads in the mark. */
|
|
17
|
+
declare const originKindLabels: {
|
|
18
|
+
readonly user: "user";
|
|
19
|
+
readonly hiddenUser: "hidden user";
|
|
20
|
+
readonly chat: "chat";
|
|
21
|
+
readonly channel: "channel";
|
|
22
|
+
};
|
|
23
|
+
/** The four kinds of origin Telegram reports for a forwarded message. */
|
|
24
|
+
export type ForwardedOriginKind = keyof typeof originKindLabels;
|
|
25
|
+
/**
|
|
26
|
+
* @description The origin of a forwarded message, distilled from a telegraf
|
|
27
|
+
* `forward_origin` by the Telegram connector.
|
|
28
|
+
*/
|
|
29
|
+
export interface ForwardedMarkSource {
|
|
30
|
+
kind: ForwardedOriginKind;
|
|
31
|
+
/** The sender's display name, or the chat / channel title; empty when Telegram gave none. */
|
|
32
|
+
name: string;
|
|
33
|
+
/** A user's `@username`, when they have one. */
|
|
34
|
+
username?: string;
|
|
35
|
+
/** The post author's signature (a channel post, an anonymous group admin). */
|
|
36
|
+
signature?: string;
|
|
37
|
+
/** When the message was ORIGINALLY sent, unix seconds. */
|
|
38
|
+
originalSentAtSeconds?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* @description Who first wrote a forwarded message, as it reads in the mark and in the header of a reply to it:
|
|
42
|
+
* `channel "Ops Alerts"`, `user "Alice Smith" (@alice)`, `chat "Team room" (signed "Chief")`. A name is quoted, so
|
|
43
|
+
* the origin cannot be told apart from what it says.
|
|
44
|
+
*/
|
|
45
|
+
export declare function describeForwardedOrigin(source: ForwardedMarkSource): string;
|
|
46
|
+
/**
|
|
47
|
+
* @description Render the mark, or `null` when the message was not forwarded.
|
|
48
|
+
* The original date is the instance-local ISO instant the `/timestamps` line
|
|
49
|
+
* uses, so the agent reads both on one clock; it is left out when Telegram gave
|
|
50
|
+
* no usable date.
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildForwardedMark(source: ForwardedMarkSource | undefined): string | null;
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=forwardedMark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forwardedMark.d.ts","sourceRoot":"","sources":["../../src/utils/forwardedMark.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAWH,kEAAkE;AAClE,QAAA,MAAM,gBAAgB;;;;;CAKZ,CAAC;AAEX,yEAAyE;AACzE,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,gBAAgB,CAAC;AAEhE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,6FAA6F;IAC7F,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAmBD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAU3E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CASzF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description Pure helper for the forwarded-message mark — the agent-facing
|
|
4
|
+
* `[Forwarded message · from: … · originally sent: …]` line the bot glues ahead
|
|
5
|
+
* of a prompt when the operator FORWARDS a message into a bound, agent-active
|
|
6
|
+
* topic. Without it the agent reads the forwarded words as the operator's own
|
|
7
|
+
* (it once took two forwarded bot alerts, sent as examples, for a report).
|
|
8
|
+
*
|
|
9
|
+
* Plain English (agent-facing, NOT i18n) and folded ahead of the prompt by the
|
|
10
|
+
* same rule as the reply quote (`getPromptWithMessageContext`): a forwarded text,
|
|
11
|
+
* a caption, a voice note's transcript and a file announcement all carry it.
|
|
12
|
+
*
|
|
13
|
+
* The input is STRUCTURAL (no telegraf imports) so the helper is unit-testable;
|
|
14
|
+
* the bridge that reads a real telegraf message lives in the Telegram connector
|
|
15
|
+
* (`getTelegramForwardedMark`).
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.describeForwardedOrigin = describeForwardedOrigin;
|
|
19
|
+
exports.buildForwardedMark = buildForwardedMark;
|
|
20
|
+
const isoTimestamp_1 = require("./isoTimestamp");
|
|
21
|
+
const stripControlCharacters_1 = require("./stripControlCharacters");
|
|
22
|
+
/** Header prefix of the mark — recognisable, agent-facing English. */
|
|
23
|
+
const forwardedMarkHeaderPrefix = '[Forwarded message · from: ';
|
|
24
|
+
/** Milliseconds in a second: Telegram dates are unix SECONDS, `formatIsoLocalOffset` takes ms. */
|
|
25
|
+
const millisecondsPerSecond = 1000;
|
|
26
|
+
/** What the origin's name stands for, as it reads in the mark. */
|
|
27
|
+
const originKindLabels = {
|
|
28
|
+
user: 'user',
|
|
29
|
+
hiddenUser: 'hidden user',
|
|
30
|
+
chat: 'chat',
|
|
31
|
+
channel: 'channel',
|
|
32
|
+
};
|
|
33
|
+
/** Fallback for an origin with no name at all. */
|
|
34
|
+
const unknownOriginName = 'unknown';
|
|
35
|
+
/**
|
|
36
|
+
* A third party's text (a sender's name, a chat's title, a post signature — all chosen by someone else) as ONE line
|
|
37
|
+
* that cannot take part in the mark's own syntax: control and bidirectional characters out, whitespace flattened, and the square brackets that
|
|
38
|
+
* close the header turned into parentheses.
|
|
39
|
+
*/
|
|
40
|
+
function cleanThirdPartyText(value) {
|
|
41
|
+
return (0, stripControlCharacters_1.stripControlCharacters)(value).replace(/\s+/g, ' ').trim().replace(/\[/g, '(').replace(/\]/g, ')');
|
|
42
|
+
}
|
|
43
|
+
/** A cleaned text as a quoted token: what a stranger wrote reads as DATA, whatever it says (`"` and `\` are escaped). */
|
|
44
|
+
function quoteCleanText(cleanText) {
|
|
45
|
+
return JSON.stringify(cleanText);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @description Who first wrote a forwarded message, as it reads in the mark and in the header of a reply to it:
|
|
49
|
+
* `channel "Ops Alerts"`, `user "Alice Smith" (@alice)`, `chat "Team room" (signed "Chief")`. A name is quoted, so
|
|
50
|
+
* the origin cannot be told apart from what it says.
|
|
51
|
+
*/
|
|
52
|
+
function describeForwardedOrigin(source) {
|
|
53
|
+
const cleanName = cleanThirdPartyText(source.name);
|
|
54
|
+
const name = cleanName ? quoteCleanText(cleanName) : unknownOriginName;
|
|
55
|
+
const cleanUsername = source.username ? cleanThirdPartyText(source.username) : '';
|
|
56
|
+
const cleanSignature = source.signature ? cleanThirdPartyText(source.signature) : '';
|
|
57
|
+
const details = [
|
|
58
|
+
...(cleanUsername ? [`@${cleanUsername}`] : []),
|
|
59
|
+
...(cleanSignature ? [`signed ${quoteCleanText(cleanSignature)}`] : []),
|
|
60
|
+
];
|
|
61
|
+
return `${originKindLabels[source.kind]} ${name}${details.length > 0 ? ` (${details.join(', ')})` : ''}`;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @description Render the mark, or `null` when the message was not forwarded.
|
|
65
|
+
* The original date is the instance-local ISO instant the `/timestamps` line
|
|
66
|
+
* uses, so the agent reads both on one clock; it is left out when Telegram gave
|
|
67
|
+
* no usable date.
|
|
68
|
+
*/
|
|
69
|
+
function buildForwardedMark(source) {
|
|
70
|
+
if (!source)
|
|
71
|
+
return null;
|
|
72
|
+
const parts = [
|
|
73
|
+
`${forwardedMarkHeaderPrefix}${describeForwardedOrigin(source)}`,
|
|
74
|
+
...(source.originalSentAtSeconds && source.originalSentAtSeconds > 0
|
|
75
|
+
? [`originally sent: ${(0, isoTimestamp_1.formatIsoLocalOffset)(source.originalSentAtSeconds * millisecondsPerSecond)}`]
|
|
76
|
+
: []),
|
|
77
|
+
];
|
|
78
|
+
return `${parts.join(' · ')}]`;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=forwardedMark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forwardedMark.js","sourceRoot":"","sources":["../../src/utils/forwardedMark.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AA4DH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G;QACd,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,UAAU,cAAc,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACxE,CAAC;IACF,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC3G,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,MAAuC;IACxE,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,KAAK,GAAG;QACZ,GAAG,yBAAyB,GAAG,uBAAuB,CAAC,MAAM,CAAC,EAAE;QAChE,GAAG,CAAC,MAAM,CAAC,qBAAqB,IAAI,MAAM,CAAC,qBAAqB,GAAG,CAAC;YAClE,CAAC,CAAC,CAAC,oBAAoB,IAAA,mCAAoB,EAAC,MAAM,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,EAAE,CAAC;YACpG,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;IACF,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;AACjC,CAAC"}
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
*/
|
|
10
10
|
/** Held per conversation at most; a scheduler firing all through a long wait must not flood the resume. */
|
|
11
11
|
export declare const limitHeldPromptsMax = 10;
|
|
12
|
+
/**
|
|
13
|
+
* The line that opens the held prompts after a message's own text. The message may be a forwarded one, whose mark has no end: without a
|
|
14
|
+
* line of their own the scheduled runs below would read as the rest of the forwarded words.
|
|
15
|
+
*/
|
|
16
|
+
export declare const heldPromptsHeader = "[Held over the usage-limit wait \u2014 not part of the message above]";
|
|
12
17
|
/**
|
|
13
18
|
* @name LimitHeldPrompt
|
|
14
19
|
* @description A prompt held over a usage-limit wait. `text` is the prompt as it
|
|
@@ -32,8 +37,9 @@ export declare function getHeldPromptsWith(held: readonly LimitHeldPrompt[], pro
|
|
|
32
37
|
};
|
|
33
38
|
/**
|
|
34
39
|
* @description The forwarded `text` with the held prompts after it, in arrival
|
|
35
|
-
* order — one message, so nothing can slip between them
|
|
36
|
-
*
|
|
40
|
+
* order — one message, so nothing can slip between them — under a line of their
|
|
41
|
+
* own ({@link heldPromptsHeader}), so they never read as part of `text`. A held
|
|
42
|
+
* copy of `text` itself is not repeated: it is being delivered right now.
|
|
37
43
|
*/
|
|
38
44
|
export declare function getTextWithHeldPrompts(text: string, held: readonly LimitHeldPrompt[]): string;
|
|
39
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limitHeldPrompts.d.ts","sourceRoot":"","sources":["../../src/utils/limitHeldPrompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,2GAA2G;AAC3G,eAAO,MAAM,mBAAmB,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"limitHeldPrompts.d.ts","sourceRoot":"","sources":["../../src/utils/limitHeldPrompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,2GAA2G;AAC3G,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAGtC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,0EAAqE,CAAC;AAEpG;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAOD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,eAAe,EAAE,EAChC,MAAM,EAAE,eAAe,GACtB;IAAE,IAAI,EAAE,eAAe,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAKnD;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,CAG7F;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,eAAe,EAAE,GAAG,MAAM,GAAG,IAAI,CAElF;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,CAI7C"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* share the hold through `postToSession`.
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.limitHeldPromptsMax = void 0;
|
|
12
|
+
exports.heldPromptsHeader = exports.limitHeldPromptsMax = void 0;
|
|
13
13
|
exports.getHeldPromptsWith = getHeldPromptsWith;
|
|
14
14
|
exports.getTextWithHeldPrompts = getTextWithHeldPrompts;
|
|
15
15
|
exports.getHeldPromptsText = getHeldPromptsText;
|
|
@@ -18,6 +18,11 @@ exports.getLimitResumeMessage = getLimitResumeMessage;
|
|
|
18
18
|
exports.limitHeldPromptsMax = 10;
|
|
19
19
|
/** Between two prompts delivered as one: each carries its own header. */
|
|
20
20
|
const heldPromptSeparator = '\n\n';
|
|
21
|
+
/**
|
|
22
|
+
* The line that opens the held prompts after a message's own text. The message may be a forwarded one, whose mark has no end: without a
|
|
23
|
+
* line of their own the scheduled runs below would read as the rest of the forwarded words.
|
|
24
|
+
*/
|
|
25
|
+
exports.heldPromptsHeader = '[Held over the usage-limit wait — not part of the message above]';
|
|
21
26
|
/** What a held prompt says when it is finally delivered. */
|
|
22
27
|
function getDeliveredText(prompt) {
|
|
23
28
|
return prompt.heldText ?? prompt.text;
|
|
@@ -37,11 +42,13 @@ function getHeldPromptsWith(held, prompt) {
|
|
|
37
42
|
}
|
|
38
43
|
/**
|
|
39
44
|
* @description The forwarded `text` with the held prompts after it, in arrival
|
|
40
|
-
* order — one message, so nothing can slip between them
|
|
41
|
-
*
|
|
45
|
+
* order — one message, so nothing can slip between them — under a line of their
|
|
46
|
+
* own ({@link heldPromptsHeader}), so they never read as part of `text`. A held
|
|
47
|
+
* copy of `text` itself is not repeated: it is being delivered right now.
|
|
42
48
|
*/
|
|
43
49
|
function getTextWithHeldPrompts(text, held) {
|
|
44
|
-
|
|
50
|
+
const heldTexts = held.filter((prompt) => prompt.text !== text).map(getDeliveredText);
|
|
51
|
+
return heldTexts.length === 0 ? text : [text, exports.heldPromptsHeader, ...heldTexts].join(heldPromptSeparator);
|
|
45
52
|
}
|
|
46
53
|
/**
|
|
47
54
|
* @description The held prompts as one message, for a session that starts with
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limitHeldPrompts.js","sourceRoot":"","sources":["../../src/utils/limitHeldPrompts.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;
|
|
1
|
+
{"version":3,"file":"limitHeldPrompts.js","sourceRoot":"","sources":["../../src/utils/limitHeldPrompts.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAmCH,gDAQC;AAQD,wDAGC;AAMD,gDAEC;AASD,sDAOC;AA5ED,2GAA2G;AAC9F,QAAA,mBAAmB,GAAG,EAAE,CAAC;AACtC,yEAAyE;AACzE,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC;;;GAGG;AACU,QAAA,iBAAiB,GAAG,kEAAkE,CAAC;AAcpG,4DAA4D;AAC5D,SAAS,gBAAgB,CAAC,MAAuB;IAC/C,OAAO,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAChC,IAAgC,EACh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IAAI,EAAE,KAAK,CAAC,aAAa,EAAE,eAAe,EAAE,KAAK,EAAE;QACvD,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,oBAAoB,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Pure helpers for the MESSAGE CONTEXT of a prompt — the agent-facing
|
|
3
|
+
* blocks the bot glues ahead of the operator's text because of how the Telegram
|
|
4
|
+
* message arrived: the reply-quote block (`replyQuote.ts`, the message it
|
|
5
|
+
* answers) and the forwarded mark (`forwardedMark.ts`, who first wrote it).
|
|
6
|
+
*
|
|
7
|
+
* The blocks ride the per-message body (like the `/timestamps` line), NOT the
|
|
8
|
+
* once-per-change preamble marker. One fold rule ({@link getPromptWithMessageContext})
|
|
9
|
+
* serves every route a prompt takes — the live forward (`forwardPromptToAgent`),
|
|
10
|
+
* the startup buffer, a file or album announcement — so a spoken or captioned
|
|
11
|
+
* message carries exactly what a typed one does.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @name MessageContext
|
|
15
|
+
* @description What a Telegram message carries besides its words: the `block` that leads the prompt (the reply quote,
|
|
16
|
+
* the forwarded mark) and whether the message was FORWARDED. A forwarded message is content and never control input:
|
|
17
|
+
* its text starting with `/` is not a slash command, a bare digit in it is not an answer, a phrase in it does not start
|
|
18
|
+
* an agent — see {@link checkIsSlashCommandPrompt}.
|
|
19
|
+
*/
|
|
20
|
+
export interface MessageContext {
|
|
21
|
+
block: string;
|
|
22
|
+
isForwarded: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @description The blocks that apply to one message as one context block, in the
|
|
26
|
+
* order given, or `undefined` when none does.
|
|
27
|
+
*/
|
|
28
|
+
export declare function joinMessageContextBlocks(blocks: ReadonlyArray<string | null | undefined>): string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* @description Whether `text` is a slash command for the agent (`/compact`, `/clear`…): a control token that no block,
|
|
31
|
+
* preamble or timestamp may be put ahead of. Never for a forwarded message, whose words are somebody else's: the mark
|
|
32
|
+
* ahead of them is exactly what makes them plain text.
|
|
33
|
+
*/
|
|
34
|
+
export declare function checkIsSlashCommandPrompt(text: string, context: MessageContext | undefined): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @description Lead a prompt with its message-context block — the ONE folding
|
|
37
|
+
* rule, shared by the live forward (`forwardPromptToAgent`) and a prompt buffered
|
|
38
|
+
* behind a session start, whose replay forwards the buffered text as is: a reply
|
|
39
|
+
* or a forward made while the agent boots must reach it exactly like one made after.
|
|
40
|
+
*
|
|
41
|
+
* The prompt is returned unchanged when there is no context, or when it is not an
|
|
42
|
+
* agent prompt at all:
|
|
43
|
+
* - a slash command typed by the operator is a control token for the agent, which
|
|
44
|
+
* a block ahead of it would corrupt into plain text (a FORWARDED message is
|
|
45
|
+
* never one — {@link checkIsSlashCommandPrompt});
|
|
46
|
+
* - a terminal topic's input is a shell command line, and typed into a shell
|
|
47
|
+
* the block's `> ` lines run as redirections that overwrite a file named by
|
|
48
|
+
* the quote's first word. A message there never carries a block either.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getPromptWithMessageContext(prompt: string, options: {
|
|
51
|
+
context: MessageContext | undefined;
|
|
52
|
+
isShellInput: boolean;
|
|
53
|
+
}): string;
|
|
54
|
+
//# sourceMappingURL=messageContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../src/utils/messageContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,GAAG,SAAS,CAG7G;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAEpG;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,OAAO,EAAE,cAAc,GAAG,SAAS,CAAC;IAAC,YAAY,EAAE,OAAO,CAAA;CAAE,GACtE,MAAM,CAIR"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description Pure helpers for the MESSAGE CONTEXT of a prompt — the agent-facing
|
|
4
|
+
* blocks the bot glues ahead of the operator's text because of how the Telegram
|
|
5
|
+
* message arrived: the reply-quote block (`replyQuote.ts`, the message it
|
|
6
|
+
* answers) and the forwarded mark (`forwardedMark.ts`, who first wrote it).
|
|
7
|
+
*
|
|
8
|
+
* The blocks ride the per-message body (like the `/timestamps` line), NOT the
|
|
9
|
+
* once-per-change preamble marker. One fold rule ({@link getPromptWithMessageContext})
|
|
10
|
+
* serves every route a prompt takes — the live forward (`forwardPromptToAgent`),
|
|
11
|
+
* the startup buffer, a file or album announcement — so a spoken or captioned
|
|
12
|
+
* message carries exactly what a typed one does.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.joinMessageContextBlocks = joinMessageContextBlocks;
|
|
16
|
+
exports.checkIsSlashCommandPrompt = checkIsSlashCommandPrompt;
|
|
17
|
+
exports.getPromptWithMessageContext = getPromptWithMessageContext;
|
|
18
|
+
const threadContextPreamble_1 = require("../threadContextPreamble");
|
|
19
|
+
/** Separator between the context blocks, and between them and the prompt they lead. */
|
|
20
|
+
const messageContextSeparator = '\n\n';
|
|
21
|
+
/**
|
|
22
|
+
* @description The blocks that apply to one message as one context block, in the
|
|
23
|
+
* order given, or `undefined` when none does.
|
|
24
|
+
*/
|
|
25
|
+
function joinMessageContextBlocks(blocks) {
|
|
26
|
+
const present = blocks.filter((block) => !!block);
|
|
27
|
+
return present.length > 0 ? present.join(messageContextSeparator) : undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @description Whether `text` is a slash command for the agent (`/compact`, `/clear`…): a control token that no block,
|
|
31
|
+
* preamble or timestamp may be put ahead of. Never for a forwarded message, whose words are somebody else's: the mark
|
|
32
|
+
* ahead of them is exactly what makes them plain text.
|
|
33
|
+
*/
|
|
34
|
+
function checkIsSlashCommandPrompt(text, context) {
|
|
35
|
+
return context?.isForwarded !== true && (0, threadContextPreamble_1.checkShouldSkipPreambleForText)(text);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @description Lead a prompt with its message-context block — the ONE folding
|
|
39
|
+
* rule, shared by the live forward (`forwardPromptToAgent`) and a prompt buffered
|
|
40
|
+
* behind a session start, whose replay forwards the buffered text as is: a reply
|
|
41
|
+
* or a forward made while the agent boots must reach it exactly like one made after.
|
|
42
|
+
*
|
|
43
|
+
* The prompt is returned unchanged when there is no context, or when it is not an
|
|
44
|
+
* agent prompt at all:
|
|
45
|
+
* - a slash command typed by the operator is a control token for the agent, which
|
|
46
|
+
* a block ahead of it would corrupt into plain text (a FORWARDED message is
|
|
47
|
+
* never one — {@link checkIsSlashCommandPrompt});
|
|
48
|
+
* - a terminal topic's input is a shell command line, and typed into a shell
|
|
49
|
+
* the block's `> ` lines run as redirections that overwrite a file named by
|
|
50
|
+
* the quote's first word. A message there never carries a block either.
|
|
51
|
+
*/
|
|
52
|
+
function getPromptWithMessageContext(prompt, options) {
|
|
53
|
+
const { context } = options;
|
|
54
|
+
if (!context || options.isShellInput || checkIsSlashCommandPrompt(prompt, context))
|
|
55
|
+
return prompt;
|
|
56
|
+
return `${context.block}${messageContextSeparator}${prompt}`;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=messageContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageContext.js","sourceRoot":"","sources":["../../src/utils/messageContext.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAuBH,4DAGC;AAOD,8DAEC;AAiBD,kEAOC;AAzDD,oEAA0E;AAE1E,uFAAuF;AACvF,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAcvC;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,MAAgD;IACvF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACnE,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAChF,CAAC;AAED;;;;GAIG;AACH,SAAgB,yBAAyB,CAAC,IAAY,EAAE,OAAmC;IACzF,OAAO,OAAO,EAAE,WAAW,KAAK,IAAI,IAAI,IAAA,sDAA8B,EAAC,IAAI,CAAC,CAAC;AAC/E,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,2BAA2B,CACzC,MAAc,EACd,OAAuE;IAEvE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,YAAY,IAAI,yBAAyB,CAAC,MAAM,EAAE,OAAO,CAAC;QAAE,OAAO,MAAM,CAAC;IAClG,OAAO,GAAG,OAAO,CAAC,KAAK,GAAG,uBAAuB,GAAG,MAAM,EAAE,CAAC;AAC/D,CAAC"}
|
|
@@ -61,9 +61,10 @@ export declare function fetchChatGptUsage(credential: OpenCodeProviderCredential
|
|
|
61
61
|
fetchImpl?: UsageFetchLike;
|
|
62
62
|
timeoutMs?: number;
|
|
63
63
|
nowMs?: number;
|
|
64
|
+
signal?: AbortSignal;
|
|
64
65
|
}): Promise<ClaudeUsageFetchResult>;
|
|
65
|
-
/** A provider's subscription usage reader: one poll with the stored credential. */
|
|
66
|
-
export type OpenCodeUsageReader = (credential: OpenCodeProviderCredential) => Promise<ClaudeUsageFetchResult>;
|
|
66
|
+
/** A provider's subscription usage reader: one poll with the stored credential; `signal` cancels it. */
|
|
67
|
+
export type OpenCodeUsageReader = (credential: OpenCodeProviderCredential, signal?: AbortSignal) => Promise<ClaudeUsageFetchResult>;
|
|
67
68
|
/** The subscription usage readers by provider id; a provider not here shows only its auth kind. */
|
|
68
69
|
export declare const openCodeUsageReaders: Readonly<Record<string, OpenCodeUsageReader>>;
|
|
69
70
|
export interface OpenCodeUsagePollerDeps {
|
|
@@ -77,10 +78,16 @@ export interface OpenCodeUsagePollerDeps {
|
|
|
77
78
|
log?: (line: string) => void;
|
|
78
79
|
}
|
|
79
80
|
export interface OpenCodeUsagePoller {
|
|
80
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Poll every provider `auth.json` lists; with `maxAgeMs`, only the subscriptions whose snapshot is older (or stale). A poll
|
|
83
|
+
* whose `signal` was aborted saves nothing: its caller has given up on it, and its late answer must not overwrite a newer one.
|
|
84
|
+
*/
|
|
81
85
|
refreshAll: (options?: {
|
|
82
86
|
maxAgeMs?: number;
|
|
87
|
+
signal?: AbortSignal;
|
|
83
88
|
}) => Promise<void>;
|
|
89
|
+
/** Mark the stored figures of every subscription that has a reader stale with `reason` (the caller gave up on a poll); the figures and their age stay. */
|
|
90
|
+
markAllStale: (reason: string) => void;
|
|
84
91
|
}
|
|
85
92
|
/**
|
|
86
93
|
* @description The poller of OpenCode providers' usage. For each provider in `auth.json`: an API key or an unknown record
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openCodeUsage.d.ts","sourceRoot":"","sources":["../../src/utils/openCodeUsage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAIL,KAAK,iBAAiB,EAEtB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACp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