@agency-tbd/cli 0.1.0 → 0.3.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.
package/README.md CHANGED
@@ -16,7 +16,7 @@ Start with `influmode guide --json`. It returns a machine-readable operating gui
16
16
 
17
17
  ## Installation and first use
18
18
 
19
- The public npm package is `@agency-tbd/cli`; the installed command is `influmode`. Node.js `>=24.22.1` is required. Repository access is not required. Once the first registry release is published, install with either package manager:
19
+ The public npm package is `@agency-tbd/cli`; the installed command is `influmode`. Node.js `>=24.22.1` is required. Repository access is not required. Install with either package manager:
20
20
 
21
21
  ```sh
22
22
  pnpm add --global @agency-tbd/cli@latest
@@ -34,12 +34,55 @@ influmode operations campaigns --search list
34
34
  influmode help campaigns list
35
35
  ```
36
36
 
37
- To have an AI assistant handle setup, give it this prompt after the first release is published:
37
+ To have an AI assistant handle setup, give it this prompt:
38
38
 
39
39
  > Install or update the public npm package @agency-tbd/cli to its latest release using pnpm or npm. Ensure Node.js meets the package's engines requirement and make the influmode command available in future terminals. Handle terminal commands yourself; repository access is not needed. Run influmode guide --json, then influmode auth login --url https://www.influmode.com and let me approve access in my browser with my own account. Never ask me to paste passwords, tokens or cookies into chat. Verify the connection with influmode capabilities, then stop without changing application data.
40
40
 
41
41
  Login opens a browser to approve the matching terminal code. `--no-browser` prints the approval URL instead. Login remembers the selected origin. Sessions last up to 24 hours; `auth logout` revokes the current CLI session. Tokens stay in origin-specific private files under `~/.config/influmode`, or `INFLUMODE_CONFIG_DIR`. An injected `INFLUMODE_TOKEN` takes precedence; never print it. `--url` overrides `INFLUMODE_URL` and the remembered origin. See [authentication](src/auth.ts) and [credential storage](src/config.ts).
42
42
 
