@phnx-labs/agents-cli 0.1.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +283 -372
- package/dist/commands/alias.d.ts +11 -0
- package/dist/commands/alias.js +117 -0
- package/dist/commands/beta.d.ts +2 -0
- package/dist/commands/beta.js +53 -0
- package/dist/commands/cloud.d.ts +8 -1
- package/dist/commands/cloud.js +108 -22
- package/dist/commands/commands.d.ts +9 -1
- package/dist/commands/commands.js +24 -172
- package/dist/commands/daemon.d.ts +8 -1
- package/dist/commands/daemon.js +13 -5
- package/dist/commands/doctor.d.ts +15 -0
- package/dist/commands/doctor.js +132 -0
- package/dist/commands/drive.d.ts +8 -1
- package/dist/commands/drive.js +20 -3
- package/dist/commands/exec.d.ts +8 -1
- package/dist/commands/exec.js +96 -27
- package/dist/commands/factory.d.ts +19 -0
- package/dist/commands/factory.js +71 -0
- package/dist/commands/fork.d.ts +8 -1
- package/dist/commands/fork.js +11 -4
- package/dist/commands/hooks.d.ts +9 -1
- package/dist/commands/hooks.js +30 -182
- package/dist/commands/init.d.ts +15 -1
- package/dist/commands/init.js +168 -74
- package/dist/commands/mcp.d.ts +9 -1
- package/dist/commands/mcp.js +11 -7
- package/dist/commands/models.d.ts +8 -1
- package/dist/commands/models.js +16 -4
- package/dist/commands/packages.d.ts +8 -1
- package/dist/commands/packages.js +13 -7
- package/dist/commands/permissions.d.ts +9 -1
- package/dist/commands/permissions.js +3 -3
- package/dist/commands/plugins.d.ts +8 -1
- package/dist/commands/plugins.js +13 -2
- package/dist/commands/profiles.d.ts +9 -1
- package/dist/commands/profiles.js +56 -7
- package/dist/commands/prune.d.ts +22 -0
- package/dist/commands/prune.js +191 -0
- package/dist/commands/pty.d.ts +1 -1
- package/dist/commands/pty.js +2 -1
- package/dist/commands/pull.d.ts +8 -1
- package/dist/commands/pull.js +58 -128
- package/dist/commands/refresh-memory.d.ts +7 -1
- package/dist/commands/refresh-memory.js +7 -1
- package/dist/commands/repo.d.ts +15 -0
- package/dist/commands/repo.js +570 -0
- package/dist/commands/resource-view.d.ts +10 -3
- package/dist/commands/resource-view.js +18 -5
- package/dist/commands/routines.d.ts +8 -1
- package/dist/commands/routines.js +17 -4
- package/dist/commands/rules.d.ts +9 -1
- package/dist/commands/rules.js +16 -11
- package/dist/commands/secrets.d.ts +8 -1
- package/dist/commands/secrets.js +235 -63
- package/dist/commands/sessions-picker.d.ts +2 -1
- package/dist/commands/sessions-picker.js +88 -11
- package/dist/commands/sessions-tail.d.ts +19 -0
- package/dist/commands/sessions-tail.js +235 -0
- package/dist/commands/sessions.d.ts +2 -1
- package/dist/commands/sessions.js +188 -7
- package/dist/commands/skills.d.ts +9 -1
- package/dist/commands/skills.js +28 -178
- package/dist/commands/status.d.ts +7 -1
- package/dist/commands/status.js +7 -1
- package/dist/commands/subagents.d.ts +8 -1
- package/dist/commands/subagents.js +11 -1
- package/dist/commands/sync.d.ts +8 -1
- package/dist/commands/sync.js +8 -1
- package/dist/commands/teams-picker.d.ts +4 -1
- package/dist/commands/teams-picker.js +55 -3
- package/dist/commands/teams.d.ts +15 -1
- package/dist/commands/teams.js +323 -69
- package/dist/commands/usage.d.ts +11 -0
- package/dist/commands/usage.js +60 -0
- package/dist/commands/utils.d.ts +6 -1
- package/dist/commands/utils.js +6 -1
- package/dist/commands/versions.d.ts +8 -1
- package/dist/commands/versions.js +4 -3
- package/dist/commands/view.d.ts +47 -2
- package/dist/commands/view.js +317 -24
- package/dist/index.d.ts +7 -2
- package/dist/index.js +172 -34
- package/dist/lib/acp/client.d.ts +31 -0
- package/dist/lib/acp/client.js +117 -0
- package/dist/lib/acp/harnesses.d.ts +26 -0
- package/dist/lib/acp/harnesses.js +65 -0
- package/dist/lib/acp/run.d.ts +18 -0
- package/dist/lib/acp/run.js +39 -0
- package/dist/lib/agents.d.ts +74 -2
- package/dist/lib/agents.js +197 -21
- package/dist/lib/artifact-actions.d.ts +8 -4
- package/dist/lib/artifact-actions.js +8 -6
- package/dist/lib/auto-pull-worker.d.ts +11 -0
- package/dist/lib/auto-pull-worker.js +121 -0
- package/dist/lib/auto-pull.d.ts +31 -0
- package/dist/lib/auto-pull.js +97 -0
- package/dist/lib/beta.d.ts +23 -0
- package/dist/lib/beta.js +90 -0
- package/dist/lib/capabilities.d.ts +29 -0
- package/dist/lib/capabilities.js +74 -0
- package/dist/lib/cloud/codex.d.ts +9 -3
- package/dist/lib/cloud/codex.js +53 -13
- package/dist/lib/cloud/factory.d.ts +8 -3
- package/dist/lib/cloud/factory.js +19 -3
- package/dist/lib/cloud/registry.d.ts +10 -1
- package/dist/lib/cloud/registry.js +14 -3
- package/dist/lib/cloud/rush.d.ts +63 -3
- package/dist/lib/cloud/rush.js +273 -20
- package/dist/lib/cloud/store.d.ts +13 -1
- package/dist/lib/cloud/store.js +23 -4
- package/dist/lib/cloud/stream.d.ts +6 -1
- package/dist/lib/cloud/stream.js +95 -39
- package/dist/lib/cloud/types.d.ts +153 -8
- package/dist/lib/cloud/types.js +34 -2
- package/dist/lib/command-skills.d.ts +20 -0
- package/dist/lib/command-skills.js +142 -0
- package/dist/lib/commands.d.ts +22 -2
- package/dist/lib/commands.js +51 -11
- package/dist/lib/convert.d.ts +10 -1
- package/dist/lib/convert.js +9 -1
- package/dist/lib/daemon.d.ts +21 -1
- package/dist/lib/daemon.js +97 -4
- package/dist/lib/drive-sync.d.ts +18 -1
- package/dist/lib/drive-sync.js +57 -15
- package/dist/lib/exec.d.ts +23 -6
- package/dist/lib/exec.js +53 -17
- package/dist/lib/fs-walk.d.ts +2 -0
- package/dist/lib/fs-walk.js +40 -0
- package/dist/lib/fuzzy.d.ts +53 -0
- package/dist/lib/fuzzy.js +72 -0
- package/dist/lib/gemini-settings.d.ts +4 -0
- package/dist/lib/gemini-settings.js +33 -0
- package/dist/lib/git.d.ts +12 -2
- package/dist/lib/git.js +17 -6
- package/dist/lib/help.d.ts +20 -1
- package/dist/lib/help.js +45 -6
- package/dist/lib/hooks/match.d.ts +32 -0
- package/dist/lib/hooks/match.js +120 -0
- package/dist/lib/hooks.d.ts +17 -4
- package/dist/lib/hooks.js +119 -101
- package/dist/lib/manifest.d.ts +6 -1
- package/dist/lib/manifest.js +15 -4
- package/dist/lib/markdown.d.ts +0 -1
- package/dist/lib/markdown.js +6 -1
- package/dist/lib/mcp.d.ts +0 -1
- package/dist/lib/mcp.js +29 -33
- package/dist/lib/memory-compile.d.ts +13 -3
- package/dist/lib/memory-compile.js +31 -9
- package/dist/lib/memory.d.ts +14 -7
- package/dist/lib/memory.js +67 -38
- package/dist/lib/migrate.d.ts +8 -0
- package/dist/lib/migrate.js +85 -0
- package/dist/lib/models.d.ts +10 -4
- package/dist/lib/models.js +36 -15
- package/dist/lib/onepassword.d.ts +63 -0
- package/dist/lib/onepassword.js +186 -0
- package/dist/lib/paths.d.ts +8 -0
- package/dist/lib/paths.js +20 -0
- package/dist/lib/permissions.d.ts +24 -2
- package/dist/lib/permissions.js +117 -48
- package/dist/lib/picker.d.ts +10 -1
- package/dist/lib/picker.js +15 -1
- package/dist/lib/plugins.d.ts +7 -1
- package/dist/lib/plugins.js +10 -1
- package/dist/lib/profiles-presets.d.ts +10 -1
- package/dist/lib/profiles-presets.js +9 -1
- package/dist/lib/profiles.d.ts +35 -1
- package/dist/lib/profiles.js +36 -15
- package/dist/lib/pty-client.d.ts +1 -1
- package/dist/lib/pty-client.js +0 -1
- package/dist/lib/pty-server.d.ts +16 -2
- package/dist/lib/pty-server.js +92 -3
- package/dist/lib/registry.d.ts +23 -3
- package/dist/lib/registry.js +153 -8
- package/dist/lib/resources.d.ts +28 -1
- package/dist/lib/resources.js +79 -1
- package/dist/lib/rotate.d.ts +40 -13
- package/dist/lib/rotate.js +238 -40
- package/dist/lib/routines.d.ts +29 -1
- package/dist/lib/routines.js +32 -5
- package/dist/lib/runner.d.ts +14 -1
- package/dist/lib/runner.js +22 -3
- package/dist/lib/sandbox.d.ts +16 -1
- package/dist/lib/sandbox.js +39 -16
- package/dist/lib/scheduler.d.ts +8 -1
- package/dist/lib/scheduler.js +8 -1
- package/dist/lib/secrets/AgentsKeychain.app/Contents/CodeResources +0 -0
- package/dist/lib/secrets/AgentsKeychain.app/Contents/Info.plist +22 -0
- package/dist/lib/secrets/AgentsKeychain.app/Contents/MacOS/AgentsKeychain +0 -0
- package/dist/lib/secrets/AgentsKeychain.app/Contents/_CodeSignature/CodeResources +123 -0
- package/dist/lib/secrets/AgentsKeychain.app/Contents/embedded.provisionprofile +0 -0
- package/dist/lib/{secrets-bundles.d.ts → secrets/bundles.d.ts} +12 -2
- package/dist/lib/{secrets-bundles.js → secrets/bundles.js} +38 -17
- package/dist/lib/secrets/index.d.ts +55 -0
- package/dist/lib/secrets/index.js +211 -0
- package/dist/lib/secrets/profiles.d.ts +10 -0
- package/dist/lib/secrets/profiles.js +13 -0
- package/dist/lib/session/active.d.ts +43 -0
- package/dist/lib/session/active.js +392 -0
- package/dist/lib/session/artifacts.d.ts +12 -1
- package/dist/lib/session/artifacts.js +25 -5
- package/dist/lib/session/cloud.d.ts +30 -0
- package/dist/lib/session/cloud.js +121 -0
- package/dist/lib/session/db.d.ts +23 -2
- package/dist/lib/session/db.js +76 -12
- package/dist/lib/session/discover.d.ts +19 -4
- package/dist/lib/session/discover.js +344 -48
- package/dist/lib/session/parse.d.ts +28 -1
- package/dist/lib/session/parse.js +267 -9
- package/dist/lib/session/prompt.d.ts +9 -1
- package/dist/lib/session/prompt.js +17 -3
- package/dist/lib/session/render.d.ts +13 -1
- package/dist/lib/session/render.js +20 -1
- package/dist/lib/session/team-filter.d.ts +9 -1
- package/dist/lib/session/team-filter.js +11 -2
- package/dist/lib/session/types.d.ts +16 -2
- package/dist/lib/session/types.js +10 -2
- package/dist/lib/shims.d.ts +64 -5
- package/dist/lib/shims.js +309 -47
- package/dist/lib/skills.d.ts +27 -2
- package/dist/lib/skills.js +127 -65
- package/dist/lib/sqlite.d.ts +43 -0
- package/dist/lib/sqlite.js +94 -0
- package/dist/lib/state.d.ts +112 -27
- package/dist/lib/state.js +320 -148
- package/dist/lib/subagents.d.ts +9 -1
- package/dist/lib/subagents.js +70 -63
- package/dist/lib/sync-manifest.d.ts +81 -0
- package/dist/lib/sync-manifest.js +450 -0
- package/dist/lib/teams/agents.d.ts +103 -5
- package/dist/lib/teams/agents.js +414 -91
- package/dist/lib/teams/api.d.ts +26 -3
- package/dist/lib/teams/api.js +63 -3
- package/dist/lib/teams/debug.d.ts +6 -1
- package/dist/lib/teams/debug.js +6 -1
- package/dist/lib/teams/file_ops.d.ts +7 -1
- package/dist/lib/teams/file_ops.js +7 -1
- package/dist/lib/teams/index.d.ts +15 -0
- package/dist/lib/teams/index.js +14 -0
- package/dist/lib/teams/parsers.d.ts +4 -1
- package/dist/lib/teams/parsers.js +11 -1
- package/dist/lib/teams/persistence.d.ts +15 -1
- package/dist/lib/teams/persistence.js +102 -20
- package/dist/lib/teams/registry.d.ts +12 -1
- package/dist/lib/teams/registry.js +116 -33
- package/dist/lib/teams/summarizer.d.ts +15 -1
- package/dist/lib/teams/summarizer.js +14 -1
- package/dist/lib/teams/supervisor.d.ts +48 -0
- package/dist/lib/teams/supervisor.js +73 -0
- package/dist/lib/template.d.ts +8 -6
- package/dist/lib/template.js +8 -6
- package/dist/lib/types.d.ts +147 -8
- package/dist/lib/types.js +26 -3
- package/dist/lib/usage.d.ts +32 -1
- package/dist/lib/usage.js +70 -6
- package/dist/lib/version-duplicates.d.ts +21 -0
- package/dist/lib/version-duplicates.js +90 -0
- package/dist/lib/versions.d.ts +33 -4
- package/dist/lib/versions.js +376 -108
- package/package.json +32 -17
- package/scripts/postinstall.js +126 -30
- package/dist/commands/__tests__/sessions.test.d.ts +0 -2
- package/dist/commands/__tests__/sessions.test.d.ts.map +0 -1
- package/dist/commands/__tests__/sessions.test.js +0 -636
- package/dist/commands/__tests__/sessions.test.js.map +0 -1
- package/dist/commands/cloud.d.ts.map +0 -1
- package/dist/commands/cloud.js.map +0 -1
- package/dist/commands/commands.d.ts.map +0 -1
- package/dist/commands/commands.js.map +0 -1
- package/dist/commands/daemon.d.ts.map +0 -1
- package/dist/commands/daemon.js.map +0 -1
- package/dist/commands/drive.d.ts.map +0 -1
- package/dist/commands/drive.js.map +0 -1
- package/dist/commands/exec.d.ts.map +0 -1
- package/dist/commands/exec.js.map +0 -1
- package/dist/commands/fork.d.ts.map +0 -1
- package/dist/commands/fork.js.map +0 -1
- package/dist/commands/hooks.d.ts.map +0 -1
- package/dist/commands/hooks.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/models.d.ts.map +0 -1
- package/dist/commands/models.js.map +0 -1
- package/dist/commands/packages.d.ts.map +0 -1
- package/dist/commands/packages.js.map +0 -1
- package/dist/commands/permissions.d.ts.map +0 -1
- package/dist/commands/permissions.js.map +0 -1
- package/dist/commands/plugins.d.ts.map +0 -1
- package/dist/commands/plugins.js.map +0 -1
- package/dist/commands/profiles.d.ts.map +0 -1
- package/dist/commands/profiles.js.map +0 -1
- package/dist/commands/pty.d.ts.map +0 -1
- package/dist/commands/pty.js.map +0 -1
- package/dist/commands/pull.d.ts.map +0 -1
- package/dist/commands/pull.js.map +0 -1
- package/dist/commands/push.d.ts +0 -3
- package/dist/commands/push.d.ts.map +0 -1
- package/dist/commands/push.js +0 -180
- package/dist/commands/push.js.map +0 -1
- package/dist/commands/refresh-memory.d.ts.map +0 -1
- package/dist/commands/refresh-memory.js.map +0 -1
- package/dist/commands/resource-view.d.ts.map +0 -1
- package/dist/commands/resource-view.js.map +0 -1
- package/dist/commands/routines.d.ts.map +0 -1
- package/dist/commands/routines.js.map +0 -1
- package/dist/commands/rules.d.ts.map +0 -1
- package/dist/commands/rules.js.map +0 -1
- package/dist/commands/secrets.d.ts.map +0 -1
- package/dist/commands/secrets.js.map +0 -1
- package/dist/commands/sessions-picker.d.ts.map +0 -1
- package/dist/commands/sessions-picker.js.map +0 -1
- package/dist/commands/sessions.d.ts.map +0 -1
- package/dist/commands/sessions.js.map +0 -1
- package/dist/commands/skills.d.ts.map +0 -1
- package/dist/commands/skills.js.map +0 -1
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/subagents.d.ts.map +0 -1
- package/dist/commands/subagents.js.map +0 -1
- package/dist/commands/sync.d.ts.map +0 -1
- package/dist/commands/sync.js.map +0 -1
- package/dist/commands/teams-picker.d.ts.map +0 -1
- package/dist/commands/teams-picker.js.map +0 -1
- package/dist/commands/teams.d.ts.map +0 -1
- package/dist/commands/teams.js.map +0 -1
- package/dist/commands/utils.d.ts.map +0 -1
- package/dist/commands/utils.js.map +0 -1
- package/dist/commands/versions.d.ts.map +0 -1
- package/dist/commands/versions.js.map +0 -1
- package/dist/commands/view.d.ts.map +0 -1
- package/dist/commands/view.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/__tests__/bugfixes.test.d.ts +0 -2
- package/dist/lib/__tests__/bugfixes.test.d.ts.map +0 -1
- package/dist/lib/__tests__/bugfixes.test.js +0 -192
- package/dist/lib/__tests__/bugfixes.test.js.map +0 -1
- package/dist/lib/__tests__/exec.test.d.ts +0 -2
- package/dist/lib/__tests__/exec.test.d.ts.map +0 -1
- package/dist/lib/__tests__/exec.test.js +0 -446
- package/dist/lib/__tests__/exec.test.js.map +0 -1
- package/dist/lib/__tests__/git-sync.test.d.ts +0 -2
- package/dist/lib/__tests__/git-sync.test.d.ts.map +0 -1
- package/dist/lib/__tests__/git-sync.test.js +0 -138
- package/dist/lib/__tests__/git-sync.test.js.map +0 -1
- package/dist/lib/__tests__/hooks.test.d.ts +0 -2
- package/dist/lib/__tests__/hooks.test.d.ts.map +0 -1
- package/dist/lib/__tests__/hooks.test.js +0 -203
- package/dist/lib/__tests__/hooks.test.js.map +0 -1
- package/dist/lib/__tests__/memory-compile.test.d.ts +0 -2
- package/dist/lib/__tests__/memory-compile.test.d.ts.map +0 -1
- package/dist/lib/__tests__/memory-compile.test.js +0 -95
- package/dist/lib/__tests__/memory-compile.test.js.map +0 -1
- package/dist/lib/__tests__/models.test.d.ts +0 -2
- package/dist/lib/__tests__/models.test.d.ts.map +0 -1
- package/dist/lib/__tests__/models.test.js +0 -239
- package/dist/lib/__tests__/models.test.js.map +0 -1
- package/dist/lib/__tests__/rotate.test.d.ts +0 -2
- package/dist/lib/__tests__/rotate.test.d.ts.map +0 -1
- package/dist/lib/__tests__/rotate.test.js +0 -80
- package/dist/lib/__tests__/rotate.test.js.map +0 -1
- package/dist/lib/__tests__/secrets-bundles.test.d.ts +0 -2
- package/dist/lib/__tests__/secrets-bundles.test.d.ts.map +0 -1
- package/dist/lib/__tests__/secrets-bundles.test.js +0 -104
- package/dist/lib/__tests__/secrets-bundles.test.js.map +0 -1
- package/dist/lib/__tests__/secrets.test.d.ts +0 -2
- package/dist/lib/__tests__/secrets.test.d.ts.map +0 -1
- package/dist/lib/__tests__/secrets.test.js +0 -90
- package/dist/lib/__tests__/secrets.test.js.map +0 -1
- package/dist/lib/__tests__/shims.test.d.ts +0 -2
- package/dist/lib/__tests__/shims.test.d.ts.map +0 -1
- package/dist/lib/__tests__/shims.test.js +0 -39
- package/dist/lib/__tests__/shims.test.js.map +0 -1
- package/dist/lib/__tests__/usage.test.d.ts +0 -2
- package/dist/lib/__tests__/usage.test.d.ts.map +0 -1
- package/dist/lib/__tests__/usage.test.js +0 -220
- package/dist/lib/__tests__/usage.test.js.map +0 -1
- package/dist/lib/__tests__/versions.test.d.ts +0 -2
- package/dist/lib/__tests__/versions.test.d.ts.map +0 -1
- package/dist/lib/__tests__/versions.test.js +0 -63
- package/dist/lib/__tests__/versions.test.js.map +0 -1
- package/dist/lib/agents.d.ts.map +0 -1
- package/dist/lib/agents.js.map +0 -1
- package/dist/lib/artifact-actions.d.ts.map +0 -1
- package/dist/lib/artifact-actions.js.map +0 -1
- package/dist/lib/cloud/codex.d.ts.map +0 -1
- package/dist/lib/cloud/codex.js.map +0 -1
- package/dist/lib/cloud/factory.d.ts.map +0 -1
- package/dist/lib/cloud/factory.js.map +0 -1
- package/dist/lib/cloud/registry.d.ts.map +0 -1
- package/dist/lib/cloud/registry.js.map +0 -1
- package/dist/lib/cloud/rush.d.ts.map +0 -1
- package/dist/lib/cloud/rush.js.map +0 -1
- package/dist/lib/cloud/store.d.ts.map +0 -1
- package/dist/lib/cloud/store.js.map +0 -1
- package/dist/lib/cloud/stream.d.ts.map +0 -1
- package/dist/lib/cloud/stream.js.map +0 -1
- package/dist/lib/cloud/types.d.ts.map +0 -1
- package/dist/lib/cloud/types.js.map +0 -1
- package/dist/lib/commands.d.ts.map +0 -1
- package/dist/lib/commands.js.map +0 -1
- package/dist/lib/convert.d.ts.map +0 -1
- package/dist/lib/convert.js.map +0 -1
- package/dist/lib/daemon.d.ts.map +0 -1
- package/dist/lib/daemon.js.map +0 -1
- package/dist/lib/drive-sync.d.ts.map +0 -1
- package/dist/lib/drive-sync.js.map +0 -1
- package/dist/lib/exec.d.ts.map +0 -1
- package/dist/lib/exec.js.map +0 -1
- package/dist/lib/factory.d.ts +0 -57
- package/dist/lib/factory.d.ts.map +0 -1
- package/dist/lib/factory.js +0 -110
- package/dist/lib/factory.js.map +0 -1
- package/dist/lib/git.d.ts.map +0 -1
- package/dist/lib/git.js.map +0 -1
- package/dist/lib/help.d.ts.map +0 -1
- package/dist/lib/help.js.map +0 -1
- package/dist/lib/hooks.d.ts.map +0 -1
- package/dist/lib/hooks.js.map +0 -1
- package/dist/lib/manifest.d.ts.map +0 -1
- package/dist/lib/manifest.js.map +0 -1
- package/dist/lib/markdown.d.ts.map +0 -1
- package/dist/lib/markdown.js.map +0 -1
- package/dist/lib/mcp.d.ts.map +0 -1
- package/dist/lib/mcp.js.map +0 -1
- package/dist/lib/memory-compile.d.ts.map +0 -1
- package/dist/lib/memory-compile.js.map +0 -1
- package/dist/lib/memory.d.ts.map +0 -1
- package/dist/lib/memory.js.map +0 -1
- package/dist/lib/models.d.ts.map +0 -1
- package/dist/lib/models.js.map +0 -1
- package/dist/lib/permissions.d.ts.map +0 -1
- package/dist/lib/permissions.js.map +0 -1
- package/dist/lib/picker.d.ts.map +0 -1
- package/dist/lib/picker.js.map +0 -1
- package/dist/lib/plugins.d.ts.map +0 -1
- package/dist/lib/plugins.js.map +0 -1
- package/dist/lib/profiles-keychain.d.ts +0 -3
- package/dist/lib/profiles-keychain.d.ts.map +0 -1
- package/dist/lib/profiles-keychain.js +0 -10
- package/dist/lib/profiles-keychain.js.map +0 -1
- package/dist/lib/profiles-presets.d.ts.map +0 -1
- package/dist/lib/profiles-presets.js.map +0 -1
- package/dist/lib/profiles.d.ts.map +0 -1
- package/dist/lib/profiles.js.map +0 -1
- package/dist/lib/pty-client.d.ts.map +0 -1
- package/dist/lib/pty-client.js.map +0 -1
- package/dist/lib/pty-server.d.ts.map +0 -1
- package/dist/lib/pty-server.js.map +0 -1
- package/dist/lib/registry.d.ts.map +0 -1
- package/dist/lib/registry.js.map +0 -1
- package/dist/lib/resources.d.ts.map +0 -1
- package/dist/lib/resources.js.map +0 -1
- package/dist/lib/rotate.d.ts.map +0 -1
- package/dist/lib/rotate.js.map +0 -1
- package/dist/lib/routines.d.ts.map +0 -1
- package/dist/lib/routines.js.map +0 -1
- package/dist/lib/runner.d.ts.map +0 -1
- package/dist/lib/runner.js.map +0 -1
- package/dist/lib/sandbox.d.ts.map +0 -1
- package/dist/lib/sandbox.js.map +0 -1
- package/dist/lib/scheduler.d.ts.map +0 -1
- package/dist/lib/scheduler.js.map +0 -1
- package/dist/lib/secrets-bundles.d.ts.map +0 -1
- package/dist/lib/secrets-bundles.js.map +0 -1
- package/dist/lib/secrets.d.ts +0 -27
- package/dist/lib/secrets.d.ts.map +0 -1
- package/dist/lib/secrets.js +0 -127
- package/dist/lib/secrets.js.map +0 -1
- package/dist/lib/session/__tests__/db.test.d.ts +0 -2
- package/dist/lib/session/__tests__/db.test.d.ts.map +0 -1
- package/dist/lib/session/__tests__/db.test.js +0 -54
- package/dist/lib/session/__tests__/db.test.js.map +0 -1
- package/dist/lib/session/__tests__/discover.test.d.ts +0 -2
- package/dist/lib/session/__tests__/discover.test.d.ts.map +0 -1
- package/dist/lib/session/__tests__/discover.test.js +0 -63
- package/dist/lib/session/__tests__/discover.test.js.map +0 -1
- package/dist/lib/session/__tests__/prompt.test.d.ts +0 -2
- package/dist/lib/session/__tests__/prompt.test.d.ts.map +0 -1
- package/dist/lib/session/__tests__/prompt.test.js +0 -44
- package/dist/lib/session/__tests__/prompt.test.js.map +0 -1
- package/dist/lib/session/__tests__/render.test.d.ts +0 -2
- package/dist/lib/session/__tests__/render.test.d.ts.map +0 -1
- package/dist/lib/session/__tests__/render.test.js +0 -602
- package/dist/lib/session/__tests__/render.test.js.map +0 -1
- package/dist/lib/session/artifacts.d.ts.map +0 -1
- package/dist/lib/session/artifacts.js.map +0 -1
- package/dist/lib/session/db.d.ts.map +0 -1
- package/dist/lib/session/db.js.map +0 -1
- package/dist/lib/session/discover.d.ts.map +0 -1
- package/dist/lib/session/discover.js.map +0 -1
- package/dist/lib/session/parse.d.ts.map +0 -1
- package/dist/lib/session/parse.js.map +0 -1
- package/dist/lib/session/prompt.d.ts.map +0 -1
- package/dist/lib/session/prompt.js.map +0 -1
- package/dist/lib/session/prompt.test.d.ts +0 -2
- package/dist/lib/session/prompt.test.d.ts.map +0 -1
- package/dist/lib/session/prompt.test.js +0 -57
- package/dist/lib/session/prompt.test.js.map +0 -1
- package/dist/lib/session/render.d.ts.map +0 -1
- package/dist/lib/session/render.js.map +0 -1
- package/dist/lib/session/team-filter.d.ts.map +0 -1
- package/dist/lib/session/team-filter.js.map +0 -1
- package/dist/lib/session/team-filter.test.d.ts +0 -2
- package/dist/lib/session/team-filter.test.d.ts.map +0 -1
- package/dist/lib/session/team-filter.test.js +0 -157
- package/dist/lib/session/team-filter.test.js.map +0 -1
- package/dist/lib/session/types.d.ts.map +0 -1
- package/dist/lib/session/types.js.map +0 -1
- package/dist/lib/shims.d.ts.map +0 -1
- package/dist/lib/shims.js.map +0 -1
- package/dist/lib/skills.d.ts.map +0 -1
- package/dist/lib/skills.js.map +0 -1
- package/dist/lib/state.d.ts.map +0 -1
- package/dist/lib/state.js.map +0 -1
- package/dist/lib/subagents.d.ts.map +0 -1
- package/dist/lib/subagents.js.map +0 -1
- package/dist/lib/teams/agents.d.ts.map +0 -1
- package/dist/lib/teams/agents.js.map +0 -1
- package/dist/lib/teams/api.d.ts.map +0 -1
- package/dist/lib/teams/api.js.map +0 -1
- package/dist/lib/teams/cloud.d.ts +0 -11
- package/dist/lib/teams/cloud.d.ts.map +0 -1
- package/dist/lib/teams/cloud.js +0 -169
- package/dist/lib/teams/cloud.js.map +0 -1
- package/dist/lib/teams/debug.d.ts.map +0 -1
- package/dist/lib/teams/debug.js.map +0 -1
- package/dist/lib/teams/file_ops.d.ts.map +0 -1
- package/dist/lib/teams/file_ops.js.map +0 -1
- package/dist/lib/teams/parsers.d.ts.map +0 -1
- package/dist/lib/teams/parsers.js.map +0 -1
- package/dist/lib/teams/persistence.d.ts.map +0 -1
- package/dist/lib/teams/persistence.js.map +0 -1
- package/dist/lib/teams/ralph.d.ts +0 -8
- package/dist/lib/teams/ralph.d.ts.map +0 -1
- package/dist/lib/teams/ralph.js +0 -59
- package/dist/lib/teams/ralph.js.map +0 -1
- package/dist/lib/teams/registry.d.ts.map +0 -1
- package/dist/lib/teams/registry.js.map +0 -1
- package/dist/lib/teams/summarizer.d.ts.map +0 -1
- package/dist/lib/teams/summarizer.js.map +0 -1
- package/dist/lib/template.d.ts.map +0 -1
- package/dist/lib/template.js.map +0 -1
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/usage.d.ts.map +0 -1
- package/dist/lib/usage.js.map +0 -1
- package/dist/lib/versions.d.ts.map +0 -1
- package/dist/lib/versions.js.map +0 -1
- package/scripts/rebuild-sqlite.sh +0 -46
|
@@ -1,10 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive session picker and preview renderer.
|
|
3
|
+
*
|
|
4
|
+
* Powers the fuzzy-searchable session list shown by `agents sessions` in a TTY.
|
|
5
|
+
* Builds a compact preview for each session (prompt, activity summary, last
|
|
6
|
+
* response) and delegates to the generic `itemPicker` for the interactive UI.
|
|
7
|
+
*/
|
|
1
8
|
import chalk from 'chalk';
|
|
2
|
-
import { parseSession } from '../lib/session/parse.js';
|
|
9
|
+
import { parseSession, sanitizeForTerminal } from '../lib/session/parse.js';
|
|
3
10
|
import { cleanSessionPrompt, extractSessionTopic } from '../lib/session/prompt.js';
|
|
4
11
|
import { linkPath, relativeToCwd } from '../lib/session/render.js';
|
|
5
12
|
import { renderMarkdown } from '../lib/markdown.js';
|
|
6
13
|
import { itemPicker } from '../lib/picker.js';
|
|
14
|
+
/**
|
|
15
|
+
* SessionMeta originates in discover.ts (gitBranch, cwd, label, etc. read from
|
|
16
|
+
* untrusted session files). parseSession sanitizes event payloads at its
|
|
17
|
+
* chokepoint, but meta fields bypass that path. Strip terminal escapes here
|
|
18
|
+
* before any meta string reaches a TTY.
|
|
19
|
+
*/
|
|
20
|
+
function sanitizeMeta(s) {
|
|
21
|
+
const clean = (v) => (v == null ? v : sanitizeForTerminal(v));
|
|
22
|
+
return {
|
|
23
|
+
...s,
|
|
24
|
+
id: sanitizeForTerminal(s.id),
|
|
25
|
+
shortId: sanitizeForTerminal(s.shortId),
|
|
26
|
+
filePath: sanitizeForTerminal(s.filePath),
|
|
27
|
+
cwd: clean(s.cwd),
|
|
28
|
+
project: clean(s.project),
|
|
29
|
+
gitBranch: clean(s.gitBranch),
|
|
30
|
+
version: clean(s.version),
|
|
31
|
+
account: clean(s.account),
|
|
32
|
+
topic: clean(s.topic),
|
|
33
|
+
label: clean(s.label),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
7
36
|
const previewCache = new Map();
|
|
37
|
+
/** Build a cached multi-line preview string for display in the session picker. */
|
|
8
38
|
export function buildPreview(session) {
|
|
9
39
|
const cached = previewCache.get(session.id);
|
|
10
40
|
if (cached)
|
|
@@ -15,12 +45,13 @@ export function buildPreview(session) {
|
|
|
15
45
|
events = parseSession(session.filePath, session.agent);
|
|
16
46
|
}
|
|
17
47
|
catch (err) {
|
|
18
|
-
parseError = err
|
|
48
|
+
parseError = sanitizeForTerminal(err?.message ?? String(err));
|
|
19
49
|
}
|
|
20
|
-
const
|
|
50
|
+
const safe = sanitizeMeta(session);
|
|
51
|
+
const header = formatHeader(safe, events);
|
|
21
52
|
const body = parseError
|
|
22
53
|
? ' ' + chalk.red(`Failed to parse session: ${parseError}`)
|
|
23
|
-
: formatCompactPreview(events,
|
|
54
|
+
: formatCompactPreview(events, safe);
|
|
24
55
|
const output = [header, '', body].filter(Boolean).join('\n');
|
|
25
56
|
previewCache.set(session.id, output);
|
|
26
57
|
return output;
|
|
@@ -63,7 +94,7 @@ function formatHeader(session, events) {
|
|
|
63
94
|
}
|
|
64
95
|
if (session.label)
|
|
65
96
|
line3.push(chalk.white(session.label));
|
|
66
|
-
line3.push(chalk.gray(session.id));
|
|
97
|
+
line3.push(chalk.gray(linkPath(session.filePath, session.id)));
|
|
67
98
|
return [
|
|
68
99
|
line1.join(DOT),
|
|
69
100
|
line2.join(DOT),
|
|
@@ -140,6 +171,8 @@ function stripTags(text) {
|
|
|
140
171
|
return cleaned;
|
|
141
172
|
}
|
|
142
173
|
const LAST_RESPONSE_MAX_LINES = 15;
|
|
174
|
+
const LAST_RESPONSE_MAX_LINES_WITH_TODOS = 8;
|
|
175
|
+
const TODOS_MAX_ITEMS = 5;
|
|
143
176
|
function formatCompactPreview(events, session) {
|
|
144
177
|
let firstUser = '';
|
|
145
178
|
let lastAssistant = '';
|
|
@@ -147,6 +180,7 @@ function formatCompactPreview(events, session) {
|
|
|
147
180
|
const filesRead = new Set();
|
|
148
181
|
let toolCalls = 0;
|
|
149
182
|
let planFile = '';
|
|
183
|
+
let latestTodos = null;
|
|
150
184
|
for (const event of events) {
|
|
151
185
|
if (event.type === 'message') {
|
|
152
186
|
if (event.role === 'user' && !firstUser && event.content) {
|
|
@@ -170,6 +204,9 @@ function formatCompactPreview(events, session) {
|
|
|
170
204
|
if (!planFile && p && /\/plans\/[^/]+\.md$/.test(p)) {
|
|
171
205
|
planFile = p;
|
|
172
206
|
}
|
|
207
|
+
if (tool === 'TodoWrite' && Array.isArray(event.args?.todos)) {
|
|
208
|
+
latestTodos = event.args.todos;
|
|
209
|
+
}
|
|
173
210
|
toolCalls++;
|
|
174
211
|
}
|
|
175
212
|
}
|
|
@@ -195,8 +232,15 @@ function formatCompactPreview(events, session) {
|
|
|
195
232
|
const basename = planFile.split('/').pop() || planFile;
|
|
196
233
|
lines.push(chalk.cyan('Plan: ') + chalk.white(linkPath(planFile, basename)));
|
|
197
234
|
}
|
|
235
|
+
const todosRendered = latestTodos ? renderTodos(latestTodos, termWidth) : [];
|
|
236
|
+
if (todosRendered.length > 0) {
|
|
237
|
+
lines.push(chalk.cyan('Todos:'));
|
|
238
|
+
for (const l of todosRendered)
|
|
239
|
+
lines.push(' ' + l);
|
|
240
|
+
}
|
|
198
241
|
if (lastAssistant) {
|
|
199
|
-
const
|
|
242
|
+
const maxLines = todosRendered.length > 0 ? LAST_RESPONSE_MAX_LINES_WITH_TODOS : LAST_RESPONSE_MAX_LINES;
|
|
243
|
+
const rendered = renderLastResponse(lastAssistant, maxLines);
|
|
200
244
|
if (rendered.length > 0) {
|
|
201
245
|
lines.push('');
|
|
202
246
|
lines.push(chalk.cyan('Last response:'));
|
|
@@ -209,7 +253,7 @@ function formatCompactPreview(events, session) {
|
|
|
209
253
|
}
|
|
210
254
|
return lines.map(l => ' ' + l).join('\n');
|
|
211
255
|
}
|
|
212
|
-
function renderLastResponse(content) {
|
|
256
|
+
function renderLastResponse(content, maxLines = LAST_RESPONSE_MAX_LINES) {
|
|
213
257
|
const cleaned = stripTags(content).trim();
|
|
214
258
|
if (!cleaned)
|
|
215
259
|
return [];
|
|
@@ -226,16 +270,50 @@ function renderLastResponse(content) {
|
|
|
226
270
|
all.shift();
|
|
227
271
|
while (all.length && !all[all.length - 1].trim())
|
|
228
272
|
all.pop();
|
|
229
|
-
if (all.length <=
|
|
273
|
+
if (all.length <= maxLines)
|
|
230
274
|
return all;
|
|
231
|
-
const shown = all.slice(0,
|
|
232
|
-
const more = all.length -
|
|
275
|
+
const shown = all.slice(0, maxLines);
|
|
276
|
+
const more = all.length - maxLines;
|
|
233
277
|
shown.push(chalk.gray(`… (${more} more line${more === 1 ? '' : 's'})`));
|
|
234
278
|
return shown;
|
|
235
279
|
}
|
|
280
|
+
function renderTodos(todos, termWidth) {
|
|
281
|
+
const out = [];
|
|
282
|
+
const shown = todos.slice(0, TODOS_MAX_ITEMS);
|
|
283
|
+
// Outer body indent (2) + inner ' ' (2) + marker (3) + space (1) = 8
|
|
284
|
+
const maxText = Math.max(20, termWidth - 8);
|
|
285
|
+
for (const item of shown) {
|
|
286
|
+
const rawText = (item.content || item.text || '').trim();
|
|
287
|
+
if (!rawText)
|
|
288
|
+
continue;
|
|
289
|
+
const text = truncate(rawText, maxText);
|
|
290
|
+
const status = item.status || 'pending';
|
|
291
|
+
let marker;
|
|
292
|
+
let textOut;
|
|
293
|
+
if (status === 'completed') {
|
|
294
|
+
marker = chalk.green('[x]');
|
|
295
|
+
textOut = chalk.gray(text);
|
|
296
|
+
}
|
|
297
|
+
else if (status === 'in_progress') {
|
|
298
|
+
marker = chalk.yellow('[>]');
|
|
299
|
+
textOut = chalk.white(text);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
marker = chalk.gray('[ ]');
|
|
303
|
+
textOut = chalk.white(text);
|
|
304
|
+
}
|
|
305
|
+
out.push(marker + ' ' + textOut);
|
|
306
|
+
}
|
|
307
|
+
if (todos.length > TODOS_MAX_ITEMS) {
|
|
308
|
+
const more = todos.length - TODOS_MAX_ITEMS;
|
|
309
|
+
out.push(chalk.gray(`… (${more} more)`));
|
|
310
|
+
}
|
|
311
|
+
return out;
|
|
312
|
+
}
|
|
236
313
|
function truncate(s, max) {
|
|
237
314
|
return s.length > max ? s.slice(0, max - 1) + '…' : s;
|
|
238
315
|
}
|
|
316
|
+
/** Show an interactive session picker and return the selected session with its action (resume or view). */
|
|
239
317
|
export async function sessionPicker(config) {
|
|
240
318
|
const picked = await itemPicker({
|
|
241
319
|
message: config.message,
|
|
@@ -253,4 +331,3 @@ export async function sessionPicker(config) {
|
|
|
253
331
|
return null;
|
|
254
332
|
return { session: picked.item, action: 'resume' };
|
|
255
333
|
}
|
|
256
|
-
//# sourceMappingURL=sessions-picker.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
export interface TailFileOptions {
|
|
3
|
+
/** If true, emit every line from byte 0 first, then follow. Default false (EOF). */
|
|
4
|
+
fromStart?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Tail a file: emit each newline-terminated line via onLine as it's written.
|
|
8
|
+
*
|
|
9
|
+
* Returns a promise that resolves when the AbortController fires. Uses
|
|
10
|
+
* fs.watch on the parent directory (more reliable on macOS than watching
|
|
11
|
+
* the file directly) and tracks byte offset to avoid re-reading content.
|
|
12
|
+
*
|
|
13
|
+
* Emits each line exactly once. Handles partial lines across reads, file
|
|
14
|
+
* truncation (offset reset), and files that don't exist yet (watches the
|
|
15
|
+
* parent dir until the file appears).
|
|
16
|
+
*/
|
|
17
|
+
export declare function tailFile(filePath: string, onLine: (line: string) => void, ac: AbortController, opts?: TailFileOptions): Promise<void>;
|
|
18
|
+
/** Attach the `tail` subcommand to an existing `sessions` command. */
|
|
19
|
+
export declare function registerSessionsTailCommand(sessionsCmd: Command): void;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live-tail a session file and stream new events as they're written.
|
|
3
|
+
*
|
|
4
|
+
* Implements `agents sessions tail` — position-tracked reader on the session
|
|
5
|
+
* JSONL, driven by an fs.watch on the parent directory. Claude and Codex
|
|
6
|
+
* only for v1 (both use append-only JSONL).
|
|
7
|
+
*/
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import * as fsp from 'fs/promises';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
import chalk from 'chalk';
|
|
12
|
+
import { discoverSessions, resolveSessionById } from '../lib/session/discover.js';
|
|
13
|
+
const TAIL_SUPPORTED = ['claude', 'codex'];
|
|
14
|
+
/**
|
|
15
|
+
* Tail a file: emit each newline-terminated line via onLine as it's written.
|
|
16
|
+
*
|
|
17
|
+
* Returns a promise that resolves when the AbortController fires. Uses
|
|
18
|
+
* fs.watch on the parent directory (more reliable on macOS than watching
|
|
19
|
+
* the file directly) and tracks byte offset to avoid re-reading content.
|
|
20
|
+
*
|
|
21
|
+
* Emits each line exactly once. Handles partial lines across reads, file
|
|
22
|
+
* truncation (offset reset), and files that don't exist yet (watches the
|
|
23
|
+
* parent dir until the file appears).
|
|
24
|
+
*/
|
|
25
|
+
export async function tailFile(filePath, onLine, ac, opts = {}) {
|
|
26
|
+
const dir = path.dirname(filePath);
|
|
27
|
+
const base = path.basename(filePath);
|
|
28
|
+
let fd = null;
|
|
29
|
+
let offset = 0;
|
|
30
|
+
let partial = '';
|
|
31
|
+
let reading = false;
|
|
32
|
+
let dirty = false;
|
|
33
|
+
const openIfPossible = async (initial) => {
|
|
34
|
+
try {
|
|
35
|
+
fd = await fsp.open(filePath, 'r');
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (initial) {
|
|
41
|
+
const st = await fd.stat();
|
|
42
|
+
offset = opts.fromStart ? 0 : st.size;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// File appeared after we started watching — emit from byte 0.
|
|
46
|
+
offset = 0;
|
|
47
|
+
partial = '';
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
};
|
|
51
|
+
const closeFd = async () => {
|
|
52
|
+
const h = fd;
|
|
53
|
+
fd = null;
|
|
54
|
+
if (h) {
|
|
55
|
+
try {
|
|
56
|
+
await h.close();
|
|
57
|
+
}
|
|
58
|
+
catch { /* already closed */ }
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const drain = async () => {
|
|
62
|
+
if (reading) {
|
|
63
|
+
dirty = true;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
reading = true;
|
|
67
|
+
try {
|
|
68
|
+
while (!ac.signal.aborted) {
|
|
69
|
+
if (!fd) {
|
|
70
|
+
const ok = await openIfPossible(false);
|
|
71
|
+
if (!ok)
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const st = await fd.stat();
|
|
75
|
+
if (st.size < offset) {
|
|
76
|
+
// Truncation or rotation: reset to start of the new content.
|
|
77
|
+
offset = 0;
|
|
78
|
+
partial = '';
|
|
79
|
+
}
|
|
80
|
+
if (st.size === offset) {
|
|
81
|
+
if (dirty) {
|
|
82
|
+
dirty = false;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const len = st.size - offset;
|
|
88
|
+
const buf = Buffer.alloc(len);
|
|
89
|
+
await fd.read(buf, 0, len, offset);
|
|
90
|
+
offset = st.size;
|
|
91
|
+
const text = partial + buf.toString('utf-8');
|
|
92
|
+
const lines = text.split('\n');
|
|
93
|
+
partial = lines.pop() ?? '';
|
|
94
|
+
for (const line of lines) {
|
|
95
|
+
if (ac.signal.aborted)
|
|
96
|
+
return;
|
|
97
|
+
if (line.length > 0)
|
|
98
|
+
onLine(line);
|
|
99
|
+
}
|
|
100
|
+
if (!dirty)
|
|
101
|
+
return;
|
|
102
|
+
dirty = false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
reading = false;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
if (fs.existsSync(filePath)) {
|
|
110
|
+
await openIfPossible(true);
|
|
111
|
+
}
|
|
112
|
+
const watcher = fs.watch(dir, { recursive: false }, (_event, filename) => {
|
|
113
|
+
if (ac.signal.aborted)
|
|
114
|
+
return;
|
|
115
|
+
// On macOS, filename is sometimes null — don't filter in that case.
|
|
116
|
+
if (filename !== null && filename !== base)
|
|
117
|
+
return;
|
|
118
|
+
// Stat detects append, truncation, or reappearance in drain(); trust that
|
|
119
|
+
// over the event type, which macOS coalesces inconsistently.
|
|
120
|
+
void drain();
|
|
121
|
+
});
|
|
122
|
+
// Initial drain in case the file has content beyond EOF-of-our-offset
|
|
123
|
+
// (e.g. --from-start, or a write between stat and watch attach).
|
|
124
|
+
await drain();
|
|
125
|
+
await new Promise((resolve) => {
|
|
126
|
+
const onAbort = () => {
|
|
127
|
+
ac.signal.removeEventListener('abort', onAbort);
|
|
128
|
+
try {
|
|
129
|
+
watcher.close();
|
|
130
|
+
}
|
|
131
|
+
catch { /* noop */ }
|
|
132
|
+
void closeFd().then(() => resolve());
|
|
133
|
+
};
|
|
134
|
+
if (ac.signal.aborted)
|
|
135
|
+
onAbort();
|
|
136
|
+
else
|
|
137
|
+
ac.signal.addEventListener('abort', onAbort);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
async function findLatestTailable() {
|
|
141
|
+
const sessions = await discoverSessions({ all: true, limit: 100 });
|
|
142
|
+
const eligible = sessions.filter(s => TAIL_SUPPORTED.includes(s.agent));
|
|
143
|
+
if (eligible.length === 0)
|
|
144
|
+
return undefined;
|
|
145
|
+
eligible.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
146
|
+
return eligible[0];
|
|
147
|
+
}
|
|
148
|
+
async function resolveTailable(sessionId) {
|
|
149
|
+
const sessions = await discoverSessions({ all: true, limit: 5000 });
|
|
150
|
+
const matches = resolveSessionById(sessions, sessionId);
|
|
151
|
+
if (matches.length === 0)
|
|
152
|
+
return undefined;
|
|
153
|
+
// Prefer a supported agent among matches; if only unsupported match, signal.
|
|
154
|
+
const supported = matches.find(s => TAIL_SUPPORTED.includes(s.agent));
|
|
155
|
+
if (supported)
|
|
156
|
+
return supported;
|
|
157
|
+
return 'unsupported';
|
|
158
|
+
}
|
|
159
|
+
async function runTail(sessionId, options) {
|
|
160
|
+
let session;
|
|
161
|
+
if (options.latest) {
|
|
162
|
+
session = await findLatestTailable();
|
|
163
|
+
if (!session) {
|
|
164
|
+
console.log(chalk.gray('No tailable sessions found (claude or codex).'));
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
if (!sessionId) {
|
|
170
|
+
console.error(chalk.red('Missing session ID. Pass an ID or use --latest.'));
|
|
171
|
+
process.exit(2);
|
|
172
|
+
}
|
|
173
|
+
const resolved = await resolveTailable(sessionId);
|
|
174
|
+
if (resolved === 'unsupported') {
|
|
175
|
+
console.error(chalk.red(`Tailing is supported for append-only JSONL agents only (claude, codex).`));
|
|
176
|
+
process.exit(2);
|
|
177
|
+
}
|
|
178
|
+
if (!resolved) {
|
|
179
|
+
console.error(chalk.red(`No session found matching: ${sessionId}`));
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
session = resolved;
|
|
183
|
+
}
|
|
184
|
+
const filePath = session.filePath.split('#')[0];
|
|
185
|
+
if (process.stderr.isTTY) {
|
|
186
|
+
process.stderr.write(chalk.gray(`Tailing ${session.agent} ${session.shortId} — ${filePath}\n`) +
|
|
187
|
+
chalk.gray('Ctrl+C to stop.\n'));
|
|
188
|
+
}
|
|
189
|
+
const ac = new AbortController();
|
|
190
|
+
const onSig = () => { ac.abort(); };
|
|
191
|
+
process.on('SIGINT', onSig);
|
|
192
|
+
process.on('SIGTERM', onSig);
|
|
193
|
+
try {
|
|
194
|
+
await tailFile(filePath, (line) => {
|
|
195
|
+
process.stdout.write(line + '\n');
|
|
196
|
+
}, ac, { fromStart: options.fromStart });
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
process.off('SIGINT', onSig);
|
|
200
|
+
process.off('SIGTERM', onSig);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/** Attach the `tail` subcommand to an existing `sessions` command. */
|
|
204
|
+
export function registerSessionsTailCommand(sessionsCmd) {
|
|
205
|
+
sessionsCmd
|
|
206
|
+
.command('tail [sessionId]')
|
|
207
|
+
.description('Live-tail a session file, streaming new JSONL events as they are written. Long-running: press Ctrl+C to stop. Claude and Codex only.')
|
|
208
|
+
.option('--latest', 'Tail the most recent tailable session (claude or codex)')
|
|
209
|
+
.option('--from-start', 'Emit the full file first, then follow (default: start at EOF)')
|
|
210
|
+
.option('--json', 'Raw JSONL passthrough (default)')
|
|
211
|
+
.addHelpText('after', `
|
|
212
|
+
This command runs until interrupted (Ctrl+C). Each line printed to stdout
|
|
213
|
+
is a raw JSONL event from the session file — parse with jq or similar.
|
|
214
|
+
|
|
215
|
+
Examples:
|
|
216
|
+
# Follow the most recent active Claude or Codex session
|
|
217
|
+
agents sessions tail --latest
|
|
218
|
+
|
|
219
|
+
# Follow a specific session by short or full ID
|
|
220
|
+
agents sessions tail a1b2c3d4
|
|
221
|
+
|
|
222
|
+
# Replay from the beginning, then follow
|
|
223
|
+
agents sessions tail a1b2c3d4 --from-start
|
|
224
|
+
|
|
225
|
+
# Pipe through jq to extract just user messages
|
|
226
|
+
agents sessions tail --latest | jq 'select(.type == "user")'
|
|
227
|
+
|
|
228
|
+
Only Claude and Codex sessions are supported — they append JSONL one event
|
|
229
|
+
per line, which makes live-tailing safe. Gemini, OpenCode, and OpenClaw
|
|
230
|
+
use formats that rewrite the file or store state elsewhere.
|
|
231
|
+
`)
|
|
232
|
+
.action(async (sessionId, options) => {
|
|
233
|
+
await runTail(sessionId, options);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
@@ -11,6 +11,7 @@ import type { SessionMeta } from '../lib/session/types.js';
|
|
|
11
11
|
* `agents sessions <id>` — that reader is version-agnostic.
|
|
12
12
|
*/
|
|
13
13
|
export declare function buildResumeCommand(session: SessionMeta, activeVersion?: string): string[] | null;
|
|
14
|
+
/** Filter and rank sessions by a multi-term search query across metadata and content. */
|
|
14
15
|
export declare function filterSessionsByQuery(sessions: SessionMeta[], query: string | undefined): SessionMeta[];
|
|
16
|
+
/** Register the `agents sessions` command with all its options and help text. */
|
|
15
17
|
export declare function registerSessionsCommands(program: Command): void;
|
|
16
|
-
//# sourceMappingURL=sessions.d.ts.map
|