@ductape/cli 0.4.6 → 0.4.9

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
@@ -20,6 +20,10 @@ import { runComponentActions } from './commands/component-actions.js';
20
20
  import { runDbMigrate, runDbMigrateStatus, runDbMigrateRollback, runDbMigrateBaseline } from './commands/db-migrate.js';
21
21
  import { runFeaturesSync, runFeaturesValidate } from './commands/features-sync.js';
22
22
  import { runSessionsValidate } from './commands/sessions-validate.js';
23
+ import { runRateLimits } from './commands/rate-limits.js';
24
+ import { runDeploy } from './commands/deploy.js';
25
+ import { runDeployRemote } from './commands/deploy-remote.js';
26
+ import { runDeployBuilds } from './commands/deploy-builds.js';
23
27
  import { runDbSchemaGenerate, runDbSchemaPush } from './commands/db-schema.js';
24
28
  import { runGraph } from './commands/graph.js';
25
29
  import { runSecretImportEnv, runSecrets } from './commands/secrets.js';
@@ -31,6 +35,7 @@ import { runApps } from './commands/apps.js';
31
35
  import { runAppsImport } from './commands/apps-import.js';
32
36
  import { runAppActions } from './commands/app-actions.js';
33
37
  import { runMarketplace } from './commands/marketplace.js';
38
+ import { runCapabilitySearch } from './commands/capabilities.js';
34
39
  import { runApply } from './commands/apply.js';
35
40
  import { runMigrateCodebase } from './commands/migrate-codebase.js';
36
41
  import { runMigrationReviewInit, runMigrationReviewRecord, runMigrationReviewFollowUp, runMigrationReviewExclude, runMigrationReviewParity, runMigrationReviewReopen, runMigrationReviewMove, runMigrationReviewMerge, runMigrationReviewSign, runMigrationReviewSnapshot, runMigrationReviewVerifySignature, runMigrationReviewValidate, } from './commands/migration-review.js';
@@ -65,6 +70,65 @@ function wrap(fn) {
65
70
  };
66
71
  }
67
72
  const program = new Command();