43
+ ## Support without GitHub access
44
+
45
+ Available since CLI **0.2.0**. Use `influmode support` for complete offline instructions. Bugs, OS/Node compatibility problems, unsupported platform workflows, feature requests and questions can be reported directly to the InfluMode team. Your existing InfluMode account is enough: you do not need a GitHub account, repository invitation or GitHub token.
46
+
47
+ An AI can handle the process from this prompt:
48
+
49
+ > Update @agency-tbd/cli to the latest public npm release using pnpm or npm, ensuring Node.js meets its engines requirement. Handle all terminal commands yourself. Read influmode guide --json and influmode support --help. Use my existing InfluMode login at https://www.influmode.com, or help me approve login in my browser without sharing credentials. Verify support info reports available:true. When I report a bug, compatibility issue, missing capability or feature request, help me describe the steps, expected/actual behavior and relevant version. Save a private support draft, remove secrets and unnecessary customer data, and show me the exact report, diagnostics and destination before sending. After I approve, submit it, verify the receipt and tell me the support reference. Keep the original draft for recovery; after a timeout check status with that same draft instead of generating another report. I do not need access to the private GitHub repository.
50
+
51
+ For terminal users and agents, save `report.json`:
52
+
53
+ ```json
54
+ {
55
+ "category": "bug",
56
+ "title": "Campaign listing fails on Windows",
57
+ "description": "Steps: sign in and list campaigns. Expected: a campaign list. Actual: the command exits with an error. Include a sanitized error message and reproduction details here."
58
+ }
59
+ ```
60
+
61
+ Categories: `bug`, `compatibility`, `feature`, `question`. Describe the unsupported workflow for a feature request; do not invent reproduction steps. Titles must be 5–160 characters; descriptions 20–12,000 characters.
62
+
63
+ ```sh
64
+ # Offline; saves a new private file and shows the full preview. Never overwrites.
65
+ influmode support draft --input @report.json --output support-draft.json
66
+ influmode support preview --input @support-draft.json
67
+
68
+ # Existing InfluMode login; --dry-run validates without opening an issue.
69
+ influmode support info
70
+ influmode support submit --input @support-draft.json --dry-run
71
+
72
+ # Show the report and destination; obtain the user's approval first.
73
+ influmode support submit --input @support-draft.json --confirm
74
+ influmode support status --input @support-draft.json
75
+ influmode support list
76
+ ```
77
+
78
+ The draft adds only CLI version, Node.js version, OS identifier and CPU architecture. The server associates the report with your authenticated account and tenant IDs. **No files, logs, environment variables, tokens or cookies are collected automatically.** Remove credentials and unnecessary personal/customer data from the text yourself. Recognizable credentials and extra diagnostics are rejected; this check cannot detect every possible secret. The draft contains your report text: keep it private, and delete it when you no longer need its recovery key. POSIX files are created with mode 0600; on Windows, use a directory private to your OS account.
79
+
80
+ Submission returns `receipt.reference`, `receipt.submitted`, `receipt.state` and recovery instructions. Only `submitted:true` confirms that GitHub accepted an issue. Unconfirmed or failed submission returns `ok:false` and a nonzero exit status while preserving the receipt. `pending` is uncertain delivery; keep the original draft and check status. `failed` means screenshot storage failed before contacting GitHub or GitHub definitively rejected the send; the receipt explains what to do. A closed issue indicates closure, not necessarily that a fix was released or a request accepted. Status exposes only your own reports and their open/closed state; repository URLs, source code, other users' reports and staff comments stay private. `support list` shows your 20 most recent receipts; use `support status <reference>` for current status.
81
+
82
+ After any interrupted send, use `support status --input @support-draft.json`. A missing receipt means no reservation exists yet; retry only the **exact same saved draft**, after correcting any reported login/configuration/input issue. Concurrent or repeated submissions of the same draft create at most one issue; changed content under the same request ID is a conflict. Never create a new draft to retry an uncertain send. If delivery remains pending, give the support reference to your InfluMode administrator for reconciliation. The CLI never automatically repeats an issue creation.
83
+
84
+ `help support <operation>` exposes live API schemas; the generic API form is `call support <operation>`. For maintainers, the [support runbook](../../docs/reference/cli-support.md) covers provisioning, delivery recovery and verification.
85
+
43
86
  ## Discover before executing
44
87
 
45
88
  | Command | What it establishes | What it does not establish |
