@ductape/cli 0.5.9 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6,7 +6,6 @@ import path from 'node:path';
6
6
  import { runLogin } from './commands/login.js';
7
7
  import { runLogout } from './commands/logout.js';
8
8
  import { runWhoami } from './commands/whoami.js';
9
- import { runTroubleshoot } from './commands/troubleshoot.js';
10
9
  import { runDoctor } from './commands/doctor.js';
11
10
  import { runProfilesList, runProfilesUse } from './commands/profiles.js';
12
11
  import { runLink } from './commands/link.js';
@@ -20,7 +19,6 @@ import { runDb, runDbActions, runDbContext } from './commands/db.js';
20
19
  import { runComponentActions } from './commands/component-actions.js';
21
20
  import { runDbMigrate, runDbMigrateStatus, runDbMigrateRollback, runDbMigrateBaseline } from './commands/db-migrate.js';
22
21
  import { runFeaturesSync, runFeaturesValidate } from './commands/features-sync.js';
23
- import { runUiAdd, runUiCheck, runUiCreate, runUiDeprecate, runUiInspect, runUiInstall, runUiList, runUiPack, runUiPublish, runUiRemove, runUiUndeprecate, runUiUpdate, runUiValidate, runUiVerify } from './commands/ui.js';
24
22
  import { runSessionsValidate } from './commands/sessions-validate.js';
25
23
  import { runRateLimits } from './commands/rate-limits.js';
26
24
  import { runDeploy } from './commands/deploy.js';
@@ -35,10 +33,11 @@ import { runWorkspacesCurrent, runWorkspacesList, runWorkspacesRefresh, runWorks
35
33
  import { runGeneratePayload, runGenerateSnippet } from './commands/generate.js';
36
34
  import { runCompletion } from './commands/completion.js';
37
35
  import { runProducts, runProductApps, runProductAppActions, runProductComponents, runProductEnvironments } from './commands/products.js';
38
- import { runApps, runAppVersionRename, runAppVersions } from './commands/apps.js';
36
+ import { runApps } from './commands/apps.js';
39
37
  import { runAppsImport } from './commands/apps-import.js';
40
38
  import { runAppActions } from './commands/app-actions.js';
41
39
  import { registerAppWebhooks } from './commands/app-webhooks.js';
40
+ import { registerWork } from './commands/work.js';
42
41
  import { runMarketplace } from './commands/marketplace.js';
43
42
  import { runCapabilitySearch } from './commands/capabilities.js';
44
43
  import { runApply } from './commands/apply.js';
@@ -129,13 +128,13 @@ const codeTarget = (c) => c
129
128
  .option('--product <tag>').option('--function <name>').option('--fn-version <version>').option('--env <slug>');
130
129
  remote('step-up', 'start', 'Email yourself a six-digit code for one change (a person only)', codeTarget).action(op('stepup.start'));
131
130
  remote('step-up', 'verify', 'Check the code and print a grant, good for ten minutes and for that one change; put it in an environment variable and pass its name with --grant-env', (c) => codeTarget(c).requiredOption('--code <code>', 'the six-digit code from your email')).action(op('stepup.verify'));
132
- remote('plans', 'create', 'Create a plan from a JSON file; nothing is changed', (c) => c.requiredOption('--file <file>', 'Plan request JSON (Cloud Run, Azure Container Apps, and AWS Lambda services accept runtime.publicAccess: true or false with human approval; static egress uses runtime.vpcEgress on Cloud Run with optional provision: true or runtime.awsVpcEgress on Lambda or ECS Fargate)')).action(op('plans.create'));
131
+ remote('plans', 'create', 'Create a plan from a JSON file; nothing is changed', (c) => c.requiredOption('--file <file>', 'Plan request JSON (static egress uses runtime.vpcEgress on Cloud Run or runtime.awsVpcEgress on Lambda or ECS Fargate)')).action(op('plans.create'));
133
132
  remote('plans', 'approve <planId>', 'Approve a plan (a person only; refused for agents)', grantOption).action(op('plans.approve'));
134
133
  remote('plans', 'list', 'List plans with where each stands: blocked, pending_approval, approved, ready, applied or expired', (c) => c.option('--product <tag>').option('--env <env>').option('--stage <stage>')).action(op('plans.list'));
135
134
  remote('plans', 'get <planId>', 'Show one plan: what it would change, its warnings and the state of the cloud it was made from').action(op('plans.get'));
136
135
  remote('plans', 'apply <planId>', 'Apply an approved or permitted plan').action(op('plans.apply'));
137
136
  remote('deployments', 'list', 'List deployments (functions and services)', (c) => c.option('--product <tag>').option('--env <env>').option('--fn-version <version>').option('--kind <kind>', 'function or service').option('--connection <tag>', 'only what was applied through this cloud connection')).action(op('deployments.list'));
138
- remote('deployments', 'get <deploymentId>', 'Show one deployment, including functions served by each active service revision').action(op('deployments.get'));
137
+ remote('deployments', 'get <deploymentId>', 'Show one deployment').action(op('deployments.get'));
139
138
  remote('deployments', 'journal <deploymentId>', 'Show a deployment\'s journal').action(op('deployments.journal'));
140
139
  const planFromDeployment = (c) => c
141
140
  .option('--runtime-file <file>', 'Runtime settings JSON that replace the deployment\'s own (cpu, memory, minInstances, maxInstances, or Cloud Run vpcEgress with network and subnet names)')
@@ -195,15 +194,6 @@ program
195
194
  skipWorkspaceSelect: Boolean(opts.skipWorkspaceSelect),
196
195
  })));
