@opscompass/opscompass-cli 1.3.8 → 1.3.10

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
@@ -105,6 +105,22 @@ Here, the OpsCompass ID of the resource is 1234567. When you have the OpsCompass
105
105
  opscompass resources get --company your_company_id --id 1234567
106
106
  ```
107
107
 
108
+ ## MSSQL current entitlements
109
+
110
+ ```sh
111
+ opscompass license-manager get-mssql-current-entitlements --company your_company_slug --account your_account_or_cloud_subscription_id
112
+ opscompass license-manager get-mssql-current-entitlements --company your_company_slug --account your_account_or_cloud_subscription_id --limit 100 --offset 0
113
+ ```
114
+
115
+ This read-only command returns a **company-scoped** JSON array, not an assessment snapshot or account-scoped inventory. The required account validates membership in the company only. `--company` and `--account` use saved defaults when omitted; `--account-id` and `--accountid` override the selected account. Accounts are nonblank strings (trimmed), preserving exact cloudSubscriptionId selectors and numeric strings without integer coercion.
116
+
117
+ Each group has `quantity`, sorted source `entitlement_ids`, and `mssqlProduct`, `mssqlEdition`, `mssqlVersion`, and `mssqlMetric` objects containing `id`, `displayName`, and `slug`. Groups are identified by the four component IDs. Quantities sum stored records regardless of purchase/support dates, with no termination adjustment; groups contain no record ID, dates, or support fields.
118
+
119
+ Optional `--limit` accepts integers 1–1000 and `--offset` accepts integers 0–10000. Omitted pagination is unbounded; there is no implicit 100-row default. Pagination applies after grouping, ordered by product display name then the four component IDs. The CLI returns one API response without automatic pagination or assessment fallback. This is separate from the unchanged raw `get-mssql-entitlements` command.
120
+
121
+ Unknown `--` flags, invalid argument values, or missing company/account scope produce an error on stderr, leave stdout empty, and exit with status 1 before making an API request.
122
+ Failed current-entitlement requests also report the error on stderr, leave stdout empty, and exit with status 1.
123
+
108
124
  ## Persisted Oracle and MSSQL assessments
109
125
 
110
126
  These commands read periodically persisted licensing results, not live configuration or current-entitlement inventory. No call recalculates an assessment, looks up another account, or fetches every page automatically.
@@ -143,3 +159,40 @@ The SDK uses the same single-page contract. Oracle methods are on `client.licens
143
159
  ### Operator rollout order
144
160
 
145
161
  The MLSS source-selection feature requires staged deployment: MLSS service first, then the customer-facing API, then the SDK/CLI client. Do not release client support before the backend accepts the new query parameter.
