@cogitator-ai/deploy 0.4.8 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +66 -31
  2. package/dist/analyzer.d.ts +91 -9
  3. package/dist/analyzer.d.ts.map +1 -1
  4. package/dist/analyzer.js +573 -93
  5. package/dist/analyzer.js.map +1 -1
  6. package/dist/deployer.d.ts +15 -2
  7. package/dist/deployer.d.ts.map +1 -1
  8. package/dist/deployer.js +18 -8
  9. package/dist/deployer.js.map +1 -1
  10. package/dist/generator.d.ts +10 -2
  11. package/dist/generator.d.ts.map +1 -1
  12. package/dist/generator.js +15 -3
  13. package/dist/generator.js.map +1 -1
  14. package/dist/index.d.ts +3 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/providers/artifacts.d.ts.map +1 -1
  19. package/dist/providers/artifacts.js +2 -1
  20. package/dist/providers/artifacts.js.map +1 -1
  21. package/dist/providers/docker.d.ts +17 -0
  22. package/dist/providers/docker.d.ts.map +1 -1
  23. package/dist/providers/docker.js +63 -8
  24. package/dist/providers/docker.js.map +1 -1
  25. package/dist/providers/fly.d.ts +2 -0
  26. package/dist/providers/fly.d.ts.map +1 -1
  27. package/dist/providers/fly.js +43 -2
  28. package/dist/providers/fly.js.map +1 -1
  29. package/dist/templates/docker-compose.d.ts.map +1 -1
  30. package/dist/templates/docker-compose.js +23 -15
  31. package/dist/templates/docker-compose.js.map +1 -1
  32. package/dist/templates/dockerfile.d.ts +31 -2
  33. package/dist/templates/dockerfile.d.ts.map +1 -1
  34. package/dist/templates/dockerfile.js +144 -45
  35. package/dist/templates/dockerfile.js.map +1 -1
  36. package/dist/templates/fly-toml.d.ts.map +1 -1
  37. package/dist/templates/fly-toml.js +65 -31
  38. package/dist/templates/fly-toml.js.map +1 -1
  39. package/dist/templates/health.d.ts +9 -2
  40. package/dist/templates/health.d.ts.map +1 -1
  41. package/dist/templates/health.js +24 -2
  42. package/dist/templates/health.js.map +1 -1
  43. package/dist/utils/text.d.ts +9 -0
  44. package/dist/utils/text.d.ts.map +1 -0
  45. package/dist/utils/text.js +19 -0
  46. package/dist/utils/text.js.map +1 -0
  47. package/dist/volumes.d.ts +10 -0
  48. package/dist/volumes.d.ts.map +1 -0
  49. package/dist/volumes.js +21 -0
  50. package/dist/volumes.js.map +1 -0
  51. package/package.json +6 -4
package/README.md CHANGED
@@ -45,39 +45,40 @@ if (!result.success) throw new Error(result.error);
45
45
  console.log(result.url); // https://my-app.fly.dev
