@scalequality/cli 0.4.44 → 0.4.45

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
@@ -145,6 +145,34 @@ Requires Node.js 18 or newer and git. Any folder works; the CLI never runs
145
145
  days are removed. Changes made by shell commands to files outside a
146
146
  repository are not tracked.
147
147
 
148
+ ## Your organization's rules in Claude Code
149
+
150
+ ```bash
151
+ npx @scalequality/cli@latest agents install
152
+ ```
153
+
154
+ On a computer that is already connected (`scalequality login`), this puts your
155
+ organization's secure development rules in Claude Code, for you only. Before
156
+ Claude Code reads a file or runs a command, it asks the rules on this computer.
157
+
158
+ - **It observes.** Nothing is blocked and nothing is asked of you. The rule
159
+ registers what it would have refused or held, so your organization can see
160
+ what the rules would do before deciding anything else.
161
+ - **What leaves this computer** is the decision alone: which agent, the kind of
162
+ action (a command, a file, a package), which rule, what the rule would have
163
+ done, the version of the rules and the time. The command, the file path and
164
+ the text never leave it.
165
+ - **Without a network** the rules already on this computer are used, and the
166
+ decisions are sent when the network is back. A package that could not be
167
+ looked up is recorded as not checked, never guessed.
168
+ - **Where it lives.** One entry in `~/.claude/settings.json` (your own hooks and
169
+ settings are kept as they are) and the files in `~/.scalequality/agents/`.
170
+ - **To remove it:** `npx @scalequality/cli@latest agents remove`. Your settings
171
+ go back to what they were.
172
+
173
+ `scalequality agents status` says whether the rule is installed and which rules
174
+ this computer holds. Available on macOS and Linux.
175
+
148
176
  ## What runs where
149
177
 
150
178
  On your machine:
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // ScaleQuality CLI. The engine of every command (login, add, service, logout,
2
+ // ScaleQuality CLI. The engine of every command (login, add, agents, service, logout,
3
3
  // and the unlisted up and connect) is built in the ScaleQuality ai-governance service
4
4
  // (src/main/workspace-connect.ts) and copied into dist/connect.cjs by `npm run sync`.
5
5
  import { createRequire } from 'node:module'
@@ -19,6 +19,11 @@ Usage:
19
19
  computer connected, also after a restart.
20
20
  scalequality add [PATH]
21
21
  Add a folder (default: the current one) for the AI Workspace to use.
22
+ scalequality agents <install|status|remove> [--api URL]
23
+ Your organization's secure development rules in the coding agents of
24
+ this computer (Claude Code for now). The agent asks the rules here
25
+ before it acts: the command and the file never leave this computer,
26
+ only the decision. While your organization observes, nothing is blocked.
22
27
  scalequality service <install|uninstall|status|logs>
23
28
  The background service: reinstall it, remove it, see whether it runs,
24
29
  read its log.