73
+ const rateLimits = program.command('rate-limits').description('Keyed request enforcement policies (not provider quotas)');
74
+ for (const operation of ['validate', 'list', 'inspect', 'sync', 'test', 'audit']) {
75
+ const command = rateLimits.command(operation + (['inspect', 'test'].includes(operation) ? ' <tag>' : ''))
76
+ .option('--dir <directory>', 'Policy JSON directory', 'ductape/rate-limits')
77
+ .option('--env <environment>', 'Runtime environment', 'dev')
78
+ .option('--workspace <id>', 'Workspace ID for Redis isolation')
79
+ .option('--product <tag>', 'Product tag for Redis isolation')
80
+ .option('--coverage <file>', 'Coverage evidence JSON for audit');
81
+ command.action(wrap((...args) => {
82
+ const withTag = ['inspect', 'test'].includes(operation);
83
+ return runRateLimits(operation, withTag ? args[0] : undefined, args[withTag ? 1 : 0]);
84
+ }));
85
+ }
86
+ const deploy = program.command('deploy').description('Plan deployments offline: nothing here contacts a cloud provider');
87
+ deploy.command('plan')
88
+ .description('Show what a deployment would do, whether the placement is allowed and whether an apply is authorised')
89
+ .requiredOption('--spec <file>', 'Plan spec JSON: desired, observed, and optionally requirements, providerLimits, policy, applier, approval')
90
+ .action(wrap((options) => runDeploy('plan', options)));
91
+ deploy.command('release-hash')
92
+ .description('Compute the identity of a release from its image digest, contract and configuration')
93
+ .requiredOption('--image <digest>', 'Image digest, sha256:<64 hex>')
94
+ .requiredOption('--contract <file>', 'Function contract JSON')
95
+ .option('--config <file>', 'Configuration JSON; secrets must be { "secret": "NAME" } references')
96
+ .action(wrap((options) => runDeploy('release-hash', options)));
97
+ // Deploy control plane (the active workspace). The offline `plan` and `release-hash` above never contact it.
98
+ const remote = (group, name, description, configure) => {
99
+ const parent = deploy.commands.find((c) => c.name() === group) ?? deploy.command(group).description(`Deploy ${group}`);
100
+ const command = parent.command(name).description(description);
101
+ configure?.(command);
102
+ return command;
103
+ };
104
+ const op = (operation) => wrap((...args) => {
105
+ const options = args[args.length - 2] ?? {};
106
+ const positional = args.slice(0, -2).filter((a) => typeof a === 'string');
107
+ return runDeployRemote(operation, { ...options, version: options.fnVersion, id: positional[0] });
108
+ });
109
+ remote('releases', 'register', 'Register an immutable release from a JSON file', (c) => c.requiredOption('--file <file>', 'Release JSON')).action(op('releases.register'));
110
+ remote('plans', 'create', 'Create a plan from a JSON file; nothing is changed', (c) => c.requiredOption('--file <file>', 'Plan request JSON')).action(op('plans.create'));
111
+ remote('plans', 'approve <planId>', 'Approve a plan (a person only; refused for agents)').action(op('plans.approve'));
112
+ remote('plans', 'apply <planId>', 'Apply an approved or permitted plan').action(op('plans.apply'));
113
+ remote('deployments', 'list', 'List deployments', (c) => c.option('--product <tag>').option('--env <env>').option('--fn-version <version>')).action(op('deployments.list'));
114
+ remote('deployments', 'get <deploymentId>', 'Show one deployment').action(op('deployments.get'));
115
+ remote('deployments', 'journal <deploymentId>', 'Show a deployment\'s journal').action(op('deployments.journal'));
116
+ remote('functions', 'list', 'List functions with their latest available version', (c) => c.option('--product <tag>')).action(op('functions.list'));
117
+ const versionTarget = (c) => c.requiredOption('--product <tag>').requiredOption('--function <name>');
118
+ remote('versions', 'list', 'List the versions of a function', versionTarget).action(op('versions.list'));
119
+ remote('versions', 'history', 'Show what happened to a version', (c) => versionTarget(c).requiredOption('--fn-version <version>')).action(op('versions.history'));
120
+ remote('versions', 'deprecate', 'Deprecate a version (existing deployments keep serving)', (c) => versionTarget(c).requiredOption('--fn-version <version>').requiredOption('--reason <text>').option('--sunset <iso-date>').option('--replacement <version>')).action(op('versions.deprecate'));
121
+ remote('versions', 'undeprecate', 'Make a deprecated version available again', (c) => versionTarget(c).requiredOption('--fn-version <version>')).action(op('versions.undeprecate'));
122
+ remote('versions', 'retire', 'Retire a deprecated version that is no longer serving (a person only; final)', (c) => versionTarget(c).requiredOption('--fn-version <version>')).action(op('versions.retire'));
123
+ remote('builds', 'create', 'Build source in your own cloud account and register a release from the image', (c) => c.requiredOption('--file <file>', 'Build JSON: productTag, functionName, version, connectionTag, region, contract, config, verification')
124
+ .option('--dir <dir>', 'Source directory (default: the current directory)')
125
+ .option('--builder <builder>', 'dockerfile (default) or buildpacks')
126
+ .option('--dockerfile <path>', 'Dockerfile inside the source (default: Dockerfile)')
127
+ .option('--context <path>', 'Build context inside the source (default: .)')
128
+ .option('--wait', 'Wait for the build to finish')
129
+ .option('--wait-minutes <n>', 'How long --wait waits (default 30)')).action(wrap((options) => runDeployBuilds('create', options)));
130
+ remote('builds', 'status <buildId>', 'Show a build').action(wrap((...args) => runDeployBuilds('status', { id: args[0] })));
131
+ remote('builds', 'list', 'List builds', (c) => c.option('--product <tag>').option('--status <status>')).action(wrap((options) => runDeployBuilds('list', options)));
68
132
  program
69
133
  .name('ductape')
70
134
  .description('Ductape CLI — local platform, auth, project linking, and resource CRUD via Workbench-compatible encrypted proxy')
@@ -591,9 +655,20 @@ productAppActions
591
655
  .requiredOption('--product <id-or-tag>', 'Product _id or tag')
592
656
  .requiredOption('--app <tag>', 'Linked app tag')
593
657
  .requiredOption('--action <tag>', 'Action tag')
658
+ .option('--env <slug>', 'Resolve the exact connected version and environment; fail closed when unavailable')
594
659
  .option('--profile <name>')
595
660
  .option('--json', 'JSON output')
596
661
  .action(wrap((opts) => runProductAppActions('get', opts)));