46
46
  ```
47
47
 
48
- | Method | Description |
49
- | ------------------------------------- | ---------------------------------------------------------------------------------------- |
50
- | `plan(options)` | Analyze + preflight. Returns `config`, `preflight`, `warnings`, `analysis`, `provider` |
51
- | `deploy(options)` | `plan`, generate artifacts, deploy. Returns `DeployResult` (`url`, `endpoints`, `error`) |
52
- | `status(target, config, projectDir)` | `DeployStatus` (`running`, `url`, `instances`, `uptime`) |
53
- | `destroy(target, config, projectDir)` | Tears down the deployment; throws when it fails |
54
- | `availableTargets()` | Names of registered providers (`['docker', 'fly']` by default) |
55
- | `registerProvider(provider)` | Add a custom `DeployProvider` |
56
- | `getProvider(target)` | The registered provider; throws for an unknown target |
48
+ | Method | Description |
49
+ | ----------------------------------------------- | ---------------------------------------------------------------------------------------- |
50
+ | `plan(options)` | Analyze + preflight. Returns `config`, `preflight`, `warnings`, `analysis`, `provider` |
51
+ | `deploy(options)` | `plan`, generate artifacts, deploy. Returns `DeployResult` (`url`, `endpoints`, `error`) |
52
+ | `status(target, config, projectDir, options?)` | `DeployStatus` (`running`, `url`, `instances`, `uptime`) |
53
+ | `destroy(target, config, projectDir, options?)` | Tears down the deployment, throws when it fails |
54
+ | `availableTargets()` | Names of registered providers (`['docker', 'fly']` by default) |
55
+ | `registerProvider(provider)` | Add a custom `DeployProvider` |
56
+ | `getProvider(target)` | The registered provider, throws for an unknown target |
57
57
 
58
- `DeployOptions`: `projectDir`, `target`, `dryRun` (plan and generate, then return `{ success: true, url: '(dry run)' }` without writing artifacts or deploying), `noPush` (drop the registry) and `configOverrides` (a partial `DeployConfig`). `deploy()` does not throw on failed preflight checks: it returns `{ success: false, error }` listing each failed check and its fix.
58
+ `DeployOptions`: `projectDir`, `target`, `dryRun` (plan and generate, then return `{ success: true, url: '(dry run)' }` without writing artifacts or deploying), `noPush` (drop the registry), `configOverrides` (a partial `DeployConfig`), `configPath` (the config file to read, by default the first of `cogitator.yml`, `cogitator.yaml`, `.cogitator.yml`, `.cogitator.yaml` in `projectDir`, the same lookup as `loadConfig`) and `env` (where secrets come from, by default the project's `.env` under the process environment). `status` and `destroy` take `{ configPath }` too. `deploy()` does not throw on failed preflight checks: it returns `{ success: false, error }` listing each failed check and its fix.
59
59
 
60
- `ProjectAnalyzer` (`analyze(projectDir, overrides?)`, `detectBuild(projectDir)`), `ArtifactGenerator`, `DockerProvider` and `FlyProvider` are exported for building your own pipeline.
60
+ `ProjectAnalyzer` (`analyze(projectDir, overrides?, { configPath, env }?)`, `detectBuild(projectDir)`), `ArtifactGenerator`, `DockerProvider` and `FlyProvider` are exported for building your own pipeline.
61
61
 
62
62
  ## Configuration
63
63
 
64
- Both `cogitator deploy` and the programmatic `Deployer` read the `deploy` section of the project's `cogitator.yml`. `configOverrides` win over it field by field (inside `services`, `env`, `health` and `resources` too), and both win over auto-detection:
64
+ Both `cogitator deploy` and the programmatic `Deployer` read the `deploy` section of the project's config file. `configOverrides` win over it field by field (inside `services`, `env`, `health` and `resources` too), and both win over auto-detection:
65
65
 
66
66
  ```yaml
67
67
  deploy:
68
68
  target: fly # docker | fly (default: docker)
69
- server: express # express | fastify | hono | koa (default: detected)
70
- port: 3000 # default: 3000
69
+ kind: worker # server | worker (default: detected, see below)
70
+ server: express # express | fastify | hono | koa | tetsu | next (default: detected)
71
+ port: 3000 # default: 3000 for a server, none for a worker
71
72
  image: my-agent # Docker image / Fly app name (default: package.json name)
72
73
  region: iad # Fly.io, default: iad
73
- instances: 2 # Fly.io only; docker runs one container
74
+ instances: 2 # Fly.io only, docker runs one container
74
75
  registry: ghcr.io/myorg
75
76
  services: # default: detected from the memory adapter
76
77
  redis: true
77
78
  postgres: true
78
79
  env:
79
80
  LOG_LEVEL: info
80
- secrets: # default: detected from llm.defaultModel
81
+ secrets: # default: detected, see below
81
82
  - OPENAI_API_KEY
82
83
  health: # defaults shown
83
84
  path: /cogitator/health
@@ -86,28 +87,62 @@ deploy:
86
87
  resources: # Fly.io VM, default: 256mb, 1 shared CPU
87
88
  memory: 512mb
88
89
  cpu: 1
