@duvoai/cli 1.115.0 → 1.116.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 (3) hide show
  1. package/README.md +203 -202
  2. package/dist/bin/duvo.js +422 -28
  3. package/package.json +1 -1
package/dist/bin/duvo.js CHANGED
@@ -14203,6 +14203,10 @@ var setProcessAttributeValueBodyApiSchema = z56.discriminatedUnion(
14203
14203
  })
14204
14204
  ]
14205
14205
  );
14206
+ var AUTOMATION_RUN_SCOPES = ["personal", "team"];
14207
+ var createRunScopeRequestApiSchema = z57.enum(AUTOMATION_RUN_SCOPES).default("personal").describe(
14208
+ "Who the new automation's runs execute as: `personal` (the default) runs as each member with their own Connections; `team` runs as the team with shared Connections, Secrets and Logins only, and can't be changed back. `team` needs Lead Builder or above, the Team automations feature, a team on the Automations workspace and not on automation revisions, and Connection sharing on; read `GET /v2/teams/{teamId}/automations/run-scope-options` to see whether it is available and why not. Refused with 409 and the blocker's `code` when it isn't, or 403 `permission_required` for a caller below Lead Builder."
14209
+ );
14206
14210
  var automationSetupProgressApiSchema = z57.object({
14207
14211
  has_captures: z57.boolean(),
14208
14212
  has_process_map: z57.boolean(),
@@ -14239,14 +14243,17 @@ var automationSummaryApiSchema = z57.object({
14239
14243
  setup_progress: automationSetupProgressApiSchema.nullable().default(null).describe(
14240
14244
  "The setup facts behind the tile's Setup badge \u2014 captures uploaded, the team's own process map generated, a proposal written \u2014 or null while the automation is not being set up (and whenever it has no module process for the facts to hang off)."
14241
14245
  ),
14242
- run_scope: z57.enum(["personal", "team"]).optional().describe(
14243
- "Who the automation's runs execute as: its members, each with their own Connections (`personal`), or the team, with shared Connections only (`team`). An automation becomes `team` once, through convert-to-team, and never goes back. Optional because a backend that predates Team automations does not send it; a client treats absence as `personal` and offers no conversion."
14246
+ run_scope: z57.enum(AUTOMATION_RUN_SCOPES).optional().describe(
14247
+ "Who the automation's runs execute as: its members, each with their own Connections (`personal`), or the team, with shared Connections only (`team`). An automation is created as either, and a `personal` one can later be converted to `team`; a `team` one never goes back. Optional because a backend that predates Team automations does not send it; a client reads absence as `personal`."
14244
14248
  ),
14245
14249
  converted_to_team_at: z57.string().nullable().optional().describe(
14246
- "When the automation was converted to run as the team, or null while it runs as its members."
14250
+ "When the automation was converted to run as the team, or null while it runs as its members or when it was created to run as the team."
14247
14251
  ),
14248
14252
  converted_by: z57.guid().nullable().optional().describe(
14249
- "The member who converted the automation to run as the team, or null while it runs as its members or when that member is gone."
14253
+ "The member who converted the automation to run as the team, or null while it runs as its members, when it was created to run as the team, or when that member is gone."
14254
+ ),
14255
+ converted_by_name: z57.string().nullable().optional().describe(
14256
+ "The display name of the member who converted the automation to run as the team, or null while it runs as its members, when that member is gone, or when they set no name. Never their email. Optional because an older backend does not send it."
14250
14257
  ),
14251
14258
  viewer_can_edit: z57.boolean().optional().describe(
14252
14259
  "Whether the caller may change this automation. An automation takes its agents' ownership rule: a Builder may edit one whose every agent they created, and Lead Builder or above may edit any. Sent by the list and detail endpoints; absent from create and update responses, where the client falls back to the caller's role."
@@ -14459,6 +14466,28 @@ var teamConversionBlockerApiSchema = z57.object({
14459
14466
  queue_automation_id: z57.string().nullable(),
14460
14467
  queue_automation_name: z57.string().nullable()
14461
14468
  });
14469
+ var TEAM_CREATION_BLOCKER_CODES = [
14470
+ "automations_workspace_required",
14471
+ "team_automations_flag_off",
14472
+ "automation_revisions",
14473
+ "connection_sharing_off",
14474
+ "permission_required"
14475
+ ];
14476
+ var runScopeOptionsResponseApiSchema = z57.object({
14477
+ team: z57.object({
14478
+ available: z57.boolean().describe(
14479
+ "Whether the caller may create an automation that runs as the team (`run_scope: team`) in this team now."
14480
+ ),
14481
+ blocker: z57.object({
14482
+ code: z57.enum(TEAM_CREATION_BLOCKER_CODES),
14483
+ message: z57.string().describe("A sentence to show the user, saying what to do.")
14484
+ }).nullable().describe(
14485
+ "Why it isn't available, most fundamental first, or null when it is."
14486
+ )
14487
+ }).describe(
14488
+ "The `team` run scope. `personal` is always available to anyone who may create an automation."
14489
+ )
14490
+ });
14462
14491
  var teamConversionPreviewApiSchema = z57.object({
14463
14492
  personal_rows: z57.array(
14464
14493
  z57.object({
@@ -14509,6 +14538,36 @@ var automationTeamConversionResponseApiSchema = z57.object({
14509
14538
  blocker: teamConversionBlockerApiSchema.nullable(),
14510
14539
  preview: teamConversionPreviewApiSchema.nullable()
14511
14540
  });
14541
+ var teamConversionPublicPreviewApiSchema = z57.object({
14542
+ personal_row_totals: teamConversionPreviewApiSchema.shape.personal_row_totals.describe(
14543
+ "Members whose personal triggers and schedules on this automation conversion turns off, and how many of each."
14544
+ ),
14545
+ slots_without_team_connection: z57.number().int().describe(
14546
+ "Connection slots across the automation's Agents with no team Connection; a Team run can't use them until one is shared."
14547
+ ),
14548
+ secrets_without_team_access: z57.number().int().describe("Secrets the Agents use that a Team run can't read."),
14549
+ logins_without_team_access: z57.number().int().describe("Logins the Agents use that a Team run can't read."),
14550
+ own_aop_exceptions: z57.array(
14551
+ z57.object({
14552
+ id: z57.string(),
14553
+ agent_id: z57.string(),
14554
+ agent_name: z57.string(),
14555
+ label: z57.string(),
14556
+ enabled: z57.boolean()
14557
+ })
14558
+ ).describe(
14559
+ "The caller's own AOP exceptions on the automation. Pass their ids to convertAutomationToTeam to copy them as team exceptions."
14560
+ ),
14561
+ no_responsible_people: z57.boolean().describe(
14562
+ "No Responsible people are named, so requests would go to the team's Owners and Administrators."
14563
+ ),
14564
+ pending_cases: z57.number().int().describe("Pending cases a Team run would pick up.")
14565
+ });
14566
+ var automationTeamConversionPublicResponseApiSchema = z57.object({
14567
+ convertible: z57.boolean(),
14568
+ blocker: teamConversionBlockerApiSchema.nullable(),
14569
+ preview: teamConversionPublicPreviewApiSchema.nullable()
14570
+ });
14512
14571
  var automationTeamConversionClientResponseSchema = automationTeamConversionResponseApiSchema.extend({
14513
14572
  blocker: teamConversionBlockerApiSchema.extend({ code: z57.string() }).nullable(),
14514
14573
  preview: teamConversionPreviewApiSchema.extend({
@@ -16435,7 +16494,10 @@ var setUpModuleResponseApiSchema = z69.object({
16435
16494
  link: z69.string().nullable().describe(
16436
16495
  "Root-relative web-app path to the Automation's setup screen, or null when this viewer has no such tab."
16437
16496
  ),
16438
- url: z69.string().nullable().describe("The full web-app URL of `link`.")
16497
+ url: z69.string().nullable().describe("The full web-app URL of `link`."),
16498
+ run_scope: z69.enum(["personal", "team"]).optional().describe(
16499
+ "Who the new Automation's runs execute as: each member (`personal`) or the team (`team`), as the request asked. Optional because a backend that predates run scopes does not send it; read absence as `personal`."
16500
+ )
16439
16501
  });
16440
16502
  var generateAutomationProposalRequestApiSchema = z69.object({
16441
16503
  current_process_snapshot_id: z69.guid().optional().describe(
@@ -25313,9 +25375,34 @@ function registerAutomationsConvertToTeam(automations) {
25313
25375
  "--copy-exception <exception-id>",
25314
25376
  "copy one of your own AOP exceptions into team exceptions (repeatable)",
25315
25377
  collect6
25378
+ ).option(
25379
+ "--dry-run",
25380
+ "show whether it can be converted and what conversion would turn off, without converting"
25316
25381
  ).option("-y, --yes", "skip confirmation prompt").option("--json", "output raw JSON from the API").action(/* @__PURE__ */ __name(async function convertToTeamAction(id, options) {
25317
25382
  const automationId = trimRequired(id, "<id>");
25318
25383
  const { apiKey, apiBaseUrl } = await requireAuthenticatedConfig(this);
25384
+ if (options.dryRun) {
25385
+ const preview = await httpRequest({
25386
+ method: "GET",
25387
+ path: apiPath("/v2/automations/:automation_id/team-conversion", {
25388
+ automation_id: automationId
25389
+ }),
25390
+ apiKey,
25391
+ apiBaseUrl
25392
+ });
25393
+ if (options.json) {
25394
+ printJson(preview);
25395
+ return;
25396
+ }
25397
+ const parsedPreview = automationTeamConversionPublicResponseApiSchema.safeParse(preview);
25398
+ if (!parsedPreview.success) {
25399
+ throw new CliError(
25400
+ `Unexpected response from the API: ${parsedPreview.error.message}`
25401
+ );
25402
+ }
25403
+ printConversionPreview(automationId, parsedPreview.data);
25404
+ return;
25405
+ }
25319
25406
  await confirmDestructive({
25320
25407
  message: `Convert automation "${automationId}" to run as your team? Members' personal triggers and schedules on it will be turned off. This can't be undone.`,
25321
25408
  skip: Boolean(options.yes)
@@ -25370,12 +25457,125 @@ function registerAutomationsConvertToTeam(automations) {
25370
25457
  }, "convertToTeamAction"));
25371
25458
  }
25372
25459
  __name(registerAutomationsConvertToTeam, "registerAutomationsConvertToTeam");
25460
+ function printConversionPreview(automationId, { convertible, blocker, preview }) {
25461
+ if (!convertible || preview === null) {
25462
+ console.log(
25463
+ renderKeyValue([
25464
+ { label: "ID", value: automationId },
25465
+ { label: "Can convert", value: "No" },
25466
+ { label: "Why not", value: blocker?.message ?? "-" },
25467
+ { label: "Code", value: blocker?.code ?? "-" }
25468
+ ])
25469
+ );
25470
+ return;
25471
+ }
25472
+ console.log(
25473
+ renderKeyValue([
25474
+ { label: "ID", value: automationId },
25475
+ { label: "Can convert", value: "Yes" },
25476
+ {
25477
+ label: "Personal triggers turned off",
25478
+ value: String(preview.personal_row_totals.triggers)
25479
+ },
25480
+ {
25481
+ label: "Personal schedules turned off",
25482
+ value: String(preview.personal_row_totals.schedules)
25483
+ },
25484
+ {
25485
+ label: "Members with setup turned off",
25486
+ value: String(preview.personal_row_totals.members)
25487
+ },
25488
+ {
25489
+ label: "Connection slots without a team Connection",
25490
+ value: String(preview.slots_without_team_connection)
25491
+ },
25492
+ {
25493
+ label: "Secrets a Team run can't use",
25494
+ value: String(preview.secrets_without_team_access)
25495
+ },
25496
+ {
25497
+ label: "Logins a Team run can't use",
25498
+ value: String(preview.logins_without_team_access)
25499
+ },
25500
+ { label: "Pending cases", value: String(preview.pending_cases) }
25501
+ ])
25502
+ );
25503
+ if (preview.own_aop_exceptions.length > 0) {
25504
+ console.log();
25505
+ console.log("Your AOP exceptions you can copy with --copy-exception:");
25506
+ for (const exception of preview.own_aop_exceptions) {
25507
+ console.log(
25508
+ ` ${exception.id} ${exception.agent_name}: ${exception.label}`
25509
+ );
25510
+ }
25511
+ }
25512
+ console.log();
25513
+ console.log(
25514
+ `Nothing was changed. Run duvo automations convert-to-team ${automationId} to convert.`
25515
+ );
25516
+ }
25517
+ __name(printConversionPreview, "printConversionPreview");
25518
+
25519
+ // src/commands/shared/run-scope.ts
25520
+ import { InvalidArgumentError } from "commander";
25521
+ var RUN_SCOPE_OPTION_DESCRIPTION = "who the automation's runs execute as: personal (each member, the default) or team (shared Connections only; needs Lead Builder or above, can't be changed back)";
25522
+ function parseRunScope(value) {
25523
+ const scope = value.trim().toLowerCase();
25524
+ const match = AUTOMATION_RUN_SCOPES.find((candidate) => candidate === scope);
25525
+ if (match === void 0) {
25526
+ throw new InvalidArgumentError(
25527
+ `Use one of: ${AUTOMATION_RUN_SCOPES.join(", ")}`
25528
+ );
25529
+ }
25530
+ return match;
25531
+ }
25532
+ __name(parseRunScope, "parseRunScope");
25533
+ function runScopeLabel(scope) {
25534
+ return scope === "team" ? "Your team" : "Each member";
25535
+ }
25536
+ __name(runScopeLabel, "runScopeLabel");
25537
+ var UNSUPPORTED_MESSAGE = "This Duvo server doesn't support creating an automation that runs as the team, so nothing was created. Leave out --run-scope to create one that runs as each member.";
25538
+ async function assertTeamRunScopeAvailable(params) {
25539
+ let raw;
25540
+ try {
25541
+ raw = await httpRequest({
25542
+ method: "GET",
25543
+ path: buildTeamPath(params.teamId, "/automations/run-scope-options"),
25544
+ apiKey: params.apiKey,
25545
+ apiBaseUrl: params.apiBaseUrl
25546
+ });
25547
+ } catch (error) {
25548
+ if (error instanceof CliError && error.exitCode === EXIT_CODE.NOT_FOUND) {
25549
+ throw new CliError(UNSUPPORTED_MESSAGE);
25550
+ }
25551
+ throw error;
25552
+ }
25553
+ const parsed = runScopeOptionsResponseApiSchema.safeParse(raw);
25554
+ if (!parsed.success) {
25555
+ throw new CliError(UNSUPPORTED_MESSAGE);
25556
+ }
25557
+ const { blocker } = parsed.data.team;
25558
+ if (!parsed.data.team.available) {
25559
+ throw new CliError(
25560
+ `Can't create an automation that runs as your team: ${blocker?.message ?? "it isn't available"}${blocker ? ` (${blocker.code})` : ""}. Nothing was created.`
25561
+ );
25562
+ }
25563
+ }
25564
+ __name(assertTeamRunScopeAvailable, "assertTeamRunScopeAvailable");
25565
+ function assertRunScopeHonoured(requested, returned, accepted) {
25566
+ if (requested === "team" && returned !== "team") {
25567
+ throw new CliError(
25568
+ `The server didn't confirm --run-scope team, so the automation will run as each member. It may predate run scopes.${accepted ? ` It accepted ${accepted}.` : ""}`
25569
+ );
25570
+ }
25571
+ }
25572
+ __name(assertRunScopeHonoured, "assertRunScopeHonoured");
25373
25573
 
25374
25574
  // src/commands/automations/create.ts
25375
25575
  function registerAutomationsCreate(automations) {
25376
25576
  automations.command("create").description(
25377
25577
  "Create a new automation. Its first agent is created alongside it."
25378
- ).requiredOption("--name <name>", "automation name").option("--json", "output raw JSON from the API").action(/* @__PURE__ */ __name(async function createAction(options) {
25578
+ ).requiredOption("--name <name>", "automation name").option("--run-scope <scope>", RUN_SCOPE_OPTION_DESCRIPTION, parseRunScope).option("--json", "output raw JSON from the API").action(/* @__PURE__ */ __name(async function createAction(options) {
25379
25579
  const name = options.name?.trim();
25380
25580
  if (name === void 0 || name.length === 0) {
25381
25581
  throw new CliError("--name must not be empty");
@@ -25385,12 +25585,20 @@ function registerAutomationsCreate(automations) {
25385
25585
  const teamId = await resolveRequiredTeamId(config, {
25386
25586
  override: getTeamFlag(this)
25387
25587
  });
25588
+ if (options.runScope === "team") {
25589
+ await assertTeamRunScopeAvailable({ apiKey, apiBaseUrl, teamId });
25590
+ }
25388
25591
  const raw = await httpRequest({
25389
25592
  method: "POST",
25390
25593
  path: buildTeamPath(teamId, "/automations"),
25391
25594
  apiKey,
25392
25595
  apiBaseUrl,
25393
- body: { name }
25596
+ body: {
25597
+ name,
25598
+ ...options.runScope !== void 0 && {
25599
+ run_scope: options.runScope
25600
+ }
25601
+ }
25394
25602
  });
25395
25603
  if (options.json) {
25396
25604
  printJson(raw);
@@ -25409,6 +25617,7 @@ function registerAutomationsCreate(automations) {
25409
25617
  renderKeyValue([
25410
25618
  { label: "ID", value: automation.id },
25411
25619
  { label: "Name", value: automation.name },
25620
+ { label: "Runs as", value: runScopeLabel(automation.run_scope) },
25412
25621
  { label: "First agent", value: firstAgentId },
25413
25622
  { label: "Created", value: automation.created_at }
25414
25623
  ])
@@ -25953,6 +26162,12 @@ function registerAutomationsGenerateProposal(automations) {
25953
26162
  }
25954
26163
  __name(registerAutomationsGenerateProposal, "registerAutomationsGenerateProposal");
25955
26164
 
26165
+ // src/commands/automations/run-scope-label.ts
26166
+ function runScopeLabel2(runScope) {
26167
+ return runScope === "team" ? "Team" : "Each member";
26168
+ }
26169
+ __name(runScopeLabel2, "runScopeLabel");
26170
+
25956
26171
  // src/commands/automations/get.ts
25957
26172
  function registerAutomationsGet(automations) {
25958
26173
  automations.command("get <id>").description("Get an automation by ID").option("--json", "output raw JSON from the API").action(/* @__PURE__ */ __name(async function getAction(id, options) {
@@ -25978,6 +26193,13 @@ function registerAutomationsGet(automations) {
25978
26193
  renderKeyValue([
25979
26194
  { label: "ID", value: automation.id },
25980
26195
  { label: "Name", value: automation.name },
26196
+ { label: "Runs as", value: runScopeLabel2(automation.run_scope) },
26197
+ ...automation.run_scope === "team" && automation.converted_to_team_at ? [
26198
+ {
26199
+ label: "Switched to team",
26200
+ value: automation.converted_by_name ? `${automation.converted_to_team_at} by ${automation.converted_by_name}` : automation.converted_to_team_at
26201
+ }
26202
+ ] : [],
25981
26203
  { label: "Agents", value: String(automation.agent_count) },
25982
26204
  { label: "Queues", value: String(automation.queue_count) },
25983
26205
  {
@@ -26063,6 +26285,10 @@ var TABLE_COLUMNS12 = [
26063
26285
  cell: /* @__PURE__ */ __name((row) => row.name, "cell"),
26064
26286
  maxWidth: 40
26065
26287
  },
26288
+ {
26289
+ header: "RUNS AS",
26290
+ cell: /* @__PURE__ */ __name((row) => runScopeLabel2(row.run_scope), "cell")
26291
+ },
26066
26292
  {
26067
26293
  header: "AGENTS",
26068
26294
  cell: /* @__PURE__ */ __name((row) => String(row.agent_count), "cell")
@@ -26503,6 +26729,50 @@ function registerAutomationsRoles(automations) {
26503
26729
  }
26504
26730
  __name(registerAutomationsRoles, "registerAutomationsRoles");
26505
26731
 
26732
+ // src/commands/automations/run-scope-options.ts
26733
+ function registerAutomationsRunScopeOptions(automations) {
26734
+ automations.command("run-scope-options").description(
26735
+ "Show whether you can create an automation that runs as your team (--run-scope team), and why not."
26736
+ ).option("--json", "output raw JSON from the API").action(/* @__PURE__ */ __name(async function runScopeOptionsAction(options) {
26737
+ const config = await requireAuthenticatedConfig(this);
26738
+ const { apiKey, apiBaseUrl } = config;
26739
+ const teamId = await resolveRequiredTeamId(config, {
26740
+ override: getTeamFlag(this)
26741
+ });
26742
+ const raw = await httpRequest({
26743
+ method: "GET",
26744
+ path: buildTeamPath(teamId, "/automations/run-scope-options"),
26745
+ apiKey,
26746
+ apiBaseUrl
26747
+ });
26748
+ if (options.json) {
26749
+ printJson(raw);
26750
+ return;
26751
+ }
26752
+ const parsed = runScopeOptionsResponseApiSchema.safeParse(raw);
26753
+ if (!parsed.success) {
26754
+ throw new CliError(
26755
+ `Unexpected response from the API: ${parsed.error.message}`
26756
+ );
26757
+ }
26758
+ const { team } = parsed.data;
26759
+ console.log(
26760
+ renderKeyValue([
26761
+ { label: "Each member", value: "Available" },
26762
+ {
26763
+ label: "Your team",
26764
+ value: team.available ? "Available" : "Not available"
26765
+ },
26766
+ ...team.blocker ? [
26767
+ { label: "Why not", value: team.blocker.message },
26768
+ { label: "Code", value: team.blocker.code }
26769
+ ] : []
26770
+ ])
26771
+ );
26772
+ }, "runScopeOptionsAction"));
26773
+ }
26774
+ __name(registerAutomationsRunScopeOptions, "registerAutomationsRunScopeOptions");
26775
+
26506
26776
  // src/commands/automations/set-config-field.ts
26507
26777
  function describeAnswer(value) {
26508
26778
  return value === null || value === void 0 ? "no answer" : JSON.stringify(value);
@@ -26661,7 +26931,7 @@ function registerAutomationsSetUpModule(automations) {
26661
26931
  ).option(
26662
26932
  "--convert-demo",
26663
26933
  "if the team has a demo of this module open, turn it into the automation and delete its sample data (no undo)"
26664
- ).option("--json", "output raw JSON from the API").action(/* @__PURE__ */ __name(async function setUpModuleAction(slug, options) {
26934
+ ).option("--run-scope <scope>", RUN_SCOPE_OPTION_DESCRIPTION, parseRunScope).option("--json", "output raw JSON from the API").action(/* @__PURE__ */ __name(async function setUpModuleAction(slug, options) {
26665
26935
  if (!isModuleTemplateSlug(slug)) {
26666
26936
  throw new CliError(
26667
26937
  `Unknown module "${slug}". Use one of: ${MODULE_TEMPLATE_SLUG_VALUES.join(", ")}`
@@ -26672,6 +26942,9 @@ function registerAutomationsSetUpModule(automations) {
26672
26942
  const teamId = await resolveRequiredTeamId(config, {
26673
26943
  override: getTeamFlag(this)
26674
26944
  });
26945
+ if (options.runScope === "team") {
26946
+ await assertTeamRunScopeAvailable({ apiKey, apiBaseUrl, teamId });
26947
+ }
26675
26948
  let raw;
26676
26949
  try {
26677
26950
  raw = await httpRequest({
@@ -26682,7 +26955,12 @@ function registerAutomationsSetUpModule(automations) {
26682
26955
  }),
26683
26956
  apiKey,
26684
26957
  apiBaseUrl,
26685
- body: { convert_existing_demo: options.convertDemo === true }
26958
+ body: {
26959
+ convert_existing_demo: options.convertDemo === true,
26960
+ ...options.runScope !== void 0 && {
26961
+ run_scope: options.runScope
26962
+ }
26963
+ }
26686
26964
  });
26687
26965
  } catch (error) {
26688
26966
  if (error instanceof CliHttpError && error.status === 409 && // Not the rarer 409 for a demo that changed mid-setup.
@@ -26703,13 +26981,19 @@ function registerAutomationsSetUpModule(automations) {
26703
26981
  `Unexpected response from the API: ${parsed.error.message}`
26704
26982
  );
26705
26983
  }
26706
- const { automation_id: automationId, name, url } = parsed.data;
26984
+ const {
26985
+ automation_id: automationId,
26986
+ name,
26987
+ url,
26988
+ run_scope: runScope
26989
+ } = parsed.data;
26707
26990
  console.log(green("Module set up!"));
26708
26991
  console.log();
26709
26992
  console.log(
26710
26993
  renderKeyValue([
26711
26994
  { label: "ID", value: automationId },
26712
26995
  { label: "Name", value: name ?? "-" },
26996
+ { label: "Runs as", value: runScopeLabel(runScope) },
26713
26997
  { label: "Setup", value: url ?? "-" }
26714
26998
  ])
26715
26999
  );
@@ -26778,6 +27062,7 @@ function registerAutomations2(program) {
26778
27062
  registerAutomationsList(automations);
26779
27063
  registerAutomationsGet(automations);
26780
27064
  registerAutomationsCreate(automations);
27065
+ registerAutomationsRunScopeOptions(automations);
26781
27066
  registerAutomationsSetUpModule(automations);
26782
27067
  registerAutomationsGenerateProcessMap(automations);
26783
27068
  registerAutomationsGenerateProposal(automations);
@@ -31137,7 +31422,9 @@ import { z as z99 } from "zod";
31137
31422
  var responseSchema5 = z99.object({
31138
31423
  automation_run: z99.object({
31139
31424
  id: z99.string(),
31140
- status: z99.string()
31425
+ status: z99.string(),
31426
+ // Absent from a backend that predates run scopes.
31427
+ run_scope: z99.enum(["personal", "team"]).optional()
31141
31428
  })
31142
31429
  });
31143
31430
  function registerClarityBuildAutomation(clarity) {
@@ -31146,7 +31433,7 @@ function registerClarityBuildAutomation(clarity) {
31146
31433
  ).option(
31147
31434
  "--proposal-id <id>",
31148
31435
  "automation proposal snapshot to build from (defaults to the live proposal)"
31149
- ).option("--json", "output raw JSON from the API").action(/* @__PURE__ */ __name(async function action(processId, options) {
31436
+ ).option("--run-scope <scope>", RUN_SCOPE_OPTION_DESCRIPTION, parseRunScope).option("--json", "output raw JSON from the API").action(/* @__PURE__ */ __name(async function action(processId, options) {
31150
31437
  const { apiKey, apiBaseUrl } = await requireAuthenticatedConfig(this);
31151
31438
  const raw = await httpRequest({
31152
31439
  method: "POST",
@@ -31155,13 +31442,28 @@ function registerClarityBuildAutomation(clarity) {
31155
31442
  }),
31156
31443
  apiKey,
31157
31444
  apiBaseUrl,
31158
- body: options.proposalId ? { transformation_proposal_id: options.proposalId } : void 0
31445
+ body: options.proposalId || options.runScope ? {
31446
+ ...options.proposalId && {
31447
+ transformation_proposal_id: options.proposalId
31448
+ },
31449
+ ...options.runScope && { run_scope: options.runScope }
31450
+ } : void 0
31159
31451
  });
31452
+ const parsed = responseSchema5.safeParse(raw);
31160
31453
  if (options.json) {
31161
31454
  printJson(raw);
31455
+ }
31456
+ if (options.runScope === "team") {
31457
+ const acceptedRunId = parsed.data?.automation_run.id;
31458
+ assertRunScopeHonoured(
31459
+ options.runScope,
31460
+ parsed.data?.automation_run.run_scope,
31461
+ acceptedRunId ? `build run ${acceptedRunId}` : void 0
31462
+ );
31463
+ }
31464
+ if (options.json) {
31162
31465
  return;
31163
31466
  }
31164
- const parsed = responseSchema5.safeParse(raw);
31165
31467
  if (!parsed.success) {
31166
31468
  throw new CliError(
31167
31469
  `Unexpected response from the API: ${parsed.error.message}`
@@ -31171,7 +31473,8 @@ function registerClarityBuildAutomation(clarity) {
31171
31473
  console.log(
31172
31474
  renderKeyValue([
31173
31475
  { label: "Run ID", value: run.id },
31174
- { label: "Status", value: run.status }
31476
+ { label: "Status", value: run.status },
31477
+ { label: "Runs as", value: runScopeLabel(run.run_scope) }
31175
31478
  ])
31176
31479
  );
31177
31480
  }, "action"));
@@ -53847,6 +54150,7 @@ var PERMISSION = {
53847
54150
  AUTOMATION_DETAILS_EDIT: "automation.details.edit",
53848
54151
  AUTOMATION_POLICY_MANAGE: "automation.policy.manage",
53849
54152
  AUTOMATION_CONVERT_TO_TEAM: "automation.convert_to_team",
54153
+ AUTOMATION_CREATE_TEAM: "automation.create_team",
53850
54154
  AUTOMATION_ATTRIBUTE_MANAGE: "automation.attribute.manage",
53851
54155
  ROUTINE_VIEW: "routine.view",
53852
54156
  ROUTINE_DECIDE: "routine.decide",
@@ -54656,6 +54960,13 @@ var TEAM_PERMISSION_META = {
54656
54960
  implies: [P4.AUTOMATION_VIEW],
54657
54961
  validScopes: SCOPES3
54658
54962
  },
54963
+ [P4.AUTOMATION_CREATE_TEAM]: {
54964
+ domain: D3.AUTOMATIONS,
54965
+ label: "Create automations that run as the team",
54966
+ help: "Create a new automation whose runs execute as the team, with shared Connections, Secrets and Logins only, instead of as each member.",
54967
+ implies: [P4.AUTOMATION_MANAGE],
54968
+ validScopes: SCOPES3
54969
+ },
54659
54970
  [P4.AUTOMATION_ATTRIBUTE_MANAGE]: {
54660
54971
  domain: D3.AUTOMATIONS,
54661
54972
  label: "Manage process attributes",
@@ -55138,6 +55449,7 @@ var LEAD_BUILDER_TIER = [
55138
55449
  P5.AGENT_MEMORY_MANAGE_OTHERS,
55139
55450
  P5.AGENT_PROMOTE_OTHERS,
55140
55451
  P5.APIKEY_MANAGE_OTHERS,
55452
+ P5.AUTOMATION_CREATE_TEAM,
55141
55453
  P5.AUTOMATION_MANAGE_OTHERS,
55142
55454
  P5.LOGIN_MANAGE,
55143
55455
  P5.PROCESS_COMPLETE,
@@ -57012,12 +57324,6 @@ var FEATURE_FLAG_CATALOGUE = {
57012
57324
  stage: "temporary",
57013
57325
  description: "Enables proactive OAuth access-token refresh for a team's Connections. When on, the minutely dispatcher refreshes tokens near expiry and cc-server replaces baked OAuth headers during long Runs. Cloud Tasks recheck the flag before each provider exchange, so turning it off also stops queued work. Off by default for staged team and organization rollout."
57014
57326
  },
57015
- CONNECTION_KEEP_ALIVE: {
57016
- key: "connection_keep_alive",
57017
- defaultValue: false,
57018
- stage: "temporary",
57019
- description: "Enables the daily Connection keep-alive cron for a team \u2014 a forced OAuth token exchange for that team's eligible Connections not exchanged for in 20h, which keeps refresh tokens from lapsing through inactivity and surfaces dead grants within a day. Resolved with FULL precedence (user, then team, then organization, then global), so an org-wide or global override DOES enroll teams: setting one enrolls every team that owns an eligible Connection, and is not a no-op. Enrolment is bounded to those owning teams rather than the whole database, and an explicit false at a narrower tier still wins. With nothing enabled the cron touches nothing while last_token_exchange_at fills in from run-triggered exchanges. The Cloud Scheduler job is a separate fleet-wide switch; this flag is what allows a staged rollout and per-team exclusion."
57020
- },
57021
57327
  NEW_AGENT_DEFAULT_KIMI_DUVO: {
57022
57328
  key: "new_agent_default_kimi_duvo",
57023
57329
  defaultValue: false,
@@ -77253,7 +77559,10 @@ var adminModelUsageReasoningSeriesSchema = z932.object({
77253
77559
  var adminModelUsageResponseSchema = z932.object({
77254
77560
  /** When the counts were read, as an ISO 8601 timestamp. */
77255
77561
  asOf: z932.string(),
77256
- /** UTC days as `YYYY-MM-DD`, oldest first; the last is today. */
77562
+ /**
77563
+ * UTC days as `YYYY-MM-DD`, oldest first; the last is today. The last 24
77564
+ * hours span two of them, each counted only in part.
77565
+ */
77257
77566
  dates: z932.array(z932.string()),
77258
77567
  /** The organization the Runs belong to. */
77259
77568
  organization: z932.object({
@@ -77266,6 +77575,29 @@ var adminModelUsageResponseSchema = z932.object({
77266
77575
  /** One series per reasoning effort with at least one Run in the range. */
77267
77576
  reasoningEfforts: z932.array(adminModelUsageReasoningSeriesSchema)
77268
77577
  });
77578
+ var adminModelUsageAgentCostSchema = z932.object({
77579
+ agentId: z932.string(),
77580
+ name: z932.string(),
77581
+ /** The revision to open for the agent; null when it has none left. */
77582
+ buildId: z932.string().nullable(),
77583
+ /** Runs created in the range. */
77584
+ runs: countSchema2,
77585
+ /** Those of them with a recorded cost; older Runs have none. */
77586
+ costedRuns: countSchema2,
77587
+ /**
77588
+ * What those Runs spent on inference, in US dollars: every LLM call made
77589
+ * for them, whichever component made it.
77590
+ */
77591
+ inferenceCostUsd: z932.number().nonnegative()
77592
+ });
77593
+ var adminModelUsageAgentCostsResponseSchema = z932.object({
77594
+ /** Most expensive first, at most `ADMIN_MODEL_USAGE_AGENT_COST_LIMIT`. */
77595
+ agents: z932.array(adminModelUsageAgentCostSchema),
77596
+ /** Existing agents with a Run in the range, including any past the limit. */
77597
+ totalAgents: countSchema2,
77598
+ /** The inference cost of all of them, in US dollars. */
77599
+ totalInferenceCostUsd: z932.number().nonnegative()
77600
+ });
77269
77601
  var ADMIN_NOTIFICATION_LIST_DEFAULT_LIMIT = 50;
77270
77602
  var ADMIN_NOTIFICATION_LIST_MAX_LIMIT = 200;
77271
77603
  var ADMIN_NOTIFICATION_NO_TEAM = "none";
@@ -81924,6 +82256,10 @@ var setProcessAttributeValueBodyApiSchema2 = z1292.discriminatedUnion(
81924
82256
  })
81925
82257
  ]
81926
82258
  );
82259
+ var AUTOMATION_RUN_SCOPES2 = ["personal", "team"];
82260
+ var createRunScopeRequestApiSchema2 = z1302.enum(AUTOMATION_RUN_SCOPES2).default("personal").describe(
82261
+ "Who the new automation's runs execute as: `personal` (the default) runs as each member with their own Connections; `team` runs as the team with shared Connections, Secrets and Logins only, and can't be changed back. `team` needs Lead Builder or above, the Team automations feature, a team on the Automations workspace and not on automation revisions, and Connection sharing on; read `GET /v2/teams/{teamId}/automations/run-scope-options` to see whether it is available and why not. Refused with 409 and the blocker's `code` when it isn't, or 403 `permission_required` for a caller below Lead Builder."
82262
+ );
81927
82263
  var automationSetupProgressApiSchema2 = z1302.object({
81928
82264
  has_captures: z1302.boolean(),
81929
82265
  has_process_map: z1302.boolean(),
@@ -81960,14 +82296,17 @@ var automationSummaryApiSchema2 = z1302.object({
81960
82296
  setup_progress: automationSetupProgressApiSchema2.nullable().default(null).describe(
81961
82297
  "The setup facts behind the tile's Setup badge \u2014 captures uploaded, the team's own process map generated, a proposal written \u2014 or null while the automation is not being set up (and whenever it has no module process for the facts to hang off)."
81962
82298
  ),
81963
- run_scope: z1302.enum(["personal", "team"]).optional().describe(
81964
- "Who the automation's runs execute as: its members, each with their own Connections (`personal`), or the team, with shared Connections only (`team`). An automation becomes `team` once, through convert-to-team, and never goes back. Optional because a backend that predates Team automations does not send it; a client treats absence as `personal` and offers no conversion."
82299
+ run_scope: z1302.enum(AUTOMATION_RUN_SCOPES2).optional().describe(
82300
+ "Who the automation's runs execute as: its members, each with their own Connections (`personal`), or the team, with shared Connections only (`team`). An automation is created as either, and a `personal` one can later be converted to `team`; a `team` one never goes back. Optional because a backend that predates Team automations does not send it; a client reads absence as `personal`."
81965
82301
  ),
81966
82302
  converted_to_team_at: z1302.string().nullable().optional().describe(
81967
- "When the automation was converted to run as the team, or null while it runs as its members."
82303
+ "When the automation was converted to run as the team, or null while it runs as its members or when it was created to run as the team."
81968
82304
  ),
81969
82305
  converted_by: z1302.guid().nullable().optional().describe(
81970
- "The member who converted the automation to run as the team, or null while it runs as its members or when that member is gone."
82306
+ "The member who converted the automation to run as the team, or null while it runs as its members, when it was created to run as the team, or when that member is gone."
82307
+ ),
82308
+ converted_by_name: z1302.string().nullable().optional().describe(
82309
+ "The display name of the member who converted the automation to run as the team, or null while it runs as its members, when that member is gone, or when they set no name. Never their email. Optional because an older backend does not send it."
81971
82310
  ),
81972
82311
  viewer_can_edit: z1302.boolean().optional().describe(
81973
82312
  "Whether the caller may change this automation. An automation takes its agents' ownership rule: a Builder may edit one whose every agent they created, and Lead Builder or above may edit any. Sent by the list and detail endpoints; absent from create and update responses, where the client falls back to the caller's role."
@@ -82180,6 +82519,28 @@ var teamConversionBlockerApiSchema2 = z1302.object({
82180
82519
  queue_automation_id: z1302.string().nullable(),
82181
82520
  queue_automation_name: z1302.string().nullable()
82182
82521
  });
82522
+ var TEAM_CREATION_BLOCKER_CODES2 = [
82523
+ "automations_workspace_required",
82524
+ "team_automations_flag_off",
82525
+ "automation_revisions",
82526
+ "connection_sharing_off",
82527
+ "permission_required"
82528
+ ];
82529
+ var runScopeOptionsResponseApiSchema2 = z1302.object({
82530
+ team: z1302.object({
82531
+ available: z1302.boolean().describe(
82532
+ "Whether the caller may create an automation that runs as the team (`run_scope: team`) in this team now."
82533
+ ),
82534
+ blocker: z1302.object({
82535
+ code: z1302.enum(TEAM_CREATION_BLOCKER_CODES2),
82536
+ message: z1302.string().describe("A sentence to show the user, saying what to do.")
82537
+ }).nullable().describe(
82538
+ "Why it isn't available, most fundamental first, or null when it is."
82539
+ )
82540
+ }).describe(
82541
+ "The `team` run scope. `personal` is always available to anyone who may create an automation."
82542
+ )
82543
+ });
82183
82544
  var teamConversionPreviewApiSchema2 = z1302.object({
82184
82545
  personal_rows: z1302.array(
82185
82546
  z1302.object({
@@ -82230,6 +82591,36 @@ var automationTeamConversionResponseApiSchema2 = z1302.object({
82230
82591
  blocker: teamConversionBlockerApiSchema2.nullable(),
82231
82592
  preview: teamConversionPreviewApiSchema2.nullable()
82232
82593
  });
82594
+ var teamConversionPublicPreviewApiSchema2 = z1302.object({
82595
+ personal_row_totals: teamConversionPreviewApiSchema2.shape.personal_row_totals.describe(
82596
+ "Members whose personal triggers and schedules on this automation conversion turns off, and how many of each."
82597
+ ),
82598
+ slots_without_team_connection: z1302.number().int().describe(
82599
+ "Connection slots across the automation's Agents with no team Connection; a Team run can't use them until one is shared."
82600
+ ),
82601
+ secrets_without_team_access: z1302.number().int().describe("Secrets the Agents use that a Team run can't read."),
82602
+ logins_without_team_access: z1302.number().int().describe("Logins the Agents use that a Team run can't read."),
82603
+ own_aop_exceptions: z1302.array(
82604
+ z1302.object({
82605
+ id: z1302.string(),
82606
+ agent_id: z1302.string(),
82607
+ agent_name: z1302.string(),
82608
+ label: z1302.string(),
82609
+ enabled: z1302.boolean()
82610
+ })
82611
+ ).describe(
82612
+ "The caller's own AOP exceptions on the automation. Pass their ids to convertAutomationToTeam to copy them as team exceptions."
82613
+ ),
82614
+ no_responsible_people: z1302.boolean().describe(
82615
+ "No Responsible people are named, so requests would go to the team's Owners and Administrators."
82616
+ ),
82617
+ pending_cases: z1302.number().int().describe("Pending cases a Team run would pick up.")
82618
+ });
82619
+ var automationTeamConversionPublicResponseApiSchema2 = z1302.object({
82620
+ convertible: z1302.boolean(),
82621
+ blocker: teamConversionBlockerApiSchema2.nullable(),
82622
+ preview: teamConversionPublicPreviewApiSchema2.nullable()
82623
+ });
82233
82624
  var automationTeamConversionClientResponseSchema2 = automationTeamConversionResponseApiSchema2.extend({
82234
82625
  blocker: teamConversionBlockerApiSchema2.extend({ code: z1302.string() }).nullable(),
82235
82626
  preview: teamConversionPreviewApiSchema2.extend({
@@ -83042,7 +83433,10 @@ var setUpModuleResponseApiSchema2 = z1322.object({
83042
83433
  link: z1322.string().nullable().describe(
83043
83434
  "Root-relative web-app path to the Automation's setup screen, or null when this viewer has no such tab."
83044
83435
  ),
83045
- url: z1322.string().nullable().describe("The full web-app URL of `link`.")
83436
+ url: z1322.string().nullable().describe("The full web-app URL of `link`."),
83437
+ run_scope: z1322.enum(["personal", "team"]).optional().describe(
83438
+ "Who the new Automation's runs execute as: each member (`personal`) or the team (`team`), as the request asked. Optional because a backend that predates run scopes does not send it; read absence as `personal`."
83439
+ )
83046
83440
  });
83047
83441
  var generateAutomationProposalRequestApiSchema2 = z1322.object({
83048
83442
  current_process_snapshot_id: z1322.guid().optional().describe(
@@ -90798,7 +91192,7 @@ __name(isStandaloneBinary, "isStandaloneBinary");
90798
91192
  import { createRequire } from "node:module";
90799
91193
  function getPackageMeta() {
90800
91194
  if (true) {
90801
- return { name: "@duvoai/cli", version: "1.115.0" };
91195
+ return { name: "@duvoai/cli", version: "1.116.0" };
90802
91196
  }
90803
91197
  const require2 = createRequire(import.meta.url);
90804
91198
  const raw = require2("../../package.json");