@uniformdev/cli 20.72.3-alpha.40 → 20.72.3-alpha.45

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.
@@ -21,7 +21,7 @@ import { dirname, extname, isAbsolute, resolve, sep } from "path";
21
21
  // package.json
22
22
  var package_default = {
23
23
  name: "@uniformdev/cli",
24
- version: "20.73.0",
24
+ version: "20.74.1",
25
25
  description: "Uniform command line interface tool",
26
26
  license: "SEE LICENSE IN LICENSE.txt",
27
27
  main: "./cli.js",
@@ -1,4 +1,4 @@
1
- import "./chunk-Z4H2GIQQ.mjs";
1
+ import "./chunk-7XIFFKLH.mjs";
2
2
 
3
3
  // src/sync/allSerializableEntitiesConfig.ts
4
4
  var allSerializableEntitiesConfig = {
package/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  withFormatOptions,
24
24
  withProjectOptions,
25
25
  withTeamOptions
26
- } from "./chunk-Z4H2GIQQ.mjs";
26
+ } from "./chunk-7XIFFKLH.mjs";
27
27
 
28
28
  // src/index.ts
29
29
  import * as dotenv from "dotenv";
@@ -2371,23 +2371,49 @@ function toInputJsonSchema(inputSchema) {
2371
2371
  }
2372
2372
 
2373
2373
  // src/commands/automation/bundleAutomationForDeploy.ts