90
+ volumes: # default: the directory of a SQLite memory database
91
+ - path: data # relative to the app directory, or absolute
92
+ size: 1 # GB, Fly.io volume size
93
+ hostGateway: true # docker: reach the host as host.docker.internal (set for a local Ollama)
89
94
  ```
90
95
 
91
- `health.path` defaults to the path the Express and Fastify adapters serve at their default `/cogitator` base path. Set it only when the adapter is mounted elsewhere (Hono, Koa and Tetsu answer wherever you mount them). Projects from `create-cogitator-app` already set it: the `api-server` template mounts the adapter at `/api` and writes `health.path: /api/health`.
96
+ ### Server or worker
97
+
98
+ `kind` decides how the app is run and checked:
99
+
100
+ - `server` answers HTTP on `port`. It gets a health check (`HEALTHCHECK`, Fly `[checks]`) and, on Fly, an HTTP service that stops idle machines and starts them on the next request. Detected from a Cogitator server adapter (`@cogitator-ai/express`, `fastify`, `hono`, `koa`, `tetsu`, `next`), Next.js or a plain HTTP framework (Express, Fastify, Hono, Koa).
101
+ - `worker` runs without serving HTTP, like a channel gateway (Telegram long polling) or a queue worker. It gets no health check, publishes `port` only when one is set, and on Fly is never stopped by the proxy (`auto_stop_machines = "off"`, no HTTP service without a port). Detected from `@cogitator-ai/channels` or `@cogitator-ai/worker`.
102
+
103
+ A project that is neither, such as a script that makes one call and exits, fails preflight: deployed, it would be restarted forever. Set `deploy.kind` when detection gets it wrong.
104
+
105
+ `health.path` defaults to the path of the detected adapter: `/cogitator/health` for Express, Fastify, Hono and Koa at their default base path, `/health` for Tetsu. Set it when the adapter is mounted elsewhere. Next.js has no health route of its own, so a server without a known path gets no health check and a warning. Projects from `create-cogitator-app` already set it: the `api-server` template mounts the adapter at `/api` and writes `health.path: /api/health`.
106
+
107
+ ### Secrets
108
+
109
+ Unless `deploy.secrets` lists them, the secrets are detected:
110
+
111
+ - what the model's provider cannot run without, routed like the runtime routes it (`meta-llama/Llama-3.3-70B-Instruct-Turbo` with `defaultProvider: together` needs `TOGETHER_API_KEY`). Azure needs the key and the endpoint, Bedrock a region and credentials. A value written in `llm.providers` counts as provided. When an alias is set instead of the main name (`GEMINI_API_KEY` for `GOOGLE_API_KEY`), the alias is passed. Optional provider settings that are set (`OPENAI_BASE_URL`, `AWS_SESSION_TOKEN`) are passed too. `PROVIDER_ENV` of `@cogitator-ai/config` is the table behind this
112
+ - the names the code passes to `requireEnv('NAME')` under `src/`
113
+ - the variables of `.env.example` that are set
114
+
115
+ When nothing is detected but the project's `.env` defines variables, preflight fails rather than deploying an app without them. List what it needs in `deploy.secrets` (an empty list deploys without any).
92
116
 
93
117
  Secrets are read from the current environment or the project's `.env` file. They are checked during preflight, passed through to the Docker Compose stack, and imported into Fly.io with `fly secrets import --stage`.
94
118
 
119
+ ### Data that outlives a deploy
120
+
121
+ A SQLite memory (`memory.adapter: sqlite`) keeps its database directory on a volume: a Docker named volume, or a Fly volume created on the first deploy and mounted through `[mounts]`. The directory is also kept out of the image, so local data never ships. A database in the project root cannot get a volume and gets a warning, move it into a directory such as `data/memory.db`. Fly machines mount one volume, more fail preflight.
122
+
123
+ ### Local Ollama
124
+
125
+ A local Ollama model on the docker target reaches the Ollama of the host: the Compose file maps `host.docker.internal` to the host and points `COGITATOR_OLLAMA_BASE_URL`, `OLLAMA_BASE_URL`, `OLLAMA_URL` and `OLLAMA_HOST` at it, keeping the port of your local URL. On Linux, Ollama must listen beyond localhost (`OLLAMA_HOST=0.0.0.0 ollama serve`). An Ollama URL that already points to another machine is passed through as it is. Other targets warn, since they have no Ollama.
126
+
95
127
  ## Auto-Detection
96
128
 
97
- | What | Source | Example |
98
- | ---------------- | ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
99
- | Server adapter | `package.json` dependencies | `@cogitator-ai/express` → Express |
100
- | Image / app name | `package.json` `name` | `@acme/My Agent` → `my-agent` (fallback `cogitator-app`) |
101
- | Package manager | Lockfile | `pnpm-lock.yaml` → `pnpm install --frozen-lockfile`, `yarn.lock` → `yarn install --frozen-lockfile`, `package-lock.json` → `npm ci`, none → `npm install` |
102
- | Start command | `scripts.start`, then `main` | `node dist/index.js` → `CMD ["node","dist/index.js"]`, any other script → `npm start`; without both, `node dist/server.js` (TypeScript) or `node src/server.js` |
103
- | Build step | `tsconfig.json` + `scripts.build` | Multi-stage build running `<pm> run build` |
104
- | Services | `cogitator.yml` / `.yaml` memory adapter | `adapter: postgres` → PostgreSQL service |
105
- | Required secrets | `llm.defaultModel` (+ `defaultProvider`) | `openai/gpt-6.1-sol` → `OPENAI_API_KEY`; Bedrock → both AWS keys |
106
- | Ollama Cloud | Model tag `:cloud` / `-cloud` | `gpt-oss:120b-cloud` → `OLLAMA_API_KEY` |
129
+ | What | Source | Example |
130
+ | ---------------- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
131
+ | Kind and server | `package.json` dependencies | `@cogitator-ai/express` → Express server, `@cogitator-ai/channels` → worker |
132
+ | Image / app name | `package.json` `name` | `@acme/My Agent` → `my-agent` (fallback `cogitator-app`) |
133
+ | Package manager | Lockfile, `packageManager`, `pnpm-workspace.yaml` | `pnpm-lock.yaml` → `pnpm install --frozen-lockfile`, Yarn 1 → `yarn install --frozen-lockfile`, Yarn Berry → `yarn install --immutable`, `bun.lock` → `bun install`, `package-lock.json` → `npm ci` |
134
+ | Install files | Files next to `package.json` | `pnpm-workspace.yaml`, `.npmrc`, `patches/`, `.yarnrc.yml`, `.yarn/`, `bunfig.toml` are copied before the install step |
135
+ | Runtime | Start command, Bun lockfile, `@cogitator-ai/tetsu` | `bun ...` start → `oven/bun:1-alpine` image, otherwise `node:24-alpine` (with Bun added for a Bun-managed Node app) |
136
+ | Start command | `scripts.start`, then `main` | `node dist/index.js` → `CMD ["node","dist/index.js"]`, any other script → `npm start` (`yarn start`, `bun run start`) |
137
+ | Build step | `tsconfig.json` + `scripts.build` | Multi-stage build running `<pm> run build` |
138
+ | Services | Config file memory adapter | `adapter: postgres` → PostgreSQL service |
139
+ | Volumes | Config file `memory.sqlite.path` | `./data/memory.db` → volume on `/app/data` |
140
+ | Required secrets | Provider of the model, `requireEnv()`, `.env.example` | `openai/gpt-6.1-sol` → `OPENAI_API_KEY`, Bedrock → `AWS_REGION` and both AWS keys |
141
+ | Ollama Cloud | Model tag `:cloud` / `-cloud` | `gpt-oss:120b-cloud` → `OLLAMA_API_KEY` |
107
142
 
108
- Problems found during analysis (invalid config, unparsable `package.json`, missing start script, `tsconfig.json` without a `build` script, local Ollama models on cloud targets, `instances > 1` on Docker) are returned as `plan.warnings` instead of being ignored.
143
+ Preflight starts with the project checks every target shares: `package.json` exists (a `cogitator wizard` assistant has none, it runs with `cogitator up` or `cogitator daemon start`), the project is a server or a worker, the `start` script does not load a `.env` file with `--env-file` (`.env` stays out of the image, use `--env-file-if-exists`), and secrets were found. Other problems (invalid config, unparsable `package.json`, missing start script, `tsconfig.json` without a `build` script, a server without a known health path, local Ollama, Redis or Postgres on Fly, `instances > 1` on Docker) are returned as `plan.warnings`.
109
144
 
110
- The image is based on `node:22-alpine`, sets `NODE_ENV=production` and `PORT`, exposes `port` and has a `HEALTHCHECK` on `health.path`.
145
+ The image is a production build in three stages. `base` is `node:24-alpine`, or `oven/bun:1-alpine` when the start command runs `bun`. `builder` adds the native toolchain (`python3`, `make`, `g++`), installs from the lockfile with the package manager's cache in a BuildKit cache mount, runs the build and drops the dev dependencies. `runtime` copies the result, runs as the image's unprivileged user (`node` or `bun`) under `tini`, so signals reach the app and child processes are reaped, and sets `NODE_ENV=production`. A server also gets `PORT`, `EXPOSE` and a `HEALTHCHECK` on its health path. A Node app whose package manager is Bun builds on the Node image with Bun copied in and `node-gyp` installed, so native dependencies such as `better-sqlite3` compile. A `start` script of the form `node [flags] dist/index.js` becomes the `CMD` directly, without its `--env-file` flags: the container gets its environment from the deployment. `file:` and `link:` dependencies are copied in before the install step. A Yarn Berry project on Plug'n'Play (Yarn's default linker) installs its package archives into the image's `.yarn/cache`, keeps only the production ones, and starts with the PnP resolver loaded through `NODE_OPTIONS` (`.pnp.cjs`, and `.pnp.loader.mjs` for ES modules).
111
146
 
112
147
  ## Deploy Targets
113
148
 
@@ -115,13 +150,13 @@ The image is based on `node:22-alpine`, sets `NODE_ENV=production` and `PORT`, e
115
150
 
116
151
  Artifacts are written to `.cogitator/`: `Dockerfile`, `.dockerignore`, `Dockerfile.dockerignore` and `docker-compose.prod.yml`. A root `.dockerignore` is created when the project has none, so `.env` and `node_modules` never enter the image.
117
152
 
118
- `deploy` builds and tags the image (`<registry>/<image>:latest`), pushes it when a registry is configured, then runs `docker compose up -d` for the app plus the Redis/PostgreSQL services it needs (health-gated, data in named volumes). Each key appears once in the app's Compose `environment`: a `REDIS_URL` / `DATABASE_URL` in `env` replaces the bundled service URL, and one listed in `secrets` is read from your environment with the bundled URL as fallback. The result's `url` is `http://localhost:<port>`. `status` reports whether the `app` service is running; `destroy` runs `docker compose down` and keeps volumes.
153
+ `deploy` builds and tags the image (`<registry>/<image>:latest`), pushes it when a registry is configured, then runs `docker compose up -d` for the app plus the Redis/PostgreSQL services it needs (health-gated, data in named volumes). Each key appears once in the app's Compose `environment`: a `REDIS_URL` / `DATABASE_URL` in `env` replaces the bundled service URL, and one listed in `secrets` is read from your environment with the bundled URL as fallback. The app container must then keep running for a few seconds (`new DockerProvider({ startupCheckMs })`, 8 seconds by default): one that exits or restarts fails the deploy with its last log lines, so a missing secret is reported instead of a restart loop. The result's `url` is `http://localhost:<port>` for a server, a worker without a port has none. `status` reports whether the `app` service is running, `destroy` runs `docker compose down` and keeps volumes.
119
154
 