@@ -33,7 +38,7 @@ browser. Run "scalequality <command> --help" for the options of a command.`
33
38
 
34
39
  // `up` (the loop the service runs, for troubleshooting) and `connect <code>`
35
40
  // (one session by one-time code, kept for older screens) work but are not listed.
36
- const COMMANDS = new Set(['connect', 'login', 'up', 'add', 'logout', 'service'])
41
+ const COMMANDS = new Set(['connect', 'login', 'up', 'add', 'agents', 'logout', 'service'])
37
42
  const [command] = process.argv.slice(2)
38
43
 
39
44
  if (!command || command === '--help' || command === '-h' || command === 'help') {
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "sdkVersion": "0.3.312",
3
- "sha256": "069e9958e121c396d3f49fba4d92ca4969a3c209c5b97de726414f8505333bda",
4
- "sourceCommit": "a27c498aba6acbd6dc55ce2cc6911e37dada29c8"
3
+ "sha256": "9190eb26cb4849817e55cff41c7aa3985712add955f6f364ba083a43b02c1609",
4
+ "sourceCommit": "e10047878832bd557cb04d838bd842f32fce793a",
5
+ "hookSha256": "ffa9d61715aeed0f38756d199e54c0ae67f342adad59f86b944c4590c9d10159"
5
6
  }
package/dist/connect.cjs CHANGED
@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
34
34
  mod
35
35
  ));
36
36
 
37
- // ../aig-folder-scope/node_modules/ws/lib/constants.js
37
+ // node_modules/ws/lib/constants.js
38
38
  var require_constants = __commonJS({
39
- "../aig-folder-scope/node_modules/ws/lib/constants.js"(exports2, module2) {
39
+ "node_modules/ws/lib/constants.js"(exports2, module2) {
40
40
  "use strict";
41
41
  var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
42
42
  var hasBlob = typeof Blob !== "undefined";
@@ -57,9 +57,9 @@ var require_constants = __commonJS({
57
57
  }
58
58
  });
59
59
 
60
- // ../aig-folder-scope/node_modules/ws/lib/buffer-util.js
60
+ // node_modules/ws/lib/buffer-util.js
61
61
  var require_buffer_util = __commonJS({
62
- "../aig-folder-scope/node_modules/ws/lib/buffer-util.js"(exports2, module2) {
62
+ "node_modules/ws/lib/buffer-util.js"(exports2, module2) {
63
63
  "use strict";
64
64
  var { EMPTY_BUFFER } = require_constants();
65
65
  var FastBuffer = Buffer[Symbol.species];
@@ -132,9 +132,9 @@ var require_buffer_util = __commonJS({
132
132
  }
133
133
  });
134
134
 
135
- // ../aig-folder-scope/node_modules/ws/lib/limiter.js
135
+ // node_modules/ws/lib/limiter.js
136
136
  var require_limiter = __commonJS({
137
- "../aig-folder-scope/node_modules/ws/lib/limiter.js"(exports2, module2) {
137
+ "node_modules/ws/lib/limiter.js"(exports2, module2) {
138
138
  "use strict";
139
139
  var kDone = /* @__PURE__ */ Symbol("kDone");
140
140
  var kRun = /* @__PURE__ */ Symbol("kRun");
@@ -182,9 +182,9 @@ var require_limiter = __commonJS({
182
182
  }
183
183
  });
184
184
 
185
- // ../aig-folder-scope/node_modules/ws/lib/permessage-deflate.js
185
+ // node_modules/ws/lib/permessage-deflate.js
186
186
  var require_permessage_deflate = __commonJS({
187
- "../aig-folder-scope/node_modules/ws/lib/permessage-deflate.js"(exports2, module2) {
187
+ "node_modules/ws/lib/permessage-deflate.js"(exports2, module2) {
188
188
  "use strict";
189
189
  var zlib = require("zlib");
190
190
  var bufferUtil = require_buffer_util();
@@ -565,9 +565,9 @@ var require_permessage_deflate = __commonJS({
565
565
  }
566
566
  });
567
567
 
568
- // ../aig-folder-scope/node_modules/ws/lib/validation.js
568
+ // node_modules/ws/lib/validation.js
569
569
  var require_validation = __commonJS({
570
- "../aig-folder-scope/node_modules/ws/lib/validation.js"(exports2, module2) {
570
+ "node_modules/ws/lib/validation.js"(exports2, module2) {
571
571
  "use strict";
572
572
  var { isUtf8 } = require("buffer");
573
573
  var { hasBlob } = require_constants();
@@ -766,9 +766,9 @@ var require_validation = __commonJS({
766
766
  }
767
767
  });
768
768
 
769
- // ../aig-folder-scope/node_modules/ws/lib/receiver.js
769
+ // node_modules/ws/lib/receiver.js
770
770
  var require_receiver = __commonJS({
771
- "../aig-folder-scope/node_modules/ws/lib/receiver.js"(exports2, module2) {
771
+ "node_modules/ws/lib/receiver.js"(exports2, module2) {
772
772
  "use strict";
773
773
  var { Writable } = require("stream");
774
774
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -1389,9 +1389,9 @@ var require_receiver = __commonJS({
1389
1389
  }
1390
1390
  });
1391
1391
 
1392
- // ../aig-folder-scope/node_modules/ws/lib/sender.js
1392
+ // node_modules/ws/lib/sender.js
1393
1393
  var require_sender = __commonJS({
1394
- "../aig-folder-scope/node_modules/ws/lib/sender.js"(exports2, module2) {
1394
+ "node_modules/ws/lib/sender.js"(exports2, module2) {
1395
1395
  "use strict";
1396
1396
  var { Duplex } = require("stream");
1397
1397
  var { randomFillSync } = require("crypto");
@@ -1882,9 +1882,9 @@ var require_sender = __commonJS({
1882
1882
  }
1883
1883
  });
1884
1884
 
1885
- // ../aig-folder-scope/node_modules/ws/lib/event-target.js
1885
+ // node_modules/ws/lib/event-target.js
1886
1886
  var require_event_target = __commonJS({
1887
- "../aig-folder-scope/node_modules/ws/lib/event-target.js"(exports2, module2) {
1887
+ "node_modules/ws/lib/event-target.js"(exports2, module2) {
1888
1888
  "use strict";
1889
1889
  var { kForOnEventAttribute, kListener } = require_constants();
1890
1890
  var kCode = /* @__PURE__ */ Symbol("kCode");
@@ -2111,9 +2111,9 @@ var require_event_target = __commonJS({
2111
2111
  }
2112
2112
  });
2113
2113
 
2114
- // ../aig-folder-scope/node_modules/ws/lib/extension.js
2114
+ // node_modules/ws/lib/extension.js
2115
2115
  var require_extension = __commonJS({
2116
- "../aig-folder-scope/node_modules/ws/lib/extension.js"(exports2, module2) {
2116
+ "node_modules/ws/lib/extension.js"(exports2, module2) {
2117
2117
  "use strict";
2118
2118
  var { tokenChars } = require_validation();
2119
2119
  function push(dest, name, elem) {
@@ -2264,16 +2264,16 @@ var require_extension = __commonJS({
2264
2264
  }
2265
2265
  });
2266
2266
 
2267
- // ../aig-folder-scope/node_modules/ws/lib/websocket.js
2267
+ // node_modules/ws/lib/websocket.js
2268
2268
  var require_websocket = __commonJS({
2269
- "../aig-folder-scope/node_modules/ws/lib/websocket.js"(exports2, module2) {
2269
+ "node_modules/ws/lib/websocket.js"(exports2, module2) {
2270
2270
  "use strict";
2271
2271
  var EventEmitter = require("events");
2272
2272
  var https = require("https");
2273
2273
  var http = require("http");
2274
2274
  var net = require("net");
2275
2275
  var tls = require("tls");
2276
- var { randomBytes, createHash: createHash10 } = require("crypto");
2276
+ var { randomBytes, createHash: createHash11 } = require("crypto");
2277
2277
  var { Duplex, Readable } = require("stream");
2278
2278
  var { URL: URL2 } = require("url");
2279
2279
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -2941,7 +2941,7 @@ var require_websocket = __commonJS({
2941
2941
  abortHandshake(websocket, socket, "Invalid Upgrade header");
2942
2942
  return;
2943
2943
  }
2944
- const digest = createHash10("sha1").update(key + GUID).digest("base64");
2944
+ const digest = createHash11("sha1").update(key + GUID).digest("base64");
2945
2945
  if (res.headers["sec-websocket-accept"] !== digest) {
2946
2946
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
2947
2947
  return;
@@ -3160,9 +3160,9 @@ var require_websocket = __commonJS({
3160
3160
  }
3161
3161
  });
3162
3162
 
3163
- // ../aig-folder-scope/node_modules/ws/lib/stream.js
3163
+ // node_modules/ws/lib/stream.js
3164
3164
  var require_stream = __commonJS({
3165
- "../aig-folder-scope/node_modules/ws/lib/stream.js"(exports2, module2) {
3165
+ "node_modules/ws/lib/stream.js"(exports2, module2) {
3166
3166
  "use strict";
3167
3167
  var WebSocket2 = require_websocket();
3168
3168
  var { Duplex } = require("stream");
@@ -3258,9 +3258,9 @@ var require_stream = __commonJS({
3258
3258
  }
3259
3259
  });
3260
3260
 
3261
- // ../aig-folder-scope/node_modules/ws/lib/subprotocol.js
3261
+ // node_modules/ws/lib/subprotocol.js
3262
3262
  var require_subprotocol = __commonJS({
3263
- "../aig-folder-scope/node_modules/ws/lib/subprotocol.js"(exports2, module2) {
3263
+ "node_modules/ws/lib/subprotocol.js"(exports2, module2) {
3264
3264
  "use strict";
3265
3265
  var { tokenChars } = require_validation();
3266
3266
  function parse2(header) {
@@ -3303,14 +3303,14 @@ var require_subprotocol = __commonJS({
3303
3303
  }
3304
3304
  });
3305
3305
 
3306
- // ../aig-folder-scope/node_modules/ws/lib/websocket-server.js
3306
+ // node_modules/ws/lib/websocket-server.js
3307
3307
  var require_websocket_server = __commonJS({
3308
- "../aig-folder-scope/node_modules/ws/lib/websocket-server.js"(exports2, module2) {
3308
+ "node_modules/ws/lib/websocket-server.js"(exports2, module2) {
3309
3309
  "use strict";
3310
3310
  var EventEmitter = require("events");
3311
3311
  var http = require("http");
3312
3312
  var { Duplex } = require("stream");
3313
- var { createHash: createHash10 } = require("crypto");
3313
+ var { createHash: createHash11 } = require("crypto");
3314
3314
  var extension2 = require_extension();
3315
3315
  var PerMessageDeflate2 = require_permessage_deflate();
3316
3316
  var subprotocol2 = require_subprotocol();
@@ -3617,7 +3617,7 @@ var require_websocket_server = __commonJS({
3617
3617
  );
3618
3618
  }
3619
3619
  if (this._state > RUNNING) return abortHandshake(socket, 503);
3620
- const digest = createHash10("sha1").update(key + GUID).digest("base64");
3620
+ const digest = createHash11("sha1").update(key + GUID).digest("base64");
3621
3621
  const headers = [
3622
3622
  "HTTP/1.1 101 Switching Protocols",
3623
3623
  "Upgrade: websocket",
@@ -3705,9 +3705,9 @@ var require_websocket_server = __commonJS({
3705
3705
  });
3706
3706
 
3707
3707
  // src/main/workspace-connect.ts
3708
- var import_fs15 = require("fs");
3708
+ var import_fs18 = require("fs");
3709
3709
  var import_os7 = require("os");
3710
- var import_path21 = require("path");
3710
+ var import_path24 = require("path");
3711
3711
  var import_url2 = require("url");
3712
3712
 
3713
3713
  // src/application/services/workspaceSandbox/importers.ts
@@ -5134,6 +5134,14 @@ function parseProtections(raw) {
5134
5134
  toolApproval: r["tool-approval"] === "require"
5135
5135
  };
5136
5136
  }
5137
+ var PROTECTION_REASON_RULE = {
5138
+ PROTECTION_SECRET_FILE: "secret-files",
5139
+ PROTECTION_DESTRUCTIVE_COMMAND: "destructive-commands",
5140
+ PROTECTION_DEPLOY: "deploy-approval",
5141
+ PROTECTION_PROTECTED_PUSH: "protected-push",
5142
+ PROTECTION_UNKNOWN_PACKAGE: "unknown-package",
5143
+ PROTECTION_TOOL_APPROVAL: "tool-approval"
5144
+ };
5137
5145
  var SECRET_FILE_MESSAGE = "Blocked by your organization's protection: secret files are never sent to the model. Do not try to read this file another way; ask the user for the specific value your task needs, or use the example file (such as .env.example).";
5138
5146
  var ENV_TEMPLATES = /* @__PURE__ */ new Set(["example", "sample", "template", "dist"]);
5139
5147
  var SECRET_EXTENSIONS = /\.(pem|key|p12|pfx|jks|keystore)$/;
@@ -5930,6 +5938,17 @@ var HttpSessionTransport = class {
5930
5938
  if (!raw || typeof raw !== "object" || !("protections" in raw)) throw new TransportError("invalid protections response", 502, false);
5931
5939
  return protectionsWireOf(raw.protections);
5932
5940
  }
5941
+ /**
5942
+ * What a protection refused, for the API to count (no command, no path, no text). Whatever the answer, nothing is
5943
+ * thrown: a 404 from an API older than this route must never read as "the session is gone".
5944
+ */
5945
+ async reportProtectionDecisions(decisions) {
5946
+ if (!decisions.length) return;
5947
+ try {
5948
+ await this.post("/protection-decisions", { decisions }, 5e3);
5949
+ } catch {
5950
+ }
5951
+ }
5933
5952
  headers(json) {
5934
5953
  return {
5935
5954
  "x-workspace-session-secret": this.opts.secret,
@@ -7942,7 +7961,7 @@ var import_crypto5 = require("crypto");
7942
7961
  var import_fs7 = require("fs");
7943
7962
  var import_http = require("http");
7944
7963
 
7945
- // ../aig-folder-scope/node_modules/ws/wrapper.mjs
7964
+ // node_modules/ws/wrapper.mjs
7946
7965
  var import_stream = __toESM(require_stream(), 1);
7947
7966
  var import_extension = __toESM(require_extension(), 1);
7948
7967
  var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
@@ -9269,7 +9288,7 @@ var import_os5 = require("os");
9269
9288
  var import_path11 = require("path");
9270
9289
  var import_url = require("url");
9271
9290
 
9272
- // ../aig-folder-scope/node_modules/zod/v3/external.js
9291
+ // node_modules/zod/v3/external.js
9273
9292
  var external_exports = {};
9274
9293
  __export(external_exports, {
9275
9294
  BRAND: () => BRAND,
@@ -9381,7 +9400,7 @@ __export(external_exports, {
9381
9400
  void: () => voidType
9382
9401
  });
9383
9402
 
9384
- // ../aig-folder-scope/node_modules/zod/v3/helpers/util.js
9403
+ // node_modules/zod/v3/helpers/util.js
9385
9404
  var util;
9386
9405
  (function(util2) {
9387
9406
  util2.assertEqual = (_) => {
@@ -9515,7 +9534,7 @@ var getParsedType = (data) => {
9515
9534
  }
9516
9535
  };
9517
9536
 
9518
- // ../aig-folder-scope/node_modules/zod/v3/ZodError.js
9537
+ // node_modules/zod/v3/ZodError.js
9519
9538
  var ZodIssueCode = util.arrayToEnum([
9520
9539
  "invalid_type",
9521
9540
  "invalid_literal",
@@ -9633,7 +9652,7 @@ ZodError.create = (issues) => {
9633
9652
  return error;
9634
9653
  };
9635
9654
 
9636
- // ../aig-folder-scope/node_modules/zod/v3/locales/en.js
9655
+ // node_modules/zod/v3/locales/en.js
9637
9656
  var errorMap = (issue, _ctx) => {
9638
9657
  let message;
9639
9658
  switch (issue.code) {
@@ -9736,7 +9755,7 @@ var errorMap = (issue, _ctx) => {
9736
9755
  };
9737
9756
  var en_default = errorMap;
9738
9757
 
9739
- // ../aig-folder-scope/node_modules/zod/v3/errors.js
9758
+ // node_modules/zod/v3/errors.js
9740
9759
  var overrideErrorMap = en_default;
9741
9760
  function setErrorMap(map) {
9742
9761
  overrideErrorMap = map;
@@ -9745,7 +9764,7 @@ function getErrorMap() {
9745
9764
  return overrideErrorMap;
9746
9765
  }
9747
9766
 
9748
- // ../aig-folder-scope/node_modules/zod/v3/helpers/parseUtil.js
9767
+ // node_modules/zod/v3/helpers/parseUtil.js
9749
9768
  var makeIssue = (params) => {
9750
9769
  const { data, path, errorMaps, issueData } = params;
9751
9770
  const fullPath = [...path, ...issueData.path || []];
@@ -9855,14 +9874,14 @@ var isDirty = (x) => x.status === "dirty";
9855
9874
  var isValid = (x) => x.status === "valid";
9856
9875
  var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
9857
9876
 
9858
- // ../aig-folder-scope/node_modules/zod/v3/helpers/errorUtil.js
9877
+ // node_modules/zod/v3/helpers/errorUtil.js
9859
9878
  var errorUtil;
9860
9879
  (function(errorUtil2) {
9861
9880
  errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
9862
9881
  errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
9863
9882
  })(errorUtil || (errorUtil = {}));
9864
9883
 
9865
- // ../aig-folder-scope/node_modules/zod/v3/types.js
9884
+ // node_modules/zod/v3/types.js
9866
9885
  var ParseInputLazyPath = class {
9867
9886
  constructor(parent, value, path, key) {
9868
9887
  this._cachedPath = [];
@@ -15605,10 +15624,10 @@ function buildOrgMcpServers(sdk, types, catalog, host) {
15605
15624
  }
15606
15625
  async function callOrgTool(host, server, tool, args) {
15607
15626
  if (!host.transport.mcpCall) return text2("The organization MCP servers are not available in this workspace.", true);
15608
- const call = (approvalId) => host.transport.mcpCall({ server, tool, arguments: args, ...approvalId ? { approvalId } : {} });
15627
+ const call2 = (approvalId) => host.transport.mcpCall({ server, tool, arguments: args, ...approvalId ? { approvalId } : {} });
15609
15628
  let res;
15610
15629
  try {
15611
- res = await call();
15630
+ res = await call2();
15612
15631
  } catch {
15613
15632
  return text2(`${server} could not be reached through ScaleQuality. Tell the user; do not retry without being asked.`, true);
15614
15633
  }
@@ -15618,7 +15637,7 @@ async function callOrgTool(host, server, tool, args) {
15618
15637
  if (!decision) return text2(`The call to ${server} (${tool}) was stopped before the user decided. Nothing ran.`, true);
15619
15638
  if (decision.decision === "REJECT") return text2(`The user declined the call to ${server} (${tool}). Nothing ran.`);
15620
15639
  try {
15621
- res = await call(pending);
15640
+ res = await call2(pending);
15622
15641
  } catch {
15623
15642
  return text2(`${server} could not be reached through ScaleQuality after the approval. Tell the user; do not retry without being asked.`, true);
15624
15643
  }
@@ -17196,6 +17215,16 @@ ${String(item.content)}` : String(item.content);
17196
17215
  const raw = this.boot?.runtime?.protections;
17197
17216
  return raw ? parseProtections(raw) : NO_PROTECTIONS;
17198
17217
  }
17218
+ /**
17219
+ * A protection refused an action: the API counts the decision (which rule, which kind of action), never the
17220
+ * command, the path or the text. What a protection holds for a person is the approval card itself, already kept.
17221
+ */
17222
+ reportRefusal(reason, action) {
17223
+ const rule = PROTECTION_REASON_RULE[reason];
17224
+ if (!rule || rule === "tool-approval" || !this.deps.transport.reportProtectionDecisions) return;
17225
+ const policyVersion = protectionsWireOf(this.boot?.runtime?.protections)?.version ?? 0;
17226
+ void this.deps.transport.reportProtectionDecisions([{ id: (0, import_crypto9.randomUUID)(), action, rule, outcome: "BLOCKED", policyVersion, occurredAt: (/* @__PURE__ */ new Date()).toISOString() }]).catch(() => void 0);
17227
+ }
17199
17228
  /** What the protections read from the workspace: the registries, the checked out branch, the installed packages. */