197
196
  program.command('logout').description('Clear local credentials').action(wrap(runLogout));
198
- program
199
- .command('troubleshoot')
200
- .description('Summarize issues from logs, deployment journals and builds in the active workspace')
201
- .option('--product <tag>', 'Only this product')
202
- .option('--since <time>', 'Duration such as 24h or ISO timestamp with timezone', '24h')
203
- .option('--until <time>', 'ISO timestamp with timezone; defaults to now')
204
- .option('--max-logs <count>', 'Maximum workspace log records to inspect, 1 to 10000', '5000')
205
- .option('--json', 'Structured report with evidence and coverage')
206
- .action(wrap(runTroubleshoot));
207
197
  program
208
198
  .command('doctor')
209
199
  .description('Report CLI, SDK, MCP, API/schema, authentication, and project compatibility facts')
@@ -784,20 +774,6 @@ const apps = program
784
774
  throw new Error('Specify a verb: list | get | create | update | delete');
785
775
  return runApps(verb, opts, []);
786
776
  }));
787
- apps.command('versions')
788
- .description('Fetch lightweight version metadata without actions, webhooks or credentials')
789
- .requiredOption('--id <id>', 'App ID')
790
- .option('--profile <name>')
791
- .option('--json', 'JSON output')
792
- .action(wrap((opts) => runAppVersions(opts)));
793
- apps.command('rename-version')
794
- .description('Rename a version label atomically without changing its contents')
795
- .requiredOption('--id <id>', 'App ID')
796
- .requiredOption('--from <label>', 'Existing version label')
797
- .requiredOption('--to <label>', 'New, unused version label')
798
- .option('--profile <name>')
799
- .option('--json', 'JSON output')
800
- .action(wrap((opts) => runAppVersionRename(opts)));
801
777
  apps
802
778
  .command('import <file>')
803
779
  .description('Import Postman v2.1 or OpenAPI 3.0 into a new or existing app')
@@ -820,6 +796,7 @@ apps
820
796
  const appActions = apps.command('actions').description("An app's own actions (endpoints). resource is a path relative to each of the app's " +
821
797
  'environment base_urls (e.g. "/v1/users/{id}"), not a full URL.');
822
798
  registerAppWebhooks(apps, wrap);
799
+ registerWork(program, wrap);
823
800
  appActions
824
801
  .command('list')
825
802
  .requiredOption('--app <tag>', 'App tag')
@@ -1101,95 +1078,6 @@ db
1101
1078
  throw new Error('Specify a verb: connect | query');
1102
1079
  return runDb(verb, { file: opts.file, json: opts.json });
1103
1080
  }));