2374
- async function readAutomationMetadataFromBundle(bundlePath, publicId) {
2374
+ async function readDeployInputFromBundle(bundlePath, publicId) {
2375
2375
  const automationModule = await import(pathToFileURL(bundlePath).href);
2376
2376
  const automation = automationModule.default;
2377
2377
  if (!automation?.metadata) {
2378
- throw new Error("Default export must be the return value of defineAutomation");
2378
+ throw new Error("Default export must be the return value of defineAutomation or defineScoutAutomation");
2379
2379
  }
2380
- const metadata = automation.metadata;
2381
- const triggers = metadata.triggers.map(
2382
- (trigger) => trigger.type === "aiTool" ? { type: "aiTool", inputSchema: toInputJsonSchema(metadata.inputSchema) } : trigger
2383
- );
2384
- return {
2380
+ const { metadata } = automation;
2381
+ if (!metadata.name) {
2382
+ throw new Error("An automation must declare a `name` in its metadata.");
2383
+ }
2384
+ const common = {
2385
2385
  publicId,
2386
2386
  name: metadata.name,
2387
2387
  description: metadata.description,
2388
+ permissions: metadata.permissions
2389
+ };
2390
+ if (automation.kind === "scout") {
2391
+ if (typeof automation.instructions !== "string") {
2392
+ throw new Error("A Scout automation must default-export the return value of defineScoutAutomation");
2393
+ }
2394
+ if (!common.permissions) {
2395
+ throw new Error(
2396
+ "A Scout automation must declare `permissions`: it acts solely through its machine identity, so without a role grant it has no authority to act."
2397
+ );
2398
+ }
2399
+ return {
2400
+ ...common,
2401
+ permissions: common.permissions,
2402
+ kind: "scout",
2403
+ // A Scout automation cannot declare an aiTool trigger, so no trigger needs remapping.
2404
+ triggers: metadata.triggers,
2405
+ instructions: automation.instructions
2406
+ };
2407
+ }
2408
+ const triggers = (metadata.triggers ?? []).map(
2409
+ (trigger) => trigger.type === "aiTool" ? { type: "aiTool", inputSchema: toInputJsonSchema(metadata.inputSchema) } : trigger
2410
+ );
2411
+ return {
2412
+ ...common,
2413
+ kind: "typescript",
2388
2414
  triggers,
2389
2415
  compatibilityDate: metadata.compatibilityDate,
2390
- permissions: metadata.permissions
2416
+ code: readFileSync2(bundlePath, "utf8")
2391
2417
  };
2392
2418
  }
2393
2419
  async function bundleAutomationForDeploy(entryFile) {
@@ -2397,14 +2423,14 @@ async function bundleAutomationForDeploy(entryFile) {
2397
2423
  const bundlePath = join7(workDir, "automation.mjs");
2398
2424
  try {
2399
2425
  await bundleWorkerCodeToFile(absEntry, bundlePath);
2400
- const metadata = await readAutomationMetadataFromBundle(bundlePath, publicId);
2401
- const code = readFileSync2(bundlePath, "utf8");
2402
- console.log(
2403
- `\u2139\uFE0F ${basename2(absEntry)} was prepared with esbuild. Size: ${Math.round(code.length / 1024)}kb`
2404
- );
2426
+ const deploy = await readDeployInputFromBundle(bundlePath, publicId);
2427
+ if (deploy.kind === "typescript") {
2428
+ console.log(
2429
+ `\u2139\uFE0F ${basename2(absEntry)} was prepared with esbuild. Size: ${Math.round(deploy.code.length / 1024)}kb`
2430
+ );
2431
+ }
2405
2432
  return {
2406
- metadata,
2407
- code,
2433
+ deploy,
2408
2434
  cleanup: () => rmSync(workDir, { recursive: true, force: true })
2409
2435
  };
2410
2436
  } catch (error) {
@@ -2440,7 +2466,7 @@ var AutomationDeployModule = {
2440
2466
  array: true,
2441
2467
  type: "string",
2442
2468
  demandOption: true,
2443
- describe: "One or more automation source files and/or directories. Each module must default-export the return value of defineAutomation. A directory is scanned (non-recursively) for files matching `*.automation.ts`."
2469
+ describe: "One or more automation source files and/or directories. Each module must default-export the return value of defineAutomation or defineScoutAutomation; which one it is determines how the automation is deployed. A directory is scanned (non-recursively) for files matching `*.automation.ts`."
2444
2470
  }).option("compatibilityDate", {
2445
2471
  type: "string",
2446
2472
  describe: "Overrides the compatibility date in metadata for every deployed automation. Format: YYYY-MM-DD."
@@ -2462,21 +2488,19 @@ var AutomationDeployModule = {
2462
2488
  files.map(async (file) => {
2463
2489
  let cleanup;
2464
2490
  try {
2465
- const bundled = await bundleAutomationForDeploy(file);
2466
- cleanup = bundled.cleanup;
2467
- await client.deploy({
2468
- ...bundled.metadata,
2469
- code: bundled.code,
2470
- compatibilityDate: compatibilityDate ?? bundled.metadata.compatibilityDate
2471
- });
2472
- const triggerKinds = bundled.metadata.triggers.map((trigger) => trigger.type);
2491
+ const prepared = await bundleAutomationForDeploy(file);
2492
+ cleanup = prepared.cleanup;
2493
+ const { deploy } = prepared;
2494
+ await client.deploy(
2495
+ deploy.kind === "typescript" ? { ...deploy, compatibilityDate: compatibilityDate ?? deploy.compatibilityDate } : deploy
2496
+ );
2497
+ const triggerKinds = deploy.triggers.map((trigger) => trigger.type);
2498
+ const label = deploy.kind === "scout" ? "Scout automation" : "automation";
2473
2499
  console.log(
2474
- `\u2705 Deployed automation "${bundled.metadata.publicId}" (${triggerKinds.length} trigger${triggerKinds.length === 1 ? "" : "s"}: ${triggerKinds.join(", ")}).`
2500
+ `\u2705 Deployed ${label} "${deploy.publicId}" (${triggerKinds.length} trigger${triggerKinds.length === 1 ? "" : "s"}: ${triggerKinds.join(", ")}).`
2475
2501
  );
2476
2502
  if (triggerKinds.includes("incomingWebhook")) {
2477
- console.log(
2478
- `Webhook URL: ${formatAutomationWebhookUrl(apiHost, projectId, bundled.metadata.publicId)}`
2479
- );
2503
+ console.log(`Webhook URL: ${formatAutomationWebhookUrl(apiHost, projectId, deploy.publicId)}`);
2480
2504
  }
2481
2505
  return true;
2482
2506
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "20.72.3-alpha.40+ffbec41570",
3
+ "version": "20.72.3-alpha.45+2b8b05d58a",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -27,14 +27,14 @@
27
27
  "dependencies": {
28
28
  "@inquirer/prompts": "^8.5.2",
29
29
  "@thi.ng/mime": "^2.2.23",
30
- "@uniformdev/assets": "20.72.3-alpha.40+ffbec41570",
31
- "@uniformdev/automations-sdk": "20.72.3-alpha.40+ffbec41570",
32
- "@uniformdev/canvas": "20.72.3-alpha.40+ffbec41570",
33
- "@uniformdev/context": "20.72.3-alpha.40+ffbec41570",
34
- "@uniformdev/files": "20.72.3-alpha.40+ffbec41570",
35
- "@uniformdev/project-map": "20.72.3-alpha.40+ffbec41570",
36
- "@uniformdev/redirect": "20.72.3-alpha.40+ffbec41570",
37
- "@uniformdev/richtext": "20.72.3-alpha.40+ffbec41570",
30
+ "@uniformdev/assets": "20.72.3-alpha.45+2b8b05d58a",
31
+ "@uniformdev/automations-sdk": "20.72.3-alpha.45+2b8b05d58a",
32
+ "@uniformdev/canvas": "20.72.3-alpha.45+2b8b05d58a",
33
+ "@uniformdev/context": "20.72.3-alpha.45+2b8b05d58a",
34
+ "@uniformdev/files": "20.72.3-alpha.45+2b8b05d58a",
35
+ "@uniformdev/project-map": "20.72.3-alpha.45+2b8b05d58a",
36
+ "@uniformdev/redirect": "20.72.3-alpha.45+2b8b05d58a",
37
+ "@uniformdev/richtext": "20.72.3-alpha.45+2b8b05d58a",
38
38
  "call-bind": "^1.0.2",
39
39
  "colorette": "2.0.20",
40
40
  "cosmiconfig": "9.0.2",
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "ffbec41570c4266c69674871c97146bf7bf86383"
81
+ "gitHead": "2b8b05d58ab275b4d29a9647feeaad47b0ab5cce"
82
82
  }