120
155
  Preflight checks: Docker installed, daemon running, Compose v2 available, registry credentials (read from the Docker config, credential helpers and stores), secrets.
121
156
 
122
157
  ### Fly.io
123
158
 
124
- Generates `.cogitator/fly.toml` (your own `fly.toml` is never overwritten) with `[env]`, HTTP checks from `health`, VM size from `resources`, and `min_machines_running` from `instances` (machines auto-stop and auto-start). `deploy` creates the app when needed, stages secrets, runs `fly deploy --config .cogitator/fly.toml --dockerfile .cogitator/Dockerfile`, and scales to `instances`; the result lists `https://<app>.fly.dev`, its health URL and the A2A agent card (`/.well-known/agent.json`). `status` reads `fly status`; `destroy` runs `fly apps destroy`. Preflight checks: `flyctl` installed, `fly auth whoami`, secrets. Works with either `flyctl` or `fly` on `PATH`.
159
+ Generates `.cogitator/fly.toml` (your own `fly.toml` is never overwritten) with `[env]`, VM size from `resources`, a `[mounts]` volume when there is one, and for a server an HTTP service with checks from `health` and `min_machines_running` from `instances` (machines auto-stop and auto-start). A worker gets no checks and is never auto-stopped. `deploy` creates the app and its volume when needed, stages secrets, runs `fly deploy --config .cogitator/fly.toml --dockerfile .cogitator/Dockerfile`, and scales to `instances`. For a server the result lists `https://<app>.fly.dev`, its health URL and the A2A agent card (`/.well-known/agent.json`). Fly runs no Redis or Postgres next to the app: with those services, `REDIS_URL` / `DATABASE_URL` become required secrets (create them with `fly redis create`, `fly postgres create` or any hosted service). `status` reads `fly status`, `destroy` runs `fly apps destroy`. Preflight checks: `flyctl` installed, `fly auth whoami`, secrets. Works with either `flyctl` or `fly` on `PATH`.
125
160
 