1104
- const ui = program
1105
- .command('ui')
1106
- .description('Frontend UI pieces written once in ductape/ui/ and added to any application of the workspace, which compiles them with its own bundler');
1107
- ui
1108
- .command('create <name>')
1109
- .description('Write a new UI piece under ductape/ui/<name>: manifest, component, styles and README')
1110
- .option('--framework <framework>', 'react, vue or javascript (plain DOM code any application can use)', 'react')
1111
- .option('--description <text>', 'One line saying what it is for')
1112
- .option('--json', 'JSON output')
1113
- .action(wrap((name, opts) => runUiCreate(name, opts)));
1114
- ui
1115
- .command('validate [name]')
1116
- .description('Check a UI piece (or all of them): manifest, published files, imports, secrets. Offline; changes nothing')
1117
- .option('--typecheck', 'Also type-check it with this project\'s TypeScript, React and Ductape SDK types')
1118
- .option('--json', 'JSON output')
1119
- .action(wrap((name, opts) => runUiValidate(name, { typecheck: Boolean(opts.typecheck), json: Boolean(opts.json) })));
1120
- ui
1121
- .command('pack <name>')
1122
- .description('Validate, then write the publishable artifact with its integrity hash. Offline')
1123
- .option('--out <file>', 'Where to write it (default ductape/.ui-packs/<name>@<version>.json)')
1124
- .option('--json', 'JSON output')
1125
- .action(wrap((name, opts) => runUiPack(name, { out: opts.out, json: Boolean(opts.json) })));
1126
- ui
1127
- .command('publish <name>')
1128
- .description('Validate and pack ductape/ui/<name>, then publish it to this workspace. Published versions never change')
1129
- .option('--typecheck', 'Type-check before publishing')
1130
- .option('--dry-run', 'Validate and pack, and say what would be published, without publishing')
1131
- .option('--json', 'JSON output')
1132
- .action(wrap((name, opts) => runUiPublish(name, { typecheck: Boolean(opts.typecheck), dryRun: Boolean(opts.dryRun), json: Boolean(opts.json) })));
1133
- ui
1134
- .command('list')
1135
- .description('The UI pieces published in this workspace, with their latest release')
1136
- .option('--search <text>', 'Only pieces whose name or description contains this')
1137
- .option('--json', 'JSON output')
1138
- .action(wrap((opts) => runUiList({ search: opts.search, json: Boolean(opts.json) })));
1139
- ui
1140
- .command('inspect <ref>')
1141
- .description('A piece\'s versions (name), or one version\'s manifest, requirements and files (name@version or name@latest)')
1142
- .option('--json', 'JSON output')
1143
- .action(wrap((ref, opts) => runUiInspect(ref, { json: Boolean(opts.json) })));
1144
- ui
1145
- .command('deprecate <ref>')
1146
- .description('Mark name@version deprecated. It stays installable by exact version; latest stops choosing it')
1147
- .requiredOption('--reason <text>', 'Why, shown to anyone who installs it')
1148
- .option('--replacement <version>', 'The version to use instead')
1149
- .option('--json', 'JSON output')
1150
- .action(wrap((ref, opts) => runUiDeprecate(ref, { reason: opts.reason, replacement: opts.replacement, json: Boolean(opts.json) })));
1151
- ui
1152
- .command('undeprecate <ref>')
1153
- .description('Clear the deprecation of name@version')
1154
- .option('--json', 'JSON output')
1155
- .action(wrap((ref, opts) => runUiUndeprecate(ref, { json: Boolean(opts.json) })));
1156
- ui
1157
- .command('add <ref>')
1158
- .description('Add a published piece (name, name@version or name@latest) to this application: its verified source goes in ductape/ui/installed/, pinned in ductape/ui.lock.json, importable as #ui/<name>')
1159
- .option('--ignore-peers', 'Add it even when the packages it needs are missing or the wrong version')
1160
- .option('--json', 'JSON output')
1161
- .action(wrap((ref, opts) => runUiAdd(ref, { ignorePeers: Boolean(opts.ignorePeers), json: Boolean(opts.json) })));
1162
- ui
1163
- .command('install')
1164
- .description('Make ductape/ui/installed/ and package.json match ductape/ui.lock.json, fetching exactly the pinned artifacts where files are missing or changed')
1165
- .option('--offline', 'Fetch nothing; fail if anything would need fetching')
1166
- .option('--json', 'JSON output')
1167
- .action(wrap((opts) => runUiInstall({ offline: Boolean(opts.offline), json: Boolean(opts.json) })));
1168
- ui
1169
- .command('update <name>')
1170
- .description('Move an added piece to its latest release, or to --to <version>')
1171
- .option('--to <version>', 'Exact version to move to')
1172
- .option('--ignore-peers', 'Update even when the packages it needs are missing or the wrong version')
1173
- .option('--json', 'JSON output')
1174
- .action(wrap((name, opts) => runUiUpdate(name, { to: opts.to, ignorePeers: Boolean(opts.ignorePeers), json: Boolean(opts.json) })));
1175
- ui
1176
- .command('remove <name>')
1177
- .description('Remove an added piece, and any piece it used that nothing else uses')
1178
- .option('--json', 'JSON output')
1179
- .action(wrap((name, opts) => runUiRemove(name, { json: Boolean(opts.json) })));
1180
- ui
1181
- .command('verify')
1182
- .description('Offline check for CI: installed pieces are exactly the pinned artifacts, package.json imports them, and the packages they need are installed')
1183
- .option('--skip-peers', 'Do not check the packages the pieces need')
1184
- .option('--json', 'JSON output')
1185
- .action(wrap((opts) => runUiVerify({ skipPeers: Boolean(opts.skipPeers), json: Boolean(opts.json) })));
1186
- ui
1187
- .command('check [name]')
1188
- .description('Online: does the product have the actions, features and sessions the added pieces need? Uses the linked product and environment unless given')
1189
- .option('--product <tag>', 'Product tag')
1190
- .option('--env <slug>', 'Environment slug')
1191
- .option('--json', 'JSON output')
1192
- .action(wrap((name, opts) => runUiCheck(name, { product: opts.product, env: opts.env, json: Boolean(opts.json) })));
1193
1081
  const features = program.command('features').description('Code-first Ductape Features (ductape/features/)');
1194
1082
  const sessions = program.command('sessions').description('Session lifecycle and propagation checks');
1195
1083
  sessions
