@intellectual-frontiers/ergonex 0.3.2 → 0.3.4

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/dist/mod.js CHANGED
@@ -911,7 +911,7 @@ function toSarif(findings, tool = "ergonex") {
911
911
  }
912
912
 
913
913
  // src/state-record.ts
914
- var ERGONEX_VERSION = "0.3.2";
914
+ var ERGONEX_VERSION = "0.3.4";
915
915
  var STATE_RECORD_PATH = ".ergonex/state.auto.json";
916
916
  var EMPTY_RECORD = {
917
917
  ergonex: ERGONEX_VERSION,
@@ -2078,7 +2078,7 @@ function rcFileFor(shell, f) {
2078
2078
  return absurd(shell);
2079
2079
  }
2080
2080
  }
2081
- // ../ts/kernel/otel.ts
2081
+ // ../telemetry/src/otel.ts
2082
2082
  var TRACE_ID = /^[0-9a-f]{32}$/;
2083
2083
  var SPAN_ID = /^[0-9a-f]{16}$/;
2084
2084
  var ZEROS = /^0+$/;
@@ -2136,8 +2136,23 @@ function isSeverityNumber(n) {
2136
2136
  }
2137
2137
  var TWO_56 = 2 ** 56;
2138
2138
  var CREDENTIAL_WORDS = new Set(["key", "code", "sig", "pwd", "pass", "session", "sid", "otp", "awsaccesskeyid", "sas", "se", "sp", "sv"]);
2139
+ function commandShape(argv) {
2140
+ const [program, ...rest] = argv;
2141
+ if (program === undefined)
2142
+ return [];
2143
+ const out = [program.split(/[/\\]/).pop() ?? program];
2144
+ for (const arg of rest) {
2145
+ if (arg === "--")
2146
+ break;
2147
+ if (arg.startsWith("--"))
2148
+ out.push(arg.split("=")[0] ?? arg);
2149
+ else if (arg.startsWith("-") && arg.length > 1 && !/^-[0-9.]/.test(arg))
2150
+ out.push(arg.slice(0, 2));
2151
+ }
2152
+ return out;
2153
+ }
2139
2154
 
2140
- // ../ts/kernel/otlp.ts
2155
+ // ../telemetry/src/otlp.ts
2141
2156
  var SPAN_KINDS = ["internal", "server", "client", "producer", "consumer"];