126
161
  ## Custom Providers
127
162
 
@@ -1,11 +1,22 @@
1
- import type { DeployConfig, DeployServer, DeployServicesConfig, DeployTarget } from '@cogitator-ai/types';
2
- export type PackageManager = 'pnpm' | 'npm' | 'yarn';
1
+ import type { DeployConfig, DeployKind, DeployServer, DeployServicesConfig, DeployTarget, PreflightCheck } from '@cogitator-ai/types';
2
+ import type { PlugAndPlay } from './templates/dockerfile.js';
3
+ /**
4
+ * The package manager a project installs with. `yarn` is Yarn 1 (classic),
5
+ * `yarn-berry` is Yarn 2 and later, which take different install flags.
6
+ */
7
+ export type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'yarn-berry' | 'bun';
3
8
  interface PackageJson {
4
9
  name?: string;
10
+ type?: string;
5
11
  main?: string;
12
+ packageManager?: string;
6
13
  scripts?: Record<string, string>;
7
14
  dependencies?: Record<string, string>;
8
15
  devDependencies?: Record<string, string>;
16
+ optionalDependencies?: Record<string, string>;
17
+ overrides?: Record<string, unknown>;
18
+ resolutions?: Record<string, unknown>;
19
+ patchedDependencies?: Record<string, string>;
9
20
  }