17200
17229
  protectionDeps() {
17201
17230
  return {
@@ -18195,6 +18224,7 @@ ${text3}`;
18195
18224
  secretFiles: i.secretFiles,
18196
18225
  protections: () => this.protections(),
18197
18226
  protection: { deps: this.protectionDeps(), approver: this.protectionApprover() },
18227
+ onRefused: (reason, action) => this.reportRefusal(reason, action),
18198
18228
  ...this.deps.talkFirst ? { talkFirst: (name, toolUseId) => this.talkFirst(name, toolUseId) } : {},
18199
18229
  beforeTool: async () => {
18200
18230
  const t0 = Date.now();
@@ -19141,6 +19171,13 @@ function buildEngineEnv(boot, configDir, model, opts = {}) {
19141
19171
  return env;
19142
19172
  }
19143
19173
  function buildQueryOptions(o) {
19174
+ const refused = (reason, action) => {
19175
+ if (!reason || !o.onRefused) return;
19176
+ try {
19177
+ o.onRefused(reason, action);
19178
+ } catch {
19179
+ }
19180
+ };
19144
19181
  const gate = o.commandGate;
19145
19182
  const beforeWrite = async (name, input) => {
19146
19183
  const field = WRITE_TOOL_PATHS[name];
@@ -19171,6 +19208,7 @@ function buildQueryOptions(o) {
19171
19208
  const d = await decideToolUse(name, input.tool_input ?? {}, { ...o.policy, protections });
19172
19209
  const guarded = d.behavior === "allow" && (name === "Bash" && mayNeedProtection(String(d.updatedInput.command ?? ""), protections) || protections.toolApproval && !o.plan && name in WRITE_TOOL_PATHS);
19173
19210
  const gated = guarded || d.behavior === "allow" && !!gate && (name === "Bash" || !!gate.checkEdit && !o.plan && name in WRITE_TOOL_PATHS);
19211
+ if (d.behavior !== "allow") refused(d.reason, name === "Bash" ? "COMMAND" : "FILE");
19174
19212
  if (d.behavior === "allow" && !gated) await beforeWrite(name, d.updatedInput);
19175
19213
  if (gated) {
19176
19214
  return { hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "ask", permissionDecisionReason: guarded ? "This action follows the organization's protections." : "Commands and changes on this machine follow the person's permission mode." } };
@@ -19195,14 +19233,20 @@ function buildQueryOptions(o) {
19195
19233
  }
19196
19234
  const protections = o.protections?.() ?? NO_PROTECTIONS;
19197
19235
  const d = await decideToolUse(toolName, input, { ...o.policy, protections });
19198
- if (d.behavior !== "allow") return { behavior: "deny", message: d.message };
19236
+ if (d.behavior !== "allow") {
19237
+ refused(d.reason, toolName === "Bash" ? "COMMAND" : "FILE");
19238
+ return { behavior: "deny", message: d.message };
19239
+ }
19199
19240
  let protectionApproved = false;
19200
19241
  if (toolName === "Bash" && mayNeedProtection(String(d.updatedInput.command ?? ""), protections)) {
19201
19242
  const command = String(d.updatedInput.command ?? "");
19202
19243
  const signal = opts?.signal ?? o.abortController.signal;
19203
19244
  if (!o.protection) return { behavior: "deny", message: PROTECTION_MESSAGES.unavailable };
19204
19245
  const v = await protectionVerdict(command, protections, o.protection.deps);
19205
- if (v.kind === "deny") return { behavior: "deny", message: v.message };
19246
+ if (v.kind === "deny") {
19247
+ refused(v.reason, v.reason === "PROTECTION_UNKNOWN_PACKAGE" ? "PACKAGE" : "COMMAND");
19248
+ return { behavior: "deny", message: v.message };
19249
+ }
19206
19250
  if (v.kind === "ask") {
19207
19251
  const approver = o.protection.approver;
19208
19252
  const r = approver ? await approver.ask(command, {
@@ -19532,6 +19576,364 @@ async function checkForUpdate(d) {
19532
19576
 
19533
19577
  // src/main/workspace-connect.ts
19534
19578
  var import_child_process6 = require("child_process");
19579
+
19580
+ // src/application/services/workspaceSandbox/codeAgentHook.ts
19581
+ var import_crypto11 = require("crypto");
19582
+ var import_fs15 = require("fs");
19583
+ var import_path21 = require("path");
19584
+ var CLAUDE_CODE_TOOLS = ["Bash", "Read", "Write", "Edit", "MultiEdit", "NotebookEdit", "Grep", "Glob"];
19585
+ var OUTBOX_MAX_BYTES = 512 * 1024;
19586
+ var agentsDir = (sqHome2) => (0, import_path21.join)(sqHome2, "agents");
19587
+ var policyPath = (sqHome2) => (0, import_path21.join)(agentsDir(sqHome2), "policy.json");
19588
+ var outboxDir = (sqHome2) => (0, import_path21.join)(agentsDir(sqHome2), "outbox");
19589
+ var apiKey = (api) => (0, import_crypto11.createHash)("sha256").update(api).digest("hex").slice(0, 16);
19590
+ var outboxPath = (sqHome2, api) => (0, import_path21.join)(outboxDir(sqHome2), `${apiKey(api)}.jsonl`);
19591
+ var syncStampPath = (sqHome2) => (0, import_path21.join)(agentsDir(sqHome2), "sync.stamp");
19592
+ function policyOf(raw) {
19593
+ const r = raw;
19594
+ if (!r || typeof r !== "object" || typeof r.version !== "number" || !r.rules || typeof r.rules !== "object" || Array.isArray(r.rules)) return null;
19595
+ const rules = {};
19596
+ for (const [rule, option] of Object.entries(r.rules)) if (typeof option === "string") rules[rule] = option;
19597
+ return { version: r.version, mode: r.mode === "observe" ? "observe" : "off", rules };
19598
+ }
19599
+ function readPolicyFile(sqHome2) {
19600
+ const out2 = { version: 1, apis: {} };
19601
+ try {
19602
+ const raw = JSON.parse((0, import_fs15.readFileSync)(policyPath(sqHome2), "utf8"));
19603
+ for (const [api, entry] of Object.entries(raw?.apis ?? {})) {
19604
+ const policy = policyOf(entry?.policy);
19605
+ if (!policy) continue;
19606
+ out2.apis[api] = {
19607
+ policy,
19608
+ fetchedAt: typeof entry.fetchedAt === "string" ? entry.fetchedAt : "",
19609
+ refreshSeconds: typeof entry.refreshSeconds === "number" && entry.refreshSeconds >= 15 && entry.refreshSeconds <= 3600 ? entry.refreshSeconds : 60
19610
+ };
19611
+ }
19612
+ } catch {
19613
+ }
19614
+ return out2;
19615
+ }
19616
+
19617
+ // src/application/services/workspaceSandbox/codeAgentInstall.ts
19618
+ var import_fs16 = require("fs");
19619
+ var import_path22 = require("path");
19620
+ var CodeAgentInstallError = class extends Error {
19621
+ constructor(code, message) {
19622
+ super(message);
19623
+ this.code = code;
19624
+ }
19625
+ code;
19626
+ };
19627
+ var hookBundlePath = (sqHome2) => (0, import_path22.join)(agentsDir(sqHome2), "hook.cjs");
19628
+ var hookScriptPath = (sqHome2) => (0, import_path22.join)(agentsDir(sqHome2), "claude-code-hook.sh");
19629
+ var claudeSettingsPath = (env) => (0, import_path22.join)(env.env.CLAUDE_CONFIG_DIR || (0, import_path22.join)(env.home, ".claude"), "settings.json");
19630
+ var shellQuote = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
19631
+ function hookScript(node, bundle) {
19632
+ return [
19633
+ "#!/bin/sh",
19634
+ "# ScaleQuality CLI: asks the organization's rules before a coding agent acts.",
19635
+ "# It only observes: it never blocks the agent, prints nothing and always ends with 0.",
19636
+ '# Written by "scalequality agents install", removed by "scalequality agents remove". Do not edit.',
19637
+ `NODE=${shellQuote(node)}`,
19638
+ `HOOK=${shellQuote(bundle)}`,
19639
+ // The Node that installed it may be gone after an upgrade: the one on the PATH does the same.
19640
+ '[ -x "$NODE" ] || NODE=$(command -v node 2>/dev/null)',
19641
+ '[ -n "$NODE" ] && [ -f "$HOOK" ] || exit 0',
19642
+ '"$NODE" "$HOOK" "$@" >/dev/null 2>&1',
19643
+ "exit 0",
19644
+ ""
19645
+ ].join("\n");
19646
+ }
19647
+ var hookCommand = (script) => `${shellQuote(script)} claude-code`;
19648
+ var MATCHER = CLAUDE_CODE_TOOLS.join("|");
19649
+ var isOurs = (hook) => typeof hook?.command === "string" && /[\\/]\.scalequality[\\/]agents[\\/]claude-code-hook\.sh/.test(hook.command);
19650
+ var entriesOf = (settings) => {
19651
+ const list = settings.hooks?.PreToolUse;
19652
+ return Array.isArray(list) ? list.filter((e) => !!e && typeof e === "object") : [];
19653
+ };
19654
+ function hasHook(settings) {
19655
+ return entriesOf(settings).some((e) => Array.isArray(e.hooks) && e.hooks.some(isOurs));
19656
+ }
19657
+ function withoutHook(settings) {
19658
+ if (!hasHook(settings)) return settings;
19659
+ const hooks = { ...settings.hooks };
19660
+ const kept = hooks.PreToolUse.flatMap((entry) => {
19661
+ const e = entry;
19662
+ if (!e || typeof e !== "object" || !Array.isArray(e.hooks) || !e.hooks.some(isOurs)) return [entry];
19663
+ const rest = e.hooks.filter((h) => !isOurs(h));
19664
+ return rest.length ? [{ ...e, hooks: rest }] : [];
19665
+ });
19666
+ if (kept.length) hooks.PreToolUse = kept;
19667
+ else delete hooks.PreToolUse;
19668
+ const out2 = { ...settings };
19669
+ if (Object.keys(hooks).length) out2.hooks = hooks;
19670
+ else delete out2.hooks;
19671
+ return out2;
19672
+ }
19673
+ function withHook(settings, command) {
19674
+ const clean = withoutHook(settings);
19675
+ const hooks = { ...clean.hooks ?? {} };
19676
+ const before = Array.isArray(hooks.PreToolUse) ? hooks.PreToolUse : [];
19677
+ hooks.PreToolUse = [...before, { matcher: MATCHER, hooks: [{ type: "command", command, timeout: 10 }] }];
19678
+ return { ...clean, hooks };
19679
+ }
19680
+ function readSettings(file) {
19681
+ if (!(0, import_fs16.existsSync)(file)) return { settings: {}, indent: " ", exists: false };
19682
+ const text3 = (0, import_fs16.readFileSync)(file, "utf8");
19683
+ let parsed;
19684
+ try {
19685
+ parsed = text3.trim() ? JSON.parse(text3) : {};
19686
+ } catch {
19687
+ parsed = null;
19688
+ }
19689
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
19690
+ throw new CodeAgentInstallError("SETTINGS_UNREADABLE", `${file} is not valid JSON, so it was left untouched. Fix the file and run the command again.`);
19691
+ }
19692
+ return { settings: parsed, indent: /^([ \t]+)"/m.exec(text3)?.[1] ?? " ", exists: true };
19693
+ }
19694
+ var keptCopyPath = (target) => `${target}.before-scalequality`;
19695
+ function canonical(value) {
19696
+ if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
19697
+ if (value && typeof value === "object") return `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonical(value[k])}`).join(",")}}`;
19698
+ return JSON.stringify(value) ?? "null";
19699
+ }
19700
+ function writeSettings(file, settings, indent, existed, keepCopy) {
19701
+ const target = existed ? (0, import_fs16.realpathSync)(file) : file;
19702
+ (0, import_fs16.mkdirSync)((0, import_path22.dirname)(target), { recursive: true });
19703
+ let mode = 384;
19704
+ if (existed) {
19705
+ try {
19706
+ mode = (0, import_fs16.statSync)(target).mode & 511;
19707
+ } catch {
19708
+ }
19709
+ if (keepCopy) (0, import_fs16.copyFileSync)(target, keptCopyPath(target));
19710
+ }
19711
+ const tmp = `${target}.${process.pid}.tmp`;
19712
+ (0, import_fs16.writeFileSync)(tmp, `${JSON.stringify(settings, null, indent)}
19713
+ `, { mode });
19714
+ (0, import_fs16.renameSync)(tmp, target);
19715
+ }
19716
+ function claudeCodeHookInstalled(env) {
19717
+ try {
19718
+ return hasHook(readSettings(claudeSettingsPath(env)).settings) && (0, import_fs16.existsSync)(hookScriptPath(env.sqHome)) && (0, import_fs16.existsSync)(hookBundlePath(env.sqHome));
19719
+ } catch {
19720
+ return false;
19721
+ }
19722
+ }
19723
+ function writeHookFiles(env, bundleSource) {
19724
+ if (!(0, import_fs16.existsSync)(bundleSource)) throw new CodeAgentInstallError("HOOK_BUNDLE_MISSING", "This installation of @scalequality/cli is incomplete (dist/hook.cjs is missing). Run it again with npx @scalequality/cli@latest.");
19725
+ (0, import_fs16.mkdirSync)(agentsDir(env.sqHome), { recursive: true, mode: 448 });
19726
+ const bundle = hookBundlePath(env.sqHome), script = hookScriptPath(env.sqHome);
19727
+ const put = (file, content, mode) => {
19728
+ const tmp = `${file}.${process.pid}.tmp`;
19729
+ (0, import_fs16.writeFileSync)(tmp, content, { mode });
19730
+ try {
19731
+ (0, import_fs16.chmodSync)(tmp, mode);
19732
+ } catch {
19733
+ }
19734
+ (0, import_fs16.renameSync)(tmp, file);
19735
+ };
19736
+ put(bundle, (0, import_fs16.readFileSync)(bundleSource), 384);
19737
+ put(script, hookScript(env.node, bundle), 448);
19738
+ }
19739
+ function refreshHookFiles(env, bundleSource) {
19740
+ try {
19741
+ if (!claudeCodeHookInstalled(env) || !(0, import_fs16.existsSync)(bundleSource)) return false;
19742
+ const same = (0, import_fs16.readFileSync)(bundleSource).equals((0, import_fs16.readFileSync)(hookBundlePath(env.sqHome))) && (0, import_fs16.readFileSync)(hookScriptPath(env.sqHome), "utf8") === hookScript(env.node, hookBundlePath(env.sqHome));
19743
+ if (same) return false;
19744
+ writeHookFiles(env, bundleSource);
19745
+ return true;
19746
+ } catch {
19747
+ return false;
19748
+ }
19749
+ }
19750
+ function installClaudeCodeHook(env, bundleSource) {
19751
+ if (env.platform === "win32") {
19752
+ throw new CodeAgentInstallError("PLATFORM_NOT_SUPPORTED", "Installing the rule in Claude Code is available on macOS and Linux for now.");
19753
+ }
19754
+ const file = claudeSettingsPath(env);
19755
+ const { settings, indent, exists } = readSettings(file);
19756
+ writeHookFiles(env, bundleSource);
19757
+ const added = !hasHook(settings);
19758
+ const next = withHook(settings, hookCommand(hookScriptPath(env.sqHome)));
19759
+ if (JSON.stringify(next) !== JSON.stringify(settings)) writeSettings(file, next, indent, exists, added);
19760
+ return { settings: file, added };
19761
+ }
19762
+ function removeClaudeCodeHook(env) {
19763
+ const file = claudeSettingsPath(env);
19764
+ const { settings, indent, exists } = readSettings(file);
19765
+ const removed = hasHook(settings);
19766
+ if (removed) {
19767
+ const clean = withoutHook(settings);
19768
+ const target = (0, import_fs16.realpathSync)(file);
19769
+ const copy = keptCopyPath(target);
19770
+ if (!Object.keys(clean).length && !(0, import_fs16.existsSync)(copy) && !(0, import_fs16.lstatSync)(file).isSymbolicLink()) (0, import_fs16.rmSync)(file, { force: true });
19771
+ else {
19772
+ writeSettings(file, clean, indent, exists, false);
19773
+ try {
19774
+ if (canonical(JSON.parse((0, import_fs16.readFileSync)(copy, "utf8"))) === canonical(clean)) (0, import_fs16.rmSync)(copy, { force: true });
19775
+ } catch {
19776
+ }
19777
+ }
19778
+ }
19779
+ (0, import_fs16.rmSync)(hookScriptPath(env.sqHome), { force: true });
19780
+ (0, import_fs16.rmSync)(hookBundlePath(env.sqHome), { force: true });
19781
+ return { settings: file, removed };
19782
+ }
19783
+
19784
+ // src/application/services/workspaceSandbox/codeAgentSync.ts
19785
+ var import_fs17 = require("fs");
19786
+ var import_path23 = require("path");
19787
+ function machineTokens(sqHome2) {
19788
+ try {
19789
+ const raw = JSON.parse((0, import_fs17.readFileSync)((0, import_path23.join)(sqHome2, "credentials.json"), "utf8"));
19790
+ return Object.entries(raw?.apis ?? {}).flatMap(([api, c]) => typeof c?.machineToken === "string" && c.machineToken ? [{ api, token: c.machineToken }] : []);
19791
+ } catch {
19792
+ return [];
19793
+ }
19794
+ }
19795
+ function savePolicies(sqHome2, change) {
19796
+ const file = readPolicyFile(sqHome2);
19797
+ change(file.apis);
19798
+ (0, import_fs17.mkdirSync)(agentsDir(sqHome2), { recursive: true, mode: 448 });
19799
+ const tmp = `${policyPath(sqHome2)}.${process.pid}.tmp`;
19800
+ (0, import_fs17.writeFileSync)(tmp, `${JSON.stringify(file, null, 2)}
19801
+ `, { mode: 384 });
19802
+ (0, import_fs17.renameSync)(tmp, policyPath(sqHome2));
19803
+ }
19804
+ async function call(deps, api, token, path, body) {
19805
+ try {
19806
+ const res = await (deps.fetchImpl ?? fetch)(`${api.replace(/\/+$/, "")}/api/ai-governance${path}`, {
19807
+ method: "POST",
19808
+ body: JSON.stringify(body),
19809
+ signal: AbortSignal.timeout(8e3),
19810
+ headers: { accept: "application/json", "content-type": "application/json", "x-machine-token": token, "user-agent": deps.userAgent ?? "scalequality-cli (agents)" }
19811
+ });
19812
+ const text3 = await res.text().catch(() => "");
19813
+ let data = null;
19814
+ try {
19815
+ data = text3 ? JSON.parse(text3) : null;
19816
+ } catch {
19817
+ data = null;
19818
+ }
19819
+ const code = typeof data?.code === "string" && /^[A-Z_]{3,80}$/.test(data.code) ? data.code : null;
19820
+ return { status: res.status, code, data: res.ok ? data : null };
19821
+ } catch {
19822
+ return { status: null, code: null, data: null };
19823
+ }
19824
+ }
19825
+ function policyOf2(raw) {
19826
+ const p = raw;
19827
+ if (!p || typeof p !== "object" || typeof p.version !== "number" || !p.rules || typeof p.rules !== "object" || Array.isArray(p.rules)) return null;
19828
+ return { version: p.version, mode: p.mode === "observe" ? "observe" : "off", rules: Object.fromEntries(Object.entries(p.rules).filter(([, v]) => typeof v === "string")) };
19829
+ }
19830
+ function batches(sqHome2, api, now) {
19831
+ const dir = outboxDir(sqHome2), key = apiKey(api);
19832
+ try {
19833
+ (0, import_fs17.renameSync)(outboxPath(sqHome2, api), (0, import_path23.join)(dir, `${key}.${now.getTime()}.${process.pid}.sending`));
19834
+ } catch {
19835
+ }
19836
+ try {
19837
+ return (0, import_fs17.readdirSync)(dir).filter((f) => f.startsWith(`${key}.`) && f.endsWith(".sending")).sort().map((f) => (0, import_path23.join)(dir, f));
19838
+ } catch {
19839
+ return [];
19840
+ }
19841
+ }
19842
+ function waiting(sqHome2, api) {
19843
+ const dir = outboxDir(sqHome2), key = apiKey(api);
19844
+ let lines2 = 0;
19845
+ try {
19846
+ for (const f of (0, import_fs17.readdirSync)(dir)) {
19847
+ if (!f.startsWith(`${key}.`)) continue;
19848
+ lines2 += (0, import_fs17.readFileSync)((0, import_path23.join)(dir, f), "utf8").split("\n").filter(Boolean).length;
19849
+ }
19850
+ } catch {
19851
+ }
19852
+ return lines2;
19853
+ }
19854
+ function forget(sqHome2, api, queueToo) {
19855
+ savePolicies(sqHome2, (apis) => {
19856
+ delete apis[api];
19857
+ });
19858
+ if (!queueToo) return;
19859
+ const dir = outboxDir(sqHome2), key = apiKey(api);
19860
+ try {
19861
+ for (const f of (0, import_fs17.readdirSync)(dir)) if (f.startsWith(`${key}.`)) (0, import_fs17.rmSync)((0, import_path23.join)(dir, f), { force: true });
19862
+ } catch {
19863
+ }
19864
+ }
19865
+ async function syncApi(deps, api, token) {
19866
+ const now = deps.now?.() ?? /* @__PURE__ */ new Date();
19867
+ const checkin = await call(deps, api, token, "/machines/self/code-agents/checkin", { agents: { claudeCode: { installed: deps.claudeCodeInstalled, scope: deps.claudeCodeInstalled ? "user" : null } } });
19868
+ const policy = policyOf2(checkin.data?.policy);
19869
+ let outcome = "UNREACHABLE";
19870
+ if (checkin.status === 200 && policy) {
19871
+ outcome = "OK";
19872
+ const refresh = typeof checkin.data?.refreshSeconds === "number" ? checkin.data.refreshSeconds : 60;
19873
+ savePolicies(deps.sqHome, (apis) => {
19874
+ apis[api] = { policy, fetchedAt: now.toISOString(), refreshSeconds: refresh };
19875
+ });
19876
+ } else if (checkin.status === 401 && checkin.code === "MACHINE_AUTH_REQUIRED") {
19877
+ outcome = "DISCONNECTED";
19878
+ forget(deps.sqHome, api, true);
19879
+ } else if (checkin.status === 404) {
19880
+ outcome = "NOT_SERVED";
19881
+ forget(deps.sqHome, api, true);
19882
+ }
19883
+ let sent = 0;
19884
+ if (outcome === "OK") {
19885
+ for (const file of batches(deps.sqHome, api, now)) {
19886
+ let decisions = [];
19887
+ try {
19888
+ decisions = (0, import_fs17.readFileSync)(file, "utf8").split("\n").filter(Boolean).flatMap((l) => {
19889
+ try {
19890
+ return [JSON.parse(l)];
19891
+ } catch {
19892
+ return [];
19893
+ }
19894
+ });
19895
+ } catch {
19896
+ }
19897
+ let delivered = true;
19898
+ for (let i = 0; i < decisions.length && delivered; i += 200) {
19899
+ const r = await call(deps, api, token, "/machines/self/code-agents/decisions", { decisions: decisions.slice(i, i + 200) });
19900
+ if (r.status !== null && (r.status < 300 || r.status === 400)) {
19901
+ if (r.status < 300) sent += Math.min(200, decisions.length - i);
19902
+ } else delivered = false;
19903
+ }
19904
+ if (!delivered) break;
19905
+ (0, import_fs17.rmSync)(file, { force: true });
19906
+ }
19907
+ }
19908
+ return { api, checkin: outcome, policy: outcome === "OK" ? policy : readPolicyFile(deps.sqHome).apis[api]?.policy ?? null, sent, waiting: waiting(deps.sqHome, api) };
19909
+ }
19910
+ async function syncAll(deps, only) {
19911
+ const tokens = machineTokens(deps.sqHome).filter((t) => !only || t.api === only);
19912
+ try {
19913
+ (0, import_fs17.mkdirSync)(agentsDir(deps.sqHome), { recursive: true, mode: 448 });
19914
+ const stamp = syncStampPath(deps.sqHome), at = deps.now?.() ?? /* @__PURE__ */ new Date();
19915
+ if ((0, import_fs17.existsSync)(stamp)) (0, import_fs17.utimesSync)(stamp, at, at);
19916
+ else (0, import_fs17.writeFileSync)(stamp, "", { mode: 384 });
19917
+ } catch {
19918
+ }
19919
+ if (!only) {
19920
+ const known = new Set(tokens.map((t) => t.api));
19921
+ const stale = Object.keys(readPolicyFile(deps.sqHome).apis).filter((api) => !known.has(api));
19922
+ for (const api of stale) forget(deps.sqHome, api, true);
19923
+ }
19924
+ const out2 = [];
19925
+ for (const t of tokens) out2.push(await syncApi(deps, t.api, t.token));
19926
+ return out2;
19927
+ }
19928
+ function lastSyncAt(sqHome2) {
19929
+ try {
19930
+ return (0, import_fs17.statSync)(syncStampPath(sqHome2)).mtime;
19931
+ } catch {
19932
+ return null;
19933
+ }
19934
+ }
19935
+
19936
+ // src/main/workspace-connect.ts
19535
19937
  var importEsm = new Function("specifier", "return import(specifier)");