162
+
163
+ ## AI Chat Documents host integration
164
+
165
+ The CLI pins the released npm package `@opscompass/harness-core@0.7.3`; a local harness checkout/link is no longer required. Fully restart Studio after adopting the published CLI so its main process loads the new runtime.
166
+
167
+ Harness 0.7.3 includes public/custom model catalog metadata and GPT-6.1 Terra support, preserves local model configuration across failed refreshes, and keeps Windows chat independent of the unsupported generic Bash adapter. New Artifact collection output must be root-level Markdown; historical reads and exports outside the collection remain available. These fixes arrive through the shared Harness without additional CLI adapter changes.
168
+
169
+ Only failure to find the top-level `@opscompass/harness-core` package becomes the friendly AI-chat-unavailable error. Missing transitive packages and internal harness modules retain their original loader errors, including when the importer path contains the harness package name.
170
+
171
+ The CLI supplies a trusted per-prompt run budget of **120 tool executions**, **5 identical calls**, and **10 minutes** to `createCliAiChatRuntime`; Studio inherits this through its selected CLI. These values do not alter Harness's library defaults or reset when a skill changes. Shared generic file and Bash calls count toward the same run ceiling; only tools with trusted skill ownership also consume that skill's allowance.
172
+
173
+ Trusted host code may explicitly pass `runBudget: { maxToolCalls, maxIdenticalCalls, maxDurationMs }` alongside `cliInvocation`. An explicit object completely replaces the CLI budget and is forwarded unchanged for Harness validation; omitted fields in that object use Harness's library defaults (20 executions, 5 identical calls, 10 minutes). Model output and renderer input must not supply this configuration. Both the CLI default and explicit budgets require `EXECUTION_POLICY_VERSION === 1`, and embedded invocation independently requires `supportsCliInvocation === true`; either missing capability fails before creating a conversation. No separate numeric Studio override is needed.
174
+
175
+ The CLI lockfile pins published Harness `0.7.3`, which includes public Skills `0.2.3` with shared Resources (60 calls) and Oracle Licensing (40 calls) limits. The bundle routes inventory-only requests to `resources list` and rejects oversized stdout from the shared CLI runner rather than returning clipped JSON; the bulk workflow's separate JSON runner is unchanged. It retains embedded invocation and warning-safe JSON, and bundles Sandbox `0.0.81` with unmodified upstream Forge `1.4.2`. Pi 1.2.0 retains the Undici 8.12.3 correction and uses official minimatch 11.0.3 in both its installed dependency and rebuilt CLI/RPC bundle. Installation needs no customer patch script or additional registry credentials.
176
+
177
+ The production audit gate accepts only a valid, successful report with zero production vulnerabilities; no advisory exception remains. Regression tests exercise PEM Buffer handling, malformed-signature rejection, and Sandbox certificate/TLS behavior through the actual installed dependencies.
178
+
179
+ Studio can create the local Documents facade from the runtime harness:
180
+
181
+ ```js
182
+ import { createCliAiChatRuntime } from "./lib/aiChatRuntime.js";
183
+ import { createCliAiChatDocuments } from "./lib/aiChatDocuments.js";
184
+
185
+ const harness = await createCliAiChatRuntime({ workspaceRoot, onEvent });
186
+ const documents = createCliAiChatDocuments({ harness, onChanged });
187
+ ```
188
+
189
+ The facade provides `list(directory?)`, `mkdir(path)`, `importFile(sourcePath, destinationPath)`, `preview(path)`, `exportFile(path, destinationPath)`, `delete(path)`, and `dispose()`. Import takes the native-dialog absolute source path and a Documents-root-relative destination; export takes a Documents-root-relative source and the native save-dialog absolute destination. Renderer requests contain only relative document paths, with the host consumer supplying dialog paths in main. The host consumer owns the facade lifecycle: call `documents.dispose()` when replacing the runtime; it waits for local operations but does not dispose the harness.
190
+
191
+
192
+ The AI Chat adapter exports `supportsCliInvocation` and accepts optional host-owned
193
+ `cliInvocation: { executable, args, env }`. This lets a packaged desktop host run
194
+ its selected JavaScript CLI through its embedded runtime while preserving the
195
+ CLI command identity, defaults home and cancellation. An explicit environment is
196
+ complete, not an ambient overlay. The adapter rejects older Harness versions
197
+ that cannot honor the invocation; the matching public Skills bundle must support
198
+ it too. Standalone callers can omit the option.
@@ -0,0 +1,90 @@
1
+ const DOCUMENT_ERROR_MESSAGES = {
2
+ DOCUMENTS_INVALID_PATH: "Invalid Documents path.",
3
+ DOCUMENTS_NOT_FOUND: "The requested document was not found.",
4
+ DOCUMENTS_EXISTS: "A file or folder with that name already exists.",
5
+ DOCUMENTS_DIRECTORY_NOT_EMPTY: "The folder is not empty.",
6
+ DOCUMENTS_BUSY: "Documents are in use by another operation.",
7
+ DOCUMENTS_IO_ERROR: "Documents could not be accessed.",
8
+ DOCUMENTS_UNAVAILABLE: "Documents are unavailable in this runtime.",
9
+ };
10
+
11
+ function documentsError(code) {
12
+ const error = new Error(DOCUMENT_ERROR_MESSAGES[code]);
13
+ error.name = "DocumentsError";
14
+ error.code = code;
15
+ return error;
16
+ }
17
+
18
+ function normalizeError(error) {
19
+ const code = error?.code;
20
+ return documentsError(Object.hasOwn(DOCUMENT_ERROR_MESSAGES, code) ? code : "DOCUMENTS_IO_ERROR");
21
+ }
22
+
23
+ const HARNESS_METHODS = [
24
+ "listDocuments",
25
+ "createDocumentDirectory",
26
+ "importDocument",
27
+ "readDocument",
28
+ "exportDocument",
29
+ "deleteDocument",
30
+ ];
31
+
32
+ export function createCliAiChatDocuments({ harness, onChanged } = {}) {
33
+ if (!harness || HARNESS_METHODS.some((method) => typeof harness[method] !== "function")) {
34
+ throw documentsError("DOCUMENTS_UNAVAILABLE");
35
+ }
36
+ if (onChanged !== undefined && typeof onChanged !== "function") {
37
+ throw new TypeError("onChanged must be a function.");
38
+ }
39
+
40
+ let closed = false;
41
+ let disposePromise;
42
+ const inFlight = new Set();
43
+
44
+ function invoke(method, args, changed = false) {
45
+ if (closed) return Promise.reject(documentsError("DOCUMENTS_UNAVAILABLE"));
46
+
47
+ const operation = Promise.resolve()
48
+ .then(() => harness[method](...args))
49
+ .catch((error) => {
50
+ throw normalizeError(error);
51
+ })
52
+ .then((result) => {
53
+ if (changed && !closed && onChanged) {
54
+ try {
55
+ const notification = onChanged();
56
+ if (notification && typeof notification.then === "function") {
57
+ void Promise.resolve(notification).catch(() => {});
58
+ }
59
+ } catch {
60
+ // Invalidation must not turn a completed local mutation into a failure.
61
+ }
62
+ }
63
+ return result;
64
+ });
65
+
66
+ inFlight.add(operation);
67
+ operation.then(
68
+ () => inFlight.delete(operation),
69
+ () => inFlight.delete(operation),
70
+ );
71
+ return operation;
72
+ }
73
+
74
+ return {
75
+ list: (directory) => invoke("listDocuments", [directory]),
76
+ mkdir: (path) => invoke("createDocumentDirectory", [path], true),
77
+ importFile: (sourcePath, destinationPath) =>
78
+ invoke("importDocument", [sourcePath, destinationPath], true),
79
+ preview: (path) => invoke("readDocument", [path]),
80
+ exportFile: (path, destinationPath) => invoke("exportDocument", [path, destinationPath]),
81
+ delete: (path) => invoke("deleteDocument", [path], true),
82
+ dispose() {
83
+ if (!disposePromise) {
84
+ closed = true;
85
+ disposePromise = Promise.allSettled([...inFlight]).then(() => undefined);
86
+ }
87
+ return disposePromise;
88
+ },
89
+ };
90
+ }
@@ -0,0 +1,51 @@
1
+ import { cliCommand, opscompassHome } from "../environment/current.js";
2
+
3
+ // DECISION: the selected CLI package owns this adapter so Studio uses the
4
+ // same CLI home, executable, and packaged harness runtime.
5
+ let harnessCoreLoader = () => import("@opscompass/harness-core");
6
+
7
+ export function __setHarnessCoreLoaderForTesting(loader) {
8
+ harnessCoreLoader = loader;
9
+ }
10
+
11
+ export const supportsCliInvocation = true;
12
+
13
+ // DECISION: The CLI owns the approved run ceiling; Harness library defaults stay compatible.
14
+ /**
15
+ * @param {{workspaceRoot: string, onEvent: Function, cliEntryPoint?: string,
16
+ * cliInvocation?: import('@opscompass/harness-core').CliInvocation,
17
+ * runBudget?: import('@opscompass/harness-core').RunBudgetOptions}} options
18
+ */
19
+ export async function createCliAiChatRuntime({ workspaceRoot, onEvent, cliEntryPoint = cliCommand, cliInvocation,
20
+ runBudget = { maxToolCalls: 120, maxIdenticalCalls: 5, maxDurationMs: 600_000 } }) {
21
+ let core;
22
+ try {
23
+ core = await harnessCoreLoader();
24
+ } catch (error) {
25
+ if (
26
+ error &&
27
+ error.code === "ERR_MODULE_NOT_FOUND" &&
28
+ /^Cannot find package '@opscompass\/harness-core' imported from /.test(error.message)
29
+ ) {
30
+ throw new Error("Opscompass AI chat is unavailable because the harness dependency could not be loaded.");
31
+ }
32
+ throw error;
33
+ }
34
+ if (cliInvocation && core.supportsCliInvocation !== true) {
35
+ throw new Error("Packaged AI chat requires an updated Harness with CLI invocation support.");
36
+ }
37
+ if (core.EXECUTION_POLICY_VERSION !== 1) {
38
+ throw new Error("This AI chat runtime does not support execution budgets. Install a compatible CLI/Harness release.");
39
+ }
40
+ const harnessOptions = {
41
+ workspaceRoot,
42
+ opscompassHome,
43
+ cliExecutable: cliCommand,
44
+ onEvent,
45
+ cliEntryPoint,
46
+ modelAccessSource: "customer",
47
+ ...(cliInvocation ? { cliInvocation } : {}),
48
+ runBudget,
49
+ };
50
+ return core.createOpscompassHarness(harnessOptions);
51
+ }
@@ -152,6 +152,77 @@ async function getMssqlEntitlements(args) {
152
152
  console.log(JSON.stringify(mssqlEntitlements, null, 2));
153
153
  }
