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
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { turnFailureOf } from "./origin-delivery.js";
|
|
2
|
+
import { getSession, insertMessage } from "./registry.js";
|
|
3
|
+
import { failedByUnrequestedStop } from "./unrequested-stop.js";
|
|
2
4
|
import { loadConfig } from "../shared/config.js";
|
|
3
5
|
import { logger } from "../shared/logger.js";
|
|
4
6
|
import { readGatewayAuthToken } from "../gateway/auth.js";
|
|
@@ -18,7 +20,7 @@ export function notifyParentSession(childSession, result, options) {
|
|
|
18
20
|
return;
|
|
19
21
|
}
|
|
20
22
|
// Run asynchronously — do not await in the caller
|
|
21
|
-
_sendNotification(childSession, result).catch((err) => {
|
|
23
|
+
_sendNotification(childSession, result, { completion: true }).catch((err) => {
|
|
22
24
|
logger.warn(`[callbacks] Failed to notify parent session ${childSession.parentSessionId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
23
25
|
});
|
|
24
26
|
}
|
|
@@ -48,16 +50,44 @@ export function notifyRateLimitResumed(childSession) {
|
|
|
48
50
|
logger.warn(`[callbacks] Failed to send resume notification: ${err instanceof Error ? err.message : String(err)}`);
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Whether a notification should start a turn in this parent.
|
|
55
|
+
*
|
|
56
|
+
* A parent in error is not woken: one stopped by a usage limit or a lost login
|
|
57
|
+
* would fail again, once for every child that finishes. The exception is a
|
|
58
|
+
* parent whose engine stopped without being asked to — its process died. It
|
|
59
|
+
* can run again at once, and it is usually waiting on exactly these
|
|
60
|
+
* notifications: left out, the conversation it answers in just stops.
|
|
61
|
+
*
|
|
62
|
+
* What counts is what the parent's turn failed with. That is not always what
|
|
63
|
+
* lastError reads: when the message saying so could not be delivered either,
|
|
64
|
+
* lastError holds the record of that, and the turn's failure is kept beside it.
|
|
65
|
+
*/
|
|
66
|
+
function wakesForNotifications(parent) {
|
|
67
|
+
return parent.status !== "error" || failedByUnrequestedStop({ status: parent.status, lastError: turnFailureOf(parent) });
|
|
68
|
+
}
|
|
69
|
+
const NOT_ACTED_ON = "ℹ️ Not acted on: this session was in an error state when this arrived, so no turn was started for it.";
|
|
70
|
+
/**
|
|
71
|
+
* Keep a notification for a parent that is not woken: write it into the
|
|
72
|
+
* parent's transcript, where the parent finds it when it runs again and the
|
|
73
|
+
* operator sees it in the meantime. It used to be dropped, and the parent had
|
|
74
|
+
* no trace that the child had finished at all.
|
|
75
|
+
*
|
|
76
|
+
* Written straight to the registry rather than through the gateway route: the
|
|
77
|
+
* route's job is to start a turn, and this must not depend on it.
|
|
78
|
+
*/
|
|
79
|
+
function recordWithoutWaking(parent, childId, message) {
|
|
80
|
+
insertMessage(parent.id, "notification", `${message}\n\n${NOT_ACTED_ON}`);
|
|
81
|
+
logger.info(`[callbacks] Parent ${parent.id} is in error — recorded the notification for child ${childId} in its transcript without waking it.`);
|
|
82
|
+
}
|
|
83
|
+
async function _sendNotification(childSession, result,
|
|
84
|
+
/** `completion`: this reports the child's turn ending (not a status notice). */
|
|
85
|
+
opts = {}) {
|
|
52
86
|
const parent = getSession(childSession.parentSessionId);
|
|
53
87
|
if (!parent) {
|
|
54
88
|
logger.info(`[callbacks] Parent ${childSession.parentSessionId} not found for child ${childSession.id} — no notification sent.`);
|
|
55
89
|
return; // Parent gone or expired
|
|
56
90
|
}
|
|
57
|
-
if (parent.status === "error") {
|
|
58
|
-
logger.info(`[callbacks] Parent ${parent.id} is in error — skipping notification for child ${childSession.id}. The child's result will not reach it.`);
|
|
59
|
-
return; // Parent already in error — skip
|
|
60
|
-
}
|
|
61
91
|
const employeeName = childSession.employee || "Unknown";
|
|
62
92
|
const childId = childSession.id;
|
|
63
93
|
let message;
|
|
@@ -69,7 +99,14 @@ async function _sendNotification(childSession, result) {
|
|
|
69
99
|
const preview = raw.length > 200 ? raw.substring(0, 200) + "..." : raw;
|
|
70
100
|
message = `📩 Employee "${employeeName}" replied in session ${childId}.\nRead the latest messages: GET /api/sessions/${childId}?last=N\n\nPreview: ${preview}`;
|
|
71
101
|
}
|
|
72
|
-
|
|
102
|
+
if (!wakesForNotifications(parent)) {
|
|
103
|
+
recordWithoutWaking(parent, childId, message);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// A successful completion names its child so the gateway can fold the ones
|
|
107
|
+
// that pile up behind a busy parent into one turn (completion-batching.ts).
|
|
108
|
+
// A failure is left unmarked: it keeps a turn of its own.
|
|
109
|
+
await _sendRaw(childSession.parentSessionId, message, opts.completion && !result.error ? childId : undefined);
|
|
73
110
|
}
|
|
74
111
|
/**
|
|
75
112
|
* Send a hardcoded notification to the configured Discord channel.
|
|
@@ -100,7 +137,7 @@ async function _sendDiscordNotification(message) {
|
|
|
100
137
|
}
|
|
101
138
|
await _postToGateway(port, `/api/connectors/${connector}/send`, { channel, text: message }, `sending a ${connector} notification`);
|
|
102
139
|
}
|
|
103
|
-
async function _sendRaw(parentSessionId, message) {
|
|
140
|
+
async function _sendRaw(parentSessionId, message, completionOf) {
|
|
104
141
|
let port = 7777;
|
|
105
142
|
try {
|
|
106
143
|
const config = loadConfig();
|
|
@@ -109,7 +146,15 @@ async function _sendRaw(parentSessionId, message) {
|
|
|
109
146
|
catch {
|
|
110
147
|
// Use default port if config is unavailable
|
|
111
148
|
}
|
|
112
|
-
await _postToGateway(port, `/api/sessions/${parentSessionId}/message`, { message, role: "notification" }, `notifying parent ${parentSessionId}`);
|
|
149
|
+
await _postToGateway(port, `/api/sessions/${parentSessionId}/message`, { message, role: "notification", ...(completionOf ? { completionOf } : {}) }, `notifying parent ${parentSessionId}`);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Wake a session on this instance's own gateway with a notification turn: the
|
|
153
|
+
* message is persisted, queued and run, and a connector-origin session answers
|
|
154
|
+
* in the conversation it came from. Rejects when the gateway does not accept it.
|
|
155
|
+
*/
|
|
156
|
+
export function postSessionNotification(port, sessionId, body) {
|
|
157
|
+
return _postToGateway(port, `/api/sessions/${sessionId}/message`, { ...body, role: "notification" }, `waking session ${sessionId}`);
|
|
113
158
|
}
|
|
114
159
|
/**
|
|
115
160
|
* POST to this instance's own gateway API.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../../src/sessions/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../../src/sessions/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,YAAqB,EACrB,MAA6F,EAC7F,OAAoC;IAEpC,IAAI,CAAC,YAAY,CAAC,eAAe;QAAE,OAAO;IAC1C,IAAI,OAAO,EAAE,YAAY,KAAK,KAAK,EAAE,CAAC;QACpC,wFAAwF;Q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,UAAU,uBAAuB,CACrC,IAAY,EACZ,SAAiB,EACjB,IAA6C;IAE7C,OAAO,cAAc,CAAC,IAAI,EAAE,iBAAiB,SAAS,UAAU,EAAE,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,kBAAkB,SAAS,EAAE,CAAC,CAAC;AACtI,CAAC;AAED;;;;;;;;GAQG;AACH,KAAK,UAAU,cAAc,CAAC,IAAY,EAAE,IAAY,EAAE,IAAa,EAAE,IAAY;IACnF,MAAM,KAAK,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,oBAAoB,IAAI,GAAG,IAAI,EAAE,EAAE;QACzD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACvD;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;IAEH,+FAA+F;IAC/F,qEAAqE;IACrE,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAEhD,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,qBAAqB,GAAG,CAAC,MAAM,SAAS,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Completion batching — one parent turn for the child completions that pile up
|
|
3
|
+
* while the parent is busy. (Ported in spirit from upstream jinn 5c0292d7 +
|
|
4
|
+
* 65c01e72; upstream batches its durable callback outbox, this fork batches
|
|
5
|
+
* the queue_items row itself.)
|
|
6
|
+
*
|
|
7
|
+
* Every child completion used to become its own queue row and its own engine
|
|
8
|
+
* turn, so a parent that delegated to N children ran N turns when they
|
|
9
|
+
* finished, and a Slack-origin parent posted into its thread N times. A
|
|
10
|
+
* completion that arrives while a completion row is still waiting now joins
|
|
11
|
+
* that row instead of opening another.
|
|
12
|
+
*
|
|
13
|
+
* What is shared is only the engine dispatch. Each notification is still
|
|
14
|
+
* persisted in the transcript as its own message; the row's prompt is rebuilt
|
|
15
|
+
* from all of them, and the dispatcher reads the prompt from the row when the
|
|
16
|
+
* turn starts.
|
|
17
|
+
*
|
|
18
|
+
* Only the pending TAIL row is ever joined, and only if it is a completion
|
|
19
|
+
* batch: reaching past an operator message, a detached-job wake-up, a restart
|
|
20
|
+
* nudge or a failed child's notification would reorder work. A failure is
|
|
21
|
+
* never batched — callbacks.ts does not mark it — so it keeps a turn of its own.
|
|
22
|
+
*/
|
|
23
|
+
import type { Session } from "../shared/types.js";
|
|
24
|
+
import type { SessionQueue } from "./queue.js";
|
|
25
|
+
/** Upstream's limits: a batch is one prompt, and a prompt has to stay readable. */
|
|
26
|
+
export declare const COMPLETION_BATCH_MAX_ITEMS = 32;
|
|
27
|
+
export declare const COMPLETION_BATCH_MAX_CHARS = 128000;
|
|
28
|
+
export interface AcceptedCompletion {
|
|
29
|
+
/** The queue row this completion will run under. */
|
|
30
|
+
queueItemId: string;
|
|
31
|
+
/** That row's prompt as of now. */
|
|
32
|
+
prompt: string;
|
|
33
|
+
/** True when it joined a row that was already waiting. */
|
|
34
|
+
joined: boolean;
|
|
35
|
+
/** Completions in the row, this one included. */
|
|
36
|
+
size: number;
|
|
37
|
+
}
|
|
38
|
+
/** One engine-facing prompt for the completions sharing a row. */
|
|
39
|
+
export declare function completionBatchPrompt(messages: readonly string[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* Queue a child's completion notification for its parent: join the pending
|
|
42
|
+
* tail row when that is a completion batch with room, otherwise open a row.
|
|
43
|
+
* The lookup and the write share one transaction, and a row that has started
|
|
44
|
+
* is no longer pending, so a turn never runs a half-written prompt.
|
|
45
|
+
*
|
|
46
|
+
* `canJoin` lets the caller veto a row the database still shows as pending but
|
|
47
|
+
* that will never run (see {@link queueChildCompletion}).
|
|
48
|
+
*/
|
|
49
|
+
export declare function acceptChildCompletion(sessionId: string, sessionKey: string, message: string, canJoin?: (queueItemId: string) => boolean): AcceptedCompletion;
|
|
50
|
+
/** The prompt a queue row holds now. A dispatcher captures the prompt when it
|
|
51
|
+
* is scheduled, but a completion batch grows while its row waits, so the turn
|
|
52
|
+
* runs what the row says. Falls back to the captured prompt for a run with no
|
|
53
|
+
* row (or a row that is gone). */
|
|
54
|
+
export declare function queuedPrompt(queueItemId: string | undefined, captured: string): string;
|
|
55
|
+
/** True for a row opened by {@link acceptChildCompletion} — a notification
|
|
56
|
+
* wake-up whatever its prompt has grown into. */
|
|
57
|
+
export declare function isCompletionBatchItem(queueItemId: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The child whose successful completion a notification reports — when the
|
|
60
|
+
* caller says so (callbacks.ts marks them) and that session really is this
|
|
61
|
+
* session's child. Anything else is an ordinary notification.
|
|
62
|
+
*/
|
|
63
|
+
export declare function completionChildOf(parent: Session, body: unknown): string | null;
|
|
64
|
+
export interface QueuedCompletion extends AcceptedCompletion {
|
|
65
|
+
/** False when the row it joined already has a dispatcher that will run it. */
|
|
66
|
+
needsDispatch: boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* What the notification route calls: queue `message` as a child completion if
|
|
70
|
+
* `body` marks it as one, and return null for anything else — so the caller
|
|
71
|
+
* queues it the ordinary way. Batching only saves turns; it must never cost a
|
|
72
|
+
* notification, so a failure here (logged) also falls back to the ordinary
|
|
73
|
+
* path instead of failing the request the child's callback is waiting on.
|
|
74
|
+
*
|
|
75
|
+
* The live queue decides two things the database cannot. A row whose only
|
|
76
|
+
* dispatcher a stop has cancelled is still "pending" until that dispatcher
|
|
77
|
+
* drains, but it will be closed without running — joining it would lose the
|
|
78
|
+
* completion, so a new row is opened instead. And a row with no dispatcher at
|
|
79
|
+
* all (a restart left it behind) needs one even though it was joined.
|
|
80
|
+
*/
|
|
81
|
+
export declare function queueChildCompletion(parent: Session, sessionKey: string, body: unknown, message: string, queue: Pick<SessionQueue, "dispatchState">): QueuedCompletion | null;
|
|
82
|
+
//# sourceMappingURL=completion-batching.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion-batching.d.ts","sourceRoot":"","sources":["../../../src/sessions/completion-batching.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,mFAAmF;AACnF,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAIlD,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,MAAM,EAAE,OAAO,CAAC;IAChB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,kEAAkE;AAClE,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAOzE;AAeD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAoB,GACrD,kBAAkB,CAuBpB;AAED;;;mCAGmC;AACnC,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQtF;AAED;kDACkD;AAClD,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAOlE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAI/E;AAED,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB;IAC1D,8EAA8E;IAC9E,aAAa,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,EACf,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,GACzC,gBAAgB,GAAG,IAAI,CASzB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { logger } from "../shared/logger.js";
|
|
2
|
+
import { enqueueQueueItem, getSession, initDb } from "./registry.js";
|
|
3
|
+
/** Upstream's limits: a batch is one prompt, and a prompt has to stay readable. */
|
|
4
|
+
export const COMPLETION_BATCH_MAX_ITEMS = 32;
|
|
5
|
+
export const COMPLETION_BATCH_MAX_CHARS = 128_000;
|
|
6
|
+
const BATCH_KIND = "child-completion";
|
|
7
|
+
/** One engine-facing prompt for the completions sharing a row. */
|
|
8
|
+
export function completionBatchPrompt(messages) {
|
|
9
|
+
if (messages.length === 1)
|
|
10
|
+
return messages[0];
|
|
11
|
+
return [
|
|
12
|
+
`📬 ${messages.length} child-session updates arrived while this session was busy. ` +
|
|
13
|
+
"Read all of them before you act, then answer once.",
|
|
14
|
+
...messages.map((message, index) => `--- Update ${index + 1} of ${messages.length} ---\n${message}`),
|
|
15
|
+
].join("\n\n");
|
|
16
|
+
}
|
|
17
|
+
function batchMessages(raw) {
|
|
18
|
+
if (typeof raw !== "string" || !raw)
|
|
19
|
+
return null;
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(raw);
|
|
22
|
+
if (parsed?.kind !== BATCH_KIND || !Array.isArray(parsed.items))
|
|
23
|
+
return null;
|
|
24
|
+
return parsed.items.every((item) => typeof item === "string") ? parsed.items : null;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const storedBatch = (messages) => JSON.stringify({ kind: BATCH_KIND, items: messages });
|
|
31
|
+
/**
|
|
32
|
+
* Queue a child's completion notification for its parent: join the pending
|
|
33
|
+
* tail row when that is a completion batch with room, otherwise open a row.
|
|
34
|
+
* The lookup and the write share one transaction, and a row that has started
|
|
35
|
+
* is no longer pending, so a turn never runs a half-written prompt.
|
|
36
|
+
*
|
|
37
|
+
* `canJoin` lets the caller veto a row the database still shows as pending but
|
|
38
|
+
* that will never run (see {@link queueChildCompletion}).
|
|
39
|
+
*/
|
|
40
|
+
export function acceptChildCompletion(sessionId, sessionKey, message, canJoin = () => true) {
|
|
41
|
+
const database = initDb();
|
|
42
|
+
return database.transaction(() => {
|
|
43
|
+
const tail = database.prepare(`
|
|
44
|
+
SELECT id, batch FROM queue_items
|
|
45
|
+
WHERE session_id = ? AND session_key = ? AND status = 'pending'
|
|
46
|
+
ORDER BY position DESC, created_at DESC, rowid DESC
|
|
47
|
+
LIMIT 1
|
|
48
|
+
`).get(sessionId, sessionKey);
|
|
49
|
+
const waiting = tail ? batchMessages(tail.batch) : null;
|
|
50
|
+
if (tail && waiting && waiting.length < COMPLETION_BATCH_MAX_ITEMS && canJoin(tail.id)) {
|
|
51
|
+
const messages = [...waiting, message];
|
|
52
|
+
const prompt = completionBatchPrompt(messages);
|
|
53
|
+
if (prompt.length <= COMPLETION_BATCH_MAX_CHARS) {
|
|
54
|
+
database.prepare("UPDATE queue_items SET prompt = ?, batch = ? WHERE id = ? AND status = 'pending'")
|
|
55
|
+
.run(prompt, storedBatch(messages), tail.id);
|
|
56
|
+
return { queueItemId: tail.id, prompt, joined: true, size: messages.length };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const queueItemId = enqueueQueueItem(sessionId, sessionKey, message);
|
|
60
|
+
database.prepare("UPDATE queue_items SET batch = ? WHERE id = ?").run(storedBatch([message]), queueItemId);
|
|
61
|
+
return { queueItemId, prompt: message, joined: false, size: 1 };
|
|
62
|
+
}).immediate();
|
|
63
|
+
}
|
|
64
|
+
/** The prompt a queue row holds now. A dispatcher captures the prompt when it
|
|
65
|
+
* is scheduled, but a completion batch grows while its row waits, so the turn
|
|
66
|
+
* runs what the row says. Falls back to the captured prompt for a run with no
|
|
67
|
+
* row (or a row that is gone). */
|
|
68
|
+
export function queuedPrompt(queueItemId, captured) {
|
|
69
|
+
if (!queueItemId)
|
|
70
|
+
return captured;
|
|
71
|
+
try {
|
|
72
|
+
const row = initDb().prepare("SELECT prompt FROM queue_items WHERE id = ?").get(queueItemId);
|
|
73
|
+
return row?.prompt ?? captured;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return captured; // the turn still runs — with what its dispatcher was given
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** True for a row opened by {@link acceptChildCompletion} — a notification
|
|
80
|
+
* wake-up whatever its prompt has grown into. */
|
|
81
|
+
export function isCompletionBatchItem(queueItemId) {
|
|
82
|
+
try {
|
|
83
|
+
const row = initDb().prepare("SELECT batch FROM queue_items WHERE id = ?").get(queueItemId);
|
|
84
|
+
return batchMessages(row?.batch) !== null;
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return false; // asked during the boot replay, which must not stop on it
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The child whose successful completion a notification reports — when the
|
|
92
|
+
* caller says so (callbacks.ts marks them) and that session really is this
|
|
93
|
+
* session's child. Anything else is an ordinary notification.
|
|
94
|
+
*/
|
|
95
|
+
export function completionChildOf(parent, body) {
|
|
96
|
+
const childId = body?.completionOf;
|
|
97
|
+
if (typeof childId !== "string" || !childId)
|
|
98
|
+
return null;
|
|
99
|
+
return getSession(childId)?.parentSessionId === parent.id ? childId : null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* What the notification route calls: queue `message` as a child completion if
|
|
103
|
+
* `body` marks it as one, and return null for anything else — so the caller
|
|
104
|
+
* queues it the ordinary way. Batching only saves turns; it must never cost a
|
|
105
|
+
* notification, so a failure here (logged) also falls back to the ordinary
|
|
106
|
+
* path instead of failing the request the child's callback is waiting on.
|
|
107
|
+
*
|
|
108
|
+
* The live queue decides two things the database cannot. A row whose only
|
|
109
|
+
* dispatcher a stop has cancelled is still "pending" until that dispatcher
|
|
110
|
+
* drains, but it will be closed without running — joining it would lose the
|
|
111
|
+
* completion, so a new row is opened instead. And a row with no dispatcher at
|
|
112
|
+
* all (a restart left it behind) needs one even though it was joined.
|
|
113
|
+
*/
|
|
114
|
+
export function queueChildCompletion(parent, sessionKey, body, message, queue) {
|
|
115
|
+
try {
|
|
116
|
+
if (!completionChildOf(parent, body))
|
|
117
|
+
return null;
|
|
118
|
+
const accepted = acceptChildCompletion(parent.id, sessionKey, message, (id) => queue.dispatchState(id) !== "cancelled");
|
|
119
|
+
return { ...accepted, needsDispatch: !accepted.joined || queue.dispatchState(accepted.queueItemId) === "none" };
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
logger.warn(`[completion-batching] Could not batch a completion for session ${parent.id}; queueing it on its own: ${err instanceof Error ? err.message : String(err)}`);
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=completion-batching.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion-batching.js","sourceRoot":"","sources":["../../../src/sessions/completion-batching.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAErE,mFAAmF;AACnF,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,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AC;AAOD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAe,EACf,UAAkB,EAClB,IAAa,EACb,OAAe,EACf,KAA0C;IAE1C,IAAI,CAAC;QACH,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QAClD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,WAAW,CAAC,CAAC;QACxH,OAAO,EAAE,GAAG,QAAQ,EAAE,aAAa,EAAE,CAAC,QAAQ,CAAC,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,MAAM,EAAE,CAAC;IAClH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC,kEAAkE,MAAM,CAAC,EAAE,6BAA6B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACxK,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { IncomingMessage, JinnConfig } from "../shared/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* What a chat message is allowed to mean to the CLI that runs the turn.
|
|
4
|
+
*
|
|
5
|
+
* The engines hand a prompt to their CLI as it is, and Claude Code reads some
|
|
6
|
+
* prompts as something other than text (read from the 2.1.296 executable):
|
|
7
|
+
*
|
|
8
|
+
* - after `trim()`, a leading "/" is one of its own commands — /logout,
|
|
9
|
+
* /permissions, /remote-control and some ninety more;
|
|
10
|
+
* - after `trim()`, the words exit, quit, :q, :q!, :wq and :wq! quit it;
|
|
11
|
+
* - a leading "!" puts its input box in bash mode: the rest is a shell command;
|
|
12
|
+
* - on a cold start the prompt is an argument, and one with a leading "-" is
|
|
13
|
+
* an option (`--mcp-config=…` starts a program of the sender's choosing).
|
|
14
|
+
*
|
|
15
|
+
* A chat message is written by whoever can reach the assistant, so none of
|
|
16
|
+
* that may be decided by its first character. Every message a connector
|
|
17
|
+
* delivers passes through here, once, before its turn runs:
|
|
18
|
+
*
|
|
19
|
+
* - Text the CLI would read as text anyway is passed on untouched.
|
|
20
|
+
* - Text it would read as a command or an option is passed on *as text*:
|
|
21
|
+
* a one-line note is put in front, so that it no longer starts with
|
|
22
|
+
* anything the CLI acts on, and the model reads the words. A leading space
|
|
23
|
+
* would not do — the CLI trims before it looks.
|
|
24
|
+
* - The operator, identified by platform ID and by nothing else, keeps the
|
|
25
|
+
* commands in OPERATOR_NATIVE_COMMANDS. The list names what is allowed:
|
|
26
|
+
* a command the CLI gains tomorrow is not on it.
|
|
27
|
+
*
|
|
28
|
+
* Nobody is told "that command is not allowed" by the gateway: to the sender it
|
|
29
|
+
* is a message like any other, answered by the model.
|
|
30
|
+
*
|
|
31
|
+
* Not decided here: the web UI and the API (callers the gateway has already
|
|
32
|
+
* authenticated) and cron prompts (the operator's own text) reach the engine
|
|
33
|
+
* as before, and the gateway's own commands (/new, /status, /model, /doctor,
|
|
34
|
+
* /cron) are answered before a message gets this far.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* The native Claude commands the operator can run from chat, and whether each
|
|
38
|
+
* takes text after it. Both tidy the conversation and finish with nothing to
|
|
39
|
+
* read; neither touches the login, permissions, settings or anything outside
|
|
40
|
+
* the session. Both are commands the interactive engine knows how to wait for
|
|
41
|
+
* (isNativeClaudeCommand) — one it does not would hang the turn.
|
|
42
|
+
*
|
|
43
|
+
* Deliberately not here: /usage and /cost. They open an interactive panel
|
|
44
|
+
* whose output never comes back to chat, and the panel can stay up in the PTY
|
|
45
|
+
* and swallow the next turn — useless from chat, and a way to wedge a session.
|
|
46
|
+
*/
|
|
47
|
+
export declare const OPERATOR_NATIVE_COMMANDS: ReadonlyMap<string, {
|
|
48
|
+
args: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Only the configured platform ID of the platform the message arrived on
|
|
52
|
+
* counts. A display name never does, and where no operator ID is configured
|
|
53
|
+
* (or the platform has none: Telegram, WhatsApp) nobody is the operator.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isVerifiedOperator(msg: IncomingMessage, config: JinnConfig): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* May this sender run a gateway command that changes the session's engine or
|
|
58
|
+
* fires a cron job? Yes for the gateway's own sources (a cron turn), yes for
|
|
59
|
+
* everyone when no operator ID is configured (nothing can verify anyone — the
|
|
60
|
+
* instance's existing behaviour is not taken away), and otherwise only the
|
|
61
|
+
* verified operator. Read-only commands do not ask this.
|
|
62
|
+
*/
|
|
63
|
+
export declare function senderMayManageSession(msg: IncomingMessage, config: JinnConfig): boolean;
|
|
64
|
+
/** The message as the turn may see it. Returns `msg` itself when nothing had to change. */
|
|
65
|
+
export declare function guardConnectorMessage(msg: IncomingMessage, config: JinnConfig): IncomingMessage;
|
|
66
|
+
//# sourceMappingURL=connector-command-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-command-guard.d.ts","sourceRoot":"","sources":["../../../src/sessions/connector-command-guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAItE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAG1E,CAAC;AA+CH;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAUpF;AAQD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAIxF;AAED,2FAA2F;AAC3F,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,GAAG,eAAe,CAa/F"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { stripTerminalControlChars } from "../shared/terminal-safe-text.js";
|
|
2
|
+
import { resolveOperatorIdentity } from "./context.js";
|
|
3
|
+
/**
|
|
4
|
+
* What a chat message is allowed to mean to the CLI that runs the turn.
|
|
5
|
+
*
|
|
6
|
+
* The engines hand a prompt to their CLI as it is, and Claude Code reads some
|
|
7
|
+
* prompts as something other than text (read from the 2.1.296 executable):
|
|
8
|
+
*
|
|
9
|
+
* - after `trim()`, a leading "/" is one of its own commands — /logout,
|
|
10
|
+
* /permissions, /remote-control and some ninety more;
|
|
11
|
+
* - after `trim()`, the words exit, quit, :q, :q!, :wq and :wq! quit it;
|
|
12
|
+
* - a leading "!" puts its input box in bash mode: the rest is a shell command;
|
|
13
|
+
* - on a cold start the prompt is an argument, and one with a leading "-" is
|
|
14
|
+
* an option (`--mcp-config=…` starts a program of the sender's choosing).
|
|
15
|
+
*
|
|
16
|
+
* A chat message is written by whoever can reach the assistant, so none of
|
|
17
|
+
* that may be decided by its first character. Every message a connector
|
|
18
|
+
* delivers passes through here, once, before its turn runs:
|
|
19
|
+
*
|
|
20
|
+
* - Text the CLI would read as text anyway is passed on untouched.
|
|
21
|
+
* - Text it would read as a command or an option is passed on *as text*:
|
|
22
|
+
* a one-line note is put in front, so that it no longer starts with
|
|
23
|
+
* anything the CLI acts on, and the model reads the words. A leading space
|
|
24
|
+
* would not do — the CLI trims before it looks.
|
|
25
|
+
* - The operator, identified by platform ID and by nothing else, keeps the
|
|
26
|
+
* commands in OPERATOR_NATIVE_COMMANDS. The list names what is allowed:
|
|
27
|
+
* a command the CLI gains tomorrow is not on it.
|
|
28
|
+
*
|
|
29
|
+
* Nobody is told "that command is not allowed" by the gateway: to the sender it
|
|
30
|
+
* is a message like any other, answered by the model.
|
|
31
|
+
*
|
|
32
|
+
* Not decided here: the web UI and the API (callers the gateway has already
|
|
33
|
+
* authenticated) and cron prompts (the operator's own text) reach the engine
|
|
34
|
+
* as before, and the gateway's own commands (/new, /status, /model, /doctor,
|
|
35
|
+
* /cron) are answered before a message gets this far.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* The native Claude commands the operator can run from chat, and whether each
|
|
39
|
+
* takes text after it. Both tidy the conversation and finish with nothing to
|
|
40
|
+
* read; neither touches the login, permissions, settings or anything outside
|
|
41
|
+
* the session. Both are commands the interactive engine knows how to wait for
|
|
42
|
+
* (isNativeClaudeCommand) — one it does not would hang the turn.
|
|
43
|
+
*
|
|
44
|
+
* Deliberately not here: /usage and /cost. They open an interactive panel
|
|
45
|
+
* whose output never comes back to chat, and the panel can stay up in the PTY
|
|
46
|
+
* and swallow the next turn — useless from chat, and a way to wedge a session.
|
|
47
|
+
*/
|
|
48
|
+
export const OPERATOR_NATIVE_COMMANDS = new Map([
|
|
49
|
+
["/compact", { args: true }], // optional instructions for the summary
|
|
50
|
+
["/clear", { args: false }],
|
|
51
|
+
]);
|
|
52
|
+
/** Sources whose text the gateway wrote itself. A cron job's prompt is the operator's. */
|
|
53
|
+
const GATEWAY_SOURCES = new Set(["cron"]);
|
|
54
|
+
/**
|
|
55
|
+
* The gateway's own /goal (goal-execution.ts). For Claude it is handed to the
|
|
56
|
+
* CLI as the native command, and the gateway writes the same command itself
|
|
57
|
+
* when it finds a goal in ordinary words — so it is everybody's, as before.
|
|
58
|
+
*/
|
|
59
|
+
const GOAL_COMMAND = /^\/goal(?:\s|$)/i;
|
|
60
|
+
/** `/command`, or `/command text` on one line: the only shape a native command is let through in. */
|
|
61
|
+
const ONE_LINE_COMMAND = /^(\/\S+)(?:[ \t]+(.*))?$/;
|
|
62
|
+
// Both patterns are anchored at the start and scan once: a long run of blanks
|
|
63
|
+
// in a message costs its length, not its square.
|
|
64
|
+
const INVISIBLE = String.raw `[\s\p{Cf}\p{Default_Ignorable_Code_Point}\u2800]`;
|
|
65
|
+
const LEADING_INVISIBLE = new RegExp(`^${INVISIBLE}+`, "u");
|
|
66
|
+
/** The whole message is one of the words the CLI quits on: exit, quit, :q, :q!, :wq, :wq!. */
|
|
67
|
+
const EXIT_WORD = new RegExp(`^(?:exit|quit|:q!?|:wq!?)${INVISIBLE}*$`, "iu");
|
|
68
|
+
const AS_TEXT = "[Chat message, delivered as plain text: nothing in it was run as a CLI command or option. Read it as an ordinary message.]";
|
|
69
|
+
const AS_TEXT_SLASH = "[Chat message, delivered as plain text: it was not run as a CLI command. Read it as an ordinary message; if it names an installed skill, it is a request to use that skill.]";
|
|
70
|
+
/**
|
|
71
|
+
* What a CLI could find itself looking at: full-width forms folded to the
|
|
72
|
+
* ASCII they stand for, nothing invisible in front. Stricter than the
|
|
73
|
+
* installed CLI, which does neither — a version that starts to must not find
|
|
74
|
+
* a command where this found none.
|
|
75
|
+
*/
|
|
76
|
+
function asSeen(text) {
|
|
77
|
+
return text.normalize("NFKC").replace(LEADING_INVISIBLE, "");
|
|
78
|
+
}
|
|
79
|
+
function readsAsCliInput(seen) {
|
|
80
|
+
return /^[/\-!]/.test(seen) || EXIT_WORD.test(seen);
|
|
81
|
+
}
|
|
82
|
+
/** Exactly as typed — a look-alike of an allowed command is not that command. */
|
|
83
|
+
function isOperatorCommand(typed) {
|
|
84
|
+
const match = ONE_LINE_COMMAND.exec(typed);
|
|
85
|
+
if (!match)
|
|
86
|
+
return false;
|
|
87
|
+
const rule = OPERATOR_NATIVE_COMMANDS.get(match[1]);
|
|
88
|
+
return rule !== undefined && (rule.args || !match[2]?.trim());
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Only the configured platform ID of the platform the message arrived on
|
|
92
|
+
* counts. A display name never does, and where no operator ID is configured
|
|
93
|
+
* (or the platform has none: Telegram, WhatsApp) nobody is the operator.
|
|
94
|
+
*/
|
|
95
|
+
export function isVerifiedOperator(msg, config) {
|
|
96
|
+
const meta = msg.transportMeta ?? {};
|
|
97
|
+
const id = (value) => (typeof value === "string" && value ? value : undefined);
|
|
98
|
+
return resolveOperatorIdentity({
|
|
99
|
+
speakerNames: [],
|
|
100
|
+
speakerSlackId: id(meta.speakerSlackId),
|
|
101
|
+
speakerDiscordId: id(meta.speakerDiscordId),
|
|
102
|
+
source: msg.source,
|
|
103
|
+
config,
|
|
104
|
+
}).operatorIdVerified;
|
|
105
|
+
}
|
|
106
|
+
/** True when the instance has a strict operator ID set (so verification is possible at all). */
|
|
107
|
+
function strictOperatorConfigured(config) {
|
|
108
|
+
const portal = config?.portal;
|
|
109
|
+
return !!portal && (Object.hasOwn(portal, "operatorSlackId") || Object.hasOwn(portal, "operatorDiscordId"));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* May this sender run a gateway command that changes the session's engine or
|
|
113
|
+
* fires a cron job? Yes for the gateway's own sources (a cron turn), yes for
|
|
114
|
+
* everyone when no operator ID is configured (nothing can verify anyone — the
|
|
115
|
+
* instance's existing behaviour is not taken away), and otherwise only the
|
|
116
|
+
* verified operator. Read-only commands do not ask this.
|
|
117
|
+
*/
|
|
118
|
+
export function senderMayManageSession(msg, config) {
|
|
119
|
+
if (GATEWAY_SOURCES.has(msg.source))
|
|
120
|
+
return true;
|
|
121
|
+
if (!strictOperatorConfigured(config))
|
|
122
|
+
return true;
|
|
123
|
+
return isVerifiedOperator(msg, config);
|
|
124
|
+
}
|
|
125
|
+
/** The message as the turn may see it. Returns `msg` itself when nothing had to change. */
|
|
126
|
+
export function guardConnectorMessage(msg, config) {
|
|
127
|
+
if (GATEWAY_SOURCES.has(msg.source))
|
|
128
|
+
return msg;
|
|
129
|
+
const text = stripTerminalControlChars(msg.text);
|
|
130
|
+
// Nothing but control characters: a blank prompt is one the CLI never
|
|
131
|
+
// submits, and the turn would wait for an answer that cannot come.
|
|
132
|
+
if (!text.trim() && msg.text.trim())
|
|
133
|
+
return { ...msg, text: `${AS_TEXT}\n${text}` };
|
|
134
|
+
const passedOn = text === msg.text ? msg : { ...msg, text };
|
|
135
|
+
const seen = asSeen(text);
|
|
136
|
+
if (!readsAsCliInput(seen))
|
|
137
|
+
return passedOn;
|
|
138
|
+
const typed = text.trim();
|
|
139
|
+
if (GOAL_COMMAND.test(typed))
|
|
140
|
+
return passedOn;
|
|
141
|
+
if (isOperatorCommand(typed) && isVerifiedOperator(msg, config))
|
|
142
|
+
return passedOn;
|
|
143
|
+
return { ...msg, text: `${seen.startsWith("/") ? AS_TEXT_SLASH : AS_TEXT}\n${text}` };
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=connector-command-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector-command-guard.js","sourceRoot":"","sources":["../../../src/sessions/connector-command-guard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAA2C,IAAI,GAAG,CAAC;IACtF,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,wCAAwC;IACtE,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;CAC5B,CAAC,CAAC;AAEH,0FAA0F;AAC1F,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAExC,qGAAqG;AACrG,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAEpD,8EAA8E;AAC9E,iDAAiD;AACjD,MAAM,SAA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@@ -380,8 +380,7 @@ Your working directory is \`~/.ryoko\` (${JINN_HOME}). This contains:
|
|
|
380
380
|
- \`cron/\` — scheduled job definitions and run history
|
|
381
381
|
- \`sessions/\` — session database
|
|
382
382
|
- \`logs/\` — gateway logs
|
|
383
|
-
- \`CLAUDE.md\` —
|
|
384
|
-
- \`AGENTS.md\` — agent/employee documentation
|
|
383
|
+
- \`AGENTS.md\` / \`CLAUDE.md\` — your operating instructions (always follow these). On newer instances CLAUDE.md is only an entry point that imports AGENTS.md
|
|
385
384
|
|
|
386
385
|
You can read, write, and modify any of these files to configure yourself, create new employees, add skills, etc.`;
|
|
387
386
|
}
|
|
@@ -1061,10 +1060,10 @@ ryoko api POST /api/sessions/<child-id>/message \\
|
|
|
1061
1060
|
|
|
1062
1061
|
6. **Respond immediately**: tell the user you have delegated and will follow up when the child reports back, then end your turn. **Do NOT poll or sleep-loop inside your turn** waiting for the child — a turn has a hard time limit, and a blocked turn cannot answer anyone.
|
|
1063
1062
|
|
|
1064
|
-
7. **onComplete notification** (the primary wake-up — attempted, not guaranteed): when the child finishes, the gateway posts a notification into your session and you are woken with a preview and the child's session id. The notification is skipped silently when
|
|
1063
|
+
7. **onComplete notification** (the primary wake-up — attempted, not guaranteed): when the child finishes, the gateway posts a notification into your session and you are woken with a preview and the child's session id. Completions that arrive while you are busy reach you together as one turn (up to 32 at a time): read every child it names. The notification is skipped silently when either of these holds:
|
|
1065
1064
|
- the child was spawned without your \`parentSessionId\` (an unlinked child never notifies anyone)
|
|
1066
1065
|
- the employee sets \`alwaysNotify: false\`
|
|
1067
|
-
|
|
1066
|
+
If your session is in \`error\` when a child finishes (your own last turn failed, for example on a usage limit or a lost login), you are not woken: the notification is written into your transcript, marked "Not acted on". When you run again, read your recent messages (\`ryoko api GET /api/sessions/<your-session-id>?last=20\`) for children that finished in the meantime. A turn that failed because the engine process died does not count: you are woken as usual.
|
|
1068
1067
|
If the POST itself fails (gateway restart, auth), a warning goes to the gateway log — not to you.
|
|
1069
1068
|
|
|
1070
1069
|
8. **Safety net**: if the user asks about progress, or a reply is overdue, read the child yourself:
|