662
+ program.command('capabilities')
663
+ .description('Read-only reuse discovery in one product and the authenticated workspace App catalogue')
664
+ .command('search <query>')
665
+ .requiredOption('--product <tag>', 'Exact product tag to search')
666
+ .option('--env <slug>', 'Environment for exact-contract next lookups')
667
+ .option('--limit <count>', 'Maximum results, up to 100', '20')
668
+ .option('--marketplace', 'Include public marketplace candidates')
669
+ .option('--profile <name>')
670
+ .option('--json', 'JSON output')
671
+ .action(wrap((query, opts) => runCapabilitySearch(query, opts)));
597
672
  const productComponents = products
598
673
  .command('components')
599
674
  .description('Compact, non-secret product component inventory');
@@ -784,9 +859,39 @@ cloud
784
859
  .action(wrap((opts) => runCloudPreflight({ product: opts.product, file: opts.file, json: opts.json })));
785
860
  cloud
786
861
  .command('connections <verb> [id]')
787
- .option('-f, --file <path>')
788
- .option('--json', 'JSON output')
789
- .action(wrap((verb, id, opts) => runCloud('connections', verb, { id, file: opts.file, json: opts.json }, [])));
862
+ .description('Cloud connections: guide | create | complete | validate | list | fetch | update | delete. Secrets come from files or environment variables, never from flags.')
863
+ .option('-f, --file <path>', 'JSON body (flags below override it)')
864
+ .option('--provider <name>', 'aws | gcp | azure | mongodb_atlas | neo4j_aura (create, guide)')
865
+ .option('--purpose <purpose>', 'guide: "resources" (default) or "deploy"')
866
+ .option('--name <name>', 'Display name (create, update)')
867
+ .option('--tag <tag>', 'Connection tag (create)')
868
+ .option('--description <text>', 'Description (create, update)')
869
+ .option('--scopes <list>', 'Comma-separated scopes (create, update)')
870
+ .option('--auth-mode <mode>', 'iam_role | oauth | service_principal | workload_identity | api_key (create)')
871
+ .option('--deploy', 'Add the "deploy" scope so validation checks Ductape Deploy permissions (GCP, create)')
872
+ .option('--project-id <id>', 'GCP or Atlas project id (complete)')
873
+ .option('--service-account-file <path>', 'GCP service account key file; read from disk, never printed (complete)')
874
+ .option('--runtime-service-account <email>', 'GCP account the deployed services run as (complete)')
875
+ .option('--role-arn <arn>', 'AWS IAM role ARN (complete)')
876
+ .option('--tenant-id <id>', 'Azure tenant id (complete)')
877
+ .option('--subscription-id <id>', 'Azure subscription id (complete)')
878
+ .option('--client-id <id>', 'Azure client id (complete)')
879
+ .option('--client-secret-env <VAR>', 'Name of the environment variable holding the Azure client secret (complete)')
880
+ .option('--default-location <region>', 'Azure default location (complete)')
881
+ .option('--atlas-public-key <key>', 'Atlas API public key (complete)')
882
+ .option('--atlas-private-key-env <VAR>', 'Name of the environment variable holding the Atlas private key (complete)')
883
+ .option('--aura-client-id <id>', 'Aura client id (complete)')
884
+ .option('--aura-client-secret-env <VAR>', 'Name of the environment variable holding the Aura client secret (complete)')
885
+ .option('--aura-instance-id <id>', 'Aura instance id (complete)')
886
+ .option('--dry-run', 'create, complete, update: print the request that would be sent, with secrets masked, and contact nothing')
887
+ .option('--json', 'JSON output')
888
+ .action(wrap((verb, id, opts) => runCloud('connections', verb, { id, file: opts.file, json: opts.json, purpose: opts.purpose, dryRun: Boolean(opts.dryRun), connection: {
889
+ provider: opts.provider, name: opts.name, tag: opts.tag, description: opts.description, scopes: opts.scopes, authMode: opts.authMode,
890
+ deploy: opts.deploy, projectId: opts.projectId, serviceAccountFile: opts.serviceAccountFile, runtimeServiceAccount: opts.runtimeServiceAccount,
891
+ roleArn: opts.roleArn, tenantId: opts.tenantId, subscriptionId: opts.subscriptionId, clientId: opts.clientId, clientSecretEnv: opts.clientSecretEnv,
892
+ defaultLocation: opts.defaultLocation, atlasPublicKey: opts.atlasPublicKey, atlasPrivateKeyEnv: opts.atlasPrivateKeyEnv,
893
+ auraClientId: opts.auraClientId, auraClientSecretEnv: opts.auraClientSecretEnv, auraInstanceId: opts.auraInstanceId,
894
+ } }, [])));
790
895
  cloud