10
21
  /** How a project builds and starts: what the generated Dockerfile needs. */
11
22
  export interface ProjectBuild {
@@ -14,39 +25,110 @@ export interface ProjectBuild {
14
25
  hasLockfile: boolean;
15
26
  hasBuildScript: boolean;
16
27
  startCommand: string[];
28
+ /** Project files the install step reads, copied before it runs, directories with a trailing slash */
29
+ installFiles: string[];
30
+ /** Version of the package manager from the `packageManager` field, e.g. `4.5.0` */
31
+ packageManagerVersion?: string;
32
+ /** Set when Yarn installs with Plug'n'Play: no node_modules, a resolver the app has to load. */
33
+ plugAndPlay?: PlugAndPlay;
17
34
  }
18
35
  export interface AnalyzerResult extends ProjectBuild {
19
36
  server?: DeployServer;
37
+ kind?: DeployKind;
20
38
  services: DeployServicesConfig;
21
39
  secrets: string[];
22
40
  warnings: string[];
41
+ /** Project checks every target's preflight includes */
42
+ checks: PreflightCheck[];
23
43
  deployConfig: DeployConfig;
24
44
  }
45
+ export interface AnalyzeOptions {
46
+ /** Config file to read, `findConfigFile(projectDir)` by default */
47
+ configPath?: string;
48
+ /** Environment the deployment takes its secrets from, the project's `.env` under the process environment by default */
49
+ env?: NodeJS.ProcessEnv;
50
+ }
51
+ /**
52
+ * Relative paths of the local packages the install reads (`file:` and `link:`
53
+ * specs in dependencies, overrides and resolutions, and in the overrides of
54
+ * pnpm-workspace.yaml), so the image copies them before it installs.
55
+ */
56
+ export declare function localDependencySpecs(projectDir: string, pkg: PackageJson): string[];
57
+ /**
58
+ * `start` as argv when it is `node` or `bun` with flags and one script, such as
59
+ * `node --env-file-if-exists=.env dist/index.js`, and undefined for anything a
60
+ * shell would have to interpret. Flags that load `.env` are dropped: the image
61
+ * gets its environment from the deployment.
62
+ */
63
+ export declare function directCommand(start: string): string[] | undefined;
25
64
  export declare class ProjectAnalyzer {
26
65
  detectServer(pkg: PackageJson): DeployServer | undefined;
66
+ /**
67
+ * What the project runs as: a `server` when it serves HTTP through a Cogitator
68
+ * adapter or an HTTP framework, a `worker` when it runs a channel gateway or
69
+ * queue worker, undefined for anything else, such as a script that exits.
70
+ */
71
+ detectKind(pkg: PackageJson, server: DeployServer | undefined): DeployKind | undefined;
27
72
  detectServices(config: {
28
73
  memory?: {
29
74
  adapter?: string | null;
30
75
  };
31
76
  }): DeployServicesConfig;
32
- detectSecrets(model: string, defaultProvider?: string): string[];
77
+ /**
78
+ * Variables the provider of `model` cannot run without, routed the way the
79
+ * runtime routes it. Each is the variable set in `env` among the ones that
80
+ * provide the setting, else the provider's own name for it. Settings with a
81
+ * value written in `providers` (cogitator.yml) need none.
82
+ */
83
+ detectSecrets(model: string, defaultProvider?: string, env?: NodeJS.ProcessEnv, providers?: Record<string, unknown>): string[];
33
84
  isOllamaCloud(model: string): boolean;
34
85
  getDeployWarnings(model: string, target: DeployTarget, defaultProvider?: string): string[];
35
- detectPackageManager(projectDir: string): {
86
+ detectPackageManager(projectDir: string, pkg?: PackageJson): {
36
87
  packageManager: PackageManager;
37
88
  hasLockfile: boolean;
38
89
  };
39
- detectStartCommand(pkg: PackageJson, hasTypeScript: boolean): string[];
40
- private loadProjectConfig;
90
+ /**
91
+ * The command a container runs: the start script itself when it is a plain
92
+ * `node` or `bun` call, so the runtime is PID 1's direct child and gets
93
+ * signals without a package manager in between, else the package manager.
94
+ */
95
+ detectStartCommand(pkg: PackageJson, hasTypeScript: boolean, packageManager?: PackageManager): string[];
41
96
  /** How the project in `projectDir` builds and starts. */
42
97
  detectBuild(projectDir: string): ProjectBuild;
43
- private buildOf;
44
98
  /**
45
99
  * Reads the project in `projectDir` into a deploy config: what it detects,
46
- * under the `deploy` section of the project's cogitator.yml, under
100
+ * under the `deploy` section of the project's config file, under
47
101
  * `configOverrides`.
48
102
  */
49
- analyze(projectDir: string, configOverrides?: Partial<DeployConfig>): AnalyzerResult;
103
+ analyze(projectDir: string, configOverrides?: Partial<DeployConfig>, options?: AnalyzeOptions): AnalyzerResult;
104
+ private providerOf;
105
+ private envNameFor;
106
+ /** Optional settings of the model's provider set in `env`, forwarded so the app sees them too. */
107
+ private optionalProviderSecrets;
108
+ /**
109
+ * How a local Ollama is reached from the deployment. A URL that already
110
+ * points beyond this machine is forwarded. Otherwise the docker target
111
+ * reaches the host through `host.docker.internal`, and other targets warn.
112
+ */
113
+ private ollamaWiring;
114
+ private flyServiceSecrets;
115
+ private detectVolumes;
116
+ private packageJsonCheck;
117
+ private kindCheck;
118
+ private startScriptCheck;
119
+ private isPnpmMonorepo;
120
+ private loadProjectConfig;
121
+ private yamlInput;
122
+ /** `llm.providers` of the config file with every `${VAR}` reference left empty: the values written in it. */
123
+ private literalProviders;
124
+ private installFiles;
125
+ /**
126
+ * Plug'n'Play settings of a Yarn 2+ project, `undefined` when it installs
127
+ * node_modules. PnP is Yarn's default linker, and Yarn writes the ESM loader
128
+ * when it is asked to or when a workspace is an ES module.
129
+ */
130
+ detectPlugAndPlay(projectDir: string, pkg: PackageJson): PlugAndPlay | undefined;
131
+ private buildOf;
50
132
  }
51
133
  export {};
52
134
  //# sourceMappingURL=analyzer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../src/analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,YAAY,EACZ,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACb,MAAM,qBAAqB,CAAC;AA4B7B,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,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