154
154
 
155
+ async function getMssqlCurrentEntitlements(args) {
156
+ let companySlug = global.company;
157
+ let accountId = global.account;
158
+ let accountAlias;
159
+ const options = {};
160
+ for (let i = 0; i < args.length; i++) {
161
+ const flag = args[i].toLowerCase();
162
+ if (!["--company", "--account", "--account-id", "--accountid", "--limit", "--offset"].includes(flag)) {
163
+ if (flag.startsWith("--")) {
164
+ console.error(`ERROR: Unknown flag ${args[i]}.`);
165
+ process.exitCode = 1;
166
+ return;
167
+ }
168
+ continue;
169
+ }
170
+ if (args[i + 1] === undefined || args[i + 1].startsWith("--")) {
171
+ console.error(`ERROR: ${flag} requires a value.`);
172
+ process.exitCode = 1;
173
+ return;
174
+ }
175
+ const value = args[++i];
176
+ switch (flag) {
177
+ case "--company":
178
+ companySlug = value;
179
+ break;
180
+ case "--account":
181
+ accountId = value;
182
+ break;
183
+ case "--account-id":
184
+ case "--accountid":
185
+ accountAlias = value;
186
+ break;
187
+ default: {
188
+ const name = flag.slice(2);
189
+ const minimum = name === "limit" ? 1 : 0;
190
+ const maximum = name === "limit" ? 1000 : 10000;
191
+ const number = Number(value);
192
+ if (!/^\d+$/.test(value) || !Number.isSafeInteger(number) || number < minimum || number > maximum) {
193
+ console.error(`ERROR: ${flag} must be an integer from ${minimum} through ${maximum} (got "${value}").`);
194
+ process.exitCode = 1;
195
+ return;
196
+ }
197
+ options[name] = number;
198
+ }
199
+ }
200
+ }
201
+ const selectedAccount = String(accountAlias ?? accountId ?? "").trim();
202
+ if (!selectedAccount) {
203
+ console.error("ERROR: --account is required (or set a default account).");
204
+ process.exitCode = 1;
205
+ return;
206
+ }
207
+ if (companySlug === undefined || companySlug === null || String(companySlug).trim() === "") {
208
+ console.error("ERROR: --company is required (or set a default company).");
209
+ process.exitCode = 1;
210
+ return;
211
+ }
212
+ try {
213
+ const client = await getOpsCompassClient();
214
+ const result = await client.licenseManager.mssql.getMssqlCurrentEntitlements(
215
+ companySlug,
216
+ selectedAccount,
217
+ Object.keys(options).length ? options : undefined,
218
+ );
219
+ console.log(JSON.stringify(result, null, 2));
220
+ } catch (error) {
221
+ process.exitCode = 1;
222
+ throw error;
223
+ }
224
+ }
225
+
155
226
  async function getMssqlEntitlementComponents(args) {
156
227
  const client = await getOpsCompassClient();
157
228
  const entitlementComponents =
@@ -612,6 +683,15 @@ async function updateMssqlConfigurations(args) {
612
683
  }
613
684
 
614
685
  async function printMssqlHelp() {
686
+ console.log("get-mssql-current-entitlements", "Read COMPANY-SCOPED current entitlement rollups; account only validates company membership.");
687
+ console.log("Parameters:");
688
+ console.log(`--company [company_slug] (default: ${global.company})`);
689
+ console.log("--account [account-id-or-cloudSubscriptionId] (defaults to current account; required if unset)");
690
+ console.log("--account-id, --accountid [account-id-or-cloudSubscriptionId] (aliases override account)");
691
+ console.log("--limit [integer 1..1000] --offset [integer 0..10000] (optional; omitted pagination is unbounded)");
692
+ console.log("Returns a JSON array grouped by product, edition, version and metric, with summed quantity and sorted entitlement_ids.");
693
+ console.log("Stored quantities are summed regardless of purchase/support dates; no termination adjustment, dates/support fields, or assessment snapshot.");
694
+ console.log();
615
695
  printAssessmentHelp("mssql");
616
696
  console.log(
617
697
  "create-mssql-shared-credential",
@@ -863,6 +943,7 @@ export {
863
943
  createMssqlEntitlement,
864
944
  updateMssqlEntitlement,
865
945
  getMssqlEntitlements,
946
+ getMssqlCurrentEntitlements,
866
947
  getMssqlEntitlementComponents,
867
948
  listMssqlAssessments,
868
949
  getMssqlAssessment,
@@ -893,6 +974,7 @@ const licenseManagerMssqlModule = {
893
974
  createMssqlEntitlement,
894
975
  updateMssqlEntitlement,
895
976
  getMssqlEntitlements,
977
+ getMssqlCurrentEntitlements,
896
978
  getMssqlEntitlementComponents,
897
979
  listMssqlAssessments,
898
980
  getMssqlAssessment,
@@ -18,6 +18,7 @@ import {
18
18
  createMssqlEntitlement,
19
19
  updateMssqlEntitlement,
20
20
  getMssqlEntitlements,
21
+ getMssqlCurrentEntitlements,
21
22
  getMssqlEntitlementComponents,
22
23
  listMssqlAssessments,
23
24
  getMssqlAssessment,
@@ -1171,9 +1172,10 @@ async function printHelp() {
1171
1172
  }
1172
1173
 
1173
1174
  const licenseManagerModule = (action, ...args) => {
1174
- // WHY: Legacy standard-argument parsing consumes scope flags before validation.
1175
- // Assessment reads must reject malformed explicit scope rather than use defaults.
1175
+ // Read commands with explicit scope validation bypass legacy argument consumption.
1176
1176
  switch (action?.toLowerCase()) {
1177
+ case "get-mssql-current-entitlements":
1178
+ return getMssqlCurrentEntitlements(args);
1177
1179
  case "get-oracle-assessment-summary":
1178
1180
  return getOracleAssessmentSummary(args);
1179
1181
  case "get-oracle-assessment-entitlements":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opscompass/opscompass-cli",
3
- "version": "1.3.8",
3
+ "version": "1.3.10",
4
4
  "description": "Calls OpsCompass's APIs",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -28,10 +28,11 @@
28
28
  "node": "^22.19.0 || ^24.0.0"
29
29
  },
30
30
  "dependencies": {
31
- "@opscompass/opscompass-api": "^1.3.7",
31
+ "@opscompass/harness-core": "0.7.3",
32
+ "@opscompass/opscompass-api": "^1.3.9",
32
33
  "adm-zip": "^0.6.1",
33
- "axios": "^1.18.1",
34
- "better-sqlite3": "12.11.1",
34
+ "axios": "^1.20.0",
35
+ "better-sqlite3": "^13.0.1",
35
36
  "fs-extra": "^10.1.0",
36
37
  "https-proxy-agent": "^5.0.1",
37
38
  "open": "^8.2.1",
@@ -44,7 +45,6 @@
44
45
  },
45
46
  "overrides": {
46
47
  "minimatch": "^10.2.3",
47
- "brace-expansion": "^2.0.2",
48
48
  "tar-fs": "^2.1.4"
49
49
  },
50
50
  "files": [
@@ -65,5 +65,10 @@
65
65
  ],
66
66
  "bin": {
67
67
  "opscompass": "index.js"
68
+ },
69
+ "allowScripts": {
70
+ "better-sqlite3": true,
71
+ "fsevents": true,
72
+ "unrs-resolver": true
68
73
  }
69
74
  }