2142
2157
  class Failure extends Error {
2143
2158
  error;
@@ -2464,7 +2479,7 @@ var decodeMetric = message((f, path) => {
2464
2479
  throw new Failure(failure(`${path}.sum`, "a sum, a gauge or a histogram", undefined));
2465
2480
  });
2466
2481
 
2467
- // ../ts/kernel/signals.ts
2482
+ // ../telemetry/src/signals.ts
2468
2483
  var ATTRIBUTE_TYPES = new Set([
2469
2484
  "string",
2470
2485
  "boolean",
@@ -2496,57 +2511,12 @@ function defineSignals(kinds) {
2496
2511
  return { kinds };
2497
2512
  }
2498
2513
 
2499
- // ../ts/runtime/otel.ts
2500
- var RETRYABLE_STATUSES = new Set([429, 502, 503, 504]);
2501
- var DAY_MS = 24 * 60 * 60 * 1000;
2502
- var RUNTIME_SIGNALS = defineSignals({
2503
- process: {
2504
- signal: "span",
2505
- spanKind: "client",
2506
- role: "detail",
2507
- description: "A program run by proc: its name and option names alone (FR-006), and its exit status.",
2508
- attributes: { "process.executable.name": "string", "process.command_args": "string[]", "process.exit.code?": "int" }
2509
- },
2510
- "http.client": {
2511
- signal: "span",
2512
- spanKind: "client",
2513
- role: "detail",
2514
- description: "A request made by the HTTP client; the URL redacted (FR-006).",
2515
- attributes: {
2516
- "http.request.method": "string",
2517
- "url.full": "string",
2518
- "server.address": "string",
2519
- "server.port?": "int",
2520
- "http.response.status_code?": "int",
2521
- "error.type?": "string"
2522
- }
2523
- },
2524
- "http.server": {
2525
- signal: "span",
2526
- spanKind: "server",
2527
- role: "detail",
2528
- description: "A request answered by serve; its parent is the request's traceparent.",
2529
- attributes: {
2530
- "http.request.method": "string",
2531
- "url.path": "string",
2532
- "url.scheme": "string",
2533
- "server.address?": "string",
2534
- "server.port?": "int",
2535
- "http.response.status_code?": "int"
2536
- }
2537
- },
2538
- "otel.warning": {
2539
- signal: "log",
2540
- severity: SEVERITY.WARN,
2541
- role: "none",
2542
- description: "Signals were not sent: an export failed, no collector answered, or the wait at exit ran out.",
2543
- attributes: {}
2544
- }
2545
- });
2546
- var UNTRACED = new WeakSet;
2547
-
2548
- // ../ts/runtime/proc.ts
2514
+ // ../system/src/proc.ts
2549
2515
  import process from "node:process";
2516
+ var tracer;
2517
+ function setProcessTracer(t) {
2518
+ tracer = t;
2519
+ }
2550
2520
  var args = Object.freeze(process.argv.slice(2));
2551
2521
  var pid = process.pid;
2552
2522
  function osOf(platform) {
@@ -2609,6 +2579,74 @@ var build = Object.freeze({
2609
2579
  target: tripleOf(osOf(process.platform), archOf(process.arch))
2610
2580
  });
2611
2581
 
2582
+ // ../telemetry/src/host/otel.ts
2583
+ var RETRYABLE_STATUSES = new Set([429, 502, 503, 504]);
2584
+ var DAY_MS = 24 * 60 * 60 * 1000;
2585
+ var RUNTIME_SIGNALS = defineSignals({
2586
+ process: {
2587
+ signal: "span",
2588
+ spanKind: "client",
2589
+ role: "detail",
2590
+ description: "A program run by proc: its name and option names alone (FR-006), and its exit status.",
2591
+ attributes: { "process.executable.name": "string", "process.command_args": "string[]", "process.exit.code?": "int" }
2592
+ },
2593
+ "http.client": {
2594
+ signal: "span",
2595
+ spanKind: "client",
2596
+ role: "detail",
2597
+ description: "A request made by the HTTP client; the URL redacted (FR-006).",
2598
+ attributes: {
2599
+ "http.request.method": "string",
2600
+ "url.full": "string",
2601
+ "server.address": "string",
2602
+ "server.port?": "int",
2603
+ "http.response.status_code?": "int",
2604
+ "error.type?": "string"
2605
+ }
2606
+ },
2607
+ "http.server": {
2608
+ signal: "span",
2609
+ spanKind: "server",
2610
+ role: "detail",
2611
+ description: "A request answered by serve; its parent is the request's traceparent.",
2612
+ attributes: {
2613
+ "http.request.method": "string",
2614
+ "url.path": "string",
2615
+ "url.scheme": "string",
2616
+ "server.address?": "string",
2617
+ "server.port?": "int",
2618
+ "http.response.status_code?": "int"
2619
+ }
2620
+ },
2621
+ "otel.warning": {
2622
+ signal: "log",
2623
+ severity: SEVERITY.WARN,
2624
+ role: "none",
2625
+ description: "Signals were not sent: an export failed, no collector answered, or the wait at exit ran out.",
2626
+ attributes: {}
2627
+ }
2628
+ });
2629
+ var current;
2630
+ function carried(r) {
2631
+ return r.kind === "ok" ? r.value : r.error.value;
2632
+ }
2633
+ function traceProcess(argv, run) {
2634
+ const c = current;
2635
+ if (c === undefined)
2636
+ return run({});
2637
+ const shape = commandShape(argv);
2638
+ return c.runtime.span("process", { "process.executable.name": shape[0] ?? "", "process.command_args": shape }, async (span) => {
2639
+ const env = { TRACEPARENT: span.traceparent };
2640
+ if (span.tracestate !== "")
2641
+ env["TRACESTATE"] = span.tracestate;
2642
+ const r = await run(env);
2643
+ span.set({ "process.exit.code": r.code });
2644
+ return r.code === 0 ? ok(r) : err({ value: r, message: `${shape[0] ?? "the program"} exited with ${r.code}` });
2645
+ }).then(carried);
2646
+ }
2647
+ setProcessTracer(traceProcess);
2648
+ var UNTRACED = new WeakSet;
2649
+
2612
2650
  // ../ts/runtime/http-client.ts
2613
2651
  var exchangeDecoder = object({
2614
2652
  method: literal("GET", "HEAD", "POST", "PUT", "PATCH", "DELETE"),
@@ -14,7 +14,7 @@ import { type Sha256 } from "@intellectual-frontiers/crypto";
14
14
  import { type Finding } from "./findings.js";
15
15
  import { type GeneratedFile } from "./render.js";
16
16
  /** The version of Ergonex the record names. */
17
- export declare const ERGONEX_VERSION = "0.3.2";
17
+ export declare const ERGONEX_VERSION = "0.3.4";
18
18
  /** Where the state record is, below the root. */
19
19
  export declare const STATE_RECORD_PATH = ".ergonex/state.auto.json";
20
20
  /** One generated file as it was written. */