@rudderhq/cli 0.3.4-canary.2 → 0.3.4-canary.21

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
@@ -10,7 +10,7 @@ var __export = (target, all) => {
10
10
  };
11
11
 
12
12
  // ../packages/shared/dist/constants.js
13
- var ORGANIZATION_STATUSES, ORGANIZATION_INTELLIGENCE_PROFILE_PURPOSES, ORGANIZATION_INTELLIGENCE_PROFILE_STATUSES, DEPLOYMENT_MODES, DEPLOYMENT_EXPOSURES, AUTH_BASE_URL_MODES, AGENT_STATUSES, AGENT_RUNTIME_TYPES, AGENT_ROLES, AGENT_ICON_NAMES, AGENT_DICEBEAR_NOTIONISTS_ICON_PREFIX, AGENT_AVATAR_BACKGROUND_PRESET_IDS, ISSUE_STATUSES, ISSUE_PRIORITIES, CALENDAR_SOURCE_TYPES, CALENDAR_OWNER_TYPES, CALENDAR_VISIBILITIES, CALENDAR_SOURCE_STATUSES, CALENDAR_EVENT_KINDS, CALENDAR_EVENT_STATUSES, CALENDAR_SOURCE_MODES, CHAT_CONVERSATION_STATUSES, CHAT_ISSUE_CREATION_MODES, CHAT_MESSAGE_ROLES, CHAT_MESSAGE_KINDS, CHAT_MESSAGE_STATUSES, CHAT_CONTEXT_ENTITY_TYPES, GOAL_LEVELS, GOAL_STATUSES, PROJECT_STATUSES, ORGANIZATION_RESOURCE_KINDS, ORGANIZATION_RESOURCE_SOURCE_TYPES, PROJECT_RESOURCE_ATTACHMENT_ROLES, AUTOMATION_STATUSES, AUTOMATION_CONCURRENCY_POLICIES, AUTOMATION_CATCH_UP_POLICIES, AUTOMATION_OUTPUT_MODES, AUTOMATION_TRIGGER_SIGNING_MODES, PROJECT_COLORS, APPROVAL_TYPES, SECRET_PROVIDERS, STORAGE_PROVIDERS, BILLING_TYPES, FINANCE_EVENT_KINDS, FINANCE_DIRECTIONS, FINANCE_UNITS, BUDGET_SCOPE_TYPES, BUDGET_METRICS, BUDGET_WINDOW_KINDS, BUDGET_INCIDENT_RESOLUTION_ACTIONS, INVITE_JOIN_TYPES, JOIN_REQUEST_TYPES, JOIN_REQUEST_STATUSES, PERMISSION_KEYS, PLUGIN_STATUSES, PLUGIN_CATEGORIES, PLUGIN_CAPABILITIES, PLUGIN_UI_SLOT_TYPES, PLUGIN_RESERVED_COMPANY_ROUTE_SEGMENTS, PLUGIN_LAUNCHER_PLACEMENT_ZONES, PLUGIN_LAUNCHER_ACTIONS, PLUGIN_LAUNCHER_BOUNDS, PLUGIN_LAUNCHER_RENDER_ENVIRONMENTS, PLUGIN_UI_SLOT_ENTITY_TYPES, PLUGIN_STATE_SCOPE_KINDS;
13
+ var ORGANIZATION_STATUSES, ORGANIZATION_INTELLIGENCE_PROFILE_PURPOSES, ORGANIZATION_INTELLIGENCE_PROFILE_STATUSES, DEPLOYMENT_MODES, DEPLOYMENT_EXPOSURES, AUTH_BASE_URL_MODES, AGENT_STATUSES, AGENT_RUNTIME_TYPES, AGENT_ROLES, AGENT_ICON_NAMES, AGENT_DICEBEAR_NOTIONISTS_ICON_PREFIX, AGENT_AVATAR_BACKGROUND_PRESET_IDS, ISSUE_STATUSES, ISSUE_PRIORITIES, CALENDAR_SOURCE_TYPES, CALENDAR_OWNER_TYPES, CALENDAR_VISIBILITIES, CALENDAR_SOURCE_STATUSES, CALENDAR_EVENT_KINDS, CALENDAR_EVENT_STATUSES, CALENDAR_SOURCE_MODES, CHAT_CONVERSATION_STATUSES, CHAT_ISSUE_CREATION_MODES, CHAT_MESSAGE_ROLES, CHAT_MESSAGE_KINDS, CHAT_MESSAGE_STATUSES, CHAT_CONTEXT_ENTITY_TYPES, GOAL_LEVELS, GOAL_STATUSES, PROJECT_STATUSES, ORGANIZATION_RESOURCE_KINDS, ORGANIZATION_RESOURCE_SOURCE_TYPES, PROJECT_RESOURCE_ATTACHMENT_ROLES, AUTOMATION_STATUSES, AUTOMATION_CONCURRENCY_POLICIES, AUTOMATION_CATCH_UP_POLICIES, AUTOMATION_OUTPUT_MODES, AUTOMATION_TRIGGER_SIGNING_MODES, PROJECT_COLORS, PROJECT_ICONS, APPROVAL_TYPES, SECRET_PROVIDERS, STORAGE_PROVIDERS, BILLING_TYPES, FINANCE_EVENT_KINDS, FINANCE_DIRECTIONS, FINANCE_UNITS, BUDGET_SCOPE_TYPES, BUDGET_METRICS, BUDGET_WINDOW_KINDS, BUDGET_INCIDENT_RESOLUTION_ACTIONS, INVITE_JOIN_TYPES, JOIN_REQUEST_TYPES, JOIN_REQUEST_STATUSES, PERMISSION_KEYS, PLUGIN_STATUSES, PLUGIN_CATEGORIES, PLUGIN_CAPABILITIES, PLUGIN_UI_SLOT_TYPES, PLUGIN_RESERVED_COMPANY_ROUTE_SEGMENTS, PLUGIN_LAUNCHER_PLACEMENT_ZONES, PLUGIN_LAUNCHER_ACTIONS, PLUGIN_LAUNCHER_BOUNDS, PLUGIN_LAUNCHER_RENDER_ENVIRONMENTS, PLUGIN_UI_SLOT_ENTITY_TYPES, PLUGIN_STATE_SCOPE_KINDS;
14
14
  var init_constants = __esm({
15
15
  "../packages/shared/dist/constants.js"() {
16
16
  "use strict";
@@ -186,6 +186,24 @@ var init_constants = __esm({
186
186
  "linear-gradient(135deg, #475569 0%, #0f766e 100%)",
187
187
  "linear-gradient(135deg, #334155 0%, #7c3aed 100%)"
188
188
  ];
189
+ PROJECT_ICONS = [
190
+ "folder",
191
+ "book",
192
+ "plane",
193
+ "globe",
194
+ "code",
195
+ "rocket",
196
+ "target",
197
+ "lightbulb",
198
+ "wrench",
199
+ "shield",
200
+ "database",
201
+ "megaphone",
202
+ "palette",
203
+ "users",
204
+ "calendar",
205
+ "package"
206
+ ];
189
207
  APPROVAL_TYPES = [
190
208
  "hire_agent",
191
209
  "approve_ceo_strategy",
@@ -428,7 +446,7 @@ var init_workspace_backup = __esm({
428
446
 
429
447
  // ../packages/shared/dist/validators/instance.js
430
448
  import { z } from "zod";
431
- var instanceLocaleSchema, instanceGeneralSettingsSchema, patchInstanceGeneralSettingsSchema, instanceNotificationSettingsSchema, patchInstanceNotificationSettingsSchema, instanceLangfuseSettingsSchema, patchInstanceLangfuseSettingsSchema, OPERATOR_PROFILE_MORE_ABOUT_YOU_MAX_LENGTH, operatorProfileSettingsSchema, patchOperatorProfileSettingsSchema, instancePathPickerSelectionTypeSchema, instancePathPickerRequestSchema, instancePathPickerResultSchema;
449
+ var instanceLocaleSchema, instanceGeneralSettingsSchema, patchInstanceGeneralSettingsSchema, instanceNotificationSettingsSchema, patchInstanceNotificationSettingsSchema, instanceLangfuseSettingsSchema, patchInstanceLangfuseSettingsSchema, OPERATOR_PROFILE_MORE_ABOUT_YOU_MAX_LENGTH, operatorProfileSettingsSchema, patchOperatorProfileSettingsSchema, KEYBOARD_SHORTCUT_ACTION_IDS, keyboardShortcutActionIdSchema, keyboardShortcutBindingSchema, keyboardShortcutPreferenceSchema, keyboardShortcutSettingsSchema, instancePathPickerSelectionTypeSchema, instancePathPickerRequestSchema, instancePathPickerResultSchema;
432
450
  var init_instance = __esm({
433
451
  "../packages/shared/dist/validators/instance.js"() {
434
452
  "use strict";
@@ -468,6 +486,43 @@ var init_instance = __esm({
468
486
  moreAboutYou: z.string().max(OPERATOR_PROFILE_MORE_ABOUT_YOU_MAX_LENGTH).default("")
469
487
  }).strict();
470
488
  patchOperatorProfileSettingsSchema = operatorProfileSettingsSchema.partial();
489
+ KEYBOARD_SHORTCUT_ACTION_IDS = [
490
+ "commandPalette.open",
491
+ "settings.open",
492
+ "issue.create",
493
+ "sidebar.toggle",
494
+ "panel.toggle"
495
+ ];
496
+ keyboardShortcutActionIdSchema = z.enum(KEYBOARD_SHORTCUT_ACTION_IDS);
497
+ keyboardShortcutBindingSchema = z.object({
498
+ key: z.string().trim().min(1).max(64),
499
+ code: z.string().trim().min(1).max(80).optional(),
500
+ metaKey: z.boolean().optional(),
501
+ ctrlKey: z.boolean().optional(),
502
+ altKey: z.boolean().optional(),
503
+ shiftKey: z.boolean().optional()
504
+ }).strict();
505
+ keyboardShortcutPreferenceSchema = z.object({
506
+ actionId: keyboardShortcutActionIdSchema,
507
+ bindings: z.array(keyboardShortcutBindingSchema).max(4).optional(),
508
+ disabled: z.boolean().optional()
509
+ }).strict();
510
+ keyboardShortcutSettingsSchema = z.object({
511
+ shortcuts: z.array(keyboardShortcutPreferenceSchema).max(KEYBOARD_SHORTCUT_ACTION_IDS.length).default([])
512
+ }).strict().superRefine((value, ctx) => {
513
+ const seen = /* @__PURE__ */ new Set();
514
+ value.shortcuts.forEach((shortcut, index) => {
515
+ if (seen.has(shortcut.actionId)) {
516
+ ctx.addIssue({
517
+ code: z.ZodIssueCode.custom,
518
+ message: `Duplicate shortcut action id: ${shortcut.actionId}`,
519
+ path: ["shortcuts", index, "actionId"]
520
+ });
521
+ return;
522
+ }
523
+ seen.add(shortcut.actionId);
524
+ });
525
+ });
471
526
  instancePathPickerSelectionTypeSchema = z.enum(["file", "directory"]);
472
527
  instancePathPickerRequestSchema = z.object({
473
528
  selectionType: instancePathPickerSelectionTypeSchema
@@ -1571,7 +1626,7 @@ function validateProjectWorkspace(value, ctx) {
1571
1626
  });
1572
1627
  }
1573
1628
  }
1574
- var executionWorkspaceStrategySchema, projectExecutionWorkspacePolicySchema, projectWorkspaceSourceTypeSchema, projectWorkspaceVisibilitySchema, projectWorkspaceFields, projectColorValues, legacyProjectColorSchema, projectColorSchema, createProjectWorkspaceSchema, updateProjectWorkspaceSchema, projectFields, createProjectSchema, updateProjectSchema;
1629
+ var executionWorkspaceStrategySchema, projectExecutionWorkspacePolicySchema, projectWorkspaceSourceTypeSchema, projectWorkspaceVisibilitySchema, projectWorkspaceFields, projectColorValues, legacyProjectColorSchema, projectColorSchema, projectIconSchema, createProjectWorkspaceSchema, updateProjectWorkspaceSchema, projectFields, createProjectSchema, updateProjectSchema;
1575
1630
  var init_project = __esm({
1576
1631
  "../packages/shared/dist/validators/project.js"() {
1577
1632
  "use strict";
@@ -1617,6 +1672,7 @@ var init_project = __esm({
1617
1672
  projectColorValues = new Set(PROJECT_COLORS);
1618
1673
  legacyProjectColorSchema = z13.string().regex(/^#[0-9a-fA-F]{6}$/);
1619
1674
  projectColorSchema = z13.string().refine((value) => legacyProjectColorSchema.safeParse(value).success || projectColorValues.has(value), "Color must be a 6-digit hex value or a supported project gradient");
1675
+ projectIconSchema = z13.enum(PROJECT_ICONS);
1620
1676
  createProjectWorkspaceSchema = z13.object({
1621
1677
  ...projectWorkspaceFields,
1622
1678
  isPrimary: z13.boolean().optional().default(false)
@@ -1635,6 +1691,7 @@ var init_project = __esm({
1635
1691
  leadAgentId: z13.string().uuid().optional().nullable(),
1636
1692
  targetDate: z13.string().optional().nullable(),
1637
1693
  color: projectColorSchema.optional().nullable(),
1694
+ icon: projectIconSchema.optional().nullable(),
1638
1695
  executionWorkspacePolicy: projectExecutionWorkspacePolicySchema.optional().nullable(),
1639
1696
  resourceAttachments: z13.array(projectResourceAttachmentInputSchema).optional(),
1640
1697
  newResources: z13.array(createProjectInlineResourceSchema).optional(),
@@ -1649,12 +1706,12 @@ var init_project = __esm({
1649
1706
 
1650
1707
  // ../packages/shared/dist/validators/issue.js
1651
1708
  import { z as z14 } from "zod";
1652
- var executionWorkspaceStrategySchema2, issueExecutionWorkspaceSettingsSchema, issueAssigneeAdapterOverridesSchema, createIssueSchema, createIssueLabelSchema, updateIssueLabelSchema, updateIssueSchema, reorderIssueSchema, checkoutIssueSchema, addIssueCommentSchema, updateIssueCommentSchema, reportIssueCommitSchema, linkIssueApprovalSchema, createIssueAttachmentMetadataSchema, createIssueWorkspaceAttachmentSchema, ISSUE_DOCUMENT_FORMATS, issueDocumentFormatSchema, issueDocumentKeySchema, upsertIssueDocumentSchema, createLibraryDocumentSchema, updateLibraryDocumentSchema, restoreLibraryDocumentRevisionSchema;
1709
+ var runWorkspaceStrategySchema, issueRunWorkspaceSettingsSchema, issueAssigneeAdapterOverridesSchema, createIssueSchema, createIssueLabelSchema, updateIssueLabelSchema, updateIssueSchema, reorderIssueSchema, checkoutIssueSchema, addIssueCommentSchema, updateIssueCommentSchema, reportIssueCommitSchema, linkIssueApprovalSchema, createIssueAttachmentMetadataSchema, createIssueWorkspaceAttachmentSchema, ISSUE_DOCUMENT_FORMATS, issueDocumentFormatSchema, issueDocumentKeySchema, upsertIssueDocumentSchema, createLibraryDocumentSchema, updateLibraryDocumentSchema, restoreLibraryDocumentRevisionSchema;
1653
1710
  var init_issue = __esm({
1654
1711
  "../packages/shared/dist/validators/issue.js"() {
1655
1712
  "use strict";
1656
1713
  init_constants();
1657
- executionWorkspaceStrategySchema2 = z14.object({
1714
+ runWorkspaceStrategySchema = z14.object({
1658
1715
  type: z14.enum(["project_primary", "git_worktree", "adapter_managed", "cloud_sandbox"]).optional(),
1659
1716
  baseRef: z14.string().optional().nullable(),
1660
1717
  branchTemplate: z14.string().optional().nullable(),
@@ -1662,9 +1719,9 @@ var init_issue = __esm({
1662
1719
  provisionCommand: z14.string().optional().nullable(),
1663
1720
  teardownCommand: z14.string().optional().nullable()
1664
1721
  }).strict();
1665
- issueExecutionWorkspaceSettingsSchema = z14.object({
1722
+ issueRunWorkspaceSettingsSchema = z14.object({
1666
1723
  mode: z14.enum(["inherit", "shared_workspace", "isolated_workspace", "operator_branch", "reuse_existing", "agent_default"]).optional(),
1667
- workspaceStrategy: executionWorkspaceStrategySchema2.optional().nullable(),
1724
+ workspaceStrategy: runWorkspaceStrategySchema.optional().nullable(),
1668
1725
  workspaceRuntime: z14.record(z14.unknown()).optional().nullable()
1669
1726
  }).strict();
1670
1727
  issueAssigneeAdapterOverridesSchema = z14.object({
@@ -1687,7 +1744,19 @@ var init_issue = __esm({
1687
1744
  requestDepth: z14.number().int().nonnegative().optional().default(0),
1688
1745
  billingCode: z14.string().optional().nullable(),
1689
1746
  assigneeAgentRuntimeOverrides: issueAssigneeAdapterOverridesSchema.optional().nullable(),
1747
+ runWorkspaceId: z14.string().uuid().optional().nullable(),
1748
+ runWorkspacePreference: z14.enum([
1749
+ "inherit",
1750
+ "shared_workspace",
1751
+ "isolated_workspace",
1752
+ "operator_branch",
1753
+ "reuse_existing",
1754
+ "agent_default"
1755
+ ]).optional().nullable(),
1756
+ runWorkspaceSettings: issueRunWorkspaceSettingsSchema.optional().nullable(),
1757
+ /** @deprecated Use runWorkspaceId. */
1690
1758
  executionWorkspaceId: z14.string().uuid().optional().nullable(),
1759
+ /** @deprecated Use runWorkspacePreference. */
1691
1760
  executionWorkspacePreference: z14.enum([
1692
1761
  "inherit",
1693
1762
  "shared_workspace",
@@ -1696,7 +1765,8 @@ var init_issue = __esm({
1696
1765
  "reuse_existing",
1697
1766
  "agent_default"
1698
1767
  ]).optional().nullable(),
1699
- executionWorkspaceSettings: issueExecutionWorkspaceSettingsSchema.optional().nullable(),
1768
+ /** @deprecated Use runWorkspaceSettings. */
1769
+ executionWorkspaceSettings: issueRunWorkspaceSettingsSchema.optional().nullable(),
1700
1770
  labelIds: z14.array(z14.string().uuid()).optional()
1701
1771
  });
1702
1772
  createIssueLabelSchema = z14.object({
@@ -1814,6 +1884,8 @@ var init_work_product = __esm({
1814
1884
  ]);
1815
1885
  createIssueWorkProductSchema = z15.object({
1816
1886
  projectId: z15.string().uuid().optional().nullable(),
1887
+ runWorkspaceId: z15.string().uuid().optional().nullable(),
1888
+ /** @deprecated Use runWorkspaceId. */
1817
1889
  executionWorkspaceId: z15.string().uuid().optional().nullable(),
1818
1890
  runtimeServiceId: z15.string().uuid().optional().nullable(),
1819
1891
  type: issueWorkProductTypeSchema,
@@ -1835,19 +1907,19 @@ var init_work_product = __esm({
1835
1907
 
1836
1908
  // ../packages/shared/dist/validators/execution-workspace.js
1837
1909
  import { z as z16 } from "zod";
1838
- var executionWorkspaceStatusSchema, updateExecutionWorkspaceSchema;
1910
+ var runWorkspaceStatusSchema, updateRunWorkspaceSchema;
1839
1911
  var init_execution_workspace = __esm({
1840
1912
  "../packages/shared/dist/validators/execution-workspace.js"() {
1841
1913
  "use strict";
1842
- executionWorkspaceStatusSchema = z16.enum([
1914
+ runWorkspaceStatusSchema = z16.enum([
1843
1915
  "active",
1844
1916
  "idle",
1845
1917
  "in_review",
1846
1918
  "archived",
1847
1919
  "cleanup_failed"
1848
1920
  ]);
1849
- updateExecutionWorkspaceSchema = z16.object({
1850
- status: executionWorkspaceStatusSchema.optional(),
1921
+ updateRunWorkspaceSchema = z16.object({
1922
+ status: runWorkspaceStatusSchema.optional(),
1851
1923
  cleanupEligibleAt: z16.string().datetime().optional().nullable(),
1852
1924
  cleanupReason: z16.string().optional().nullable(),
1853
1925
  metadata: z16.record(z16.unknown()).optional().nullable()
@@ -2713,7 +2785,7 @@ var init_organization_skill_reference = __esm({
2713
2785
  });
2714
2786
 
2715
2787
  // ../packages/shared/dist/project-mentions.js
2716
- var AGENT_AVATAR_UUID_RE, AGENT_ASSET_ICON_RE, AGENT_DICEBEAR_NOTIONISTS_ICON_RE, PROJECT_COLOR_VALUES, AGENT_AVATAR_BACKGROUND_VALUES;
2788
+ var AGENT_AVATAR_UUID_RE, AGENT_ASSET_ICON_RE, AGENT_DICEBEAR_NOTIONISTS_ICON_RE, PROJECT_COLOR_VALUES, PROJECT_ICON_VALUES, AGENT_AVATAR_BACKGROUND_VALUES;
2717
2789
  var init_project_mentions = __esm({
2718
2790
  "../packages/shared/dist/project-mentions.js"() {
2719
2791
  "use strict";
@@ -2722,12 +2794,13 @@ var init_project_mentions = __esm({
2722
2794
  AGENT_ASSET_ICON_RE = new RegExp(`^asset:${AGENT_AVATAR_UUID_RE}(?:\\?bg=([a-z0-9-]+))?$`, "i");
2723
2795
  AGENT_DICEBEAR_NOTIONISTS_ICON_RE = new RegExp(`^${AGENT_DICEBEAR_NOTIONISTS_ICON_PREFIX}${AGENT_AVATAR_UUID_RE}(?:\\?bg=([a-z0-9-]+))?$`, "i");
2724
2796
  PROJECT_COLOR_VALUES = new Set(PROJECT_COLORS);
2797
+ PROJECT_ICON_VALUES = new Set(PROJECT_ICONS);
2725
2798
  AGENT_AVATAR_BACKGROUND_VALUES = new Set(AGENT_AVATAR_BACKGROUND_PRESET_IDS);
2726
2799
  }
2727
2800
  });
2728
2801
 
2729
2802
  // ../packages/shared/dist/issue-activity.js
2730
- var ISSUE_UPDATE_ACTIVITY_METADATA_KEYS, LOW_SIGNAL_ISSUE_UPDATE_ACTIVITY_FIELDS, ISSUE_UPDATE_ACTIVITY_METADATA_KEY_SET, LOW_SIGNAL_ISSUE_UPDATE_ACTIVITY_FIELD_SET;
2803
+ var ISSUE_UPDATE_ACTIVITY_METADATA_KEYS, LOW_SIGNAL_ISSUE_UPDATE_ACTIVITY_FIELDS, INTERNAL_ISSUE_UPDATE_ACTIVITY_FIELDS, ISSUE_UPDATE_ACTIVITY_METADATA_KEY_SET, LOW_SIGNAL_ISSUE_UPDATE_ACTIVITY_FIELD_SET, INTERNAL_ISSUE_UPDATE_ACTIVITY_FIELD_SET;
2731
2804
  var init_issue_activity = __esm({
2732
2805
  "../packages/shared/dist/issue-activity.js"() {
2733
2806
  "use strict";
@@ -2743,8 +2816,19 @@ var init_issue_activity = __esm({
2743
2816
  "normalizedReason"
2744
2817
  ];
2745
2818
  LOW_SIGNAL_ISSUE_UPDATE_ACTIVITY_FIELDS = ["description", "title"];
2819
+ INTERNAL_ISSUE_UPDATE_ACTIVITY_FIELDS = [
2820
+ "executionWorkspaceId",
2821
+ "executionWorkspacePreference",
2822
+ "executionWorkspaceSettings",
2823
+ "currentExecutionWorkspace",
2824
+ "runWorkspaceId",
2825
+ "runWorkspacePreference",
2826
+ "runWorkspaceSettings",
2827
+ "currentRunWorkspace"
2828
+ ];
2746
2829
  ISSUE_UPDATE_ACTIVITY_METADATA_KEY_SET = new Set(ISSUE_UPDATE_ACTIVITY_METADATA_KEYS);
2747
2830
  LOW_SIGNAL_ISSUE_UPDATE_ACTIVITY_FIELD_SET = new Set(LOW_SIGNAL_ISSUE_UPDATE_ACTIVITY_FIELDS);
2831
+ INTERNAL_ISSUE_UPDATE_ACTIVITY_FIELD_SET = new Set(INTERNAL_ISSUE_UPDATE_ACTIVITY_FIELDS);
2748
2832
  }
2749
2833
  });
2750
2834
 
@@ -10693,7 +10777,7 @@ var AGENT_CLI_CAPABILITIES = [
10693
10777
  id: "issue.documents.put",
10694
10778
  command: "rudder issue documents put <issue> <key> --body-file <path>",
10695
10779
  category: "issue",
10696
- description: "Legacy create or update of a DB-backed issue document; prefer `rudder library file put` for durable project files.",
10780
+ description: "Legacy create or update of a DB-backed issue document; prefer local project Library files under `$RUDDER_PROJECT_LIBRARY_ROOT` for durable project files.",
10697
10781
  mutating: true,
10698
10782
  contract: "compat",
10699
10783
  requiresOrgId: false,
@@ -10765,7 +10849,7 @@ var AGENT_CLI_CAPABILITIES = [
10765
10849
  id: "library.file.list",
10766
10850
  command: "rudder library file list [directory]",
10767
10851
  category: "library",
10768
- description: "List path-based Library files and folders.",
10852
+ description: "List Library files and folders; file rows include `libraryEntryId` when a strong reference can be generated.",
10769
10853
  mutating: false,
10770
10854
  contract: "agent-v1",
10771
10855
  requiresOrgId: true,
@@ -10777,7 +10861,31 @@ var AGENT_CLI_CAPABILITIES = [
10777
10861
  id: "library.file.get",
10778
10862
  command: "rudder library file get <path>",
10779
10863
  category: "library",
10780
- description: "Read one path-based Library file.",
10864
+ description: "Fallback read when local filesystem access is unavailable; JSON includes `mentionHref` and `markdownLink`.",
10865
+ mutating: false,
10866
+ contract: "agent-v1",
10867
+ requiresOrgId: true,
10868
+ requiresAgentId: false,
10869
+ requiresRunId: false,
10870
+ attachesRunIdWhenAvailable: false
10871
+ },
10872
+ {
10873
+ id: "library.file.ref",
10874
+ command: "rudder library file ref <path>",
10875
+ category: "library",
10876
+ description: "Return the stable Markdown reference for one Library file without printing file content.",
10877
+ mutating: false,
10878
+ contract: "agent-v1",
10879
+ requiresOrgId: true,
10880
+ requiresAgentId: false,
10881
+ requiresRunId: false,
10882
+ attachesRunIdWhenAvailable: false
10883
+ },
10884
+ {
10885
+ id: "library.file.link",
10886
+ command: "rudder library file link <path>",
10887
+ category: "library",
10888
+ description: "Compatibility alias for `rudder library file ref <path>`.",
10781
10889
  mutating: false,
10782
10890
  contract: "agent-v1",
10783
10891
  requiresOrgId: true,
@@ -10789,7 +10897,7 @@ var AGENT_CLI_CAPABILITIES = [
10789
10897
  id: "library.file.put",
10790
10898
  command: "rudder library file put <path> --body-file <path>",
10791
10899
  category: "library",
10792
- description: "Create or update one path-based Library file.",
10900
+ description: "Fallback create/update when local filesystem access is unavailable; JSON includes `mentionHref` and `markdownLink`.",
10793
10901
  mutating: true,
10794
10902
  contract: "agent-v1",
10795
10903
  requiresOrgId: true,
@@ -10952,12 +11060,327 @@ var AGENT_CLI_CAPABILITIES = [
10952
11060
  requiresAgentId: false,
10953
11061
  requiresRunId: false,
10954
11062
  attachesRunIdWhenAvailable: true
11063
+ },
11064
+ {
11065
+ id: "automation.list",
11066
+ command: "rudder automation list --org-id <id>",
11067
+ category: "automation",
11068
+ description: "List automations for an organization with compact local filters.",
11069
+ mutating: false,
11070
+ contract: "agent-v1",
11071
+ requiresOrgId: true,
11072
+ requiresAgentId: false,
11073
+ requiresRunId: false,
11074
+ attachesRunIdWhenAvailable: false
11075
+ },
11076
+ {
11077
+ id: "automation.get",
11078
+ command: "rudder automation get <automation-id>",
11079
+ category: "automation",
11080
+ description: "Read one automation detail including triggers and recent runs.",
11081
+ mutating: false,
11082
+ contract: "agent-v1",
11083
+ requiresOrgId: false,
11084
+ requiresAgentId: false,
11085
+ requiresRunId: false,
11086
+ attachesRunIdWhenAvailable: false
11087
+ },
11088
+ {
11089
+ id: "automation.runs",
11090
+ command: "rudder automation runs <automation-id>",
11091
+ category: "automation",
11092
+ description: "List recent runs for one automation.",
11093
+ mutating: false,
11094
+ contract: "agent-v1",
11095
+ requiresOrgId: false,
11096
+ requiresAgentId: false,
11097
+ requiresRunId: false,
11098
+ attachesRunIdWhenAvailable: false
11099
+ },
11100
+ {
11101
+ id: "automation.triggers.list",
11102
+ command: "rudder automation triggers list <automation-id>",
11103
+ category: "automation",
11104
+ description: "List triggers configured for one automation.",
11105
+ mutating: false,
11106
+ contract: "agent-v1",
11107
+ requiresOrgId: false,
11108
+ requiresAgentId: false,
11109
+ requiresRunId: false,
11110
+ attachesRunIdWhenAvailable: false
11111
+ },
11112
+ {
11113
+ id: "automation.create",
11114
+ command: "rudder automation create --org-id <id> --title <title> --assignee-agent-id <id>",
11115
+ category: "automation",
11116
+ description: "Create an automation through the governed automation API.",
11117
+ mutating: true,
11118
+ contract: "agent-v1",
11119
+ requiresOrgId: true,
11120
+ requiresAgentId: false,
11121
+ requiresRunId: false,
11122
+ attachesRunIdWhenAvailable: true
11123
+ },
11124
+ {
11125
+ id: "automation.update",
11126
+ command: "rudder automation update <automation-id>",
11127
+ category: "automation",
11128
+ description: "Update automation fields through the governed automation API.",
11129
+ mutating: true,
11130
+ contract: "agent-v1",
11131
+ requiresOrgId: false,
11132
+ requiresAgentId: false,
11133
+ requiresRunId: false,
11134
+ attachesRunIdWhenAvailable: true
11135
+ },
11136
+ {
11137
+ id: "automation.enable",
11138
+ command: "rudder automation enable <automation-id>",
11139
+ category: "automation",
11140
+ description: "Enable an automation by setting status to active.",
11141
+ mutating: true,
11142
+ contract: "agent-v1",
11143
+ requiresOrgId: false,
11144
+ requiresAgentId: false,
11145
+ requiresRunId: false,
11146
+ attachesRunIdWhenAvailable: true
11147
+ },
11148
+ {
11149
+ id: "automation.disable",
11150
+ command: "rudder automation disable <automation-id>",
11151
+ category: "automation",
11152
+ description: "Disable an automation by setting status to paused.",
11153
+ mutating: true,
11154
+ contract: "agent-v1",
11155
+ requiresOrgId: false,
11156
+ requiresAgentId: false,
11157
+ requiresRunId: false,
11158
+ attachesRunIdWhenAvailable: true
11159
+ },
11160
+ {
11161
+ id: "automation.run",
11162
+ command: "rudder automation run <automation-id>",
11163
+ category: "automation",
11164
+ description: "Trigger a manual automation run.",
11165
+ mutating: true,
11166
+ contract: "agent-v1",
11167
+ requiresOrgId: false,
11168
+ requiresAgentId: false,
11169
+ requiresRunId: false,
11170
+ attachesRunIdWhenAvailable: true
11171
+ },
11172
+ {
11173
+ id: "chat.list",
11174
+ command: "rudder chat list --org-id <id>",
11175
+ category: "chat",
11176
+ description: "List chat conversations without dumping full message history.",
11177
+ mutating: false,
11178
+ contract: "agent-v1",
11179
+ requiresOrgId: true,
11180
+ requiresAgentId: false,
11181
+ requiresRunId: false,
11182
+ attachesRunIdWhenAvailable: false
11183
+ },
11184
+ {
11185
+ id: "chat.search",
11186
+ command: "rudder chat search <query> --org-id <id>",
11187
+ category: "chat",
11188
+ description: "Search chats with bounded snippets and optional scope filtering.",
11189
+ mutating: false,
11190
+ contract: "agent-v1",
11191
+ requiresOrgId: true,
11192
+ requiresAgentId: false,
11193
+ requiresRunId: false,
11194
+ attachesRunIdWhenAvailable: false
11195
+ },
11196
+ {
11197
+ id: "chat.get",
11198
+ command: "rudder chat get <chat-id>",
11199
+ category: "chat",
11200
+ description: "Read one chat conversation record.",
11201
+ mutating: false,
11202
+ contract: "agent-v1",
11203
+ requiresOrgId: false,
11204
+ requiresAgentId: false,
11205
+ requiresRunId: false,
11206
+ attachesRunIdWhenAvailable: false
11207
+ },
11208
+ {
11209
+ id: "chat.messages",
11210
+ command: "rudder chat messages <chat-id> [--limit <n>] [--cursor <cursor>] [--include-transcript]",
11211
+ category: "chat",
11212
+ description: "Read bounded chat messages with page cursors; transcript output is omitted unless requested.",
11213
+ mutating: false,
11214
+ contract: "agent-v1",
11215
+ requiresOrgId: false,
11216
+ requiresAgentId: false,
11217
+ requiresRunId: false,
11218
+ attachesRunIdWhenAvailable: false
11219
+ },
11220
+ {
11221
+ id: "chat.transcript",
11222
+ command: "rudder chat transcript <chat-id> [--limit <n>] [--cursor <cursor>] [--max-output-chars <n>]",
11223
+ category: "chat",
11224
+ description: "Read paginated chat messages with assistant transcript entries clipped in human output.",
11225
+ mutating: false,
11226
+ contract: "agent-v1",
11227
+ requiresOrgId: false,
11228
+ requiresAgentId: false,
11229
+ requiresRunId: false,
11230
+ attachesRunIdWhenAvailable: false
11231
+ },
11232
+ {
11233
+ id: "chat.read",
11234
+ command: "rudder chat read <chat-id> [--turn-limit <n>] [--cursor <cursor>] [--include-output]",
11235
+ category: "chat",
11236
+ description: "Read a bounded recent-message snapshot for one chat with page cursors.",
11237
+ mutating: false,
11238
+ contract: "agent-v1",
11239
+ requiresOrgId: false,
11240
+ requiresAgentId: false,
11241
+ requiresRunId: false,
11242
+ attachesRunIdWhenAvailable: false
11243
+ },
11244
+ {
11245
+ id: "chat.create",
11246
+ command: "rudder chat create --org-id <id>",
11247
+ category: "chat",
11248
+ description: "Create a chat conversation.",
11249
+ mutating: true,
11250
+ contract: "agent-v1",
11251
+ requiresOrgId: true,
11252
+ requiresAgentId: false,
11253
+ requiresRunId: false,
11254
+ attachesRunIdWhenAvailable: true
11255
+ },
11256
+ {
11257
+ id: "chat.send",
11258
+ command: "rudder chat send <chat-id> --body <text>",
11259
+ category: "chat",
11260
+ description: "Send a chat message and persist the assistant reply through the server.",
11261
+ mutating: true,
11262
+ contract: "agent-v1",
11263
+ requiresOrgId: false,
11264
+ requiresAgentId: false,
11265
+ requiresRunId: false,
11266
+ attachesRunIdWhenAvailable: true
11267
+ },
11268
+ {
11269
+ id: "chat.archive",
11270
+ command: "rudder chat archive <chat-id>",
11271
+ category: "chat",
11272
+ description: "Archive a chat conversation without deleting it.",
11273
+ mutating: true,
11274
+ contract: "agent-v1",
11275
+ requiresOrgId: false,
11276
+ requiresAgentId: false,
11277
+ requiresRunId: false,
11278
+ attachesRunIdWhenAvailable: true
11279
+ },
11280
+ {
11281
+ id: "runs.list",
11282
+ command: "rudder runs list --org-id <id>",
11283
+ category: "runs",
11284
+ description: "List observed agent runs with filters for status, agent, issue, runtime, and time.",
11285
+ mutating: false,
11286
+ contract: "agent-v1",
11287
+ requiresOrgId: true,
11288
+ requiresAgentId: false,
11289
+ requiresRunId: false,
11290
+ attachesRunIdWhenAvailable: false
11291
+ },
11292
+ {
11293
+ id: "runs.get",
11294
+ command: "rudder runs get <run-id>",
11295
+ category: "runs",
11296
+ description: "Read one observed run detail.",
11297
+ mutating: false,
11298
+ contract: "agent-v1",
11299
+ requiresOrgId: false,
11300
+ requiresAgentId: false,
11301
+ requiresRunId: false,
11302
+ attachesRunIdWhenAvailable: false
11303
+ },
11304
+ {
11305
+ id: "runs.events",
11306
+ command: "rudder runs events <run-id>",
11307
+ category: "runs",
11308
+ description: "List persisted run events.",
11309
+ mutating: false,
11310
+ contract: "agent-v1",
11311
+ requiresOrgId: false,
11312
+ requiresAgentId: false,
11313
+ requiresRunId: false,
11314
+ attachesRunIdWhenAvailable: false
11315
+ },
11316
+ {
11317
+ id: "runs.log",
11318
+ command: "rudder runs log <run-id>",
11319
+ category: "runs",
11320
+ description: "Read stored run log content with clipped human output.",
11321
+ mutating: false,
11322
+ contract: "agent-v1",
11323
+ requiresOrgId: false,
11324
+ requiresAgentId: false,
11325
+ requiresRunId: false,
11326
+ attachesRunIdWhenAvailable: false
11327
+ },
11328
+ {
11329
+ id: "runs.transcript",
11330
+ command: "rudder runs transcript <run-id> [--turn-limit <n>] [--cursor <cursor>] [--include-output]",
11331
+ category: "runs",
11332
+ description: "Read the server-normalized run transcript; human output is compact and JSON includes full entries.",
11333
+ mutating: false,
11334
+ contract: "agent-v1",
11335
+ requiresOrgId: false,
11336
+ requiresAgentId: false,
11337
+ requiresRunId: false,
11338
+ attachesRunIdWhenAvailable: false
11339
+ },
11340
+ {
11341
+ id: "runs.errors",
11342
+ command: "rudder runs errors <run-id>",
11343
+ category: "runs",
11344
+ description: "List failed tool calls, stderr, runtime failures, and jump-to-context commands.",
11345
+ mutating: false,
11346
+ contract: "agent-v1",
11347
+ requiresOrgId: false,
11348
+ requiresAgentId: false,
11349
+ requiresRunId: false,
11350
+ attachesRunIdWhenAvailable: false
11351
+ },
11352
+ {
11353
+ id: "runs.cancel",
11354
+ command: "rudder runs cancel <run-id>",
11355
+ category: "runs",
11356
+ description: "Cancel a heartbeat run through the governed server route.",
11357
+ mutating: true,
11358
+ contract: "agent-v1",
11359
+ requiresOrgId: false,
11360
+ requiresAgentId: false,
11361
+ requiresRunId: false,
11362
+ attachesRunIdWhenAvailable: true
11363
+ },
11364
+ {
11365
+ id: "runs.retry",
11366
+ command: "rudder runs retry <run-id>",
11367
+ category: "runs",
11368
+ description: "Retry a failed, timed out, or cancelled run through the governed server route.",
11369
+ mutating: true,
11370
+ contract: "agent-v1",
11371
+ requiresOrgId: false,
11372
+ requiresAgentId: false,
11373
+ requiresRunId: false,
11374
+ attachesRunIdWhenAvailable: true
10955
11375
  }
10956
11376
  ];
10957
11377
  var CATEGORY_TITLES = {
10958
11378
  agent: "Agent",
10959
11379
  issue: "Issue",
10960
11380
  project: "Project",
11381
+ automation: "Automation",
11382
+ chat: "Chat",
11383
+ runs: "Runs",
10961
11384
  approval: "Approval",
10962
11385
  skill: "Skill",
10963
11386
  library: "Library"
@@ -11706,10 +12129,14 @@ var RUDDER_AGENT_OPERATING_CONTRACT = [
11706
12129
  "- Personal skills live under `$AGENT_HOME/skills`.",
11707
12130
  "- Shared organization workspace root lives under `$RUDDER_ORG_WORKSPACE_ROOT`.",
11708
12131
  "- Shared organization skills live under `$RUDDER_ORG_SKILLS_DIR`.",
11709
- '- Library-backed project resources use `sourceType: "library"`; their `locator` points into `library:projects/<project-name>/`.',
12132
+ "- Project Library root lives under `$RUDDER_PROJECT_LIBRARY_ROOT` when the run has project context.",
12133
+ "- Project Library locator lives in `$RUDDER_PROJECT_LIBRARY_PATH` when the run has project context, for example `projects/<project-key>`.",
12134
+ '- Library-backed project resources use `sourceType: "library"`; their `locator` points into `library:projects/<project-key>/`.',
11710
12135
  "- Project Context is explicit operator-curated context, not the whole knowledge boundary. When it is insufficient, inspect broader Library and org workspace know-how before concluding context is missing.",
11711
- "- Durable generated project work files should be written under `library:projects/<project-name>/`.",
11712
- "- When you create or update a durable Library file, always include a user-visible Markdown link to that file in your final chat reply or issue comment. Use `library-file://file?p=<url-encoded-relative-path>&t=<url-encoded-title>` for Library file links.",
12136
+ "- In local trusted runs, durable generated project work files should be written directly under `$RUDDER_PROJECT_LIBRARY_ROOT` with normal filesystem tools.",
12137
+ "- `library:projects/<project-key>/...` is the Rudder product locator for those files, not the Markdown link syntax and not a reason to route ordinary local edits through the CLI.",
12138
+ '- When you create or update a durable Library file, always include a user-visible Markdown link to that file in your final chat reply or issue comment. Use `rudder library file ref "$RUDDER_PROJECT_LIBRARY_PATH/<relative-file>" --json` and paste the returned `markdownLink`; do not pass the absolute `$RUDDER_PROJECT_LIBRARY_ROOT/...` path to `ref`, and do not hand-write `library-entry://...` or `library-file://...` links.',
12139
+ '- If `$RUDDER_PROJECT_LIBRARY_ROOT` is unset or inaccessible, use `rudder library file get/put "$RUDDER_PROJECT_LIBRARY_PATH/<relative-file>"` as the remote or restricted runtime fallback.',
11713
12140
  "- Use `/tmp` only for transient scratch files and temporary verification files; do not put durable work product there.",
11714
12141
  "- Local trusted runtimes may expose the host operator home as `$RUDDER_OPERATOR_HOME`; use it only when a local skill or script intentionally needs operator-owned desktop app or CLI state. Do not replace `$HOME` with it.",
11715
12142
  "",
@@ -11718,6 +12145,18 @@ var RUDDER_AGENT_OPERATING_CONTRACT = [
11718
12145
  "When you write issue comments or chat replies, match the language of the user's or board's most recent substantive message unless they explicitly ask for a different language.",
11719
12146
  "When you mention a web page, issue URL, external dashboard, or other user-openable target in an issue comment or chat reply, write it as a clickable Markdown link with a descriptive label, for example `[NameSilo transfer page](https://www.namesilo.com/account_domain_manage_transfer.php)`. Do not put action URLs in backticks or code blocks unless you are showing literal code or a command.",
11720
12147
  "",
12148
+ "## Rudder Renderable Links",
12149
+ "",
12150
+ "When you mention Rudder entities in any user-visible Markdown output, prefer Rudder's renderable Markdown link syntax over plain IDs, bare URLs, or backticked references so the UI can render chips and navigate correctly.",
12151
+ "",
12152
+ "- Issues: use `[<identifier-or-title>](issue://<issue-id>?r=<identifier>)`; include `&c=<comment-id>` when linking to a specific comment.",
12153
+ "- Agents: use `[<agent-name>](agent://<agent-id>)` for reference-only links. Use `[<agent-name>](agent://<agent-id>?intent=wake)` only when you deliberately want an issue-composer mention to wake that agent.",
12154
+ "- Projects: use `[<project-name>](project://<project-id>)` when citing a Rudder project.",
12155
+ "- Chat threads: use `[<chat-title>](chat://<conversation-id>?t=<url-encoded-title>)` when citing a Rudder chat conversation.",
12156
+ '- Library files: use the `markdownLink` returned by `rudder library file ref "$RUDDER_PROJECT_LIBRARY_PATH/<relative-file>" --json`; do not hand-write `library-entry://...` links, and treat `library-file://...` as legacy path syntax only.',
12157
+ "",
12158
+ "Write these as normal Markdown links, not inside code spans or code blocks, unless you are literally documenting the syntax.",
12159
+ "",
11721
12160
  "Mention-triggered comment wakes arrive with `RUDDER_WAKE_COMMENT_ID`; read that wake comment before acting. Board/operator issue comments can wake an agent with a plain `@AgentName` token or an issue-composer agent mention serialized as `agent://agent-id?intent=wake`. Plain structured links such as `agent://agent-id` are reference-only links for rendering and navigation. Agent-authored issue comments do not fan out peer wakeups by default; use reviewer, assignment, or explicit handoff workflow instead. Mentioning an agent requests attention or collaboration; it does not transfer issue ownership unless the comment also makes an explicit handoff and normal checkout rules allow it.",
11722
12161
  "",
11723
12162
  "When an issue comment, done comment, or blocker comment cites visual evidence from a local screenshot/image path, attach the image with the Rudder CLI `--image <path>` option instead of leaving only the filesystem path in the text.",
@@ -12703,9 +13142,27 @@ function parseCsv5(value) {
12703
13142
  // src/commands/client/library.ts
12704
13143
  import { readFile as readFile6 } from "node:fs/promises";
12705
13144
  import path20 from "node:path";
13145
+ function toLibraryFileLinkResult(detail) {
13146
+ return {
13147
+ filePath: detail.filePath,
13148
+ libraryEntryId: detail.libraryEntryId,
13149
+ mentionHref: detail.mentionHref,
13150
+ markdownLink: detail.markdownLink
13151
+ };
13152
+ }
13153
+ async function printLibraryFileReference(filePath, opts) {
13154
+ const ctx = resolveCommandContext(opts, { requireCompany: true });
13155
+ const search = new URLSearchParams();
13156
+ search.set("path", filePath.trim());
13157
+ const result = await ctx.api.get(
13158
+ `/api/orgs/${ctx.orgId}/workspace/file?${search.toString()}`
13159
+ );
13160
+ if (!result) throw new Error("Library file not found");
13161
+ printOutput(toLibraryFileLinkResult(result), { json: ctx.json });
13162
+ }
12706
13163
  function registerLibraryCommands(program) {
12707
13164
  const library = program.command("library").description("Library file operations");
12708
- const file = library.command("file").description("Path-based Library file operations");
13165
+ const file = library.command("file").description("Library file operations");
12709
13166
  addCommonClientOptions(
12710
13167
  file.command("list").description(getAgentCliCapabilityById("library.file.list").description).argument("[directoryPath]", "Library directory path", "projects").action(async (directoryPath, opts) => {
12711
13168
  try {
@@ -12740,6 +13197,26 @@ function registerLibraryCommands(program) {
12740
13197
  }),
12741
13198
  { includeCompany: true }
12742
13199
  );
13200
+ addCommonClientOptions(
13201
+ file.command("link").description(getAgentCliCapabilityById("library.file.link").description).argument("<filePath>", "Library file path").action(async (filePath, opts) => {
13202
+ try {
13203
+ await printLibraryFileReference(filePath, opts);
13204
+ } catch (err) {
13205
+ handleCommandError(err);
13206
+ }
13207
+ }),
13208
+ { includeCompany: true }
13209
+ );
13210
+ addCommonClientOptions(
13211
+ file.command("ref").description(getAgentCliCapabilityById("library.file.ref").description).argument("<filePath>", "Library file path").action(async (filePath, opts) => {
13212
+ try {
13213
+ await printLibraryFileReference(filePath, opts);
13214
+ } catch (err) {
13215
+ handleCommandError(err);
13216
+ }
13217
+ }),
13218
+ { includeCompany: true }
13219
+ );
12743
13220
  addCommonClientOptions(
12744
13221
  file.command("put").description(getAgentCliCapabilityById("library.file.put").description).argument("<filePath>", "Library file path").option("--body-file <path>", "Read file content from a file, or '-' for stdin").action(async (filePath, opts) => {
12745
13222
  try {
@@ -12792,6 +13269,664 @@ async function readStdinText3() {
12792
13269
  return Buffer.concat(chunks).toString("utf8");
12793
13270
  }
12794
13271
 
13272
+ // src/commands/client/automation.ts
13273
+ init_dist();
13274
+ function registerAutomationCommands(program) {
13275
+ const automation = program.command("automation").description("Automation operations");
13276
+ addCommonClientOptions(
13277
+ automation.command("list").description(getAgentCliCapabilityById("automation.list").description).option("-O, --org-id <id>", "Organization ID").option("--status <status>", "Filter by automation status").option("--assignee-agent-id <id>", "Filter by assignee agent ID").option("--project-id <id>", "Filter by project ID").option("--output-mode <mode>", "Filter by output mode").action(async (opts) => {
13278
+ try {
13279
+ const ctx = resolveCommandContext(opts, { requireCompany: true });
13280
+ const rows = await ctx.api.get(`/api/orgs/${ctx.orgId}/automations`) ?? [];
13281
+ const filtered = rows.filter(
13282
+ (row) => (!opts.status || row.status === opts.status) && (!opts.assigneeAgentId || row.assigneeAgentId === opts.assigneeAgentId) && (!opts.projectId || row.projectId === opts.projectId) && (!opts.outputMode || row.outputMode === opts.outputMode)
13283
+ );
13284
+ printOutput(ctx.json ? filtered : filtered.map(formatAutomationListItem), { json: ctx.json });
13285
+ } catch (err) {
13286
+ handleCommandError(err);
13287
+ }
13288
+ }),
13289
+ { includeCompany: false }
13290
+ );
13291
+ addCommonClientOptions(
13292
+ automation.command("get").description(getAgentCliCapabilityById("automation.get").description).argument("<automationId>", "Automation ID").action(async (automationId, opts) => {
13293
+ try {
13294
+ const ctx = resolveCommandContext(opts);
13295
+ const row = await ctx.api.get(`/api/automations/${encodeURIComponent(automationId)}`);
13296
+ printOutput(row, { json: ctx.json });
13297
+ } catch (err) {
13298
+ handleCommandError(err);
13299
+ }
13300
+ })
13301
+ );
13302
+ addCommonClientOptions(
13303
+ automation.command("runs").description(getAgentCliCapabilityById("automation.runs").description).argument("<automationId>", "Automation ID").option("--limit <n>", "Maximum runs to return", "50").action(async (automationId, opts) => {
13304
+ try {
13305
+ const ctx = resolveCommandContext(opts);
13306
+ const params = new URLSearchParams();
13307
+ if (opts.limit) params.set("limit", opts.limit);
13308
+ const rows = await ctx.api.get(
13309
+ `/api/automations/${encodeURIComponent(automationId)}/runs?${params.toString()}`
13310
+ ) ?? [];
13311
+ printOutput(ctx.json ? rows : rows.map(formatAutomationRun), { json: ctx.json });
13312
+ } catch (err) {
13313
+ handleCommandError(err);
13314
+ }
13315
+ })
13316
+ );
13317
+ addCommonClientOptions(
13318
+ automation.command("triggers").description("Automation trigger operations").command("list").description(getAgentCliCapabilityById("automation.triggers.list").description).argument("<automationId>", "Automation ID").action(async (automationId, opts) => {
13319
+ try {
13320
+ const ctx = resolveCommandContext(opts);
13321
+ const row = await ctx.api.get(`/api/automations/${encodeURIComponent(automationId)}`);
13322
+ const triggers = row?.triggers ?? [];
13323
+ printOutput(triggers, { json: ctx.json });
13324
+ } catch (err) {
13325
+ handleCommandError(err);
13326
+ }
13327
+ })
13328
+ );
13329
+ addCommonClientOptions(
13330
+ automation.command("create").description(getAgentCliCapabilityById("automation.create").description).option("-O, --org-id <id>", "Organization ID").option("--payload <json>", "Raw automation create payload JSON").option("--title <title>", "Automation title").option("--description <text>", "Automation description").option("--assignee-agent-id <id>", "Assignee agent ID").option("--project-id <id>", "Project ID").option("--goal-id <id>", "Goal ID").option("--parent-issue-id <id>", "Parent issue ID").option("--priority <priority>", "Issue priority for tracked output").option("--status <status>", "Automation status").option("--output-mode <mode>", "Automation output mode").option("--concurrency-policy <policy>", "Automation concurrency policy").option("--catch-up-policy <policy>", "Automation catch-up policy").option("--notify-on-issue-created", "Notify when tracked issue output is created").action(async (opts) => {
13331
+ try {
13332
+ const ctx = resolveCommandContext(opts, { requireCompany: true });
13333
+ const payload = createAutomationSchema.parse(buildAutomationPayload(opts));
13334
+ const created = await ctx.api.post(`/api/orgs/${ctx.orgId}/automations`, payload);
13335
+ printOutput(created, { json: ctx.json });
13336
+ } catch (err) {
13337
+ handleCommandError(err);
13338
+ }
13339
+ }),
13340
+ { includeCompany: false }
13341
+ );
13342
+ addCommonClientOptions(
13343
+ automation.command("update").description(getAgentCliCapabilityById("automation.update").description).argument("<automationId>", "Automation ID").option("--payload <json>", "Raw automation update payload JSON").option("--title <title>", "Automation title").option("--description <text>", "Automation description").option("--assignee-agent-id <id>", "Assignee agent ID").option("--project-id <id>", "Project ID").option("--goal-id <id>", "Goal ID").option("--parent-issue-id <id>", "Parent issue ID").option("--priority <priority>", "Issue priority for tracked output").option("--status <status>", "Automation status").option("--output-mode <mode>", "Automation output mode").option("--concurrency-policy <policy>", "Automation concurrency policy").option("--catch-up-policy <policy>", "Automation catch-up policy").option("--notify-on-issue-created", "Notify when tracked issue output is created").action(async (automationId, opts) => {
13344
+ try {
13345
+ const ctx = resolveCommandContext(opts);
13346
+ const payload = updateAutomationSchema.parse(buildAutomationPayload(opts));
13347
+ const updated = await ctx.api.patch(`/api/automations/${encodeURIComponent(automationId)}`, payload);
13348
+ printOutput(updated, { json: ctx.json });
13349
+ } catch (err) {
13350
+ handleCommandError(err);
13351
+ }
13352
+ })
13353
+ );
13354
+ addCommonClientOptions(
13355
+ automation.command("enable").description(getAgentCliCapabilityById("automation.enable").description).argument("<automationId>", "Automation ID").action(async (automationId, opts) => {
13356
+ try {
13357
+ const ctx = resolveCommandContext(opts);
13358
+ const updated = await ctx.api.patch(`/api/automations/${encodeURIComponent(automationId)}`, {
13359
+ status: "active"
13360
+ });
13361
+ printOutput(updated, { json: ctx.json });
13362
+ } catch (err) {
13363
+ handleCommandError(err);
13364
+ }
13365
+ })
13366
+ );
13367
+ addCommonClientOptions(
13368
+ automation.command("disable").description(getAgentCliCapabilityById("automation.disable").description).argument("<automationId>", "Automation ID").action(async (automationId, opts) => {
13369
+ try {
13370
+ const ctx = resolveCommandContext(opts);
13371
+ const updated = await ctx.api.patch(`/api/automations/${encodeURIComponent(automationId)}`, {
13372
+ status: "paused"
13373
+ });
13374
+ printOutput(updated, { json: ctx.json });
13375
+ } catch (err) {
13376
+ handleCommandError(err);
13377
+ }
13378
+ })
13379
+ );
13380
+ addCommonClientOptions(
13381
+ automation.command("run").description(getAgentCliCapabilityById("automation.run").description).argument("<automationId>", "Automation ID").option("--trigger-id <id>", "Trigger ID").option("--payload <json>", "Manual run payload JSON").option("--idempotency-key <key>", "Idempotency key").option("--source <source>", "Run source", "manual").action(async (automationId, opts) => {
13382
+ try {
13383
+ const ctx = resolveCommandContext(opts);
13384
+ const payload = runAutomationSchema.parse({
13385
+ triggerId: opts.triggerId,
13386
+ payload: opts.payload ? parseJsonOption(opts.payload, "--payload") : void 0,
13387
+ idempotencyKey: opts.idempotencyKey,
13388
+ source: opts.source
13389
+ });
13390
+ const run = await ctx.api.post(`/api/automations/${encodeURIComponent(automationId)}/run`, payload);
13391
+ printOutput(run, { json: ctx.json });
13392
+ } catch (err) {
13393
+ handleCommandError(err);
13394
+ }
13395
+ })
13396
+ );
13397
+ }
13398
+ function buildAutomationPayload(opts) {
13399
+ return {
13400
+ ...parseJsonObjectOption(opts.payload, "--payload"),
13401
+ ...definedRecord({
13402
+ title: opts.title,
13403
+ description: opts.description,
13404
+ assigneeAgentId: opts.assigneeAgentId,
13405
+ projectId: opts.projectId,
13406
+ goalId: opts.goalId,
13407
+ parentIssueId: opts.parentIssueId,
13408
+ priority: opts.priority,
13409
+ status: opts.status,
13410
+ outputMode: opts.outputMode,
13411
+ concurrencyPolicy: opts.concurrencyPolicy,
13412
+ catchUpPolicy: opts.catchUpPolicy,
13413
+ notifyOnIssueCreated: opts.notifyOnIssueCreated
13414
+ })
13415
+ };
13416
+ }
13417
+ function definedRecord(record) {
13418
+ return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0));
13419
+ }
13420
+ function parseJsonOption(value, label) {
13421
+ try {
13422
+ return JSON.parse(value);
13423
+ } catch (error) {
13424
+ throw new Error(`${label} must be valid JSON`);
13425
+ }
13426
+ }
13427
+ function parseJsonObjectOption(value, label) {
13428
+ if (!value) return {};
13429
+ const parsed = parseJsonOption(value, label);
13430
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
13431
+ throw new Error(`${label} must be a JSON object`);
13432
+ }
13433
+ return parsed;
13434
+ }
13435
+ function formatAutomationListItem(row) {
13436
+ const nextRunAt = row.triggers.map((trigger) => trigger.nextRunAt).filter(Boolean).sort()[0] ?? null;
13437
+ return {
13438
+ id: row.id,
13439
+ title: row.title,
13440
+ status: row.status,
13441
+ assigneeAgentId: row.assigneeAgentId,
13442
+ outputMode: row.outputMode,
13443
+ lastRun: row.lastRun?.status ?? "-",
13444
+ nextRunAt
13445
+ };
13446
+ }
13447
+ function formatAutomationRun(row) {
13448
+ return {
13449
+ id: row.id,
13450
+ status: row.status,
13451
+ source: row.source,
13452
+ triggeredAt: row.triggeredAt,
13453
+ linkedIssue: row.linkedIssue?.identifier ?? row.linkedIssueId ?? "-",
13454
+ linkedChatConversationId: row.linkedChatConversationId ?? "-",
13455
+ failureReason: row.failureReason ?? "-"
13456
+ };
13457
+ }
13458
+
13459
+ // src/commands/client/chat.ts
13460
+ init_dist();
13461
+ function registerChatCommands(program) {
13462
+ const chat = program.command("chat").description("Chat operations");
13463
+ addCommonClientOptions(
13464
+ chat.command("list").description(getAgentCliCapabilityById("chat.list").description).option("-O, --org-id <id>", "Organization ID").option("--status <status>", "active, resolved, archived, or all", "active").option("--query <text>", "Server-side chat search query").option("--limit <n>", "Maximum rows to print").action(async (opts) => {
13465
+ try {
13466
+ const ctx = resolveCommandContext(opts, { requireCompany: true });
13467
+ const rows = await listChats(ctx, opts);
13468
+ printOutput(ctx.json ? rows : rows.map(formatChatConversation), { json: ctx.json });
13469
+ } catch (err) {
13470
+ handleCommandError(err);
13471
+ }
13472
+ }),
13473
+ { includeCompany: false }
13474
+ );
13475
+ addCommonClientOptions(
13476
+ chat.command("search").description(getAgentCliCapabilityById("chat.search").description).argument("<query>", "Search query").option("-O, --org-id <id>", "Organization ID").option("--status <status>", "active, resolved, archived, or all", "all").option("--scope <scope>", "Search scope: all, title, summary, messages", "all").option("--limit <n>", "Maximum rows to print", "20").option("--snippet-chars <n>", "Maximum snippet characters", "220").action(async (query, opts) => {
13477
+ try {
13478
+ const ctx = resolveCommandContext(opts, { requireCompany: true });
13479
+ const rows = await listChats(ctx, { ...opts, query });
13480
+ const filtered = filterChatSearchRows(rows, query, opts.scope ?? "all").slice(0, parseLimit(opts.limit, rows.length));
13481
+ const snippetChars = parseLimit(opts.snippetChars, 220);
13482
+ printOutput(
13483
+ ctx.json ? filtered : filtered.map((row) => formatChatSearchResult(row, snippetChars)),
13484
+ { json: ctx.json }
13485
+ );
13486
+ } catch (err) {
13487
+ handleCommandError(err);
13488
+ }
13489
+ }),
13490
+ { includeCompany: false }
13491
+ );
13492
+ addCommonClientOptions(
13493
+ chat.command("get").description(getAgentCliCapabilityById("chat.get").description).argument("<chatId>", "Chat conversation ID").action(async (chatId, opts) => {
13494
+ try {
13495
+ const ctx = resolveCommandContext(opts);
13496
+ const row = await ctx.api.get(`/api/chats/${encodeURIComponent(chatId)}`);
13497
+ printOutput(row, { json: ctx.json });
13498
+ } catch (err) {
13499
+ handleCommandError(err);
13500
+ }
13501
+ })
13502
+ );
13503
+ addCommonClientOptions(
13504
+ chat.command("messages").description(getAgentCliCapabilityById("chat.messages").description).argument("<chatId>", "Chat conversation ID").option("--include-transcript", "Include assistant transcript entries").option("--include-output", "Alias for --include-transcript").option("--include-outputs", "Alias for --include-transcript").option("--limit <n>", "Maximum messages to print").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-output-chars <n>", "Maximum transcript output chars for human output", "1200").action(async (chatId, opts) => {
13505
+ try {
13506
+ const ctx = resolveCommandContext(opts);
13507
+ const page = await getChatMessagesPage(ctx, chatId, {
13508
+ includeTranscript: includesChatTranscript(opts),
13509
+ limit: opts.limit,
13510
+ cursor: opts.cursor
13511
+ });
13512
+ printOutput(
13513
+ ctx.json ? page : page.messages.map((message) => formatChatMessage(message, parseLimit(opts.maxOutputChars, 1200))),
13514
+ { json: ctx.json }
13515
+ );
13516
+ } catch (err) {
13517
+ handleCommandError(err);
13518
+ }
13519
+ })
13520
+ );
13521
+ addCommonClientOptions(
13522
+ chat.command("transcript").description(getAgentCliCapabilityById("chat.transcript").description).argument("<chatId>", "Chat conversation ID").option("--limit <n>", "Maximum messages to print").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-chars <n>", "Maximum transcript chars per message", "1200").option("--max-output-chars <n>", "Alias for --max-chars").action(async (chatId, opts) => {
13523
+ try {
13524
+ const ctx = resolveCommandContext(opts);
13525
+ const page = await getChatMessagesPage(ctx, chatId, {
13526
+ includeTranscript: true,
13527
+ limit: opts.limit,
13528
+ cursor: opts.cursor
13529
+ });
13530
+ const maxChars = parseLimit(opts.maxOutputChars ?? opts.maxChars, 1200);
13531
+ printOutput(
13532
+ ctx.json ? page : page.messages.flatMap((message) => formatChatTranscriptMessage(message, maxChars)),
13533
+ { json: ctx.json }
13534
+ );
13535
+ } catch (err) {
13536
+ handleCommandError(err);
13537
+ }
13538
+ })
13539
+ );
13540
+ addCommonClientOptions(
13541
+ chat.command("read").description(getAgentCliCapabilityById("chat.read").description).argument("<chatId>", "Chat conversation ID").option("--include-transcript", "Include assistant transcript entries").option("--include-output", "Alias for --include-transcript").option("--include-outputs", "Alias for --include-transcript").option("--limit <n>", "Maximum recent messages", "20").option("--turn-limit <n>", "Alias for --limit for chat turn snapshots").option("--cursor <cursor>", "Stable message cursor returned in page.nextCursor").option("--max-output-chars <n>", "Maximum transcript output chars for human output", "1200").action(async (chatId, opts) => {
13542
+ try {
13543
+ const ctx = resolveCommandContext(opts);
13544
+ const [conversation, page] = await Promise.all([
13545
+ ctx.api.get(`/api/chats/${encodeURIComponent(chatId)}`),
13546
+ getChatMessagesPage(ctx, chatId, {
13547
+ includeTranscript: includesChatTranscript(opts),
13548
+ limit: opts.turnLimit ?? opts.limit,
13549
+ cursor: opts.cursor
13550
+ })
13551
+ ]);
13552
+ const payload = {
13553
+ conversation,
13554
+ messages: page.messages,
13555
+ page: page.page
13556
+ };
13557
+ printOutput(
13558
+ ctx.json ? payload : page.messages.map((message) => formatChatMessage(message, parseLimit(opts.maxOutputChars, 1200))),
13559
+ { json: ctx.json }
13560
+ );
13561
+ } catch (err) {
13562
+ handleCommandError(err);
13563
+ }
13564
+ })
13565
+ );
13566
+ addCommonClientOptions(
13567
+ chat.command("create").description(getAgentCliCapabilityById("chat.create").description).option("-O, --org-id <id>", "Organization ID").option("--payload <json>", "Raw chat create payload JSON").option("--title <title>", "Chat title").option("--summary <text>", "Chat summary").option("--preferred-agent-id <id>", "Preferred agent ID").option("--issue-creation-mode <mode>", "Issue creation mode").option("--plan-mode", "Create a plan-mode chat").action(async (opts) => {
13568
+ try {
13569
+ const ctx = resolveCommandContext(opts, { requireCompany: true });
13570
+ const payload = createChatConversationSchema.parse({
13571
+ ...parseJsonObjectOption2(opts.payload, "--payload"),
13572
+ ...definedRecord2({
13573
+ title: opts.title,
13574
+ summary: opts.summary,
13575
+ preferredAgentId: opts.preferredAgentId,
13576
+ issueCreationMode: opts.issueCreationMode,
13577
+ planMode: opts.planMode
13578
+ })
13579
+ });
13580
+ const created = await ctx.api.post(`/api/orgs/${ctx.orgId}/chats`, payload);
13581
+ printOutput(created, { json: ctx.json });
13582
+ } catch (err) {
13583
+ handleCommandError(err);
13584
+ }
13585
+ }),
13586
+ { includeCompany: false }
13587
+ );
13588
+ addCommonClientOptions(
13589
+ chat.command("send").description(getAgentCliCapabilityById("chat.send").description).argument("<chatId>", "Chat conversation ID").option("--body <text>", "Message body").option("--edit-user-message-id <id>", "Regenerate/edit from a prior user message").action(async (chatId, opts) => {
13590
+ try {
13591
+ const ctx = resolveCommandContext(opts);
13592
+ const body = opts.body ?? await readStdin();
13593
+ const payload = addChatMessageSchema.parse({
13594
+ body,
13595
+ editUserMessageId: opts.editUserMessageId
13596
+ });
13597
+ const result = await ctx.api.post(`/api/chats/${encodeURIComponent(chatId)}/messages`, payload);
13598
+ printOutput(result, { json: ctx.json });
13599
+ } catch (err) {
13600
+ handleCommandError(err);
13601
+ }
13602
+ })
13603
+ );
13604
+ addCommonClientOptions(
13605
+ chat.command("archive").description(getAgentCliCapabilityById("chat.archive").description).argument("<chatId>", "Chat conversation ID").action(async (chatId, opts) => {
13606
+ try {
13607
+ const ctx = resolveCommandContext(opts);
13608
+ const payload = updateChatConversationSchema.parse({ status: "archived" });
13609
+ const updated = await ctx.api.patch(`/api/chats/${encodeURIComponent(chatId)}`, payload);
13610
+ printOutput(updated, { json: ctx.json });
13611
+ } catch (err) {
13612
+ handleCommandError(err);
13613
+ }
13614
+ })
13615
+ );
13616
+ }
13617
+ async function listChats(ctx, opts) {
13618
+ const params = new URLSearchParams();
13619
+ if (opts.status) params.set("status", opts.status);
13620
+ if (opts.query) params.set("q", opts.query);
13621
+ const rows = await ctx.api.get(`/api/orgs/${ctx.orgId}/chats?${params.toString()}`) ?? [];
13622
+ return rows.slice(0, parseLimit(opts.limit, rows.length));
13623
+ }
13624
+ async function getChatMessagesPage(ctx, chatId, opts) {
13625
+ const params = new URLSearchParams();
13626
+ params.set("envelope", "true");
13627
+ params.set("order", "newest");
13628
+ params.set("limit", String(parseLimit(opts.limit, 50)));
13629
+ if (opts.cursor) params.set("cursor", opts.cursor);
13630
+ if (opts.includeTranscript) params.set("includeTranscript", "true");
13631
+ const page = await ctx.api.get(`/api/chats/${encodeURIComponent(chatId)}/messages?${params.toString()}`);
13632
+ if (!page) {
13633
+ throw new Error("Chat messages response was empty");
13634
+ }
13635
+ return page;
13636
+ }
13637
+ function filterChatSearchRows(rows, query, scope) {
13638
+ const normalized = query.toLowerCase();
13639
+ if (scope === "all") return rows;
13640
+ return rows.filter((row) => {
13641
+ if (scope === "title") return row.title.toLowerCase().includes(normalized);
13642
+ if (scope === "summary") return Boolean(row.summary?.toLowerCase().includes(normalized));
13643
+ if (scope === "messages") return Boolean(row.searchPreview?.toLowerCase().includes(normalized));
13644
+ return true;
13645
+ });
13646
+ }
13647
+ function formatChatConversation(row) {
13648
+ return {
13649
+ id: row.id,
13650
+ title: row.title,
13651
+ status: row.status,
13652
+ preferredAgentId: row.preferredAgentId ?? "-",
13653
+ unread: row.unreadCount,
13654
+ lastMessageAt: row.lastMessageAt ?? "-",
13655
+ preview: row.latestReplyPreview ?? row.latestUserMessagePreview ?? "-"
13656
+ };
13657
+ }
13658
+ function formatChatSearchResult(row, maxChars) {
13659
+ return {
13660
+ id: row.id,
13661
+ title: row.title,
13662
+ status: row.status,
13663
+ lastMessageAt: row.lastMessageAt ?? "-",
13664
+ snippet: clip(row.searchPreview ?? row.latestReplyPreview ?? row.latestUserMessagePreview ?? row.summary ?? "", maxChars)
13665
+ };
13666
+ }
13667
+ function formatChatMessage(row, maxOutputChars = 1200) {
13668
+ return {
13669
+ id: row.id,
13670
+ role: row.role,
13671
+ kind: row.kind,
13672
+ status: row.status,
13673
+ createdAt: row.createdAt,
13674
+ body: clip(row.body, 220),
13675
+ transcriptEntries: row.transcriptSummary?.entryCount ?? row.transcript?.length ?? 0,
13676
+ ...row.transcript?.length ? { transcriptPreview: clip(row.transcript.map((entry) => formatTranscriptEntry(entry, maxOutputChars)).join(" "), maxOutputChars) } : {}
13677
+ };
13678
+ }
13679
+ function formatChatTranscriptMessage(row, maxChars) {
13680
+ const header = {
13681
+ id: row.id,
13682
+ role: row.role,
13683
+ kind: row.kind,
13684
+ status: row.status,
13685
+ createdAt: row.createdAt,
13686
+ body: clip(row.body, 220)
13687
+ };
13688
+ const transcriptRows = (row.transcript ?? []).map((entry, index) => ({
13689
+ id: `${row.id}:entry-${index + 1}`,
13690
+ messageId: row.id,
13691
+ role: row.role,
13692
+ entry: formatTranscriptEntry(entry, maxChars)
13693
+ }));
13694
+ return transcriptRows.length > 0 ? [header, ...transcriptRows] : [header];
13695
+ }
13696
+ function formatTranscriptEntry(entry, maxChars) {
13697
+ if (entry.kind === "tool_call") return `${entry.ts} tool_call ${entry.name} ${clip(JSON.stringify(entry.input), maxChars)}`;
13698
+ if (entry.kind === "tool_result") return `${entry.ts} tool_result ${entry.toolName ?? entry.toolUseId} ${entry.isError ? "ERROR " : ""}${clip(entry.content, maxChars)}`;
13699
+ if (entry.kind === "result") return `${entry.ts} result ${entry.isError ? "ERROR " : ""}${clip(entry.text || entry.errors.join("; "), maxChars)}`;
13700
+ if ("text" in entry) return `${entry.ts} ${entry.kind} ${clip(entry.text, maxChars)}`;
13701
+ return `${entry.ts} ${entry.kind}`;
13702
+ }
13703
+ function parseLimit(value, fallback) {
13704
+ const parsed = Number(value ?? fallback);
13705
+ if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
13706
+ return Math.floor(parsed);
13707
+ }
13708
+ function includesChatTranscript(opts) {
13709
+ return Boolean(opts.includeTranscript || opts.includeOutput || opts.includeOutputs);
13710
+ }
13711
+ function clip(value, maxChars) {
13712
+ const text6 = value.replace(/\s+/g, " ").trim();
13713
+ if (text6.length <= maxChars) return text6;
13714
+ return `${text6.slice(0, Math.max(0, maxChars - 1))}\u2026`;
13715
+ }
13716
+ function parseJsonObjectOption2(value, label) {
13717
+ if (!value) return {};
13718
+ try {
13719
+ const parsed = JSON.parse(value);
13720
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
13721
+ throw new Error(`${label} must be a JSON object`);
13722
+ }
13723
+ return parsed;
13724
+ } catch (error) {
13725
+ if (error instanceof Error && error.message.includes("JSON object")) throw error;
13726
+ throw new Error(`${label} must be valid JSON`);
13727
+ }
13728
+ }
13729
+ function definedRecord2(record) {
13730
+ return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0));
13731
+ }
13732
+ async function readStdin() {
13733
+ const chunks = [];
13734
+ for await (const chunk of process.stdin) {
13735
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
13736
+ }
13737
+ return Buffer.concat(chunks).toString("utf8");
13738
+ }
13739
+
13740
+ // src/commands/client/runs.ts
13741
+ function registerRunsCommands(program) {
13742
+ const runs = program.command("runs").description("Run debugging operations");
13743
+ addCommonClientOptions(
13744
+ runs.command("list").description(getAgentCliCapabilityById("runs.list").description).option("-O, --org-id <id>", "Organization ID").option("--updated-after <iso>", "Only runs updated after this timestamp").option("--run-id-prefix <prefix>", "Filter by run ID prefix").option("--agent-id <id>", "Filter by agent ID").option("--status <status>", "Filter by run status").option("--runtime <type>", "Filter by runtime type").option("--issue-id <id>", "Filter by linked issue ID").option("--created-before <iso>", "Only runs created before this timestamp").option("--limit <n>", "Maximum rows", "200").action(async (opts) => {
13745
+ try {
13746
+ const ctx = resolveCommandContext(opts, { requireCompany: true });
13747
+ const rows = await ctx.api.get(`/api/run-intelligence/orgs/${ctx.orgId}/runs?${buildRunsListQuery(opts)}`) ?? [];
13748
+ printOutput(ctx.json ? rows : rows.map(formatRunListRow), { json: ctx.json });
13749
+ } catch (err) {
13750
+ handleCommandError(err);
13751
+ }
13752
+ }),
13753
+ { includeCompany: false }
13754
+ );
13755
+ addCommonClientOptions(
13756
+ runs.command("get").description(getAgentCliCapabilityById("runs.get").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
13757
+ try {
13758
+ const ctx = resolveCommandContext(opts);
13759
+ const row = await ctx.api.get(`/api/run-intelligence/runs/${encodeURIComponent(runId)}`);
13760
+ printOutput(row, { json: ctx.json });
13761
+ } catch (err) {
13762
+ handleCommandError(err);
13763
+ }
13764
+ })
13765
+ );
13766
+ addCommonClientOptions(
13767
+ runs.command("events").description(getAgentCliCapabilityById("runs.events").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
13768
+ try {
13769
+ const ctx = resolveCommandContext(opts);
13770
+ const rows = await ctx.api.get(`/api/run-intelligence/runs/${encodeURIComponent(runId)}/events`) ?? [];
13771
+ printOutput(ctx.json ? rows : rows.map(formatRunEvent), { json: ctx.json });
13772
+ } catch (err) {
13773
+ handleCommandError(err);
13774
+ }
13775
+ })
13776
+ );
13777
+ addCommonClientOptions(
13778
+ runs.command("log").description(getAgentCliCapabilityById("runs.log").description).argument("<runId>", "Run ID").option("--max-chars <n>", "Maximum log characters for human output", "12000").action(async (runId, opts) => {
13779
+ try {
13780
+ const ctx = resolveCommandContext(opts);
13781
+ const row = await ctx.api.get(`/api/run-intelligence/runs/${encodeURIComponent(runId)}/log`);
13782
+ if (ctx.json) {
13783
+ printOutput(row, { json: true });
13784
+ } else {
13785
+ process.stdout.write(clip2(row?.content ?? "", parseLimit2(opts.maxChars, 12e3)) + "\n");
13786
+ }
13787
+ } catch (err) {
13788
+ handleCommandError(err);
13789
+ }
13790
+ })
13791
+ );
13792
+ addCommonClientOptions(
13793
+ runs.command("transcript").description(getAgentCliCapabilityById("runs.transcript").description).argument("<runId>", "Run ID").option("--errors-only", "Show only error transcript rows").option("--around-error <id>", "Show context around a run error id such as step-12").option("--context-turns <n>", "Turns around --around-error", "1").option("--cursor <cursor>", "Stable transcript cursor returned in page.nextCursor").option("--turn-limit <n>", "Maximum turns to return", "20").option("--chronological", "Show oldest-first instead of default newest-first").option("--narrative", "Use a narrative human layout").option("--max-chars <n>", "Maximum output characters per row", "1200").option("--max-output-chars <n>", "Alias for --max-chars").option("--include-output", "Include row output in compact human transcript rows").option("--include-outputs", "Alias for --include-output").action(async (runId, opts) => {
13794
+ try {
13795
+ const ctx = resolveCommandContext(opts);
13796
+ const payload = await ctx.api.get(
13797
+ `/api/run-intelligence/runs/${encodeURIComponent(runId)}/transcript?${buildTranscriptQuery(opts, { json: ctx.json })}`
13798
+ );
13799
+ if (ctx.json) {
13800
+ printOutput(payload, { json: true });
13801
+ } else if (opts.narrative) {
13802
+ printOutput((payload?.rows ?? []).map(formatRunTranscriptNarrative), { json: false });
13803
+ } else {
13804
+ printOutput((payload?.rows ?? []).map(formatRunTranscriptRow), { json: false });
13805
+ }
13806
+ } catch (err) {
13807
+ handleCommandError(err);
13808
+ }
13809
+ })
13810
+ );
13811
+ addCommonClientOptions(
13812
+ runs.command("errors").description(getAgentCliCapabilityById("runs.errors").description).argument("<runId>", "Run ID").option("--max-chars <n>", "Maximum output characters per error", "1200").action(async (runId, opts) => {
13813
+ try {
13814
+ const ctx = resolveCommandContext(opts);
13815
+ const params = new URLSearchParams();
13816
+ params.set("maxChars", String(parseLimit2(opts.maxChars, 1200)));
13817
+ const payload = await ctx.api.get(
13818
+ `/api/run-intelligence/runs/${encodeURIComponent(runId)}/errors?${params.toString()}`
13819
+ );
13820
+ printOutput(ctx.json ? payload : (payload?.errors ?? []).map(formatRunError), { json: ctx.json });
13821
+ } catch (err) {
13822
+ handleCommandError(err);
13823
+ }
13824
+ })
13825
+ );
13826
+ addCommonClientOptions(
13827
+ runs.command("cancel").description(getAgentCliCapabilityById("runs.cancel").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
13828
+ try {
13829
+ const ctx = resolveCommandContext(opts);
13830
+ const row = await ctx.api.post(`/api/heartbeat-runs/${encodeURIComponent(runId)}/cancel`, {});
13831
+ printOutput(row, { json: ctx.json });
13832
+ } catch (err) {
13833
+ handleCommandError(err);
13834
+ }
13835
+ })
13836
+ );
13837
+ addCommonClientOptions(
13838
+ runs.command("retry").description(getAgentCliCapabilityById("runs.retry").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
13839
+ try {
13840
+ const ctx = resolveCommandContext(opts);
13841
+ const row = await ctx.api.post(`/api/heartbeat-runs/${encodeURIComponent(runId)}/retry`, {});
13842
+ printOutput(row, { json: ctx.json });
13843
+ } catch (err) {
13844
+ handleCommandError(err);
13845
+ }
13846
+ })
13847
+ );
13848
+ }
13849
+ function buildRunsListQuery(opts) {
13850
+ const params = new URLSearchParams();
13851
+ if (opts.updatedAfter) params.set("updatedAfter", opts.updatedAfter);
13852
+ if (opts.runIdPrefix) params.set("runIdPrefix", opts.runIdPrefix);
13853
+ if (opts.agentId) params.set("agentId", opts.agentId);
13854
+ if (opts.status) params.set("status", opts.status);
13855
+ if (opts.runtime) params.set("runtime", opts.runtime);
13856
+ if (opts.issueId) params.set("issueId", opts.issueId);
13857
+ if (opts.createdBefore) params.set("createdBefore", opts.createdBefore);
13858
+ if (opts.limit) params.set("limit", opts.limit);
13859
+ return params.toString();
13860
+ }
13861
+ function buildTranscriptQuery(opts, output) {
13862
+ const params = new URLSearchParams();
13863
+ if (opts.errorsOnly) params.set("errorsOnly", "true");
13864
+ if (opts.aroundError) params.set("aroundError", opts.aroundError);
13865
+ if (opts.cursor) params.set("cursor", opts.cursor);
13866
+ if (opts.turnLimit) params.set("turnLimit", String(parseLimit2(opts.turnLimit, 20)));
13867
+ params.set("contextTurns", String(parseLimit2(opts.contextTurns, 1)));
13868
+ params.set("order", opts.chronological || opts.narrative ? "oldest" : "newest");
13869
+ params.set("output", output.json ? "full" : "compact");
13870
+ const includeOutputs = output.json || Boolean(opts.includeOutput || opts.includeOutputs || opts.narrative);
13871
+ params.set("includeOutputs", includeOutputs ? "true" : "false");
13872
+ params.set("maxChars", String(parseLimit2(opts.maxOutputChars ?? opts.maxChars, 1200)));
13873
+ return params.toString();
13874
+ }
13875
+ function formatRunListRow(row) {
13876
+ return {
13877
+ id: row.run.id,
13878
+ status: row.run.status,
13879
+ agent: row.agentName ?? row.run.agentId,
13880
+ runtime: row.bundle.agentRuntimeType,
13881
+ issue: row.issue?.identifier ?? row.issue?.id ?? "-",
13882
+ updatedAt: row.run.updatedAt
13883
+ };
13884
+ }
13885
+ function formatRunEvent(row) {
13886
+ return {
13887
+ seq: row.seq,
13888
+ level: row.level,
13889
+ stream: row.stream,
13890
+ message: row.message,
13891
+ createdAt: row.createdAt
13892
+ };
13893
+ }
13894
+ function formatRunTranscriptRow(row) {
13895
+ return {
13896
+ id: row.id,
13897
+ turn: row.turnIndex ?? "-",
13898
+ kind: row.kind,
13899
+ ts: row.ts,
13900
+ error: row.isError ? "yes" : "no",
13901
+ preview: row.preview || row.detailPreview,
13902
+ ...row.output ? { output: row.output.text } : {}
13903
+ };
13904
+ }
13905
+ function formatRunTranscriptNarrative(row) {
13906
+ const marker = row.isError ? "ERROR " : "";
13907
+ return `${row.id} ${row.ts} ${marker}${row.kind}: ${row.preview || row.detailPreview}${row.output ? `
13908
+ ${row.output.text}` : ""}`;
13909
+ }
13910
+ function formatRunError(row) {
13911
+ return {
13912
+ id: row.id,
13913
+ type: row.type,
13914
+ turn: row.turnIndex ?? "-",
13915
+ summary: row.summary,
13916
+ output: row.output.text,
13917
+ context: row.transcriptContext?.command ?? "-"
13918
+ };
13919
+ }
13920
+ function parseLimit2(value, fallback) {
13921
+ const parsed = Number(value ?? fallback);
13922
+ if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
13923
+ return Math.floor(parsed);
13924
+ }
13925
+ function clip2(value, maxChars) {
13926
+ if (value.length <= maxChars) return value;
13927
+ return `${value.slice(0, Math.max(0, maxChars - 1))}\u2026`;
13928
+ }
13929
+
12795
13930
  // src/config/data-dir.ts
12796
13931
  init_home();
12797
13932
  import path21 from "node:path";
@@ -13172,6 +14307,9 @@ function createProgram() {
13172
14307
  registerDashboardCommands(program);
13173
14308
  registerSkillCommands(program);
13174
14309
  registerLibraryCommands(program);
14310
+ registerAutomationCommands(program);
14311
+ registerChatCommands(program);
14312
+ registerRunsCommands(program);
13175
14313
  registerLazyWorktreeCommands(program);
13176
14314
  registerPluginCommands(program);
13177
14315
  registerLazyBenchmarkCommands(program);