19536
19938
  async function loadSdk() {
19537
19939
  const resolved = require.resolve("@anthropic-ai/claude-agent-sdk");
@@ -19546,9 +19948,9 @@ var say = (line = "") => {
19546
19948
  var cliVersion = process.env.SCALEQUALITY_CLI_VERSION || "dev";
19547
19949
  var userAgent = (mode) => `scalequality-cli/${cliVersion} (${mode}; node ${process.versions.node}; ${process.platform})`;
19548
19950
  var HOME = (0, import_os7.homedir)();
19549
- var SQ_HOME = (0, import_path21.join)(HOME, ".scalequality");
19550
- var ENGINE_HOME = (0, import_path21.join)(SQ_HOME, "workspace");
19551
- var credentials = new CredentialStore((0, import_path21.join)(SQ_HOME, "credentials.json"));
19951
+ var SQ_HOME = (0, import_path24.join)(HOME, ".scalequality");
19952
+ var ENGINE_HOME = (0, import_path24.join)(SQ_HOME, "workspace");
19953
+ var credentials = new CredentialStore((0, import_path24.join)(SQ_HOME, "credentials.json"));
19552
19954
  function startFailure(e, api) {
19553
19955
  if (e instanceof NotLocalSessionError) return 'This code belongs to a cloud workspace session. In the AI Workspace, choose "Use a folder on your computer" to get a code for this command.';
19554
19956
  if (e instanceof SessionGoneError) {
@@ -19561,16 +19963,16 @@ function startFailure(e, api) {
19561
19963
  return "ScaleQuality could not start this session. Try again in a moment, or get a new code from the AI Workspace.";
19562
19964
  }
19563
19965
  function engineDirs() {
19564
- const configDir = (0, import_path21.join)(ENGINE_HOME, "claude-home");
19565
- const scratch = (0, import_path21.join)(ENGINE_HOME, "tmp");
19566
- (0, import_fs15.mkdirSync)(configDir, { recursive: true, mode: 448 });
19567
- (0, import_fs15.mkdirSync)(scratch, { recursive: true, mode: 448 });
19966
+ const configDir = (0, import_path24.join)(ENGINE_HOME, "claude-home");
19967
+ const scratch = (0, import_path24.join)(ENGINE_HOME, "tmp");
19968
+ (0, import_fs18.mkdirSync)(configDir, { recursive: true, mode: 448 });
19969
+ (0, import_fs18.mkdirSync)(scratch, { recursive: true, mode: 448 });
19568
19970
  return { configDir, scratch };
19569
19971
  }
19570
19972
  function createLocalEngine(o) {
19571
19973
  const { configDir, scratch } = engineDirs();
19572
- const sessions = (0, import_path21.join)(ENGINE_HOME, "sessions");
19573
- const stateDir = (0, import_path21.join)(sessions, o.sessionId);
19974
+ const sessions = (0, import_path24.join)(ENGINE_HOME, "sessions");
19975
+ const stateDir = (0, import_path24.join)(sessions, o.sessionId);
19574
19976
  void pruneSessionStates(sessions, stateDir).catch(() => void 0);
19575
19977
  const log = {
19576
19978
  info: (msg, ctx) => {
@@ -19873,7 +20275,7 @@ async function upMain(api, verbose, service) {
19873
20275
  let shuttingDown = false;
19874
20276
  let agent;
19875
20277
  const startSession = ({ sessionId, secret, root }) => {
19876
- const label = (0, import_path21.basename)(root);
20278
+ const label = (0, import_path24.basename)(root);
19877
20279
  const prefix = style.dim(`[${label}] `);
19878
20280
  const consoleLog = new ConsoleLog(style);
19879
20281
  let resolveDone = () => void 0;
@@ -19943,6 +20345,7 @@ async function upMain(api, verbose, service) {
19943
20345
  }
19944
20346
  process.exit(RESTART_EXIT_CODE);
19945
20347
  });
20348
+ startAgentsSync(api);
19946
20349
  say(style.bold(`ScaleQuality: keeping "${credential.name}" connected to ${api}${service ? " (background service)" : ""}`));
19947
20350
  say(` Folders: ${credential.folders.length ? credential.folders.join(", ") : "none yet (scalequality add <folder>)"}`);
19948
20351
  say(style.dim(" Commands that sessions want to run are approved in the browser."));
@@ -19967,6 +20370,137 @@ async function upMain(api, verbose, service) {
19967
20370
  throw e;
19968
20371
  }
19969
20372
  }
20373
+ var AGENTS_USAGE = [
20374
+ "Usage: scalequality agents <install|status|remove> [--api URL]",
20375
+ "",
20376
+ "Your organization's secure development rules in the coding agents of this",
20377
+ "computer (Claude Code for now). The agent asks the rules on this computer",
20378
+ "before it acts: the command and the file never leave it, only the decision.",
20379
+ "While your organization observes, nothing is blocked.",
20380
+ "",
20381
+ " install Put the rule in Claude Code for you (you can remove it).",
20382
+ " status Whether it is installed, and the rules this computer holds.",
20383
+ " remove Take it out of Claude Code."
20384
+ ].join("\n");
20385
+ var agentsEnv = () => ({ home: HOME, sqHome: SQ_HOME, platform: process.platform, env: process.env, node: process.execPath });
20386
+ var hookBundle = () => (0, import_path24.join)(__dirname, "hook.cjs");
20387
+ var agentsSyncDeps = () => ({ sqHome: SQ_HOME, claudeCodeInstalled: claudeCodeHookInstalled(agentsEnv()), userAgent: userAgent("agents") });
20388
+ function startAgentsSync(api) {
20389
+ const round2 = async () => {
20390
+ let installed2 = false;
20391
+ try {
20392
+ refreshHookFiles(agentsEnv(), hookBundle());
20393
+ const deps = agentsSyncDeps();
20394
+ installed2 = deps.claudeCodeInstalled;
20395
+ await syncAll(deps, api);
20396
+ } catch {
20397
+ }
20398
+ setTimeout(() => void round2(), installed2 ? 6e4 : 6e5).unref();
20399
+ };
20400
+ setTimeout(() => void round2(), 5e3).unref();
20401
+ }
20402
+ function agentsLines(results, installed2) {
20403
+ const lines2 = [`Claude Code ${installed2 ? `rule installed for you (${claudeSettingsPath(agentsEnv())})` : "rule not installed (scalequality agents install)"}`];
20404
+ if (!results.length) lines2.push("ScaleQuality this computer is not connected (scalequality login)");
20405
+ for (const r of results) {
20406
+ const kept = readPolicyFile(SQ_HOME).apis[r.api];
20407
+ const state = r.checkin === "OK" ? r.policy?.mode === "observe" ? "observing" : "off in your organization" : r.checkin === "NOT_SERVED" ? "not available at this address yet" : r.checkin === "DISCONNECTED" ? "this computer was disconnected there" : kept ? `not reached now; keeping the rules read at ${kept.fetchedAt}` : "not reached now";
20408
+ lines2.push(`ScaleQuality address ${r.api}`);
20409
+ lines2.push(` Rules ${state}${r.policy && r.checkin === "OK" ? ` (version ${r.policy.version}: ${Object.keys(r.policy.rules).join(", ") || "no secure development rule is on"})` : ""}`);
20410
+ if (r.sent || r.waiting) lines2.push(` Decisions ${r.sent} sent now, ${r.waiting} waiting`);
20411
+ }
20412
+ return lines2;
20413
+ }
20414
+ async function agentsMain(argv) {
20415
+ const [action, ...rest] = argv;
20416
+ if (action === "-h" || action === "--help" || !action) {
20417
+ process.stdout.write(`${AGENTS_USAGE}
20418
+ `);
20419
+ process.exit(action ? 0 : 2);
20420
+ }
20421
+ let apiArg = null;
20422
+ let quiet = false;
20423
+ for (let i = 0; i < rest.length; i++) {
20424
+ const a = rest[i];
20425
+ if (a === "--quiet") {
20426
+ quiet = true;
20427
+ continue;
20428
+ }
20429
+ if (a === "-h" || a === "--help") {
20430
+ process.stdout.write(`${AGENTS_USAGE}
20431
+ `);
20432
+ process.exit(0);
20433
+ }
20434
+ if (a === "--api" || a.startsWith("--api=")) {
20435
+ const v = a.includes("=") ? a.slice(a.indexOf("=") + 1) : rest[++i];
20436
+ apiArg = v ? normalizeApiUrl(v) : null;
20437
+ if (!apiArg) {
20438
+ say(style.red("--api must be an https address (http is accepted only for localhost)."));
20439
+ process.exit(2);
20440
+ }
20441
+ continue;
20442
+ }
20443
+ say(style.red(`Unexpected argument ${a}.`));
20444
+ say();
20445
+ say(AGENTS_USAGE);
20446
+ process.exit(2);
20447
+ }
20448
+ const env = agentsEnv();
20449
+ if (action === "sync") {
20450
+ refreshHookFiles(env, hookBundle());
20451
+ const results = await syncAll(agentsSyncDeps(), apiArg);
20452
+ if (!quiet) process.stdout.write(`${agentsLines(results, claudeCodeHookInstalled(env)).join("\n")}
20453
+ `);
20454
+ return;
20455
+ }
20456
+ if (action === "status") {
20457
+ const results = await syncAll(agentsSyncDeps(), apiArg);
20458
+ const at = lastSyncAt(SQ_HOME);
20459
+ process.stdout.write(`${[...agentsLines(results, claudeCodeHookInstalled(env)), ...at ? [`Last read ${at.toISOString()}`] : []].join("\n")}
20460
+ `);
20461
+ return;
20462
+ }
20463
+ if (action === "install") {
20464
+ if (!credentials.apis().length) {
20465
+ say(style.red("This computer is not connected to ScaleQuality. Run scalequality login first."));
20466
+ process.exit(1);
20467
+ }
20468
+ try {
20469
+ const { settings, added } = installClaudeCodeHook(env, hookBundle());
20470
+ say(style.green(added ? `The rule is now in Claude Code for you (${settings}).` : `The rule was already in Claude Code (${settings}); its files were refreshed.`));
20471
+ } catch (e) {
20472
+ if (e instanceof CodeAgentInstallError) {
20473
+ say(style.red(e.message));
20474
+ process.exit(1);
20475
+ }
20476
+ throw e;
20477
+ }
20478
+ const results = await syncAll(agentsSyncDeps(), apiArg);
20479
+ process.stdout.write(`${agentsLines(results, true).join("\n")}
20480
+ `);
20481
+ say(style.dim("Claude Code asks the rules on this computer before it acts. Nothing is blocked while your organization observes;"));
20482
+ say(style.dim('only the decision leaves this computer, never the command or the file. "scalequality agents remove" takes it out.'));
20483
+ return;
20484
+ }
20485
+ if (action === "remove") {
20486
+ try {
20487
+ const { settings, removed } = removeClaudeCodeHook(env);
20488
+ say(removed ? `The rule was taken out of Claude Code (${settings}).` : "The rule was not installed in Claude Code.");
20489
+ } catch (e) {
20490
+ if (e instanceof CodeAgentInstallError) {
20491
+ say(style.red(e.message));
20492
+ process.exit(1);
20493
+ }
20494
+ throw e;
20495
+ }
20496
+ await syncAll(agentsSyncDeps(), apiArg);
20497
+ return;
20498
+ }
20499
+ say(style.red(`Unknown agents action ${action}.`));
20500
+ say();
20501
+ say(AGENTS_USAGE);
20502
+ process.exit(2);
20503
+ }
19970
20504
  function startSelfUpdate(api, busy, restart) {
19971
20505
  const confirm = setTimeout(() => {
19972
20506
  try {
@@ -20017,7 +20551,7 @@ function startSelfUpdate(api, busy, restart) {
20017
20551
  }
20018
20552
  async function addMain(api, path) {
20019
20553
  try {
20020
- const real = await addFolder(credentials, api, (0, import_path21.resolve)(path ?? process.cwd()), HOME);
20554
+ const real = await addFolder(credentials, api, (0, import_path24.resolve)(path ?? process.cwd()), HOME);
20021
20555
  say(style.green(`Added ${real}.`));
20022
20556
  const credential = credentials.get(api);
20023
20557
  const client = new MachineClient(api, { token: credential.machineToken, userAgent: userAgent("add") });
@@ -20119,6 +20653,10 @@ async function main() {
20119
20653
  }
20120
20654
  const argv = process.argv.slice(2);
20121
20655
  const command = argv[0];
20656
+ if (command === "agents") {
20657
+ await agentsMain(argv.slice(1));
20658
+ return;
20659
+ }
20122
20660
  if (!isMachineCommand(command)) {
20123
20661
  await connectMain(argv);
20124
20662
  return;
package/dist/hook.cjs ADDED
@@ -0,0 +1,6 @@
1
+ /* @scalequality/cli hook: built from scalequality-ai-governance-service src/main/code-agent-hook.ts. */
2
+ "use strict";var be=require("child_process"),_e=require("fs"),ke=require("os"),Ee=require("path");var ae=require("child_process"),I=require("crypto"),g=require("fs"),w=require("path");var G=require("child_process"),K=require("util");var Pt=6*1024*1024,St=4*1024*1024;var At=(0,K.promisify)(G.execFile);var Ct={perFileBytes:200*1024,totalBytes:2*1024*1024,maxFiles:500},Dt=448*1024;var It={bytes:1024*1024,lines:2e4};var Nt=2*1024*1024;var Se="scalequality",Bt=`mcp__${Se}__`;var Oe={Write:"file_path",Edit:"file_path",MultiEdit:"file_path",NotebookEdit:"notebook_path"},Te="generate_image";var xe="screenshot_app";var jt={...Oe,[`mcp__scalequality__${Te}`]:"file_path",[`mcp__scalequality__${xe}`]:"file_path"};var qt=600*1e3;var Re=String.raw`(~|\$\{?home\}?|\$\{?userprofile\}?|/users/[^/\s]+|/home/[^/\s]+|/root)/`,Gt=[{re:/(^|[\s=:/~])\.(ssh|aws|gnupg)(\/|\s|$)/i,why:"Credential directories on this machine are not readable from the workspace."},{re:/(^|[\s=:/~])\.(netrc|git-credentials|pgpass)\b/i,why:"Credential files on this machine are not readable from the workspace."},{re:new RegExp(`${Re}\\.(npmrc|yarnrc\\.yml|pypirc|docker|kube|azure|config/(gh|hub|gcloud|op))\\b`,"i"),why:"Credential files on this machine are not readable from the workspace."},{re:/(^|[;&|(`]|\$\()\s*(security\s+(find|dump|export)-|gh\s+auth\s+(token|status\s+-t\b|status\s+--show-token)|op\s+(read|item\s+get)|pass\s+show|secret-tool\s+lookup|aws\s+configure\s+(get|export-credentials)|gcloud\s+auth\s+print-)/i,why:"Credential stores on this machine are not readable from the workspace."}];function b(e){return e.replace(/\\\n/g," ").replace(/['"\\]/g,"").replace(/[ \t]+/g," ").toLowerCase()}var ve=Object.freeze({secretFiles:!1,protectedPush:!1,deployApproval:!1,destructiveCommands:!1,unknownPackage:null,toolApproval:!1}),Ae={"secret-files":["block"],"protected-push":["require"],"deploy-approval":["require"],"destructive-commands":["require"],"unknown-package":["block","warn"],"tool-approval":["require"]};function Ce(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(!t.rules||typeof t.rules!="object"||Array.isArray(t.rules))return null;let r={};for(let[s,o]of Object.entries(t.rules))typeof o=="string"&&Ae[s]?.includes(o)&&(r[s]=o);let n=typeof t.version=="number"&&Number.isFinite(t.version)?t.version:0;return Object.keys(r).length?{version:n,rules:r}:null}function Q(e){let t=Ce(e);if(!t)return ve;let r=t.rules;return{secretFiles:r["secret-files"]==="block",protectedPush:r["protected-push"]==="require",deployApproval:r["deploy-approval"]==="require",destructiveCommands:r["destructive-commands"]==="require",unknownPackage:r["unknown-package"]==="block"||r["unknown-package"]==="warn"?r["unknown-package"]:null,toolApproval:r["tool-approval"]==="require"}}var U={PROTECTION_SECRET_FILE:"secret-files",PROTECTION_DESTRUCTIVE_COMMAND:"destructive-commands",PROTECTION_DEPLOY:"deploy-approval",PROTECTION_PROTECTED_PUSH:"protected-push",PROTECTION_UNKNOWN_PACKAGE:"unknown-package",PROTECTION_TOOL_APPROVAL:"tool-approval"};var W="Blocked by your organization's protection: secret files are never sent to the model. Do not try to read this file another way; ask the user for the specific value your task needs, or use the example file (such as .env.example).",De=new Set(["example","sample","template","dist"]),Ie=/\.(pem|key|p12|pfx|jks|keystore)$/,Ne=new Set([".npmrc",".pypirc",".netrc",".git-credentials","credentials.json","secrets.yml","secrets.yaml","terraform.tfvars"]);function M(e){let t=e.trim().replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase();if(!t)return!1;let r=t.split("/"),n=r[r.length-1];return n===".env"?!0:n.startsWith(".env.")?!n.slice(5).split(".").some(s=>De.has(s)):Ie.test(n)||/^id_(rsa|dsa|ecdsa|ed25519)/.test(n)&&!n.endsWith(".pub")||Ne.has(n)||n.endsWith(".auto.tfvars")||/^service-account.*\.json$/.test(n)?!0:n==="credentials"&&r[r.length-2]===".aws"}var Le=[".env",".env.local",".env.production","server.pem","tls.key","cert.p12","cert.pfx","release.jks","app.keystore","id_rsa","id_ed25519",".npmrc",".pypirc",".netrc",".git-credentials","credentials.json","service-account.json","service-account-prod.json","prod.auto.tfvars","terraform.tfvars",".aws/credentials","secrets.yml","secrets.yaml"],$e=["package.json","index.ts","main.py","README.md","app.yml","app.yaml","main.tf","Main.java","config"];function Fe(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];n==="*"?e[r+1]==="*"?(t+=".*",r++,e[r+1]==="/"&&r++):t+="[^/]*":n==="?"?t+="[^/]":n==="{"?t+="(":n==="}"?t+=")":n===","?t+="|":t+=n.replace(/[.+^$()|[\]\\]/g,"\\$&")}return new RegExp(`^${t}$`,"i")}function He(e){return e.split(/\s+/).filter(Boolean).filter(r=>!r.startsWith("!")).some(r=>{let n;try{n=Fe(r.replace(/^\.\//,""))}catch{return!1}let s=o=>n.test(o)||!r.includes("/")&&n.test(o.split("/").pop());return Le.some(s)&&!$e.some(s)})}var Yt=[...[".env",".env.local",".env.*.local",".env.development",".env.dev",".env.production",".env.prod",".env.staging",".env.stage",".env.test",".env.testing",".env.qa",".env.uat",".env.preview",".env.ci",".env.docker",".env.vault",".env.keys",".env.backup",".env.bak",".env.old",".env.secret",".env.secrets",".env.override","*.pem","*.key","*.p12","*.pfx","*.jks","*.keystore","id_rsa","id_rsa_*","id_dsa","id_dsa_*","id_ecdsa","id_ecdsa_*","id_ed25519","id_ed25519_*",".npmrc",".pypirc",".netrc",".git-credentials","credentials.json","service-account*.json","*.auto.tfvars","terraform.tfvars",".aws/credentials","secrets.yml","secrets.yaml"].map(e=>`Read(**/${e})`)],We={Read:["file_path"],Write:["file_path"],Edit:["file_path"],MultiEdit:["file_path"],NotebookEdit:["notebook_path"],Grep:["path"],Glob:["path"],LS:["path"]};function $(e,t){for(let r of We[e]??[]){let n=t[r];if(typeof n=="string"&&M(n))return W}return e==="Grep"&&typeof t.glob=="string"&&He(t.glob)?W:null}var Me=new Set(["ls","stat","test","[","[[","file","wc","rm","touch","echo","printf","chmod","mkdir","realpath","basename","dirname","du","true","cd","pwd"]),Ue=new Set(["status","add","rm","check-ignore","ls-files","update-index"]),Be=/(^|\s)(grep|egrep|fgrep)\s(.*\s)?(-[a-z]*r[a-z]*|--recursive|--dereference-recursive)(\s|$)|(^|\s)(rg|ag|ack|ack-grep)(\s|$)|(^|\s)git\s+(-c\s+\S+\s+)*grep(\s|$)/;function v(e){return e.replace(/\\\n/g," ").split(/\|\||&&|[|;&\n\r`]|\$\(|<\(|>\(|[()]/).map(t=>t.trim()).filter(Boolean)}function _(e){let t=e.split(/\s+/).filter(Boolean),r=0;for(;;){let n=t[r];if(n===void 0)break;if(/^[a-z_][a-z0-9_]*=/i.test(n)){r++;continue}if(["sudo","doas","command","builtin","exec","nohup","time","nice","env","xargs"].includes(n.replace(/^.*\//,""))){for(r++;t[r]?.startsWith("-");)r++;continue}break}return t.slice(r)}function z(e){return e.replace(/^[<>]+/,"").split(/[=:@,]/).map(t=>t.replace(/^[<>]+/,"")).filter(Boolean)}function F(e){let t=b(e),r=v(t);return(t.split(/[\s|;&()`]+/).filter(Boolean).some(i=>z(i).some(M))||/(^|\s)(source|\.)\s+\S*\.env(\s|$)/.test(t))&&(!r.every(c=>{let p=_(c),u=(p[0]??"").replace(/^.*\//,"");if(u==="git"){let a=p.slice(1).find(l=>!l.startsWith("-"));return!!a&&Ue.has(a)}if(u==="cp"||u==="mv"||u==="install"){let a=p.slice(1).filter(l=>!l.startsWith("-"));return a.length>=2&&!a.slice(0,-1).some(l=>z(l).some(M))}return Me.has(u)})||/<\s*[^<\s]/.test(t.replace(/<<-?\s*\S+/g,"")))?W:t.replace(/\\\n/g," ").split(/&&|\|\||[;&\n\r`]|\$\(|<\(|>\(|[()]/).map(i=>i.split("|")[0].trim()).filter(Boolean).some(i=>Be.test(_(i).join(" ")))?"Blocked by your organization's protection: secret files are never sent to the model, and a recursive search from a command would read them. Use the Grep tool for this search (it skips secret files), or search specific files by name.":null}var H=/(^|\s)(-[a-z]*r[a-z]*|--recursive)(\s|$)/,je=[e=>e[0]==="rm"&&H.test(e.slice(1).join(" ")),(e,t)=>e[0]==="find"&&/\s-delete(\s|$)/.test(t),(e,t)=>e[0]==="find"&&/\s-exec(dir)?\s+(\S*\/)?rm\s/.test(t),(e,t)=>e[0]==="git"&&/(^|\s)reset\s+(.*\s)?--hard(\s|$)/.test(t),(e,t)=>e[0]==="git"&&/(^|\s)clean\s+(.*\s)?(-[a-z]*f[a-z]*|--force)(\s|$)/.test(t),(e,t)=>e[0]==="git"&&/(^|\s)checkout\s+(.*\s)?(--\s+)?(\.|:\/|\*)(\s|$)/.test(t),(e,t)=>e[0]==="git"&&/(^|\s)restore\s+(.*\s)?(\.|:\/|\*)(\s|$)/.test(t),e=>e[0]==="dd",e=>!!e[0]?.startsWith("mkfs"),e=>e[0]==="shred",(e,t)=>e[0]==="chmod"&&H.test(t)&&/(^|\s)(0?777|a\+rwx|ugo\+rwx)(\s|$)/.test(t),(e,t)=>e[0]==="chown"&&H.test(t),e=>e[0]==="dropdb"],qe=[/\b(curl|wget|fetch)\b[^|;\n]*\|\s*(sudo\s+(-\S+\s+)*)?(env\s+)?(\S*\/)?(sh|bash|zsh|dash|ksh|fish|python3?|perl|ruby|node)(\s|$)/,/\b(sh|bash|zsh|dash|ksh|fish|source|\.)\s+<\(\s*(curl|wget)\b/,/\b(sh|bash|zsh|dash|ksh|fish)\s+-c\s+\$\(\s*(curl|wget)\b/,/\beval\s+\$\(\s*(curl|wget)\b/];function X(e){let t=b(e);return qe.some(r=>r.test(t))||/\bdrop\s+(database|table|schema)\b/.test(t)||/(^|[\s;&|(])(psql|mysql|mariadb|sqlite3|clickhouse-client|cockroach)\b.*\btruncate\b/.test(t)?!0:v(t).some(r=>{let n=_(r).map((s,o)=>o===0?s.replace(/^.*\//,""):s);return je.some(s=>s(n,n.join(" ")))})}var Ge=[/\b(npm|pnpm|yarn|bun)\s+(.*\s)?publish(\s|$)/,/\bcargo\s+publish\b/,/\bgem\s+push\b/,/\bpoetry\s+publish\b/,/\btwine\s+upload\b/,/\b(docker|podman)\s+(image\s+)?push\b/,/\b(terraform|tofu)\s+(.*\s)?(apply|destroy)\b/,/\bpulumi\s+(.*\s)?(up|destroy|update)\b/,/\bcdk\s+(.*\s)?(deploy|destroy)\b/,/\b(serverless|sls)\s+(.*\s)?deploy\b/,/\bkubectl\s+(.*\s)?(apply|delete|rollout)\b/,/\bhelm\s+(.*\s)?(install|upgrade|uninstall)\b/,/(^|\s)vercel(\s+.*)?\s(--prod|deploy)\b/,/\bnetlify\s+(.*\s)?deploy\b/,/\b(fly|flyctl)\s+(.*\s)?deploy\b/,/\bwrangler\s+(.*\s)?(deploy|publish)\b/,/\bgcloud\s+(.*\s)?deploy\b/,/\baz\s+(.*\s)?(deploy|deployment|webapp\s+up)\b/,/\baws\s+(.*\s)?cloudformation\s+(.*\s)?deploy\b/,/\baws\s+(.*\s)?ecs\s+(.*\s)?update-service\b/,/\baws\s+(.*\s)?lambda\s+(.*\s)?update-function-code\b/,/\baws\s+(.*\s)?s3\s+sync\s+(.*\s)?\S+\s+s3:\/\/\S+(\s+-.*)?$/,/\bgh\s+release\s+create\b/,/\beas\s+submit\b/,/\bmvn\b.*\bdeploy\b/,/\bgradlew?\b.*\bpublish/,/\bdotnet\s+nuget\s+push\b/,/\bfirebase\s+(.*\s)?deploy\b/,/\beb\s+deploy\b/];function Z(e){return v(b(e)).some(t=>{let n=_(t).join(" ");return Ge.some(s=>s.test(n))})}var Ke=/^(main|master|production|prod|develop|development|release\/.+)$/;function Y(e){return Ke.test(e.replace(/^refs\/heads\//,"").toLowerCase())}var ze=new Set(["-o","--push-option","--repo","--receive-pack","--exec","--signed"]);function ee(e){let t=[];for(let r of v(b(e))){let n=_(r);if((n[0]??"").replace(/^.*\//,"")!=="git")continue;let s=1;for(;s<n.length&&n[s].startsWith("-");)s+=n[s]==="-C"||n[s]==="-c"?2:1;if(n[s]!=="push")continue;let o={branches:[],current:!1,force:!1,all:!1},i=!1,c=[];for(let u=s+1;u<n.length;u++){let a=n[u];if(a==="--"){c.push(...n.slice(u+1));break}if(ze.has(a)){u++;continue}(/^--force(-with-lease|-if-includes)?(=|$)/.test(a)||a==="--mirror")&&(o.force=!0),(a==="--all"||a==="--mirror"||a==="--branches")&&(o.all=!0),a==="--tags"&&(i=!0),/^-[a-z]+$/.test(a)&&!a.startsWith("--")&&a.includes("f")&&(o.force=!0),!a.startsWith("-")&&c.push(a)}let p=c.slice(1);!p.length&&!i&&(o.current=!0);for(let u of p){u.startsWith("+")&&(o.force=!0);let a=u.replace(/^\+/,""),d=(a.includes(":")?a.slice(a.indexOf(":")+1):a).replace(/^refs\/heads\//,"");d&&(d==="head"||d==="@"?o.current=!0:o.branches.push(d))}t.push(o)}return t}async function Ye(e,t){let r=ee(e);if(!r.length)return!1;let n;for(let s of r)if(s.force||s.all||s.branches.some(Y)||s.current&&(n===void 0&&(n=await t().catch(()=>null)),!n||n==="head"||n==="HEAD"||Y(n)))return!0;return!1}var Ve=/^(@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/,Je=/^[a-z0-9]([a-z0-9._-]*[a-z0-9])?$/,Qe=/^[a-z0-9][a-z0-9_-]*$/,Xe=new Set(["--registry","--prefix","-w","--workspace","--tag","--omit","--include","--cache","--userconfig","-c","--filter","-F","--dir","-C","--cwd","-p","--package"]),V=new Set(["-r","--requirement","-c","--constraint","-e","--editable","-i","--index-url","--extra-index-url","-f","--find-links","-t","--target","--prefix","--root","--python","-p","--group","--optional","-G","--source","--platform","--python-version","--implementation","--abi","--trusted-host","--cert","--client-cert","--cache-dir","--src","--upgrade-strategy","--progress-bar","--log","--timeout","--retries","--proxy","-E","--extras","--with","--dev-group"]),Ze=new Set(["-F","--features","--rename","-p","--package","--registry","--manifest-path","--target","--branch","--tag","--rev"]);function te(e){return/^(\.|\/|~|file:|link:|workspace:|portal:|patch:|git[+:]|github:|gitlab:|bitbucket:|https?:|ssh:)/.test(e)||/\.(tgz|tar\.gz|tar|zip|whl)$/.test(e)||e.includes("://")}function x(e){if(te(e))return null;let t=/^[^@]+@npm:(.+)$/.exec(e)??/^@[^/]+\/[^@]+@npm:(.+)$/.exec(e),r=t?t[1]:e,n=r.startsWith("@"),s=r.indexOf("@",n?1:0),o=s>0?r.slice(0,s):r;return!n&&o.includes("/")?null:Ve.test(o)?o:null}function J(e){if(te(e)||e.includes(" @ "))return null;let t=e.split(/[\[<>=!~;@\s]/)[0];return Je.test(t)?t:null}function et(e){let t=e.split("@")[0];return Qe.test(t)?t:null}function R(e,t){let r=[];for(let n=0;n<e.length;n++){let s=e[n];if(t.has(s)){n++;continue}s.startsWith("-")||r.push(s)}return r}function ne(e,t={}){let r=[],n=(s,o)=>{o&&!r.some(i=>i.ecosystem===s&&i.name===o)&&r.push({ecosystem:s,name:o})};for(let s of v(b(e))){let o=_(s),i=(o[0]??"").replace(/^.*\//,""),c=o.slice(1);if(c.some(l=>/^(--registry|--index-url|-i)(=|$)/.test(l)))continue;if(["npm","pnpm","yarn","bun"].includes(i)){let l=R(c,Xe),d=0;l[0]==="global"&&(d=1);let m=l[d];if(m==="add"||(m==="install"||m==="i"||m==="in")&&i!=="yarn")for(let T of l.slice(d+1))n("npm",x(T));if((i==="pnpm"||i==="yarn")&&m==="dlx"&&l[d+1]&&n("npm",x(l[d+1])),i==="npm"&&(m==="exec"||m==="x")&&l[d+1]){let T=x(l[d+1]);T&&!t.installedLocally?.(T)&&n("npm",T)}continue}if(i==="npx"||i==="bunx"||i==="pnpx"){let l=c.findIndex(L=>L==="-p"||L==="--package");if(l>=0&&c[l+1]){n("npm",x(c[l+1]));continue}let d=R(c,new Set(["--registry","--cache","--prefix"]))[0],m=d?x(d):null;m&&!t.installedLocally?.(m)&&n("npm",m);continue}/^python[0-9.]*$/.test(i)&&c[0]==="-m"&&/^pip3?$/.test(c[1]??"")?o=[c[1],...c.slice(2)]:i==="uv"&&c[0]==="pip"&&(o=["pip",...c.slice(1)]);let u=(o[0]??"").replace(/^.*\//,""),a=o.slice(1);if(/^pip3?(\.\d+)?$/.test(u)&&a[0]==="install"){for(let l of R(a.slice(1),V))n("pypi",J(l));continue}if((u==="uv"||u==="poetry")&&a[0]==="add"){for(let l of R(a.slice(1),V))n("pypi",J(l));continue}if(u==="cargo"&&a[0]==="add"){if(a.some(l=>/^--(git|path)(=|$)/.test(l)))continue;for(let l of R(a.slice(1),Ze))n("crates",et(l))}}return r}var re=30,tt=3e3;function nt(e){return e.ecosystem==="npm"?`https://registry.npmjs.org/${e.name.replace("/","%2F")}`:e.ecosystem==="pypi"?`https://pypi.org/pypi/${encodeURIComponent(e.name)}/json`:`https://crates.io/api/v1/crates/${encodeURIComponent(e.name)}`}function rt(e,t){let r=null;if(e.ecosystem==="npm")r=t?.time?.created;else if(e.ecosystem==="crates")r=t?.crate?.created_at;else{let s=null,o=t?.releases&&typeof t.releases=="object"?Object.values(t.releases):[];for(let i of o)if(Array.isArray(i))for(let c of i){let p=Date.parse(String(c?.upload_time_iso_8601??c?.upload_time??""));Number.isFinite(p)&&(s===null||p<s)&&(s=p)}return s===null?null:new Date(s)}let n=typeof r=="string"?Date.parse(r):NaN;return Number.isFinite(n)?new Date(n):null}var D=class{constructor(t={}){this.o=t}o;cache=new Map;async check(t){let r=new Map,n=AbortSignal.timeout(this.o.timeoutMs??tt);return await Promise.all(t.map(async s=>{let o=`${s.ecosystem}:${s.name}`,i=this.cache.get(o);if(i){r.set(o,i);return}let c=await this.lookup(s,n);c!=="UNVERIFIED"&&this.cache.set(o,c),r.set(o,c)})),r}async lookup(t,r){try{let n=await(this.o.fetchImpl??fetch)(nt(t),{headers:{accept:"application/json","user-agent":this.o.userAgent??"scalequality-code (+https://scalequality.io)"},signal:r,redirect:"follow"});if(n.status===404)return"NOT_FOUND";if(!n.ok)return"UNVERIFIED";let s=await n.json(),o=rt(t,s);return o?((this.o.now?.()??new Date).getTime()-o.getTime())/864e5<re?"TOO_NEW":"OK":"UNVERIFIED"}catch{return"UNVERIFIED"}}};function se(e,t){return t.toolApproval||t.destructiveCommands&&X(e)||t.deployApproval&&Z(e)||t.protectedPush&&ee(e).length>0?!0:t.unknownPackage!==null&&ne(e).length>0}function st(e,t,r){let n=t==="npm"?"npm":t==="pypi"?"PyPI":"crates.io";return r==="NOT_FOUND"?`Blocked by your organization's protection: the package "${e}" does not exist in the public ${n} registry. It was not installed. Check the name (it may be a typo or an invented package) and ask the user before trying another one.`:`Blocked by your organization's protection: the package "${e}" was first published on ${n} less than ${re} days ago. It was not installed. Use an established package or ask the user.`}async function oe(e,t,r){let n=[],s=null;if(t.unknownPackage){let o=ne(e,{installedLocally:r.installedLocally});if(o.length){let i=await r.registry.check(o),c=o.map(a=>({r:a,status:i.get(`${a.ecosystem}:${a.name}`)??"UNVERIFIED"})).filter(a=>a.status!=="OK"),p=c.find(a=>a.status==="NOT_FOUND"||a.status==="TOO_NEW");if(p&&t.unknownPackage==="block"){let a=p.status;return{kind:"deny",message:st(p.r.name,p.r.ecosystem,a),reason:"PROTECTION_UNKNOWN_PACKAGE",package:p.r.name,packageReason:a}}let u=p??(t.unknownPackage==="block"?c[0]:void 0);u&&(n.push("PROTECTION_UNKNOWN_PACKAGE"),s={name:u.r.name,reason:u.status})}}return t.destructiveCommands&&X(e)&&n.push("PROTECTION_DESTRUCTIVE_COMMAND"),t.deployApproval&&Z(e)&&n.push("PROTECTION_DEPLOY"),t.protectedPush&&await Ye(e,r.currentBranch)&&n.push("PROTECTION_PROTECTED_PUSH"),t.toolApproval&&!n.length&&n.push("PROTECTION_TOOL_APPROVAL"),n.length?{kind:"ask",reasons:n,...s?{package:s.name,packageReason:s.reason}:{}}:{kind:"allow"}}var ce=["Bash","Read","Write","Edit","MultiEdit","NotebookEdit","Grep","Glob"],le=1500,ot=512*1024,y=e=>(0,w.join)(e,"agents"),N=e=>(0,w.join)(y(e),"policy.json"),k=e=>(0,w.join)(y(e),"outbox"),A=e=>(0,I.createHash)("sha256").update(e).digest("hex").slice(0,16),C=(e,t)=>(0,w.join)(k(e),`${A(t)}.jsonl`),B=e=>(0,w.join)(y(e),"sync.stamp");function it(e){let t=e;if(!t||typeof t!="object"||typeof t.version!="number"||!t.rules||typeof t.rules!="object"||Array.isArray(t.rules))return null;let r={};for(let[n,s]of Object.entries(t.rules))typeof s=="string"&&(r[n]=s);return{version:t.version,mode:t.mode==="observe"?"observe":"off",rules:r}}function E(e){let t={version:1,apis:{}};try{let r=JSON.parse((0,g.readFileSync)(N(e),"utf8"));for(let[n,s]of Object.entries(r?.apis??{})){let o=it(s?.policy);o&&(t.apis[n]={policy:o,fetchedAt:typeof s.fetchedAt=="string"?s.fetchedAt:"",refreshSeconds:typeof s.refreshSeconds=="number"&&s.refreshSeconds>=15&&s.refreshSeconds<=3600?s.refreshSeconds:60})}}catch{}return t}function ue(e){try{let t=JSON.parse(e);return t?.hook_event_name!=="PreToolUse"||typeof t.tool_name!="string"||!t.tool_input||typeof t.tool_input!="object"||Array.isArray(t.tool_input)?null:{tool:t.tool_name,input:t.tool_input,cwd:typeof t.cwd=="string"&&t.cwd?t.cwd:null}}catch{return null}}var ie=e=>e==="PROTECTION_UNKNOWN_PACKAGE"?"PACKAGE":"COMMAND";async function pe(e,t,r){let n={...Q({version:t.version,rules:t.rules}),toolApproval:!1};if(e.tool!=="Bash")return n.secretFiles&&$(e.tool,e.input)?[{action:"FILE",rule:"secret-files",outcome:"WOULD_BLOCK"}]:[];let s=typeof e.input.command=="string"?e.input.command:"";if(!s.trim())return[];if(n.secretFiles&&F(s))return[{action:"COMMAND",rule:"secret-files",outcome:"WOULD_BLOCK"}];if(!se(s,n))return[];let o=await oe(s,n,r);return o.kind==="allow"?[]:o.kind==="deny"?[{action:ie(o.reason),rule:U[o.reason],outcome:"WOULD_BLOCK"}]:o.reasons.map(i=>({action:ie(i),rule:U[i],outcome:i==="PROTECTION_UNKNOWN_PACKAGE"&&o.packageReason==="UNVERIFIED"?"NOT_CHECKED":"WOULD_HOLD"}))}function fe(e,t){return{registry:t,currentBranch:()=>new Promise(r=>{if(!e){r(null);return}(0,ae.execFile)("git",["rev-parse","--abbrev-ref","HEAD"],{cwd:e,timeout:1e3,windowsHide:!0},(n,s)=>r(n?null:String(s).trim()||null))}),installedLocally:r=>!!e&&((0,g.existsSync)((0,w.join)(e,"node_modules",r,"package.json"))||(0,g.existsSync)((0,w.join)(e,"node_modules",".bin",r)))}}function de(e,t,r,n,s=new Date){if(!r.length)return 0;let o=C(e,t);try{if((0,g.statSync)(o).size>ot)return 0}catch{}(0,g.mkdirSync)(k(e),{recursive:!0,mode:448});let i=r.map(c=>({id:(0,I.randomUUID)(),agent:"CLAUDE_CODE",action:c.action,rule:c.rule,outcome:c.outcome,policyVersion:n,occurredAt:s.toISOString()}));return(0,g.appendFileSync)(o,i.map(c=>`${JSON.stringify(c)}
3
+ `).join(""),{mode:384}),i.length}function he(e,t,r,n=new Date){let s=0;try{s=(0,g.statSync)(B(e)).mtimeMs}catch{}if(n.getTime()-s<6e4)return!1;if(r)return!0;let o=Object.values(t.apis);return o.length?o.some(i=>n.getTime()-(Date.parse(i.fetchedAt)||0)>i.refreshSeconds*1e3):n.getTime()-s>6e5}var h=require("fs"),P=require("path");var j=class extends Error{constructor(r,n){super(n);this.code=r}code},at=e=>(0,P.join)(y(e),"hook.cjs"),ct=e=>(0,P.join)(y(e),"claude-code-hook.sh"),lt=e=>(0,P.join)(e.env.CLAUDE_CONFIG_DIR||(0,P.join)(e.home,".claude"),"settings.json");var Zt=ce.join("|"),ut=e=>typeof e?.command=="string"&&/[\\/]\.scalequality[\\/]agents[\\/]claude-code-hook\.sh/.test(e.command),pt=e=>{let t=e.hooks?.PreToolUse;return Array.isArray(t)?t.filter(r=>!!r&&typeof r=="object"):[]};function ft(e){return pt(e).some(t=>Array.isArray(t.hooks)&&t.hooks.some(ut))}function dt(e){if(!(0,h.existsSync)(e))return{settings:{},indent:" ",exists:!1};let t=(0,h.readFileSync)(e,"utf8"),r;try{r=t.trim()?JSON.parse(t):{}}catch{r=null}if(!r||typeof r!="object"||Array.isArray(r))throw new j("SETTINGS_UNREADABLE",`${e} is not valid JSON, so it was left untouched. Fix the file and run the command again.`);return{settings:r,indent:/^([ \t]+)"/m.exec(t)?.[1]??" ",exists:!0}}function ge(e){try{return ft(dt(lt(e)).settings)&&(0,h.existsSync)(ct(e.sqHome))&&(0,h.existsSync)(at(e.sqHome))}catch{return!1}}var f=require("fs"),S=require("path");function ht(e){try{let t=JSON.parse((0,f.readFileSync)((0,S.join)(e,"credentials.json"),"utf8"));return Object.entries(t?.apis??{}).flatMap(([r,n])=>typeof n?.machineToken=="string"&&n.machineToken?[{api:r,token:n.machineToken}]:[])}catch{return[]}}function ye(e,t){let r=E(e);t(r.apis),(0,f.mkdirSync)(y(e),{recursive:!0,mode:448});let n=`${N(e)}.${process.pid}.tmp`;(0,f.writeFileSync)(n,`${JSON.stringify(r,null,2)}
4
+ `,{mode:384}),(0,f.renameSync)(n,N(e))}async function me(e,t,r,n,s){try{let o=await(e.fetchImpl??fetch)(`${t.replace(/\/+$/,"")}/api/ai-governance${n}`,{method:"POST",body:JSON.stringify(s),signal:AbortSignal.timeout(8e3),headers:{accept:"application/json","content-type":"application/json","x-machine-token":r,"user-agent":e.userAgent??"scalequality-cli (agents)"}}),i=await o.text().catch(()=>""),c=null;try{c=i?JSON.parse(i):null}catch{c=null}let p=typeof c?.code=="string"&&/^[A-Z_]{3,80}$/.test(c.code)?c.code:null;return{status:o.status,code:p,data:o.ok?c:null}}catch{return{status:null,code:null,data:null}}}function gt(e){let t=e;return!t||typeof t!="object"||typeof t.version!="number"||!t.rules||typeof t.rules!="object"||Array.isArray(t.rules)?null:{version:t.version,mode:t.mode==="observe"?"observe":"off",rules:Object.fromEntries(Object.entries(t.rules).filter(([,r])=>typeof r=="string"))}}function mt(e,t,r){let n=k(e),s=A(t);try{(0,f.renameSync)(C(e,t),(0,S.join)(n,`${s}.${r.getTime()}.${process.pid}.sending`))}catch{}try{return(0,f.readdirSync)(n).filter(o=>o.startsWith(`${s}.`)&&o.endsWith(".sending")).sort().map(o=>(0,S.join)(n,o))}catch{return[]}}function yt(e,t){let r=k(e),n=A(t),s=0;try{for(let o of(0,f.readdirSync)(r))o.startsWith(`${n}.`)&&(s+=(0,f.readFileSync)((0,S.join)(r,o),"utf8").split(`
5
+ `).filter(Boolean).length)}catch{}return s}function q(e,t,r){if(ye(e,o=>{delete o[t]}),!r)return;let n=k(e),s=A(t);try{for(let o of(0,f.readdirSync)(n))o.startsWith(`${s}.`)&&(0,f.rmSync)((0,S.join)(n,o),{force:!0})}catch{}}async function wt(e,t,r){let n=e.now?.()??new Date,s=await me(e,t,r,"/machines/self/code-agents/checkin",{agents:{claudeCode:{installed:e.claudeCodeInstalled,scope:e.claudeCodeInstalled?"user":null}}}),o=gt(s.data?.policy),i="UNREACHABLE";if(s.status===200&&o){i="OK";let p=typeof s.data?.refreshSeconds=="number"?s.data.refreshSeconds:60;ye(e.sqHome,u=>{u[t]={policy:o,fetchedAt:n.toISOString(),refreshSeconds:p}})}else s.status===401&&s.code==="MACHINE_AUTH_REQUIRED"?(i="DISCONNECTED",q(e.sqHome,t,!0)):s.status===404&&(i="NOT_SERVED",q(e.sqHome,t,!0));let c=0;if(i==="OK")for(let p of mt(e.sqHome,t,n)){let u=[];try{u=(0,f.readFileSync)(p,"utf8").split(`
6
+ `).filter(Boolean).flatMap(l=>{try{return[JSON.parse(l)]}catch{return[]}})}catch{}let a=!0;for(let l=0;l<u.length&&a;l+=200){let d=await me(e,t,r,"/machines/self/code-agents/decisions",{decisions:u.slice(l,l+200)});d.status!==null&&(d.status<300||d.status===400)?d.status<300&&(c+=Math.min(200,u.length-l)):a=!1}if(!a)break;(0,f.rmSync)(p,{force:!0})}return{api:t,checkin:i,policy:i==="OK"?o:E(e.sqHome).apis[t]?.policy??null,sent:c,waiting:yt(e.sqHome,t)}}async function we(e,t){let r=ht(e.sqHome).filter(s=>!t||s.api===t);try{(0,f.mkdirSync)(y(e.sqHome),{recursive:!0,mode:448});let s=B(e.sqHome),o=e.now?.()??new Date;(0,f.existsSync)(s)?(0,f.utimesSync)(s,o,o):(0,f.writeFileSync)(s,"",{mode:384})}catch{}if(!t){let s=new Set(r.map(i=>i.api)),o=Object.keys(E(e.sqHome).apis).filter(i=>!s.has(i));for(let i of o)q(e.sqHome,i,!0)}let n=[];for(let s of r)n.push(await wt(e,s.api,s.token));return n}var Pe=(0,ke.homedir)(),O=(0,Ee.join)(Pe,".scalequality");function bt(){return new Promise(e=>{if(process.stdin.isTTY){e("");return}let t=[],r=0,n=()=>e(Buffer.concat(t).toString("utf8")),s=setTimeout(n,2e3);process.stdin.on("data",o=>{r+=o.length,r<=4*1024*1024&&t.push(o)}),process.stdin.on("end",()=>{clearTimeout(s),n()}),process.stdin.on("error",()=>{clearTimeout(s),n()})})}async function _t(e){let t=E(O),r=Object.entries(t.apis).filter(([,s])=>s.policy.mode==="observe"&&Object.keys(s.policy.rules).length>0),n=!1;if(e==="claude-code"&&r.length){let s=ue(await bt());if(s){let o=fe(s.cwd,new D({timeoutMs:le,userAgent:"scalequality-cli (+https://scalequality.io)"}));for(let[i,c]of r)de(O,i,await pe(s,c.policy,o),c.policy.version)>0&&(n=!0)}}n||(n=Object.keys(t.apis).some(s=>{try{return(0,_e.statSync)(C(O,s)).size>0}catch{return!1}})),he(O,t,n)&&(0,be.spawn)(process.execPath,[__filename,"sync"],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()}async function kt(){let e=process.argv[2];e==="sync"?await we({sqHome:O,claudeCodeInstalled:ge({home:Pe,env:process.env,sqHome:O})}):await _t(e)}process.on("uncaughtException",()=>process.exit(0));process.on("unhandledRejection",()=>process.exit(0));kt().then(()=>process.exit(0),()=>process.exit(0));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scalequality/cli",
3
- "version": "0.4.44",
4
- "description": "ScaleQuality CLI. Connect your computer to the ScaleQuality AI Workspace (`scalequality login`), run its coding engine in any folder of your computer, and import your Claude Code and Codex conversations.",
3
+ "version": "0.4.45",
4
+ "description": "ScaleQuality CLI. Connect your computer to the ScaleQuality AI Workspace (`scalequality login`), run its coding engine in any folder of your computer, import your Claude Code and Codex conversations, and have your organization's secure development rules asked by Claude Code (`scalequality agents`).",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "scalequality": "bin/scalequality.mjs"