@revfleet/hscli 0.8.12 → 0.9.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 (153) hide show
  1. package/CHANGELOG.md +166 -1
  2. package/README.md +220 -10
  3. package/dist/cli.js +27 -3
  4. package/dist/cli.js.map +1 -1
  5. package/dist/commands/agent/contracts.d.ts +3 -0
  6. package/dist/commands/agent/contracts.js +139 -0
  7. package/dist/commands/agent/contracts.js.map +1 -0
  8. package/dist/commands/agent/index.d.ts +3 -0
  9. package/dist/commands/agent/index.js +188 -0
  10. package/dist/commands/agent/index.js.map +1 -0
  11. package/dist/commands/agent/recipes.d.ts +13 -0
  12. package/dist/commands/agent/recipes.js +108 -0
  13. package/dist/commands/agent/recipes.js.map +1 -0
  14. package/dist/commands/agent/runner.d.ts +16 -0
  15. package/dist/commands/agent/runner.js +165 -0
  16. package/dist/commands/agent/runner.js.map +1 -0
  17. package/dist/commands/auth/index.js +64 -7
  18. package/dist/commands/auth/index.js.map +1 -1
  19. package/dist/commands/automation/index.js +30 -0
  20. package/dist/commands/automation/index.js.map +1 -1
  21. package/dist/commands/backup/index.d.ts +12 -0
  22. package/dist/commands/backup/index.js +459 -0
  23. package/dist/commands/backup/index.js.map +1 -0
  24. package/dist/commands/cms/content-ops.js +1 -1
  25. package/dist/commands/cms/content-ops.js.map +1 -1
  26. package/dist/commands/communication-preferences/index.js +207 -7
  27. package/dist/commands/communication-preferences/index.js.map +1 -1
  28. package/dist/commands/content-permissions/index.d.ts +22 -0
  29. package/dist/commands/content-permissions/index.js +141 -0
  30. package/dist/commands/content-permissions/index.js.map +1 -0
  31. package/dist/commands/context/index.d.ts +3 -0
  32. package/dist/commands/context/index.js +182 -0
  33. package/dist/commands/context/index.js.map +1 -0
  34. package/dist/commands/crm/associations.js +38 -0
  35. package/dist/commands/crm/associations.js.map +1 -1
  36. package/dist/commands/crm/custom-objects.js +39 -2
  37. package/dist/commands/crm/custom-objects.js.map +1 -1
  38. package/dist/commands/crm/dated.js +3 -3
  39. package/dist/commands/crm/dated.js.map +1 -1
  40. package/dist/commands/crm/migration.js +210 -2
  41. package/dist/commands/crm/migration.js.map +1 -1
  42. package/dist/commands/crm/properties.js +2 -1
  43. package/dist/commands/crm/properties.js.map +1 -1
  44. package/dist/commands/crm/property-batch.d.ts +1 -0
  45. package/dist/commands/crm/property-batch.js +44 -5
  46. package/dist/commands/crm/property-batch.js.map +1 -1
  47. package/dist/commands/crm/shared.js +21 -2
  48. package/dist/commands/crm/shared.js.map +1 -1
  49. package/dist/commands/crm/sync.js +1 -1
  50. package/dist/commands/crm/sync.js.map +1 -1
  51. package/dist/commands/doctor/index.js +193 -0
  52. package/dist/commands/doctor/index.js.map +1 -1
  53. package/dist/commands/email-tracking/index.d.ts +16 -0
  54. package/dist/commands/email-tracking/index.js +314 -0
  55. package/dist/commands/email-tracking/index.js.map +1 -0
  56. package/dist/commands/extensions/index.js +1 -1
  57. package/dist/commands/extensions/index.js.map +1 -1
  58. package/dist/commands/forms/index.js +15 -2
  59. package/dist/commands/forms/index.js.map +1 -1
  60. package/dist/commands/forms/legacy-v2.d.ts +7 -2
  61. package/dist/commands/forms/legacy-v2.js +103 -7
  62. package/dist/commands/forms/legacy-v2.js.map +1 -1
  63. package/dist/commands/guide/index.d.ts +1 -1
  64. package/dist/commands/guide/index.js +37 -4
  65. package/dist/commands/guide/index.js.map +1 -1
  66. package/dist/commands/internal/catalog.d.ts +1 -0
  67. package/dist/commands/internal/catalog.js +2 -0
  68. package/dist/commands/internal/catalog.js.map +1 -0
  69. package/dist/commands/internal/index.d.ts +26 -0
  70. package/dist/commands/internal/index.js +823 -0
  71. package/dist/commands/internal/index.js.map +1 -0
  72. package/dist/commands/internal-session.d.ts +15 -0
  73. package/dist/commands/internal-session.js +152 -0
  74. package/dist/commands/internal-session.js.map +1 -0
  75. package/dist/commands/lists/index.js +1 -1
  76. package/dist/commands/lists/index.js.map +1 -1
  77. package/dist/commands/marketing/email-audit.d.ts +32 -0
  78. package/dist/commands/marketing/email-audit.js +121 -0
  79. package/dist/commands/marketing/email-audit.js.map +1 -0
  80. package/dist/commands/marketing/index.js +2 -0
  81. package/dist/commands/marketing/index.js.map +1 -1
  82. package/dist/commands/mcp.js +5 -3
  83. package/dist/commands/mcp.js.map +1 -1
  84. package/dist/commands/playbooks/index.d.ts +3 -0
  85. package/dist/commands/playbooks/index.js +228 -0
  86. package/dist/commands/playbooks/index.js.map +1 -0
  87. package/dist/commands/portals/index.d.ts +3 -0
  88. package/dist/commands/portals/index.js +132 -0
  89. package/dist/commands/portals/index.js.map +1 -0
  90. package/dist/commands/reports/index.d.ts +3 -0
  91. package/dist/commands/reports/index.js +479 -0
  92. package/dist/commands/reports/index.js.map +1 -0
  93. package/dist/commands/sales-content/index.d.ts +13 -0
  94. package/dist/commands/sales-content/index.js +59 -0
  95. package/dist/commands/sales-content/index.js.map +1 -0
  96. package/dist/commands/sales-templates/index.d.ts +3 -0
  97. package/dist/commands/sales-templates/index.js +88 -0
  98. package/dist/commands/sales-templates/index.js.map +1 -0
  99. package/dist/commands/seed/cms.js +28 -45
  100. package/dist/commands/seed/cms.js.map +1 -1
  101. package/dist/commands/sequences/index.d.ts +18 -0
  102. package/dist/commands/sequences/index.js +263 -0
  103. package/dist/commands/sequences/index.js.map +1 -0
  104. package/dist/commands/settings/index.js +450 -102
  105. package/dist/commands/settings/index.js.map +1 -1
  106. package/dist/commands/settings/site-settings.d.ts +3 -0
  107. package/dist/commands/settings/site-settings.js +106 -0
  108. package/dist/commands/settings/site-settings.js.map +1 -0
  109. package/dist/commands/ui/index.js +14 -4
  110. package/dist/commands/ui/index.js.map +1 -1
  111. package/dist/commands/workflows/index.js +2 -0
  112. package/dist/commands/workflows/index.js.map +1 -1
  113. package/dist/commands/workflows/preflight.d.ts +23 -0
  114. package/dist/commands/workflows/preflight.js +295 -0
  115. package/dist/commands/workflows/preflight.js.map +1 -0
  116. package/dist/core/action-contract.d.ts +43 -0
  117. package/dist/core/action-contract.js +207 -0
  118. package/dist/core/action-contract.js.map +1 -0
  119. package/dist/core/auth.d.ts +6 -0
  120. package/dist/core/auth.js +85 -0
  121. package/dist/core/auth.js.map +1 -1
  122. package/dist/core/http.d.ts +8 -0
  123. package/dist/core/http.js +37 -5
  124. package/dist/core/http.js.map +1 -1
  125. package/dist/core/id-maps.d.ts +27 -0
  126. package/dist/core/id-maps.js +204 -0
  127. package/dist/core/id-maps.js.map +1 -0
  128. package/dist/core/output.d.ts +2 -1
  129. package/dist/core/output.js +34 -0
  130. package/dist/core/output.js.map +1 -1
  131. package/dist/mcp/profiles.d.ts +14 -0
  132. package/dist/mcp/profiles.js +68 -0
  133. package/dist/mcp/profiles.js.map +1 -0
  134. package/dist/mcp/server.d.ts +5 -3
  135. package/dist/mcp/server.js +22 -5
  136. package/dist/mcp/server.js.map +1 -1
  137. package/docs/CAPABILITY_LIBRARY.md +29 -8
  138. package/docs/COMMAND_TREE.md +96 -17
  139. package/docs/COMPARISON.md +8 -5
  140. package/docs/COOKBOOK.md +124 -5
  141. package/docs/INTERNAL-ENDPOINTS-DISCOVERY.md +813 -0
  142. package/docs/INTERNAL-ENDPOINTS.md +371 -0
  143. package/docs/INTERNAL_ENDPOINTS.md +243 -0
  144. package/docs/MARKETING_SETUP.md +21 -1
  145. package/docs/MCP.md +28 -89
  146. package/docs/MCP_TOOL_CATALOG.md +192 -0
  147. package/docs/MIGRATION_ADAPTERS.md +115 -0
  148. package/docs/PORTAL_BACKUP.md +212 -0
  149. package/docs/PUBLISHING.md +1 -1
  150. package/docs/SALES_CONTENT_INTERNAL_PUNCH_LIST.md +504 -0
  151. package/docs/TUTORIALS/secure-agent-writes.md +49 -0
  152. package/docs/WHY_HOW_WHAT.md +10 -4
  153. package/package.json +4 -2
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ import { type CliContext } from "../../core/output.js";
3
+ export declare function registerActionContractCommands(agent: Command, getCtx: () => CliContext): void;
@@ -0,0 +1,139 @@
1
+ import { spawn } from "node:child_process";
2
+ import { getProfile, hasProfile } from "../../core/auth.js";
3
+ import { readActionContractFile, sealActionContract, verifyActionContract, } from "../../core/action-contract.js";
4
+ import { CliError, printResult, redactSensitive } from "../../core/output.js";
5
+ function activePortalId(profile) {
6
+ if (!hasProfile(profile))
7
+ return undefined;
8
+ return getProfile(profile).portalId;
9
+ }
10
+ function renderedCommands(ctx, contract) {
11
+ return contract.operation.commands.map((command) => [
12
+ "hscli",
13
+ "--profile",
14
+ contract.profile,
15
+ ...(ctx.policyFile ? ["--policy-file", ctx.policyFile] : []),
16
+ ...(contract.changeTicket ? ["--change-ticket", contract.changeTicket] : []),
17
+ ...command.argv,
18
+ ]);
19
+ }
20
+ function executionArgv(ctx, contract, argv, force) {
21
+ return [
22
+ process.argv[1] ?? "hscli",
23
+ "--profile",
24
+ contract.profile,
25
+ ...(ctx.policyFile ? ["--policy-file", ctx.policyFile] : []),
26
+ ...(contract.changeTicket ? ["--change-ticket", contract.changeTicket] : []),
27
+ "--format",
28
+ "jsonl",
29
+ ...(force ? ["--force"] : []),
30
+ ...argv,
31
+ ];
32
+ }
33
+ async function executeArgv(argv, contractId) {
34
+ await new Promise((resolve, reject) => {
35
+ const child = spawn(process.execPath, argv, {
36
+ shell: false,
37
+ stdio: "inherit",
38
+ env: {
39
+ ...process.env,
40
+ HSCLI_ACTION_CONTRACT_ID: contractId,
41
+ },
42
+ });
43
+ child.once("error", (error) => {
44
+ reject(new CliError("ACTION_CONTRACT_COMMAND_FAILED", error.message));
45
+ });
46
+ child.once("close", (code, signal) => {
47
+ if (code === 0) {
48
+ resolve();
49
+ return;
50
+ }
51
+ reject(new CliError("ACTION_CONTRACT_COMMAND_FAILED", `Contract command exited with code ${code ?? "null"}${signal ? ` (signal ${signal})` : ""}.`));
52
+ });
53
+ });
54
+ }
55
+ export function registerActionContractCommands(agent, getCtx) {
56
+ const contract = agent
57
+ .command("contract")
58
+ .description("Create, inspect, verify, and apply versioned hscli action contracts");
59
+ contract
60
+ .command("create")
61
+ .requiredOption("--input <file>", "JSON action-contract draft")
62
+ .description("Validate and seal an action-contract draft without executing it")
63
+ .action((opts) => {
64
+ const ctx = getCtx();
65
+ printResult(ctx, sealActionContract(readActionContractFile(String(opts.input))));
66
+ });
67
+ contract
68
+ .command("inspect")
69
+ .argument("<file>", "Sealed action-contract JSON file")
70
+ .description("Print a redacted action contract without validating active profile state")
71
+ .action((file) => {
72
+ const ctx = getCtx();
73
+ printResult(ctx, redactSensitive(readActionContractFile(String(file))));
74
+ });
75
+ contract
76
+ .command("verify")
77
+ .argument("<file>", "Sealed action-contract JSON file")
78
+ .description("Verify digest, profile, portal, and expiry without executing it")
79
+ .action((file) => {
80
+ const ctx = getCtx();
81
+ const verification = verifyActionContract(readActionContractFile(String(file)), {
82
+ profile: ctx.profile,
83
+ portalId: activePortalId(ctx.profile),
84
+ changeTicket: ctx.changeTicket,
85
+ });
86
+ printResult(ctx, {
87
+ valid: verification.valid,
88
+ id: verification.contract.id,
89
+ digest: verification.digest,
90
+ profile: verification.contract.profile,
91
+ portalId: verification.contract.portalId,
92
+ expiresAt: verification.contract.expiresAt,
93
+ portalCheck: verification.portalCheck,
94
+ commandCount: verification.contract.operation.commands.length,
95
+ });
96
+ });
97
+ contract
98
+ .command("apply")
99
+ .argument("<file>", "Sealed action-contract JSON file")
100
+ .option("--execute", "Approve execution after contract verification")
101
+ .description("Preview by default; execution requires both --execute and global --force")
102
+ .action(async (file, opts) => {
103
+ const ctx = getCtx();
104
+ const verification = verifyActionContract(readActionContractFile(String(file)), {
105
+ profile: ctx.profile,
106
+ portalId: activePortalId(ctx.profile),
107
+ changeTicket: ctx.changeTicket,
108
+ });
109
+ const approved = Boolean(opts.execute) && ctx.force;
110
+ if (!approved) {
111
+ printResult(ctx, {
112
+ executionMode: "plan-only",
113
+ approved: false,
114
+ reason: "Both --execute and --force are required",
115
+ contractId: verification.contract.id,
116
+ digest: verification.digest,
117
+ commands: renderedCommands(ctx, verification.contract),
118
+ });
119
+ return;
120
+ }
121
+ let verificationCount = 0;
122
+ for (const command of verification.contract.operation.commands) {
123
+ await executeArgv(executionArgv(ctx, verification.contract, command.argv, true), verification.contract.id);
124
+ if (command.verifyArgv) {
125
+ await executeArgv(executionArgv(ctx, verification.contract, command.verifyArgv, false), verification.contract.id);
126
+ verificationCount += 1;
127
+ }
128
+ }
129
+ printResult(ctx, {
130
+ executionMode: "executed",
131
+ approved: true,
132
+ contractId: verification.contract.id,
133
+ digest: verification.digest,
134
+ commandCount: verification.contract.operation.commands.length,
135
+ verificationCount,
136
+ });
137
+ });
138
+ }
139
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../src/commands/agent/contracts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAmB,MAAM,sBAAsB,CAAC;AAE/F,SAAS,cAAc,CAAC,OAAe;IACrC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;AACtC,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAe,EAAE,QAA+C;IACxF,OAAO,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QAClD,OAAO;QACP,WAAW;QACX,QAAQ,CAAC,OAAO;QAChB,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,eAAe,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAA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C,GAAG,EAAE;YACf,aAAa,EAAE,UAAU;YACzB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,YAAY,CAAC,QAAQ,CAAC,EAAE;YACpC,MAAM,EAAE,YAAY,CAAC,MAAM;YAC3B,YAAY,EAAE,YAAY,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM;YAC7D,iBAAiB;SAClB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ import { type CliContext } from "../../core/output.js";
3
+ export declare function registerAgent(program: Command, getCtx: () => CliContext): void;
@@ -0,0 +1,188 @@
1
+ import { CliError, printResult } from "../../core/output.js";
2
+ import { registerActionContractCommands } from "./contracts.js";
3
+ import { AGENT_PRINCIPLES, recipeIds, resolveRecipe } from "./recipes.js";
4
+ import { runAgentRecipe } from "./runner.js";
5
+ function shellQuoteArg(value) {
6
+ if (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value))
7
+ return value;
8
+ return `'${value.replace(/'/g, "'\\''")}'`;
9
+ }
10
+ function shellJoin(argv) {
11
+ return argv.map(shellQuoteArg).join(" ");
12
+ }
13
+ function yamlSingleQuote(value) {
14
+ return `'${value.replace(/'/g, "''")}'`;
15
+ }
16
+ function xmlEscape(value) {
17
+ return value
18
+ .replace(/&/g, "&amp;")
19
+ .replace(/</g, "&lt;")
20
+ .replace(/>/g, "&gt;")
21
+ .replace(/"/g, "&quot;")
22
+ .replace(/'/g, "&apos;");
23
+ }
24
+ function validateCronExpression(raw) {
25
+ const cron = raw.trim().replace(/\s+/g, " ");
26
+ if (/[\r\n]/.test(raw) || cron.split(" ").length !== 5) {
27
+ throw new CliError("AGENT_SCHEDULE_CRON_INVALID", "--cron must be a single-line five-field cron expression");
28
+ }
29
+ return cron;
30
+ }
31
+ function globalArgv(ctx) {
32
+ const parts = ["hscli", "--profile", ctx.profile];
33
+ if (ctx.policyFile)
34
+ parts.push("--policy-file", ctx.policyFile);
35
+ if (ctx.changeTicket)
36
+ parts.push("--change-ticket", ctx.changeTicket);
37
+ return parts;
38
+ }
39
+ function renderCommand(ctx, argv) {
40
+ const renderedArgv = argv.map((arg) => arg === "{{telemetryFile}}" ? "<run-output>/requests.jsonl" : arg);
41
+ return shellJoin([...globalArgv(ctx), ...renderedArgv]);
42
+ }
43
+ function renderRecipe(ctx, recipeId) {
44
+ const recipe = resolveRecipe(recipeId);
45
+ return {
46
+ id: recipe.id,
47
+ title: recipe.title,
48
+ purpose: recipe.purpose,
49
+ cadence: recipe.cadence,
50
+ deterministicSignals: recipe.deterministicSignals,
51
+ commands: recipe.commandArgv.map((argv) => renderCommand(ctx, argv)),
52
+ };
53
+ }
54
+ function renderPlan(ctx, recipeId) {
55
+ const recipe = renderRecipe(ctx, recipeId);
56
+ return {
57
+ executionMode: "plan-only",
58
+ recipe: recipe.id,
59
+ title: recipe.title,
60
+ profile: ctx.profile,
61
+ policyFile: ctx.policyFile ?? null,
62
+ changeTicket: ctx.changeTicket ?? null,
63
+ principles: AGENT_PRINCIPLES,
64
+ guardrails: [
65
+ "No writes are executed by `agent plan`.",
66
+ "Runbooks use public HubSpot APIs by default.",
67
+ "Every write-capable follow-up must still use --force.",
68
+ "Use --policy-file and --change-ticket for governed portals.",
69
+ "Use trace/audit commands to make agent activity reviewable.",
70
+ "Internal migration adapters remain explicit allowlisted commands, not generic passthroughs.",
71
+ ],
72
+ deterministicSignals: recipe.deterministicSignals,
73
+ commands: recipe.commands,
74
+ };
75
+ }
76
+ function renderScheduleArtifact(ctx, recipeId, target, rawCron) {
77
+ const cron = validateCronExpression(rawCron);
78
+ const commandArgv = [...globalArgv(ctx), "--format", "jsonl", "agent", "run", recipeId];
79
+ const command = shellJoin(commandArgv);
80
+ if (target === "cron") {
81
+ return `${cron} ${command} >> hscli-agent-${recipeId}.jsonl 2>&1`;
82
+ }
83
+ if (target === "github-actions") {
84
+ return [
85
+ "name: hscli agent runbook",
86
+ "on:",
87
+ " schedule:",
88
+ ` - cron: '${cron}'`,
89
+ "jobs:",
90
+ " runbook:",
91
+ " runs-on: ubuntu-latest",
92
+ " steps:",
93
+ " - uses: actions/setup-node@v4",
94
+ " with:",
95
+ " node-version: '20'",
96
+ " - run: npm install -g @revfleet/hscli",
97
+ ` - run: ${yamlSingleQuote(command)}`,
98
+ ].join("\n");
99
+ }
100
+ const launchdArgs = commandArgv.map((arg) => ` <string>${xmlEscape(arg)}</string>`);
101
+ return [
102
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
103
+ "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">",
104
+ "<plist version=\"1.0\">",
105
+ "<dict>",
106
+ " <key>Label</key><string>ai.revfleet.hscli.agent</string>",
107
+ " <key>ProgramArguments</key>",
108
+ " <array>",
109
+ ...launchdArgs,
110
+ " </array>",
111
+ " <key>StartCalendarInterval</key>",
112
+ " <dict><key>Hour</key><integer>8</integer><key>Minute</key><integer>0</integer></dict>",
113
+ "</dict>",
114
+ "</plist>",
115
+ ].join("\n");
116
+ }
117
+ export function registerAgent(program, getCtx) {
118
+ const agent = program
119
+ .command("agent")
120
+ .description("Agent-safe HubSpot operator runbooks: public API first, scheduled, auditable, policy-aware");
121
+ registerActionContractCommands(agent, getCtx);
122
+ agent
123
+ .command("list")
124
+ .description("List deterministic agent-safe operator recipes")
125
+ .action(() => {
126
+ const ctx = getCtx();
127
+ printResult(ctx, {
128
+ principles: AGENT_PRINCIPLES,
129
+ recipes: recipeIds().map((id) => {
130
+ const recipe = resolveRecipe(id);
131
+ return {
132
+ id: recipe.id,
133
+ title: recipe.title,
134
+ purpose: recipe.purpose,
135
+ cadence: recipe.cadence,
136
+ deterministicSignals: recipe.deterministicSignals,
137
+ };
138
+ }),
139
+ });
140
+ });
141
+ agent
142
+ .command("plan")
143
+ .argument("<recipe>", "portal-baseline|data-cleanup|pipeline-risk|automation-risk")
144
+ .description("Render a safe runbook plan without executing HubSpot requests")
145
+ .action((recipe) => {
146
+ const ctx = getCtx();
147
+ printResult(ctx, renderPlan(ctx, recipe));
148
+ });
149
+ agent
150
+ .command("run")
151
+ .argument("<recipe>", "portal-baseline|data-cleanup|pipeline-risk|automation-risk")
152
+ .option("--output <dir>", "Evidence directory (default: ~/.revfleet/agent-runs/<recipe>/<run>)")
153
+ .option("--resume", "Resume from checkpoint in the output directory")
154
+ .option("--continue-on-error", "Run remaining steps and report completed_with_errors")
155
+ .description("Execute a deterministic read-only recipe and write resumable evidence")
156
+ .action(async (recipe, opts) => {
157
+ const ctx = getCtx();
158
+ const result = await runAgentRecipe(ctx, recipe, {
159
+ output: opts.output ? String(opts.output) : undefined,
160
+ resume: Boolean(opts.resume),
161
+ continueOnError: Boolean(opts.continueOnError),
162
+ });
163
+ printResult(ctx, result);
164
+ });
165
+ const schedule = agent.command("schedule").description("Render schedule artifacts for agent runbooks");
166
+ schedule
167
+ .command("render")
168
+ .argument("<recipe>", "portal-baseline|data-cleanup|pipeline-risk|automation-risk")
169
+ .option("--target <target>", "cron|github-actions|launchd", "cron")
170
+ .option("--cron <expr>", "Cron expression for cron/github-actions targets", "0 8 * * 1")
171
+ .description("Render a schedule artifact; does not install or execute it")
172
+ .action((recipe, opts) => {
173
+ const ctx = getCtx();
174
+ resolveRecipe(recipe);
175
+ const target = String(opts.target ?? "cron");
176
+ if (!["cron", "github-actions", "launchd"].includes(target)) {
177
+ throw new CliError("AGENT_SCHEDULE_TARGET_UNKNOWN", "Expected --target cron|github-actions|launchd");
178
+ }
179
+ const cron = String(opts.cron ?? "0 8 * * 1");
180
+ printResult(ctx, {
181
+ recipe,
182
+ target,
183
+ installsNothing: true,
184
+ artifact: renderScheduleArtifact(ctx, recipe, target, cron),
185
+ });
186
+ });
187
+ }
188
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/agent/index.ts"],"names":[],"mappings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Q,CAAC;SACjB,QAAQ,CAAC,UAAU,EAAE,4DAA4D,CAAC;SAClF,MAAM,CAAC,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,CAAC;SAClE,MAAM,CAAC,eAAe,EAAE,iDAAiD,EAAE,WAAW,CAAC;SACvF,WAAW,CAAC,4DAA4D,CAAC;SACzE,MAAM,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;QACvB,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;QACrB,aAAa,CAAC,MAAM,CAAC,CAAC;QACtB,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,MAAM,CAAmB,CAAC;QAC/D,IAAI,CAAC,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5D,MAAM,IAAI,QAAQ,CAAC,+BAA+B,EAAE,+CAA+C,CAAC,CAAC;QACvG,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,WAAW,CAAC,CAAC;QAC9C,WAAW,CAAC,GAAG,EAAE;YACf,MAAM;YACN,MAAM;YACN,eAAe,EAAE,IAAI;YACrB,QAAQ,EAAE,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC;SAC5D,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,13 @@
1
+ export type AgentRecipeId = "portal-baseline" | "data-cleanup" | "pipeline-risk" | "automation-risk";
2
+ export type ScheduleTarget = "cron" | "github-actions" | "launchd";
3
+ export interface AgentRecipe {
4
+ id: AgentRecipeId;
5
+ title: string;
6
+ purpose: string;
7
+ cadence: string;
8
+ deterministicSignals: string[];
9
+ commandArgv: string[][];
10
+ }
11
+ export declare const AGENT_PRINCIPLES: string[];
12
+ export declare function recipeIds(): AgentRecipeId[];
13
+ export declare function resolveRecipe(id: string): AgentRecipe;
@@ -0,0 +1,108 @@
1
+ import { CliError } from "../../core/output.js";
2
+ export const AGENT_PRINCIPLES = [
3
+ "public-api-first",
4
+ "mcp-compatible",
5
+ "scheduled-runbooks",
6
+ "audit-trail",
7
+ "explicit-migration-adapters",
8
+ "deterministic-scoring",
9
+ "writes-require-force",
10
+ ];
11
+ const RECIPES = {
12
+ "portal-baseline": {
13
+ id: "portal-baseline",
14
+ title: "Portal baseline",
15
+ purpose: "Create one evidence-first snapshot of portal identity, access topology, CRM readiness, pipeline structure, and automation exposure for a first audit or recurring review.",
16
+ cadence: "monthly-or-before-change",
17
+ deterministicSignals: [
18
+ "portal identity and API reachability",
19
+ "users and teams",
20
+ "deal pipeline inventory",
21
+ "contact, company, and deal data readiness",
22
+ "workflow exposure",
23
+ "request and error evidence",
24
+ ],
25
+ commandArgv: [
26
+ ["--format", "jsonl", "auth", "whoami"],
27
+ ["--format", "jsonl", "doctor", "capabilities"],
28
+ ["--format", "jsonl", "account", "info"],
29
+ ["--format", "jsonl", "settings", "users", "list", "--limit", "100"],
30
+ ["--format", "jsonl", "settings", "teams", "list"],
31
+ ["--format", "jsonl", "crm", "pipelines", "list", "deals"],
32
+ ["--format", "jsonl", "reports", "pull", "object-fill-rate", "--object", "contacts", "--properties", "email,firstname,lastname,company,hubspot_owner_id,country", "--limit", "5000"],
33
+ ["--format", "jsonl", "reports", "pull", "object-fill-rate", "--object", "companies", "--properties", "name,domain,hubspot_owner_id,lifecyclestage", "--limit", "5000"],
34
+ ["--format", "jsonl", "reports", "pull", "object-fill-rate", "--object", "deals", "--properties", "dealname,dealstage,hubspot_owner_id,amount,closedate", "--limit", "5000"],
35
+ ["--format", "jsonl", "workflows", "flows", "list", "--limit", "100"],
36
+ ["--format", "jsonl", "workflows", "v3", "list", "--limit", "100"],
37
+ ["--format", "jsonl", "audit", "timeline", "--file", "{{telemetryFile}}"],
38
+ ],
39
+ },
40
+ "data-cleanup": {
41
+ id: "data-cleanup",
42
+ title: "Data cleanup review",
43
+ purpose: "Find missing contact/account fields, lifecycle gaps, and records that need owner or company context before AI or reporting work.",
44
+ cadence: "weekly",
45
+ deterministicSignals: [
46
+ "contact fill rate",
47
+ "company fill rate",
48
+ "lifecycle distribution",
49
+ "unassigned records",
50
+ "recent write/error audit",
51
+ ],
52
+ commandArgv: [
53
+ ["--format", "jsonl", "reports", "pull", "object-fill-rate", "--object", "contacts", "--limit", "5000"],
54
+ ["--format", "jsonl", "reports", "pull", "object-fill-rate", "--object", "companies", "--limit", "5000"],
55
+ ["--format", "jsonl", "reports", "pull", "property-distribution", "--object", "contacts", "--property", "lifecyclestage", "--limit", "5000"],
56
+ ["--format", "jsonl", "audit", "timeline", "--file", "{{telemetryFile}}"],
57
+ ],
58
+ },
59
+ "pipeline-risk": {
60
+ id: "pipeline-risk",
61
+ title: "Pipeline risk review",
62
+ purpose: "Review deal pipeline health, stage metadata, owner coverage, and stale high-value opportunities.",
63
+ cadence: "weekday-morning",
64
+ deterministicSignals: [
65
+ "pipeline/stage inventory",
66
+ "deal owner coverage",
67
+ "stage distribution",
68
+ "close-date coverage",
69
+ "amount coverage",
70
+ ],
71
+ commandArgv: [
72
+ ["--format", "jsonl", "crm", "pipelines", "list", "deals"],
73
+ ["--format", "jsonl", "reports", "pull", "object-fill-rate", "--object", "deals", "--properties", "dealname,dealstage,hubspot_owner_id,closedate,amount", "--limit", "5000"],
74
+ ["--format", "jsonl", "reports", "pull", "property-distribution", "--object", "deals", "--property", "dealstage", "--limit", "5000"],
75
+ ["--format", "jsonl", "audit", "timeline", "--file", "{{telemetryFile}}"],
76
+ ],
77
+ },
78
+ "automation-risk": {
79
+ id: "automation-risk",
80
+ title: "Automation risk review",
81
+ purpose: "Inspect workflow sprawl, error surfaces, missing documentation, email actions, and dependencies before agents operate on the portal.",
82
+ cadence: "daily",
83
+ deterministicSignals: [
84
+ "workflow inventory",
85
+ "workflow errors",
86
+ "missing descriptions/goals",
87
+ "email action exposure",
88
+ "audit activity by tool",
89
+ ],
90
+ commandArgv: [
91
+ ["--format", "jsonl", "workflows", "flows", "list", "--limit", "100"],
92
+ ["--format", "jsonl", "workflows", "v3", "list", "--limit", "100"],
93
+ ["--format", "jsonl", "reports", "pull", "property-distribution", "--object", "contacts", "--property", "hs_email_optout", "--limit", "5000"],
94
+ ["--format", "jsonl", "audit", "timeline", "--file", "{{telemetryFile}}"],
95
+ ],
96
+ },
97
+ };
98
+ export function recipeIds() {
99
+ return ["portal-baseline", "data-cleanup", "pipeline-risk", "automation-risk"];
100
+ }
101
+ export function resolveRecipe(id) {
102
+ const recipe = RECIPES[id];
103
+ if (!recipe) {
104
+ throw new CliError("AGENT_RECIPE_UNKNOWN", `Unknown agent recipe '${id}'. Expected one of: ${recipeIds().join(", ")}`);
105
+ }
106
+ return recipe;
107
+ }
108
+ //# sourceMappingURL=recipes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipes.js","sourceRoot":"","sources":["../../../src/commands/agent/recipes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAchD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,kBAAkB;IAClB,gBAAgB;IAChB,oBAAoB;IACpB,aAAa;IACb,6BAA6B;IAC7B,uBAAuB;IACvB,sBAAsB;CACvB,CAAC;AAEF,MAAM,OAAO,GAAuC;IAClD,iBAAiB,EAAE;QACjB,EAAE,EAAE,iBAAiB;QACrB,KAAK,EAAE,iBAAiB;QACxB,OAAO,EAAE,2KAA2K;QACpL,OAAO,EAAE,0BAA0B;QACnC,oBAAoB,EAAE;YACpB,sCAAsC;YACtC,iBAAiB;YACjB,yBAAyB;YACzB,2CAA2C;YAC3C,mBAAmB;YACnB,4BAA4B;SAC7B;QACD,WAAW,EAAE;YACX,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;YACvC,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC;YAC/C,CAAC,UAAU,EA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5
+ continueOnError?: boolean;
6
+ }
7
+ export interface AgentRunResult {
8
+ status: "completed" | "completed_with_errors";
9
+ recipe: string;
10
+ profile: string;
11
+ completedSteps: number;
12
+ failedSteps: number;
13
+ outputDir: string;
14
+ runId: string;
15
+ }
16
+ export declare function runAgentRecipe(ctx: CliContext, recipeId: string, options: AgentRunOptions): Promise<AgentRunResult>;