@revoengine/cli 2.1.0 → 2.2.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 (66) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +113 -12
  3. package/dist/src/application-access.d.ts +4 -0
  4. package/dist/src/application-access.js +18 -0
  5. package/dist/src/application-cors.d.ts +2 -0
  6. package/dist/src/application-cors.js +19 -0
  7. package/dist/src/argument-contract.js +24 -4
  8. package/dist/src/automation-contract.generated.d.ts +165 -6
  9. package/dist/src/automation-contract.generated.js +198 -6
  10. package/dist/src/cli.js +10 -2
  11. package/dist/src/client.d.ts +53 -1
  12. package/dist/src/client.js +84 -0
  13. package/dist/src/commands/applications.d.ts +2 -0
  14. package/dist/src/commands/applications.js +44 -0
  15. package/dist/src/commands/emulate.d.ts +1 -0
  16. package/dist/src/commands/emulate.js +79 -3
  17. package/dist/src/commands/index.d.ts +2 -0
  18. package/dist/src/commands/index.js +2 -0
  19. package/dist/src/commands/migrate.js +10 -2
  20. package/dist/src/commands/sites.d.ts +2 -0
  21. package/dist/src/commands/sites.js +156 -0
  22. package/dist/src/commands/terminal-pty.js +2 -1
  23. package/dist/src/component-lock.d.ts +2 -1
  24. package/dist/src/component-lock.js +22 -1
  25. package/dist/src/endpoint-application.d.ts +25 -0
  26. package/dist/src/endpoint-application.js +75 -0
  27. package/dist/src/endpoint-emulator.d.ts +5 -0
  28. package/dist/src/endpoint-emulator.js +29 -0
  29. package/dist/src/endpoint-storage-transports.d.ts +2 -0
  30. package/dist/src/endpoint-storage-transports.js +8 -0
  31. package/dist/src/metadata-backfill.d.ts +1 -1
  32. package/dist/src/metadata-backfill.js +10 -1
  33. package/dist/src/migration.d.ts +6 -2
  34. package/dist/src/migration.js +104 -41
  35. package/dist/src/project.d.ts +8 -1
  36. package/dist/src/project.js +4 -0
  37. package/dist/src/request-contract.d.ts +5 -0
  38. package/dist/src/request-contract.js +12 -0
  39. package/dist/src/resource-inventory.d.ts +4 -2
  40. package/dist/src/resource-inventory.js +16 -1
  41. package/dist/src/resource-syncs/account-principal.d.ts +2 -0
  42. package/dist/src/resource-syncs/account-principal.js +3 -0
  43. package/dist/src/resource-syncs/application-principals.d.ts +60 -0
  44. package/dist/src/resource-syncs/application-principals.js +151 -0
  45. package/dist/src/resource-syncs/application-sync.d.ts +110 -0
  46. package/dist/src/resource-syncs/application-sync.js +328 -0
  47. package/dist/src/resource-syncs/endpoint-sync.d.ts +38 -0
  48. package/dist/src/resource-syncs/endpoint-sync.js +278 -14
  49. package/dist/src/resource-syncs/group-sync.d.ts +12 -0
  50. package/dist/src/resource-syncs/group-sync.js +60 -6
  51. package/dist/src/resource-syncs/runtime-definition-validation.js +26 -1
  52. package/dist/src/resource-syncs/service-account-sync.d.ts +10 -0
  53. package/dist/src/resource-syncs/service-account-sync.js +32 -4
  54. package/dist/src/reviewed-plan.js +2 -2
  55. package/dist/src/sync-omit-write-fence.js +4 -1
  56. package/dist/src/sync-omit.d.ts +1 -1
  57. package/dist/src/sync-omit.js +7 -2
  58. package/dist/src/tracked-resources.d.ts +1 -1
  59. package/dist/src/tracked-resources.js +3 -2
  60. package/dist/src/types.d.ts +30 -0
  61. package/dist/src/ui.js +2 -0
  62. package/dist/src/workspace-diff.js +1 -0
  63. package/dist/src/workspace-digests.js +2 -0
  64. package/dist/src/workspace-prune.js +67 -9
  65. package/package.json +11 -6
  66. package/scripts/postinstall.mjs +40 -0