791
896
  .command('resources <verb>')
792
897
  .option('-f, --file <path>')
@@ -43,8 +43,12 @@ export class ApiClient {
43
43
  mutationState: mutating ? 'unknown' : 'not_attempted',
44
44
  });
45
45
  if (!res.ok) {
46
- const msg = parsed.message ??
47
- parsed.error ??
46
+ // Integrations routes answer { status:false, meta:{ code }, errors:"explanation" }; keep that text and code.
47
+ const body = parsed;
48
+ const detail = typeof body.errors === 'string' ? body.errors : undefined;
49
+ const msg = body.message ??
50
+ body.error ??
51
+ (detail ? `${detail}${body.meta?.code ? ` [${body.meta.code}]` : ''}` : undefined) ??
48
52
  `HTTP ${res.status}`;
49
53
  throw new DuctapeOperationError(msg, {
50
54
  code: 'HTTP_ERROR', operation: `${method.toUpperCase()} ${path.split('?')[0]}`,
@@ -0,0 +1,35 @@
1
+ import { discoverMarketplaceApps, getProduct, listApps, listAppActions, listProductAppActions } from './platform-api.js';
2
+ import type { WorkspaceContext } from './workspace-context.js';
3
+ type RecordValue = Record<string, unknown>;
4
+ export declare const capabilitySearchSources: {
5
+ discoverMarketplaceApps: typeof discoverMarketplaceApps;
6
+ getProduct: typeof getProduct;
7
+ listApps: typeof listApps;
8
+ listAppActions: typeof listAppActions;
9
+ listProductAppActions: typeof listProductAppActions;
10
+ };
11
+ export type CapabilitySearchSources = typeof capabilitySearchSources;
12
+ export declare function searchCapabilities(ctx: WorkspaceContext, opts: {
13
+ product: string;
14
+ env?: string;
15
+ query: string;
16
+ limit?: number;
17
+ marketplace?: boolean;
18
+ }, sources?: CapabilitySearchSources): Promise<{
19
+ items: RecordValue[];
20
+ workspace_id: string;
21
+ product_tag: string;
22
+ total_matches_in_scanned_inventories: number;
23
+ returned_count: number;
24
+ truncated: boolean;
25
+ partial: boolean;
26
+ next_cursor: null;
27
+ coverage: RecordValue[];
28
+ limits: {
29
+ maximum_app_action_reads: number;
30
+ maximum_items_per_inventory: number;
31
+ maximum_total_inventory_items: number;
32
+ };
33
+ limitations: string[];
34
+ }>;
35
+ export {};
@@ -0,0 +1,180 @@
1
+ import { discoverMarketplaceApps, getProduct, listApps, listAppActions, listProductAppActions } from './platform-api.js';
2
+ const record = (value) => value && typeof value === 'object' && !Array.isArray(value) ? value : {};
3
+ const text = (value) => typeof value === 'string' && value.trim() ? value : undefined;
4
+ export const capabilitySearchSources = { discoverMarketplaceApps, getProduct, listApps, listAppActions, listProductAppActions };
5
+ export async function searchCapabilities(ctx, opts, sources = capabilitySearchSources) {
6
+ const terms = [...new Set(opts.query.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean))];
7
+ if (!terms.length)
8
+ throw new Error('Capability search requires at least one searchable query term');
9
+ const limit = Number.isFinite(opts.limit) ? Math.max(1, Math.min(Math.floor(opts.limit), 100)) : 20;
10
+ const coverage = [];
11
+ const candidates = [];
12
+ const seen = new Set();
13
+ const maxApps = 20;
14
+ const maxItemsPerInventory = 500;
15
+ const maxTotalItems = 2000;
16
+ let totalScanned = 0;
17
+ let appReads = 0;
18
+ const add = (kind, value, identifiers, provenance, nextLookup) => {
19
+ const item = record(value);
20
+ const tag = text(item.tag) ?? text(item.name) ?? text(item.namespace);
21
+ if (!tag)
22
+ return;
23
+ const key = JSON.stringify([kind, identifiers]);
24
+ if (seen.has(key))
25
+ return;
26
+ seen.add(key);
27
+ if (item.deleted === true)
28
+ return;
29
+ const searchable = [tag, text(item.name), text(item.app_name), text(item.description), ...Object.values(identifiers)].join(' ').toLowerCase();
30
+ const matched = terms.filter(term => searchable.includes(term));
31
+ if (!matched.length)
32
+ return;
33
+ candidates.push({
34
+ kind, tag, name: text(item.name) ?? text(item.app_name), description: text(item.description),
35
+ identifiers, provenance, match: { score: matched.length * 10 + matched.filter(term => tag.toLowerCase().includes(term)).length * 5, matched_terms: matched },
36
+ contract_status: 'summary_only', next_lookup: nextLookup,
37
+ });
38
+ };
39
+ const unavailable = (source) => coverage.push({ source, status: 'unavailable', error: 'Inventory could not be read. Check authentication, authorization, and deployed API support; no absence conclusion is valid.' });
40
+ const inventory = (source, rows) => {
41
+ const count = Math.min(rows.length, maxItemsPerInventory, Math.max(0, maxTotalItems - totalScanned));
42
+ totalScanned += count;
43
+ coverage.push({ source, status: 'searched', received_count: rows.length, scanned_count: count, truncated: rows.length > count, upstream_completeness: 'unknown' });
44
+ return rows.slice(0, count);
45
+ };
46
+ let product = {};
47
+ try {
48
+ const fetched = record(await sources.getProduct(ctx, { tag: opts.product }));
49
+ product = record(fetched.data ?? fetched);
50
+ if (!Object.keys(product).length)
51
+ throw new Error('Missing product');
52
+ coverage.push({ source: 'product', status: 'searched', product: opts.product });
53
+ }
54
+ catch {
55
+ unavailable('product');
56
+ }
57
+ const groups = [
58
+ ['feature', ['features'], 'features'], ['function', ['functions'], 'functions'],
59
+ ['database', ['databases'], 'databases'], ['graph', ['graphs'], 'graphs'], ['vector', ['vectors', 'vector_databases'], 'vectors'],
60
+ ];
61
+ for (const [kind, keys, componentType] of groups) {
62
+ const key = keys.find(name => Array.isArray(product[name]));
63
+ if (!key) {
64
+ coverage.push({ source: `product.${componentType}`, status: 'unavailable', error: 'Product inventory omitted this collection; it is not known to be empty.' });
65
+ continue;
66
+ }
67
+ for (const value of inventory(`product.${componentType}`, product[key])) {
68
+ const item = record(value);
69
+ const tag = text(item.tag);
70
+ const namespace = text(item.namespace);
71
+ if (!tag && !namespace) {
72
+ coverage.push({ source: `product.${componentType}`, status: 'incomplete', error: 'An item lacked an exact tag or namespace and was omitted.' });
73
+ continue;
74
+ }
75
+ add(kind, item, { product_tag: opts.product, ...(tag ? { tag } : { namespace }) }, `product.${componentType}`, {
76
+ tool: 'ductape_cli', argv: ['products', 'components', 'get', '--product-tag', opts.product, '--type', componentType, '--json'],
77
+ note: 'Inspect the exact returned definition before reuse; this search does not establish runtime availability.',
78
+ });
79
+ if (!['database', 'graph', 'vector'].includes(kind) || !tag)
80
+ continue;
81
+ if (!Array.isArray(item.actions)) {
82
+ coverage.push({ source: `${kind}:${tag}:actions`, status: 'unavailable', error: 'Saved action inventory was omitted; no actions were inferred.' });
83
+ continue;
84
+ }
85
+ for (const action of inventory(`${kind}:${tag}:actions`, item.actions)) {
86
+ const actionTag = text(record(action).tag);
87
+ if (!actionTag)
88
+ continue;
89
+ add(`${kind}_action`, action, { product_tag: opts.product, [`${kind}_tag`]: tag, action_tag: actionTag }, `product.${componentType}.actions`, kind === 'database' ? {
90
+ tool: 'ductape_schema', arguments: { product_tag: opts.product, database_tag: tag, action_tag: actionTag, ...(opts.env ? { env_slug: opts.env } : {}) },
91
+ required_before_lookup: opts.env ? [] : ['env_slug'],
92
+ } : {
93
+ tool: 'ductape_cli', argv: [kind, 'actions', 'get', actionTag, `--${kind}`, tag, '--json'],
94
+ required_before_lookup: ['Confirm the local project is linked to this exact product and workspace.'],
95
+ });
96
+ }
97
+ }
98
+ }
99
+ const linkedApps = Array.isArray(product.apps) ? inventory('product.apps', product.apps) : [];
100
+ if (!Array.isArray(product.apps))
101
+ coverage.push({ source: 'product.apps', status: 'unavailable', error: 'Linked App inventory was omitted.' });
102
+ const scanApp = async (value, linked) => {
103
+ const app = record(value);
104
+ const appTag = text(app.app_tag) ?? text(app.tag);
105
+ const accessTag = text(app.access_tag);
106
+ const identifier = appTag ?? accessTag;
107
+ if (!identifier) {
108
+ coverage.push({ source: linked ? 'product.apps' : 'workspace.apps', status: 'incomplete', error: 'App identifier missing; skipped.' });
109
+ return;
110
+ }
111
+ const provenance = linked ? 'product.apps' : 'workspace.apps';
112
+ add('app', { ...app, tag: identifier }, { ...(linked ? { product_tag: opts.product } : {}), app_tag: appTag, access_tag: accessTag }, provenance, {
113
+ tool: 'ductape_cli', argv: linked
114
+ ? ['products', 'apps', 'actions', 'list', '--product', opts.product, '--app', identifier, '--json']
115
+ : ['apps', 'actions', 'list', '--app', identifier, '--json'],
116
+ note: 'Catalogue candidates only; inspect the exact environment-bound action contract before execution.',
117
+ });
118
+ if (appReads >= maxApps) {
119
+ const source = `${provenance}:remaining_actions`;
120
+ const omitted = coverage.find(item => item.source === source);
121
+ if (omitted)
122
+ omitted.omitted_count = Number(omitted.omitted_count) + 1;
123
+ else
124
+ coverage.push({ source, status: 'omitted_by_budget', omitted_count: 1 });
125
+ return;
126
+ }
127
+ appReads += 1;
128
+ try {
129
+ const actions = linked ? await sources.listProductAppActions(ctx, opts.product, identifier) : await sources.listAppActions(ctx, identifier);
130
+ if (!Array.isArray(actions))
131
+ throw new Error('Action inventory is not an array');
132
+ for (const action of inventory(`${provenance}:${identifier}:actions`, actions)) {
133
+ const actionTag = text(record(action).tag);
134
+ if (!actionTag)
135
+ continue;
136
+ add('app_action', action, { ...(linked ? { product_tag: opts.product } : {}), app_tag: identifier, ...(accessTag ? { access_tag: accessTag } : {}), action_tag: actionTag }, provenance, linked ? {
137
+ tool: 'ductape_schema', arguments: { product_tag: opts.product, app_tag: accessTag ?? identifier, action_tag: actionTag, ...(opts.env ? { env_slug: opts.env } : {}) },
138
+ required_before_lookup: opts.env ? [] : ['env_slug'],
139
+ note: 'Listed action is a catalogue candidate, not proof it exists in the connected runtime version.',
140
+ } : {
141
+ tool: 'ductape_cli', argv: ['apps', 'actions', 'get', '--app', identifier, '--action', actionTag, '--json'],
142
+ note: 'Workspace-owned catalogue action. Verify product connection and its exact environment-bound contract before execution.',
143
+ });
144
+ }
145
+ }
146
+ catch {
147
+ unavailable(`${provenance}:${identifier}:actions`);
148
+ }
149
+ };
150
+ for (const app of linkedApps)
151
+ await scanApp(app, true);
152
+ try {
153
+ const apps = await sources.listApps(ctx);
154
+ for (const app of inventory('workspace.apps', apps))
155
+ await scanApp(app, false);
156
+ }
157
+ catch {
158
+ unavailable('workspace.apps');
159
+ }
160
+ if (opts.marketplace) {
161
+ try {
162
+ const found = await sources.discoverMarketplaceApps(ctx, { query: opts.query, limit });
163
+ coverage.push({ ...found.coverage, source: 'public_marketplace', status: 'searched', truncated: found.truncated });
164
+ for (const app of found.items)
165
+ add('marketplace_app', app, { app_tag: record(app).tag }, 'public_marketplace', { tool: 'ductape_marketplace_inspect', arguments: { app_tag: record(app).tag }, note: 'Public candidate only; discovery never connects or imports it.' });
166
+ }
167
+ catch {
168
+ unavailable('public_marketplace');
169
+ }
170
+ }
171
+ candidates.sort((a, b) => Number(record(b.match).score) - Number(record(a.match).score));
172
+ return {
173
+ items: candidates.slice(0, limit), workspace_id: ctx.workspaceId, product_tag: opts.product,
174
+ total_matches_in_scanned_inventories: candidates.length, returned_count: Math.min(limit, candidates.length),
175
+ truncated: candidates.length > limit || coverage.some(item => item.truncated === true || item.status === 'omitted_by_budget'),
176
+ partial: true, next_cursor: null, coverage,
177
+ limits: { maximum_app_action_reads: maxApps, maximum_items_per_inventory: maxItemsPerInventory, maximum_total_inventory_items: maxTotalItems },
178
+ limitations: ['Search is lexical and summary-only, scoped to this product and the authenticated workspace App catalogue.', 'Other products in the workspace are not searched. Inventories have no upstream completeness guarantee; missing metadata or failed reads never establish absence.', 'Refine the query, inspect listed inventories directly, and obtain exact runtime contracts before reuse. No operation was executed or asset created.'],
179
+ };
180
+ }
@@ -0,0 +1,68 @@
1
+ export declare const CLOUD_PROVIDERS: readonly ["aws", "gcp", "azure", "mongodb_atlas", "neo4j_aura"];
2
+ export type CloudProviderName = (typeof CLOUD_PROVIDERS)[number];
3
+ export type GuidePurpose = 'resources' | 'deploy';
4
+ export interface IConnectionFlags {
5
+ provider?: string;
6
+ name?: string;
7
+ tag?: string;
8
+ description?: string;
9
+ scopes?: string;
10
+ authMode?: string;
11
+ deploy?: boolean;
12
+ projectId?: string;
13
+ serviceAccountFile?: string;
14
+ runtimeServiceAccount?: string;
15
+ roleArn?: string;
16
+ tenantId?: string;
17
+ subscriptionId?: string;
18
+ clientId?: string;
19
+ clientSecretEnv?: string;
20
+ defaultLocation?: string;
21
+ atlasPublicKey?: string;
22
+ atlasPrivateKeyEnv?: string;
23
+ auraClientId?: string;
24
+ auraClientSecretEnv?: string;
25
+ auraInstanceId?: string;
26
+ }
27
+ export interface IConnectionIo {
28
+ readFile(path: string): string;
29
+ env: Record<string, string | undefined>;
30
+ }
31
+ export declare const realIo: IConnectionIo;
32
+ /**
33
+ * Builds the request body for `ductape cloud connections <verb>` from flags, on top of any body read from a file. Flags win.
34
+ * Nothing secret is accepted as a flag value.
35
+ */
36
+ export declare function buildConnectionBody(verb: string, flags: IConnectionFlags, base?: Record<string, unknown>, io?: IConnectionIo): Record<string, unknown>;
37
+ export interface IGuideStep {
38
+ step: number;
39
+ /** "you" runs it in their own cloud account or terminal; "ductape" is a ductape command. */
40
+ who: 'you' | 'ductape';
41
+ title: string;
42
+ commands?: string[];
43
+ notes?: string[];
44
+ }
45
+ export interface IConnectionGuide {
46
+ provider: CloudProviderName;
47
+ purpose: GuidePurpose;
48
+ supported: boolean;
49
+ summary: string;
50
+ secrets: string;
51
+ steps: IGuideStep[];
52
+ /** Roles and APIs the connection needs, when the purpose is deploy. */
53
+ access?: {
54
+ roles: Array<{
55
+ role: string;
56
+ for: string;
57
+ }>;
58
+ apis: string[];
59
+ };
60
+ }
61
+ export declare const GCP_DEPLOY_ROLE_LIST: {
62
+ role: string;
63
+ for: string;
64
+ }[];
65
+ export declare const GCP_DEPLOY_APIS: string[];
66
+ export declare function connectionGuide(providerInput: string, purposeInput?: string): IConnectionGuide;
67
+ /** A copy of a request body that is safe to print: secrets and key material are replaced, everything else is kept. */
68
+ export declare function maskConnectionBody(body: Record<string, unknown>): Record<string, unknown>;