@@ -1264,7 +1152,8 @@ for (const verb of ['create', 'update', 'get', 'list', 'delete', 'execute']) {
1264
1152
  program
1265
1153
  .command('secrets <verb>')
1266
1154
  .description('Workspace secrets CRUD')
1267
- .option('-k, --key <key>')
1155
+ .option('-k, --key <key>', 'The secret\'s key; with create, only the value is asked for')
1156
+ .option('--env <slug>', 'create: limit the secret to this environment (default: every environment)')
1268
1157
  .option('-f, --file <path>')
1269
1158
  .option('-i, --interactive', 'Prompt for fields (default in TTY when -f omitted)')
1270
1159
  .option('--no-interactive', 'Require -f JSON for create/update')
@@ -15,10 +15,8 @@ export class ApiClient {
15
15
  }
16
16
  async request(method, path, body, extraHeaders) {
17
17
  const url = `${this.apiUrl}${path.startsWith('/') ? path : `/${path}`}`;
18
- // Bytes (a Worker bundle) are sent as they are; everything else is JSON.
19
- const raw = body instanceof Uint8Array;
20
18
  const headers = {
21
- 'Content-Type': raw ? 'application/octet-stream' : 'application/json',
19
+ 'Content-Type': 'application/json',
22
20
  ...extraHeaders,
23
21
  };
24
22
  if (this.token) {
@@ -30,7 +28,7 @@ export class ApiClient {
30
28
  method,
31
29
  headers,
32
30
  ...(this.timeoutMs ? { signal: AbortSignal.timeout(this.timeoutMs) } : {}),
33
- body: body === undefined ? undefined : raw ? body : JSON.stringify(body),
31
+ body: body !== undefined ? JSON.stringify(body) : undefined,
34
32
  });
35
33
  }
36
34
  catch (cause) {
@@ -309,9 +309,6 @@ export const GCP_DEPLOY_CREATES = [
309
309
  ];
310
310
  export const GCP_DEPLOY_SAFETY = 'Ductape only adds resources it labels as its own (ductape_managed), never changes or reuses one it did not create, and never deletes anything, including what it created. Removing deployed resources is always your own action. Use a dedicated project if you can, so what Ductape adds is easy to see.';
311
311
  export const GCP_DEPLOY_TROUBLESHOOTING = [
312
- { problem: 'Static egress creation fails with a Compute API or IAM error', fix: 'Enable compute.googleapis.com in the connected project. Grant the connection service account the Compute permissions named in the error, then retry the deployment. The journal records the outbound IPv4 once the network is ready.' },
313
- { problem: 'Cloud Run cannot attach the VPC subnet', fix: 'Check that the subnet belongs to the selected VPC and is in the deployment region and connected project. If Google Cloud reports an IAM denial, check the principal and permission named in the error.' },
314
- { problem: 'Cloud Run starts but Atlas connections time out or fail during TLS setup', fix: 'Check that Cloud NAT serves the selected subnet and uses a reserved IPv4. Verify the actual outbound IP from the revision and allowlist it as a /32 in Atlas. If the Ductape resolver returns 502, check the integrations logs for that request separately.' },
315
312
  { problem: '"<API> has not been used in project <PROJECT_ID> before or it is disabled"', fix: 'Enable that API (step 1), wait a minute or two for it to take effect, and try again.' },
316
313
  { problem: 'Validation lists missing permissions and the roles that grant them', fix: 'Grant exactly those roles to the Ductape service account on the project (step 3) and validate again. Role changes can take a minute to apply.' },
317
314
  { problem: '"caller does not have permission to act as service account ..." when a build or deploy starts', fix: 'Grant roles/iam.serviceAccountUser to the Ductape service account on the project. Cloud Build and Cloud Run run as a service account, and the Ductape account must be allowed to act as it.' },
@@ -459,6 +456,7 @@ export const AZURE_DEPLOY_TROUBLESHOOTING = [
459
456
  export const CLOUDFLARE_DEPLOY_ROLE_LIST = [
460
457
  { role: 'Account / Workers Scripts / Edit', for: 'create Worker versions and deployments, and the placeholder that stands in until a release is checked' },
461
458
  { role: 'Account / Workers KV Storage / Edit', for: 'keep release bundles in a namespace named ductape-releases until they are deployed' },
459
+ { role: 'Account / Workers Containers / Edit', for: 'only to deploy container images (cloudflare_containers): copy them into the account\'s Cloudflare registry, prepare them and create the Container application; needs the Workers Paid plan' },
462
460
  ];
463
461
  export const CLOUDFLARE_DEPLOY_CREATES = [
464
462
  'A Workers KV namespace named ductape-releases, where each release bundle waits until it is deployed (the bundle stays in your account; Ductape keeps only its digest)',
@@ -466,15 +464,18 @@ export const CLOUDFLARE_DEPLOY_CREATES = [
466
464
  'One Worker version per release, tagged with the release hash, carrying the deployment\'s signing key as a secret binding',
467
465
  'One deployment per traffic change: Cloudflare\'s own gradual rollout, with the percentages you plan',
468
466
  'A workers.dev address for each Worker and a preview address for each version, so a release is called and checked before it takes any traffic',
467
+ 'For container images (cloudflare_containers): the image copied into registry.cloudflare.com under the account, one router Worker per deployment with a Durable Object class, one Container application, and each release\'s environment encrypted in Workers KV (only the key is a Worker secret)',
469
468
  ];
470
469
  export const CLOUDFLARE_DEPLOY_SAFETY = 'Ductape only adds resources it tags as its own (ductape_managed), never changes or reuses one it did not create, and never deletes anything, including what it created. Removing deployed Workers is always your own action. A Worker has no cloud-level access check in front of it: the function\'s own signature check, which every call must pass, is the access control. Only functions can run on Workers, not services, and only TypeScript functions.';
471
470
  export const CLOUDFLARE_DEPLOY_TROUBLESHOOTING = [
472
471
  { problem: 'Validation says the token lacks permissions', fix: 'Edit the API token and add Account / Workers Scripts / Edit and Account / Workers KV Storage / Edit, limited to this account, then validate again.' },
472
+ { problem: 'A container deploy is refused while copying the image into the Cloudflare registry ("Authentication error", 10000)', fix: 'Edit the API token and add Account / Workers Containers / Edit (under Developer Platform). The account must be on the Workers Paid plan.' },
473
+ { problem: 'The image is built for linux/arm64', fix: 'Cloudflare Containers run linux/amd64 only. Build with --platform linux/amd64, or publish a multi-platform image that includes it.' },
473
474
  { problem: '"has no workers.dev subdomain"', fix: 'Set one under Workers & Pages in the dashboard. Deployed functions are reached on it.' },
474
475
  { problem: '"not in this Cloudflare account (namespace ductape-releases)"', fix: 'Publish the bundle again with ductape deploy releases publish-worker. Releases are published through one connection and deployed through the same one.' },
475
476
  { problem: 'A plan says this release is a container image, or a Worker bundle', fix: 'A release is made of one kind of artifact. Bundles run only on cloudflare_workers targets and images only on the others.' },
476
477
  { problem: 'A plan is blocked on timeout', fix: 'A Worker is stopped after 30 seconds of CPU time. Lower the contract\'s timeout_ms, or deploy that function to Cloud Run, Lambda or Container Apps.' },
477
- { problem: 'The cloud refuses cpu, memory or instance settings', fix: 'Cloudflare manages size and scaling. Remove the runtime block from the plan.' },
478
+ { problem: 'The cloud refuses cpu, memory or instance settings', fix: 'On Workers, Cloudflare manages size and scaling: remove the runtime block. On Containers only cpu, memory and maxInstances apply; they pick the instance type and how many containers share a release.' },
478
479
  { problem: 'Cloudflare only keeps the last 100 versions', fix: 'Rolling back to a release that is older than that fails with a clear message. Publish and deploy it again.' },
479
480
  ];
480
481
  export const GCP_DEPLOY_APIS = [
@@ -562,12 +563,12 @@ export function connectionGuide(providerInput, purposeInput = 'resources') {
562
563
  if (provider === 'cloudflare' && purpose === 'deploy') {
563
564
  return {
564
565
  ...base, supported: true,
565
- summary: 'Lets Ductape deploy your TypeScript functions to Cloudflare Workers in your own account, through an API token you create and can read. Workers have no container: you publish a JavaScript bundle.',
566
+ summary: 'Lets Ductape deploy your TypeScript functions to Cloudflare Workers, and container images (services included) to Cloudflare Containers, in your own account, through an API token you create and can read. Workers have no container: you publish a JavaScript bundle. Containers take a linux/amd64 image, which Ductape copies into the account\'s Cloudflare registry.',
566
567
  steps: [
567
568
  { step: 1, who: 'you', title: 'Find your account id', notes: ['In the Cloudflare dashboard, open Workers & Pages. The account id is on the right and is 32 characters. Make sure the account has a workers.dev subdomain.'] },
568
569
  {
569
- step: 2, who: 'you', title: 'Create an API token with two permissions',
570
- notes: ['Manage Account, Account API Tokens, Create Token, Create Custom Token. Add Account / Workers Scripts / Edit and Account / Workers KV Storage / Edit, limit it to this account and create it. Cloudflare shows the token once.'],
570
+ step: 2, who: 'you', title: 'Create an API token',
571
+ notes: ['Manage Account, Account API Tokens, Create Token, Create Custom Token. Add Account / Workers Scripts / Edit and Account / Workers KV Storage / Edit. To deploy container images also add Account / Workers Containers / Edit (listed under Developer Platform); the account then needs the Workers Paid plan. Limit it to this account and create it. Cloudflare shows the token once.'],
571
572
  },
572
573
  { step: 3, who: 'you', title: 'Put the token in an environment variable', commands: ['read -s CLOUDFLARE_API_TOKEN && export CLOUDFLARE_API_TOKEN'], notes: ['This keeps the token out of the command line and shell history.'] },
573
574
  { step: 4, who: 'ductape', title: 'Create the connection', commands: ['ductape cloud connections create --provider cloudflare --name "<NAME>" --tag <TAG> --deploy'] },
@@ -580,6 +581,7 @@ export function connectionGuide(providerInput, purposeInput = 'resources') {
580
581
  next: [
581
582
  'Publish a release: ductape deploy releases publish-worker --file release.json --connection <TAG> --entry src/index.ts (or --bundle dist/index.js). The file holds product, function, version, contract, config and verification, and no image.',
582
583
  'Plan and apply as usual with a target of kind cloudflare_workers on that connection. Release, plan, approval, canary and rollback work the same as on the other clouds.',
584
+ 'For a container image: register it with ductape deploy releases register (a public image on Docker Hub or GHCR, or one already in registry.cloudflare.com under the account), then plan with a target of kind cloudflare_containers. runtime.cpu and runtime.memory pick the instance type and runtime.maxInstances how many containers share a release.',
583
585
  CLOUDFLARE_DEPLOY_SAFETY,
584
586
  ],
585
587
  };
@@ -1,6 +1,6 @@
1
1
  /** Enum values aligned with @ductape/sdk — used for CLI dropdowns */
2
2
  export declare const STORAGE_PROVIDERS: readonly ["aws", "gcp", "azure"];
3
- export declare const DATABASE_TYPES: readonly ["postgresql", "mongodb", "mysql", "redis"];
3
+ export declare const DATABASE_TYPES: readonly ["postgresql", "mongodb", "mysql"];
4
4
  export declare const GRAPH_TYPES: readonly ["neo4j", "neptune", "arangodb", "memgraph"];
5
5
  export declare const VECTOR_DB_TYPES: readonly ["pinecone", "qdrant", "weaviate", "chroma", "milvus", "pgvector", "memory"];
6
6
  export declare const VECTOR_DISTANCE_METRICS: readonly ["cosine", "euclidean", "dotproduct"];
@@ -1,6 +1,6 @@
1
1
  /** Enum values aligned with @ductape/sdk — used for CLI dropdowns */
2
2
  export const STORAGE_PROVIDERS = ['aws', 'gcp', 'azure'];
3
- export const DATABASE_TYPES = ['postgresql', 'mongodb', 'mysql', 'redis'];
3
+ export const DATABASE_TYPES = ['postgresql', 'mongodb', 'mysql'];
4
4
  export const GRAPH_TYPES = ['neo4j', 'neptune', 'arangodb', 'memgraph'];
5
5
  export const VECTOR_DB_TYPES = [
6
6
  'pinecone',
@@ -6,6 +6,7 @@ export type InteractiveOpts = {
6
6
  export declare function isInteractive(opts?: InteractiveOpts): boolean;
7
7
  export declare function promptForm(schema: FormSchema, opts?: {
8
8
  patch?: boolean;
9
+ preset?: Record<string, unknown>;
9
10
  }): Promise<Record<string, unknown>>;
10
11
  export declare function promptTag(label?: string): Promise<string>;
11
12
  export declare function promptKey(label?: string): Promise<string>;
@@ -1,5 +1,5 @@
1
- import password from '@inquirer/password';
2
1
  import input from '@inquirer/input';
2
+ import password from '@inquirer/password';
3
3
  import select from '@inquirer/select';
4
4
  import { MESSAGE_BROKER_TYPES, STORAGE_PROVIDERS } from './enums.js';
5
5
  export function isInteractive(opts) {
@@ -67,26 +67,7 @@ async function promptEnvs(variant, context) {
67
67
  message: `Environment slug #${envs.length + 1} (3 letters)`,
68
68
  validate: (v) => (v.length >= 1 && v.length <= 3 ? true : 'Use 1–3 characters'),
69
69
  });
70
- if (variant === 'database' && context?.databaseType === 'redis') {
71
- const mode = await select({ message: 'Redis connection', choices: [
72
- { name: 'Redis URL', value: 'url' }, { name: 'Import cloud instance', value: 'import' }, { name: 'Provision cloud instance', value: 'provision' },
73
- ] });
74
- if (mode === 'url')
75
- envs.push({ slug, connection_url: await password({ message: 'Redis URL (redis:// or rediss://)' }) });
76
- else {
77
- const row = { slug, cloud: await input({ message: 'Cloud connection tag' }),
78
- instance: await input({ message: 'Redis instance name or resource ID' }), region: await input({ message: 'Cloud region' }), importExisting: mode === 'import' };
79
- if (mode === 'import') {
80
- const token = await password({ message: 'AWS Redis AUTH token (leave empty for GCP/Azure or stored credentials)' });
81
- if (token)
82
- row.masterPassword = token;
83
- }
84
- else
85
- row.redis = await promptJsonObject('Redis provider settings (GCP: authorizedNetwork, memorySizeGb; AWS: cacheSubnetGroupName, securityGroupIds, nodeType; Azure: resourceGroup, sku)');
86
- envs.push(row);
87
- }
88
- }
89
- else if (variant === 'database' || variant === 'graph') {
70
+ if (variant === 'database' || variant === 'graph') {
90
71
  const connection_url = await input({
91
72
  message: 'Connection URL',
92
73
  });
@@ -165,6 +146,15 @@ async function promptField(field, patch) {
165
146
  throw new Error('envs field missing envsVariant');
166
147
  return promptEnvs(field.envsVariant);
167
148
  }
149
+ if (field.kind === 'secret') {
150
+ // Masked and never trimmed: a secret is stored exactly as typed or pasted, apart from a trailing line break.
151
+ const value = (await password({ message: field.label, mask: '*' })).replace(/\r?\n$/, '');
152
+ if (!value && !required)
153
+ return undefined;
154
+ if (!value && required)
155
+ throw new Error(`${field.label} is required`);
156
+ return value;
157
+ }
168
158
  const value = await input({
169
159
  message: field.label,
170
160
  default: field.default !== undefined ? String(field.default) : undefined,
@@ -178,9 +168,14 @@ async function promptField(field, patch) {
178
168
  export async function promptForm(schema, opts) {
179
169
  const patch = Boolean(opts?.patch);
180
170
  const body = {};
171
+ const preset = opts?.preset ?? {};
181
172
  let vectorType;
182
- let databaseType;
183
173
  for (const field of schema.fields) {
174
+ // A value already given on the command line (such as -k) is used, not asked for again.
175
+ if (preset[field.key] !== undefined && preset[field.key] !== '') {
176
+ body[field.key] = preset[field.key];
177
+ continue;
178
+ }
184
179
  if (patch && !field.required) {
185
180
  const set = await askYesNo(`Set ${field.label}?`, false);
186
181
  if (!set)
@@ -191,14 +186,9 @@ export async function promptForm(schema, opts) {
191
186
  if (value !== undefined) {
192
187
  body.type = value;
193
188
  vectorType = String(value);
194
- databaseType = String(value);
195
189
  }
196
190
  continue;
197
191
  }
198
- if (field.kind === 'envs' && field.envsVariant === 'database' && databaseType === 'redis') {
199
- body[field.key] = await promptEnvs('database', { databaseType });
200
- continue;
201
- }
202
192
  if (field.kind === 'envs' && field.envsVariant === 'vector') {
203
193
  const envs = await promptEnvs('vector', { vectorType });
204
194
  if (envs.length)
@@ -198,13 +198,13 @@ const SCHEMAS = {
198
198
  'secrets:create': {
199
199
  fields: [
200
200
  { key: 'key', label: 'Secret key', kind: 'text', required: true },
201
- { key: 'value', label: 'Secret value', kind: 'text', required: true },
201
+ { key: 'value', label: 'Secret value (hidden as you type)', kind: 'secret', required: true },
202
202
  DESC,
203
203
  ],
204
204
  },
205
205
  'secrets:update': {
206
206
  fields: optional([
207
- { key: 'value', label: 'Secret value', kind: 'text' },
207
+ { key: 'value', label: 'Secret value (hidden as you type)', kind: 'secret' },
208
208
  DESC,
209
209
  ]),
210
210
  },
@@ -1,4 +1,5 @@
1
- export type FieldKind = 'text' | 'number' | 'enum' | 'envs';
1
+ /** `secret` is typed without being shown on screen. */
2
+ export type FieldKind = 'text' | 'secret' | 'number' | 'enum' | 'envs';
2
3
  export type EnvsVariant = 'database' | 'graph' | 'storage' | 'broker' | 'vector' | 'simple';
3
4
  export interface FormField {
4
5
  key: string;
@@ -24,7 +24,6 @@ export declare function getApp(ctx: WorkspaceContext, opts: {
24
24
  tag?: string;
25
25
  }): Promise<unknown>;
26
26
  export declare function createApp(ctx: WorkspaceContext, body: Record<string, unknown>): Promise<unknown>;
27
- export declare function getAppVersions(ctx: WorkspaceContext, appId: string): Promise<unknown>;
28
27
  export declare function updateApp(ctx: WorkspaceContext, appId: string, body: Record<string, unknown>): Promise<unknown>;
29
28
  export declare function updateAppViaProxy(ctx: WorkspaceContext, tag: string, body: Record<string, unknown>): Promise<unknown>;
30
29
  export declare function deleteApp(ctx: WorkspaceContext, appId: string): Promise<unknown>;
@@ -428,19 +428,22 @@ export async function createApp(ctx, body) {
428
428
  const result = await client(ctx).post('/apps/v1/create', payload);
429
429
  return unwrapOne(result);
430
430
  }
431
- export async function getAppVersions(ctx, appId) {
432
- return unwrapOne(await client(ctx).getPath(`/apps/v1/${appId}/versions/metadata`, workspaceAuthQuery(ctx)));
433
- }
434
431
  export async function updateApp(ctx, appId, body) {
435
- const q = workspaceAuthQuery(ctx);
436
- const result = await client(ctx).put(`/apps/v1/${appId}?${new URLSearchParams(q).toString()}`, { component: 'app', ...body });
432
+ const q = {
433
+ user_id: ctx.credentials.user_id,
434
+ public_key: ctx.credentials.public_key,
435
+ };
436
+ const result = await client(ctx).put(`/apps/v1/${appId}?${new URLSearchParams(q).toString()}`, body);
437
437
  return unwrapOne(result);
438
438
  }
439
439
  export async function updateAppViaProxy(ctx, tag, body) {
440
440
  return proxy(ctx).execute('app', 'update', [tag, body]);
441
441
  }
442
442
  export async function deleteApp(ctx, appId) {
443
- const q = workspaceAuthQuery(ctx);
443
+ const q = {
444
+ user_id: ctx.credentials.user_id,
445
+ public_key: ctx.credentials.public_key,
446
+ };
444
447
  return client(ctx).delete(`/apps/v1/${appId}?${new URLSearchParams(q).toString()}`);
445
448
  }
446
449
  // —— App actions (sdk-proxy — admin op, requires access key) ——
@@ -7,5 +7,7 @@ export declare function resolveBody(opts: InteractiveOpts & {
7
7
  schema?: FormSchema;
8
8
  patch?: boolean;
9
9
  requireBody?: boolean;
10
+ /** Fields already given as flags; the form does not ask for them. */
11
+ preset?: Record<string, unknown>;
10
12
  }): Promise<Record<string, unknown> | undefined>;
11
13
  export declare function bodyRequiredHint(schemaKey?: string): string;
@@ -20,7 +20,7 @@ export async function resolveBody(opts) {
20
20
  }
21
21
  const schema = opts.schema ?? (opts.schemaKey ? getFormSchema(opts.schemaKey) : undefined);
22
22
  if (schema && isInteractive(opts)) {
23
- return promptForm(schema, { patch: opts.patch ?? opts.schemaKey?.endsWith(':update') });
23
+ return promptForm(schema, { patch: opts.patch ?? opts.schemaKey?.endsWith(':update'), preset: opts.preset });
24
24
  }
25
25
  if (opts.requireBody && isInteractive(opts) === false) {
26
26
  return undefined;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Reads the pass and fail counts from a test run's output, for the runners people use most. Only the summary lines
3
+ * are read, last one wins (a runner can print progress before its final tally). Nothing found means the counts are
4
+ * unknown; the exit code still says whether the run passed.
5
+ */
6
+ export interface ITestCounts {
7
+ passed?: number;
8
+ failed?: number;
9
+ skipped?: number;
10
+ runner?: string;
11
+ }
12
+ export declare function readTestCounts(output: string): ITestCounts;
@@ -0,0 +1,50 @@
1
+ // eslint-disable-next-line no-control-regex
2
+ const ANSI = /\u001b\[[0-9;]*[A-Za-z]/g;
3
+ const num = (s) => (s === undefined ? undefined : Number(s));
4
+ const RULES = [
5
+ // Jest: "Tests: 1 failed, 2 skipped, 40 passed, 43 total"
6
+ {
7
+ runner: 'jest',
8
+ re: /^Tests:\s+(.*\btotal)\s*$/m,
9
+ read: (m) => ({ failed: num(/(\d+) failed/.exec(m[1])?.[1]) ?? 0, skipped: num(/(\d+) skipped/.exec(m[1])?.[1]), passed: num(/(\d+) passed/.exec(m[1])?.[1]) ?? 0 }),
10
+ },
11
+ // Vitest: " Tests 2 failed | 40 passed (42)"
12
+ {
13
+ runner: 'vitest',
14
+ re: /^\s*Tests\s+(.*\(\d+\))\s*$/m,
15
+ read: (m) => ({ failed: num(/(\d+) failed/.exec(m[1])?.[1]) ?? 0, skipped: num(/(\d+) skipped/.exec(m[1])?.[1]), passed: num(/(\d+) passed/.exec(m[1])?.[1]) ?? 0 }),
16
+ },
17
+ // node:test and TAP: "# pass 48" / "# fail 0" (node:test also prints "ℹ pass 48")
18
+ {
19
+ runner: 'node-test',
20
+ re: /^(?:#|ℹ) pass (\d+)\s*$[\s\S]*?^(?:#|ℹ) fail (\d+)\s*$/m,
21
+ read: (m) => ({ passed: Number(m[1]), failed: Number(m[2]) }),
22
+ },
23
+ // Mocha: " 40 passing (2s)" then optionally " 2 failing"
24
+ {
25
+ runner: 'mocha',
26
+ re: /^\s*(\d+) passing \([^)]*\)\s*$(?:\s*^\s*(\d+) pending\s*$)?(?:\s*^\s*(\d+) failing\s*$)?/m,
27
+ read: (m) => ({ passed: Number(m[1]), skipped: num(m[2]), failed: num(m[3]) ?? 0 }),
28
+ },
29
+ // pytest: "==== 2 failed, 40 passed, 1 skipped in 3.2s ===="
30
+ {
31
+ runner: 'pytest',
32
+ re: /^=+ (.*\b(?:passed|failed)\b.*) in [\d.]+s(?: \([^)]*\))? =+\s*$/m,
33
+ read: (m) => ({ failed: num(/(\d+) failed/.exec(m[1])?.[1]) ?? 0, skipped: num(/(\d+) skipped/.exec(m[1])?.[1]), passed: num(/(\d+) passed/.exec(m[1])?.[1]) ?? 0 }),
34
+ },
35
+ ];
36
+ export function readTestCounts(output) {
37
+ const text = output.replace(ANSI, '');
38
+ let best;
39
+ for (const rule of RULES) {
40
+ const re = new RegExp(rule.re.source, rule.re.flags.includes('g') ? rule.re.flags : `${rule.re.flags}g`);
41
+ let m;
42
+ while ((m = re.exec(text))) {
43
+ if (!best || m.index >= best.at) {
44
+ const counts = Object.fromEntries(Object.entries(rule.read(m)).filter(([, v]) => v !== undefined && !Number.isNaN(v)));
45
+ best = { at: m.index, counts: { ...counts, runner: rule.runner } };
46
+ }
47
+ }
48
+ }
49
+ return best?.counts ?? {};
50
+ }
@@ -0,0 +1,37 @@
1
+ import { type AgentClient } from './work.js';
2
+ /**
3
+ * Records what Ductape made or ran on the work it was made for: a Deploy release, deployment or build, or a test run
4
+ * through `ductape work test`. The work tracker finds the item (the one the agent session, or the person in this repo,
5
+ * holds) and checks releases, deployments and builds against Deploy's own records, so nothing here is taken on trust.
6
+ *
7
+ * It never fails the command it follows: the deploy or test has already happened, and a work tracker that cannot be
8
+ * reached is no reason to report it as failed. Set DUCTAPE_WORK_RECORD=off to skip it, or DUCTAPE_WORK_ITEM=W-12 to
9
+ * name the item.
10
+ */
11
+ export interface IDeliveredArtifact {
12
+ kind: 'release' | 'deployment' | 'build' | 'test_report';
13
+ ref: string;
14
+ url?: string;
15
+ title?: string;
16
+ meta?: Record<string, string | number | boolean>;
17
+ source?: 'ductape_cli';
18
+ }
19
+ export interface IDeliveryResult {
20
+ recorded: string[];
21
+ candidates: string[];
22
+ reason?: string;
23
+ artifact?: {
24
+ kind: string;
25
+ ref: string;
26
+ title: string | null;
27
+ source: string;
28
+ };
29
+ }
30
+ /** What to tell the person after recording. Silent when there was no work to record on. */
31
+ export declare function describeDelivery(result: IDeliveryResult, artifact: IDeliveredArtifact): string | undefined;
32
+ export declare function recordOnWork(artifact: IDeliveredArtifact, opts?: {
33
+ item?: string;
34
+ quiet?: boolean;
35
+ client?: AgentClient;
36
+ session?: string;
37
+ }): Promise<IDeliveryResult | undefined>;