@phnx-labs/agents-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +316 -0
- package/LICENSE +21 -0
- package/README.md +537 -0
- package/dist/commands/__tests__/sessions.test.d.ts +2 -0
- package/dist/commands/__tests__/sessions.test.d.ts.map +1 -0
- package/dist/commands/__tests__/sessions.test.js +636 -0
- package/dist/commands/__tests__/sessions.test.js.map +1 -0
- package/dist/commands/cloud.d.ts +3 -0
- package/dist/commands/cloud.d.ts.map +1 -0
- package/dist/commands/cloud.js +322 -0
- package/dist/commands/cloud.js.map +1 -0
- package/dist/commands/commands.d.ts +3 -0
- package/dist/commands/commands.d.ts.map +1 -0
- package/dist/commands/commands.js +628 -0
- package/dist/commands/commands.js.map +1 -0
- package/dist/commands/daemon.d.ts +3 -0
- package/dist/commands/daemon.d.ts.map +1 -0
- package/dist/commands/daemon.js +110 -0
- package/dist/commands/daemon.js.map +1 -0
- package/dist/commands/drive.d.ts +3 -0
- package/dist/commands/drive.d.ts.map +1 -0
- package/dist/commands/drive.js +166 -0
- package/dist/commands/drive.js.map +1 -0
- package/dist/commands/exec.d.ts +3 -0
- package/dist/commands/exec.d.ts.map +1 -0
- package/dist/commands/exec.js +241 -0
- package/dist/commands/exec.js.map +1 -0
- package/dist/commands/fork.d.ts +3 -0
- package/dist/commands/fork.d.ts.map +1 -0
- package/dist/commands/fork.js +139 -0
- package/dist/commands/fork.js.map +1 -0
- package/dist/commands/hooks.d.ts +3 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +689 -0
- package/dist/commands/hooks.js.map +1 -0
- package/dist/commands/init.d.ts +6 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +127 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +581 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/models.d.ts +3 -0
- package/dist/commands/models.d.ts.map +1 -0
- package/dist/commands/models.js +158 -0
- package/dist/commands/models.js.map +1 -0
- package/dist/commands/packages.d.ts +3 -0
- package/dist/commands/packages.d.ts.map +1 -0
- package/dist/commands/packages.js +541 -0
- package/dist/commands/packages.js.map +1 -0
- package/dist/commands/permissions.d.ts +3 -0
- package/dist/commands/permissions.d.ts.map +1 -0
- package/dist/commands/permissions.js +723 -0
- package/dist/commands/permissions.js.map +1 -0
- package/dist/commands/plugins.d.ts +3 -0
- package/dist/commands/plugins.d.ts.map +1 -0
- package/dist/commands/plugins.js +382 -0
- package/dist/commands/plugins.js.map +1 -0
- package/dist/commands/profiles.d.ts +3 -0
- package/dist/commands/profiles.d.ts.map +1 -0
- package/dist/commands/profiles.js +242 -0
- package/dist/commands/profiles.js.map +1 -0
- package/dist/commands/pty.d.ts +20 -0
- package/dist/commands/pty.d.ts.map +1 -0
- package/dist/commands/pty.js +389 -0
- package/dist/commands/pty.js.map +1 -0
- package/dist/commands/pull.d.ts +3 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +448 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +3 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +180 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/refresh-memory.d.ts +9 -0
- package/dist/commands/refresh-memory.d.ts.map +1 -0
- package/dist/commands/refresh-memory.js +45 -0
- package/dist/commands/refresh-memory.js.map +1 -0
- package/dist/commands/resource-view.d.ts +31 -0
- package/dist/commands/resource-view.d.ts.map +1 -0
- package/dist/commands/resource-view.js +183 -0
- package/dist/commands/resource-view.js.map +1 -0
- package/dist/commands/routines.d.ts +3 -0
- package/dist/commands/routines.d.ts.map +1 -0
- package/dist/commands/routines.js +579 -0
- package/dist/commands/routines.js.map +1 -0
- package/dist/commands/rules.d.ts +3 -0
- package/dist/commands/rules.d.ts.map +1 -0
- package/dist/commands/rules.js +488 -0
- package/dist/commands/rules.js.map +1 -0
- package/dist/commands/secrets.d.ts +3 -0
- package/dist/commands/secrets.d.ts.map +1 -0
- package/dist/commands/secrets.js +339 -0
- package/dist/commands/secrets.js.map +1 -0
- package/dist/commands/sessions-picker.d.ts +16 -0
- package/dist/commands/sessions-picker.d.ts.map +1 -0
- package/dist/commands/sessions-picker.js +256 -0
- package/dist/commands/sessions-picker.js.map +1 -0
- package/dist/commands/sessions.d.ts +16 -0
- package/dist/commands/sessions.d.ts.map +1 -0
- package/dist/commands/sessions.js +1077 -0
- package/dist/commands/sessions.js.map +1 -0
- package/dist/commands/skills.d.ts +3 -0
- package/dist/commands/skills.d.ts.map +1 -0
- package/dist/commands/skills.js +716 -0
- package/dist/commands/skills.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +19 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/subagents.d.ts +3 -0
- package/dist/commands/subagents.d.ts.map +1 -0
- package/dist/commands/subagents.js +350 -0
- package/dist/commands/subagents.js.map +1 -0
- package/dist/commands/sync.d.ts +3 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +62 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/teams-picker.d.ts +14 -0
- package/dist/commands/teams-picker.d.ts.map +1 -0
- package/dist/commands/teams-picker.js +278 -0
- package/dist/commands/teams-picker.js.map +1 -0
- package/dist/commands/teams.d.ts +3 -0
- package/dist/commands/teams.d.ts.map +1 -0
- package/dist/commands/teams.js +917 -0
- package/dist/commands/teams.js.map +1 -0
- package/dist/commands/utils.d.ts +39 -0
- package/dist/commands/utils.d.ts.map +1 -0
- package/dist/commands/utils.js +100 -0
- package/dist/commands/utils.js.map +1 -0
- package/dist/commands/versions.d.ts +3 -0
- package/dist/commands/versions.d.ts.map +1 -0
- package/dist/commands/versions.js +700 -0
- package/dist/commands/versions.js.map +1 -0
- package/dist/commands/view.d.ts +8 -0
- package/dist/commands/view.d.ts.map +1 -0
- package/dist/commands/view.js +626 -0
- package/dist/commands/view.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +484 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/__tests__/bugfixes.test.d.ts +2 -0
- package/dist/lib/__tests__/bugfixes.test.d.ts.map +1 -0
- package/dist/lib/__tests__/bugfixes.test.js +192 -0
- package/dist/lib/__tests__/bugfixes.test.js.map +1 -0
- package/dist/lib/__tests__/exec.test.d.ts +2 -0
- package/dist/lib/__tests__/exec.test.d.ts.map +1 -0
- package/dist/lib/__tests__/exec.test.js +446 -0
- package/dist/lib/__tests__/exec.test.js.map +1 -0
- package/dist/lib/__tests__/git-sync.test.d.ts +2 -0
- package/dist/lib/__tests__/git-sync.test.d.ts.map +1 -0
- package/dist/lib/__tests__/git-sync.test.js +138 -0
- package/dist/lib/__tests__/git-sync.test.js.map +1 -0
- package/dist/lib/__tests__/hooks.test.d.ts +2 -0
- package/dist/lib/__tests__/hooks.test.d.ts.map +1 -0
- package/dist/lib/__tests__/hooks.test.js +203 -0
- package/dist/lib/__tests__/hooks.test.js.map +1 -0
- package/dist/lib/__tests__/memory-compile.test.d.ts +2 -0
- package/dist/lib/__tests__/memory-compile.test.d.ts.map +1 -0
- package/dist/lib/__tests__/memory-compile.test.js +95 -0
- package/dist/lib/__tests__/memory-compile.test.js.map +1 -0
- package/dist/lib/__tests__/models.test.d.ts +2 -0
- package/dist/lib/__tests__/models.test.d.ts.map +1 -0
- package/dist/lib/__tests__/models.test.js +239 -0
- package/dist/lib/__tests__/models.test.js.map +1 -0
- package/dist/lib/__tests__/rotate.test.d.ts +2 -0
- package/dist/lib/__tests__/rotate.test.d.ts.map +1 -0
- package/dist/lib/__tests__/rotate.test.js +80 -0
- package/dist/lib/__tests__/rotate.test.js.map +1 -0
- package/dist/lib/__tests__/secrets-bundles.test.d.ts +2 -0
- package/dist/lib/__tests__/secrets-bundles.test.d.ts.map +1 -0
- package/dist/lib/__tests__/secrets-bundles.test.js +104 -0
- package/dist/lib/__tests__/secrets-bundles.test.js.map +1 -0
- package/dist/lib/__tests__/secrets.test.d.ts +2 -0
- package/dist/lib/__tests__/secrets.test.d.ts.map +1 -0
- package/dist/lib/__tests__/secrets.test.js +90 -0
- package/dist/lib/__tests__/secrets.test.js.map +1 -0
- package/dist/lib/__tests__/shims.test.d.ts +2 -0
- package/dist/lib/__tests__/shims.test.d.ts.map +1 -0
- package/dist/lib/__tests__/shims.test.js +39 -0
- package/dist/lib/__tests__/shims.test.js.map +1 -0
- package/dist/lib/__tests__/usage.test.d.ts +2 -0
- package/dist/lib/__tests__/usage.test.d.ts.map +1 -0
- package/dist/lib/__tests__/usage.test.js +220 -0
- package/dist/lib/__tests__/usage.test.js.map +1 -0
- package/dist/lib/__tests__/versions.test.d.ts +2 -0
- package/dist/lib/__tests__/versions.test.d.ts.map +1 -0
- package/dist/lib/__tests__/versions.test.js +63 -0
- package/dist/lib/__tests__/versions.test.js.map +1 -0
- package/dist/lib/agents.d.ts +107 -0
- package/dist/lib/agents.d.ts.map +1 -0
- package/dist/lib/agents.js +1096 -0
- package/dist/lib/agents.js.map +1 -0
- package/dist/lib/artifact-actions.d.ts +22 -0
- package/dist/lib/artifact-actions.d.ts.map +1 -0
- package/dist/lib/artifact-actions.js +55 -0
- package/dist/lib/artifact-actions.js.map +1 -0
- package/dist/lib/cloud/codex.d.ts +19 -0
- package/dist/lib/cloud/codex.d.ts.map +1 -0
- package/dist/lib/cloud/codex.js +210 -0
- package/dist/lib/cloud/codex.js.map +1 -0
- package/dist/lib/cloud/factory.d.ts +26 -0
- package/dist/lib/cloud/factory.d.ts.map +1 -0
- package/dist/lib/cloud/factory.js +37 -0
- package/dist/lib/cloud/factory.js.map +1 -0
- package/dist/lib/cloud/registry.d.ts +6 -0
- package/dist/lib/cloud/registry.d.ts.map +1 -0
- package/dist/lib/cloud/registry.js +56 -0
- package/dist/lib/cloud/registry.js.map +1 -0
- package/dist/lib/cloud/rush.d.ts +15 -0
- package/dist/lib/cloud/rush.d.ts.map +1 -0
- package/dist/lib/cloud/rush.js +185 -0
- package/dist/lib/cloud/rush.js.map +1 -0
- package/dist/lib/cloud/store.d.ts +10 -0
- package/dist/lib/cloud/store.d.ts.map +1 -0
- package/dist/lib/cloud/store.js +96 -0
- package/dist/lib/cloud/store.js.map +1 -0
- package/dist/lib/cloud/stream.d.ts +18 -0
- package/dist/lib/cloud/stream.d.ts.map +1 -0
- package/dist/lib/cloud/stream.js +138 -0
- package/dist/lib/cloud/stream.js.map +1 -0
- package/dist/lib/cloud/types.d.ts +60 -0
- package/dist/lib/cloud/types.d.ts.map +1 -0
- package/dist/lib/cloud/types.js +2 -0
- package/dist/lib/cloud/types.js.map +1 -0
- package/dist/lib/commands.d.ts +121 -0
- package/dist/lib/commands.d.ts.map +1 -0
- package/dist/lib/commands.js +499 -0
- package/dist/lib/commands.js.map +1 -0
- package/dist/lib/convert.d.ts +11 -0
- package/dist/lib/convert.d.ts.map +1 -0
- package/dist/lib/convert.js +45 -0
- package/dist/lib/convert.js.map +1 -0
- package/dist/lib/daemon.d.ts +22 -0
- package/dist/lib/daemon.d.ts.map +1 -0
- package/dist/lib/daemon.js +311 -0
- package/dist/lib/daemon.js.map +1 -0
- package/dist/lib/drive-sync.d.ts +28 -0
- package/dist/lib/drive-sync.d.ts.map +1 -0
- package/dist/lib/drive-sync.js +193 -0
- package/dist/lib/drive-sync.js.map +1 -0
- package/dist/lib/exec.d.ts +85 -0
- package/dist/lib/exec.d.ts.map +1 -0
- package/dist/lib/exec.js +423 -0
- package/dist/lib/exec.js.map +1 -0
- package/dist/lib/factory.d.ts +57 -0
- package/dist/lib/factory.d.ts.map +1 -0
- package/dist/lib/factory.js +110 -0
- package/dist/lib/factory.js.map +1 -0
- package/dist/lib/git.d.ts +146 -0
- package/dist/lib/git.d.ts.map +1 -0
- package/dist/lib/git.js +635 -0
- package/dist/lib/git.js.map +1 -0
- package/dist/lib/help.d.ts +3 -0
- package/dist/lib/help.d.ts.map +1 -0
- package/dist/lib/help.js +63 -0
- package/dist/lib/help.js.map +1 -0
- package/dist/lib/hooks.d.ts +116 -0
- package/dist/lib/hooks.d.ts.map +1 -0
- package/dist/lib/hooks.js +837 -0
- package/dist/lib/hooks.js.map +1 -0
- package/dist/lib/manifest.d.ts +8 -0
- package/dist/lib/manifest.d.ts.map +1 -0
- package/dist/lib/manifest.js +36 -0
- package/dist/lib/manifest.js.map +1 -0
- package/dist/lib/markdown.d.ts +5 -0
- package/dist/lib/markdown.d.ts.map +1 -0
- package/dist/lib/markdown.js +11 -0
- package/dist/lib/markdown.js.map +1 -0
- package/dist/lib/mcp.d.ts +64 -0
- package/dist/lib/mcp.d.ts.map +1 -0
- package/dist/lib/mcp.js +327 -0
- package/dist/lib/mcp.js.map +1 -0
- package/dist/lib/memory-compile.d.ts +56 -0
- package/dist/lib/memory-compile.d.ts.map +1 -0
- package/dist/lib/memory-compile.js +167 -0
- package/dist/lib/memory-compile.js.map +1 -0
- package/dist/lib/memory.d.ts +56 -0
- package/dist/lib/memory.d.ts.map +1 -0
- package/dist/lib/memory.js +267 -0
- package/dist/lib/memory.js.map +1 -0
- package/dist/lib/models.d.ts +91 -0
- package/dist/lib/models.d.ts.map +1 -0
- package/dist/lib/models.js +706 -0
- package/dist/lib/models.js.map +1 -0
- package/dist/lib/permissions.d.ts +204 -0
- package/dist/lib/permissions.d.ts.map +1 -0
- package/dist/lib/permissions.js +1022 -0
- package/dist/lib/permissions.js.map +1 -0
- package/dist/lib/picker.d.ts +17 -0
- package/dist/lib/picker.d.ts.map +1 -0
- package/dist/lib/picker.js +95 -0
- package/dist/lib/picker.js.map +1 -0
- package/dist/lib/plugins.d.ts +73 -0
- package/dist/lib/plugins.d.ts.map +1 -0
- package/dist/lib/plugins.js +549 -0
- package/dist/lib/plugins.js.map +1 -0
- package/dist/lib/profiles-keychain.d.ts +3 -0
- package/dist/lib/profiles-keychain.d.ts.map +1 -0
- package/dist/lib/profiles-keychain.js +10 -0
- package/dist/lib/profiles-keychain.js.map +1 -0
- package/dist/lib/profiles-presets.d.ts +15 -0
- package/dist/lib/profiles-presets.d.ts.map +1 -0
- package/dist/lib/profiles-presets.js +95 -0
- package/dist/lib/profiles-presets.js.map +1 -0
- package/dist/lib/profiles.d.ts +35 -0
- package/dist/lib/profiles.d.ts.map +1 -0
- package/dist/lib/profiles.js +123 -0
- package/dist/lib/profiles.js.map +1 -0
- package/dist/lib/pty-client.d.ts +22 -0
- package/dist/lib/pty-client.d.ts.map +1 -0
- package/dist/lib/pty-client.js +181 -0
- package/dist/lib/pty-client.js.map +1 -0
- package/dist/lib/pty-server.d.ts +16 -0
- package/dist/lib/pty-server.d.ts.map +1 -0
- package/dist/lib/pty-server.js +422 -0
- package/dist/lib/pty-server.js.map +1 -0
- package/dist/lib/registry.d.ts +28 -0
- package/dist/lib/registry.d.ts.map +1 -0
- package/dist/lib/registry.js +203 -0
- package/dist/lib/registry.js.map +1 -0
- package/dist/lib/resources.d.ts +50 -0
- package/dist/lib/resources.d.ts.map +1 -0
- package/dist/lib/resources.js +103 -0
- package/dist/lib/resources.js.map +1 -0
- package/dist/lib/rotate.d.ts +52 -0
- package/dist/lib/rotate.d.ts.map +1 -0
- package/dist/lib/rotate.js +87 -0
- package/dist/lib/rotate.js.map +1 -0
- package/dist/lib/routines.d.ts +70 -0
- package/dist/lib/routines.d.ts.map +1 -0
- package/dist/lib/routines.js +325 -0
- package/dist/lib/routines.js.map +1 -0
- package/dist/lib/runner.d.ts +12 -0
- package/dist/lib/runner.d.ts.map +1 -0
- package/dist/lib/runner.js +311 -0
- package/dist/lib/runner.js.map +1 -0
- package/dist/lib/sandbox.d.ts +10 -0
- package/dist/lib/sandbox.d.ts.map +1 -0
- package/dist/lib/sandbox.js +201 -0
- package/dist/lib/sandbox.js.map +1 -0
- package/dist/lib/scheduler.d.ts +18 -0
- package/dist/lib/scheduler.d.ts.map +1 -0
- package/dist/lib/scheduler.js +69 -0
- package/dist/lib/scheduler.js.map +1 -0
- package/dist/lib/secrets-bundles.d.ts +29 -0
- package/dist/lib/secrets-bundles.d.ts.map +1 -0
- package/dist/lib/secrets-bundles.js +168 -0
- package/dist/lib/secrets-bundles.js.map +1 -0
- package/dist/lib/secrets.d.ts +27 -0
- package/dist/lib/secrets.d.ts.map +1 -0
- package/dist/lib/secrets.js +127 -0
- package/dist/lib/secrets.js.map +1 -0
- package/dist/lib/session/__tests__/db.test.d.ts +2 -0
- package/dist/lib/session/__tests__/db.test.d.ts.map +1 -0
- package/dist/lib/session/__tests__/db.test.js +54 -0
- package/dist/lib/session/__tests__/db.test.js.map +1 -0
- package/dist/lib/session/__tests__/discover.test.d.ts +2 -0
- package/dist/lib/session/__tests__/discover.test.d.ts.map +1 -0
- package/dist/lib/session/__tests__/discover.test.js +63 -0
- package/dist/lib/session/__tests__/discover.test.js.map +1 -0
- package/dist/lib/session/__tests__/prompt.test.d.ts +2 -0
- package/dist/lib/session/__tests__/prompt.test.d.ts.map +1 -0
- package/dist/lib/session/__tests__/prompt.test.js +44 -0
- package/dist/lib/session/__tests__/prompt.test.js.map +1 -0
- package/dist/lib/session/__tests__/render.test.d.ts +2 -0
- package/dist/lib/session/__tests__/render.test.d.ts.map +1 -0
- package/dist/lib/session/__tests__/render.test.js +602 -0
- package/dist/lib/session/__tests__/render.test.js.map +1 -0
- package/dist/lib/session/artifacts.d.ts +5 -0
- package/dist/lib/session/artifacts.d.ts.map +1 -0
- package/dist/lib/session/artifacts.js +75 -0
- package/dist/lib/session/artifacts.js.map +1 -0
- package/dist/lib/session/db.d.ts +118 -0
- package/dist/lib/session/db.d.ts.map +1 -0
- package/dist/lib/session/db.js +576 -0
- package/dist/lib/session/db.js.map +1 -0
- package/dist/lib/session/discover.d.ts +60 -0
- package/dist/lib/session/discover.d.ts.map +1 -0
- package/dist/lib/session/discover.js +1272 -0
- package/dist/lib/session/discover.js.map +1 -0
- package/dist/lib/session/parse.d.ts +23 -0
- package/dist/lib/session/parse.d.ts.map +1 -0
- package/dist/lib/session/parse.js +650 -0
- package/dist/lib/session/parse.js.map +1 -0
- package/dist/lib/session/prompt.d.ts +4 -0
- package/dist/lib/session/prompt.d.ts.map +1 -0
- package/dist/lib/session/prompt.js +64 -0
- package/dist/lib/session/prompt.js.map +1 -0
- package/dist/lib/session/prompt.test.d.ts +2 -0
- package/dist/lib/session/prompt.test.d.ts.map +1 -0
- package/dist/lib/session/prompt.test.js +57 -0
- package/dist/lib/session/prompt.test.js.map +1 -0
- package/dist/lib/session/render.d.ts +90 -0
- package/dist/lib/session/render.d.ts.map +1 -0
- package/dist/lib/session/render.js +778 -0
- package/dist/lib/session/render.js.map +1 -0
- package/dist/lib/session/team-filter.d.ts +26 -0
- package/dist/lib/session/team-filter.d.ts.map +1 -0
- package/dist/lib/session/team-filter.js +66 -0
- package/dist/lib/session/team-filter.js.map +1 -0
- package/dist/lib/session/team-filter.test.d.ts +2 -0
- package/dist/lib/session/team-filter.test.d.ts.map +1 -0
- package/dist/lib/session/team-filter.test.js +157 -0
- package/dist/lib/session/team-filter.test.js.map +1 -0
- package/dist/lib/session/types.d.ts +69 -0
- package/dist/lib/session/types.d.ts.map +1 -0
- package/dist/lib/session/types.js +2 -0
- package/dist/lib/session/types.js.map +1 -0
- package/dist/lib/shims.d.ts +228 -0
- package/dist/lib/shims.d.ts.map +1 -0
- package/dist/lib/shims.js +1170 -0
- package/dist/lib/shims.js.map +1 -0
- package/dist/lib/skills.d.ts +134 -0
- package/dist/lib/skills.d.ts.map +1 -0
- package/dist/lib/skills.js +783 -0
- package/dist/lib/skills.js.map +1 -0
- package/dist/lib/state.d.ts +53 -0
- package/dist/lib/state.d.ts.map +1 -0
- package/dist/lib/state.js +299 -0
- package/dist/lib/state.js.map +1 -0
- package/dist/lib/subagents.d.ts +75 -0
- package/dist/lib/subagents.d.ts.map +1 -0
- package/dist/lib/subagents.js +402 -0
- package/dist/lib/subagents.js.map +1 -0
- package/dist/lib/teams/agents.d.ts +146 -0
- package/dist/lib/teams/agents.d.ts.map +1 -0
- package/dist/lib/teams/agents.js +1072 -0
- package/dist/lib/teams/agents.js.map +1 -0
- package/dist/lib/teams/api.d.ts +77 -0
- package/dist/lib/teams/api.d.ts.map +1 -0
- package/dist/lib/teams/api.js +229 -0
- package/dist/lib/teams/api.js.map +1 -0
- package/dist/lib/teams/cloud.d.ts +11 -0
- package/dist/lib/teams/cloud.d.ts.map +1 -0
- package/dist/lib/teams/cloud.js +169 -0
- package/dist/lib/teams/cloud.js.map +1 -0
- package/dist/lib/teams/debug.d.ts +2 -0
- package/dist/lib/teams/debug.d.ts.map +1 -0
- package/dist/lib/teams/debug.js +6 -0
- package/dist/lib/teams/debug.js.map +1 -0
- package/dist/lib/teams/file_ops.d.ts +6 -0
- package/dist/lib/teams/file_ops.d.ts.map +1 -0
- package/dist/lib/teams/file_ops.js +59 -0
- package/dist/lib/teams/file_ops.js.map +1 -0
- package/dist/lib/teams/parsers.d.ts +5 -0
- package/dist/lib/teams/parsers.d.ts.map +1 -0
- package/dist/lib/teams/parsers.js +826 -0
- package/dist/lib/teams/parsers.js.map +1 -0
- package/dist/lib/teams/persistence.d.ts +28 -0
- package/dist/lib/teams/persistence.d.ts.map +1 -0
- package/dist/lib/teams/persistence.js +289 -0
- package/dist/lib/teams/persistence.js.map +1 -0
- package/dist/lib/teams/ralph.d.ts +8 -0
- package/dist/lib/teams/ralph.d.ts.map +1 -0
- package/dist/lib/teams/ralph.js +59 -0
- package/dist/lib/teams/ralph.js.map +1 -0
- package/dist/lib/teams/registry.d.ts +11 -0
- package/dist/lib/teams/registry.d.ts.map +1 -0
- package/dist/lib/teams/registry.js +56 -0
- package/dist/lib/teams/registry.js.map +1 -0
- package/dist/lib/teams/summarizer.d.ts +58 -0
- package/dist/lib/teams/summarizer.d.ts.map +1 -0
- package/dist/lib/teams/summarizer.js +766 -0
- package/dist/lib/teams/summarizer.js.map +1 -0
- package/dist/lib/template.d.ts +24 -0
- package/dist/lib/template.d.ts.map +1 -0
- package/dist/lib/template.js +57 -0
- package/dist/lib/template.js.map +1 -0
- package/dist/lib/types.d.ts +282 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +18 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/usage.d.ts +73 -0
- package/dist/lib/usage.d.ts.map +1 -0
- package/dist/lib/usage.js +623 -0
- package/dist/lib/usage.js.map +1 -0
- package/dist/lib/versions.d.ts +248 -0
- package/dist/lib/versions.d.ts.map +1 -0
- package/dist/lib/versions.js +1737 -0
- package/dist/lib/versions.js.map +1 -0
- package/package.json +82 -0
- package/scripts/postinstall.js +72 -0
- package/scripts/rebuild-sqlite.sh +46 -0
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
/**
|
|
4
|
+
* Auto-detect agent type from file path and parse the session.
|
|
5
|
+
*/
|
|
6
|
+
export function parseSession(filePath, agent) {
|
|
7
|
+
const detected = agent || detectAgent(filePath);
|
|
8
|
+
if (!detected) {
|
|
9
|
+
throw new Error(`Cannot detect agent type from path: ${filePath}`);
|
|
10
|
+
}
|
|
11
|
+
switch (detected) {
|
|
12
|
+
case 'claude': return parseClaude(filePath);
|
|
13
|
+
case 'codex': return parseCodex(filePath);
|
|
14
|
+
case 'gemini': return parseGemini(filePath);
|
|
15
|
+
case 'opencode': return parseOpenCode(filePath);
|
|
16
|
+
case 'openclaw': return []; // OpenClaw sessions don't have parseable files yet
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function detectAgent(filePath) {
|
|
20
|
+
if (filePath.includes('/.claude/') || filePath.includes('\\.claude\\'))
|
|
21
|
+
return 'claude';
|
|
22
|
+
if (filePath.includes('/.codex/') || filePath.includes('\\.codex\\'))
|
|
23
|
+
return 'codex';
|
|
24
|
+
if (filePath.includes('/.gemini/') || filePath.includes('\\.gemini\\'))
|
|
25
|
+
return 'gemini';
|
|
26
|
+
if (filePath.includes('opencode.db'))
|
|
27
|
+
return 'opencode';
|
|
28
|
+
// Try file extension + content heuristic
|
|
29
|
+
if (filePath.endsWith('.json'))
|
|
30
|
+
return 'gemini';
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Summarize a tool_use into a one-liner string.
|
|
35
|
+
*/
|
|
36
|
+
export function summarizeToolUse(tool, args) {
|
|
37
|
+
if (!args)
|
|
38
|
+
return tool;
|
|
39
|
+
switch (tool) {
|
|
40
|
+
case 'Bash':
|
|
41
|
+
return `Bash: ${truncate(String(args.command || '').replace(/\n/g, ' ').trim(), 120)}`;
|
|
42
|
+
case 'Read':
|
|
43
|
+
return `Read ${shortenPath(args.file_path || '')}`;
|
|
44
|
+
case 'Write':
|
|
45
|
+
return `Write ${shortenPath(args.file_path || '')}`;
|
|
46
|
+
case 'Edit':
|
|
47
|
+
return `Edit ${shortenPath(args.file_path || '')}`;
|
|
48
|
+
case 'Glob':
|
|
49
|
+
return `Glob ${args.pattern || ''}`;
|
|
50
|
+
case 'Grep':
|
|
51
|
+
return `Grep ${args.pattern || ''} ${args.path || ''}`.trim();
|
|
52
|
+
case 'Agent':
|
|
53
|
+
return `Agent: ${truncate(args.description || args.prompt || '', 80)}`;
|
|
54
|
+
case 'WebSearch':
|
|
55
|
+
case 'WebFetch':
|
|
56
|
+
return `${tool}: ${truncate(args.query || args.url || '', 80)}`;
|
|
57
|
+
// Codex tools
|
|
58
|
+
case 'exec_command':
|
|
59
|
+
return `Bash: ${truncate(String(args.command || args.cmd || '').replace(/\n/g, ' ').trim(), 120)}`;
|
|
60
|
+
case 'read_file':
|
|
61
|
+
return `Read ${shortenPath(args.file_path || args.path || '')}`;
|
|
62
|
+
case 'write_file':
|
|
63
|
+
case 'create_file':
|
|
64
|
+
return `Write ${shortenPath(args.file_path || args.path || '')}`;
|
|
65
|
+
case 'edit_file':
|
|
66
|
+
return `Edit ${shortenPath(args.file_path || args.path || '')}`;
|
|
67
|
+
// Gemini tools
|
|
68
|
+
case 'run_shell_command':
|
|
69
|
+
return `Bash: ${truncate(String(args.command || '').replace(/\n/g, ' ').trim(), 120)}`;
|
|
70
|
+
case 'search_file_content':
|
|
71
|
+
return `Search ${args.pattern || ''}`;
|
|
72
|
+
default: {
|
|
73
|
+
// Generic: show first meaningful arg
|
|
74
|
+
for (const key of ['file_path', 'path', 'pattern', 'command', 'prompt', 'query', 'url']) {
|
|
75
|
+
if (args[key])
|
|
76
|
+
return `${tool}: ${truncate(String(args[key]), 80)}`;
|
|
77
|
+
}
|
|
78
|
+
return tool;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function truncate(s, n) {
|
|
83
|
+
return s.length <= n ? s : s.slice(0, n - 3) + '...';
|
|
84
|
+
}
|
|
85
|
+
function shortenPath(p) {
|
|
86
|
+
const home = process.env.HOME || '';
|
|
87
|
+
if (home && p.startsWith(home))
|
|
88
|
+
return '~' + p.slice(home.length);
|
|
89
|
+
return p;
|
|
90
|
+
}
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
// Claude parser
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
export function parseClaude(filePath) {
|
|
95
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
96
|
+
const lines = content.split('\n').filter(l => l.trim());
|
|
97
|
+
const events = [];
|
|
98
|
+
// Map tool_use id -> {tool, args} for correlating with tool_result
|
|
99
|
+
const toolUseMap = new Map();
|
|
100
|
+
for (const line of lines) {
|
|
101
|
+
let raw;
|
|
102
|
+
try {
|
|
103
|
+
raw = JSON.parse(line);
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
/* malformed JSONL line, skip */
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const type = raw.type;
|
|
110
|
+
const timestamp = raw.timestamp || new Date().toISOString();
|
|
111
|
+
if (type === 'assistant') {
|
|
112
|
+
const contentBlocks = raw.message?.content || [];
|
|
113
|
+
for (const block of contentBlocks) {
|
|
114
|
+
if (block.type === 'thinking') {
|
|
115
|
+
// Thinking content -- may be encrypted (has .signature field)
|
|
116
|
+
const thinkingText = block.thinking || '';
|
|
117
|
+
if (thinkingText) {
|
|
118
|
+
events.push({
|
|
119
|
+
type: 'thinking',
|
|
120
|
+
agent: 'claude',
|
|
121
|
+
timestamp,
|
|
122
|
+
content: thinkingText,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else if (block.type === 'text') {
|
|
127
|
+
const text = (block.text || '').trim();
|
|
128
|
+
if (text) {
|
|
129
|
+
events.push({
|
|
130
|
+
type: 'message',
|
|
131
|
+
agent: 'claude',
|
|
132
|
+
timestamp,
|
|
133
|
+
role: 'assistant',
|
|
134
|
+
content: text,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else if (block.type === 'tool_use') {
|
|
139
|
+
const toolName = block.name || 'unknown';
|
|
140
|
+
const toolInput = block.input || {};
|
|
141
|
+
const toolId = block.id;
|
|
142
|
+
const isLocal = toolInput.is_local === true;
|
|
143
|
+
if (toolId) {
|
|
144
|
+
toolUseMap.set(toolId, { tool: toolName, args: toolInput });
|
|
145
|
+
}
|
|
146
|
+
const event = {
|
|
147
|
+
type: 'tool_use',
|
|
148
|
+
agent: 'claude',
|
|
149
|
+
timestamp,
|
|
150
|
+
tool: toolName,
|
|
151
|
+
args: toolInput,
|
|
152
|
+
path: toolInput.file_path || undefined,
|
|
153
|
+
command: toolName === 'Bash' ? toolInput.command : undefined,
|
|
154
|
+
};
|
|
155
|
+
if (isLocal)
|
|
156
|
+
event._local = true;
|
|
157
|
+
events.push(event);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Capture token usage and model from assistant turn
|
|
161
|
+
if (raw.message?.usage) {
|
|
162
|
+
const u = raw.message.usage;
|
|
163
|
+
events.push({
|
|
164
|
+
type: 'usage',
|
|
165
|
+
agent: 'claude',
|
|
166
|
+
timestamp,
|
|
167
|
+
model: raw.message.model,
|
|
168
|
+
inputTokens: u.input_tokens,
|
|
169
|
+
outputTokens: u.output_tokens,
|
|
170
|
+
cacheReadTokens: u.cache_read_input_tokens,
|
|
171
|
+
cacheCreationTokens: u.cache_creation_input_tokens,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else if (type === 'user') {
|
|
176
|
+
const contentBlocks = raw.message?.content;
|
|
177
|
+
if (typeof contentBlocks === 'string') {
|
|
178
|
+
// Simple user text
|
|
179
|
+
const text = contentBlocks.trim();
|
|
180
|
+
if (text) {
|
|
181
|
+
events.push({
|
|
182
|
+
type: 'message',
|
|
183
|
+
agent: 'claude',
|
|
184
|
+
timestamp,
|
|
185
|
+
role: 'user',
|
|
186
|
+
content: text,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else if (Array.isArray(contentBlocks)) {
|
|
191
|
+
for (const block of contentBlocks) {
|
|
192
|
+
if (block.type === 'text') {
|
|
193
|
+
const text = (block.text || '').trim();
|
|
194
|
+
if (text && !text.startsWith('[Request interrupted')) {
|
|
195
|
+
events.push({
|
|
196
|
+
type: 'message',
|
|
197
|
+
agent: 'claude',
|
|
198
|
+
timestamp,
|
|
199
|
+
role: 'user',
|
|
200
|
+
content: text,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else if (block.type === 'image') {
|
|
205
|
+
const source = block.source || {};
|
|
206
|
+
if (source.type === 'base64') {
|
|
207
|
+
const sizeBytes = Math.ceil((source.data?.length || 0) * 0.75);
|
|
208
|
+
events.push({
|
|
209
|
+
type: 'attachment',
|
|
210
|
+
agent: 'claude',
|
|
211
|
+
timestamp,
|
|
212
|
+
mediaType: source.media_type || 'image/png',
|
|
213
|
+
sizeBytes,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else if (block.type === 'document') {
|
|
218
|
+
const source = block.source || {};
|
|
219
|
+
events.push({
|
|
220
|
+
type: 'attachment',
|
|
221
|
+
agent: 'claude',
|
|
222
|
+
timestamp,
|
|
223
|
+
mediaType: source.media_type || 'application/pdf',
|
|
224
|
+
sizeBytes: 0,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
else if (block.type === 'tool_result') {
|
|
228
|
+
const toolId = block.tool_use_id;
|
|
229
|
+
const toolInfo = toolId ? toolUseMap.get(toolId) : undefined;
|
|
230
|
+
const isError = block.is_error === true;
|
|
231
|
+
// Extract output text from tool result
|
|
232
|
+
let output = '';
|
|
233
|
+
if (typeof block.content === 'string') {
|
|
234
|
+
output = block.content;
|
|
235
|
+
}
|
|
236
|
+
else if (Array.isArray(block.content)) {
|
|
237
|
+
output = block.content
|
|
238
|
+
.filter((c) => c.type === 'text')
|
|
239
|
+
.map((c) => c.text || '')
|
|
240
|
+
.join('\n');
|
|
241
|
+
}
|
|
242
|
+
if (isError) {
|
|
243
|
+
events.push({
|
|
244
|
+
type: 'error',
|
|
245
|
+
agent: 'claude',
|
|
246
|
+
timestamp,
|
|
247
|
+
tool: toolInfo?.tool,
|
|
248
|
+
content: output || 'Tool execution failed',
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
events.push({
|
|
253
|
+
type: 'tool_result',
|
|
254
|
+
agent: 'claude',
|
|
255
|
+
timestamp,
|
|
256
|
+
tool: toolInfo?.tool,
|
|
257
|
+
success: true,
|
|
258
|
+
output: output.length > 500 ? output.slice(0, 497) + '...' : output,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
if (toolId)
|
|
262
|
+
toolUseMap.delete(toolId);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
else if (type === 'result') {
|
|
268
|
+
events.push({
|
|
269
|
+
type: 'result',
|
|
270
|
+
agent: 'claude',
|
|
271
|
+
timestamp,
|
|
272
|
+
content: raw.subtype || 'success',
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
// Skip: permission-mode, attachment, and other line types
|
|
276
|
+
}
|
|
277
|
+
return events;
|
|
278
|
+
}
|
|
279
|
+
// ---------------------------------------------------------------------------
|
|
280
|
+
// Codex parser
|
|
281
|
+
// ---------------------------------------------------------------------------
|
|
282
|
+
export function parseCodex(filePath) {
|
|
283
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
284
|
+
const lines = content.split('\n').filter(l => l.trim());
|
|
285
|
+
const events = [];
|
|
286
|
+
// Track function_call id -> name for correlating with function_call_output
|
|
287
|
+
const callMap = new Map();
|
|
288
|
+
for (const line of lines) {
|
|
289
|
+
let raw;
|
|
290
|
+
try {
|
|
291
|
+
raw = JSON.parse(line);
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
/* malformed JSONL line, skip */
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const lineType = raw.type;
|
|
298
|
+
const timestamp = raw.timestamp || new Date().toISOString();
|
|
299
|
+
const payload = raw.payload || {};
|
|
300
|
+
if (lineType === 'session_meta') {
|
|
301
|
+
events.push({
|
|
302
|
+
type: 'init',
|
|
303
|
+
agent: 'codex',
|
|
304
|
+
timestamp,
|
|
305
|
+
content: `Codex ${payload.cli_version || ''} session in ${payload.cwd || ''}`.trim(),
|
|
306
|
+
});
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (lineType === 'response_item') {
|
|
310
|
+
const ptype = payload.type;
|
|
311
|
+
if (ptype === 'message') {
|
|
312
|
+
const contentBlocks = payload.content || [];
|
|
313
|
+
const role = payload.role === 'user' || payload.role === 'developer' ? 'user' : 'assistant';
|
|
314
|
+
for (const block of contentBlocks) {
|
|
315
|
+
if (block.type === 'output_text') {
|
|
316
|
+
const text = (block.text || '').trim();
|
|
317
|
+
if (text) {
|
|
318
|
+
events.push({
|
|
319
|
+
type: 'message',
|
|
320
|
+
agent: 'codex',
|
|
321
|
+
timestamp,
|
|
322
|
+
role: 'assistant',
|
|
323
|
+
content: text,
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
else if (block.type === 'input_text') {
|
|
328
|
+
// Developer/user input messages -- only include actual prompts, not system instructions
|
|
329
|
+
const text = (block.text || '').trim();
|
|
330
|
+
if (text && text.length < 2000 && !text.includes('<permissions instructions>')) {
|
|
331
|
+
events.push({
|
|
332
|
+
type: 'message',
|
|
333
|
+
agent: 'codex',
|
|
334
|
+
timestamp,
|
|
335
|
+
role: 'user',
|
|
336
|
+
content: text,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else if (ptype === 'function_call') {
|
|
343
|
+
const name = payload.name || 'unknown';
|
|
344
|
+
let args = {};
|
|
345
|
+
try {
|
|
346
|
+
args = typeof payload.arguments === 'string'
|
|
347
|
+
? JSON.parse(payload.arguments)
|
|
348
|
+
: (payload.arguments || {});
|
|
349
|
+
}
|
|
350
|
+
catch {
|
|
351
|
+
/* arguments not valid JSON, preserve raw */
|
|
352
|
+
args = { raw: payload.arguments };
|
|
353
|
+
}
|
|
354
|
+
const callId = payload.call_id || payload.id;
|
|
355
|
+
if (callId) {
|
|
356
|
+
callMap.set(callId, { name, args });
|
|
357
|
+
}
|
|
358
|
+
events.push({
|
|
359
|
+
type: 'tool_use',
|
|
360
|
+
agent: 'codex',
|
|
361
|
+
timestamp,
|
|
362
|
+
tool: name,
|
|
363
|
+
args,
|
|
364
|
+
command: name === 'exec_command' ? (args.command || args.cmd) : undefined,
|
|
365
|
+
path: args.file_path || args.path || undefined,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
else if (ptype === 'function_call_output') {
|
|
369
|
+
const callId = payload.call_id || payload.id;
|
|
370
|
+
const callInfo = callId ? callMap.get(callId) : undefined;
|
|
371
|
+
const output = String(payload.output || '');
|
|
372
|
+
events.push({
|
|
373
|
+
type: 'tool_result',
|
|
374
|
+
agent: 'codex',
|
|
375
|
+
timestamp,
|
|
376
|
+
tool: callInfo?.name,
|
|
377
|
+
success: true,
|
|
378
|
+
output: output.length > 500 ? output.slice(0, 497) + '...' : output,
|
|
379
|
+
});
|
|
380
|
+
if (callId)
|
|
381
|
+
callMap.delete(callId);
|
|
382
|
+
}
|
|
383
|
+
else if (ptype === 'reasoning') {
|
|
384
|
+
// Codex reasoning -- try to get the readable summary
|
|
385
|
+
const summaries = payload.summary || [];
|
|
386
|
+
const text = summaries.length > 0
|
|
387
|
+
? summaries.map((s) => s.text || '').join('\n')
|
|
388
|
+
: (payload.text || '');
|
|
389
|
+
if (text.trim()) {
|
|
390
|
+
events.push({
|
|
391
|
+
type: 'thinking',
|
|
392
|
+
agent: 'codex',
|
|
393
|
+
timestamp,
|
|
394
|
+
content: text.trim(),
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
// Skip: event_msg (token_count, etc.), turn_context
|
|
400
|
+
}
|
|
401
|
+
return events;
|
|
402
|
+
}
|
|
403
|
+
// ---------------------------------------------------------------------------
|
|
404
|
+
// Gemini parser
|
|
405
|
+
// ---------------------------------------------------------------------------
|
|
406
|
+
export function parseGemini(filePath) {
|
|
407
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
408
|
+
let session;
|
|
409
|
+
try {
|
|
410
|
+
session = JSON.parse(content);
|
|
411
|
+
}
|
|
412
|
+
catch {
|
|
413
|
+
/* Gemini session file is not valid JSON */
|
|
414
|
+
throw new Error(`Failed to parse Gemini session: ${filePath}`);
|
|
415
|
+
}
|
|
416
|
+
const messages = session.messages || [];
|
|
417
|
+
const events = [];
|
|
418
|
+
events.push({
|
|
419
|
+
type: 'init',
|
|
420
|
+
agent: 'gemini',
|
|
421
|
+
timestamp: session.startTime || new Date().toISOString(),
|
|
422
|
+
content: `Gemini session ${session.sessionId || ''}`.trim(),
|
|
423
|
+
});
|
|
424
|
+
for (const msg of messages) {
|
|
425
|
+
const timestamp = msg.timestamp || session.startTime || new Date().toISOString();
|
|
426
|
+
if (msg.type === 'user') {
|
|
427
|
+
const text = extractGeminiContent(msg.content);
|
|
428
|
+
if (text) {
|
|
429
|
+
events.push({
|
|
430
|
+
type: 'message',
|
|
431
|
+
agent: 'gemini',
|
|
432
|
+
timestamp,
|
|
433
|
+
role: 'user',
|
|
434
|
+
content: text,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
else if (msg.type === 'gemini') {
|
|
439
|
+
// Reasoning thoughts
|
|
440
|
+
if (Array.isArray(msg.thoughts)) {
|
|
441
|
+
for (const thought of msg.thoughts) {
|
|
442
|
+
const text = thought.description || thought.subject || '';
|
|
443
|
+
if (text.trim()) {
|
|
444
|
+
const subject = thought.subject ? `**${thought.subject}**: ` : '';
|
|
445
|
+
events.push({
|
|
446
|
+
type: 'thinking',
|
|
447
|
+
agent: 'gemini',
|
|
448
|
+
timestamp: thought.timestamp || timestamp,
|
|
449
|
+
content: `${subject}${thought.description || ''}`.trim(),
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
// Assistant text
|
|
455
|
+
const text = extractGeminiContent(msg.content);
|
|
456
|
+
if (text) {
|
|
457
|
+
events.push({
|
|
458
|
+
type: 'message',
|
|
459
|
+
agent: 'gemini',
|
|
460
|
+
timestamp,
|
|
461
|
+
role: 'assistant',
|
|
462
|
+
content: text,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
// Tool calls (Gemini inlines call + result on the same message)
|
|
466
|
+
if (Array.isArray(msg.toolCalls)) {
|
|
467
|
+
for (const tc of msg.toolCalls) {
|
|
468
|
+
const toolName = tc.name || 'unknown';
|
|
469
|
+
const args = tc.args || {};
|
|
470
|
+
events.push({
|
|
471
|
+
type: 'tool_use',
|
|
472
|
+
agent: 'gemini',
|
|
473
|
+
timestamp: tc.timestamp || timestamp,
|
|
474
|
+
tool: toolName,
|
|
475
|
+
args,
|
|
476
|
+
command: ['run_shell_command', 'shell', 'bash'].includes(toolName) ? args.command : undefined,
|
|
477
|
+
path: args.file_path || args.path || undefined,
|
|
478
|
+
});
|
|
479
|
+
// Inline result
|
|
480
|
+
if (tc.result || tc.status) {
|
|
481
|
+
let output = '';
|
|
482
|
+
if (Array.isArray(tc.result)) {
|
|
483
|
+
for (const r of tc.result) {
|
|
484
|
+
const resp = r?.functionResponse?.response;
|
|
485
|
+
if (resp?.output) {
|
|
486
|
+
output += String(resp.output);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
else if (typeof tc.result === 'string') {
|
|
491
|
+
output = tc.result;
|
|
492
|
+
}
|
|
493
|
+
events.push({
|
|
494
|
+
type: 'tool_result',
|
|
495
|
+
agent: 'gemini',
|
|
496
|
+
timestamp: tc.timestamp || timestamp,
|
|
497
|
+
tool: toolName,
|
|
498
|
+
success: tc.status === 'success',
|
|
499
|
+
output: output.length > 500 ? output.slice(0, 497) + '...' : output,
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return events;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Extract text content from Gemini's content field,
|
|
510
|
+
* which can be a string or an array of {text: string} parts.
|
|
511
|
+
*/
|
|
512
|
+
function extractGeminiContent(content) {
|
|
513
|
+
if (typeof content === 'string')
|
|
514
|
+
return content.trim();
|
|
515
|
+
if (Array.isArray(content)) {
|
|
516
|
+
return content
|
|
517
|
+
.map((part) => {
|
|
518
|
+
if (typeof part === 'string')
|
|
519
|
+
return part;
|
|
520
|
+
if (typeof part?.text === 'string')
|
|
521
|
+
return part.text;
|
|
522
|
+
return '';
|
|
523
|
+
})
|
|
524
|
+
.join('\n')
|
|
525
|
+
.trim();
|
|
526
|
+
}
|
|
527
|
+
return '';
|
|
528
|
+
}
|
|
529
|
+
// ---------------------------------------------------------------------------
|
|
530
|
+
// OpenCode parser
|
|
531
|
+
// ---------------------------------------------------------------------------
|
|
532
|
+
/**
|
|
533
|
+
* Parse an OpenCode session from its SQLite database.
|
|
534
|
+
* filePath format: "/path/to/opencode.db#session_id"
|
|
535
|
+
*
|
|
536
|
+
* Data model: session -> message -> part
|
|
537
|
+
* Messages have role (user/assistant) and metadata.
|
|
538
|
+
* Parts contain the actual content: text, tool, reasoning, patch, step-start/finish.
|
|
539
|
+
*/
|
|
540
|
+
export function parseOpenCode(filePath) {
|
|
541
|
+
const [dbPath, sessionId] = filePath.split('#');
|
|
542
|
+
if (!dbPath || !sessionId)
|
|
543
|
+
return [];
|
|
544
|
+
const events = [];
|
|
545
|
+
try {
|
|
546
|
+
// Query messages with their parts, ordered chronologically.
|
|
547
|
+
// Each row: msg_role ||| part_type ||| part_data (truncated for tool output) ||| msg_time
|
|
548
|
+
const query = `
|
|
549
|
+
SELECT
|
|
550
|
+
json_extract(m.data, '$.role'),
|
|
551
|
+
json_extract(p.data, '$.type'),
|
|
552
|
+
CASE
|
|
553
|
+
WHEN json_extract(p.data, '$.type') = 'tool'
|
|
554
|
+
THEN substr(p.data, 1, 2000)
|
|
555
|
+
ELSE p.data
|
|
556
|
+
END,
|
|
557
|
+
m.time_created
|
|
558
|
+
FROM message m
|
|
559
|
+
JOIN part p ON p.message_id = m.id AND p.session_id = m.session_id
|
|
560
|
+
WHERE m.session_id = '${sessionId.replace(/'/g, "''")}'
|
|
561
|
+
ORDER BY m.time_created ASC, p.time_created ASC;
|
|
562
|
+
`.replace(/\n/g, ' ');
|
|
563
|
+
const out = execSync(`sqlite3 -separator '|||' "${dbPath}"`, { encoding: 'utf-8', input: query, stdio: ['pipe', 'pipe', 'ignore'], timeout: 10000 });
|
|
564
|
+
for (const line of out.split('\n')) {
|
|
565
|
+
if (!line.trim())
|
|
566
|
+
continue;
|
|
567
|
+
const sepIdx1 = line.indexOf('|||');
|
|
568
|
+
if (sepIdx1 === -1)
|
|
569
|
+
continue;
|
|
570
|
+
const sepIdx2 = line.indexOf('|||', sepIdx1 + 3);
|
|
571
|
+
if (sepIdx2 === -1)
|
|
572
|
+
continue;
|
|
573
|
+
const sepIdx3 = line.lastIndexOf('|||');
|
|
574
|
+
const role = line.slice(0, sepIdx1);
|
|
575
|
+
const partType = line.slice(sepIdx1 + 3, sepIdx2);
|
|
576
|
+
const partDataStr = line.slice(sepIdx2 + 3, sepIdx3);
|
|
577
|
+
const timeStr = line.slice(sepIdx3 + 3);
|
|
578
|
+
const timeMs = parseInt(timeStr, 10);
|
|
579
|
+
const timestamp = isNaN(timeMs) ? new Date().toISOString() : new Date(timeMs).toISOString();
|
|
580
|
+
let partData;
|
|
581
|
+
try {
|
|
582
|
+
partData = JSON.parse(partDataStr);
|
|
583
|
+
}
|
|
584
|
+
catch {
|
|
585
|
+
/* malformed part data, skip */
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
switch (partType) {
|
|
589
|
+
case 'text': {
|
|
590
|
+
const text = (partData.text || '').trim();
|
|
591
|
+
if (text) {
|
|
592
|
+
events.push({
|
|
593
|
+
type: 'message',
|
|
594
|
+
agent: 'opencode',
|
|
595
|
+
timestamp,
|
|
596
|
+
role: role === 'user' ? 'user' : 'assistant',
|
|
597
|
+
content: text,
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
case 'reasoning': {
|
|
603
|
+
const text = (partData.text || '').trim();
|
|
604
|
+
if (text) {
|
|
605
|
+
events.push({
|
|
606
|
+
type: 'thinking',
|
|
607
|
+
agent: 'opencode',
|
|
608
|
+
timestamp,
|
|
609
|
+
content: text,
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
case 'tool': {
|
|
615
|
+
const toolName = partData.tool || 'unknown';
|
|
616
|
+
const state = partData.state || {};
|
|
617
|
+
const input = state.input || {};
|
|
618
|
+
const output = state.output || '';
|
|
619
|
+
events.push({
|
|
620
|
+
type: 'tool_use',
|
|
621
|
+
agent: 'opencode',
|
|
622
|
+
timestamp,
|
|
623
|
+
tool: toolName,
|
|
624
|
+
args: input,
|
|
625
|
+
command: toolName === 'shell' ? input.command : undefined,
|
|
626
|
+
path: input.filePath || input.path || undefined,
|
|
627
|
+
});
|
|
628
|
+
if (state.status === 'completed' || state.status === 'error') {
|
|
629
|
+
const outputStr = typeof output === 'string' ? output : JSON.stringify(output);
|
|
630
|
+
events.push({
|
|
631
|
+
type: state.status === 'error' ? 'error' : 'tool_result',
|
|
632
|
+
agent: 'opencode',
|
|
633
|
+
timestamp,
|
|
634
|
+
tool: toolName,
|
|
635
|
+
success: state.status === 'completed',
|
|
636
|
+
output: outputStr.length > 500 ? outputStr.slice(0, 497) + '...' : outputStr,
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
// Skip step-start, step-finish, patch, file — not needed for transcript/trace
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
catch {
|
|
646
|
+
/* DB not accessible or query failed */
|
|
647
|
+
}
|
|
648
|
+
return events;
|
|
649
|
+
}
|
|
650
|
+
//# sourceMappingURL=parse.js.map
|