@@ -130,8 +173,24 @@ For repository development, install dependencies with `pnpm install --frozen-loc
130
173
 
131
174
  Before publishing, run `pnpm --filter @agency-tbd/cli release:check` on a supported Node.js release. It runs type checks, CLI tests, catalog validation and an isolated npm installation of the actual packed archive. Package contents are limited to compiled JavaScript, the README and package metadata; repository source, tests, source maps and local configuration are excluded. `pnpm pack` replaces workspace catalog references with installable dependency versions.
132
175
 
133
- Publish a reviewed release from a clean, merged checkout with `pnpm --filter @agency-tbd/cli release:publish`, using an npm account authorized to publish under the `@agency-tbd` scope. The first publication requires that scope to exist and the account to complete npm's authentication/2FA requirements. No application deployment is required to distribute the existing CLI. For each subsequent release, increment `apps/cli/package.json`'s version before review and publication; the CLI version output and API compatibility header read that same version. Do not reuse a published version. Do not claim installation from the registry works until the release is visible and verified there.
176
+ Publish a reviewed release from a clean, merged checkout with `pnpm --filter @agency-tbd/cli release:publish`, using an npm account authorized to publish under the `@agency-tbd` scope. The first publication requires that scope to exist and the account to complete npm's authentication/2FA requirements. CLI-only releases need no application deployment. New server-backed features such as support require the matching backend migration, configuration and deployment before publishing the CLI that advertises them. For each subsequent release, increment `apps/cli/package.json`'s version before review and publication; the CLI version output and API compatibility header read that same version. Do not reuse a published version. Do not claim installation from the registry works until the release is visible and verified there.
134
177
 
135
178
  This evergreen reference owns `apps/cli/src/**` command behavior. Run `pnpm --filter @agency-tbd/cli test`, `check-types`, and `catalog:check` after changes. The subprocess integration tests exercise discovery, help without side effects, account context, forbidden-operation recovery, writes, pagination, polling and partial batch failure against a real local HTTP transport.
136
179
 
137
180
  The design follows live discovery and agent guidance patterns from [Google Workspace CLI](https://github.com/googleworkspace/cli), and help/output conventions from the [Command Line Interface Guidelines](https://clig.dev/). The live Influmode schema is the authority for current fields and operations.
181
+
182
+ ### Screenshot attachments (CLI 0.3.0)
183
+
184
+ Requires a server with support attachments deployed. Create a draft with the screenshots you want to share:
185
+
186
+ ```sh
187
+ influmode support draft --input @report.json --attach erro.png --attach esperado.jpg --output support-draft.json
188
+ influmode support preview --input @support-draft.json
189
+ # After reviewing the report, screenshots and destination:
190
+ influmode support submit --input @support-draft.json --confirm
191
+ influmode support status --input @support-draft.json
192
+ ```
193
+
194
+ Up to five PNG, JPEG or WebP files are accepted: 4 MiB per file, 10 MiB total. Draft and preview are offline. The private draft contains a snapshot of each image, so moving or editing the source screenshot cannot change the approved submission. Preview shows the filename, detected type, byte count and SHA-256 hash without printing image contents. Review the selected images for private information before sharing; image text is not automatically redacted. Only submit uploads the selected screenshots.
195
+
196
+ The private GitHub issue links to authenticated InfluMode file access. Investigators need an authorized session in the reporting tenant; GitHub access alone is insufficient. Storage objects are private, and signed storage URLs are never placed in the issue. All screenshots must be stored before the issue is sent. Keep the same draft after a timeout and check status before retrying; an uncertain submission must never be recreated with a new request ID.
package/dist/agent.js CHANGED
@@ -23,6 +23,22 @@ export const agentGuide = {
23
23
  retry: "Never automatically retry a mutation after an ambiguous failure; inspect saved state first.",
24
24
  coverage: "API access does not reproduce UI preparation or prove every workflow is executable.",
25
25
  },
26
+ support: {
27
+ purpose: "Report bugs, compatibility problems, missing platform features or questions to the InfluMode team without GitHub access.",
28
+ help: "influmode support --help",
29
+ prepare: "influmode support draft --input @report.json --output support-draft.json",
30
+ input: {
31
+ category: "bug|compatibility|feature|question",
32
+ title: "Short summary",
33
+ description: "Reproduction, expected/actual behavior or requested feature; at least 20 characters",
34
+ },
35
+ approval: "Show the exact saved report, diagnostics and destination to the user. Remove secrets and private customer data. Obtain approval before submitting.",
36
+ send: "influmode support submit --input @support-draft.json --confirm",
37
+ recover: "influmode support status --input @support-draft.json",
38
+ list: "influmode support list",
39
+ delivery: "Check receipt.submitted and receipt.state. Pending is uncertain delivery; reuse the saved draft to reconcile. Never generate a new requestId after an uncertain send.",
40
+ privacy: "Only the approved report, CLI/Node/OS/architecture and authenticated account/tenant IDs are sent. No automatic logs, environment, files or credentials. Status exposes only your own report and open/closed state, never private staff comments or repository access.",
41
+ },
26
42
  recordUpdates: {
27
43
  resources: ["leads", "deals", "campaigns"],
28
44
  state: ["updates.getState", "updates.updateState"],
@@ -90,7 +106,7 @@ function summary(resource, operation) {
90
106
  const name = operation.path.join(".");
91
107
  return {
92
108
  name,
93
- command: `influmode ${resource === "auth" ? "call auth" : resource} ${name}`,
109
+ command: `influmode ${["auth", "support"].includes(resource) ? `call ${resource}` : resource} ${name}`,
94
110
  help: `influmode help ${resource} ${name}`,
95
111
  method: operation.method,
96
112
  effect: operation.method === "GET" ? "declared-read" : "potential-write",
package/dist/args.js CHANGED
@@ -9,6 +9,8 @@ export function parse(argv) {
9
9
  help: { type: "boolean", short: "h" },
10
10
  version: { type: "boolean" },
11
11
  json: { type: "boolean" },
12
+ confirm: { type: "boolean" },
13
+ attach: { type: "string", multiple: true },
12
14
  type: { type: "string" },
13
15
  "sponsor-tenant": { type: "string" },
14
16
  url: { type: "string" },
package/dist/catalog.js CHANGED
@@ -47,6 +47,7 @@ export const resources = [
47
47
  "settings",
48
48
  "shell",
49
49
  "sponsorships",
50
+ "support",
50
51
  "team",
51
52
  "tracking-links",
52
53
  "users/profile",
package/dist/commands.js CHANGED
@@ -7,6 +7,7 @@ import { download, upload } from "./files.js";
7
7
  import { readJson } from "./input.js";
8
8
  import { saveOutput } from "./output.js";
9
9
  import { describe } from "./schema.js";
10
+ import { supportCommand } from "./support.js";
10
11
  import { http } from "./transport.js";
11
12
  export async function executeCommand(connection, { values, positionals }) {
12
13
  const [command, subcommand, ...rest] = positionals;
@@ -35,6 +36,8 @@ export async function executeCommand(connection, { values, positionals }) {
35
36
  return logout(connection);
36
37
  throw new CliError("USAGE", "Use auth login, status, or logout", 2);
37
38
  }
39
+ if (command === "support")
40
+ return supportCommand(connection, { values, positionals });
38
41
  if (command === "batch")
39
42
  return batch(connection, await readJson(values.input), values["dry-run"] ?? false);
40
43
  if (command === "files")
package/dist/help.js CHANGED
@@ -1,4 +1,13 @@
1
1
  export const commandHelp = {
2
+ support: `influmode support draft --input @report.json --output support-draft.json [--attach screenshot.png]
3
+ influmode support preview --input @support-draft.json
4
+ influmode support info
5
+ influmode support submit --input @support-draft.json --confirm [--dry-run]
6
+ influmode support status <reference>
7
+ influmode support status --input @support-draft.json
8
+ influmode support list
9
+ Report JSON: {"category":"bug|compatibility|feature|question","title":"Short summary","description":"Steps, expected and actual behavior; at least 20 characters"}.
10
+ Draft/preview are offline. Draft adds only CLI/Node/OS/architecture diagnostics and saves a private file. Review the exact report and destination, remove secrets/private customer data, obtain approval, then submit. Login uses your InfluMode account; no GitHub account or repository access is needed. Keep the same draft/requestId for recovery: an uncertain send must never be repeated with a new draft. Status and list show only your reports; no private repository links, code or staff comments are exposed. Repeat --attach for up to 5 PNG/JPEG/WebP screenshots (4 MiB each, 10 MiB total). Draft snapshots the exact bytes offline; preview shows names, sizes and SHA-256 hashes, never image bytes. Only confirmed submit uploads them. Screenshots stay private; the team must sign in to the reporting tenant to open them. No other files, logs or environment variables are automatically attached. Run help support <operation> for live API schemas; use call support <operation> for generic API access.`,
2
11
  auth: "influmode auth login --url <HTTPS_ORIGIN> [--no-browser]\ninflumode auth status\ninflumode auth logout\nBrowser approval is required for login. Status confirms identity, not effective operation permissions. Logout revokes the session.\nFor the auth API group, inspect help auth <operation> and execute with call auth <operation>.",
3
12
  resources: "influmode resources [--search text]\nOffline API group and HTTP route inventory. HTTP routes can require browser, provider or internal-service credentials; listing is not execution permission.",
4
13
  operations: "influmode operations <resource> [--search text]\nRead live operation names, descriptions and command syntax without running their handlers. Requires login. Follow with help <resource> <operation>.",
@@ -15,6 +24,7 @@ export const help = `Influmode CLI — operate Influmode from an AI agent or she
15
24
 
16
25
  influmode auth login [--no-browser]
17
26
  influmode auth status | logout
27
+ influmode support Report bugs, compatibility gaps or feature requests
18
28
  influmode resources [--search text]
19
29
  influmode guide [--json] Agent instructions, limits and recovery
20
30
  influmode capabilities [resource] Account context; permissions remain handler-enforced
@@ -91,6 +101,10 @@ transport to bypass it. Fix invalid input from error.details and live help. For
91
101
  inspect saved state before doing anything else. A timeout does not prove the write failed.
92
102
  HTTP route inventories include internal endpoints, callbacks and webhooks; they are not a list
93
103
  of supported generic operations. Browser consent and UI preparation can still be necessary.
104
+ For bugs, compatibility gaps, missing platform features or questions, run support --help.
105
+ Prepare a private report with support draft, show its exact text and destination, obtain approval,
106
+ then support submit --confirm. Keep the original draft; after a timeout check support status
107
+ with that same --input file. Users need only InfluMode login, never GitHub access.
94
108
  Run guide --json for machine-readable limits, input conventions and recovery instructions.
95
109
  Check both the exit status and ok. Business declines and failed batches can return ok:false
96
110
  on stdout with partial results; thrown errors return JSON diagnostics on stderr.
package/dist/main.js CHANGED
@@ -8,39 +8,56 @@ import { baseUrl, loadToken, selectedOrigin } from "./config.js";
8
8
  import { CliError, failure, isFailedResult } from "./errors.js";
9
9
  import { commandHelp, help, skill } from "./help.js";
10
10
  import { json } from "./input.js";
11
+ import { offlineSupport } from "./support.js";
11
12
  import { cliVersion } from "./version.js";
12
- async function dispatch() {
13
- const parsed = parse(process.argv.slice(2));
13
+ async function offlineCommand(parsed) {
14
14
  const { values, positionals } = parsed;
15
15
  const [command, subcommand] = positionals;
16
16
  if (values.version)
17
- return { version: cliVersion };
18
- const topic = command === "help" ? subcommand : values.help ? command : undefined;
17
+ return { handled: true, result: { version: cliVersion } };
18
+ const topic = command === "help"
19
+ ? subcommand
20
+ : values.help || (command === "support" && !subcommand)
21
+ ? command
22
+ : undefined;
19
23
  if (topic && commandHelp[topic] && (command !== "help" || positionals.length === 2)) {
20
24
  if (values.json)
21
- return { command: topic, usage: commandHelp[topic] };
25
+ return { handled: true, result: { command: topic, usage: commandHelp[topic] } };
22
26
  process.stdout.write(`${commandHelp[topic]}\n`);
23
- return undefined;
27
+ return { handled: true };
24
28
  }
25
29
  if (command === "skill" || command === "guide") {
26
30
  if (values.json)
27
- return agentGuide;
31
+ return { handled: true, result: agentGuide };
28
32
  process.stdout.write(skill);
29
- return undefined;
33
+ return { handled: true };
30
34
  }
31
35
  if (!command ||
32
36
  (values.help && !subcommand && !resources.some((resource) => resource === command)) ||
33
37
  (command === "help" && !subcommand)) {
34
38
  if (values.json)
35
- return { usage: help, agent: agentGuide };
39
+ return { handled: true, result: { usage: help, agent: agentGuide } };
36
40
  process.stdout.write(help);
37
- return undefined;
41
+ return { handled: true };
38
42
  }
39
43
  if (command === "resources")
40
44
  return {
41
- resources: resources.filter((item) => !values.search || item.includes(values.search)),
42
- httpRoutes: httpRoutes.filter((item) => !values.search || item.includes(values.search)),
45
+ handled: true,
46
+ result: {
47
+ resources: resources.filter((item) => !values.search || item.includes(values.search)),
48
+ httpRoutes: httpRoutes.filter((item) => !values.search || item.includes(values.search)),
49
+ },
43
50
  };
51
+ if (command === "support" && ["draft", "preview"].includes(subcommand ?? ""))
52
+ return { handled: true, result: await offlineSupport(parsed) };
53
+ return { handled: false };
54
+ }
55
+ async function dispatch() {
56
+ const parsed = parse(process.argv.slice(2));
57
+ const offline = await offlineCommand(parsed);
58
+ if (offline.handled)
59
+ return offline.result;
60
+ const { values, positionals: [command, subcommand], } = parsed;
44
61
  const configuredUrl = values.url ?? process.env["INFLUMODE_URL"] ?? (await selectedOrigin());
45
62
  if (!configuredUrl)
46
63
  throw new CliError("SERVER_REQUIRED", "Set INFLUMODE_URL or pass --url with your tenant application origin", 2);
@@ -0,0 +1,101 @@
1
+ import { createHash } from "node:crypto";
2
+ import { open } from "node:fs/promises";
3
+ import { basename } from "node:path";
4
+ import { CliError } from "./errors.js";
5
+ const MAX_FILE = 4 * 1024 * 1024;
6
+ const MAX_TOTAL = 10 * 1024 * 1024;
7
+ function invalid() {
8
+ throw new CliError("SUPPORT_ATTACHMENTS", "Attach up to 5 PNG, JPEG or WebP screenshots, at most 4 MiB each and 10 MiB total. Recreate the draft if its attachment bytes changed.", 2);
9
+ }
10
+ function imageType(bytes) {
11
+ if (bytes.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])))
12
+ return "image/png";
13
+ if (bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255)
14
+ return "image/jpeg";
15
+ if (bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP")
16
+ return "image/webp";
17
+ return invalid();
18
+ }
19
+ export function validateAttachments(value) {
20
+ if (!Array.isArray(value) || value.length > 5)
21
+ return invalid();
22
+ let total = 0;
23
+ return value.map((raw) => {
24
+ if (!raw || typeof raw !== "object")
25
+ return invalid();
26
+ const item = raw;
27
+ if (typeof item.name !== "string" ||
28
+ !/^[^/\\\p{Cc}]{1,160}$/u.test(item.name) ||
29
+ typeof item.data !== "string" ||
30
+ item.data.length > Math.ceil(MAX_FILE / 3) * 4 ||
31
+ typeof item.sha256 !== "string")
32
+ return invalid();
33
+ const bytes = Buffer.from(item.data, "base64");
34
+ total += bytes.length;
35
+ if (!bytes.length ||
36
+ bytes.length > MAX_FILE ||
37
+ total > MAX_TOTAL ||
38
+ bytes.length !== item.size ||
39
+ bytes.toString("base64") !== item.data ||
40
+ imageType(bytes) !== item.type ||
41
+ createHash("sha256").update(bytes).digest("hex") !== item.sha256)
42
+ return invalid();
43
+ return {
44
+ name: item.name,
45
+ type: item.type,
46
+ size: item.size,
47
+ sha256: item.sha256,
48
+ data: item.data,
49
+ };
50
+ });
51
+ }
52
+ async function readScreenshot(path, remaining) {
53
+ const handle = await open(path, "r");
54
+ try {
55
+ const stat = await handle.stat();
56
+ if (!stat.isFile() || !stat.size || stat.size > MAX_FILE || stat.size > remaining)
57
+ return invalid();
58
+ // Bound reads even if the source grows after stat.
59
+ const buffer = Buffer.alloc(Math.min(MAX_FILE, remaining) + 1);
60
+ let length = 0;
61
+ while (length < buffer.length) {
62
+ const { bytesRead } = await handle.read(buffer, length, buffer.length - length, null);
63
+ if (!bytesRead)
64
+ break;
65
+ length += bytesRead;
66
+ }
67
+ if (length > MAX_FILE || length > remaining)
68
+ return invalid();
69
+ return buffer.subarray(0, length);
70
+ }
71
+ finally {
72
+ await handle.close();
73
+ }
74
+ }
75
+ export async function snapshotAttachments(paths) {
76
+ if (paths.length > 5)
77
+ return invalid();
78
+ const attachments = [];
79
+ let total = 0;
80
+ for (const path of paths) {
81
+ const bytes = await readScreenshot(path, MAX_TOTAL - total);
82
+ total += bytes.length;
83
+ attachments.push({
84
+ name: basename(path),
85
+ type: imageType(bytes),
86
+ size: bytes.length,
87
+ sha256: createHash("sha256").update(bytes).digest("hex"),
88
+ data: bytes.toString("base64"),
89
+ });
90
+ }
91
+ return validateAttachments(attachments);
92
+ }
93
+ export function attachmentPreview(value) {
94
+ if (!value || typeof value !== "object" || !("attachments" in value))
95
+ return value;
96
+ return {
97
+ ...value,
98
+ attachments: validateAttachments(value.attachments).map(({ data: _data, ...metadata }) => metadata),
99
+ };
100
+ }
101
+ //# sourceMappingURL=support-attachments.js.map
@@ -0,0 +1,132 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { ORPCError } from "@orpc/client";
3
+ import { CliError } from "./errors.js";
4
+ import { readJson } from "./input.js";
5
+ import { saveOutput } from "./output.js";
6
+ import { snapshotAttachments, validateAttachments, attachmentPreview, } from "./support-attachments.js";
7
+ import { rpc } from "./transport.js";
8
+ import { cliVersion } from "./version.js";
9
+ const categories = new Set(["bug", "compatibility", "feature", "question"]);
10
+ const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
11
+ function object(value) {
12
+ return !!value && typeof value === "object" && !Array.isArray(value);
13
+ }
14
+ function report(value) {
15
+ if (!object(value) ||
16
+ typeof value["category"] !== "string" ||
17
+ !categories.has(value["category"]) ||
18
+ typeof value["title"] !== "string" ||
19
+ value["title"].trim().length < 5 ||
20
+ value["title"].trim().length > 160 ||
21
+ /[\r\n]/.test(value["title"]) ||
22
+ typeof value["description"] !== "string" ||
23
+ value["description"].trim().length < 20 ||
24
+ value["description"].trim().length > 12000)
25
+ throw new CliError("SUPPORT_INPUT", 'Use --input with {"category":"bug|compatibility|feature|question","title":"Short summary","description":"Steps, expected and actual behavior; at least 20 characters"}. Remove passwords, tokens, cookies and private customer data.', 2);
26
+ return {
27
+ category: value["category"],
28
+ title: value["title"].trim(),
29
+ description: value["description"].trim(),
30
+ };
31
+ }
32
+ function draft(value) {
33
+ const text = report(value);
34
+ if (!object(value) ||
35
+ typeof value["requestId"] !== "string" ||
36
+ !uuid.test(value["requestId"]) ||
37
+ !object(value["diagnostics"]))
38
+ throw new CliError("SUPPORT_DRAFT_REQUIRED", "First run influmode support draft --input @report.json --output support-draft.json. Reuse that saved draft for submission and recovery.", 2);
39
+ return {
40
+ requestId: value["requestId"],
41
+ ...text,
42
+ diagnostics: value["diagnostics"],
43
+ ...(value["attachments"] === undefined
44
+ ? {}
45
+ : { attachments: validateAttachments(value["attachments"]) }),
46
+ };
47
+ }
48
+ function preview(value) {
49
+ return {
50
+ destination: "InfluMode team, private GitHub issue tracker",
51
+ report: attachmentPreview(value),
52
+ sent: false,
53
+ privacy: "Only this report, the listed runtime diagnostics and your authenticated account/tenant IDs are sent. Only explicitly attached screenshots are uploaded. No logs, other files, environment variables or credentials are collected. Review text for private data before sharing.",
54
+ };
55
+ }
56
+ /** Draft and preview are offline and never need login or network access. */
57
+ export async function offlineSupport({ values, positionals }) {
58
+ const action = positionals[1];
59
+ if (values.attach?.length && action !== "draft")
60
+ throw new CliError("SUPPORT_ATTACHMENTS", "Use --attach only with support draft; submit the saved draft after reviewing it.", 2);
61
+ if (action === "preview")
62
+ return preview(draft(await readJson(values.input)));
63
+ if (!values.output)
64
+ throw new CliError("SUPPORT_OUTPUT_REQUIRED", "Save a reusable draft: influmode support draft --input @report.json --output support-draft.json", 2);
65
+ const input = await readJson(values.input);
66
+ const value = {
67
+ requestId: randomUUID(),
68
+ ...report(input),
69
+ ...(values.attach?.length ? { attachments: await snapshotAttachments(values.attach) } : {}),
70
+ diagnostics: {
71
+ cliVersion,
72
+ nodeVersion: process.version,
73
+ platform: process.platform,
74
+ arch: process.arch,
75
+ },
76
+ };
77
+ const saved = await saveOutput(values.output, () => Promise.resolve(value));
78
+ return {
79
+ ...saved,
80
+ ...preview(value),
81
+ next: "Show this exact report and destination to the user. After approval, run influmode support submit with this saved file as --input and --confirm. Keep this same file to recover with support status --input.",
82
+ };
83
+ }
84
+ export async function supportCommand(connection, { values, positionals }) {
85
+ const [, action, reference] = positionals;
86
+ if (values.attach?.length)
87
+ throw new CliError("SUPPORT_ATTACHMENTS", "Use --attach with support draft first; attachments cannot be added during submission.", 2);
88
+ if (action === "info")
89
+ return rpc(connection, "support", ["info"], {}, "GET");
90
+ if (action === "list")
91
+ return rpc(connection, "support", ["list"], {}, "GET");
92
+ if (action === "status") {
93
+ const input = reference
94
+ ? { reference }
95
+ : { requestId: draft(await readJson(values.input)).requestId };
96
+ return rpc(connection, "support", ["status"], input, "GET");
97
+ }
98
+ if (action !== "submit")
99
+ throw new CliError("USAGE", "Run influmode support --help for drafting, submitting and checking support requests.", 2);
100
+ const input = draft(await readJson(values.input));
101
+ if (values["dry-run"]) {
102
+ const { attachments: _attachments, ...textInput } = input;
103
+ return {
104
+ ...preview(input),
105
+ attachmentValidation: "Screenshot bytes validated locally; not sent. Storage availability and permissions are checked only during confirmed submission.",
106
+ validation: await rpc(connection, "support", ["__cli", "validate"], {
107
+ path: ["submit"],
108
+ input: textInput,
109
+ }),
110
+ };
111
+ }
112
+ if (!values.confirm)
113
+ throw new CliError("SUPPORT_CONFIRM_REQUIRED", "Show the saved draft and destination to the user, obtain approval, then submit with --confirm. Preview with influmode support preview --input @support-draft.json.", 2);
114
+ try {
115
+ const receipt = await rpc(connection, "support", ["submit"], input);
116
+ return {
117
+ ok: object(receipt) && receipt["submitted"] === true,
118
+ receipt,
119
+ next: "Check receipt.submitted and receipt.state. Pending means delivery is uncertain, not failed. Keep your draft; use support status --input @support-draft.json to reconcile.",
120
+ };
121
+ }
122
+ catch (error) {
123
+ if (error instanceof ORPCError &&
124
+ ["UNAUTHORIZED", "FORBIDDEN", "BAD_REQUEST", "CONFLICT"].includes(String(error.code)))
125
+ throw error;
126
+ throw new CliError("SUPPORT_SUBMISSION_UNCONFIRMED", "Submission was not confirmed. Run influmode support status with the same --input @draft file before doing anything else. Do not create a new draft or assume it failed.", 1, {
127
+ requestId: input.requestId,
128
+ cause: error instanceof Error ? error.message : "Request failed",
129
+ });
130
+ }
131
+ }
132
+ //# sourceMappingURL=support.js.map
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@agency-tbd/cli",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Operate InfluMode from your terminal or AI assistant using your own account and permissions",
5
+ "homepage": "https://www.influmode.com",
5
6
  "bin": {
6
7
  "influmode": "dist/main.js"
7
8
  },