@stigmer/cli 3.0.8
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/LICENSE +190 -0
- package/README.md +42 -0
- package/auth/auth0.d.ts +19 -0
- package/auth/auth0.d.ts.map +1 -0
- package/auth/auth0.js +39 -0
- package/auth/auth0.js.map +1 -0
- package/auth/callback-server.d.ts +18 -0
- package/auth/callback-server.d.ts.map +1 -0
- package/auth/callback-server.js +77 -0
- package/auth/callback-server.js.map +1 -0
- package/auth/index.d.ts +5 -0
- package/auth/index.d.ts.map +1 -0
- package/auth/index.js +6 -0
- package/auth/index.js.map +1 -0
- package/auth/login.d.ts +2 -0
- package/auth/login.d.ts.map +1 -0
- package/auth/login.js +56 -0
- package/auth/login.js.map +1 -0
- package/auth/pages.d.ts +7 -0
- package/auth/pages.d.ts.map +1 -0
- package/auth/pages.js +21 -0
- package/auth/pages.js.map +1 -0
- package/auth/pkce.d.ts +7 -0
- package/auth/pkce.d.ts.map +1 -0
- package/auth/pkce.js +22 -0
- package/auth/pkce.js.map +1 -0
- package/auth/token.d.ts +33 -0
- package/auth/token.d.ts.map +1 -0
- package/auth/token.js +111 -0
- package/auth/token.js.map +1 -0
- package/backend.d.ts +5 -0
- package/backend.d.ts.map +1 -0
- package/backend.js +14 -0
- package/backend.js.map +1 -0
- package/cli/stigmer.d.ts +3 -0
- package/cli/stigmer.d.ts.map +1 -0
- package/cli/stigmer.js +14 -0
- package/cli/stigmer.js.map +1 -0
- package/client/client.d.ts +25 -0
- package/client/client.d.ts.map +1 -0
- package/client/client.js +55 -0
- package/client/client.js.map +1 -0
- package/client/index.d.ts +2 -0
- package/client/index.d.ts.map +1 -0
- package/client/index.js +3 -0
- package/client/index.js.map +1 -0
- package/commands/agent-exec-flags.d.ts +30 -0
- package/commands/agent-exec-flags.d.ts.map +1 -0
- package/commands/agent-exec-flags.js +52 -0
- package/commands/agent-exec-flags.js.map +1 -0
- package/commands/apikey/duration.d.ts +2 -0
- package/commands/apikey/duration.d.ts.map +1 -0
- package/commands/apikey/duration.js +30 -0
- package/commands/apikey/duration.js.map +1 -0
- package/commands/apikey/index.d.ts +3 -0
- package/commands/apikey/index.d.ts.map +1 -0
- package/commands/apikey/index.js +118 -0
- package/commands/apikey/index.js.map +1 -0
- package/commands/apply.d.ts +3 -0
- package/commands/apply.d.ts.map +1 -0
- package/commands/apply.js +155 -0
- package/commands/apply.js.map +1 -0
- package/commands/auth/index.d.ts +3 -0
- package/commands/auth/index.d.ts.map +1 -0
- package/commands/auth/index.js +76 -0
- package/commands/auth/index.js.map +1 -0
- package/commands/completion.d.ts +3 -0
- package/commands/completion.d.ts.map +1 -0
- package/commands/completion.js +82 -0
- package/commands/completion.js.map +1 -0
- package/commands/config/backend.d.ts +3 -0
- package/commands/config/backend.d.ts.map +1 -0
- package/commands/config/backend.js +49 -0
- package/commands/config/backend.js.map +1 -0
- package/commands/config/context.d.ts +3 -0
- package/commands/config/context.d.ts.map +1 -0
- package/commands/config/context.js +23 -0
- package/commands/config/context.js.map +1 -0
- package/commands/config/index.d.ts +3 -0
- package/commands/config/index.d.ts.map +1 -0
- package/commands/config/index.js +13 -0
- package/commands/config/index.js.map +1 -0
- package/commands/config/kv.d.ts +3 -0
- package/commands/config/kv.d.ts.map +1 -0
- package/commands/config/kv.js +39 -0
- package/commands/config/kv.js.map +1 -0
- package/commands/connect.d.ts +3 -0
- package/commands/connect.d.ts.map +1 -0
- package/commands/connect.js +56 -0
- package/commands/connect.js.map +1 -0
- package/commands/delete.d.ts +3 -0
- package/commands/delete.d.ts.map +1 -0
- package/commands/delete.js +41 -0
- package/commands/delete.js.map +1 -0
- package/commands/diff.d.ts +3 -0
- package/commands/diff.d.ts.map +1 -0
- package/commands/diff.js +87 -0
- package/commands/diff.js.map +1 -0
- package/commands/down.d.ts +3 -0
- package/commands/down.d.ts.map +1 -0
- package/commands/down.js +23 -0
- package/commands/down.js.map +1 -0
- package/commands/download.d.ts +3 -0
- package/commands/download.d.ts.map +1 -0
- package/commands/download.js +46 -0
- package/commands/download.js.map +1 -0
- package/commands/draft.d.ts +3 -0
- package/commands/draft.d.ts.map +1 -0
- package/commands/draft.js +97 -0
- package/commands/draft.js.map +1 -0
- package/commands/execution/approve.d.ts +3 -0
- package/commands/execution/approve.d.ts.map +1 -0
- package/commands/execution/approve.js +60 -0
- package/commands/execution/approve.js.map +1 -0
- package/commands/execution/control.d.ts +3 -0
- package/commands/execution/control.d.ts.map +1 -0
- package/commands/execution/control.js +57 -0
- package/commands/execution/control.js.map +1 -0
- package/commands/execution/index.d.ts +3 -0
- package/commands/execution/index.d.ts.map +1 -0
- package/commands/execution/index.js +21 -0
- package/commands/execution/index.js.map +1 -0
- package/commands/execution/logs.d.ts +3 -0
- package/commands/execution/logs.d.ts.map +1 -0
- package/commands/execution/logs.js +34 -0
- package/commands/execution/logs.js.map +1 -0
- package/commands/execution/trace.d.ts +3 -0
- package/commands/execution/trace.d.ts.map +1 -0
- package/commands/execution/trace.js +24 -0
- package/commands/execution/trace.js.map +1 -0
- package/commands/get.d.ts +3 -0
- package/commands/get.d.ts.map +1 -0
- package/commands/get.js +81 -0
- package/commands/get.js.map +1 -0
- package/commands/internal-daemon.d.ts +3 -0
- package/commands/internal-daemon.d.ts.map +1 -0
- package/commands/internal-daemon.js +22 -0
- package/commands/internal-daemon.js.map +1 -0
- package/commands/list.d.ts +3 -0
- package/commands/list.d.ts.map +1 -0
- package/commands/list.js +117 -0
- package/commands/list.js.map +1 -0
- package/commands/logs.d.ts +3 -0
- package/commands/logs.d.ts.map +1 -0
- package/commands/logs.js +59 -0
- package/commands/logs.js.map +1 -0
- package/commands/mcp-server.d.ts +22 -0
- package/commands/mcp-server.d.ts.map +1 -0
- package/commands/mcp-server.js +104 -0
- package/commands/mcp-server.js.map +1 -0
- package/commands/push.d.ts +3 -0
- package/commands/push.d.ts.map +1 -0
- package/commands/push.js +150 -0
- package/commands/push.js.map +1 -0
- package/commands/reset.d.ts +3 -0
- package/commands/reset.d.ts.map +1 -0
- package/commands/reset.js +45 -0
- package/commands/reset.js.map +1 -0
- package/commands/resume.d.ts +3 -0
- package/commands/resume.d.ts.map +1 -0
- package/commands/resume.js +87 -0
- package/commands/resume.js.map +1 -0
- package/commands/run.d.ts +3 -0
- package/commands/run.d.ts.map +1 -0
- package/commands/run.js +193 -0
- package/commands/run.js.map +1 -0
- package/commands/search.d.ts +3 -0
- package/commands/search.d.ts.map +1 -0
- package/commands/search.js +73 -0
- package/commands/search.js.map +1 -0
- package/commands/seedpack.d.ts +3 -0
- package/commands/seedpack.d.ts.map +1 -0
- package/commands/seedpack.js +76 -0
- package/commands/seedpack.js.map +1 -0
- package/commands/setup.d.ts +3 -0
- package/commands/setup.d.ts.map +1 -0
- package/commands/setup.js +57 -0
- package/commands/setup.js.map +1 -0
- package/commands/shared.d.ts +15 -0
- package/commands/shared.d.ts.map +1 -0
- package/commands/shared.js +34 -0
- package/commands/shared.js.map +1 -0
- package/commands/status.d.ts +3 -0
- package/commands/status.d.ts.map +1 -0
- package/commands/status.js +18 -0
- package/commands/status.js.map +1 -0
- package/commands/tag.d.ts +3 -0
- package/commands/tag.d.ts.map +1 -0
- package/commands/tag.js +24 -0
- package/commands/tag.js.map +1 -0
- package/commands/up.d.ts +3 -0
- package/commands/up.d.ts.map +1 -0
- package/commands/up.js +39 -0
- package/commands/up.js.map +1 -0
- package/commands/usage.d.ts +3 -0
- package/commands/usage.d.ts.map +1 -0
- package/commands/usage.js +56 -0
- package/commands/usage.js.map +1 -0
- package/commands/validate.d.ts +3 -0
- package/commands/validate.d.ts.map +1 -0
- package/commands/validate.js +64 -0
- package/commands/validate.js.map +1 -0
- package/commands/version.d.ts +3 -0
- package/commands/version.d.ts.map +1 -0
- package/commands/version.js +11 -0
- package/commands/version.js.map +1 -0
- package/config/config.d.ts +39 -0
- package/config/config.d.ts.map +1 -0
- package/config/config.js +85 -0
- package/config/config.js.map +1 -0
- package/config/index.d.ts +5 -0
- package/config/index.d.ts.map +1 -0
- package/config/index.js +6 -0
- package/config/index.js.map +1 -0
- package/config/keys.d.ts +6 -0
- package/config/keys.d.ts.map +1 -0
- package/config/keys.js +53 -0
- package/config/keys.js.map +1 -0
- package/config/paths.d.ts +10 -0
- package/config/paths.d.ts.map +1 -0
- package/config/paths.js +21 -0
- package/config/paths.js.map +1 -0
- package/config/resolve.d.ts +33 -0
- package/config/resolve.d.ts.map +1 -0
- package/config/resolve.js +77 -0
- package/config/resolve.js.map +1 -0
- package/errors/classify.d.ts +17 -0
- package/errors/classify.d.ts.map +1 -0
- package/errors/classify.js +158 -0
- package/errors/classify.js.map +1 -0
- package/errors/cli-exit-error.d.ts +6 -0
- package/errors/cli-exit-error.d.ts.map +1 -0
- package/errors/cli-exit-error.js +15 -0
- package/errors/cli-exit-error.js.map +1 -0
- package/errors/exit-codes.d.ts +10 -0
- package/errors/exit-codes.d.ts.map +1 -0
- package/errors/exit-codes.js +12 -0
- package/errors/exit-codes.js.map +1 -0
- package/errors/handle.d.ts +14 -0
- package/errors/handle.d.ts.map +1 -0
- package/errors/handle.js +46 -0
- package/errors/handle.js.map +1 -0
- package/errors/index.d.ts +6 -0
- package/errors/index.d.ts.map +1 -0
- package/errors/index.js +7 -0
- package/errors/index.js.map +1 -0
- package/errors/usage-error.d.ts +5 -0
- package/errors/usage-error.d.ts.map +1 -0
- package/errors/usage-error.js +13 -0
- package/errors/usage-error.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +8 -0
- package/index.js.map +1 -0
- package/local/artifact.d.ts +38 -0
- package/local/artifact.d.ts.map +1 -0
- package/local/artifact.js +133 -0
- package/local/artifact.js.map +1 -0
- package/local/constants.d.ts +36 -0
- package/local/constants.d.ts.map +1 -0
- package/local/constants.js +44 -0
- package/local/constants.js.map +1 -0
- package/local/daemon/components.d.ts +20 -0
- package/local/daemon/components.d.ts.map +1 -0
- package/local/daemon/components.js +105 -0
- package/local/daemon/components.js.map +1 -0
- package/local/daemon/env.d.ts +55 -0
- package/local/daemon/env.d.ts.map +1 -0
- package/local/daemon/env.js +82 -0
- package/local/daemon/env.js.map +1 -0
- package/local/daemon/host.d.ts +7 -0
- package/local/daemon/host.d.ts.map +1 -0
- package/local/daemon/host.js +74 -0
- package/local/daemon/host.js.map +1 -0
- package/local/daemon/index.d.ts +8 -0
- package/local/daemon/index.d.ts.map +1 -0
- package/local/daemon/index.js +8 -0
- package/local/daemon/index.js.map +1 -0
- package/local/daemon/launch.d.ts +11 -0
- package/local/daemon/launch.d.ts.map +1 -0
- package/local/daemon/launch.js +219 -0
- package/local/daemon/launch.js.map +1 -0
- package/local/daemon/process.d.ts +28 -0
- package/local/daemon/process.d.ts.map +1 -0
- package/local/daemon/process.js +149 -0
- package/local/daemon/process.js.map +1 -0
- package/local/daemon/supervisor.d.ts +56 -0
- package/local/daemon/supervisor.d.ts.map +1 -0
- package/local/daemon/supervisor.js +211 -0
- package/local/daemon/supervisor.js.map +1 -0
- package/local/daemon/types.d.ts +63 -0
- package/local/daemon/types.d.ts.map +1 -0
- package/local/daemon/types.js +9 -0
- package/local/daemon/types.js.map +1 -0
- package/local/llm-config.d.ts +30 -0
- package/local/llm-config.d.ts.map +1 -0
- package/local/llm-config.js +93 -0
- package/local/llm-config.js.map +1 -0
- package/local/logs/tail.d.ts +19 -0
- package/local/logs/tail.d.ts.map +1 -0
- package/local/logs/tail.js +86 -0
- package/local/logs/tail.js.map +1 -0
- package/local/logs/view.d.ts +20 -0
- package/local/logs/view.d.ts.map +1 -0
- package/local/logs/view.js +50 -0
- package/local/logs/view.js.map +1 -0
- package/local/net/tcp.d.ts +23 -0
- package/local/net/tcp.d.ts.map +1 -0
- package/local/net/tcp.js +47 -0
- package/local/net/tcp.js.map +1 -0
- package/local/paths.d.ts +26 -0
- package/local/paths.d.ts.map +1 -0
- package/local/paths.js +57 -0
- package/local/paths.js.map +1 -0
- package/local/reset.d.ts +14 -0
- package/local/reset.d.ts.map +1 -0
- package/local/reset.js +57 -0
- package/local/reset.js.map +1 -0
- package/local/runtime/index.d.ts +5 -0
- package/local/runtime/index.d.ts.map +1 -0
- package/local/runtime/index.js +6 -0
- package/local/runtime/index.js.map +1 -0
- package/local/runtime/node.d.ts +8 -0
- package/local/runtime/node.d.ts.map +1 -0
- package/local/runtime/node.js +59 -0
- package/local/runtime/node.js.map +1 -0
- package/local/runtime/runner.d.ts +40 -0
- package/local/runtime/runner.d.ts.map +1 -0
- package/local/runtime/runner.js +154 -0
- package/local/runtime/runner.js.map +1 -0
- package/local/runtime/server.d.ts +39 -0
- package/local/runtime/server.d.ts.map +1 -0
- package/local/runtime/server.js +141 -0
- package/local/runtime/server.js.map +1 -0
- package/local/runtime/which.d.ts +3 -0
- package/local/runtime/which.d.ts.map +1 -0
- package/local/runtime/which.js +30 -0
- package/local/runtime/which.js.map +1 -0
- package/local/seedpack/apply.d.ts +43 -0
- package/local/seedpack/apply.d.ts.map +1 -0
- package/local/seedpack/apply.js +94 -0
- package/local/seedpack/apply.js.map +1 -0
- package/local/seedpack/content.d.ts +56 -0
- package/local/seedpack/content.d.ts.map +1 -0
- package/local/seedpack/content.js +201 -0
- package/local/seedpack/content.js.map +1 -0
- package/local/setup/prompt.d.ts +8 -0
- package/local/setup/prompt.d.ts.map +1 -0
- package/local/setup/prompt.js +63 -0
- package/local/setup/prompt.js.map +1 -0
- package/local/setup/wizard.d.ts +22 -0
- package/local/setup/wizard.d.ts.map +1 -0
- package/local/setup/wizard.js +65 -0
- package/local/setup/wizard.js.map +1 -0
- package/local/state/health-state.d.ts +26 -0
- package/local/state/health-state.d.ts.map +1 -0
- package/local/state/health-state.js +34 -0
- package/local/state/health-state.js.map +1 -0
- package/local/state/index.d.ts +7 -0
- package/local/state/index.d.ts.map +1 -0
- package/local/state/index.js +8 -0
- package/local/state/index.js.map +1 -0
- package/local/state/lock.d.ts +12 -0
- package/local/state/lock.d.ts.map +1 -0
- package/local/state/lock.js +70 -0
- package/local/state/lock.js.map +1 -0
- package/local/state/log-rotation.d.ts +17 -0
- package/local/state/log-rotation.d.ts.map +1 -0
- package/local/state/log-rotation.js +101 -0
- package/local/state/log-rotation.js.map +1 -0
- package/local/state/pidfile.d.ts +11 -0
- package/local/state/pidfile.d.ts.map +1 -0
- package/local/state/pidfile.js +35 -0
- package/local/state/pidfile.js.map +1 -0
- package/local/state/proc.d.ts +16 -0
- package/local/state/proc.d.ts.map +1 -0
- package/local/state/proc.js +69 -0
- package/local/state/proc.js.map +1 -0
- package/local/state/startup-config.d.ts +23 -0
- package/local/state/startup-config.d.ts.map +1 -0
- package/local/state/startup-config.js +33 -0
- package/local/state/startup-config.js.map +1 -0
- package/local/status.d.ts +9 -0
- package/local/status.d.ts.map +1 -0
- package/local/status.js +168 -0
- package/local/status.js.map +1 -0
- package/local/temporal/download.d.ts +20 -0
- package/local/temporal/download.d.ts.map +1 -0
- package/local/temporal/download.js +36 -0
- package/local/temporal/download.js.map +1 -0
- package/local/temporal/index.d.ts +5 -0
- package/local/temporal/index.d.ts.map +1 -0
- package/local/temporal/index.js +6 -0
- package/local/temporal/index.js.map +1 -0
- package/local/temporal/inspect.d.ts +8 -0
- package/local/temporal/inspect.d.ts.map +1 -0
- package/local/temporal/inspect.js +33 -0
- package/local/temporal/inspect.js.map +1 -0
- package/local/temporal/manager.d.ts +50 -0
- package/local/temporal/manager.d.ts.map +1 -0
- package/local/temporal/manager.js +208 -0
- package/local/temporal/manager.js.map +1 -0
- package/local/temporal/supervisor.d.ts +34 -0
- package/local/temporal/supervisor.d.ts.map +1 -0
- package/local/temporal/supervisor.js +83 -0
- package/local/temporal/supervisor.js.map +1 -0
- package/local/webconsole/index.d.ts +4 -0
- package/local/webconsole/index.d.ts.map +1 -0
- package/local/webconsole/index.js +13 -0
- package/local/webconsole/index.js.map +1 -0
- package/logger.d.ts +13 -0
- package/logger.d.ts.map +1 -0
- package/logger.js +35 -0
- package/logger.js.map +1 -0
- package/output/command-result.d.ts +47 -0
- package/output/command-result.d.ts.map +1 -0
- package/output/command-result.js +134 -0
- package/output/command-result.js.map +1 -0
- package/output/confirm.d.ts +22 -0
- package/output/confirm.d.ts.map +1 -0
- package/output/confirm.js +42 -0
- package/output/confirm.js.map +1 -0
- package/output/format.d.ts +22 -0
- package/output/format.d.ts.map +1 -0
- package/output/format.js +72 -0
- package/output/format.js.map +1 -0
- package/output/index.d.ts +7 -0
- package/output/index.d.ts.map +1 -0
- package/output/index.js +8 -0
- package/output/index.js.map +1 -0
- package/output/ndjson.d.ts +24 -0
- package/output/ndjson.d.ts.map +1 -0
- package/output/ndjson.js +38 -0
- package/output/ndjson.js.map +1 -0
- package/output/proto.d.ts +12 -0
- package/output/proto.d.ts.map +1 -0
- package/output/proto.js +34 -0
- package/output/proto.js.map +1 -0
- package/output/style.d.ts +19 -0
- package/output/style.d.ts.map +1 -0
- package/output/style.js +44 -0
- package/output/style.js.map +1 -0
- package/output/table.d.ts +5 -0
- package/output/table.d.ts.map +1 -0
- package/output/table.js +43 -0
- package/output/table.js.map +1 -0
- package/package.json +49 -0
- package/program.d.ts +3 -0
- package/program.d.ts.map +1 -0
- package/program.js +95 -0
- package/program.js.map +1 -0
- package/registry/aliases.d.ts +18 -0
- package/registry/aliases.d.ts.map +1 -0
- package/registry/aliases.js +85 -0
- package/registry/aliases.js.map +1 -0
- package/registry/index.d.ts +6 -0
- package/registry/index.d.ts.map +1 -0
- package/registry/index.js +7 -0
- package/registry/index.js.map +1 -0
- package/registry/metadata.d.ts +12 -0
- package/registry/metadata.d.ts.map +1 -0
- package/registry/metadata.js +49 -0
- package/registry/metadata.js.map +1 -0
- package/registry/registry.d.ts +39 -0
- package/registry/registry.d.ts.map +1 -0
- package/registry/registry.js +59 -0
- package/registry/registry.js.map +1 -0
- package/registry/verb-support.d.ts +5 -0
- package/registry/verb-support.d.ts.map +1 -0
- package/registry/verb-support.js +48 -0
- package/registry/verb-support.js.map +1 -0
- package/registry/verbs.d.ts +16 -0
- package/registry/verbs.d.ts.map +1 -0
- package/registry/verbs.js +36 -0
- package/registry/verbs.js.map +1 -0
- package/resources/apply/apply.d.ts +55 -0
- package/resources/apply/apply.d.ts.map +1 -0
- package/resources/apply/apply.js +163 -0
- package/resources/apply/apply.js.map +1 -0
- package/resources/apply/declarative.d.ts +106 -0
- package/resources/apply/declarative.d.ts.map +1 -0
- package/resources/apply/declarative.js +378 -0
- package/resources/apply/declarative.js.map +1 -0
- package/resources/apply/discovery.d.ts +7 -0
- package/resources/apply/discovery.d.ts.map +1 -0
- package/resources/apply/discovery.js +47 -0
- package/resources/apply/discovery.js.map +1 -0
- package/resources/apply/handlers.d.ts +15 -0
- package/resources/apply/handlers.d.ts.map +1 -0
- package/resources/apply/handlers.js +126 -0
- package/resources/apply/handlers.js.map +1 -0
- package/resources/apply/synth/project-track.d.ts +21 -0
- package/resources/apply/synth/project-track.d.ts.map +1 -0
- package/resources/apply/synth/project-track.js +102 -0
- package/resources/apply/synth/project-track.js.map +1 -0
- package/resources/apply/synth/reader.d.ts +18 -0
- package/resources/apply/synth/reader.d.ts.map +1 -0
- package/resources/apply/synth/reader.js +55 -0
- package/resources/apply/synth/reader.js.map +1 -0
- package/resources/apply/synth/runtime.d.ts +8 -0
- package/resources/apply/synth/runtime.d.ts.map +1 -0
- package/resources/apply/synth/runtime.js +32 -0
- package/resources/apply/synth/runtime.js.map +1 -0
- package/resources/apply/synth/synthesize.d.ts +43 -0
- package/resources/apply/synth/synthesize.d.ts.map +1 -0
- package/resources/apply/synth/synthesize.js +115 -0
- package/resources/apply/synth/synthesize.js.map +1 -0
- package/resources/connect/connect.d.ts +24 -0
- package/resources/connect/connect.d.ts.map +1 -0
- package/resources/connect/connect.js +71 -0
- package/resources/connect/connect.js.map +1 -0
- package/resources/connect/discover.d.ts +5 -0
- package/resources/connect/discover.d.ts.map +1 -0
- package/resources/connect/discover.js +100 -0
- package/resources/connect/discover.js.map +1 -0
- package/resources/connect/display.d.ts +5 -0
- package/resources/connect/display.d.ts.map +1 -0
- package/resources/connect/display.js +58 -0
- package/resources/connect/display.js.map +1 -0
- package/resources/connect/oauth.d.ts +45 -0
- package/resources/connect/oauth.d.ts.map +1 -0
- package/resources/connect/oauth.js +152 -0
- package/resources/connect/oauth.js.map +1 -0
- package/resources/delete.d.ts +18 -0
- package/resources/delete.d.ts.map +1 -0
- package/resources/delete.js +180 -0
- package/resources/delete.js.map +1 -0
- package/resources/diff.d.ts +16 -0
- package/resources/diff.d.ts.map +1 -0
- package/resources/diff.js +158 -0
- package/resources/diff.js.map +1 -0
- package/resources/documents.d.ts +16 -0
- package/resources/documents.d.ts.map +1 -0
- package/resources/documents.js +89 -0
- package/resources/documents.js.map +1 -0
- package/resources/download.d.ts +16 -0
- package/resources/download.d.ts.map +1 -0
- package/resources/download.js +107 -0
- package/resources/download.js.map +1 -0
- package/resources/execution-approve.d.ts +26 -0
- package/resources/execution-approve.d.ts.map +1 -0
- package/resources/execution-approve.js +69 -0
- package/resources/execution-approve.js.map +1 -0
- package/resources/execution-control.d.ts +16 -0
- package/resources/execution-control.d.ts.map +1 -0
- package/resources/execution-control.js +57 -0
- package/resources/execution-control.js.map +1 -0
- package/resources/execution-format.d.ts +12 -0
- package/resources/execution-format.d.ts.map +1 -0
- package/resources/execution-format.js +56 -0
- package/resources/execution-format.js.map +1 -0
- package/resources/execution-logs.d.ts +16 -0
- package/resources/execution-logs.d.ts.map +1 -0
- package/resources/execution-logs.js +132 -0
- package/resources/execution-logs.js.map +1 -0
- package/resources/execution-trace.d.ts +10 -0
- package/resources/execution-trace.d.ts.map +1 -0
- package/resources/execution-trace.js +125 -0
- package/resources/execution-trace.js.map +1 -0
- package/resources/execution.d.ts +59 -0
- package/resources/execution.d.ts.map +1 -0
- package/resources/execution.js +192 -0
- package/resources/execution.js.map +1 -0
- package/resources/get-bindings.d.ts +12 -0
- package/resources/get-bindings.d.ts.map +1 -0
- package/resources/get-bindings.js +40 -0
- package/resources/get-bindings.js.map +1 -0
- package/resources/get.d.ts +6 -0
- package/resources/get.d.ts.map +1 -0
- package/resources/get.js +31 -0
- package/resources/get.js.map +1 -0
- package/resources/git.d.ts +15 -0
- package/resources/git.d.ts.map +1 -0
- package/resources/git.js +69 -0
- package/resources/git.js.map +1 -0
- package/resources/ignore/defaults.d.ts +2 -0
- package/resources/ignore/defaults.d.ts.map +1 -0
- package/resources/ignore/defaults.js +140 -0
- package/resources/ignore/defaults.js.map +1 -0
- package/resources/ignore/index.d.ts +5 -0
- package/resources/ignore/index.d.ts.map +1 -0
- package/resources/ignore/index.js +6 -0
- package/resources/ignore/index.js.map +1 -0
- package/resources/ignore/match.d.ts +3 -0
- package/resources/ignore/match.d.ts.map +1 -0
- package/resources/ignore/match.js +166 -0
- package/resources/ignore/match.js.map +1 -0
- package/resources/ignore/matcher.d.ts +44 -0
- package/resources/ignore/matcher.d.ts.map +1 -0
- package/resources/ignore/matcher.js +125 -0
- package/resources/ignore/matcher.js.map +1 -0
- package/resources/ignore/pattern.d.ts +13 -0
- package/resources/ignore/pattern.d.ts.map +1 -0
- package/resources/ignore/pattern.js +118 -0
- package/resources/ignore/pattern.js.map +1 -0
- package/resources/list.d.ts +7 -0
- package/resources/list.d.ts.map +1 -0
- package/resources/list.js +82 -0
- package/resources/list.js.map +1 -0
- package/resources/mcp/runtime-env.d.ts +23 -0
- package/resources/mcp/runtime-env.d.ts.map +1 -0
- package/resources/mcp/runtime-env.js +68 -0
- package/resources/mcp/runtime-env.js.map +1 -0
- package/resources/picker/ink.d.ts +35 -0
- package/resources/picker/ink.d.ts.map +1 -0
- package/resources/picker/ink.js +45 -0
- package/resources/picker/ink.js.map +1 -0
- package/resources/picker/tty.d.ts +19 -0
- package/resources/picker/tty.d.ts.map +1 -0
- package/resources/picker/tty.js +21 -0
- package/resources/picker/tty.js.map +1 -0
- package/resources/reference.d.ts +32 -0
- package/resources/reference.d.ts.map +1 -0
- package/resources/reference.js +128 -0
- package/resources/reference.js.map +1 -0
- package/resources/render.d.ts +28 -0
- package/resources/render.d.ts.map +1 -0
- package/resources/render.js +87 -0
- package/resources/render.js.map +1 -0
- package/resources/run/agent-exec.d.ts +15 -0
- package/resources/run/agent-exec.d.ts.map +1 -0
- package/resources/run/agent-exec.js +81 -0
- package/resources/run/agent-exec.js.map +1 -0
- package/resources/run/attachments.d.ts +24 -0
- package/resources/run/attachments.d.ts.map +1 -0
- package/resources/run/attachments.js +209 -0
- package/resources/run/attachments.js.map +1 -0
- package/resources/run/create.d.ts +56 -0
- package/resources/run/create.d.ts.map +1 -0
- package/resources/run/create.js +105 -0
- package/resources/run/create.js.map +1 -0
- package/resources/run/env.d.ts +18 -0
- package/resources/run/env.d.ts.map +1 -0
- package/resources/run/env.js +147 -0
- package/resources/run/env.js.map +1 -0
- package/resources/run/epilogue.d.ts +9 -0
- package/resources/run/epilogue.d.ts.map +1 -0
- package/resources/run/epilogue.js +144 -0
- package/resources/run/epilogue.js.map +1 -0
- package/resources/run/header.d.ts +23 -0
- package/resources/run/header.d.ts.map +1 -0
- package/resources/run/header.js +51 -0
- package/resources/run/header.js.map +1 -0
- package/resources/run/prepare.d.ts +60 -0
- package/resources/run/prepare.d.ts.map +1 -0
- package/resources/run/prepare.js +78 -0
- package/resources/run/prepare.js.map +1 -0
- package/resources/run/resolve.d.ts +8 -0
- package/resources/run/resolve.d.ts.map +1 -0
- package/resources/run/resolve.js +28 -0
- package/resources/run/resolve.js.map +1 -0
- package/resources/run/resume.d.ts +13 -0
- package/resources/run/resume.d.ts.map +1 -0
- package/resources/run/resume.js +94 -0
- package/resources/run/resume.js.map +1 -0
- package/resources/run/stream.d.ts +24 -0
- package/resources/run/stream.d.ts.map +1 -0
- package/resources/run/stream.js +80 -0
- package/resources/run/stream.js.map +1 -0
- package/resources/run/workflow-stream.d.ts +25 -0
- package/resources/run/workflow-stream.d.ts.map +1 -0
- package/resources/run/workflow-stream.js +152 -0
- package/resources/run/workflow-stream.js.map +1 -0
- package/resources/run/workspace.d.ts +17 -0
- package/resources/run/workspace.d.ts.map +1 -0
- package/resources/run/workspace.js +147 -0
- package/resources/run/workspace.js.map +1 -0
- package/resources/search.d.ts +22 -0
- package/resources/search.d.ts.map +1 -0
- package/resources/search.js +23 -0
- package/resources/search.js.map +1 -0
- package/resources/session.d.ts +19 -0
- package/resources/session.d.ts.map +1 -0
- package/resources/session.js +51 -0
- package/resources/session.js.map +1 -0
- package/resources/skill.d.ts +84 -0
- package/resources/skill.d.ts.map +1 -0
- package/resources/skill.js +342 -0
- package/resources/skill.js.map +1 -0
- package/resources/stream/approval-detect.d.ts +38 -0
- package/resources/stream/approval-detect.d.ts.map +1 -0
- package/resources/stream/approval-detect.js +93 -0
- package/resources/stream/approval-detect.js.map +1 -0
- package/resources/stream/convert.d.ts +38 -0
- package/resources/stream/convert.d.ts.map +1 -0
- package/resources/stream/convert.js +178 -0
- package/resources/stream/convert.js.map +1 -0
- package/resources/stream/diff.d.ts +29 -0
- package/resources/stream/diff.d.ts.map +1 -0
- package/resources/stream/diff.js +214 -0
- package/resources/stream/diff.js.map +1 -0
- package/resources/stream/events.d.ts +137 -0
- package/resources/stream/events.d.ts.map +1 -0
- package/resources/stream/events.js +15 -0
- package/resources/stream/events.js.map +1 -0
- package/resources/stream/headless.d.ts +38 -0
- package/resources/stream/headless.d.ts.map +1 -0
- package/resources/stream/headless.js +75 -0
- package/resources/stream/headless.js.map +1 -0
- package/resources/stream/ink.d.ts +22 -0
- package/resources/stream/ink.d.ts.map +1 -0
- package/resources/stream/ink.js +24 -0
- package/resources/stream/ink.js.map +1 -0
- package/resources/stream/render-ndjson.d.ts +25 -0
- package/resources/stream/render-ndjson.d.ts.map +1 -0
- package/resources/stream/render-ndjson.js +156 -0
- package/resources/stream/render-ndjson.js.map +1 -0
- package/resources/stream/render-plaintext.d.ts +18 -0
- package/resources/stream/render-plaintext.d.ts.map +1 -0
- package/resources/stream/render-plaintext.js +71 -0
- package/resources/stream/render-plaintext.js.map +1 -0
- package/resources/stream/snapshot.d.ts +8 -0
- package/resources/stream/snapshot.d.ts.map +1 -0
- package/resources/stream/snapshot.js +163 -0
- package/resources/stream/snapshot.js.map +1 -0
- package/resources/stream/subagent.d.ts +12 -0
- package/resources/stream/subagent.d.ts.map +1 -0
- package/resources/stream/subagent.js +76 -0
- package/resources/stream/subagent.js.map +1 -0
- package/resources/stream/submit.d.ts +20 -0
- package/resources/stream/submit.d.ts.map +1 -0
- package/resources/stream/submit.js +125 -0
- package/resources/stream/submit.js.map +1 -0
- package/resources/stream/todo.d.ts +11 -0
- package/resources/stream/todo.d.ts.map +1 -0
- package/resources/stream/todo.js +44 -0
- package/resources/stream/todo.js.map +1 -0
- package/resources/stream/tool-state.d.ts +31 -0
- package/resources/stream/tool-state.d.ts.map +1 -0
- package/resources/stream/tool-state.js +126 -0
- package/resources/stream/tool-state.js.map +1 -0
- package/resources/stream/tty.d.ts +8 -0
- package/resources/stream/tty.d.ts.map +1 -0
- package/resources/stream/tty.js +15 -0
- package/resources/stream/tty.js.map +1 -0
- package/resources/stream/workflow-event-view.d.ts +21 -0
- package/resources/stream/workflow-event-view.d.ts.map +1 -0
- package/resources/stream/workflow-event-view.js +88 -0
- package/resources/stream/workflow-event-view.js.map +1 -0
- package/resources/stream/workflow-render-ndjson.d.ts +5 -0
- package/resources/stream/workflow-render-ndjson.d.ts.map +1 -0
- package/resources/stream/workflow-render-ndjson.js +54 -0
- package/resources/stream/workflow-render-ndjson.js.map +1 -0
- package/resources/stream/workflow-render-plaintext.d.ts +8 -0
- package/resources/stream/workflow-render-plaintext.d.ts.map +1 -0
- package/resources/stream/workflow-render-plaintext.js +34 -0
- package/resources/stream/workflow-render-plaintext.js.map +1 -0
- package/resources/tag.d.ts +4 -0
- package/resources/tag.d.ts.map +1 -0
- package/resources/tag.js +36 -0
- package/resources/tag.js.map +1 -0
- package/resources/usage.d.ts +14 -0
- package/resources/usage.d.ts.map +1 -0
- package/resources/usage.js +251 -0
- package/resources/usage.js.map +1 -0
- package/resources/validate.d.ts +6 -0
- package/resources/validate.d.ts.map +1 -0
- package/resources/validate.js +28 -0
- package/resources/validate.js.map +1 -0
- package/resources/version.d.ts +6 -0
- package/resources/version.d.ts.map +1 -0
- package/resources/version.js +75 -0
- package/resources/version.js.map +1 -0
- package/runtime.d.ts +5 -0
- package/runtime.d.ts.map +1 -0
- package/runtime.js +19 -0
- package/runtime.js.map +1 -0
- package/src/auth/auth0.ts +43 -0
- package/src/auth/callback-server.ts +104 -0
- package/src/auth/index.ts +6 -0
- package/src/auth/login.ts +61 -0
- package/src/auth/pages.ts +31 -0
- package/src/auth/pkce.test.ts +37 -0
- package/src/auth/pkce.ts +26 -0
- package/src/auth/token.test.ts +95 -0
- package/src/auth/token.ts +135 -0
- package/src/backend.ts +15 -0
- package/src/cli/stigmer.ts +16 -0
- package/src/client/client.test.ts +46 -0
- package/src/client/client.ts +84 -0
- package/src/client/index.ts +3 -0
- package/src/commands/agent-exec-flags.ts +75 -0
- package/src/commands/apikey/duration.test.ts +23 -0
- package/src/commands/apikey/duration.ts +35 -0
- package/src/commands/apikey/index.ts +133 -0
- package/src/commands/apply.ts +213 -0
- package/src/commands/auth/index.ts +87 -0
- package/src/commands/completion.ts +96 -0
- package/src/commands/config/backend.ts +58 -0
- package/src/commands/config/context.ts +26 -0
- package/src/commands/config/index.ts +18 -0
- package/src/commands/config/kv.ts +44 -0
- package/src/commands/connect.ts +75 -0
- package/src/commands/delete.ts +56 -0
- package/src/commands/diff.ts +97 -0
- package/src/commands/down.ts +27 -0
- package/src/commands/download.ts +68 -0
- package/src/commands/draft.ts +128 -0
- package/src/commands/execution/approve.ts +76 -0
- package/src/commands/execution/control.ts +79 -0
- package/src/commands/execution/index.ts +24 -0
- package/src/commands/execution/logs.ts +47 -0
- package/src/commands/execution/trace.ts +32 -0
- package/src/commands/get.ts +99 -0
- package/src/commands/internal-daemon.ts +25 -0
- package/src/commands/list.ts +138 -0
- package/src/commands/logs.ts +73 -0
- package/src/commands/mcp-server.test.ts +65 -0
- package/src/commands/mcp-server.ts +124 -0
- package/src/commands/push.ts +205 -0
- package/src/commands/reset.ts +57 -0
- package/src/commands/resume.ts +121 -0
- package/src/commands/run.ts +276 -0
- package/src/commands/search.ts +90 -0
- package/src/commands/seedpack.ts +94 -0
- package/src/commands/setup.ts +71 -0
- package/src/commands/shared.ts +41 -0
- package/src/commands/status.ts +20 -0
- package/src/commands/tag.ts +31 -0
- package/src/commands/up.ts +51 -0
- package/src/commands/usage.ts +74 -0
- package/src/commands/validate.test.ts +79 -0
- package/src/commands/validate.ts +73 -0
- package/src/commands/version.ts +13 -0
- package/src/config/config.test.ts +76 -0
- package/src/config/config.ts +127 -0
- package/src/config/index.ts +22 -0
- package/src/config/keys.test.ts +38 -0
- package/src/config/keys.ts +64 -0
- package/src/config/paths.ts +25 -0
- package/src/config/resolve.test.ts +103 -0
- package/src/config/resolve.ts +80 -0
- package/src/errors/classify.ts +199 -0
- package/src/errors/cli-exit-error.ts +16 -0
- package/src/errors/clierr.test.ts +172 -0
- package/src/errors/exit-codes.ts +14 -0
- package/src/errors/handle.ts +53 -0
- package/src/errors/index.ts +7 -0
- package/src/errors/usage-error.ts +14 -0
- package/src/index.ts +8 -0
- package/src/local/artifact.test.ts +28 -0
- package/src/local/artifact.ts +166 -0
- package/src/local/constants.ts +52 -0
- package/src/local/daemon/components.test.ts +80 -0
- package/src/local/daemon/components.ts +113 -0
- package/src/local/daemon/daemon.integration.test.ts +183 -0
- package/src/local/daemon/env.test.ts +51 -0
- package/src/local/daemon/env.ts +118 -0
- package/src/local/daemon/host.ts +79 -0
- package/src/local/daemon/index.ts +18 -0
- package/src/local/daemon/launch.ts +260 -0
- package/src/local/daemon/process.ts +183 -0
- package/src/local/daemon/supervisor.test.ts +260 -0
- package/src/local/daemon/supervisor.ts +249 -0
- package/src/local/daemon/types.ts +76 -0
- package/src/local/llm-config.test.ts +80 -0
- package/src/local/llm-config.ts +107 -0
- package/src/local/logs/tail.test.ts +70 -0
- package/src/local/logs/tail.ts +100 -0
- package/src/local/logs/view.test.ts +46 -0
- package/src/local/logs/view.ts +65 -0
- package/src/local/net/tcp.ts +65 -0
- package/src/local/paths.ts +67 -0
- package/src/local/reset.test.ts +53 -0
- package/src/local/reset.ts +90 -0
- package/src/local/runtime/index.ts +18 -0
- package/src/local/runtime/node.ts +67 -0
- package/src/local/runtime/runner.ts +186 -0
- package/src/local/runtime/runtime.test.ts +155 -0
- package/src/local/runtime/server.test.ts +152 -0
- package/src/local/runtime/server.ts +172 -0
- package/src/local/runtime/which.ts +30 -0
- package/src/local/seedpack/apply.test.ts +166 -0
- package/src/local/seedpack/apply.ts +139 -0
- package/src/local/seedpack/content.test.ts +148 -0
- package/src/local/seedpack/content.ts +223 -0
- package/src/local/setup/prompt.ts +70 -0
- package/src/local/setup/wizard.test.ts +42 -0
- package/src/local/setup/wizard.ts +78 -0
- package/src/local/state/health-state.ts +55 -0
- package/src/local/state/index.ts +8 -0
- package/src/local/state/lock.ts +77 -0
- package/src/local/state/log-rotation.ts +112 -0
- package/src/local/state/pidfile.ts +37 -0
- package/src/local/state/proc.ts +66 -0
- package/src/local/state/startup-config.ts +51 -0
- package/src/local/state/state.test.ts +166 -0
- package/src/local/status.test.ts +88 -0
- package/src/local/status.ts +186 -0
- package/src/local/temporal/download.test.ts +64 -0
- package/src/local/temporal/download.ts +54 -0
- package/src/local/temporal/index.ts +6 -0
- package/src/local/temporal/inspect.ts +32 -0
- package/src/local/temporal/manager.test.ts +31 -0
- package/src/local/temporal/manager.ts +247 -0
- package/src/local/temporal/supervisor.test.ts +77 -0
- package/src/local/temporal/supervisor.ts +97 -0
- package/src/local/webconsole/index.ts +13 -0
- package/src/logger.ts +39 -0
- package/src/output/command-result.test.ts +64 -0
- package/src/output/command-result.ts +185 -0
- package/src/output/confirm.test.ts +43 -0
- package/src/output/confirm.ts +53 -0
- package/src/output/format.test.ts +65 -0
- package/src/output/format.ts +101 -0
- package/src/output/index.ts +30 -0
- package/src/output/ndjson.ts +55 -0
- package/src/output/proto.test.ts +72 -0
- package/src/output/proto.ts +55 -0
- package/src/output/style.ts +57 -0
- package/src/output/table.test.ts +37 -0
- package/src/output/table.ts +52 -0
- package/src/program.test.ts +64 -0
- package/src/program.ts +100 -0
- package/src/registry/aliases.test.ts +99 -0
- package/src/registry/aliases.ts +93 -0
- package/src/registry/index.ts +7 -0
- package/src/registry/metadata.ts +60 -0
- package/src/registry/registry.test.ts +80 -0
- package/src/registry/registry.ts +101 -0
- package/src/registry/verb-support.ts +50 -0
- package/src/registry/verbs.ts +43 -0
- package/src/resources/apply/apply.integration.test.ts +207 -0
- package/src/resources/apply/apply.ts +202 -0
- package/src/resources/apply/declarative.integration.test.ts +126 -0
- package/src/resources/apply/declarative.test.ts +132 -0
- package/src/resources/apply/declarative.ts +474 -0
- package/src/resources/apply/discovery.ts +60 -0
- package/src/resources/apply/handlers.ts +145 -0
- package/src/resources/apply/synth/capstone.integration.test.ts +134 -0
- package/src/resources/apply/synth/project-track.integration.test.ts +194 -0
- package/src/resources/apply/synth/project-track.ts +126 -0
- package/src/resources/apply/synth/reader.test.ts +90 -0
- package/src/resources/apply/synth/reader.ts +68 -0
- package/src/resources/apply/synth/runtime.test.ts +29 -0
- package/src/resources/apply/synth/runtime.ts +39 -0
- package/src/resources/apply/synth/synthesize.test.ts +109 -0
- package/src/resources/apply/synth/synthesize.ts +161 -0
- package/src/resources/connect/__fixtures__/stdio-crash.mjs +6 -0
- package/src/resources/connect/__fixtures__/stdio-server.mjs +43 -0
- package/src/resources/connect/connect.integration.test.ts +185 -0
- package/src/resources/connect/connect.ts +107 -0
- package/src/resources/connect/discover.test.ts +45 -0
- package/src/resources/connect/discover.ts +125 -0
- package/src/resources/connect/display.ts +68 -0
- package/src/resources/connect/oauth.test.ts +155 -0
- package/src/resources/connect/oauth.ts +191 -0
- package/src/resources/delete.ts +239 -0
- package/src/resources/diff.integration.test.ts +103 -0
- package/src/resources/diff.test.ts +34 -0
- package/src/resources/diff.ts +187 -0
- package/src/resources/documents.test.ts +67 -0
- package/src/resources/documents.ts +102 -0
- package/src/resources/download.ts +151 -0
- package/src/resources/execution-approve.test.ts +50 -0
- package/src/resources/execution-approve.ts +94 -0
- package/src/resources/execution-control.ts +78 -0
- package/src/resources/execution-format.test.ts +48 -0
- package/src/resources/execution-format.ts +54 -0
- package/src/resources/execution-logs.ts +176 -0
- package/src/resources/execution-trace.ts +159 -0
- package/src/resources/execution.integration.test.ts +285 -0
- package/src/resources/execution.test.ts +138 -0
- package/src/resources/execution.ts +229 -0
- package/src/resources/get-bindings.ts +61 -0
- package/src/resources/get.ts +41 -0
- package/src/resources/git.ts +71 -0
- package/src/resources/ignore/defaults.ts +155 -0
- package/src/resources/ignore/ignore.test.ts +139 -0
- package/src/resources/ignore/index.ts +17 -0
- package/src/resources/ignore/match.ts +158 -0
- package/src/resources/ignore/matcher.ts +158 -0
- package/src/resources/ignore/pattern.ts +131 -0
- package/src/resources/list.ts +97 -0
- package/src/resources/mcp/runtime-env.test.ts +68 -0
- package/src/resources/mcp/runtime-env.ts +79 -0
- package/src/resources/mutate-verbs.integration.test.ts +233 -0
- package/src/resources/picker/ink.tsx +114 -0
- package/src/resources/picker/tty.test.ts +37 -0
- package/src/resources/picker/tty.ts +30 -0
- package/src/resources/push-download.integration.test.ts +175 -0
- package/src/resources/read-completion.integration.test.ts +156 -0
- package/src/resources/read-verbs.integration.test.ts +164 -0
- package/src/resources/reference.test.ts +107 -0
- package/src/resources/reference.ts +140 -0
- package/src/resources/render.ts +118 -0
- package/src/resources/run/agent-exec.ts +107 -0
- package/src/resources/run/attachments.test.ts +113 -0
- package/src/resources/run/attachments.ts +261 -0
- package/src/resources/run/create.test.ts +119 -0
- package/src/resources/run/create.ts +165 -0
- package/src/resources/run/env.test.ts +131 -0
- package/src/resources/run/env.ts +167 -0
- package/src/resources/run/epilogue.ts +166 -0
- package/src/resources/run/header.test.ts +61 -0
- package/src/resources/run/header.ts +62 -0
- package/src/resources/run/prepare.test.ts +92 -0
- package/src/resources/run/prepare.ts +139 -0
- package/src/resources/run/resolve.ts +32 -0
- package/src/resources/run/resume.ts +119 -0
- package/src/resources/run/stream.ts +108 -0
- package/src/resources/run/workflow-stream.integration.test.ts +157 -0
- package/src/resources/run/workflow-stream.ts +203 -0
- package/src/resources/run/workspace.test.ts +93 -0
- package/src/resources/run/workspace.ts +171 -0
- package/src/resources/search.ts +53 -0
- package/src/resources/session.test.ts +48 -0
- package/src/resources/session.ts +66 -0
- package/src/resources/skill.test.ts +227 -0
- package/src/resources/skill.ts +451 -0
- package/src/resources/stream/approval-detect.ts +118 -0
- package/src/resources/stream/convert.ts +210 -0
- package/src/resources/stream/diff.test.ts +316 -0
- package/src/resources/stream/diff.ts +254 -0
- package/src/resources/stream/events.ts +193 -0
- package/src/resources/stream/headless.test.ts +119 -0
- package/src/resources/stream/headless.ts +112 -0
- package/src/resources/stream/ink.tsx +56 -0
- package/src/resources/stream/lazy-import.test.ts +63 -0
- package/src/resources/stream/render-ndjson.test.ts +116 -0
- package/src/resources/stream/render-ndjson.ts +176 -0
- package/src/resources/stream/render-plaintext.test.ts +68 -0
- package/src/resources/stream/render-plaintext.ts +86 -0
- package/src/resources/stream/snapshot.test.ts +97 -0
- package/src/resources/stream/snapshot.ts +191 -0
- package/src/resources/stream/subagent.ts +104 -0
- package/src/resources/stream/submit.test.ts +77 -0
- package/src/resources/stream/submit.ts +137 -0
- package/src/resources/stream/todo.ts +53 -0
- package/src/resources/stream/tool-state.ts +142 -0
- package/src/resources/stream/tty.ts +14 -0
- package/src/resources/stream/workflow-event-view.test.ts +116 -0
- package/src/resources/stream/workflow-event-view.ts +111 -0
- package/src/resources/stream/workflow-render-ndjson.ts +61 -0
- package/src/resources/stream/workflow-render-plaintext.ts +43 -0
- package/src/resources/stream/workflow-render.test.ts +81 -0
- package/src/resources/tag.ts +50 -0
- package/src/resources/usage.test.ts +94 -0
- package/src/resources/usage.ts +301 -0
- package/src/resources/validate.test.ts +54 -0
- package/src/resources/validate.ts +31 -0
- package/src/resources/version.ts +105 -0
- package/src/runtime.ts +23 -0
- package/src/types/marked-terminal.d.ts +31 -0
- package/src/version.ts +46 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +45 -0
- package/version.js.map +1 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Workflow version history (`get <workflow> --version-history`) and single
|
|
2
|
+
// version retrieval (`get <workflow> --version <hashOrTag>`). Versioning is a
|
|
3
|
+
// workflow-only feature: applies create immutable, hash-addressed versions that
|
|
4
|
+
// can be tagged and diffed. Mirrors Go's workflow.RunVersionsList /
|
|
5
|
+
// RunVersionsGet, including the table layout and the empty-history guidance.
|
|
6
|
+
import { create } from "@bufbuild/protobuf";
|
|
7
|
+
import { timestampDate } from "@bufbuild/protobuf/wkt";
|
|
8
|
+
import { GetWorkflowVersionInputSchema, ListWorkflowVersionsInputSchema, } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/version_pb";
|
|
9
|
+
import { CliExitError, ExitCode } from "../errors/index.js";
|
|
10
|
+
// Go caps the history view at 50 entries (workflow.getWorkflow → RunVersionsList).
|
|
11
|
+
const VERSION_HISTORY_PAGE_SIZE = 50;
|
|
12
|
+
/** Render the workflow's version history table, or empty-history guidance. */
|
|
13
|
+
export async function renderWorkflowVersionHistory(client, org, slug) {
|
|
14
|
+
const response = await client.workflow.listVersions(create(ListWorkflowVersionsInputSchema, { org, slug, pageSize: VERSION_HISTORY_PAGE_SIZE }));
|
|
15
|
+
if (response.versions.length === 0) {
|
|
16
|
+
return [
|
|
17
|
+
"",
|
|
18
|
+
`No version history found for ${org}/${slug}`,
|
|
19
|
+
"Tip: Apply a workflow to create the first version:",
|
|
20
|
+
" stigmer apply -f workflow.yaml",
|
|
21
|
+
"",
|
|
22
|
+
].join("\n");
|
|
23
|
+
}
|
|
24
|
+
return renderVersionsTable(response.versions, response.totalCount);
|
|
25
|
+
}
|
|
26
|
+
/** Fetch the validated YAML for a specific version (by hash or tag). */
|
|
27
|
+
export async function getWorkflowVersionYaml(client, org, slug, hashOrTag) {
|
|
28
|
+
const workflow = await client.workflow.getByReference({ org, slug });
|
|
29
|
+
const workflowId = workflow.metadata?.id ?? "";
|
|
30
|
+
const entry = await client.workflow.getVersion(create(GetWorkflowVersionInputSchema, { workflowId, versionHash: hashOrTag }));
|
|
31
|
+
if (entry.validatedYaml === "") {
|
|
32
|
+
throw new CliExitError(`version ${truncateHash(hashOrTag)} has no validated YAML`, ExitCode.General);
|
|
33
|
+
}
|
|
34
|
+
// Go uses fmt.Print (no added newline) — the YAML carries its own.
|
|
35
|
+
return entry.validatedYaml;
|
|
36
|
+
}
|
|
37
|
+
// --- Rendering (mirrors Go's displayVersionsTable) ---
|
|
38
|
+
function renderVersionsTable(entries, totalCount) {
|
|
39
|
+
const lines = [
|
|
40
|
+
"",
|
|
41
|
+
`Version History (${totalCount} total)`,
|
|
42
|
+
"",
|
|
43
|
+
` ${pad("HASH", 14)} ${pad("TAG", 10)} ${pad("APPLIED AT", 20)} ${pad("CURRENT", 8)} MESSAGE`,
|
|
44
|
+
` ${"─".repeat(14)} ${"─".repeat(10)} ${"─".repeat(20)} ${"─".repeat(8)} ───────`,
|
|
45
|
+
];
|
|
46
|
+
for (const entry of entries) {
|
|
47
|
+
const hash = truncateHash(entry.versionHash);
|
|
48
|
+
const tag = entry.tag === "" ? "-" : entry.tag;
|
|
49
|
+
const appliedAt = entry.appliedAt === undefined ? "-" : formatAppliedAt(entry.appliedAt);
|
|
50
|
+
const current = entry.isCurrent ? "*" : "";
|
|
51
|
+
const message = truncateMessage(entry.message);
|
|
52
|
+
lines.push(` ${pad(hash, 14)} ${pad(tag, 10)} ${pad(appliedAt, 20)} ${pad(current, 8)} ${message}`);
|
|
53
|
+
}
|
|
54
|
+
lines.push("");
|
|
55
|
+
return `${lines.join("\n")}\n`;
|
|
56
|
+
}
|
|
57
|
+
function truncateHash(hash) {
|
|
58
|
+
return hash.length > 12 ? hash.slice(0, 12) : hash;
|
|
59
|
+
}
|
|
60
|
+
function truncateMessage(message) {
|
|
61
|
+
if (message === "")
|
|
62
|
+
return "-";
|
|
63
|
+
return message.length > 40 ? `${message.slice(0, 37)}...` : message;
|
|
64
|
+
}
|
|
65
|
+
// Matches Go's "2006-01-02 15:04" local-time layout.
|
|
66
|
+
function formatAppliedAt(timestamp) {
|
|
67
|
+
const date = timestampDate(timestamp);
|
|
68
|
+
const pad2 = (n) => String(n).padStart(2, "0");
|
|
69
|
+
return (`${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())} ` +
|
|
70
|
+
`${pad2(date.getHours())}:${pad2(date.getMinutes())}`);
|
|
71
|
+
}
|
|
72
|
+
function pad(value, width) {
|
|
73
|
+
return value.length >= width ? value : value + " ".repeat(width - value.length);
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/resources/version.ts"],"names":[],"mappings":"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"}
|
package/runtime.d.ts
ADDED
package/runtime.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAQA,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE7C;AAED,wBAAgB,OAAO,IAAI,OAAO,CAEjC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAElD;AAED,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
package/runtime.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Process-global CLI flags that cross-cutting modules (config, errors, logger)
|
|
2
|
+
// read without threading them through every call. Set once by the root
|
|
3
|
+
// preAction hook from the parsed global options. Mirrors the Go CLI's atomic
|
|
4
|
+
// `standalone`/`debug` globals in internal/cli/config and clierr.
|
|
5
|
+
let debug = false;
|
|
6
|
+
let standalone = false;
|
|
7
|
+
export function setDebug(value) {
|
|
8
|
+
debug = value;
|
|
9
|
+
}
|
|
10
|
+
export function isDebug() {
|
|
11
|
+
return debug;
|
|
12
|
+
}
|
|
13
|
+
export function setStandalone(value) {
|
|
14
|
+
standalone = value;
|
|
15
|
+
}
|
|
16
|
+
export function isStandalone() {
|
|
17
|
+
return standalone;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=runtime.js.map
|
package/runtime.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,uEAAuE;AACvE,6EAA6E;AAC7E,kEAAkE;AAElE,IAAI,KAAK,GAAG,KAAK,CAAC;AAClB,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,KAAK,GAAG,KAAK,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,OAAO;IACrB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,UAAU,GAAG,KAAK,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Auth0 PKCE configuration for Stigmer Cloud.
|
|
2
|
+
//
|
|
3
|
+
// These values are public metadata for a Native/PKCE application — they are NOT
|
|
4
|
+
// secrets. An Auth0 client ID is a public identifier (like a username, not a
|
|
5
|
+
// password), and PKCE removes the need for a client secret entirely. The
|
|
6
|
+
// authorize/token endpoints are hardcoded because Auth0's URL structure is
|
|
7
|
+
// stable ({domain}/authorize, {domain}/oauth/token), saving an OIDC-discovery
|
|
8
|
+
// round-trip at login time. Kept byte-for-byte identical to the Go CLI.
|
|
9
|
+
|
|
10
|
+
export const AUTH0_DOMAIN = "https://stigmer-prod.us.auth0.com";
|
|
11
|
+
export const CLIENT_ID = "kIT6URf4HKn6YzrQVVFTFN63BrSJdTPM";
|
|
12
|
+
export const AUDIENCE = "https://api.stigmer.com/";
|
|
13
|
+
export const CALLBACK_PORT = 8088;
|
|
14
|
+
export const CALLBACK_PATH = "/auth/callback";
|
|
15
|
+
|
|
16
|
+
const SCOPES = ["openid", "profile", "email", "offline_access"] as const;
|
|
17
|
+
|
|
18
|
+
export const AUTHORIZE_URL = `${AUTH0_DOMAIN}/authorize`;
|
|
19
|
+
export const TOKEN_URL = `${AUTH0_DOMAIN}/oauth/token`;
|
|
20
|
+
|
|
21
|
+
/** The loopback redirect URI Auth0 calls back with the authorization code. */
|
|
22
|
+
export function callbackUrl(): string {
|
|
23
|
+
return `http://localhost:${CALLBACK_PORT}${CALLBACK_PATH}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Build the Auth0 /authorize URL for the PKCE authorization-code flow.
|
|
28
|
+
* `prompt=login` forces the login page even with an active session, enabling
|
|
29
|
+
* account switching.
|
|
30
|
+
*/
|
|
31
|
+
export function buildAuthorizeUrl(params: { state: string; codeChallenge: string }): string {
|
|
32
|
+
const url = new URL(AUTHORIZE_URL);
|
|
33
|
+
url.searchParams.set("response_type", "code");
|
|
34
|
+
url.searchParams.set("client_id", CLIENT_ID);
|
|
35
|
+
url.searchParams.set("redirect_uri", callbackUrl());
|
|
36
|
+
url.searchParams.set("scope", SCOPES.join(" "));
|
|
37
|
+
url.searchParams.set("audience", AUDIENCE);
|
|
38
|
+
url.searchParams.set("state", params.state);
|
|
39
|
+
url.searchParams.set("code_challenge", params.codeChallenge);
|
|
40
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
41
|
+
url.searchParams.set("prompt", "login");
|
|
42
|
+
return url.toString();
|
|
43
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// A short-lived loopback HTTP server that receives Auth0's redirect carrying
|
|
2
|
+
// the authorization code. Lifecycle: new -> start -> waitForCallback -> shutdown.
|
|
3
|
+
|
|
4
|
+
import { createServer, type IncomingMessage, type Server, type ServerResponse } from "node:http";
|
|
5
|
+
import { CliExitError, ExitCode } from "../errors/index.js";
|
|
6
|
+
import { HOLDING_PAGE, renderErrorPage, SUCCESS_PAGE } from "./pages.js";
|
|
7
|
+
|
|
8
|
+
export interface CallbackResult {
|
|
9
|
+
readonly code: string;
|
|
10
|
+
readonly state: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Settler = {
|
|
14
|
+
resolve(result: CallbackResult): void;
|
|
15
|
+
reject(error: Error): void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export class CallbackServer {
|
|
19
|
+
private server?: Server;
|
|
20
|
+
private settler?: Settler;
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
private readonly port: number,
|
|
24
|
+
private readonly path: string,
|
|
25
|
+
) {}
|
|
26
|
+
|
|
27
|
+
/** Bind and listen on 127.0.0.1, reporting a clear error if the port is taken. */
|
|
28
|
+
start(): Promise<void> {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
const server = createServer((req, res) => this.handle(req, res));
|
|
31
|
+
server.once("error", (err) => {
|
|
32
|
+
reject(
|
|
33
|
+
new CliExitError(
|
|
34
|
+
`failed to start the login callback server on port ${this.port} (is it already in use?): ${err.message}`,
|
|
35
|
+
ExitCode.General,
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
server.listen(this.port, "127.0.0.1", () => {
|
|
40
|
+
this.server = server;
|
|
41
|
+
resolve();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Resolve when the OAuth callback arrives; reject on error or timeout. */
|
|
47
|
+
waitForCallback(timeoutMs: number): Promise<CallbackResult> {
|
|
48
|
+
return new Promise<CallbackResult>((resolve, reject) => {
|
|
49
|
+
const timer = setTimeout(() => {
|
|
50
|
+
reject(new CliExitError("timed out waiting for authentication — please try again", ExitCode.General));
|
|
51
|
+
}, timeoutMs);
|
|
52
|
+
this.settler = {
|
|
53
|
+
resolve: (result) => {
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
resolve(result);
|
|
56
|
+
},
|
|
57
|
+
reject: (error) => {
|
|
58
|
+
clearTimeout(timer);
|
|
59
|
+
reject(error);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async shutdown(): Promise<void> {
|
|
66
|
+
const server = this.server;
|
|
67
|
+
if (server === undefined) return;
|
|
68
|
+
await new Promise<void>((resolve) => server.close(() => resolve()));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private handle(req: IncomingMessage, res: ServerResponse): void {
|
|
72
|
+
const url = new URL(req.url ?? "/", `http://localhost:${this.port}`);
|
|
73
|
+
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
74
|
+
|
|
75
|
+
if (url.pathname !== this.path) {
|
|
76
|
+
res.end(HOLDING_PAGE);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const errorCode = url.searchParams.get("error");
|
|
81
|
+
if (errorCode !== null) {
|
|
82
|
+
const description = url.searchParams.get("error_description") ?? "";
|
|
83
|
+
const message =
|
|
84
|
+
errorCode === "access_denied" ? "You cancelled the login process." : "Authentication was cancelled or denied.";
|
|
85
|
+
res.end(renderErrorPage(message, errorCode, description));
|
|
86
|
+
this.settler?.reject(
|
|
87
|
+
new CliExitError(`authentication failed: ${errorCode}${description ? ` — ${description}` : ""}`, ExitCode.Auth),
|
|
88
|
+
);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const code = url.searchParams.get("code");
|
|
93
|
+
if (code === null || code === "") {
|
|
94
|
+
res.end(
|
|
95
|
+
renderErrorPage("No authorization code received.", "missing_code", "The callback did not contain a code."),
|
|
96
|
+
);
|
|
97
|
+
this.settler?.reject(new CliExitError("callback did not contain an authorization code", ExitCode.Auth));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
res.end(SUCCESS_PAGE);
|
|
102
|
+
this.settler?.resolve({ code, state: url.searchParams.get("state") ?? "" });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Public surface of the auth module.
|
|
2
|
+
|
|
3
|
+
export { AUDIENCE, AUTH0_DOMAIN, buildAuthorizeUrl, callbackUrl, CLIENT_ID } from "./auth0.js";
|
|
4
|
+
export { login } from "./login.js";
|
|
5
|
+
export { challengeS256, generateState, generateVerifier } from "./pkce.js";
|
|
6
|
+
export { createRefreshingTokenProvider, exchangeCode, refreshAccessToken, type TokenSet } from "./token.js";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Browser-based PKCE OAuth login orchestration.
|
|
2
|
+
//
|
|
3
|
+
// Flow:
|
|
4
|
+
// 1. Start a loopback server to receive the Auth0 callback.
|
|
5
|
+
// 2. Open the browser to /authorize with a PKCE code_challenge.
|
|
6
|
+
// 3. Wait for the redirect carrying the authorization code (5-min timeout).
|
|
7
|
+
// 4. Validate the state parameter (CSRF), then exchange code -> tokens.
|
|
8
|
+
// 5. Persist tokens and switch the backend to cloud mode.
|
|
9
|
+
//
|
|
10
|
+
// Progress goes to stderr; the command layer renders the final result.
|
|
11
|
+
|
|
12
|
+
import open from "open";
|
|
13
|
+
import { load, save } from "../config/index.js";
|
|
14
|
+
import { CliExitError, ExitCode } from "../errors/index.js";
|
|
15
|
+
import { log } from "../logger.js";
|
|
16
|
+
import { buildAuthorizeUrl, CALLBACK_PATH, CALLBACK_PORT } from "./auth0.js";
|
|
17
|
+
import { CallbackServer } from "./callback-server.js";
|
|
18
|
+
import { challengeS256, generateState, generateVerifier } from "./pkce.js";
|
|
19
|
+
import { exchangeCode } from "./token.js";
|
|
20
|
+
|
|
21
|
+
const LOGIN_TIMEOUT_MS = 5 * 60 * 1000;
|
|
22
|
+
|
|
23
|
+
export async function login(): Promise<void> {
|
|
24
|
+
const verifier = generateVerifier();
|
|
25
|
+
const codeChallenge = challengeS256(verifier);
|
|
26
|
+
const state = generateState();
|
|
27
|
+
|
|
28
|
+
const server = new CallbackServer(CALLBACK_PORT, CALLBACK_PATH);
|
|
29
|
+
await server.start();
|
|
30
|
+
try {
|
|
31
|
+
const authUrl = buildAuthorizeUrl({ state, codeChallenge });
|
|
32
|
+
process.stderr.write("Opening browser for authentication...\n");
|
|
33
|
+
process.stderr.write(`If the browser doesn't open automatically, visit:\n${authUrl}\n\n`);
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
await open(authUrl);
|
|
37
|
+
} catch (err) {
|
|
38
|
+
log.debug(`failed to open browser automatically: ${(err as Error).message}`);
|
|
39
|
+
process.stderr.write("Could not open the browser automatically. Please open the URL above.\n");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const callback = await server.waitForCallback(LOGIN_TIMEOUT_MS);
|
|
43
|
+
if (callback.state !== state) {
|
|
44
|
+
throw new CliExitError("OAuth state mismatch — possible CSRF attack, aborting login", ExitCode.Auth);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const tokens = await exchangeCode({ code: callback.code, codeVerifier: verifier });
|
|
48
|
+
|
|
49
|
+
const config = load();
|
|
50
|
+
config.backend.type = "cloud";
|
|
51
|
+
config.backend.cloud = {
|
|
52
|
+
...config.backend.cloud,
|
|
53
|
+
token: tokens.accessToken,
|
|
54
|
+
refresh_token: tokens.refreshToken,
|
|
55
|
+
token_expiry: tokens.expiresAt,
|
|
56
|
+
};
|
|
57
|
+
save(config);
|
|
58
|
+
} finally {
|
|
59
|
+
await server.shutdown();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Minimal HTML pages served by the loopback callback server. Self-contained
|
|
2
|
+
// (no external assets) so they render instantly and offline.
|
|
3
|
+
|
|
4
|
+
function page(title: string, body: string): string {
|
|
5
|
+
return `<!DOCTYPE html><html><head><meta charset="utf-8"><title>${title}</title></head><body style="font-family:system-ui,sans-serif;text-align:center;padding:60px;color:#1a1a2e">${body}</body></html>`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Shown briefly while the user authenticates (only seen on direct navigation). */
|
|
9
|
+
export const HOLDING_PAGE = page("Stigmer CLI", "<h2>Stigmer CLI</h2><p>Waiting for authentication…</p>");
|
|
10
|
+
|
|
11
|
+
/** Shown after a successful login; the user can close the tab and return to the CLI. */
|
|
12
|
+
export const SUCCESS_PAGE = page(
|
|
13
|
+
"Stigmer CLI — Success",
|
|
14
|
+
"<h2>✓ Authentication successful</h2><p>You can close this tab and return to your terminal.</p>",
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
/** Shown when Auth0 redirects with an error or no code. */
|
|
18
|
+
export function renderErrorPage(message: string, code: string, description: string): string {
|
|
19
|
+
return page(
|
|
20
|
+
"Stigmer CLI — Error",
|
|
21
|
+
`<h2>✗ Authentication failed</h2><p>${escapeHtml(message)}</p><p style="color:#888;font-size:0.9em">${escapeHtml(code)}${description ? `: ${escapeHtml(description)}` : ""}</p>`,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function escapeHtml(s: string): string {
|
|
26
|
+
return s
|
|
27
|
+
.replace(/&/g, "&")
|
|
28
|
+
.replace(/</g, "<")
|
|
29
|
+
.replace(/>/g, ">")
|
|
30
|
+
.replace(/"/g, """);
|
|
31
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { buildAuthorizeUrl } from "./auth0.js";
|
|
4
|
+
import { challengeS256, generateState, generateVerifier } from "./pkce.js";
|
|
5
|
+
|
|
6
|
+
describe("PKCE helpers", () => {
|
|
7
|
+
it("generates a base64url verifier with no padding", () => {
|
|
8
|
+
const verifier = generateVerifier();
|
|
9
|
+
expect(verifier).toMatch(/^[A-Za-z0-9_-]+$/);
|
|
10
|
+
expect(verifier).not.toContain("=");
|
|
11
|
+
expect(verifier.length).toBeGreaterThanOrEqual(43);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("derives the S256 challenge as base64url(sha256(verifier))", () => {
|
|
15
|
+
const verifier = "fixed-verifier-value";
|
|
16
|
+
const expected = createHash("sha256").update(verifier).digest("base64url");
|
|
17
|
+
expect(challengeS256(verifier)).toBe(expected);
|
|
18
|
+
expect(challengeS256(verifier)).not.toContain("=");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("produces distinct random verifiers and states", () => {
|
|
22
|
+
expect(generateVerifier()).not.toBe(generateVerifier());
|
|
23
|
+
expect(generateState()).not.toBe(generateState());
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe("authorize URL", () => {
|
|
28
|
+
it("includes the PKCE challenge, S256 method, state, and prompt=login", () => {
|
|
29
|
+
const url = new URL(buildAuthorizeUrl({ state: "st", codeChallenge: "ch" }));
|
|
30
|
+
expect(url.searchParams.get("response_type")).toBe("code");
|
|
31
|
+
expect(url.searchParams.get("code_challenge")).toBe("ch");
|
|
32
|
+
expect(url.searchParams.get("code_challenge_method")).toBe("S256");
|
|
33
|
+
expect(url.searchParams.get("state")).toBe("st");
|
|
34
|
+
expect(url.searchParams.get("prompt")).toBe("login");
|
|
35
|
+
expect(url.searchParams.get("redirect_uri")).toBe("http://localhost:8088/auth/callback");
|
|
36
|
+
});
|
|
37
|
+
});
|
package/src/auth/pkce.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// PKCE (RFC 7636) helpers for the authorization-code flow.
|
|
2
|
+
//
|
|
3
|
+
// The verifier is a high-entropy random string; its SHA-256 hash (the
|
|
4
|
+
// "challenge", S256 method) is sent on /authorize, and the raw verifier is sent
|
|
5
|
+
// on /token. Auth0 checks they correspond, proving the same client that started
|
|
6
|
+
// the flow is completing it — without ever transmitting a client secret.
|
|
7
|
+
|
|
8
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
9
|
+
|
|
10
|
+
// 32 random bytes -> 43-char base64url string, within RFC 7636's 43–128 range.
|
|
11
|
+
const VERIFIER_BYTES = 32;
|
|
12
|
+
|
|
13
|
+
/** Generate a cryptographically random PKCE code_verifier (base64url). */
|
|
14
|
+
export function generateVerifier(): string {
|
|
15
|
+
return randomBytes(VERIFIER_BYTES).toString("base64url");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Derive the S256 code_challenge for a verifier: base64url(sha256(verifier)). */
|
|
19
|
+
export function challengeS256(verifier: string): string {
|
|
20
|
+
return createHash("sha256").update(verifier).digest("base64url");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Generate a random OAuth `state` value for CSRF protection. */
|
|
24
|
+
export function generateState(): string {
|
|
25
|
+
return randomBytes(VERIFIER_BYTES).toString("base64url");
|
|
26
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { mkdtempSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import type { Config } from "../config/index.js";
|
|
6
|
+
import { createRefreshingTokenProvider } from "./token.js";
|
|
7
|
+
|
|
8
|
+
// The provider persists refreshed tokens via config.save(), which writes to
|
|
9
|
+
// ~/.stigmer/config.yaml. Redirect HOME to a throwaway dir so tests never touch
|
|
10
|
+
// the developer's real config.
|
|
11
|
+
let originalHome: string | undefined;
|
|
12
|
+
|
|
13
|
+
function cloudConfig(overrides: Partial<NonNullable<Config["backend"]["cloud"]>>): Config {
|
|
14
|
+
return { backend: { type: "cloud", cloud: { endpoint: "api.stigmer.ai:443", ...overrides } } };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function mockFetch(response: { ok: boolean; status?: number; body: unknown }): void {
|
|
18
|
+
vi.stubGlobal(
|
|
19
|
+
"fetch",
|
|
20
|
+
vi.fn(async () => ({
|
|
21
|
+
ok: response.ok,
|
|
22
|
+
status: response.status ?? (response.ok ? 200 : 400),
|
|
23
|
+
json: async () => response.body,
|
|
24
|
+
})),
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
originalHome = process.env.HOME;
|
|
30
|
+
process.env.HOME = mkdtempSync(join(tmpdir(), "stigmer-token-"));
|
|
31
|
+
delete process.env.STIGMER_API_KEY;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
if (originalHome === undefined) delete process.env.HOME;
|
|
36
|
+
else process.env.HOME = originalHome;
|
|
37
|
+
vi.unstubAllGlobals();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe("createRefreshingTokenProvider", () => {
|
|
41
|
+
it("returns STIGMER_API_KEY without refreshing", async () => {
|
|
42
|
+
process.env.STIGMER_API_KEY = "env-key";
|
|
43
|
+
const fetchSpy = vi.fn();
|
|
44
|
+
vi.stubGlobal("fetch", fetchSpy);
|
|
45
|
+
const provider = createRefreshingTokenProvider(cloudConfig({ token: "stale", token_expiry: past() }));
|
|
46
|
+
expect(await provider()).toBe("env-key");
|
|
47
|
+
expect(fetchSpy).not.toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("returns a non-expired token without refreshing", async () => {
|
|
51
|
+
const fetchSpy = vi.fn();
|
|
52
|
+
vi.stubGlobal("fetch", fetchSpy);
|
|
53
|
+
const provider = createRefreshingTokenProvider(cloudConfig({ token: "good", token_expiry: future() }));
|
|
54
|
+
expect(await provider()).toBe("good");
|
|
55
|
+
expect(fetchSpy).not.toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("refreshes an expired token and persists the new one", async () => {
|
|
59
|
+
mockFetch({ ok: true, body: { access_token: "fresh", refresh_token: "r2", expires_in: 3600 } });
|
|
60
|
+
const config = cloudConfig({ token: "expired", token_expiry: past(), refresh_token: "r1" });
|
|
61
|
+
const provider = createRefreshingTokenProvider(config);
|
|
62
|
+
expect(await provider()).toBe("fresh");
|
|
63
|
+
expect(config.backend.cloud?.token).toBe("fresh");
|
|
64
|
+
expect(config.backend.cloud?.refresh_token).toBe("r2");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("falls back to the existing token when refresh fails", async () => {
|
|
68
|
+
mockFetch({ ok: false, status: 401, body: { error: "invalid_grant" } });
|
|
69
|
+
const provider = createRefreshingTokenProvider(
|
|
70
|
+
cloudConfig({ token: "expired", token_expiry: past(), refresh_token: "r1" }),
|
|
71
|
+
);
|
|
72
|
+
expect(await provider()).toBe("expired");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("returns null in cloud mode with no credentials", async () => {
|
|
76
|
+
const provider = createRefreshingTokenProvider(cloudConfig({}));
|
|
77
|
+
expect(await provider()).toBeNull();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("treats a token without an expiry as valid (legacy)", async () => {
|
|
81
|
+
const fetchSpy = vi.fn();
|
|
82
|
+
vi.stubGlobal("fetch", fetchSpy);
|
|
83
|
+
const provider = createRefreshingTokenProvider(cloudConfig({ token: "legacy" }));
|
|
84
|
+
expect(await provider()).toBe("legacy");
|
|
85
|
+
expect(fetchSpy).not.toHaveBeenCalled();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
function past(): string {
|
|
90
|
+
return new Date(Date.now() - 10 * 60 * 1000).toISOString();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function future(): string {
|
|
94
|
+
return new Date(Date.now() + 60 * 60 * 1000).toISOString();
|
|
95
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Auth0 token operations: exchange an authorization code for tokens, refresh an
|
|
2
|
+
// expired access token, and expose a token provider that refreshes silently.
|
|
3
|
+
|
|
4
|
+
import type { TokenProvider } from "@stigmer/sdk";
|
|
5
|
+
import { type Config, save } from "../config/index.js";
|
|
6
|
+
import { CliExitError, ExitCode } from "../errors/index.js";
|
|
7
|
+
import { CLIENT_ID, callbackUrl, TOKEN_URL } from "./auth0.js";
|
|
8
|
+
|
|
9
|
+
/** Normalized result of an Auth0 token endpoint call. */
|
|
10
|
+
export interface TokenSet {
|
|
11
|
+
readonly accessToken: string;
|
|
12
|
+
/** Present when `offline_access` was granted; may rotate on refresh. */
|
|
13
|
+
readonly refreshToken?: string;
|
|
14
|
+
/** Absolute expiry as an RFC 3339 string, derived from `expires_in`. */
|
|
15
|
+
readonly expiresAt?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Refresh this many ms before the real expiry so an in-flight request never
|
|
19
|
+
// races the token going stale.
|
|
20
|
+
const EXPIRY_SKEW_MS = 60_000;
|
|
21
|
+
|
|
22
|
+
interface Auth0TokenResponse {
|
|
23
|
+
access_token?: string;
|
|
24
|
+
refresh_token?: string;
|
|
25
|
+
expires_in?: number;
|
|
26
|
+
error?: string;
|
|
27
|
+
error_description?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Exchange a PKCE authorization code for an access (+refresh) token. */
|
|
31
|
+
export async function exchangeCode(params: { code: string; codeVerifier: string }): Promise<TokenSet> {
|
|
32
|
+
return postToken({
|
|
33
|
+
grant_type: "authorization_code",
|
|
34
|
+
client_id: CLIENT_ID,
|
|
35
|
+
code: params.code,
|
|
36
|
+
redirect_uri: callbackUrl(),
|
|
37
|
+
code_verifier: params.codeVerifier,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Exchange a refresh token for a fresh access token. */
|
|
42
|
+
export async function refreshAccessToken(refreshToken: string): Promise<TokenSet> {
|
|
43
|
+
return postToken({
|
|
44
|
+
grant_type: "refresh_token",
|
|
45
|
+
client_id: CLIENT_ID,
|
|
46
|
+
refresh_token: refreshToken,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* A token provider for the backend client that keeps the access token fresh.
|
|
52
|
+
*
|
|
53
|
+
* Precedence and behavior, evaluated per request:
|
|
54
|
+
* 1. STIGMER_API_KEY (env / bridged --api-key) wins and is never refreshed.
|
|
55
|
+
* 2. A non-expired access token is returned as-is.
|
|
56
|
+
* 3. An expired token with a refresh token is refreshed; the new token,
|
|
57
|
+
* rotated refresh token, and expiry are persisted, then returned.
|
|
58
|
+
* 4. Otherwise the (possibly stale) token or null is returned, letting the
|
|
59
|
+
* server reject it so the error maps to a clear "please log in" exit.
|
|
60
|
+
*
|
|
61
|
+
* Closes over `config` so a refresh updates the same object the rest of the
|
|
62
|
+
* command sees, and writes it through to disk.
|
|
63
|
+
*/
|
|
64
|
+
export function createRefreshingTokenProvider(config: Config): TokenProvider {
|
|
65
|
+
return async (): Promise<string | null> => {
|
|
66
|
+
const envKey = process.env.STIGMER_API_KEY;
|
|
67
|
+
if (envKey !== undefined && envKey !== "") return envKey;
|
|
68
|
+
|
|
69
|
+
const cloud = config.backend.cloud;
|
|
70
|
+
if (cloud?.token === undefined || cloud.token === "") {
|
|
71
|
+
return cloud?.refresh_token ? refreshAndPersist(config, cloud.refresh_token) : null;
|
|
72
|
+
}
|
|
73
|
+
if (!isExpired(cloud.token_expiry)) return cloud.token;
|
|
74
|
+
if (cloud.refresh_token === undefined || cloud.refresh_token === "") return cloud.token;
|
|
75
|
+
return refreshAndPersist(config, cloud.refresh_token);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function refreshAndPersist(config: Config, refreshToken: string): Promise<string | null> {
|
|
80
|
+
let next: TokenSet;
|
|
81
|
+
try {
|
|
82
|
+
next = await refreshAccessToken(refreshToken);
|
|
83
|
+
} catch {
|
|
84
|
+
// Refresh failed (revoked/expired refresh token). Fall back to the current
|
|
85
|
+
// token if any; the server will reject it and the user is prompted to log in.
|
|
86
|
+
return config.backend.cloud?.token ?? null;
|
|
87
|
+
}
|
|
88
|
+
const cloud = config.backend.cloud ?? {};
|
|
89
|
+
cloud.token = next.accessToken;
|
|
90
|
+
if (next.refreshToken !== undefined) cloud.refresh_token = next.refreshToken;
|
|
91
|
+
cloud.token_expiry = next.expiresAt;
|
|
92
|
+
config.backend.cloud = cloud;
|
|
93
|
+
save(config);
|
|
94
|
+
return next.accessToken;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function isExpired(expiresAt: string | undefined): boolean {
|
|
98
|
+
// Legacy tokens persisted without an expiry are assumed valid; the server is
|
|
99
|
+
// the ultimate authority and a 401 triggers re-login.
|
|
100
|
+
if (expiresAt === undefined || expiresAt === "") return false;
|
|
101
|
+
const expiryMs = Date.parse(expiresAt);
|
|
102
|
+
if (Number.isNaN(expiryMs)) return false;
|
|
103
|
+
return Date.now() >= expiryMs - EXPIRY_SKEW_MS;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function postToken(form: Record<string, string>): Promise<TokenSet> {
|
|
107
|
+
let response: Response;
|
|
108
|
+
try {
|
|
109
|
+
response = await fetch(TOKEN_URL, {
|
|
110
|
+
method: "POST",
|
|
111
|
+
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
112
|
+
body: new URLSearchParams(form).toString(),
|
|
113
|
+
});
|
|
114
|
+
} catch (err) {
|
|
115
|
+
throw new CliExitError(
|
|
116
|
+
`failed to reach the authentication server: ${(err as Error).message}`,
|
|
117
|
+
ExitCode.Connection,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const body = (await response.json().catch(() => ({}))) as Auth0TokenResponse;
|
|
122
|
+
if (!response.ok || body.access_token === undefined) {
|
|
123
|
+
const detail = body.error_description ?? body.error ?? `HTTP ${response.status}`;
|
|
124
|
+
throw new CliExitError(`authentication failed: ${detail}`, ExitCode.Auth);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
accessToken: body.access_token,
|
|
129
|
+
refreshToken: body.refresh_token,
|
|
130
|
+
expiresAt:
|
|
131
|
+
body.expires_in !== undefined
|
|
132
|
+
? new Date(Date.now() + body.expires_in * 1000).toISOString()
|
|
133
|
+
: undefined,
|
|
134
|
+
};
|
|
135
|
+
}
|