netra-sdk 1.0.4 → 1.0.6

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/index.cjs CHANGED
@@ -18515,6 +18515,8 @@ var Measure = /* @__PURE__ */ ((Measure2) => {
18515
18515
  Measure2["TOTAL_COST"] = "Total Cost";
18516
18516
  Measure2["VIOLATIONS"] = "Violations";
18517
18517
  Measure2["TOTAL_TOKENS"] = "Total Tokens";
18518
+ Measure2["AUDIO_DURATION"] = "Audio Duration";
18519
+ Measure2["CHARACTER_COUNT"] = "Character Count";
18518
18520
  return Measure2;
18519
18521
  })(Measure || {});
18520
18522
  var Aggregation = /* @__PURE__ */ ((Aggregation2) => {
@@ -27427,6 +27429,67 @@ var Simulation = class {
27427
27429
  }
27428
27430
  }
27429
27431
  };
27432
+
27433
+ // src/api/prompts/client.ts
27434
+ var PromptsHttpClient = class extends NetraHttpClient {
27435
+ constructor(config2) {
27436
+ super(config2, "NETRA_PROMPTS_TIMEOUT", 30);
27437
+ }
27438
+ /**
27439
+ * Fetch prompt version from backend
27440
+ */
27441
+ async getPromptVersion(name, label) {
27442
+ if (!this.isInitialized()) {
27443
+ console.error(
27444
+ "netra.prompts: Prompts client is not initialized; cannot fetch prompt"
27445
+ );
27446
+ return null;
27447
+ }
27448
+ try {
27449
+ const payload = {
27450
+ promptName: name,
27451
+ label
27452
+ };
27453
+ const response = await this.post("/sdk/prompts/version", payload);
27454
+ if (!response.ok) {
27455
+ const errorMessage = response.data?.error?.message ?? "Unknown error";
27456
+ console.error(`netra.prompts: Failed to fetch prompt: ${errorMessage}`);
27457
+ return null;
27458
+ }
27459
+ return response.data;
27460
+ } catch (err) {
27461
+ const message = err?.response?.data?.error?.message ?? "";
27462
+ console.error("netra.prompts: Failed to fetch prompt:", message);
27463
+ return null;
27464
+ }
27465
+ }
27466
+ };
27467
+
27468
+ // src/api/prompts/api.ts
27469
+ var Prompts = class {
27470
+ constructor(config2) {
27471
+ this.config = config2;
27472
+ this.client = new PromptsHttpClient(config2);
27473
+ }
27474
+ /**
27475
+ * Fetch prompt version by name and label.
27476
+ *
27477
+ * @param params.name - Name of the prompt (required)
27478
+ * @param params.label - Label of the prompt version (default: "production")
27479
+ */
27480
+ async getPrompt(params) {
27481
+ if (!params || typeof params.name !== "string" || !params.name) {
27482
+ console.error("netra.prompts: name is required to fetch a prompt");
27483
+ return null;
27484
+ }
27485
+ const label = params.label ?? "production";
27486
+ const result = await this.client.getPromptVersion(params.name, label);
27487
+ if (!result) {
27488
+ return null;
27489
+ }
27490
+ return result.data ?? null;
27491
+ }
27492
+ };
27430
27493
  function serializeValue(value) {
27431
27494
  try {
27432
27495
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null || value === void 0) {
@@ -27677,6 +27740,7 @@ var Netra = class {
27677
27740
  this.evaluation = new Evaluation(cfg);
27678
27741
  this.dashboard = new Dashboard(cfg);
27679
27742
  this.simulation = new Simulation(cfg);
27743
+ this.prompts = new Prompts(cfg);
27680
27744
  this._initialized = true;
27681
27745
  console.info("Netra successfully initialized.");
27682
27746
  if (cfg.debugMode) {
@@ -27983,6 +28047,7 @@ exports.Measure = Measure;
27983
28047
  exports.Netra = Netra;
27984
28048
  exports.NetraInstruments = NetraInstruments;
27985
28049
  exports.Operator = Operator;
28050
+ exports.Prompts = Prompts;
27986
28051
  exports.RunEntryContext = RunEntryContext;
27987
28052
  exports.RunStatus = RunStatus;
27988
28053
  exports.Scope = Scope;