openryoko 2026.10.8 → 2026.10.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/jimmy.js +51 -1
- package/dist/bin/jimmy.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/src/backup/archive.d.ts +65 -0
- package/dist/src/backup/archive.d.ts.map +1 -0
- package/dist/src/backup/archive.js +214 -0
- package/dist/src/backup/archive.js.map +1 -0
- package/dist/src/backup/catalog.d.ts +64 -0
- package/dist/src/backup/catalog.d.ts.map +1 -0
- package/dist/src/backup/catalog.js +252 -0
- package/dist/src/backup/catalog.js.map +1 -0
- package/dist/src/backup/database-restore.d.ts +63 -0
- package/dist/src/backup/database-restore.d.ts.map +1 -0
- package/dist/src/backup/database-restore.js +236 -0
- package/dist/src/backup/database-restore.js.map +1 -0
- package/dist/src/backup/database-source.d.ts +70 -0
- package/dist/src/backup/database-source.d.ts.map +1 -0
- package/dist/src/backup/database-source.js +70 -0
- package/dist/src/backup/database-source.js.map +1 -0
- package/dist/src/backup/format.d.ts +4 -0
- package/dist/src/backup/format.d.ts.map +1 -0
- package/dist/src/backup/format.js +15 -0
- package/dist/src/backup/format.js.map +1 -0
- package/dist/src/backup/gateway-liveness.d.ts +44 -0
- package/dist/src/backup/gateway-liveness.d.ts.map +1 -0
- package/dist/src/backup/gateway-liveness.js +120 -0
- package/dist/src/backup/gateway-liveness.js.map +1 -0
- package/dist/src/backup/inspect.d.ts +45 -0
- package/dist/src/backup/inspect.d.ts.map +1 -0
- package/dist/src/backup/inspect.js +291 -0
- package/dist/src/backup/inspect.js.map +1 -0
- package/dist/src/backup/layout.d.ts +11 -0
- package/dist/src/backup/layout.d.ts.map +1 -0
- package/dist/src/backup/layout.js +16 -0
- package/dist/src/backup/layout.js.map +1 -0
- package/dist/src/backup/limits.d.ts +54 -0
- package/dist/src/backup/limits.d.ts.map +1 -0
- package/dist/src/backup/limits.js +59 -0
- package/dist/src/backup/limits.js.map +1 -0
- package/dist/src/backup/manifest.d.ts +45 -0
- package/dist/src/backup/manifest.d.ts.map +1 -0
- package/dist/src/backup/manifest.js +77 -0
- package/dist/src/backup/manifest.js.map +1 -0
- package/dist/src/backup/restore.d.ts +73 -0
- package/dist/src/backup/restore.d.ts.map +1 -0
- package/dist/src/backup/restore.js +685 -0
- package/dist/src/backup/restore.js.map +1 -0
- package/dist/src/backup/run.d.ts +76 -0
- package/dist/src/backup/run.d.ts.map +1 -0
- package/dist/src/backup/run.js +181 -0
- package/dist/src/backup/run.js.map +1 -0
- package/dist/src/backup/scheduler.d.ts +51 -0
- package/dist/src/backup/scheduler.d.ts.map +1 -0
- package/dist/src/backup/scheduler.js +198 -0
- package/dist/src/backup/scheduler.js.map +1 -0
- package/dist/src/backup/settings.d.ts +44 -0
- package/dist/src/backup/settings.d.ts.map +1 -0
- package/dist/src/backup/settings.js +91 -0
- package/dist/src/backup/settings.js.map +1 -0
- package/dist/src/backup/space.d.ts +22 -0
- package/dist/src/backup/space.d.ts.map +1 -0
- package/dist/src/backup/space.js +47 -0
- package/dist/src/backup/space.js.map +1 -0
- package/dist/src/backup/state.d.ts +46 -0
- package/dist/src/backup/state.d.ts.map +1 -0
- package/dist/src/backup/state.js +137 -0
- package/dist/src/backup/state.js.map +1 -0
- package/dist/src/backup/tar.d.ts +64 -0
- package/dist/src/backup/tar.d.ts.map +1 -0
- package/dist/src/backup/tar.js +274 -0
- package/dist/src/backup/tar.js.map +1 -0
- package/dist/src/backup/targets.d.ts +85 -0
- package/dist/src/backup/targets.d.ts.map +1 -0
- package/dist/src/backup/targets.js +104 -0
- package/dist/src/backup/targets.js.map +1 -0
- package/dist/src/backup/walk.d.ts +42 -0
- package/dist/src/backup/walk.d.ts.map +1 -0
- package/dist/src/backup/walk.js +324 -0
- package/dist/src/backup/walk.js.map +1 -0
- package/dist/src/cli/backup.d.ts +45 -0
- package/dist/src/cli/backup.d.ts.map +1 -0
- package/dist/src/cli/backup.js +344 -0
- package/dist/src/cli/backup.js.map +1 -0
- package/dist/src/cli/bundled-skills.d.ts +7 -1
- package/dist/src/cli/bundled-skills.d.ts.map +1 -1
- package/dist/src/cli/bundled-skills.js +12 -2
- package/dist/src/cli/bundled-skills.js.map +1 -1
- package/dist/src/cli/config-failure.d.ts +18 -0
- package/dist/src/cli/config-failure.d.ts.map +1 -0
- package/dist/src/cli/config-failure.js +39 -0
- package/dist/src/cli/config-failure.js.map +1 -0
- package/dist/src/cli/gateway-audit.d.ts +3 -0
- package/dist/src/cli/gateway-audit.d.ts.map +1 -1
- package/dist/src/cli/gateway-audit.js +61 -14
- package/dist/src/cli/gateway-audit.js.map +1 -1
- package/dist/src/cli/gateway-url-backup.d.ts +21 -0
- package/dist/src/cli/gateway-url-backup.d.ts.map +1 -0
- package/dist/src/cli/gateway-url-backup.js +87 -0
- package/dist/src/cli/gateway-url-backup.js.map +1 -0
- package/dist/src/cli/home-copy.d.ts +37 -0
- package/dist/src/cli/home-copy.d.ts.map +1 -0
- package/dist/src/cli/home-copy.js +155 -0
- package/dist/src/cli/home-copy.js.map +1 -0
- package/dist/src/cli/interactive-config.d.ts +5 -0
- package/dist/src/cli/interactive-config.d.ts.map +1 -1
- package/dist/src/cli/interactive-config.js +16 -7
- package/dist/src/cli/interactive-config.js.map +1 -1
- package/dist/src/cli/migrate.d.ts +20 -0
- package/dist/src/cli/migrate.d.ts.map +1 -1
- package/dist/src/cli/migrate.js +365 -68
- package/dist/src/cli/migrate.js.map +1 -1
- package/dist/src/cli/migration-declarations.d.ts +24 -0
- package/dist/src/cli/migration-declarations.d.ts.map +1 -0
- package/dist/src/cli/migration-declarations.js +54 -0
- package/dist/src/cli/migration-declarations.js.map +1 -0
- package/dist/src/cli/start.d.ts.map +1 -1
- package/dist/src/cli/start.js +40 -1
- package/dist/src/cli/start.js.map +1 -1
- package/dist/src/connectors/chunked-send.d.ts +27 -0
- package/dist/src/connectors/chunked-send.d.ts.map +1 -0
- package/dist/src/connectors/chunked-send.js +40 -0
- package/dist/src/connectors/chunked-send.js.map +1 -0
- package/dist/src/connectors/cron/index.d.ts +10 -0
- package/dist/src/connectors/cron/index.d.ts.map +1 -1
- package/dist/src/connectors/cron/index.js +26 -3
- package/dist/src/connectors/cron/index.js.map +1 -1
- package/dist/src/connectors/discord/attachments.d.ts +25 -0
- package/dist/src/connectors/discord/attachments.d.ts.map +1 -0
- package/dist/src/connectors/discord/attachments.js +33 -0
- package/dist/src/connectors/discord/attachments.js.map +1 -0
- package/dist/src/connectors/discord/format.d.ts +17 -1
- package/dist/src/connectors/discord/format.d.ts.map +1 -1
- package/dist/src/connectors/discord/format.js +36 -6
- package/dist/src/connectors/discord/format.js.map +1 -1
- package/dist/src/connectors/discord/index.d.ts +12 -0
- package/dist/src/connectors/discord/index.d.ts.map +1 -1
- package/dist/src/connectors/discord/index.js +47 -40
- package/dist/src/connectors/discord/index.js.map +1 -1
- package/dist/src/connectors/discord/remote.d.ts +45 -1
- package/dist/src/connectors/discord/remote.d.ts.map +1 -1
- package/dist/src/connectors/discord/remote.js +147 -22
- package/dist/src/connectors/discord/remote.js.map +1 -1
- package/dist/src/connectors/slack/attachments.d.ts +25 -0
- package/dist/src/connectors/slack/attachments.d.ts.map +1 -0
- package/dist/src/connectors/slack/attachments.js +32 -0
- package/dist/src/connectors/slack/attachments.js.map +1 -0
- package/dist/src/connectors/slack/auth-test-cache.d.ts +22 -0
- package/dist/src/connectors/slack/auth-test-cache.d.ts.map +1 -0
- package/dist/src/connectors/slack/auth-test-cache.js +34 -0
- package/dist/src/connectors/slack/auth-test-cache.js.map +1 -0
- package/dist/src/connectors/slack/format.d.ts +6 -1
- package/dist/src/connectors/slack/format.d.ts.map +1 -1
- package/dist/src/connectors/slack/format.js +65 -13
- package/dist/src/connectors/slack/format.js.map +1 -1
- package/dist/src/connectors/slack/index.d.ts +4 -0
- package/dist/src/connectors/slack/index.d.ts.map +1 -1
- package/dist/src/connectors/slack/index.js +64 -52
- package/dist/src/connectors/slack/index.js.map +1 -1
- package/dist/src/connectors/slack/provider-auth-blocks.d.ts +62 -0
- package/dist/src/connectors/slack/provider-auth-blocks.d.ts.map +1 -0
- package/dist/src/connectors/slack/provider-auth-blocks.js +204 -0
- package/dist/src/connectors/slack/provider-auth-blocks.js.map +1 -0
- package/dist/src/connectors/slack/provider-auth.d.ts +126 -0
- package/dist/src/connectors/slack/provider-auth.d.ts.map +1 -0
- package/dist/src/connectors/slack/provider-auth.js +357 -0
- package/dist/src/connectors/slack/provider-auth.js.map +1 -0
- package/dist/src/connectors/telegram/index.d.ts +5 -0
- package/dist/src/connectors/telegram/index.d.ts.map +1 -1
- package/dist/src/connectors/telegram/index.js +14 -22
- package/dist/src/connectors/telegram/index.js.map +1 -1
- package/dist/src/connectors/whatsapp/index.d.ts +3 -0
- package/dist/src/connectors/whatsapp/index.d.ts.map +1 -1
- package/dist/src/connectors/whatsapp/index.js +33 -14
- package/dist/src/connectors/whatsapp/index.js.map +1 -1
- package/dist/src/cron/alert-throttle.d.ts +28 -0
- package/dist/src/cron/alert-throttle.d.ts.map +1 -0
- package/dist/src/cron/alert-throttle.js +106 -0
- package/dist/src/cron/alert-throttle.js.map +1 -0
- package/dist/src/cron/jobs.d.ts +8 -0
- package/dist/src/cron/jobs.d.ts.map +1 -1
- package/dist/src/cron/jobs.js +27 -1
- package/dist/src/cron/jobs.js.map +1 -1
- package/dist/src/cron/run-outcome.d.ts +28 -0
- package/dist/src/cron/run-outcome.d.ts.map +1 -0
- package/dist/src/cron/run-outcome.js +66 -0
- package/dist/src/cron/run-outcome.js.map +1 -0
- package/dist/src/cron/runner.d.ts.map +1 -1
- package/dist/src/cron/runner.js +68 -5
- package/dist/src/cron/runner.js.map +1 -1
- package/dist/src/cron/scheduler.d.ts +8 -1
- package/dist/src/cron/scheduler.d.ts.map +1 -1
- package/dist/src/cron/scheduler.js +11 -4
- package/dist/src/cron/scheduler.js.map +1 -1
- package/dist/src/cron/waiting-fires.d.ts +18 -0
- package/dist/src/cron/waiting-fires.d.ts.map +1 -0
- package/dist/src/cron/waiting-fires.js +49 -0
- package/dist/src/cron/waiting-fires.js.map +1 -0
- package/dist/src/engines/claude-interactive.d.ts +19 -3
- package/dist/src/engines/claude-interactive.d.ts.map +1 -1
- package/dist/src/engines/claude-interactive.js +42 -17
- package/dist/src/engines/claude-interactive.js.map +1 -1
- package/dist/src/engines/claude.d.ts.map +1 -1
- package/dist/src/engines/claude.js +38 -5
- package/dist/src/engines/claude.js.map +1 -1
- package/dist/src/engines/codex.d.ts.map +1 -1
- package/dist/src/engines/codex.js +1 -0
- package/dist/src/engines/codex.js.map +1 -1
- package/dist/src/engines/gemini.d.ts.map +1 -1
- package/dist/src/engines/gemini.js +1 -0
- package/dist/src/engines/gemini.js.map +1 -1
- package/dist/src/gateway/api.d.ts.map +1 -1
- package/dist/src/gateway/api.js +184 -160
- package/dist/src/gateway/api.js.map +1 -1
- package/dist/src/gateway/config-redaction.d.ts +32 -0
- package/dist/src/gateway/config-redaction.d.ts.map +1 -0
- package/dist/src/gateway/config-redaction.js +139 -0
- package/dist/src/gateway/config-redaction.js.map +1 -0
- package/dist/src/gateway/config-revision.d.ts +46 -0
- package/dist/src/gateway/config-revision.d.ts.map +1 -0
- package/dist/src/gateway/config-revision.js +63 -0
- package/dist/src/gateway/config-revision.js.map +1 -0
- package/dist/src/gateway/connector-config.d.ts +21 -0
- package/dist/src/gateway/connector-config.d.ts.map +1 -0
- package/dist/src/gateway/connector-config.js +24 -0
- package/dist/src/gateway/connector-config.js.map +1 -0
- package/dist/src/gateway/daemon-entry.js +5 -0
- package/dist/src/gateway/daemon-entry.js.map +1 -1
- package/dist/src/gateway/engine-health-monitor.d.ts +67 -0
- package/dist/src/gateway/engine-health-monitor.d.ts.map +1 -0
- package/dist/src/gateway/engine-health-monitor.js +221 -0
- package/dist/src/gateway/engine-health-monitor.js.map +1 -0
- package/dist/src/gateway/files.d.ts +7 -1
- package/dist/src/gateway/files.d.ts.map +1 -1
- package/dist/src/gateway/files.js +110 -217
- package/dist/src/gateway/files.js.map +1 -1
- package/dist/src/gateway/onboarding-personalize.d.ts +2 -0
- package/dist/src/gateway/onboarding-personalize.d.ts.map +1 -1
- package/dist/src/gateway/onboarding-personalize.js +17 -1
- package/dist/src/gateway/onboarding-personalize.js.map +1 -1
- package/dist/src/gateway/portal-config.d.ts +17 -3
- package/dist/src/gateway/portal-config.d.ts.map +1 -1
- package/dist/src/gateway/portal-config.js +52 -3
- package/dist/src/gateway/portal-config.js.map +1 -1
- package/dist/src/gateway/request-origin.d.ts +9 -0
- package/dist/src/gateway/request-origin.d.ts.map +1 -1
- package/dist/src/gateway/request-origin.js +10 -0
- package/dist/src/gateway/request-origin.js.map +1 -1
- package/dist/src/gateway/server.d.ts.map +1 -1
- package/dist/src/gateway/server.js +82 -59
- package/dist/src/gateway/server.js.map +1 -1
- package/dist/src/gateway/slack-connect-rollback.d.ts +23 -0
- package/dist/src/gateway/slack-connect-rollback.d.ts.map +1 -0
- package/dist/src/gateway/slack-connect-rollback.js +53 -0
- package/dist/src/gateway/slack-connect-rollback.js.map +1 -0
- package/dist/src/gateway/status-reconciler.d.ts +25 -7
- package/dist/src/gateway/status-reconciler.d.ts.map +1 -1
- package/dist/src/gateway/status-reconciler.js +86 -43
- package/dist/src/gateway/status-reconciler.js.map +1 -1
- package/dist/src/gateway/watcher.d.ts.map +1 -1
- package/dist/src/gateway/watcher.js +44 -3
- package/dist/src/gateway/watcher.js.map +1 -1
- package/dist/src/mcp/gateway-server.js +21 -3
- package/dist/src/mcp/gateway-server.js.map +1 -1
- package/dist/src/mcp/resolver.d.ts.map +1 -1
- package/dist/src/mcp/resolver.js +51 -1
- package/dist/src/mcp/resolver.js.map +1 -1
- package/dist/src/models/service.d.ts.map +1 -1
- package/dist/src/models/service.js +14 -8
- package/dist/src/models/service.js.map +1 -1
- package/dist/src/provider-auth/discovery.d.ts +16 -0
- package/dist/src/provider-auth/discovery.d.ts.map +1 -0
- package/dist/src/provider-auth/discovery.js +66 -0
- package/dist/src/provider-auth/discovery.js.map +1 -0
- package/dist/src/provider-auth/failure-notices.d.ts +29 -0
- package/dist/src/provider-auth/failure-notices.d.ts.map +1 -0
- package/dist/src/provider-auth/failure-notices.js +48 -0
- package/dist/src/provider-auth/failure-notices.js.map +1 -0
- package/dist/src/provider-auth/failure-signal.d.ts +22 -0
- package/dist/src/provider-auth/failure-signal.d.ts.map +1 -0
- package/dist/src/provider-auth/failure-signal.js +79 -0
- package/dist/src/provider-auth/failure-signal.js.map +1 -0
- package/dist/src/provider-auth/index.d.ts +26 -0
- package/dist/src/provider-auth/index.d.ts.map +1 -0
- package/dist/src/provider-auth/index.js +51 -0
- package/dist/src/provider-auth/index.js.map +1 -0
- package/dist/src/provider-auth/input.d.ts +44 -0
- package/dist/src/provider-auth/input.d.ts.map +1 -0
- package/dist/src/provider-auth/input.js +86 -0
- package/dist/src/provider-auth/input.js.map +1 -0
- package/dist/src/provider-auth/providers.d.ts +26 -0
- package/dist/src/provider-auth/providers.d.ts.map +1 -0
- package/dist/src/provider-auth/providers.js +86 -0
- package/dist/src/provider-auth/providers.js.map +1 -0
- package/dist/src/provider-auth/runtime.d.ts +21 -0
- package/dist/src/provider-auth/runtime.d.ts.map +1 -0
- package/dist/src/provider-auth/runtime.js +104 -0
- package/dist/src/provider-auth/runtime.js.map +1 -0
- package/dist/src/provider-auth/service.d.ts +70 -0
- package/dist/src/provider-auth/service.d.ts.map +1 -0
- package/dist/src/provider-auth/service.js +349 -0
- package/dist/src/provider-auth/service.js.map +1 -0
- package/dist/src/provider-auth/terminal.d.ts +21 -0
- package/dist/src/provider-auth/terminal.d.ts.map +1 -0
- package/dist/src/provider-auth/terminal.js +46 -0
- package/dist/src/provider-auth/terminal.js.map +1 -0
- package/dist/src/provider-auth/types.d.ts +123 -0
- package/dist/src/provider-auth/types.d.ts.map +1 -0
- package/dist/src/provider-auth/types.js +10 -0
- package/dist/src/provider-auth/types.js.map +1 -0
- package/dist/src/sessions/accounting.d.ts +3 -0
- package/dist/src/sessions/accounting.d.ts.map +1 -1
- package/dist/src/sessions/accounting.js +5 -0
- package/dist/src/sessions/accounting.js.map +1 -1
- package/dist/src/sessions/backup-integrity.d.ts +45 -0
- package/dist/src/sessions/backup-integrity.d.ts.map +1 -0
- package/dist/src/sessions/backup-integrity.js +122 -0
- package/dist/src/sessions/backup-integrity.js.map +1 -0
- package/dist/src/sessions/backup.d.ts +40 -2
- package/dist/src/sessions/backup.d.ts.map +1 -1
- package/dist/src/sessions/backup.js +88 -12
- package/dist/src/sessions/backup.js.map +1 -1
- package/dist/src/sessions/callbacks.d.ts +9 -0
- package/dist/src/sessions/callbacks.d.ts.map +1 -1
- package/dist/src/sessions/callbacks.js +55 -10
- package/dist/src/sessions/callbacks.js.map +1 -1
- package/dist/src/sessions/completion-batching.d.ts +82 -0
- package/dist/src/sessions/completion-batching.d.ts.map +1 -0
- package/dist/src/sessions/completion-batching.js +126 -0
- package/dist/src/sessions/completion-batching.js.map +1 -0
- package/dist/src/sessions/connector-command-guard.d.ts +66 -0
- package/dist/src/sessions/connector-command-guard.d.ts.map +1 -0
- package/dist/src/sessions/connector-command-guard.js +145 -0
- package/dist/src/sessions/connector-command-guard.js.map +1 -0
- package/dist/src/sessions/context.d.ts.map +1 -1
- package/dist/src/sessions/context.js +3 -4
- package/dist/src/sessions/context.js.map +1 -1
- package/dist/src/sessions/engine-fallback.d.ts +43 -1
- package/dist/src/sessions/engine-fallback.d.ts.map +1 -1
- package/dist/src/sessions/engine-fallback.js +266 -15
- package/dist/src/sessions/engine-fallback.js.map +1 -1
- package/dist/src/sessions/engine-health-gate.d.ts +83 -0
- package/dist/src/sessions/engine-health-gate.d.ts.map +1 -0
- package/dist/src/sessions/engine-health-gate.js +186 -0
- package/dist/src/sessions/engine-health-gate.js.map +1 -0
- package/dist/src/sessions/engine-login.d.ts +58 -0
- package/dist/src/sessions/engine-login.d.ts.map +1 -0
- package/dist/src/sessions/engine-login.js +107 -0
- package/dist/src/sessions/engine-login.js.map +1 -0
- package/dist/src/sessions/fork.d.ts.map +1 -1
- package/dist/src/sessions/fork.js +3 -1
- package/dist/src/sessions/fork.js.map +1 -1
- package/dist/src/sessions/goal-execution.d.ts.map +1 -1
- package/dist/src/sessions/goal-execution.js +8 -1
- package/dist/src/sessions/goal-execution.js.map +1 -1
- package/dist/src/sessions/limit-failure-notice.d.ts +41 -0
- package/dist/src/sessions/limit-failure-notice.d.ts.map +1 -0
- package/dist/src/sessions/limit-failure-notice.js +87 -0
- package/dist/src/sessions/limit-failure-notice.js.map +1 -0
- package/dist/src/sessions/lost-turn.d.ts +39 -0
- package/dist/src/sessions/lost-turn.d.ts.map +1 -0
- package/dist/src/sessions/lost-turn.js +32 -0
- package/dist/src/sessions/lost-turn.js.map +1 -0
- package/dist/src/sessions/manager.d.ts.map +1 -1
- package/dist/src/sessions/manager.js +104 -47
- package/dist/src/sessions/manager.js.map +1 -1
- package/dist/src/sessions/new-session-engine.d.ts +42 -0
- package/dist/src/sessions/new-session-engine.d.ts.map +1 -0
- package/dist/src/sessions/new-session-engine.js +100 -0
- package/dist/src/sessions/new-session-engine.js.map +1 -0
- package/dist/src/sessions/origin-delivery.d.ts +50 -4
- package/dist/src/sessions/origin-delivery.d.ts.map +1 -1
- package/dist/src/sessions/origin-delivery.js +108 -9
- package/dist/src/sessions/origin-delivery.js.map +1 -1
- package/dist/src/sessions/queue.d.ts +14 -0
- package/dist/src/sessions/queue.d.ts.map +1 -1
- package/dist/src/sessions/queue.js +38 -2
- package/dist/src/sessions/queue.js.map +1 -1
- package/dist/src/sessions/registry.d.ts +4 -2
- package/dist/src/sessions/registry.d.ts.map +1 -1
- package/dist/src/sessions/registry.js +21 -4
- package/dist/src/sessions/registry.js.map +1 -1
- package/dist/src/sessions/reply-disposition.d.ts +8 -0
- package/dist/src/sessions/reply-disposition.d.ts.map +1 -1
- package/dist/src/sessions/reply-disposition.js +8 -0
- package/dist/src/sessions/reply-disposition.js.map +1 -1
- package/dist/src/sessions/restart-resume.d.ts +234 -0
- package/dist/src/sessions/restart-resume.d.ts.map +1 -0
- package/dist/src/sessions/restart-resume.js +596 -0
- package/dist/src/sessions/restart-resume.js.map +1 -0
- package/dist/src/sessions/speaker-prefix.d.ts.map +1 -1
- package/dist/src/sessions/speaker-prefix.js +3 -1
- package/dist/src/sessions/speaker-prefix.js.map +1 -1
- package/dist/src/sessions/turn-delivery.d.ts +26 -0
- package/dist/src/sessions/turn-delivery.d.ts.map +1 -0
- package/dist/src/sessions/turn-delivery.js +34 -0
- package/dist/src/sessions/turn-delivery.js.map +1 -0
- package/dist/src/sessions/unrequested-stop.d.ts +26 -0
- package/dist/src/sessions/unrequested-stop.d.ts.map +1 -0
- package/dist/src/sessions/unrequested-stop.js +19 -0
- package/dist/src/sessions/unrequested-stop.js.map +1 -0
- package/dist/src/sessions/usage-limit-wait.d.ts +14 -0
- package/dist/src/sessions/usage-limit-wait.d.ts.map +1 -0
- package/dist/src/sessions/usage-limit-wait.js +9 -0
- package/dist/src/sessions/usage-limit-wait.js.map +1 -0
- package/dist/src/shared/attachment-download.d.ts +41 -0
- package/dist/src/shared/attachment-download.d.ts.map +1 -0
- package/dist/src/shared/attachment-download.js +110 -0
- package/dist/src/shared/attachment-download.js.map +1 -0
- package/dist/src/shared/attachment-notice.d.ts +24 -0
- package/dist/src/shared/attachment-notice.d.ts.map +1 -0
- package/dist/src/shared/attachment-notice.js +37 -0
- package/dist/src/shared/attachment-notice.js.map +1 -0
- package/dist/src/shared/attachments.d.ts +65 -0
- package/dist/src/shared/attachments.d.ts.map +1 -0
- package/dist/src/shared/attachments.js +153 -0
- package/dist/src/shared/attachments.js.map +1 -0
- package/dist/src/shared/childEnv.d.ts +15 -0
- package/dist/src/shared/childEnv.d.ts.map +1 -1
- package/dist/src/shared/childEnv.js +15 -0
- package/dist/src/shared/childEnv.js.map +1 -1
- package/dist/src/shared/claude-auto-memory.d.ts +33 -0
- package/dist/src/shared/claude-auto-memory.d.ts.map +1 -0
- package/dist/src/shared/claude-auto-memory.js +156 -0
- package/dist/src/shared/claude-auto-memory.js.map +1 -0
- package/dist/src/shared/claude-limit-reset.d.ts +54 -0
- package/dist/src/shared/claude-limit-reset.d.ts.map +1 -0
- package/dist/src/shared/claude-limit-reset.js +99 -0
- package/dist/src/shared/claude-limit-reset.js.map +1 -0
- package/dist/src/shared/config-error.d.ts +21 -0
- package/dist/src/shared/config-error.d.ts.map +1 -0
- package/dist/src/shared/config-error.js +37 -0
- package/dist/src/shared/config-error.js.map +1 -0
- package/dist/src/shared/config-file.d.ts +57 -0
- package/dist/src/shared/config-file.d.ts.map +1 -0
- package/dist/src/shared/config-file.js +217 -0
- package/dist/src/shared/config-file.js.map +1 -0
- package/dist/src/shared/config-yaml-edit.d.ts +20 -0
- package/dist/src/shared/config-yaml-edit.d.ts.map +1 -0
- package/dist/src/shared/config-yaml-edit.js +468 -0
- package/dist/src/shared/config-yaml-edit.js.map +1 -0
- package/dist/src/shared/config.d.ts.map +1 -1
- package/dist/src/shared/config.js +12 -4
- package/dist/src/shared/config.js.map +1 -1
- package/dist/src/shared/engine-fallback.d.ts +22 -0
- package/dist/src/shared/engine-fallback.d.ts.map +1 -1
- package/dist/src/shared/engine-fallback.js +55 -4
- package/dist/src/shared/engine-fallback.js.map +1 -1
- package/dist/src/shared/engine-health.d.ts +16 -0
- package/dist/src/shared/engine-health.d.ts.map +1 -1
- package/dist/src/shared/engine-health.js +42 -0
- package/dist/src/shared/engine-health.js.map +1 -1
- package/dist/src/shared/list-alignment.d.ts +23 -0
- package/dist/src/shared/list-alignment.d.ts.map +1 -0
- package/dist/src/shared/list-alignment.js +61 -0
- package/dist/src/shared/list-alignment.js.map +1 -0
- package/dist/src/shared/logger.d.ts.map +1 -1
- package/dist/src/shared/logger.js +104 -33
- package/dist/src/shared/logger.js.map +1 -1
- package/dist/src/shared/map-limited.d.ts +11 -0
- package/dist/src/shared/map-limited.d.ts.map +1 -0
- package/dist/src/shared/map-limited.js +30 -0
- package/dist/src/shared/map-limited.js.map +1 -0
- package/dist/src/shared/oneShotCli.d.ts.map +1 -1
- package/dist/src/shared/oneShotCli.js +4 -2
- package/dist/src/shared/oneShotCli.js.map +1 -1
- package/dist/src/shared/partial-delivery.d.ts +24 -0
- package/dist/src/shared/partial-delivery.d.ts.map +1 -0
- package/dist/src/shared/partial-delivery.js +46 -0
- package/dist/src/shared/partial-delivery.js.map +1 -0
- package/dist/src/shared/process-safety-net.d.ts +44 -0
- package/dist/src/shared/process-safety-net.d.ts.map +1 -0
- package/dist/src/shared/process-safety-net.js +88 -0
- package/dist/src/shared/process-safety-net.js.map +1 -0
- package/dist/src/shared/rateLimit.d.ts +45 -2
- package/dist/src/shared/rateLimit.d.ts.map +1 -1
- package/dist/src/shared/rateLimit.js +64 -2
- package/dist/src/shared/rateLimit.js.map +1 -1
- package/dist/src/shared/redact.d.ts.map +1 -1
- package/dist/src/shared/redact.js +11 -1
- package/dist/src/shared/redact.js.map +1 -1
- package/dist/src/shared/safe-file-name.d.ts +9 -0
- package/dist/src/shared/safe-file-name.d.ts.map +1 -0
- package/dist/src/shared/safe-file-name.js +16 -0
- package/dist/src/shared/safe-file-name.js.map +1 -0
- package/dist/src/shared/terminal-safe-text.d.ts +2 -0
- package/dist/src/shared/terminal-safe-text.d.ts.map +1 -0
- package/dist/src/shared/terminal-safe-text.js +21 -0
- package/dist/src/shared/terminal-safe-text.js.map +1 -0
- package/dist/src/shared/types.d.ts +75 -4
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/skills-sync/apply.d.ts +21 -0
- package/dist/src/skills-sync/apply.d.ts.map +1 -0
- package/dist/src/skills-sync/apply.js +209 -0
- package/dist/src/skills-sync/apply.js.map +1 -0
- package/dist/src/skills-sync/backup-run.d.ts +47 -0
- package/dist/src/skills-sync/backup-run.d.ts.map +1 -0
- package/dist/src/skills-sync/backup-run.js +150 -0
- package/dist/src/skills-sync/backup-run.js.map +1 -0
- package/dist/src/skills-sync/bounded-read.d.ts +32 -0
- package/dist/src/skills-sync/bounded-read.d.ts.map +1 -0
- package/dist/src/skills-sync/bounded-read.js +104 -0
- package/dist/src/skills-sync/bounded-read.js.map +1 -0
- package/dist/src/skills-sync/bundled.d.ts +28 -0
- package/dist/src/skills-sync/bundled.d.ts.map +1 -0
- package/dist/src/skills-sync/bundled.js +84 -0
- package/dist/src/skills-sync/bundled.js.map +1 -0
- package/dist/src/skills-sync/fingerprint.d.ts +32 -0
- package/dist/src/skills-sync/fingerprint.d.ts.map +1 -0
- package/dist/src/skills-sync/fingerprint.js +58 -0
- package/dist/src/skills-sync/fingerprint.js.map +1 -0
- package/dist/src/skills-sync/history.d.ts +44 -0
- package/dist/src/skills-sync/history.d.ts.map +1 -0
- package/dist/src/skills-sync/history.js +115 -0
- package/dist/src/skills-sync/history.js.map +1 -0
- package/dist/src/skills-sync/home-skill.d.ts +28 -0
- package/dist/src/skills-sync/home-skill.d.ts.map +1 -0
- package/dist/src/skills-sync/home-skill.js +67 -0
- package/dist/src/skills-sync/home-skill.js.map +1 -0
- package/dist/src/skills-sync/instance.d.ts +26 -0
- package/dist/src/skills-sync/instance.d.ts.map +1 -0
- package/dist/src/skills-sync/instance.js +128 -0
- package/dist/src/skills-sync/instance.js.map +1 -0
- package/dist/src/skills-sync/names.d.ts +25 -0
- package/dist/src/skills-sync/names.d.ts.map +1 -0
- package/dist/src/skills-sync/names.js +56 -0
- package/dist/src/skills-sync/names.js.map +1 -0
- package/dist/src/skills-sync/plan.d.ts +58 -0
- package/dist/src/skills-sync/plan.d.ts.map +1 -0
- package/dist/src/skills-sync/plan.js +132 -0
- package/dist/src/skills-sync/plan.js.map +1 -0
- package/dist/src/skills-sync/receipt.d.ts +61 -0
- package/dist/src/skills-sync/receipt.d.ts.map +1 -0
- package/dist/src/skills-sync/receipt.js +149 -0
- package/dist/src/skills-sync/receipt.js.map +1 -0
- package/dist/src/skills-sync/staging.d.ts +21 -0
- package/dist/src/skills-sync/staging.d.ts.map +1 -0
- package/dist/src/skills-sync/staging.js +81 -0
- package/dist/src/skills-sync/staging.js.map +1 -0
- package/dist/src/skills-sync/sync.d.ts +37 -0
- package/dist/src/skills-sync/sync.d.ts.map +1 -0
- package/dist/src/skills-sync/sync.js +201 -0
- package/dist/src/skills-sync/sync.js.map +1 -0
- package/dist/src/skills-sync/types.d.ts +66 -0
- package/dist/src/skills-sync/types.d.ts.map +1 -0
- package/dist/src/skills-sync/types.js +2 -0
- package/dist/src/skills-sync/types.js.map +1 -0
- package/dist/src/stt/config.d.ts +5 -0
- package/dist/src/stt/config.d.ts.map +1 -0
- package/dist/src/stt/config.js +18 -0
- package/dist/src/stt/config.js.map +1 -0
- package/dist/src/updates/maintenance.d.ts.map +1 -1
- package/dist/src/updates/maintenance.js +24 -4
- package/dist/src/updates/maintenance.js.map +1 -1
- package/dist/src/workflows/repository-mutex.d.ts +1 -1
- package/dist/web/404.html +1 -1
- package/dist/web/__next.__PAGE__.txt +11 -11
- package/dist/web/__next._full.txt +12 -12
- package/dist/web/__next._tree.txt +2 -2
- package/dist/web/_next/static/chunks/{0g5c5ppr8zmup.js → 20v6mri7epga5.js} +1 -1
- package/dist/web/_next/static/chunks/2u0328ngpt-ek.js +1 -0
- package/dist/web/_next/static/chunks/3f9i3f9q6v6_j.css +1 -0
- package/dist/web/_next/static/chunks/{08i7uo3uz6_fn.js → 3yy053rafgrzy.js} +1 -1
- package/dist/web/_not-found/__next._full.txt +10 -10
- package/dist/web/_not-found/__next._not-found.__PAGE__.txt +9 -9
- package/dist/web/_not-found/__next._tree.txt +2 -2
- package/dist/web/_not-found.html +1 -1
- package/dist/web/_not-found.txt +10 -10
- package/dist/web/chat/__next._full.txt +12 -12
- package/dist/web/chat/__next._tree.txt +2 -2
- package/dist/web/chat/__next.chat.__PAGE__.txt +11 -11
- package/dist/web/chat.html +1 -1
- package/dist/web/chat.txt +12 -12
- package/dist/web/cron/__next._full.txt +12 -12
- package/dist/web/cron/__next._tree.txt +2 -2
- package/dist/web/cron/__next.cron.__PAGE__.txt +11 -11
- package/dist/web/cron.html +1 -1
- package/dist/web/cron.txt +12 -12
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +12 -12
- package/dist/web/kanban/__next._full.txt +12 -12
- package/dist/web/kanban/__next._tree.txt +2 -2
- package/dist/web/kanban/__next.kanban.__PAGE__.txt +11 -11
- package/dist/web/kanban.html +1 -1
- package/dist/web/kanban.txt +12 -12
- package/dist/web/logs/__next._full.txt +12 -12
- package/dist/web/logs/__next._tree.txt +2 -2
- package/dist/web/logs/__next.logs.__PAGE__.txt +11 -11
- package/dist/web/logs.html +1 -1
- package/dist/web/logs.txt +12 -12
- package/dist/web/models/__next._full.txt +12 -12
- package/dist/web/models/__next._tree.txt +2 -2
- package/dist/web/models/__next.models.__PAGE__.txt +11 -11
- package/dist/web/models.html +1 -1
- package/dist/web/models.txt +12 -12
- package/dist/web/org/__next._full.txt +12 -12
- package/dist/web/org/__next._tree.txt +2 -2
- package/dist/web/org/__next.org.__PAGE__.txt +11 -11
- package/dist/web/org.html +1 -1
- package/dist/web/org.txt +12 -12
- package/dist/web/sessions/__next._full.txt +10 -10
- package/dist/web/sessions/__next._tree.txt +2 -2
- package/dist/web/sessions/__next.sessions.__PAGE__.txt +9 -9
- package/dist/web/sessions.html +1 -1
- package/dist/web/sessions.txt +10 -10
- package/dist/web/settings/__next._full.txt +12 -12
- package/dist/web/settings/__next._tree.txt +2 -2
- package/dist/web/settings/__next.settings.__PAGE__.txt +11 -11
- package/dist/web/settings.html +1 -1
- package/dist/web/settings.txt +12 -12
- package/dist/web/skills/__next._full.txt +12 -12
- package/dist/web/skills/__next._tree.txt +2 -2
- package/dist/web/skills/__next.skills.__PAGE__.txt +11 -11
- package/dist/web/skills.html +1 -1
- package/dist/web/skills.txt +12 -12
- package/package.json +2 -1
- package/template/AGENTS.md +48 -308
- package/template/CLAUDE.md +4 -349
- package/template/bundled-skill-history.json +377 -0
- package/template/config.default.yaml +52 -3
- package/template/docs/architecture.md +41 -3
- package/template/docs/backup.md +142 -0
- package/template/docs/connectors.md +192 -16
- package/template/docs/cron.md +30 -11
- package/template/docs/memory.md +47 -0
- package/template/docs/overview.md +6 -2
- package/template/docs/self-modification.md +11 -10
- package/template/docs/skills.md +77 -4
- package/template/migrations/0.3.0/MIGRATION.md +6 -0
- package/template/migrations/0.7.3/MIGRATION.md +6 -0
- package/template/migrations/0.7.5/MIGRATION.md +1 -1
- package/template/migrations/0.9.0/MIGRATION.md +6 -0
- package/template/migrations/2026.10.13/MIGRATION.md +76 -0
- package/template/migrations/2026.10.13/files/docs/architecture.md +112 -0
- package/template/migrations/2026.10.13/files/docs/automations.md +110 -0
- package/template/migrations/2026.10.13/files/docs/backup.md +142 -0
- package/template/migrations/2026.10.13/files/docs/connectors.md +370 -0
- package/template/migrations/2026.10.13/files/docs/cron-commands.md +52 -0
- package/template/migrations/2026.10.13/files/docs/cron.md +178 -0
- package/template/migrations/2026.10.13/files/docs/mcp.md +108 -0
- package/template/migrations/2026.10.13/files/docs/memory.md +47 -0
- package/template/migrations/2026.10.13/files/docs/org.md +111 -0
- package/template/migrations/2026.10.13/files/docs/overview.md +44 -0
- package/template/migrations/2026.10.13/files/docs/self-modification.md +71 -0
- package/template/migrations/2026.10.13/files/docs/skills.md +140 -0
- package/template/migrations/2026.10.13/files/skills/cron-manager/SKILL.md +107 -0
- package/template/migrations/2026.10.13/files/skills/management/SKILL.md +227 -0
- package/template/migrations/2026.10.13/files/skills/migrate/SKILL.md +194 -0
- package/template/migrations/2026.10.13/files/skills/onboarding/SKILL.md +153 -0
- package/template/migrations/2026.10.13/files/skills/openryoko-config/SKILL.md +35 -0
- package/template/migrations/2026.10.13/files/skills/openryoko-config/references/engine-fallback.md +98 -0
- package/template/migrations/2026.10.13/files/skills/openryoko-config/references/jev.md +89 -0
- package/template/migrations/2026.10.13/files/skills/openryoko-config/references/maintenance.md +49 -0
- package/template/migrations/2026.10.13/files/skills/openryoko-config/references/platform.md +100 -0
- package/template/migrations/2026.10.13/files/skills/self-heal/SKILL.md +187 -0
- package/template/migrations/2026.10.9/MIGRATION.md +44 -0
- package/template/migrations/2026.10.9/files/docs/memory.md +47 -0
- package/template/migrations/2026.10.9/files/skills/migrate/SKILL.md +194 -0
- package/template/migrations/2026.5.7/MIGRATION.md +6 -0
- package/template/migrations/2026.8.28/MIGRATION.md +6 -0
- package/template/migrations/2026.9.11/MIGRATION.md +6 -0
- package/template/skills/cron-manager/SKILL.md +10 -0
- package/template/skills/management/SKILL.md +5 -4
- package/template/skills/migrate/SKILL.md +47 -14
- package/template/skills/onboarding/SKILL.md +3 -3
- package/template/skills/openryoko-config/SKILL.md +1 -1
- package/template/skills/openryoko-config/references/engine-fallback.md +16 -5
- package/template/skills/openryoko-config/references/platform.md +23 -4
- package/template/skills/self-heal/SKILL.md +117 -44
- package/dist/src/engines/mock.d.ts +0 -16
- package/dist/src/engines/mock.d.ts.map +0 -1
- package/dist/src/engines/mock.js +0 -47
- package/dist/src/engines/mock.js.map +0 -1
- package/dist/src/shared/test-support/posix-mode.d.ts +0 -17
- package/dist/src/shared/test-support/posix-mode.d.ts.map +0 -1
- package/dist/src/shared/test-support/posix-mode.js +0 -23
- package/dist/src/shared/test-support/posix-mode.js.map +0 -1
- package/dist/web/_next/static/Oux0UBcCkbX5eOp9-vC4k/_buildManifest.js +0 -11
- package/dist/web/_next/static/Oux0UBcCkbX5eOp9-vC4k/_clientMiddlewareManifest.js +0 -1
- package/dist/web/_next/static/Oux0UBcCkbX5eOp9-vC4k/_ssgManifest.js +0 -1
- package/dist/web/_next/static/chunks/02h65sho8c14h.js +0 -1
- package/dist/web/_next/static/chunks/0ic18n-m7ixyw.css +0 -1
- package/dist/web/_next/static/chunks/19s8vn2kgy7q1.js +0 -1
- package/dist/web/_next/static/chunks/1_jm0szyu2the.js +0 -1
- package/dist/web/_next/static/chunks/1omdg4m5w9lgx.js +0 -1
- package/dist/web/_next/static/chunks/25nob1new8t4s.js +0 -79
- package/dist/web/_next/static/chunks/2iqxlc9wtxzm2.js +0 -1
- package/dist/web/_next/static/chunks/3_6klkygi417n.js +0 -1
- package/dist/web/_next/static/chunks/3alc-b00c58_3.css +0 -1
- /package/dist/web/_next/static/{70PNIyOj8-2kywAG6J41- → ov0mWzyHx0B5oEnTHE_pa}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{70PNIyOj8-2kywAG6J41- → ov0mWzyHx0B5oEnTHE_pa}/_clientMiddlewareManifest.js +0 -0
- /package/dist/web/_next/static/{70PNIyOj8-2kywAG6J41- → ov0mWzyHx0B5oEnTHE_pa}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How often a usage-limit failure that names its reset is posted.
|
|
3
|
+
*
|
|
4
|
+
* A turn that meets a limit it will not wait for fails at once, with the reset
|
|
5
|
+
* time for its answer. A conversation gets that answer every time: somebody
|
|
6
|
+
* asked. A cron job's delivery channel got it on every fire as well — the same
|
|
7
|
+
* text every fifteen minutes, for the days a weekly limit lasts. It is told
|
|
8
|
+
* once per limit period now. Every fire is still recorded as failed for that
|
|
9
|
+
* reason; only the repeat of a message already in the channel is held back.
|
|
10
|
+
*/
|
|
11
|
+
import { logger } from "../shared/logger.js";
|
|
12
|
+
import { claimUsageLimitAnnouncement, usageLimitAnnounced } from "./engine-health-gate.js";
|
|
13
|
+
/** The failures made for a limit that is not waited for, with the period each is about. */
|
|
14
|
+
const limitFailures = new WeakMap();
|
|
15
|
+
/** The same, by the session whose turn it was, for whoever reports that turn's
|
|
16
|
+
* failure onward (see limitFailureOf). The most recent sessions only: a cron
|
|
17
|
+
* job makes a new session on every fire, for as long as a limit lasts. */
|
|
18
|
+
const MAX_REMEMBERED_SESSIONS = 256;
|
|
19
|
+
const failedSessions = new Map();
|
|
20
|
+
/** Mark `failed` as the answer of a turn — `sessionId`'s, when it is known —
|
|
21
|
+
* that met `period` and will not wait for it. */
|
|
22
|
+
export function noteLimitFailure(failed, period, sessionId) {
|
|
23
|
+
limitFailures.set(failed, period);
|
|
24
|
+
if (sessionId && failed.error) {
|
|
25
|
+
failedSessions.delete(sessionId); // re-inserted below, as the most recent
|
|
26
|
+
failedSessions.set(sessionId, { period, error: failed.error });
|
|
27
|
+
for (const oldest of failedSessions.keys()) {
|
|
28
|
+
if (failedSessions.size <= MAX_REMEMBERED_SESSIONS)
|
|
29
|
+
break;
|
|
30
|
+
failedSessions.delete(oldest);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return failed;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The limit period a session's turn failed on, if that failure is still what
|
|
37
|
+
* the session records. For whoever reports the failure onward — the cron
|
|
38
|
+
* runner, for its alert — so that "was it a usage limit, and which" is not
|
|
39
|
+
* read back out of the wording of an error.
|
|
40
|
+
*
|
|
41
|
+
* A later turn, or a reply that could not be delivered, records something else
|
|
42
|
+
* on the session; then that is what failed, and this names nothing.
|
|
43
|
+
*/
|
|
44
|
+
export function limitFailureOf(session) {
|
|
45
|
+
const noted = session ? failedSessions.get(session.id) : undefined;
|
|
46
|
+
return noted && session?.lastError === noted.error ? noted.period : undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Whom a cron fire's replies reach: the channel its job delivers to, or the job
|
|
50
|
+
* when it delivers nowhere. Undefined for anything that is not a job's fire — a
|
|
51
|
+
* conversation, or a cron-started session that reports through another route.
|
|
52
|
+
* Counting by channel means every channel waiting for a job's output learns why
|
|
53
|
+
* none is coming, and learns it once however many jobs deliver there.
|
|
54
|
+
*/
|
|
55
|
+
function cronAudience(session) {
|
|
56
|
+
if (session.source !== "cron")
|
|
57
|
+
return undefined;
|
|
58
|
+
const meta = (session.transportMeta ?? {});
|
|
59
|
+
const { deliveryConnector, deliveryChannel, cronJobId } = meta;
|
|
60
|
+
if (typeof deliveryConnector === "string" && typeof deliveryChannel === "string")
|
|
61
|
+
return `cron-delivery:${deliveryConnector}:${deliveryChannel}`;
|
|
62
|
+
return typeof cronJobId === "string" ? `cron-job:${cronJobId}` : undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Deliver a turn's answer — unless it is a limit failure that its cron job's
|
|
66
|
+
* delivery channel has already been told for the same limit period, which is
|
|
67
|
+
* not posted again. "Told" means the post went out: one the channel refused is
|
|
68
|
+
* left for the next fire to try.
|
|
69
|
+
*
|
|
70
|
+
* Nothing is recorded as undelivered for a post that was held back: the turn
|
|
71
|
+
* failed on the limit, and that stays the reason on its session.
|
|
72
|
+
*/
|
|
73
|
+
export async function deliverUnlessAlreadyTold(session, result, deliver) {
|
|
74
|
+
const period = limitFailures.get(result);
|
|
75
|
+
const audience = period ? cronAudience(session) : undefined;
|
|
76
|
+
if (!period || !audience)
|
|
77
|
+
return deliver();
|
|
78
|
+
if (usageLimitAnnounced(period.engine, period.resetsAt, audience)) {
|
|
79
|
+
logger.info(`Session ${session.id}: not posting the ${period.engine} usage-limit failure again — its delivery channel was told for this limit period (resets ${period.resetsAt})`);
|
|
80
|
+
return { deliveredReply: false };
|
|
81
|
+
}
|
|
82
|
+
const delivery = await deliver();
|
|
83
|
+
if (delivery.failure === undefined)
|
|
84
|
+
claimUsageLimitAnnouncement(period.engine, period.resetsAt, audience);
|
|
85
|
+
return delivery;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=limit-failure-notice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limit-failure-notice.js","sourceRoot":"","sources":["../../../src/sessions/limit-failure-notice.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal receipt for a turn nobody is left to finish.
|
|
3
|
+
*
|
|
4
|
+
* A session can stay at status:"running" after its runner has gone — the web
|
|
5
|
+
* runner writes no receipt for a turn the gateway interrupted, on the
|
|
6
|
+
* understanding that a newer message's turn follows, and sometimes none does;
|
|
7
|
+
* and a queue row cancelled before it ran never reaches a runner at all.
|
|
8
|
+
* (An engine process that dies mid-turn is no longer one of these: the runner
|
|
9
|
+
* settles it as a failed turn itself — see settleUnrequestedStop.) Nothing in
|
|
10
|
+
* the process will ever settle such a session, so the status reconciler does
|
|
11
|
+
* it through this function.
|
|
12
|
+
*
|
|
13
|
+
* It honours the same contract as the runners' own completion
|
|
14
|
+
* (SessionManager.runSession / runWebSession): persist the outcome with its
|
|
15
|
+
* reason, wake the parent session, report the completion. Writing a bare
|
|
16
|
+
* "idle" here instead made a lost turn read as a success, and a parent waiting
|
|
17
|
+
* on the child was never woken.
|
|
18
|
+
*/
|
|
19
|
+
import type { Session } from "../shared/types.js";
|
|
20
|
+
/** Why the turn has no result. Reaches the operator (lastError), the dashboard
|
|
21
|
+
* (completion event) and the parent session (notification), so it says what
|
|
22
|
+
* to do next as well as what happened. */
|
|
23
|
+
export declare const LOST_TURN_ERROR: string;
|
|
24
|
+
export interface SettleLostTurnInput {
|
|
25
|
+
session: Session;
|
|
26
|
+
/** Wall-clock instant of the settle, in epoch milliseconds. */
|
|
27
|
+
now: number;
|
|
28
|
+
/** The session employee's `alwaysNotify` setting, when it has one. */
|
|
29
|
+
alwaysNotify?: boolean;
|
|
30
|
+
emit: (event: string, payload: unknown) => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Settle a lost turn. The status is "interrupted", not "error": the engine
|
|
34
|
+
* session and transcript are intact, so the next message resumes it, and a
|
|
35
|
+
* parent that lost its own turn keeps receiving its children's completions
|
|
36
|
+
* (callbacks do not wake a parent that is in "error").
|
|
37
|
+
*/
|
|
38
|
+
export declare function settleLostTurn(input: SettleLostTurnInput): Session | undefined;
|
|
39
|
+
//# sourceMappingURL=lost-turn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lost-turn.d.ts","sourceRoot":"","sources":["../../../src/sessions/lost-turn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAIlD;;2CAE2C;AAC3C,eAAO,MAAM,eAAe,QAEqC,CAAC;AAElE,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,+DAA+D;IAC/D,GAAG,EAAE,MAAM,CAAC;IACZ,sEAAsE;IACtE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,GAAG,SAAS,CAgB9E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { notifyParentSession } from "./callbacks.js";
|
|
2
|
+
import { updateSession } from "./registry.js";
|
|
3
|
+
/** Why the turn has no result. Reaches the operator (lastError), the dashboard
|
|
4
|
+
* (completion event) and the parent session (notification), so it says what
|
|
5
|
+
* to do next as well as what happened. */
|
|
6
|
+
export const LOST_TURN_ERROR = "Interrupted: the engine turn ended without a result (the engine process was lost, or its completion never arrived). "
|
|
7
|
+
+ "The last request was not answered — send it again to retry.";
|
|
8
|
+
/**
|
|
9
|
+
* Settle a lost turn. The status is "interrupted", not "error": the engine
|
|
10
|
+
* session and transcript are intact, so the next message resumes it, and a
|
|
11
|
+
* parent that lost its own turn keeps receiving its children's completions
|
|
12
|
+
* (callbacks do not wake a parent that is in "error").
|
|
13
|
+
*/
|
|
14
|
+
export function settleLostTurn(input) {
|
|
15
|
+
const settled = updateSession(input.session.id, {
|
|
16
|
+
status: "interrupted",
|
|
17
|
+
lastActivity: new Date(input.now).toISOString(),
|
|
18
|
+
lastError: LOST_TURN_ERROR,
|
|
19
|
+
});
|
|
20
|
+
if (!settled)
|
|
21
|
+
return undefined; // deleted while the sweep was looking at it
|
|
22
|
+
notifyParentSession(settled, { error: LOST_TURN_ERROR }, { alwaysNotify: input.alwaysNotify });
|
|
23
|
+
input.emit("session:completed", {
|
|
24
|
+
sessionId: settled.id,
|
|
25
|
+
employee: settled.employee ?? undefined,
|
|
26
|
+
title: settled.title,
|
|
27
|
+
result: null,
|
|
28
|
+
error: LOST_TURN_ERROR,
|
|
29
|
+
});
|
|
30
|
+
return settled;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=lost-turn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lost-turn.js","sourceRoot":"","sources":["../../../src/sessions/lost-turn.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;2CAE2C;AAC3C,MAAM,CAAC,MAAM,eAAe,GAC1B,sHAAsH;MACpH,6DAA6D,CAAC;AAWlE;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE;QAC9C,MAAM,EAAE,aAAa;QACrB,YAAY,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE;QAC/C,SAAS,EAAE,eAAe;KAC3B,CAAC,CAAC;IACH,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC,CAAC,4CAA4C;IAC5E,mBAAmB,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IAC/F,KAAK,CAAC,IAAI,CAAC,mBAAmB,EAAE;QAC9B,SAAS,EAAE,OAAO,CAAC,EAAE;QACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;QACvC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,eAAe;KACvB,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/sessions/manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/sessions/manager.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
1
|
import { cancelWorkflowAttemptDispatch, claimWorkflowAttemptDispatch, createSession, deleteSession, getOrCreateWorkflowAttemptSession, getSession, getSessionBySessionKey, getMessages, insertMessage, interruptSessionAttempt, listChildSessions, listPendingWorkflowAttemptDispatches, settleWorkflowAttemptDispatch, updateSession, } from "./registry.js";
|
|
3
2
|
import { isInterruptibleEngine } from "../shared/types.js";
|
|
4
3
|
import { continueWorkflowAttemptSession } from "./attempt-continuation.js";
|
|
@@ -6,22 +5,27 @@ import { workflowAttemptInterruptionCause } from "./workflow-interruptions.js";
|
|
|
6
5
|
import { recordTurnAccounting } from "./accounting.js";
|
|
7
6
|
import { runWithSessionGoal, sessionGoalOptions } from "./goal-execution.js";
|
|
8
7
|
import { conversationOutcome } from "./conversation-outcome.js";
|
|
9
|
-
import { buildEngineSyncPrompt, clearEngineSyncMarker, engineFallbackFailure, engineSyncSince, maybeRevertEngineOverride, runEngineWithResponseTimeout, runFallbackAttempts, waitForEngineRetry } from "./engine-fallback.js";
|
|
8
|
+
import { buildEngineSyncPrompt, clearEngineSyncMarker, engineFallbackFailure, engineSyncSince, failLimitThatOutlastsTheWait, isAwayFromEngine, maybeRevertEngineOverride, runEngineWithResponseTimeout, runFallbackAttempts, stoppedByShutdown, waitForEngineRetry } from "./engine-fallback.js";
|
|
9
|
+
import { startOnHealthyEngine } from "./new-session-engine.js";
|
|
10
10
|
import { notifyParentSession, notifyRateLimited, notifyRateLimitResumed, notifyDiscordChannel } from "./callbacks.js";
|
|
11
11
|
import { buildContext } from "./context.js";
|
|
12
|
-
import { normalizeDelivery, normalizeTurns
|
|
12
|
+
import { normalizeDelivery, normalizeTurns } from "./reply-disposition.js";
|
|
13
13
|
import { deliverToOriginConnector, isUndeliveredToOrigin, recordFailedOriginDelivery } from "./origin-delivery.js";
|
|
14
|
+
import { deliverTurn, recordUndeliveredTurn } from "./turn-delivery.js";
|
|
15
|
+
import { deliverUnlessAlreadyTold } from "./limit-failure-notice.js";
|
|
14
16
|
import { SessionQueue } from "./queue.js";
|
|
15
17
|
import { JINN_HOME } from "../shared/paths.js";
|
|
16
18
|
import { logger } from "../shared/logger.js";
|
|
17
19
|
import { resolveEffort } from "../shared/effort.js";
|
|
18
20
|
import { effortLevelsForModel } from "../shared/models.js";
|
|
19
|
-
import { computeNextRetryDelayMs, computeRateLimitDeadlineMs, detectRateLimit, isDeadSessionError, isPoisonedTranscriptError, isTransientServerError } from "../shared/rateLimit.js";
|
|
21
|
+
import { computeNextRetryDelayMs, computeRateLimitDeadlineMs, detectRateLimit, isDeadSessionError, isPoisonedTranscriptError, isTransientServerError, MAX_USAGE_LIMIT_WAIT_MS, withEarlierProgress } from "../shared/rateLimit.js";
|
|
20
22
|
import { getClaudeExpectedResetAt, isLikelyNearClaudeUsageLimit, recordClaudeRateLimit } from "../shared/usageAwareness.js";
|
|
21
23
|
import { buildSpeakerPrefix } from "./speaker-prefix.js";
|
|
24
|
+
import { guardConnectorMessage, senderMayManageSession } from "./connector-command-guard.js";
|
|
22
25
|
import { loadJobs } from "../cron/jobs.js";
|
|
23
26
|
import { setCronJobEnabled, triggerCronJob } from "../cron/scheduler.js";
|
|
24
27
|
import { checkBudget } from "../gateway/budgets.js";
|
|
28
|
+
import { holdAttachmentDirs, removeAttachmentDirs } from "../shared/attachments.js";
|
|
25
29
|
import { resolveMcpServers, writeMcpConfigFile, cleanupMcpConfigFile } from "../mcp/resolver.js";
|
|
26
30
|
const WORKFLOW_CAPABILITIES = { threading: false, messageEdits: false, reactions: false, attachments: false };
|
|
27
31
|
/** Inert connector a workflow attempt turn runs under: nothing to deliver to,
|
|
@@ -291,9 +295,13 @@ export class SessionManager {
|
|
|
291
295
|
return this.queue;
|
|
292
296
|
}
|
|
293
297
|
async route(msg, connector, opts = {}) {
|
|
294
|
-
if (await this.handleCommand(msg, connector))
|
|
298
|
+
if (await this.handleCommand(msg, connector)) {
|
|
299
|
+
// A command is answered on the spot: nothing will read what came attached to it.
|
|
300
|
+
removeAttachmentDirs(msg.attachments.flatMap((attachment) => attachment.localPath ?? []));
|
|
295
301
|
return;
|
|
302
|
+
}
|
|
296
303
|
let session = getSessionBySessionKey(msg.sessionKey);
|
|
304
|
+
let healthyStartNotice;
|
|
297
305
|
if (!session) {
|
|
298
306
|
session = createSession({
|
|
299
307
|
engine: opts.engine ?? opts.employee?.engine ?? this.config.engines.default,
|
|
@@ -313,6 +321,10 @@ export class SessionManager {
|
|
|
313
321
|
});
|
|
314
322
|
logger.info(`Created new session ${session.id} for ${msg.sessionKey}` +
|
|
315
323
|
(opts.employee ? ` (employee: ${opts.employee.name})` : ""));
|
|
324
|
+
// An engine already known to be out of allowance is not worth a failed
|
|
325
|
+
// turn to rediscover: start on its fallback, under the same temporary
|
|
326
|
+
// override a mid-turn switch records.
|
|
327
|
+
({ session, notice: healthyStartNotice } = startOnHealthyEngine(this.config, (name) => this.engines.get(name), session, opts));
|
|
316
328
|
}
|
|
317
329
|
else {
|
|
318
330
|
const mergedMeta = mergeTransportMeta(session.transportMeta, msg.transportMeta);
|
|
@@ -327,9 +339,14 @@ export class SessionManager {
|
|
|
327
339
|
session = maybeRevertEngineOverride(session);
|
|
328
340
|
const target = connector.reconstructTarget(msg.replyContext);
|
|
329
341
|
target.messageTs ??= msg.messageId;
|
|
342
|
+
if (healthyStartNotice)
|
|
343
|
+
await connector.replyMessage(target, healthyStartNotice).catch(() => { });
|
|
330
344
|
const attachmentPaths = msg.attachments
|
|
331
345
|
.map((attachment) => attachment.localPath)
|
|
332
346
|
.filter((filePath) => !!filePath);
|
|
347
|
+
// Until this message's turn is over — it may wait a long time for it — the
|
|
348
|
+
// hourly sweep of old attachments must leave these alone.
|
|
349
|
+
holdAttachmentDirs(attachmentPaths);
|
|
333
350
|
if (session.status === "waiting") {
|
|
334
351
|
const expectedResetAt = getClaudeExpectedResetAt();
|
|
335
352
|
const resumeText = expectedResetAt
|
|
@@ -348,10 +365,17 @@ export class SessionManager {
|
|
|
348
365
|
try {
|
|
349
366
|
await this.queue.enqueue(msg.sessionKey, () => {
|
|
350
367
|
executionStarted = true;
|
|
351
|
-
return this.runSession(session, msg, attachmentPaths, connector, target, opts.employee);
|
|
368
|
+
return this.runSession(session, guardConnectorMessage(msg, this.config), attachmentPaths, connector, target, opts.employee);
|
|
352
369
|
});
|
|
353
370
|
}
|
|
354
371
|
finally {
|
|
372
|
+
// The turn is over, however it ended: it ran to its end, it was
|
|
373
|
+
// cancelled in the queue, or it stopped at one of runSession's early
|
|
374
|
+
// exits (engine not available, /goal on an engine that cannot take it,
|
|
375
|
+
// session gone). Its attachments — the message's own directory under
|
|
376
|
+
// tmp/attachments/, never any other path — are removed here, the one
|
|
377
|
+
// place every one of those ways out passes through.
|
|
378
|
+
removeAttachmentDirs(attachmentPaths);
|
|
355
379
|
// A cancelled queue item never enters runSession's cleanup. Clear only
|
|
356
380
|
// that item's pending indicators; a started session may have deliberately
|
|
357
381
|
// delivered :eyes: as its final response and must retain that reaction.
|
|
@@ -400,6 +424,17 @@ export class SessionManager {
|
|
|
400
424
|
const session = getSession(sessionId);
|
|
401
425
|
if (!session)
|
|
402
426
|
return;
|
|
427
|
+
// Hooks come from the interactive Claude PTY alone. While a Claude
|
|
428
|
+
// session is held on its fallback engine, that PTY was left behind by the
|
|
429
|
+
// switch: the fallback engine is answering the turn Claude failed, and
|
|
430
|
+
// whatever the PTY still reports would be a second answer to it, or the
|
|
431
|
+
// failure of a turn nobody waits on. Only that case is ignored — a
|
|
432
|
+
// conversation that merely borrowed Claude and has gone back to its own
|
|
433
|
+
// engine still gets what Claude finishes for it in the background.
|
|
434
|
+
if (isAwayFromEngine(session, "claude")) {
|
|
435
|
+
logger.info(`Ignoring a late ${hook.hook_event_name} hook for session ${sessionId}: it was moved to ${session.engine} and has not returned`);
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
403
438
|
if (hook.hook_event_name === "StopFailure") {
|
|
404
439
|
// Background continuation failed — record it for operators, but don't
|
|
405
440
|
// post to the channel (nothing was promised; avoid error spam during
|
|
@@ -670,8 +705,9 @@ export class SessionManager {
|
|
|
670
705
|
if (isPoisoned) {
|
|
671
706
|
logger.warn(`Poisoned transcript for ${session.id} — clearing engine session id; not auto-retrying to avoid duplicate side effects`);
|
|
672
707
|
const meta = { ...(session.transportMeta || {}) };
|
|
708
|
+
// engineOverride stays: it is the session's way back to the engine it
|
|
709
|
+
// was moved off, and dropping it left the session on the substitute.
|
|
673
710
|
delete meta["engineSessions"];
|
|
674
|
-
delete meta["engineOverride"];
|
|
675
711
|
updateSession(session.id, { engineSessionId: null, transportMeta: meta });
|
|
676
712
|
session = { ...session, engineSessionId: null, transportMeta: meta };
|
|
677
713
|
// Blank the returned sessionId so the post-run persistence below does not
|
|
@@ -697,8 +733,7 @@ export class SessionManager {
|
|
|
697
733
|
if (isDead) {
|
|
698
734
|
logger.warn(`Dead session detected for ${session.id} — clearing stale engine IDs`);
|
|
699
735
|
const meta = { ...(session.transportMeta || {}) };
|
|
700
|
-
delete meta["engineSessions"];
|
|
701
|
-
delete meta["engineOverride"];
|
|
736
|
+
delete meta["engineSessions"]; // engineOverride stays, as above
|
|
702
737
|
updateSession(session.id, {
|
|
703
738
|
engineSessionId: null,
|
|
704
739
|
transportMeta: meta,
|
|
@@ -755,7 +790,9 @@ export class SessionManager {
|
|
|
755
790
|
await new Promise((r) => setTimeout(r, Math.min(20_000, delayMs - waited)));
|
|
756
791
|
}
|
|
757
792
|
const resumeId = result.sessionId?.trim() || session.engineSessionId || undefined;
|
|
758
|
-
result
|
|
793
|
+
// Still the same turn: the continuation's result carries what the
|
|
794
|
+
// run it continues was seen doing, for whoever judges or takes over.
|
|
795
|
+
result = withEarlierProgress(result, await runEngine(engine, {
|
|
759
796
|
prompt: "The previous response was interrupted by a temporary Anthropic API server error. " +
|
|
760
797
|
"The conversation history up to that point is intact. Continue and complete the original request now. " +
|
|
761
798
|
"If the work was already finished, reply with the final result.",
|
|
@@ -770,7 +807,7 @@ export class SessionManager {
|
|
|
770
807
|
remoteCwd: employee?.remoteCwd,
|
|
771
808
|
mcpConfigPath,
|
|
772
809
|
sessionId: session.id,
|
|
773
|
-
});
|
|
810
|
+
}));
|
|
774
811
|
wasInterrupted = result.error?.startsWith("Interrupted");
|
|
775
812
|
if (wasInterrupted || !isTransientServerError(result))
|
|
776
813
|
break;
|
|
@@ -799,7 +836,7 @@ export class SessionManager {
|
|
|
799
836
|
mcpConfigPath: targetEngine.name === "claude" ? mcpConfigPath : undefined };
|
|
800
837
|
},
|
|
801
838
|
});
|
|
802
|
-
result = fallback
|
|
839
|
+
result = failLimitThatOutlastsTheWait(fallback);
|
|
803
840
|
session = fallback.session;
|
|
804
841
|
engine = fallback.engine;
|
|
805
842
|
if (!getSession(session.id)) {
|
|
@@ -817,7 +854,7 @@ export class SessionManager {
|
|
|
817
854
|
recordClaudeRateLimit(rateLimit.resetsAt);
|
|
818
855
|
const waitEmoji = "hourglass_flowing_sand";
|
|
819
856
|
const { delayMs, resumeAt } = computeNextRetryDelayMs(rateLimit.resetsAt);
|
|
820
|
-
const deadlineMs = computeRateLimitDeadlineMs(rateLimit.resetsAt, rateLimit.resetsAt ? 30 * 60_000 :
|
|
857
|
+
const deadlineMs = computeRateLimitDeadlineMs(rateLimit.resetsAt, rateLimit.resetsAt ? 30 * 60_000 : MAX_USAGE_LIMIT_WAIT_MS);
|
|
821
858
|
const resumeText = resumeAt
|
|
822
859
|
? resumeAt.toLocaleString("en-GB", { weekday: "short", day: "2-digit", month: "short", hour: "2-digit", minute: "2-digit" })
|
|
823
860
|
: null;
|
|
@@ -870,7 +907,7 @@ export class SessionManager {
|
|
|
870
907
|
await connector.addReaction(target, "eyes").catch(() => { });
|
|
871
908
|
}
|
|
872
909
|
logger.info(`Session ${session.id} retrying after usage limit (attempt ${attempt})`);
|
|
873
|
-
const
|
|
910
|
+
const retried = await runEngine(engine, {
|
|
874
911
|
prompt: msg.text,
|
|
875
912
|
resumeSessionId: currentSession.engineSessionId ?? undefined,
|
|
876
913
|
systemPrompt,
|
|
@@ -885,6 +922,13 @@ export class SessionManager {
|
|
|
885
922
|
attachments: attachments.length > 0 ? attachments : undefined,
|
|
886
923
|
sessionId: session.id,
|
|
887
924
|
});
|
|
925
|
+
// Told that the next reset is further off than a turn waits for, the
|
|
926
|
+
// wait ends the way a turn that starts on such a limit does: failed
|
|
927
|
+
// now, with the reset time for its answer — not slept through.
|
|
928
|
+
const retryResult = failLimitThatOutlastsTheWait({ result: retried, engine, attempted: false, session });
|
|
929
|
+
if (stoppedByShutdown(retryResult))
|
|
930
|
+
return; // not an answer: the next start resumes it
|
|
931
|
+
const gaveUp = retryResult !== retried;
|
|
888
932
|
const retryInterrupted = retryResult.error?.startsWith("Interrupted");
|
|
889
933
|
const retryRateLimit = !retryInterrupted ? detectRateLimit(retryResult) : { limited: false };
|
|
890
934
|
if (retryRateLimit.limited) {
|
|
@@ -927,28 +971,36 @@ export class SessionManager {
|
|
|
927
971
|
await connector.removeReaction(target, "eyes").catch(() => { });
|
|
928
972
|
await connector.removeReaction(target, waitEmoji).catch(() => { });
|
|
929
973
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
}
|
|
974
|
+
// Same rule as the ordinary path below: a reply the connector refuses
|
|
975
|
+
// is recorded as undelivered once the turn's state is written.
|
|
976
|
+
const { publicAction } = normalizeDelivery(retryText, this.buildDeliveryContext(session, msg, capabilities));
|
|
977
|
+
const retryDelivery = await deliverUnlessAlreadyTold(session, retryResult, () => deliverTurn(connector, target, [publicAction]));
|
|
978
|
+
recordDeliveredOutcome(retryResult, retryDelivery.deliveredReply);
|
|
936
979
|
const retryUpdated = updateSession(session.id, {
|
|
937
980
|
...(retryResult.sessionId?.trim() ? { engineSessionId: retryResult.sessionId } : {}),
|
|
938
981
|
status: retryResult.error ? "error" : "idle",
|
|
939
982
|
replyContext: msg.replyContext,
|
|
940
983
|
messageId: msg.messageId ?? null,
|
|
941
|
-
|
|
984
|
+
// Merge like the normal completion below: replacing the stored
|
|
985
|
+
// meta here dropped an active engine override, and the session
|
|
986
|
+
// then never went back to the engine it was moved off.
|
|
987
|
+
transportMeta: mergeTransportMeta(getSession(session.id)?.transportMeta ?? session.transportMeta, msg.transportMeta),
|
|
942
988
|
lastActivity: new Date().toISOString(),
|
|
943
989
|
lastError: retryResult.error ?? null,
|
|
944
990
|
...(typeof retryResult.contextTokens === "number" ? { lastContextTokens: retryResult.contextTokens } : {}),
|
|
945
991
|
});
|
|
946
992
|
if (retryUpdated) {
|
|
947
|
-
|
|
948
|
-
|
|
993
|
+
if (retryDelivery.failure !== undefined)
|
|
994
|
+
recordUndeliveredTurn(retryUpdated, retryDelivery.failure);
|
|
995
|
+
// A wait that was given up did not end with the limit clearing.
|
|
996
|
+
if (!gaveUp)
|
|
997
|
+
notifyRateLimitResumed(retryUpdated);
|
|
998
|
+
notifyDiscordChannel(gaveUp
|
|
999
|
+
? `❌ ${session.engine} usage limit did not clear in time. Session ${session.id}${session.employee ? ` (${session.employee})` : ""} has been stopped.`
|
|
1000
|
+
: `✅ ${session.engine} usage limit cleared. Session ${session.id}${session.employee ? ` (${session.employee})` : ""} resumed.`);
|
|
949
1001
|
notifyParentSession(retryUpdated, { result: retryResult.result, error: retryResult.error ?? null, cost: retryResult.cost, durationMs: retryResult.durationMs }, { alwaysNotify: employee?.alwaysNotify });
|
|
950
1002
|
}
|
|
951
|
-
logger.info(`Session ${session.id} resumed after usage reset`);
|
|
1003
|
+
logger.info(`Session ${session.id} ${gaveUp ? "stopped waiting: the next usage reset is too far off" : "resumed after usage reset"}`);
|
|
952
1004
|
return;
|
|
953
1005
|
}
|
|
954
1006
|
// Exhausted waiting window
|
|
@@ -994,6 +1046,10 @@ export class SessionManager {
|
|
|
994
1046
|
if (decorateMessages && capabilities.reactions) {
|
|
995
1047
|
await connector.removeReaction(target, "eyes").catch(() => { });
|
|
996
1048
|
}
|
|
1049
|
+
// A reply the connector refuses must not undo the turn: the engine has
|
|
1050
|
+
// finished, so its state is saved below either way, and the failure is
|
|
1051
|
+
// recorded as an undelivered reply once that state is written.
|
|
1052
|
+
let undelivered;
|
|
997
1053
|
if (!wasInterrupted && responseText) {
|
|
998
1054
|
// Sanitize engine output before posting: strip operator-facing notes
|
|
999
1055
|
// (reply-disposition trailer) so they never reach an external channel,
|
|
@@ -1004,18 +1060,12 @@ export class SessionManager {
|
|
|
1004
1060
|
// without ack multiplication; a single ack is added only if no turn was
|
|
1005
1061
|
// public. The last entry equals `result.result`.
|
|
1006
1062
|
const turns = result.turns ?? [];
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
}
|
|
1014
|
-
else {
|
|
1015
|
-
const { publicAction } = normalizeDelivery(responseText, deliveryCtx);
|
|
1016
|
-
await deliverPublic(connector, target, publicAction);
|
|
1017
|
-
recordDeliveredOutcome(result, publicAction.kind === "reply");
|
|
1018
|
-
}
|
|
1063
|
+
const actions = turns.length > 1
|
|
1064
|
+
? normalizeTurns(turns, deliveryCtx).actions
|
|
1065
|
+
: [normalizeDelivery(responseText, deliveryCtx).publicAction];
|
|
1066
|
+
const delivery = await deliverUnlessAlreadyTold(session, result, () => deliverTurn(connector, target, actions));
|
|
1067
|
+
recordDeliveredOutcome(result, delivery.deliveredReply);
|
|
1068
|
+
undelivered = delivery.failure;
|
|
1019
1069
|
}
|
|
1020
1070
|
const updatedSession = updateSession(session.id, {
|
|
1021
1071
|
...(result.sessionId?.trim() ? { engineSessionId: result.sessionId } : {}),
|
|
@@ -1032,6 +1082,8 @@ export class SessionManager {
|
|
|
1032
1082
|
...(typeof result.contextTokens === "number" ? { lastContextTokens: result.contextTokens } : {}),
|
|
1033
1083
|
});
|
|
1034
1084
|
if (updatedSession) {
|
|
1085
|
+
if (undelivered !== undefined)
|
|
1086
|
+
recordUndeliveredTurn(updatedSession, undelivered);
|
|
1035
1087
|
notifyParentSession(updatedSession, { result: result.result, error: wasInterrupted ? null : (result.error ?? null), cost: result.cost, durationMs: result.durationMs }, { alwaysNotify: employee?.alwaysNotify });
|
|
1036
1088
|
}
|
|
1037
1089
|
logger.info(`Session ${session.id} completed in ${result.durationMs ?? 0}ms` +
|
|
@@ -1059,15 +1111,8 @@ export class SessionManager {
|
|
|
1059
1111
|
}
|
|
1060
1112
|
}
|
|
1061
1113
|
finally {
|
|
1062
|
-
//
|
|
1063
|
-
|
|
1064
|
-
try {
|
|
1065
|
-
fs.rmSync(filePath, { force: true });
|
|
1066
|
-
}
|
|
1067
|
-
catch {
|
|
1068
|
-
// Ignore cleanup errors — best effort
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1114
|
+
// (The attachments downloaded for this message are removed by route(),
|
|
1115
|
+
// once the turn is over — whichever way it ended.)
|
|
1071
1116
|
if (mcpConfigPath)
|
|
1072
1117
|
cleanupMcpConfigFile(session.id);
|
|
1073
1118
|
}
|
|
@@ -1105,6 +1150,12 @@ export class SessionManager {
|
|
|
1105
1150
|
return true;
|
|
1106
1151
|
}
|
|
1107
1152
|
if (text.startsWith("/model")) {
|
|
1153
|
+
// Switching the model is a change to the session. On an instance with an
|
|
1154
|
+
// operator ID set, only the operator makes it; anyone else's "/model …"
|
|
1155
|
+
// is left to fall through and reach the assistant as an ordinary message
|
|
1156
|
+
// (no "not allowed" reply — the feature is simply not advertised).
|
|
1157
|
+
if (!senderMayManageSession(msg, this.config))
|
|
1158
|
+
return false;
|
|
1108
1159
|
const nextModel = text.slice("/model".length).trim();
|
|
1109
1160
|
if (!nextModel) {
|
|
1110
1161
|
await connector.replyMessage(target, "Usage: /model <model-name>");
|
|
@@ -1142,7 +1193,7 @@ export class SessionManager {
|
|
|
1142
1193
|
return true;
|
|
1143
1194
|
}
|
|
1144
1195
|
if (text.startsWith("/cron")) {
|
|
1145
|
-
return this.handleCronCommand(text, connector, target);
|
|
1196
|
+
return this.handleCronCommand(text, connector, target, senderMayManageSession(msg, this.config));
|
|
1146
1197
|
}
|
|
1147
1198
|
return false;
|
|
1148
1199
|
}
|
|
@@ -1157,7 +1208,7 @@ export class SessionManager {
|
|
|
1157
1208
|
logger.info(`Deleted session ${session.id}`);
|
|
1158
1209
|
}
|
|
1159
1210
|
}
|
|
1160
|
-
async handleCronCommand(text, connector, target) {
|
|
1211
|
+
async handleCronCommand(text, connector, target, mayManage) {
|
|
1161
1212
|
const [_, subcommand = "", ...rest] = text.split(/\s+/);
|
|
1162
1213
|
const arg = rest.join(" ").trim();
|
|
1163
1214
|
if (!subcommand || subcommand === "list") {
|
|
@@ -1170,6 +1221,12 @@ export class SessionManager {
|
|
|
1170
1221
|
await connector.replyMessage(target, ["Cron jobs:", ...lines].join("\n"));
|
|
1171
1222
|
return true;
|
|
1172
1223
|
}
|
|
1224
|
+
// run / enable / disable change the schedule. On an instance with an
|
|
1225
|
+
// operator ID set, only the operator runs them; anyone else's command is
|
|
1226
|
+
// left to fall through to the assistant as an ordinary message. Listing
|
|
1227
|
+
// (handled above) stays open to everyone.
|
|
1228
|
+
if (!mayManage)
|
|
1229
|
+
return false;
|
|
1173
1230
|
if (subcommand === "run") {
|
|
1174
1231
|
if (!arg) {
|
|
1175
1232
|
await connector.replyMessage(target, "Usage: /cron run <job-id-or-name>");
|