@agency-tbd/cli 0.2.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
@@ -77,7 +77,7 @@ influmode support list
77
77
 
78
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
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 GitHub definitively rejected the send, and 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.
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
81
 
82
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
83
 
@@ -178,3 +178,19 @@ Publish a reviewed release from a clean, merged checkout with `pnpm --filter @ag
178
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.
179
179
 
180
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/args.js CHANGED
@@ -10,6 +10,7 @@ export function parse(argv) {
10
10
  version: { type: "boolean" },
11
11
  json: { type: "boolean" },
12
12
  confirm: { type: "boolean" },
13
+ attach: { type: "string", multiple: true },
13
14
  type: { type: "string" },
14
15
  "sponsor-tenant": { type: "string" },
15
16
  url: { type: "string" },
package/dist/help.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export const commandHelp = {
2
- support: `influmode support draft --input @report.json --output support-draft.json
2
+ support: `influmode support draft --input @report.json --output support-draft.json [--attach screenshot.png]
3
3
  influmode support preview --input @support-draft.json
4
4
  influmode support info
5
5
  influmode support submit --input @support-draft.json --confirm [--dry-run]
@@ -7,7 +7,7 @@ influmode support status <reference>
7
7
  influmode support status --input @support-draft.json
8
8
  influmode support list
9
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. No files, logs or environment variables are automatically attached. Run help support <operation> for live API schemas; use call support <operation> for generic API access.`,
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.`,
11
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>.",
12
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.",
13
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>.",
@@ -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
package/dist/support.js CHANGED
@@ -3,6 +3,7 @@ import { ORPCError } from "@orpc/client";
3
3
  import { CliError } from "./errors.js";
4
4
  import { readJson } from "./input.js";
5
5
  import { saveOutput } from "./output.js";
6
+ import { snapshotAttachments, validateAttachments, attachmentPreview, } from "./support-attachments.js";
6
7
  import { rpc } from "./transport.js";
7
8
  import { cliVersion } from "./version.js";
8
9
  const categories = new Set(["bug", "compatibility", "feature", "question"]);
@@ -35,19 +36,28 @@ function draft(value) {
35
36
  !uuid.test(value["requestId"]) ||
36
37
  !object(value["diagnostics"]))
37
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);
38
- return { requestId: value["requestId"], ...text, diagnostics: value["diagnostics"] };
39
+ return {
40
+ requestId: value["requestId"],
41
+ ...text,
42
+ diagnostics: value["diagnostics"],
43
+ ...(value["attachments"] === undefined
44
+ ? {}
45
+ : { attachments: validateAttachments(value["attachments"]) }),
46
+ };
39
47
  }
40
48
  function preview(value) {
41
49
  return {
42
50
  destination: "InfluMode team, private GitHub issue tracker",
43
- report: value,
51
+ report: attachmentPreview(value),
44
52
  sent: false,
45
- privacy: "Only this report, the listed runtime diagnostics and your authenticated account/tenant IDs are sent. No logs, files, environment variables or credentials are collected. Review text for private data before sharing.",
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.",
46
54
  };
47
55
  }
48
56
  /** Draft and preview are offline and never need login or network access. */
49
57
  export async function offlineSupport({ values, positionals }) {
50
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);
51
61
  if (action === "preview")
52
62
  return preview(draft(await readJson(values.input)));
53
63
  if (!values.output)
@@ -56,6 +66,7 @@ export async function offlineSupport({ values, positionals }) {
56
66
  const value = {
57
67
  requestId: randomUUID(),
58
68
  ...report(input),
69
+ ...(values.attach?.length ? { attachments: await snapshotAttachments(values.attach) } : {}),
59
70
  diagnostics: {
60
71
  cliVersion,
61
72
  nodeVersion: process.version,
@@ -72,6 +83,8 @@ export async function offlineSupport({ values, positionals }) {
72
83
  }
73
84
  export async function supportCommand(connection, { values, positionals }) {
74
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);
75
88
  if (action === "info")
76
89
  return rpc(connection, "support", ["info"], {}, "GET");
77
90
  if (action === "list")
@@ -85,14 +98,17 @@ export async function supportCommand(connection, { values, positionals }) {
85
98
  if (action !== "submit")
86
99
  throw new CliError("USAGE", "Run influmode support --help for drafting, submitting and checking support requests.", 2);
87
100
  const input = draft(await readJson(values.input));
88
- if (values["dry-run"])
101
+ if (values["dry-run"]) {
102
+ const { attachments: _attachments, ...textInput } = input;
89
103
  return {
90
104
  ...preview(input),
105
+ attachmentValidation: "Screenshot bytes validated locally; not sent. Storage availability and permissions are checked only during confirmed submission.",
91
106
  validation: await rpc(connection, "support", ["__cli", "validate"], {
92
107
  path: ["submit"],
93
- input,
108
+ input: textInput,
94
109
  }),
95
110
  };
111
+ }
96
112
  if (!values.confirm)
97
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);
98
114
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agency-tbd/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Operate InfluMode from your terminal or AI assistant using your own account and permissions",
5
5
  "homepage": "https://www.influmode.com",
6
6
  "bin": {