@@ -1,4 +1,5 @@
1
1
  import { loadComponentSources } from "./component-manifests.js";
2
+ import { DEFAULT_ENDPOINT_APPLICATION_ID } from "./endpoint-application.js";
2
3
  import { agentDependencies } from "./resource-syncs/agent-sync.js";
3
4
  import fs from 'node:fs';
4
5
  import path from 'node:path';
@@ -10,8 +11,9 @@ import { readResourceInventory, resourceIdOf } from "./resource-inventory.js";
10
11
  import { normalizeStableKeyValue, readConfiguredResourceMetadataStableKey } from "./resource-metadata.js";
11
12
  import { isBuiltinSystemAccount } from "./resource-syncs/account-principal.js";
12
13
  import { findManifestFiles, isRecord, requireProjectLayout } from "./resource-syncs/util.js";
13
- import { preserveOmittedProperties } from "./sync-omit.js";
14
+ import { omitPaths, preserveOmittedProperties } from "./sync-omit.js";
14
15
  const manifests = {
16
+ application: ['Applications', 'application.json'],
15
17
  agent: ['Agents', 'agent.json'],
16
18
  'agent-plugin': ['AgentPlugins', 'agent-plugin.json'],
17
19
  component: ['Components', 'component.json'],
@@ -26,7 +28,7 @@ const manifests = {
26
28
  'service-account': ['ServiceAccounts', 'service-account.json'],
27
29
  };
28
30
  const deletionOrder = [
29
- 'agent', 'agent-plugin', 'event', 'schedule', 'endpoint', 'job-template', 'component',
31
+ 'agent', 'agent-plugin', 'event', 'schedule', 'endpoint', 'application', 'job-template', 'component',
30
32
  'database-view', 'database-table', 'role-group', 'service-account', 'group',
31
33
  ];
32
34
  function key(resource, identity) {
@@ -50,7 +52,7 @@ export function readPruneManifests(cwd, resources) {
50
52
  const manifest = JSON.parse(fs.readFileSync(filename, 'utf8'));
51
53
  if (!isRecord(manifest))
52
54
  throw new Error(`Invalid prune manifest: ${filename}.`);
53
- const stableKey = resource === 'component'
55
+ const stableKey = resource === 'application' ? typeof manifest.key === 'string' ? manifest.key : null : resource === 'component'
54
56
  ? readConfiguredResourceMetadataStableKey(manifest, stableKeyName)
55
57
  : typeof manifest.stableKey === 'string' ? manifest.stableKey : null;
56
58
  if (!stableKey)
@@ -78,6 +80,8 @@ function localReferences(resource, manifest) {
78
80
  if (resource === 'job-template' && isRecord(manifest.component))
79
81
  add('component', manifest.component.stableKey);
80
82
  if (resource === 'endpoint') {
83
+ if (isRecord(manifest.application) && typeof manifest.application.key === 'string')
84
+ add('application', manifest.application.key);
81
85
  for (const binding of [manifest.execution, manifest.schema]) {
82
86
  if (isRecord(binding))
83
87
  add('component', binding.stableKey);
@@ -100,6 +104,16 @@ function localReferences(resource, manifest) {
100
104
  if (manifest.owner.type === 'service-account')
101
105
  add('service-account', manifest.owner.stableKey);
102
106
  }
107
+ if (resource === 'application' && isRecord(manifest.invocationPolicy) && Array.isArray(manifest.invocationPolicy.groups)) {
108
+ for (const reference of manifest.invocationPolicy.groups)
109
+ if (isRecord(reference) && reference.type === 'group')
110
+ add('group', reference.stableKey);
111
+ }
112
+ if (resource === 'application' && isRecord(manifest.invocationPolicy) && Array.isArray(manifest.invocationPolicy.serviceAccounts)) {
113
+ for (const principal of manifest.invocationPolicy.serviceAccounts)
114
+ if (isRecord(principal) && principal.kind === 'service-account')
115
+ add('service-account', principal.stableKey);
116
+ }
103
117
  if (isRecord(manifest.executionPrincipal))
104
118
  add('service-account', manifest.executionPrincipal.stableKey);
105
119
  if (isRecord(manifest.executionPolicy) && isRecord(manifest.executionPolicy.serviceAccount) && manifest.executionPolicy.serviceAccount.kind === 'service-account')
@@ -114,6 +128,13 @@ function remoteReferences(resource, record, tables) {
114
128
  };
115
129
  if (resource === 'agent')
116
130
  add('service-account', record.serviceAccountUserId);
131
+ if (resource === 'application' && isRecord(record.invocationPolicy) && Array.isArray(record.invocationPolicy.groups))
132
+ for (const id of record.invocationPolicy.groups)
133
+ add('group', id);
134
+ if (resource === 'application' && isRecord(record.invocationPolicy) && Array.isArray(record.invocationPolicy.serviceAccounts)) {
135
+ for (const id of record.invocationPolicy.serviceAccounts)
136
+ add('service-account', id);
137
+ }
117
138
  const sections = resource === 'agent' ? [record.config, record.policy] : resource === 'agent-plugin' ? [record.config] : [];
118
139
  function pluginRefs(value) {
119
140
  if (!isRecord(value))
@@ -137,6 +158,8 @@ function remoteReferences(resource, record, tables) {
137
158
  }
138
159
  if (resource === 'job-template' || resource === 'endpoint')
139
160
  add('component', record.componentId);
161
+ if (resource === 'endpoint' && typeof record.serviceId === 'string' && record.serviceId !== DEFAULT_ENDPOINT_APPLICATION_ID)
162
+ add('application', record.serviceId);
140
163
  if (resource === 'endpoint' && isRecord(record.options))
141
164
  add('component', record.options.componentSchemaId);
142
165
  if (resource === 'job-template')
@@ -210,7 +233,7 @@ export function planWorkspacePrune(input) {
210
233
  throw new Error(`Invalid ${resource} inventory: missing target ID.`);
211
234
  if (byId.has(key(resource, id)))
212
235
  throw new Error(`Repeated ${resource} target ID "${id}".`);
213
- const stableKey = readConfiguredResourceMetadataStableKey(record, input.stableKeyName);
236
+ const stableKey = resource === 'application' ? typeof record.key === 'string' ? record.key : null : readConfiguredResourceMetadataStableKey(record, input.stableKeyName);
214
237
  byId.set(key(resource, id), { resource, record, stableKey });
215
238
  if (!stableKey || isBuiltinSystemAccount(record))
216
239
  continue;
@@ -220,6 +243,8 @@ export function planWorkspacePrune(input) {
220
243
  keys.add(identity);
221
244
  if (!input.resources.includes(resource) || input.local[resource]?.has(identity))
222
245
  continue;
246
+ if (resource === 'application' && (record.system || record.key === '@default' || id === DEFAULT_ENDPOINT_APPLICATION_ID))
247
+ continue;
223
248
  if (resource === 'agent' || resource === 'agent-plugin')
224
249
  blockers.push(`Prune of ${resource} is not supported; remove it explicitly after reviewing runs and dependencies.`);
225
250
  if (resource === 'service-account' && (record.serviceAccount !== true || id === input.actorId)) {
@@ -240,6 +265,21 @@ export function planWorkspacePrune(input) {
240
265
  });
241
266
  }
242
267
  }
268
+ // Application deletion is physical. Even an Endpoint pruned in this run keeps
269
+ // its FK in retained history; only a verified live reassignment can release it.
270
+ for (const record of input.inventory.endpoint || []) {
271
+ if (typeof record.serviceId !== 'string')
272
+ continue;
273
+ const removed = candidates.get(key('application', record.serviceId));
274
+ if (!removed)
275
+ continue;
276
+ const endpointKey = readConfiguredResourceMetadataStableKey(record, input.stableKeyName);
277
+ const desired = endpointKey && input.resources.includes('endpoint') ? input.local.endpoint?.get(normalizeStableKeyValue(endpointKey)) : undefined;
278
+ const nextApp = desired && isRecord(desired.application) ? desired.application : undefined;
279
+ const reassigns = active(record) && desired && (nextApp?.system === '@default' || typeof nextApp?.key === 'string' && nextApp.key !== removed.stableKey || !nextApp);
280
+ if (!reassigns)
281
+ blockers.push(`Application "${removed.stableKey}" is referenced by Endpoint "${endpointKey || resourceIdOf(record)}", including retained Endpoint history; physical deletion is blocked.`);
282
+ }
243
283
  const removedKeys = new Set([...candidates.values()].map((item) => key(item.resource, item.stableKey)));
244
284
  for (const [family, entries] of Object.entries(input.local)) {
245
285
  for (const [identity, manifest] of entries || []) {
@@ -274,6 +314,8 @@ export function planWorkspacePrune(input) {
274
314
  ||
275
315
  ((target.resource === 'group' || target.resource === 'service-account')
276
316
  && (!isRecord(desired.owner) || !['group', 'service-account'].includes(String(desired.owner.type))))
317
+ || (target.resource === 'application' && removed.resource === 'group' && (desired.invocationPolicy === undefined || isRecord(desired.invocationPolicy) && desired.invocationPolicy.groups === undefined || omitPaths('application').some(parts => parts[0] === 'invocationPolicy')))
318
+ || (target.resource === 'application' && removed.resource === 'service-account' && (desired.invocationPolicy === undefined || omitPaths('application').some(parts => parts[0] === 'invocationPolicy')))
277
319
  || (target.resource === 'job-template' && removed.resource === 'service-account' && !isRecord(desired.executionPrincipal)));
278
320
  if (!desired || preservesReference || localReferences(target.resource, desired).some((ref) => key(ref.resource, ref.identity) === key(removed.resource, removed.stableKey))) {
279
321
  blockers.push(`${removed.resource} "${removed.stableKey}" is still referenced by retained ${target.resource} "${target.stableKey || resourceIdOf(target.record)}".`);
@@ -346,6 +388,8 @@ export function planWorkspacePrune(input) {
346
388
  }
347
389
  export async function buildWorkspacePrunePlan(input) {
348
390
  const resources = new Set(input.resources);
391
+ if (resources.has('application'))
392
+ resources.add('endpoint');
349
393
  // Include unmanaged and out-of-scope consumers in dependency checks.
350
394
  if (resources.has('component')) {
351
395
  resources.add('job-template');
@@ -371,6 +415,8 @@ export async function buildWorkspacePrunePlan(input) {
371
415
  resources.add('service-account');
372
416
  resources.add('job-template');
373
417
  resources.add('agent');
418
+ resources.add('application');
419
+ resources.add('endpoint');
374
420
  }
375
421
  const local = readPruneManifests(input.cwd, input.resources);
376
422
  const inventory = {};
@@ -400,7 +446,7 @@ export async function buildWorkspacePrunePlan(input) {
400
446
  inventory[resource] = components;
401
447
  continue;
402
448
  }
403
- for await (const entry of readResourceInventory(input.client, resource)) {
449
+ for await (const entry of readResourceInventory(input.client, resource, { allowUnsupportedApplications: (input.resources.length > 1 || !input.resources.includes('application')) && !local.application?.size })) {
404
450
  if (!entry.resource || resourceIdOf(entry.resource) !== entry.listedId)
405
451
  throw new Error(`Incomplete ${resource} inventory; prune blocked.`);
406
452
  records.push(entry.resource);
@@ -415,7 +461,7 @@ export async function buildWorkspacePrunePlan(input) {
415
461
  const plan = planWorkspacePrune({ resources: input.resources, local, inventory, stableKeyName, actorId });
416
462
  if (input.captureTargets) {
417
463
  plan.targetState = input.resources.flatMap(resource => (inventory[resource] || []).filter(active).flatMap(record => {
418
- const stableKey = readConfiguredResourceMetadataStableKey(record, stableKeyName);
464
+ const stableKey = resource === 'application' ? typeof record.key === 'string' ? record.key : null : readConfiguredResourceMetadataStableKey(record, stableKeyName);
419
465
  return stableKey ? [{ resource, stableKey: normalizeStableKeyValue(stableKey), targetId: resourceIdOf(record),
420
466
  version: typeof record.version === 'number' ? record.version : null, active: record.active ?? null }] : [];
421
467
  })).sort((left, right) => key(left.resource, left.stableKey).localeCompare(key(right.resource, right.stableKey))
@@ -438,7 +484,7 @@ function clearPruneBaseline(cwd, envName, item) {
438
484
  return;
439
485
  }
440
486
  const fields = {
441
- 'job-template': 'jobTemplates', endpoint: 'endpoints', schedule: 'schedules', event: 'events',
487
+ 'job-template': 'jobTemplates', endpoint: 'endpoints', application: 'applications', schedule: 'schedules', event: 'events',
442
488
  'database-table': 'databaseSchemas', 'database-view': 'databaseViews', group: 'groups',
443
489
  'role-group': 'roleGroups', 'service-account': 'serviceAccounts', agent: 'agents', 'agent-plugin': 'agentPlugins',
444
490
  };
@@ -487,10 +533,22 @@ export async function applyWorkspacePrune(input) {
487
533
  if (resourceIdOf(entry.resource) === item.targetId && active(entry.resource))
488
534
  current = entry.resource;
489
535
  }
490
- if (!current || readConfiguredResourceMetadataStableKey(current, readProjectStableKeyName(input.cwd)) !== item.stableKey
536
+ if (!current || (item.resource === 'application' ? current.key : readConfiguredResourceMetadataStableKey(current, readProjectStableKeyName(input.cwd))) !== item.stableKey
491
537
  || resourceHash(current) !== item.targetHash)
492
538
  throw new Error('target changed after deletion was reviewed');
493
- await input.client.deleteWorkspaceResource(item.resource, item.targetId);
539
+ if (item.resource === 'application') {
540
+ if (current.system || current.key === '@default' || !Number.isInteger(current.version))
541
+ throw new Error('Application deletion requires a reviewed mutable identity and version.');
542
+ // Rebuild immediately: Endpoint histories are retained even after prune.
543
+ const fresh = await buildWorkspacePrunePlan(input);
544
+ const candidate = fresh.items.find(value => value.resource === 'application' && value.targetId === item.targetId);
545
+ if (fresh.blockers.length || !candidate || candidate.targetHash !== item.targetHash)
546
+ throw new Error('Application references or revision changed after planning.');
547
+ await input.client.deleteApplication(item.targetId, current.version);
548
+ }
549
+ else {
550
+ await input.client.deleteWorkspaceResource(item.resource, item.targetId);
551
+ }
494
552
  accepted = true;
495
553
  for await (const entry of readResourceInventory(input.client, item.resource)) {
496
554
  if (resourceIdOf(entry.resource) === item.targetId && active(entry.resource))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revoengine/cli",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "CLI package for the RevoEngine Platform API",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -11,20 +11,22 @@
11
11
  "scripts": {
12
12
  "build": "npm run clean && tsc -p tsconfig.build.json",
13
13
  "clean": "node --input-type=module -e \"import fs from 'node:fs'; fs.rmSync('dist', { recursive: true, force: true });\"",
14
- "check": "node --input-type=module -e \"await import('./src/config.ts'); await import('./src/commands/terminal-process-group.ts'); await import('./src/commands/terminal-file-descriptor.ts'); await import('./src/workspace-write-lock.ts'); await import('./src/argument-contract.ts'); await import('./src/legacy.ts'); await import('./src/http-trace.ts'); await import('./src/request-queue.ts'); await import('./src/client.ts'); await import('./src/component-lock.ts'); await import('./src/component-lifecycle.ts'); await import('./src/component-element-validation.ts'); await import('./src/component-source-validation.ts'); await import('./src/request-contract.ts'); await import('./src/sync-omit.ts'); await import('./src/sync-omit-command.ts'); await import('./src/sync-omit-write-fence.ts'); await import('./src/component-contract.ts'); await import('./src/component-manifests.ts'); await import('./src/planning-snapshot.ts'); await import('./src/workspace-digests.ts'); await import('./src/database-indexes.ts'); await import('./src/diff-details.ts'); await import('./src/resource-metadata.ts'); await import('./src/tracked-resources.ts'); await import('./src/resource-inventory.ts'); await import('./src/metadata-backfill.ts'); await import('./src/workspace-component.ts'); await import('./src/workspace-resource.ts'); await import('./src/database-table-artifacts.ts'); await import('./src/project.ts'); await import('./src/prompt.ts'); await import('./src/runtime-view.ts'); await import('./src/spinner.ts'); await import('./src/types.ts'); await import('./src/utils.ts'); await import('./src/resource-syncs/util.ts'); await import('./src/resource-syncs/agent-sync.ts'); await import('./src/resource-syncs/database-table-sync.ts'); await import('./src/resource-syncs/database-view-sync.ts'); await import('./src/resource-syncs/endpoint-sync.ts'); await import('./src/resource-syncs/group-sync.ts'); await import('./src/resource-syncs/role-group-sync.ts'); await import('./src/resource-syncs/job-template-sync.ts'); await import('./src/resource-syncs/schedule-sync.ts'); await import('./src/resource-syncs/event-sync.ts'); await import('./src/resource-syncs/account-principal.ts'); await import('./src/resource-syncs/identity-migration.ts'); await import('./src/resource-syncs/service-account-sync.ts'); await import('./src/commands/service-accounts.ts'); await import('./src/commands/agents.ts'); await import('./src/migration-actions.ts'); await import('./src/reviewed-plan.ts'); await import('./src/migration.ts'); await import('./src/workspace-diff.ts'); await import('./src/workspace-prune.ts'); await import('./src/sync-output.ts'); await import('./src/ui.ts'); await import('./src/update-notifier.ts'); await import('./src/env-sync.ts'); await import('./src/commands/auth.ts'); await import('./src/commands/component.ts'); await import('./src/commands/database-tables.ts'); await import('./src/commands/database-views.ts'); await import('./src/commands/endpoints.ts'); await import('./src/commands/emulate.ts'); await import('./src/commands/env.ts'); await import('./src/commands/events.ts'); await import('./src/commands/groups.ts'); await import('./src/commands/info.ts'); await import('./src/commands/job-templates.ts'); await import('./src/commands/metadata.ts'); await import('./src/commands/migrate.ts'); await import('./src/commands/request.ts'); await import('./src/commands/studio.ts'); await import('./src/commands/tests.ts'); await import('./src/native-tests.ts'); await import('./src/test-workspace.ts'); await import('./src/commands/role-groups.ts'); await import('./src/commands/search.ts'); await import('./src/commands/schedules.ts'); await import('./src/commands/terminal-service.ts'); await import('./src/commands/terminal-browser.ts'); await import('./src/commands/terminal-image.ts'); await import('./src/commands/terminal-sandbox.ts'); await import('./src/commands/terminal-patch.ts'); await import('./src/commands/terminal-patch-worker.ts'); await import('./src/commands/terminal-browser-profile-import.protocol.ts'); await import('./src/commands/terminal-browser-profile-import.ts'); await import('./src/commands/terminal-browser-profile-import-runner.ts'); await import('./src/commands/terminal.ts'); await import('./src/cli.ts'); await import('./src/index.ts'); await import('./bin/revo.ts'); await import('./scripts/dev.ts')\"",
14
+ "check": "node --input-type=module -e \"await import('./src/config.ts'); await import('./scripts/postinstall.mjs'); await import('./src/commands/terminal-process-group.ts'); await import('./src/commands/terminal-file-descriptor.ts'); await import('./src/workspace-write-lock.ts'); await import('./src/argument-contract.ts'); await import('./src/legacy.ts'); await import('./src/http-trace.ts'); await import('./src/request-queue.ts'); await import('./src/client.ts'); await import('./src/component-lock.ts'); await import('./src/component-lifecycle.ts'); await import('./src/component-element-validation.ts'); await import('./src/component-source-validation.ts'); await import('./src/request-contract.ts'); await import('./src/sync-omit.ts'); await import('./src/sync-omit-command.ts'); await import('./src/sync-omit-write-fence.ts'); await import('./src/component-contract.ts'); await import('./src/component-manifests.ts'); await import('./src/planning-snapshot.ts'); await import('./src/workspace-digests.ts'); await import('./src/database-indexes.ts'); await import('./src/diff-details.ts'); await import('./src/resource-metadata.ts'); await import('./src/tracked-resources.ts'); await import('./src/resource-inventory.ts'); await import('./src/metadata-backfill.ts'); await import('./src/workspace-component.ts'); await import('./src/workspace-resource.ts'); await import('./src/database-table-artifacts.ts'); await import('./src/project.ts'); await import('./src/prompt.ts'); await import('./src/runtime-view.ts'); await import('./src/spinner.ts'); await import('./src/types.ts'); await import('./src/utils.ts'); await import('./src/resource-syncs/util.ts'); await import('./src/resource-syncs/agent-sync.ts'); await import('./src/resource-syncs/database-table-sync.ts'); await import('./src/resource-syncs/database-view-sync.ts'); await import('./src/resource-syncs/endpoint-sync.ts'); await import('./src/resource-syncs/group-sync.ts'); await import('./src/resource-syncs/role-group-sync.ts'); await import('./src/resource-syncs/job-template-sync.ts'); await import('./src/resource-syncs/schedule-sync.ts'); await import('./src/resource-syncs/event-sync.ts'); await import('./src/resource-syncs/account-principal.ts'); await import('./src/resource-syncs/identity-migration.ts'); await import('./src/resource-syncs/service-account-sync.ts'); await import('./src/commands/service-accounts.ts'); await import('./src/commands/agents.ts'); await import('./src/migration-actions.ts'); await import('./src/reviewed-plan.ts'); await import('./src/migration.ts'); await import('./src/workspace-diff.ts'); await import('./src/workspace-prune.ts'); await import('./src/sync-output.ts'); await import('./src/ui.ts'); await import('./src/update-notifier.ts'); await import('./src/env-sync.ts'); await import('./src/commands/auth.ts'); await import('./src/commands/component.ts'); await import('./src/commands/database-tables.ts'); await import('./src/commands/database-views.ts'); await import('./src/commands/endpoints.ts'); await import('./src/commands/applications.ts'); await import('./src/application-cors.ts'); await import('./src/resource-syncs/application-sync.ts'); await import('./src/commands/emulate.ts'); await import('./src/commands/env.ts'); await import('./src/commands/events.ts'); await import('./src/commands/groups.ts'); await import('./src/commands/info.ts'); await import('./src/commands/job-templates.ts'); await import('./src/commands/metadata.ts'); await import('./src/commands/migrate.ts'); await import('./src/commands/request.ts'); await import('./src/commands/studio.ts'); await import('./src/commands/sites.ts'); await import('./src/commands/tests.ts'); await import('./src/native-tests.ts'); await import('./src/test-workspace.ts'); await import('./src/commands/role-groups.ts'); await import('./src/commands/search.ts'); await import('./src/commands/schedules.ts'); await import('./src/commands/terminal-service.ts'); await import('./src/commands/terminal-browser.ts'); await import('./src/commands/terminal-image.ts'); await import('./src/commands/terminal-sandbox.ts'); await import('./src/commands/terminal-patch.ts'); await import('./src/commands/terminal-patch-worker.ts'); await import('./src/commands/terminal-browser-profile-import.protocol.ts'); await import('./src/commands/terminal-browser-profile-import.ts'); await import('./src/commands/terminal-browser-profile-import-runner.ts'); await import('./src/commands/terminal.ts'); await import('./src/cli.ts'); await import('./src/index.ts'); await import('./bin/revo.ts'); await import('./scripts/dev.ts')\"",
15
15
  "dev": "node ./scripts/dev.ts",
16
16
  "prepack": "npm run build",
17
17
  "test": "node --test ./test/*.test.ts",
18
- "postinstall": "playwright-core install chromium",
18
+ "postinstall": "node scripts/postinstall.mjs",
19
19
  "generate:automation-contract": "node scripts/generate-automation-contract.ts --write",
20
- "check:automation-contract": "node scripts/generate-automation-contract.ts"
20
+ "check:automation-contract": "node scripts/generate-automation-contract.ts",
21
+ "test:installed": "node scripts/verify-installed-cli.mjs"
21
22
  },
22
23
  "files": [
23
24
  "dist/",
24
25
  "README.md",
25
26
  "CHANGELOG.md",
26
27
  "tsconfig.json",
27
- "tsconfig.build.json"
28
+ "tsconfig.build.json",
29
+ "scripts/postinstall.mjs"
28
30
  ],
29
31
  "engines": {
30
32
  "node": ">=24"
@@ -41,6 +43,9 @@
41
43
  "ws": "^8.19.0"
42
44
  },
43
45
  "optionalDependencies": {
44
- "node-pty": "^1.0.0"
46
+ "node-pty": "1.1.0"
47
+ },
48
+ "allowScripts": {
49
+ "node-pty": true
45
50
  }
46
51
  }
@@ -0,0 +1,40 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { existsSync, realpathSync } from 'node:fs';
3
+ import { createRequire } from 'node:module';
4
+ import path from 'node:path';
5
+ import { pathToFileURL } from 'node:url';
6
+ // Published packages use compiled code; source checkouts can run npm install before build.
7
+ const compiledHelper = new URL('../dist/src/commands/terminal-pty.js', import.meta.url);
8
+ const { ensurePtyHelperExecutable } = await import(existsSync(compiledHelper)
9
+ ? compiledHelper.href : new URL('../src/commands/terminal-pty.ts', import.meta.url).href);
10
+
11
+ const require = createRequire(import.meta.url);
12
+
13
+ /** Optional PTY support must not prevent installing the ordinary CLI commands. */
14
+ export function prepareOptionalPtyInstallation() {
15
+ try {
16
+ ensurePtyHelperExecutable();
17
+ } catch (error) {
18
+ if (error?.code === 'MODULE_NOT_FOUND') return;
19
+ process.stderr.write('Optional interactive terminal setup could not finish; the runner will retry before starting a PTY.\n');
20
+ }
21
+ }
22
+
23
+ export function postinstall() {
24
+ prepareOptionalPtyInstallation();
25
+ // Use this package's browser installer, independently of the caller's PATH.
26
+ const browserCli = path.join(path.dirname(require.resolve('playwright-core/package.json')), 'cli.js');
27
+ const result = spawnSync(process.execPath, [browserCli, 'install', 'chromium'], {
28
+ stdio: 'inherit',
29
+ });
30
+ if (result.error) throw result.error;
31
+ return result.status ?? 1;
32
+ }
33
+
34
+ if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) {
35
+ try { process.exitCode = postinstall(); }
36
+ catch (error) {
37
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
38
+ process.exitCode = 1;
39
+ }
40
+ }