@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
package/dist/lib/models.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model catalog extraction, caching, and resolution for all supported agents.
|
|
3
|
+
*
|
|
4
|
+
* Each agent ships its model list differently -- Claude and Codex embed it in
|
|
5
|
+
* compiled bundles/binaries, Gemini exports it from a JS module, and OpenCode/
|
|
6
|
+
* Cursor/OpenClaw expose it via CLI commands. This module provides a unified
|
|
7
|
+
* `getModelCatalog()` and `resolveModel()` interface over all of them, backed
|
|
8
|
+
* by a file-system cache keyed on source mtime.
|
|
9
|
+
*/
|
|
1
10
|
import * as fs from 'fs';
|
|
2
11
|
import * as path from 'path';
|
|
3
|
-
import * as os from 'os';
|
|
4
12
|
import { execFileSync } from 'child_process';
|
|
5
13
|
import { getVersionDir } from './versions.js';
|
|
6
|
-
|
|
14
|
+
import { getAgentsDir } from './state.js';
|
|
15
|
+
const CACHE_PATH = path.join(getAgentsDir(), '.models-cache.json');
|
|
7
16
|
/**
|
|
8
17
|
* Bump when the extractor logic changes shape in an incompatible way so cached
|
|
9
18
|
* catalogs from older agents-cli builds are re-extracted.
|
|
@@ -13,6 +22,7 @@ let memoryCache = null;
|
|
|
13
22
|
function cacheKey(agent, version) {
|
|
14
23
|
return `${agent}@${version}`;
|
|
15
24
|
}
|
|
25
|
+
/** Load the cache file from disk (or return the in-memory copy). */
|
|
16
26
|
function loadCache() {
|
|
17
27
|
if (memoryCache)
|
|
18
28
|
return memoryCache;
|
|
@@ -22,7 +32,7 @@ function loadCache() {
|
|
|
22
32
|
memoryCache = raw;
|
|
23
33
|
}
|
|
24
34
|
else {
|
|
25
|
-
// Legacy (pre-schema) or stale-schema cache
|
|
35
|
+
// Legacy (pre-schema) or stale-schema cache -- drop it.
|
|
26
36
|
memoryCache = { schema: CACHE_SCHEMA_VERSION, entries: {} };
|
|
27
37
|
}
|
|
28
38
|
}
|
|
@@ -31,6 +41,7 @@ function loadCache() {
|
|
|
31
41
|
}
|
|
32
42
|
return memoryCache;
|
|
33
43
|
}
|
|
44
|
+
/** Persist the in-memory cache to disk. Best-effort; failures are silent. */
|
|
34
45
|
function saveCache() {
|
|
35
46
|
if (!memoryCache)
|
|
36
47
|
return;
|
|
@@ -48,9 +59,9 @@ function saveCache() {
|
|
|
48
59
|
* Locate the file that authoritatively describes the installed model catalog
|
|
49
60
|
* for a given (agent, version). The `kind` tells `getModelCatalog` how to
|
|
50
61
|
* read it:
|
|
51
|
-
* bundle/binary
|
|
52
|
-
* js
|
|
53
|
-
* cli
|
|
62
|
+
* bundle/binary -- strings(1)-style extraction (claude/codex)
|
|
63
|
+
* js -- read + regex-parse an exported JS module (gemini)
|
|
64
|
+
* cli -- spawn the agent's own `models` command (opencode/cursor/openclaw)
|
|
54
65
|
*
|
|
55
66
|
* Returns null if nothing usable is found.
|
|
56
67
|
*/
|
|
@@ -83,7 +94,7 @@ export function locateModelSource(agent, version) {
|
|
|
83
94
|
return null;
|
|
84
95
|
}
|
|
85
96
|
if (agent === 'gemini') {
|
|
86
|
-
// Gemini ships a clean ES module with all constants and aliases
|
|
97
|
+
// Gemini ships a clean ES module with all constants and aliases -- no need
|
|
87
98
|
// to parse the minified CLI bundle.
|
|
88
99
|
const modelsJs = path.join(versionDir, 'node_modules', '@google', 'gemini-cli-core', 'dist', 'src', 'config', 'models.js');
|
|
89
100
|
if (fs.existsSync(modelsJs))
|
|
@@ -111,7 +122,7 @@ export function locateModelSource(agent, version) {
|
|
|
111
122
|
}
|
|
112
123
|
if (agent === 'cursor') {
|
|
113
124
|
// cursor-agent is installed via curl script, not agents-cli. Version argument
|
|
114
|
-
// is accepted for API symmetry but ignored
|
|
125
|
+
// is accepted for API symmetry but ignored -- cursor lives on PATH.
|
|
115
126
|
const pathBin = findOnPath('cursor-agent');
|
|
116
127
|
if (pathBin)
|
|
117
128
|
return { path: pathBin, kind: 'cli' };
|
|
@@ -119,6 +130,7 @@ export function locateModelSource(agent, version) {
|
|
|
119
130
|
}
|
|
120
131
|
return null;
|
|
121
132
|
}
|
|
133
|
+
/** Search PATH for a command and return its absolute path, or null. */
|
|
122
134
|
function findOnPath(command) {
|
|
123
135
|
const pathEnv = process.env.PATH || '';
|
|
124
136
|
const exts = process.platform === 'win32' ? (process.env.PATHEXT || '').split(';') : [''];
|
|
@@ -138,6 +150,7 @@ function findOnPath(command) {
|
|
|
138
150
|
}
|
|
139
151
|
return null;
|
|
140
152
|
}
|
|
153
|
+
/** Map the current Node.js platform/arch pair to a Rust-style target triple. */
|
|
141
154
|
function currentTargetTriple() {
|
|
142
155
|
switch (`${process.platform}-${process.arch}`) {
|
|
143
156
|
case 'darwin-arm64': return 'aarch64-apple-darwin';
|
|
@@ -300,7 +313,7 @@ function extractGeminiCatalog(text) {
|
|
|
300
313
|
validIds.add(id);
|
|
301
314
|
}
|
|
302
315
|
}
|
|
303
|
-
// Fall back to any gemini-shaped id we saw in the constants map
|
|
316
|
+
// Fall back to any gemini-shaped id we saw in the constants map -- useful
|
|
304
317
|
// when the Set shape changes across gemini versions.
|
|
305
318
|
if (validIds.size === 0) {
|
|
306
319
|
for (const [name, value] of constants) {
|
|
@@ -336,7 +349,7 @@ function extractGeminiCatalog(text) {
|
|
|
336
349
|
defaults.add(previewPro); // auto/pro alias resolves here
|
|
337
350
|
const displayNameFor = (id) => {
|
|
338
351
|
// Gemini has a `getDisplayString` for some aliases but the canonical id
|
|
339
|
-
// is human-readable enough ("gemini-3-pro-preview")
|
|
352
|
+
// is human-readable enough ("gemini-3-pro-preview") -- no separate map.
|
|
340
353
|
return undefined;
|
|
341
354
|
};
|
|
342
355
|
const models = Array.from(validIds)
|
|
@@ -351,7 +364,7 @@ function extractGeminiCatalog(text) {
|
|
|
351
364
|
}
|
|
352
365
|
/**
|
|
353
366
|
* Extract OpenCode's catalog by invoking `opencode models --verbose`. The
|
|
354
|
-
* output is a sequence of `<provider>/<id>\n{json}` blocks
|
|
367
|
+
* output is a sequence of `<provider>/<id>\n{json}` blocks -- we parse every
|
|
355
368
|
* JSON block that follows a provider/id line.
|
|
356
369
|
*
|
|
357
370
|
* OpenCode caches the models.dev snapshot internally, so this is a local,
|
|
@@ -418,7 +431,7 @@ function extractOpenCodeCatalog(binaryPath) {
|
|
|
418
431
|
if (seen.has(fullKey))
|
|
419
432
|
continue;
|
|
420
433
|
seen.add(fullKey);
|
|
421
|
-
// obj.status can be "active" | "deprecated" | "preview"
|
|
434
|
+
// obj.status can be "active" | "deprecated" | "preview" -- surface only
|
|
422
435
|
// when it isn't the default so the consumer can flag stale models.
|
|
423
436
|
const nonDefaultStatus = obj.status && obj.status !== 'active' ? obj.status : undefined;
|
|
424
437
|
models.push({
|
|
@@ -601,8 +614,14 @@ export function getModelCatalog(agent, version) {
|
|
|
601
614
|
models,
|
|
602
615
|
aliases,
|
|
603
616
|
};
|
|
604
|
-
cache
|
|
605
|
-
|
|
617
|
+
// Don't cache empty CLI extractions: the CLI may have been mid-install,
|
|
618
|
+
// network-dependent, or transiently failing. Caching 0 models would mask
|
|
619
|
+
// the real catalog forever (mtime won't change). Bundle/binary/js sources
|
|
620
|
+
// are deterministic, so cache those even when empty.
|
|
621
|
+
if (src.kind !== 'cli' || models.length > 0) {
|
|
622
|
+
cache.entries[key] = { sourcePath: src.path, mtime, catalog };
|
|
623
|
+
saveCache();
|
|
624
|
+
}
|
|
606
625
|
return catalog;
|
|
607
626
|
}
|
|
608
627
|
/**
|
|
@@ -642,6 +661,7 @@ export function resolveModel(agent, version, requested) {
|
|
|
642
661
|
warning: `model "${requested}" not in known catalog for ${agent}@${version}; forwarding as-is${hint}`,
|
|
643
662
|
};
|
|
644
663
|
}
|
|
664
|
+
/** Find the closest matching model ids/aliases using edit distance. */
|
|
645
665
|
function pickSuggestions(requested, catalog) {
|
|
646
666
|
const all = [...catalog.models.map((m) => m.id), ...Object.keys(catalog.aliases)];
|
|
647
667
|
return all
|
|
@@ -651,6 +671,7 @@ function pickSuggestions(requested, catalog) {
|
|
|
651
671
|
.slice(0, 3)
|
|
652
672
|
.map((s) => s.id);
|
|
653
673
|
}
|
|
674
|
+
/** Normalized Levenshtein similarity (0..1, where 1 is identical). */
|
|
654
675
|
function similarity(a, b) {
|
|
655
676
|
const longer = a.length >= b.length ? a : b;
|
|
656
677
|
const shorter = a.length >= b.length ? b : a;
|
|
@@ -659,6 +680,7 @@ function similarity(a, b) {
|
|
|
659
680
|
const distance = levenshtein(longer, shorter);
|
|
660
681
|
return (longer.length - distance) / longer.length;
|
|
661
682
|
}
|
|
683
|
+
/** Standard Levenshtein edit distance between two strings. */
|
|
662
684
|
function levenshtein(a, b) {
|
|
663
685
|
const m = a.length;
|
|
664
686
|
const n = b.length;
|
|
@@ -703,4 +725,3 @@ export function buildReasoningFlags(agent, level) {
|
|
|
703
725
|
}
|
|
704
726
|
return [];
|
|
705
727
|
}
|
|
706
|
-
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1Password CLI (op) integration for importing secrets from vaults.
|
|
3
|
+
*/
|
|
4
|
+
export interface OpVault {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export interface OpItemSummary {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
category: string;
|
|
12
|
+
vault: {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface OpField {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
type: string;
|
|
21
|
+
value?: string;
|
|
22
|
+
purpose?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface OpItem extends OpItemSummary {
|
|
25
|
+
fields: OpField[];
|
|
26
|
+
}
|
|
27
|
+
export interface ImportableSecret {
|
|
28
|
+
envKey: string;
|
|
29
|
+
itemTitle: string;
|
|
30
|
+
fieldLabel: string;
|
|
31
|
+
value: string;
|
|
32
|
+
}
|
|
33
|
+
export interface SkippedField {
|
|
34
|
+
itemTitle: string;
|
|
35
|
+
fieldLabel: string;
|
|
36
|
+
reason: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function assertOpAvailable(): void;
|
|
39
|
+
export declare function listVaults(): OpVault[];
|
|
40
|
+
export declare function listItems(vaultName: string): OpItemSummary[];
|
|
41
|
+
export declare function getItem(itemId: string, vaultName: string): OpItem;
|
|
42
|
+
export declare function toEnvKey(title: string): string;
|
|
43
|
+
export declare function slugify(name: string): string;
|
|
44
|
+
export declare function extractSecrets(items: OpItemSummary[], vaultName: string): {
|
|
45
|
+
secrets: ImportableSecret[];
|
|
46
|
+
skipped: SkippedField[];
|
|
47
|
+
};
|
|
48
|
+
export interface PasswordItemTemplate {
|
|
49
|
+
title: string;
|
|
50
|
+
category: 'PASSWORD';
|
|
51
|
+
tags: string[];
|
|
52
|
+
fields: Array<{
|
|
53
|
+
id: string;
|
|
54
|
+
type: 'CONCEALED';
|
|
55
|
+
purpose: 'PASSWORD';
|
|
56
|
+
label: string;
|
|
57
|
+
value: string;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
export declare function buildPasswordItemTemplate(title: string, value: string): PasswordItemTemplate;
|
|
61
|
+
export declare function itemExistsByTitle(title: string, vaultName: string): boolean;
|
|
62
|
+
export declare function deleteItemByTitle(title: string, vaultName: string): void;
|
|
63
|
+
export declare function createPasswordItem(title: string, value: string, vaultName: string): void;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1Password CLI (op) integration for importing secrets from vaults.
|
|
3
|
+
*/
|
|
4
|
+
import { spawnSync } from 'child_process';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as os from 'os';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
function runOp(args, input) {
|
|
9
|
+
const result = spawnSync('op', args, {
|
|
10
|
+
stdio: [input !== undefined ? 'pipe' : 'ignore', 'pipe', 'pipe'],
|
|
11
|
+
encoding: 'utf-8',
|
|
12
|
+
maxBuffer: 10 * 1024 * 1024,
|
|
13
|
+
input,
|
|
14
|
+
});
|
|
15
|
+
if (result.error) {
|
|
16
|
+
if (result.error.code === 'ENOENT') {
|
|
17
|
+
return { ok: false, error: '1Password CLI not found. Install: brew install 1password-cli' };
|
|
18
|
+
}
|
|
19
|
+
return { ok: false, error: result.error.message };
|
|
20
|
+
}
|
|
21
|
+
if (result.status !== 0) {
|
|
22
|
+
const stderr = result.stderr?.trim() || '';
|
|
23
|
+
if (stderr.includes('not signed in') || stderr.includes('sign in') || stderr.includes('no active session')) {
|
|
24
|
+
return { ok: false, error: 'Not signed in to 1Password. Run: op signin' };
|
|
25
|
+
}
|
|
26
|
+
return { ok: false, error: stderr || `op exited with code ${result.status}` };
|
|
27
|
+
}
|
|
28
|
+
return { ok: true, stdout: result.stdout };
|
|
29
|
+
}
|
|
30
|
+
export function assertOpAvailable() {
|
|
31
|
+
// `op account list` works with both CLI session tokens and the 1Password
|
|
32
|
+
// desktop biometric integration; `op whoami` fails on the latter.
|
|
33
|
+
const result = runOp(['account', 'list', '--format=json']);
|
|
34
|
+
if (!result.ok) {
|
|
35
|
+
throw new Error(result.error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function listVaults() {
|
|
39
|
+
const result = runOp(['vault', 'list', '--format=json']);
|
|
40
|
+
if (!result.ok)
|
|
41
|
+
throw new Error(result.error);
|
|
42
|
+
return JSON.parse(result.stdout);
|
|
43
|
+
}
|
|
44
|
+
export function listItems(vaultName) {
|
|
45
|
+
const result = runOp(['item', 'list', '--vault', vaultName, '--format=json']);
|
|
46
|
+
if (!result.ok) {
|
|
47
|
+
if (result.error.includes('vault') && result.error.includes('not found')) {
|
|
48
|
+
const vaults = listVaults();
|
|
49
|
+
const available = vaults.map((v) => v.name).join(', ');
|
|
50
|
+
throw new Error(`Vault '${vaultName}' not found. Available: ${available || '(none)'}`);
|
|
51
|
+
}
|
|
52
|
+
throw new Error(result.error);
|
|
53
|
+
}
|
|
54
|
+
const items = JSON.parse(result.stdout);
|
|
55
|
+
return items || [];
|
|
56
|
+
}
|
|
57
|
+
export function getItem(itemId, vaultName) {
|
|
58
|
+
const result = runOp(['item', 'get', itemId, '--vault', vaultName, '--format=json', '--reveal']);
|
|
59
|
+
if (!result.ok)
|
|
60
|
+
throw new Error(result.error);
|
|
61
|
+
return JSON.parse(result.stdout);
|
|
62
|
+
}
|
|
63
|
+
export function toEnvKey(title) {
|
|
64
|
+
return title
|
|
65
|
+
.toUpperCase()
|
|
66
|
+
.replace(/[^A-Z0-9]+/g, '_')
|
|
67
|
+
.replace(/^_+|_+$/g, '')
|
|
68
|
+
.replace(/^(\d)/, '_$1');
|
|
69
|
+
}
|
|
70
|
+
export function slugify(name) {
|
|
71
|
+
return name
|
|
72
|
+
.toLowerCase()
|
|
73
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
74
|
+
.replace(/^-+|-+$/g, '');
|
|
75
|
+
}
|
|
76
|
+
const IMPORTABLE_FIELD_TYPES = new Set([
|
|
77
|
+
'CONCEALED', 'concealed',
|
|
78
|
+
'STRING', 'string', 'text', 'TEXT',
|
|
79
|
+
'URL', 'url',
|
|
80
|
+
]);
|
|
81
|
+
const SKIP_FIELD_LABELS = new Set(['username', 'notesPlain', 'notes']);
|
|
82
|
+
function pickBestField(fields) {
|
|
83
|
+
const dominated = fields.filter((f) => IMPORTABLE_FIELD_TYPES.has(f.type) &&
|
|
84
|
+
f.value &&
|
|
85
|
+
!SKIP_FIELD_LABELS.has(f.label?.toLowerCase() || ''));
|
|
86
|
+
if (dominated.length === 0)
|
|
87
|
+
return null;
|
|
88
|
+
// Prefer concealed fields (credentials/passwords)
|
|
89
|
+
const concealed = dominated.find((f) => f.type.toLowerCase() === 'concealed');
|
|
90
|
+
if (concealed)
|
|
91
|
+
return concealed;
|
|
92
|
+
// Then prefer fields labeled credential/password/secret/key/token
|
|
93
|
+
const secretLabels = ['credential', 'password', 'secret', 'key', 'token', 'api_key', 'apikey'];
|
|
94
|
+
const labeled = dominated.find((f) => secretLabels.includes(f.label?.toLowerCase() || ''));
|
|
95
|
+
if (labeled)
|
|
96
|
+
return labeled;
|
|
97
|
+
// Fall back to first importable field
|
|
98
|
+
return dominated[0];
|
|
99
|
+
}
|
|
100
|
+
export function extractSecrets(items, vaultName) {
|
|
101
|
+
const secrets = [];
|
|
102
|
+
const skipped = [];
|
|
103
|
+
for (const summary of items) {
|
|
104
|
+
let item;
|
|
105
|
+
try {
|
|
106
|
+
item = getItem(summary.id, vaultName);
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
skipped.push({
|
|
110
|
+
itemTitle: summary.title,
|
|
111
|
+
fieldLabel: '*',
|
|
112
|
+
reason: err.message,
|
|
113
|
+
});
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const field = pickBestField(item.fields || []);
|
|
117
|
+
if (!field) {
|
|
118
|
+
skipped.push({
|
|
119
|
+
itemTitle: item.title,
|
|
120
|
+
fieldLabel: '*',
|
|
121
|
+
reason: 'no importable fields',
|
|
122
|
+
});
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (field.value.includes('\n')) {
|
|
126
|
+
skipped.push({
|
|
127
|
+
itemTitle: item.title,
|
|
128
|
+
fieldLabel: field.label,
|
|
129
|
+
reason: 'contains newlines (keychain limitation)',
|
|
130
|
+
});
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const envKey = toEnvKey(item.title);
|
|
134
|
+
secrets.push({
|
|
135
|
+
envKey,
|
|
136
|
+
itemTitle: item.title,
|
|
137
|
+
fieldLabel: field.label,
|
|
138
|
+
value: field.value,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return { secrets, skipped };
|
|
142
|
+
}
|
|
143
|
+
export function buildPasswordItemTemplate(title, value) {
|
|
144
|
+
return {
|
|
145
|
+
title,
|
|
146
|
+
category: 'PASSWORD',
|
|
147
|
+
tags: ['agents-cli'],
|
|
148
|
+
fields: [
|
|
149
|
+
{ id: 'password', type: 'CONCEALED', purpose: 'PASSWORD', label: 'password', value },
|
|
150
|
+
],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export function itemExistsByTitle(title, vaultName) {
|
|
154
|
+
const result = runOp(['item', 'get', title, '--vault', vaultName, '--format=json']);
|
|
155
|
+
if (result.ok)
|
|
156
|
+
return true;
|
|
157
|
+
if (/isn't an item|not found|no item found/i.test(result.error))
|
|
158
|
+
return false;
|
|
159
|
+
throw new Error(result.error);
|
|
160
|
+
}
|
|
161
|
+
export function deleteItemByTitle(title, vaultName) {
|
|
162
|
+
const result = runOp(['item', 'delete', title, '--vault', vaultName]);
|
|
163
|
+
if (!result.ok)
|
|
164
|
+
throw new Error(result.error);
|
|
165
|
+
}
|
|
166
|
+
export function createPasswordItem(title, value, vaultName) {
|
|
167
|
+
// op item create reads stdin templates only from a real pipe; spawnSync's
|
|
168
|
+
// input plumbing is detected as empty and op silently ignores the template.
|
|
169
|
+
// The supported alternative is --template <file>, which works reliably.
|
|
170
|
+
const template = JSON.stringify(buildPasswordItemTemplate(title, value));
|
|
171
|
+
const tmpFile = path.join(os.tmpdir(), `agents-op-tpl-${process.pid}-${Date.now()}.json`);
|
|
172
|
+
fs.writeFileSync(tmpFile, template, { mode: 0o600 });
|
|
173
|
+
try {
|
|
174
|
+
const result = runOp(['item', 'create', '--template', tmpFile, '--vault', vaultName]);
|
|
175
|
+
if (!result.ok)
|
|
176
|
+
throw new Error(result.error);
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
try {
|
|
180
|
+
fs.unlinkSync(tmpFile);
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
// best-effort cleanup
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve base + name while preventing path-traversal attacks.
|
|
3
|
+
* Rejects path separators, null bytes, '.' and '..', and any resolved path
|
|
4
|
+
* that escapes the base directory. Dot-prefixed names like '.env.example'
|
|
5
|
+
* are allowed — actual traversal is caught by the containment check below.
|
|
6
|
+
* Allows spaces, unicode, and other common filename characters.
|
|
7
|
+
*/
|
|
8
|
+
export declare function safeJoin(base: string, name: string): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve base + name while preventing path-traversal attacks.
|
|
4
|
+
* Rejects path separators, null bytes, '.' and '..', and any resolved path
|
|
5
|
+
* that escapes the base directory. Dot-prefixed names like '.env.example'
|
|
6
|
+
* are allowed — actual traversal is caught by the containment check below.
|
|
7
|
+
* Allows spaces, unicode, and other common filename characters.
|
|
8
|
+
*/
|
|
9
|
+
export function safeJoin(base, name) {
|
|
10
|
+
if (!name ||
|
|
11
|
+
name === '.' || name === '..' ||
|
|
12
|
+
/[\/\\\x00]/.test(name) ||
|
|
13
|
+
name.length > 255) {
|
|
14
|
+
throw new Error(`Invalid name: ${name}`);
|
|
15
|
+
}
|
|
16
|
+
const resolved = path.resolve(base, name);
|
|
17
|
+
if (!resolved.startsWith(path.resolve(base) + path.sep))
|
|
18
|
+
throw new Error(`Path escape: ${name}`);
|
|
19
|
+
return resolved;
|
|
20
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { AgentId, PermissionSet, InstalledPermission, ClaudePermissions, OpenCodePermissions, CodexPermissions } from './types.js';
|
|
2
|
+
/** Agents that support the permissions subsystem. */
|
|
2
3
|
export declare const PERMISSIONS_CAPABLE_AGENTS: AgentId[];
|
|
4
|
+
/** Filename used for Codex Starlark deny-rules generated from permission groups. */
|
|
3
5
|
export declare const CODEX_RULES_FILENAME = "agents-deny.rules";
|
|
4
6
|
/**
|
|
5
7
|
* Convert canonical deny rules to Codex Starlark .rules format.
|
|
6
|
-
* E.g. "Bash(git reset:*)"
|
|
8
|
+
* E.g. "Bash(git reset:*)" -> prefix_rule(pattern=["git", "reset"], decision="forbidden")
|
|
7
9
|
*/
|
|
8
10
|
export declare function convertDenyToCodexRules(deny: string[]): string | null;
|
|
9
11
|
/**
|
|
@@ -39,6 +41,27 @@ export declare function discoverPermissionGroups(): PermissionGroupInfo[];
|
|
|
39
41
|
* Get total rule count across all permission groups.
|
|
40
42
|
*/
|
|
41
43
|
export declare function getTotalPermissionRuleCount(): number;
|
|
44
|
+
/**
|
|
45
|
+
* A permission set recipe — names a set and lists which groups it composes.
|
|
46
|
+
* Lives at ~/.agents/permissions/sets/<name>.yaml.
|
|
47
|
+
*/
|
|
48
|
+
export interface PermissionSetRecipe {
|
|
49
|
+
name: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
includes: string[];
|
|
52
|
+
}
|
|
53
|
+
/** Env var that selects which set recipe to apply at sync time. */
|
|
54
|
+
export declare const PERMISSION_SET_ENV_VAR = "AGENTS_PERMISSION_SET";
|
|
55
|
+
/**
|
|
56
|
+
* Read a permission set recipe by name from ~/.agents/permissions/sets/.
|
|
57
|
+
* Returns null if the recipe file is missing or malformed.
|
|
58
|
+
*/
|
|
59
|
+
export declare function readPermissionSetRecipe(name: string): PermissionSetRecipe | null;
|
|
60
|
+
/**
|
|
61
|
+
* Return the active permission set name from AGENTS_PERMISSION_SET env var,
|
|
62
|
+
* or null if unset. Caller decides the default behavior when null.
|
|
63
|
+
*/
|
|
64
|
+
export declare function getActivePermissionSetName(): string | null;
|
|
42
65
|
/**
|
|
43
66
|
* Build a PermissionSet from selected groups.
|
|
44
67
|
* Concatenates allow/deny rules from each group.
|
|
@@ -201,4 +224,3 @@ export declare function saveDefaultPermissionSet(set: PermissionSet): {
|
|
|
201
224
|
success: boolean;
|
|
202
225
|
error?: string;
|
|
203
226
|
};
|
|
204
|
-
//# sourceMappingURL=permissions.d.ts.map
|