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
|
@@ -53,7 +53,9 @@ export function buildSpeakerPrefix(meta, context) {
|
|
|
53
53
|
speakerDiscordId: str(meta.speakerDiscordId),
|
|
54
54
|
...context,
|
|
55
55
|
});
|
|
56
|
-
|
|
56
|
+
// Brackets would close the line early; control characters (line breaks
|
|
57
|
+
// included) act on the terminal the line is pasted into.
|
|
58
|
+
const safeName = name.replace(/[\[\]\u0000-\u001F\u007F-\u009F]/g, "").slice(0, 60);
|
|
57
59
|
const operator = context.operatorName?.trim();
|
|
58
60
|
const tag = operator
|
|
59
61
|
? isOp
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"speaker-prefix.js","sourceRoot":"","sources":["../../../src/sessions/speaker-prefix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAevD,0DAA0D;AAC1D,SAAS,GAAG,CAAC,CAAU;IACrB,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAuB,EACvB,OAAuE;IAEvE,6CAA6C;IAC7C,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEjE,MAAM,OAAO,GAAG;QACd,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC;QACrB,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC;QACzB,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC;QAC5B,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC;KACxB,CAAC;IACF,oEAAoE;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,uEAAuE;IACvE,wEAAwE;IACxE,2CAA2C;IAC3C,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,uBAAuB,CAAC;QAC1D,YAAY,EAAE,OAAO;QACrB,cAAc,EAAE,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;QACxC,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC;QAC5C,GAAG,OAAO;KACX,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"speaker-prefix.js","sourceRoot":"","sources":["../../../src/sessions/speaker-prefix.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAevD,0DAA0D;AAC1D,SAAS,GAAG,CAAC,CAAU;IACrB,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,IAAuB,EACvB,OAAuE;IAEvE,6CAA6C;IAC7C,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEjE,MAAM,OAAO,GAAG;QACd,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC;QACrB,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC;QACzB,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC;QAC5B,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC;KACxB,CAAC;IACF,oEAAoE;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,uEAAuE;IACvE,wEAAwE;IACxE,2CAA2C;IAC3C,MAAM,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,uBAAuB,CAAC;QAC1D,YAAY,EAAE,OAAO;QACrB,cAAc,EAAE,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;QACxC,gBAAgB,EAAE,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC;QAC5C,GAAG,OAAO;KACX,CAAC,CAAC;IACH,uEAAuE;IACvE,yDAAyD;IACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,mCAAmC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACpF,MAAM,QAAQ,GAAG,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,CAAC;IAC9C,MAAM,GAAG,GAAG,QAAQ;QAClB,CAAC,CAAC,IAAI;YACJ,CAAC,CAAC,iBAAiB;YACnB,CAAC,CAAC,uDAAuD,QAAQ,GAAG;QACtE,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,aAAa,QAAQ,GAAG,GAAG,GAAG,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Session, Target } from "../shared/types.js";
|
|
2
|
+
import { type PublicAction, type PublicDeliverer } from "./reply-disposition.js";
|
|
3
|
+
export interface TurnDelivery {
|
|
4
|
+
/** True when the turn's last public action was a text reply and it landed. */
|
|
5
|
+
deliveredReply: boolean;
|
|
6
|
+
/** Why a public action did not land. Absent when everything was delivered. */
|
|
7
|
+
failure?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Post a finished turn's public actions in order, and report how that went
|
|
11
|
+
* instead of throwing. By the time this runs the engine has produced its
|
|
12
|
+
* result: a connector that cannot take the reply must not turn a completed
|
|
13
|
+
* turn into a failed one, or keep its state from being saved.
|
|
14
|
+
*
|
|
15
|
+
* Delivery stops at the first action that fails — the ones after it would
|
|
16
|
+
* arrive without the message that leads into them.
|
|
17
|
+
*/
|
|
18
|
+
export declare function deliverTurn(connector: PublicDeliverer, target: Target, actions: readonly PublicAction[]): Promise<TurnDelivery>;
|
|
19
|
+
/**
|
|
20
|
+
* The turn is saved, but its reply never reached the conversation. Persist
|
|
21
|
+
* that on the session — the same record an undelivered background reply
|
|
22
|
+
* leaves, with the transport's reason added — and log why. Call it after the
|
|
23
|
+
* turn's own state update: it sets lastError.
|
|
24
|
+
*/
|
|
25
|
+
export declare function recordUndeliveredTurn(session: Session, failure: string): void;
|
|
26
|
+
//# sourceMappingURL=turn-delivery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-delivery.d.ts","sourceRoot":"","sources":["../../../src/sessions/turn-delivery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAiB,KAAK,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGhG,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,cAAc,EAAE,OAAO,CAAC;IACxB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,eAAe,EAC1B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,SAAS,YAAY,EAAE,GAC/B,OAAO,CAAC,YAAY,CAAC,CASvB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAK7E"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { logger } from "../shared/logger.js";
|
|
2
|
+
import { deliverPublic } from "./reply-disposition.js";
|
|
3
|
+
import { recordFailedOriginDelivery } from "./origin-delivery.js";
|
|
4
|
+
/**
|
|
5
|
+
* Post a finished turn's public actions in order, and report how that went
|
|
6
|
+
* instead of throwing. By the time this runs the engine has produced its
|
|
7
|
+
* result: a connector that cannot take the reply must not turn a completed
|
|
8
|
+
* turn into a failed one, or keep its state from being saved.
|
|
9
|
+
*
|
|
10
|
+
* Delivery stops at the first action that fails — the ones after it would
|
|
11
|
+
* arrive without the message that leads into them.
|
|
12
|
+
*/
|
|
13
|
+
export async function deliverTurn(connector, target, actions) {
|
|
14
|
+
for (const action of actions) {
|
|
15
|
+
try {
|
|
16
|
+
await deliverPublic(connector, target, action);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
return { deliveredReply: false, failure: err instanceof Error ? err.message : String(err) };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return { deliveredReply: actions.at(-1)?.kind === "reply" };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The turn is saved, but its reply never reached the conversation. Persist
|
|
26
|
+
* that on the session — the same record an undelivered background reply
|
|
27
|
+
* leaves, with the transport's reason added — and log why. Call it after the
|
|
28
|
+
* turn's own state update: it sets lastError.
|
|
29
|
+
*/
|
|
30
|
+
export function recordUndeliveredTurn(session, failure) {
|
|
31
|
+
logger.error(`Session ${session.id}: reply was not delivered to ${session.connector ?? session.source} — ${failure}`);
|
|
32
|
+
recordFailedOriginDelivery(session, undefined, failure);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=turn-delivery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-delivery.js","sourceRoot":"","sources":["../../../src/sessions/turn-delivery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAA2C,MAAM,wBAAwB,CAAC;AAChG,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AASlE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,SAA0B,EAC1B,MAAc,EACd,OAAgC;IAEhC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9F,CAAC;IACH,CAAC;IACD,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,OAAO,EAAE,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAgB,EAAE,OAAe;IACrE,MAAM,CAAC,KAAK,CACV,WAAW,OAAO,CAAC,EAAE,gCAAgC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,MAAM,OAAO,EAAE,CACxG,CAAC;IACF,0BAA0B,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The failure of an engine run that stopped without being asked to — how it is
|
|
3
|
+
* worded, and how a session that failed that way is recognised afterwards.
|
|
4
|
+
*
|
|
5
|
+
* settleUnrequestedStop() (engine-fallback.ts) turns such a run into a failed
|
|
6
|
+
* one: the engine's process died, or its own turn deadline ran out. The session
|
|
7
|
+
* ends up in "error" like any other failure, but it is not like the others. A
|
|
8
|
+
* session stopped by a usage limit or a lost login fails again on its next
|
|
9
|
+
* turn; this one has its engine session and its transcript intact, and its next
|
|
10
|
+
* turn simply starts a new process.
|
|
11
|
+
*
|
|
12
|
+
* Whoever has to tell the two apart asks here. This module is the one place
|
|
13
|
+
* that knows the wording, and it depends on nothing, so that anything — the
|
|
14
|
+
* callback that wakes a parent for its children — can ask without pulling in
|
|
15
|
+
* the engine runner.
|
|
16
|
+
*/
|
|
17
|
+
import type { Session } from "../shared/types.js";
|
|
18
|
+
/** The error a run that stopped without being asked to is settled with. */
|
|
19
|
+
export declare function unrequestedStopError(engineName: string, detail: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* True while a session is in the error its last turn was settled with because
|
|
22
|
+
* its engine stopped without being asked to. The next turn that settles — or
|
|
23
|
+
* anything else that rewrites lastError — ends it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function failedByUnrequestedStop(session: Pick<Session, "status" | "lastError">): boolean;
|
|
26
|
+
//# sourceMappingURL=unrequested-stop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unrequested-stop.d.ts","sourceRoot":"","sources":["../../../src/sessions/unrequested-stop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAMlD,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,CAAC,GAAG,OAAO,CAI/F"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const STOPPED_UNEXPECTEDLY = " stopped unexpectedly: ";
|
|
2
|
+
/** What the wording starts with: the engine's name, and nothing before it. */
|
|
3
|
+
const ENGINE_NAME = /^[\w.-]+$/;
|
|
4
|
+
/** The error a run that stopped without being asked to is settled with. */
|
|
5
|
+
export function unrequestedStopError(engineName, detail) {
|
|
6
|
+
return `${engineName}${STOPPED_UNEXPECTEDLY}${detail}`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* True while a session is in the error its last turn was settled with because
|
|
10
|
+
* its engine stopped without being asked to. The next turn that settles — or
|
|
11
|
+
* anything else that rewrites lastError — ends it.
|
|
12
|
+
*/
|
|
13
|
+
export function failedByUnrequestedStop(session) {
|
|
14
|
+
if (session.status !== "error" || !session.lastError)
|
|
15
|
+
return false;
|
|
16
|
+
const at = session.lastError.indexOf(STOPPED_UNEXPECTEDLY);
|
|
17
|
+
return at > 0 && ENGINE_NAME.test(session.lastError.slice(0, at));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=unrequested-stop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unrequested-stop.js","sourceRoot":"","sources":["../../../src/sessions/unrequested-stop.ts"],"names":[],"mappings":"AAkBA,MAAM,oBAAoB,GAAG,yBAAyB,CAAC;AACvD,8EAA8E;AAC9E,MAAM,WAAW,GAAG,WAAW,CAAC;AAEhC,2EAA2E;AAC3E,MAAM,UAAU,oBAAoB,CAAC,UAAkB,EAAE,MAAc;IACrE,OAAO,GAAG,UAAU,GAAG,oBAAoB,GAAG,MAAM,EAAE,CAAC;AACzD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAA8C;IACpF,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IACnE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC3D,OAAO,EAAE,GAAG,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a parked turn expects its usage limit to reset.
|
|
3
|
+
*
|
|
4
|
+
* A turn that meets a usage limit with no engine to switch to is parked: its
|
|
5
|
+
* session goes to "waiting", and the runner notes the reset it is waiting for
|
|
6
|
+
* in `lastError`, as an ISO time ("<engine> usage limit — resumes <ISO>").
|
|
7
|
+
* The wait itself is a loop in the gateway process, so that note is all that
|
|
8
|
+
* is left of it on disk. This is the one place that reads it.
|
|
9
|
+
*/
|
|
10
|
+
import type { Session } from "../shared/types.js";
|
|
11
|
+
/** The reset (ISO) the usage-limit wait of a "waiting" session expects, when
|
|
12
|
+
* that wait knows it. Undefined for a session that is not waiting. */
|
|
13
|
+
export declare function usageLimitWaitResetsAt(session: Pick<Session, "status" | "lastError">): string | undefined;
|
|
14
|
+
//# sourceMappingURL=usage-limit-wait.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-limit-wait.d.ts","sourceRoot":"","sources":["../../../src/sessions/usage-limit-wait.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAIlD;uEACuE;AACvE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,WAAW,CAAC,GAAG,MAAM,GAAG,SAAS,CAGzG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const ISO_TIME = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z/;
|
|
2
|
+
/** The reset (ISO) the usage-limit wait of a "waiting" session expects, when
|
|
3
|
+
* that wait knows it. Undefined for a session that is not waiting. */
|
|
4
|
+
export function usageLimitWaitResetsAt(session) {
|
|
5
|
+
if (session.status !== "waiting")
|
|
6
|
+
return undefined;
|
|
7
|
+
return session.lastError?.match(ISO_TIME)?.[0];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=usage-limit-wait.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-limit-wait.js","sourceRoot":"","sources":["../../../src/sessions/usage-limit-wait.ts"],"names":[],"mappings":"AAWA,MAAM,QAAQ,GAAG,gDAAgD,CAAC;AAElE;uEACuE;AACvE,MAAM,UAAU,sBAAsB,CAAC,OAA8C;IACnF,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACnD,OAAO,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The largest attachment a connector downloads when its config does not say:
|
|
3
|
+
* `connectors.<name>.maxAttachmentMb`. How large a file is, is up to whoever
|
|
4
|
+
* sent it, so there has to be a limit; it is generous because people do send
|
|
5
|
+
* recordings and videos, and a file over it is not delivered to the session.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_MAX_ATTACHMENT_MB = 200;
|
|
8
|
+
/**
|
|
9
|
+
* A connector's attachment limit in bytes, from its `maxAttachmentMb`. The
|
|
10
|
+
* config is hand-edited YAML: anything that is not a positive number means
|
|
11
|
+
* the default, not "no limit" and not "nothing at all".
|
|
12
|
+
*/
|
|
13
|
+
export declare function attachmentLimitBytes(maxAttachmentMb: unknown): number;
|
|
14
|
+
/** `bytes` in megabytes, the way the setting is written: "200", "1.5", "0.5". */
|
|
15
|
+
export declare function megabytes(bytes: number): string;
|
|
16
|
+
/** The message says how large is too large, and nothing about the file. */
|
|
17
|
+
export declare class AttachmentTooLargeError extends Error {
|
|
18
|
+
/** The limit that was passed. */
|
|
19
|
+
readonly maxBytes: number;
|
|
20
|
+
constructor(maxBytes: number);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Save what `chunks` yields as the file `destPath`, refusing more than
|
|
24
|
+
* `maxBytes`.
|
|
25
|
+
*
|
|
26
|
+
* Each chunk is written as it arrives, so no more than one chunk is held in
|
|
27
|
+
* memory however large the file, and reading stops at the first chunk that
|
|
28
|
+
* passes the limit — the rest is never asked for. The directory is created
|
|
29
|
+
* once there is something to put in it. When the save fails, for size or for
|
|
30
|
+
* any other reason, nothing is left: neither the partial file nor a directory
|
|
31
|
+
* created for it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function saveWithin(chunks: AsyncIterable<Uint8Array>, destination: string, maxBytes: number): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Save the body of an HTTP response as `destPath`, refusing more than
|
|
36
|
+
* `maxBytes`. A body announced as larger is refused without being read; the
|
|
37
|
+
* announcement is not trusted beyond that, and the body is counted as it is
|
|
38
|
+
* read either way (see {@link saveWithin}).
|
|
39
|
+
*/
|
|
40
|
+
export declare function saveResponseWithin(res: Response, destPath: string, maxBytes: number): Promise<void>;
|
|
41
|
+
//# sourceMappingURL=attachment-download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-download.d.ts","sourceRoot":"","sources":["../../../src/shared/attachment-download.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,OAAO,GAAG,MAAM,CAIrE;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,2EAA2E;AAC3E,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,iCAAiC;IACjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBACd,QAAQ,EAAE,MAAM;CAK7B;AAqBD;;;;;;;;;;GAUG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBxH;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQzG"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
const BYTES_PER_MB = 1024 * 1024;
|
|
4
|
+
/**
|
|
5
|
+
* The largest attachment a connector downloads when its config does not say:
|
|
6
|
+
* `connectors.<name>.maxAttachmentMb`. How large a file is, is up to whoever
|
|
7
|
+
* sent it, so there has to be a limit; it is generous because people do send
|
|
8
|
+
* recordings and videos, and a file over it is not delivered to the session.
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_MAX_ATTACHMENT_MB = 200;
|
|
11
|
+
/**
|
|
12
|
+
* A connector's attachment limit in bytes, from its `maxAttachmentMb`. The
|
|
13
|
+
* config is hand-edited YAML: anything that is not a positive number means
|
|
14
|
+
* the default, not "no limit" and not "nothing at all".
|
|
15
|
+
*/
|
|
16
|
+
export function attachmentLimitBytes(maxAttachmentMb) {
|
|
17
|
+
const megabytes = typeof maxAttachmentMb === "number" && Number.isFinite(maxAttachmentMb) && maxAttachmentMb > 0 ? maxAttachmentMb : DEFAULT_MAX_ATTACHMENT_MB;
|
|
18
|
+
return Math.floor(megabytes * BYTES_PER_MB);
|
|
19
|
+
}
|
|
20
|
+
/** `bytes` in megabytes, the way the setting is written: "200", "1.5", "0.5". */
|
|
21
|
+
export function megabytes(bytes) {
|
|
22
|
+
return String(Number((bytes / BYTES_PER_MB).toFixed(2)));
|
|
23
|
+
}
|
|
24
|
+
/** The message says how large is too large, and nothing about the file. */
|
|
25
|
+
export class AttachmentTooLargeError extends Error {
|
|
26
|
+
/** The limit that was passed. */
|
|
27
|
+
maxBytes;
|
|
28
|
+
constructor(maxBytes) {
|
|
29
|
+
super(`Attachment is too large (limit ${maxBytes} bytes)`);
|
|
30
|
+
this.name = "AttachmentTooLargeError";
|
|
31
|
+
this.maxBytes = maxBytes;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Remove a failed save: the partial file, and the directories that were
|
|
36
|
+
* created for it. Deliberately weak tools — unlink removes one file, and a
|
|
37
|
+
* non-recursive rmdir removes a directory only while it is empty — so that
|
|
38
|
+
* whatever path this is handed, it cannot take anything else with it.
|
|
39
|
+
*/
|
|
40
|
+
async function discard(destPath, firstCreated) {
|
|
41
|
+
await fs.promises.unlink(destPath).catch(() => { });
|
|
42
|
+
if (firstCreated === undefined)
|
|
43
|
+
return;
|
|
44
|
+
for (let directory = path.dirname(destPath); directory.startsWith(firstCreated); directory = path.dirname(directory)) {
|
|
45
|
+
try {
|
|
46
|
+
await fs.promises.rmdir(directory);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return; // not empty (somebody else's file is in it), or already gone
|
|
50
|
+
}
|
|
51
|
+
if (directory === firstCreated)
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Save what `chunks` yields as the file `destPath`, refusing more than
|
|
57
|
+
* `maxBytes`.
|
|
58
|
+
*
|
|
59
|
+
* Each chunk is written as it arrives, so no more than one chunk is held in
|
|
60
|
+
* memory however large the file, and reading stops at the first chunk that
|
|
61
|
+
* passes the limit — the rest is never asked for. The directory is created
|
|
62
|
+
* once there is something to put in it. When the save fails, for size or for
|
|
63
|
+
* any other reason, nothing is left: neither the partial file nor a directory
|
|
64
|
+
* created for it.
|
|
65
|
+
*/
|
|
66
|
+
export async function saveWithin(chunks, destination, maxBytes) {
|
|
67
|
+
const destPath = path.resolve(destination);
|
|
68
|
+
let handle;
|
|
69
|
+
let firstCreated;
|
|
70
|
+
const open = async () => {
|
|
71
|
+
firstCreated = await fs.promises.mkdir(path.dirname(destPath), { recursive: true });
|
|
72
|
+
return fs.promises.open(destPath, "w");
|
|
73
|
+
};
|
|
74
|
+
try {
|
|
75
|
+
let received = 0;
|
|
76
|
+
for await (const chunk of chunks) {
|
|
77
|
+
received += chunk.byteLength;
|
|
78
|
+
if (received > maxBytes)
|
|
79
|
+
throw new AttachmentTooLargeError(maxBytes);
|
|
80
|
+
handle ??= await open();
|
|
81
|
+
await handle.write(chunk);
|
|
82
|
+
}
|
|
83
|
+
handle ??= await open(); // an empty body is an empty file
|
|
84
|
+
await handle.close();
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
await handle?.close().catch(() => { });
|
|
88
|
+
await discard(destPath, firstCreated);
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Save the body of an HTTP response as `destPath`, refusing more than
|
|
94
|
+
* `maxBytes`. A body announced as larger is refused without being read; the
|
|
95
|
+
* announcement is not trusted beyond that, and the body is counted as it is
|
|
96
|
+
* read either way (see {@link saveWithin}).
|
|
97
|
+
*/
|
|
98
|
+
export async function saveResponseWithin(res, destPath, maxBytes) {
|
|
99
|
+
const announced = Number(res.headers.get("content-length"));
|
|
100
|
+
if (Number.isFinite(announced) && announced > maxBytes) {
|
|
101
|
+
await res.body?.cancel().catch(() => { });
|
|
102
|
+
throw new AttachmentTooLargeError(maxBytes);
|
|
103
|
+
}
|
|
104
|
+
const body = res.body;
|
|
105
|
+
await saveWithin(body ?? emptyBody(), destPath, maxBytes);
|
|
106
|
+
}
|
|
107
|
+
async function* emptyBody() {
|
|
108
|
+
// nothing to yield
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=attachment-download.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-download.js","sourceRoot":"","sources":["../../../src/shared/attachment-download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,eAAwB;IAC3D,MAAM,SAAS,GACb,OAAO,eAAe,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC,IAAI,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,yBAAyB,CAAC;IAC/I,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,YAAY,CAAC,CAAC;AAC9C,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,2EAA2E;AAC3E,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,iCAAiC;IACxB,QAAQ,CAAS;IAC1B,YAAY,QAAgB;QAC1B,KAAK,CAAC,kCAAkC,QAAQ,SAAS,CAAC,CAAC;QAC3D,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED;;;;;GAKG;AACH,KAAK,UAAU,OAAO,CAAC,QAAgB,EAAE,YAAgC;IACvE,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACnD,IAAI,YAAY,KAAK,SAAS;QAAE,OAAO;IACvC,KAAK,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACrH,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,6DAA6D;QACvE,CAAC;QACD,IAAI,SAAS,KAAK,YAAY;YAAE,OAAO;IACzC,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAiC,EAAE,WAAmB,EAAE,QAAgB;IACvG,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3C,IAAI,MAA0C,CAAC;IAC/C,IAAI,YAAgC,CAAC;IACrC,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;QACtB,YAAY,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACpF,OAAO,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC,CAAC;IACF,IAAI,CAAC;QACH,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACjC,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC;YAC7B,IAAI,QAAQ,GAAG,QAAQ;gBAAE,MAAM,IAAI,uBAAuB,CAAC,QAAQ,CAAC,CAAC;YACrE,MAAM,KAAK,MAAM,IAAI,EAAE,CAAC;YACxB,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;QACD,MAAM,KAAK,MAAM,IAAI,EAAE,CAAC,CAAC,iCAAiC;QAC1D,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACtC,MAAM,OAAO,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACtC,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,GAAa,EAAE,QAAgB,EAAE,QAAgB;IACxF,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC5D,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;QACvD,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACzC,MAAM,IAAI,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,IAAuE,CAAC;IACzF,MAAM,UAAU,CAAC,IAAI,IAAI,SAAS,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC5D,CAAC;AAED,KAAK,SAAS,CAAC,CAAC,SAAS;IACvB,mBAAmB;AACrB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a connector names an attachment it did not retrieve: `what` — a label of
|
|
3
|
+
* the connector's own making, an opaque ID or a position, never the file's
|
|
4
|
+
* name — and the reason, when the reason is the file's size. Any other error
|
|
5
|
+
* is left out: its message may quote a URL or the name.
|
|
6
|
+
*/
|
|
7
|
+
export declare function failedAttachment(what: string, err: unknown): string;
|
|
8
|
+
/**
|
|
9
|
+
* What a connector appends to a message whose attachments did not all arrive.
|
|
10
|
+
*
|
|
11
|
+
* Keep attachment failures visible to the engine. Silently dropping a file can
|
|
12
|
+
* make a content-dependent task continue with invented or unrelated input —
|
|
13
|
+
* and with a size limit in force, "silently dropped" is what would happen to
|
|
14
|
+
* every large video. `failed` holds labels from {@link failedAttachment}: the
|
|
15
|
+
* notice is the connector's own text, with nothing of the sender's in it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function attachmentFailureNotice(platform: string, failed: readonly string[]): string;
|
|
18
|
+
/**
|
|
19
|
+
* `text` with the notice for `failed` appended. A slash command is passed on
|
|
20
|
+
* exactly as typed — the session manager matches it by its text, and a command
|
|
21
|
+
* reads no attachment anyway — and so is anything that is not text.
|
|
22
|
+
*/
|
|
23
|
+
export declare function withAttachmentNotice<T>(text: T, platform: string, failed: readonly string[]): T | string;
|
|
24
|
+
//# sourceMappingURL=attachment-notice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-notice.d.ts","sourceRoot":"","sources":["../../../src/shared/attachment-notice.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAEnE;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAO3F;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAGxG"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AttachmentTooLargeError, megabytes } from "./attachment-download.js";
|
|
2
|
+
/**
|
|
3
|
+
* How a connector names an attachment it did not retrieve: `what` — a label of
|
|
4
|
+
* the connector's own making, an opaque ID or a position, never the file's
|
|
5
|
+
* name — and the reason, when the reason is the file's size. Any other error
|
|
6
|
+
* is left out: its message may quote a URL or the name.
|
|
7
|
+
*/
|
|
8
|
+
export function failedAttachment(what, err) {
|
|
9
|
+
return err instanceof AttachmentTooLargeError ? `${what} (larger than the ${megabytes(err.maxBytes)} MB attachment limit)` : what;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* What a connector appends to a message whose attachments did not all arrive.
|
|
13
|
+
*
|
|
14
|
+
* Keep attachment failures visible to the engine. Silently dropping a file can
|
|
15
|
+
* make a content-dependent task continue with invented or unrelated input —
|
|
16
|
+
* and with a size limit in force, "silently dropped" is what would happen to
|
|
17
|
+
* every large video. `failed` holds labels from {@link failedAttachment}: the
|
|
18
|
+
* notice is the connector's own text, with nothing of the sender's in it.
|
|
19
|
+
*/
|
|
20
|
+
export function attachmentFailureNotice(platform, failed) {
|
|
21
|
+
if (failed.length === 0)
|
|
22
|
+
return "";
|
|
23
|
+
return (`\n\n[System attachment notice: The following ${platform} attachment(s) could not be retrieved: ` +
|
|
24
|
+
`${failed.join(", ")}. Do not infer or substitute their contents. ` +
|
|
25
|
+
"Explain that the attachment could not be read, and why where a reason is given, before doing any content-dependent work.]");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* `text` with the notice for `failed` appended. A slash command is passed on
|
|
29
|
+
* exactly as typed — the session manager matches it by its text, and a command
|
|
30
|
+
* reads no attachment anyway — and so is anything that is not text.
|
|
31
|
+
*/
|
|
32
|
+
export function withAttachmentNotice(text, platform, failed) {
|
|
33
|
+
if (typeof text !== "string" || text.trimStart().startsWith("/"))
|
|
34
|
+
return text;
|
|
35
|
+
return text + attachmentFailureNotice(platform, failed);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=attachment-notice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment-notice.js","sourceRoot":"","sources":["../../../src/shared/attachment-notice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,GAAY;IACzD,OAAO,GAAG,YAAY,uBAAuB,CAAC,CAAC,CAAC,GAAG,IAAI,qBAAqB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC;AACpI,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAgB,EAAE,MAAyB;IACjF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnC,OAAO,CACL,gDAAgD,QAAQ,yCAAyC;QACjG,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,+CAA+C;QACnE,2HAA2H,CAC5H,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAI,IAAO,EAAE,QAAgB,EAAE,MAAyB;IAC1F,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9E,OAAO,IAAI,GAAG,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where connectors keep the attachments they download: tmp/attachments/, one
|
|
3
|
+
* directory per incoming message.
|
|
4
|
+
*
|
|
5
|
+
* Not tmp/ itself. An attachment is named by whoever sent it, and tmp/ also
|
|
6
|
+
* holds the gateway's own state (engine-health.json, claude-usage.json): a
|
|
7
|
+
* file with one of those names would replace it, and the end-of-turn cleanup
|
|
8
|
+
* would then delete it. A directory per message also keeps two messages — or
|
|
9
|
+
* two files of one message — with the same file name from overwriting each
|
|
10
|
+
* other while a turn is still reading them.
|
|
11
|
+
*
|
|
12
|
+
* Absolute, always. The home can be given as a relative path (RYOKO_HOME=./home),
|
|
13
|
+
* and the cleanup below refuses every relative path it is handed — it must
|
|
14
|
+
* never guess what one is relative to. Left relative, this directory was
|
|
15
|
+
* refused along with them, and nothing was ever removed or swept. It is
|
|
16
|
+
* resolved here, once, against the directory the gateway was started in.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ATTACHMENTS_DIR: string;
|
|
19
|
+
/**
|
|
20
|
+
* A directory for the attachments of one incoming message. Only the name is
|
|
21
|
+
* decided here; whoever saves a file creates the directory, so a message
|
|
22
|
+
* without attachments (or whose downloads all fail) leaves nothing behind.
|
|
23
|
+
*/
|
|
24
|
+
export declare function newAttachmentDir(): string;
|
|
25
|
+
/**
|
|
26
|
+
* Where the `slot`-th attachment of a message goes inside that message's
|
|
27
|
+
* directory. One slot each, because one message can carry two files with the
|
|
28
|
+
* same name (Discord calls every pasted screenshot image.png).
|
|
29
|
+
*/
|
|
30
|
+
export declare function attachmentSlot(messageDir: string, slot: number): string;
|
|
31
|
+
/**
|
|
32
|
+
* Keep the per-message directories of these attachment files out of the
|
|
33
|
+
* sweep until {@link removeAttachmentDirs} is called for them. A turn can wait
|
|
34
|
+
* far longer than a day before it reads its attachments — behind a long
|
|
35
|
+
* session, or paused on a usage limit — and must still find them.
|
|
36
|
+
*/
|
|
37
|
+
export declare function holdAttachmentDirs(filePaths: readonly string[]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Remove the per-message directories the given attachment files were saved
|
|
40
|
+
* in. A path that is not inside tmp/attachments/ is left alone: this is called
|
|
41
|
+
* with whatever a connector put in `localPath`, and must never delete on its
|
|
42
|
+
* say-so anything but an attachment directory.
|
|
43
|
+
*/
|
|
44
|
+
export declare function removeAttachmentDirs(filePaths: readonly string[]): void;
|
|
45
|
+
/** How long a message's attachments stay when nothing came to remove them. */
|
|
46
|
+
export declare const STALE_ATTACHMENTS_AFTER_MS: number;
|
|
47
|
+
/**
|
|
48
|
+
* Remove what has been lying in tmp/attachments/ for longer than
|
|
49
|
+
* `olderThanMs`, and return how many entries went.
|
|
50
|
+
*
|
|
51
|
+
* Attachments are saved when a message arrives and removed when its turn
|
|
52
|
+
* ends. A message that never gets a turn — the bot stays silent on it, the
|
|
53
|
+
* gateway is restarted first — left its files for good, so that posting files
|
|
54
|
+
* where the bot reads was enough to fill the disk. Only direct children of
|
|
55
|
+
* tmp/attachments/ are removed (a link is removed as a link), never the
|
|
56
|
+
* directory itself, and never one a turn still holds.
|
|
57
|
+
*/
|
|
58
|
+
export declare function sweepStaleAttachmentDirs(now?: number, olderThanMs?: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* Sweep now — what a previous run of the gateway left behind — and then every
|
|
61
|
+
* hour. Returns the function that stops it. The timer never keeps the process
|
|
62
|
+
* alive on its own.
|
|
63
|
+
*/
|
|
64
|
+
export declare function startAttachmentSweep(): () => void;
|
|
65
|
+
//# sourceMappingURL=attachments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../../../src/shared/attachments.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,QAAuC,CAAC;AAEpE;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvE;AAqBD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAKrE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAcvE;AAED,8EAA8E;AAC9E,eAAO,MAAM,0BAA0B,QAAsB,CAAC;AAG9D;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,GAAE,MAAmB,EAAE,WAAW,GAAE,MAAmC,GAAG,MAAM,CAsB3H;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,IAAI,CASjD"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { logger } from "./logger.js";
|
|
5
|
+
import { TMP_DIR } from "./paths.js";
|
|
6
|
+
/**
|
|
7
|
+
* Where connectors keep the attachments they download: tmp/attachments/, one
|
|
8
|
+
* directory per incoming message.
|
|
9
|
+
*
|
|
10
|
+
* Not tmp/ itself. An attachment is named by whoever sent it, and tmp/ also
|
|
11
|
+
* holds the gateway's own state (engine-health.json, claude-usage.json): a
|
|
12
|
+
* file with one of those names would replace it, and the end-of-turn cleanup
|
|
13
|
+
* would then delete it. A directory per message also keeps two messages — or
|
|
14
|
+
* two files of one message — with the same file name from overwriting each
|
|
15
|
+
* other while a turn is still reading them.
|
|
16
|
+
*
|
|
17
|
+
* Absolute, always. The home can be given as a relative path (RYOKO_HOME=./home),
|
|
18
|
+
* and the cleanup below refuses every relative path it is handed — it must
|
|
19
|
+
* never guess what one is relative to. Left relative, this directory was
|
|
20
|
+
* refused along with them, and nothing was ever removed or swept. It is
|
|
21
|
+
* resolved here, once, against the directory the gateway was started in.
|
|
22
|
+
*/
|
|
23
|
+
export const ATTACHMENTS_DIR = path.resolve(TMP_DIR, "attachments");
|
|
24
|
+
/**
|
|
25
|
+
* A directory for the attachments of one incoming message. Only the name is
|
|
26
|
+
* decided here; whoever saves a file creates the directory, so a message
|
|
27
|
+
* without attachments (or whose downloads all fail) leaves nothing behind.
|
|
28
|
+
*/
|
|
29
|
+
export function newAttachmentDir() {
|
|
30
|
+
return path.join(ATTACHMENTS_DIR, randomUUID());
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Where the `slot`-th attachment of a message goes inside that message's
|
|
34
|
+
* directory. One slot each, because one message can carry two files with the
|
|
35
|
+
* same name (Discord calls every pasted screenshot image.png).
|
|
36
|
+
*/
|
|
37
|
+
export function attachmentSlot(messageDir, slot) {
|
|
38
|
+
return path.join(messageDir, String(slot));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The per-message directory under tmp/attachments/ that `filePath` lies in, or
|
|
42
|
+
* null when it lies anywhere else. A path that is not absolute is not
|
|
43
|
+
* resolved, it is refused: what it is relative to is anybody's guess.
|
|
44
|
+
*/
|
|
45
|
+
function messageDirOf(filePath) {
|
|
46
|
+
if (typeof filePath !== "string" || !path.isAbsolute(filePath) || !path.isAbsolute(ATTACHMENTS_DIR))
|
|
47
|
+
return null;
|
|
48
|
+
const root = path.normalize(ATTACHMENTS_DIR);
|
|
49
|
+
const relative = path.relative(root, path.normalize(filePath));
|
|
50
|
+
const [messageDir] = relative.split(path.sep);
|
|
51
|
+
if (!messageDir || messageDir === ".." || path.isAbsolute(relative))
|
|
52
|
+
return null;
|
|
53
|
+
const directory = path.join(root, messageDir);
|
|
54
|
+
// Checked once more where it counts: only a direct child of tmp/attachments/.
|
|
55
|
+
return path.dirname(directory) === root ? directory : null;
|
|
56
|
+
}
|
|
57
|
+
/** Directories a queued or running turn still reads from: the sweep leaves them. */
|
|
58
|
+
const heldDirs = new Set();
|
|
59
|
+
/**
|
|
60
|
+
* Keep the per-message directories of these attachment files out of the
|
|
61
|
+
* sweep until {@link removeAttachmentDirs} is called for them. A turn can wait
|
|
62
|
+
* far longer than a day before it reads its attachments — behind a long
|
|
63
|
+
* session, or paused on a usage limit — and must still find them.
|
|
64
|
+
*/
|
|
65
|
+
export function holdAttachmentDirs(filePaths) {
|
|
66
|
+
for (const filePath of filePaths) {
|
|
67
|
+
const directory = messageDirOf(filePath);
|
|
68
|
+
if (directory)
|
|
69
|
+
heldDirs.add(directory);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Remove the per-message directories the given attachment files were saved
|
|
74
|
+
* in. A path that is not inside tmp/attachments/ is left alone: this is called
|
|
75
|
+
* with whatever a connector put in `localPath`, and must never delete on its
|
|
76
|
+
* say-so anything but an attachment directory.
|
|
77
|
+
*/
|
|
78
|
+
export function removeAttachmentDirs(filePaths) {
|
|
79
|
+
const directories = new Set();
|
|
80
|
+
for (const filePath of filePaths) {
|
|
81
|
+
const directory = messageDirOf(filePath);
|
|
82
|
+
if (directory)
|
|
83
|
+
directories.add(directory);
|
|
84
|
+
}
|
|
85
|
+
for (const directory of directories) {
|
|
86
|
+
heldDirs.delete(directory);
|
|
87
|
+
try {
|
|
88
|
+
fs.rmSync(directory, { recursive: true, force: true });
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Best effort: a leftover temp directory is not worth failing a turn over.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** How long a message's attachments stay when nothing came to remove them. */
|
|
96
|
+
export const STALE_ATTACHMENTS_AFTER_MS = 24 * 60 * 60 * 1000;
|
|
97
|
+
const SWEEP_EVERY_MS = 60 * 60 * 1000;
|
|
98
|
+
/**
|
|
99
|
+
* Remove what has been lying in tmp/attachments/ for longer than
|
|
100
|
+
* `olderThanMs`, and return how many entries went.
|
|
101
|
+
*
|
|
102
|
+
* Attachments are saved when a message arrives and removed when its turn
|
|
103
|
+
* ends. A message that never gets a turn — the bot stays silent on it, the
|
|
104
|
+
* gateway is restarted first — left its files for good, so that posting files
|
|
105
|
+
* where the bot reads was enough to fill the disk. Only direct children of
|
|
106
|
+
* tmp/attachments/ are removed (a link is removed as a link), never the
|
|
107
|
+
* directory itself, and never one a turn still holds.
|
|
108
|
+
*/
|
|
109
|
+
export function sweepStaleAttachmentDirs(now = Date.now(), olderThanMs = STALE_ATTACHMENTS_AFTER_MS) {
|
|
110
|
+
if (!path.isAbsolute(ATTACHMENTS_DIR))
|
|
111
|
+
return 0;
|
|
112
|
+
const root = path.normalize(ATTACHMENTS_DIR);
|
|
113
|
+
let names;
|
|
114
|
+
try {
|
|
115
|
+
names = fs.readdirSync(root);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return 0; // nothing was ever saved here
|
|
119
|
+
}
|
|
120
|
+
let removed = 0;
|
|
121
|
+
for (const name of names) {
|
|
122
|
+
const entry = path.join(root, name);
|
|
123
|
+
if (path.dirname(entry) !== root || heldDirs.has(entry))
|
|
124
|
+
continue;
|
|
125
|
+
try {
|
|
126
|
+
if (fs.lstatSync(entry).mtimeMs > now - olderThanMs)
|
|
127
|
+
continue;
|
|
128
|
+
fs.rmSync(entry, { recursive: true, force: true });
|
|
129
|
+
removed++;
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
// Best effort: the next sweep tries again.
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return removed;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Sweep now — what a previous run of the gateway left behind — and then every
|
|
139
|
+
* hour. Returns the function that stops it. The timer never keeps the process
|
|
140
|
+
* alive on its own.
|
|
141
|
+
*/
|
|
142
|
+
export function startAttachmentSweep() {
|
|
143
|
+
const sweep = () => {
|
|
144
|
+
const removed = sweepStaleAttachmentDirs();
|
|
145
|
+
if (removed > 0)
|
|
146
|
+
logger.info(`Removed ${removed} leftover attachment director${removed === 1 ? "y" : "ies"} older than a day`);
|
|
147
|
+
};
|
|
148
|
+
sweep();
|
|
149
|
+
const timer = setInterval(sweep, SWEEP_EVERY_MS);
|
|
150
|
+
timer.unref();
|
|
151
|
+
return () => clearInterval(timer);
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=attachments.js.map
|