opsveritas-sdk 0.4.2 → 0.4.3

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.js CHANGED
@@ -154,6 +154,7 @@ async function run(agentName, fn, opts) {
154
154
  const totalCost = ctx.calls.reduce((s, c) => s + (c.costUsd ?? 0), 0);
155
155
  const models = [...new Set(ctx.calls.map((c) => c.model).filter((m) => !!m))];
156
156
  const platform = ctx.calls[0]?.platform ?? "custom_webhook";
157
+ const outputSummary = [...ctx.calls].reverse().find((c) => c.outputSummary)?.outputSummary;
157
158
  const payload = {
158
159
  platform,
159
160
  agent_name: agentName,
@@ -167,6 +168,7 @@ async function run(agentName, fn, opts) {
167
168
  if (totalCost) payload.cost_usd = Math.round(totalCost * 1e6) / 1e6;
168
169
  if (models.length) payload.models = models;
169
170
  if (ctx.userId) payload.user_id = ctx.userId;
171
+ if (outputSummary) payload.output_summary = outputSummary;
170
172
  void sendExecution(payload);
171
173
  }
172
174
  });
@@ -471,7 +473,7 @@ function patchOpenAI(client, opts) {
471
473
  const cost_usd = model && input_tokens != null && output_tokens != null ? calcCost(String(model), input_tokens, output_tokens) : void 0;
472
474
  const activeRun = getActiveRun();
473
475
  if (activeRun) {
474
- activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: model ? String(model) : void 0, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage });
476
+ activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: model ? String(model) : void 0, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage, outputSummary: extractOutput(resp) });
475
477
  } else {
476
478
  void sendExecution({
477
479
  platform: opts.platform ?? "custom_webhook",
@@ -523,7 +525,7 @@ function patchAnthropic(client, opts) {
523
525
  const cost_usd = model && input_tokens != null && output_tokens != null ? calcCost(String(model), input_tokens, output_tokens) : void 0;
524
526
  const activeRun = getActiveRun();
525
527
  if (activeRun) {
526
- activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: model ? String(model) : void 0, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage });
528
+ activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: model ? String(model) : void 0, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage, outputSummary: extractOutput(resp) });
527
529
  } else {
528
530
  void sendExecution({
529
531
  platform: opts.platform ?? "custom_webhook",
@@ -573,7 +575,7 @@ function patchGemini(client, opts) {
573
575
  const cost_usd = modelName && input_tokens != null && output_tokens != null ? calcCost(modelName, input_tokens, output_tokens) : void 0;
574
576
  const activeRun = getActiveRun();
575
577
  if (activeRun) {
576
- activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: modelName, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage });
578
+ activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: modelName, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage, outputSummary: extractOutput(resp) });
577
579
  } else {
578
580
  void sendExecution({
579
581
  platform: opts.platform ?? "custom_webhook",
@@ -677,7 +679,16 @@ function langchain(agentName, opts = {}) {
677
679
  const cost_usd = model && inputTokens != null && outputTokens != null ? calcCost(model, inputTokens, outputTokens) : void 0;
678
680
  const activeRun = getActiveRun();
679
681
  if (activeRun) {
680
- activeRun.calls.push({ platform, model, inputTokens, outputTokens, costUsd: cost_usd, status });
682
+ activeRun.calls.push({
683
+ platform,
684
+ model,
685
+ inputTokens,
686
+ outputTokens,
687
+ costUsd: cost_usd,
688
+ status,
689
+ errorMessage,
690
+ outputSummary: output ? extractText(output) : void 0
691
+ });
681
692
  } else {
682
693
  void sendExecution({
683
694
  platform,
package/dist/index.mjs CHANGED
@@ -120,6 +120,7 @@ async function run(agentName, fn, opts) {
120
120
  const totalCost = ctx.calls.reduce((s, c) => s + (c.costUsd ?? 0), 0);
121
121
  const models = [...new Set(ctx.calls.map((c) => c.model).filter((m) => !!m))];
122
122
  const platform = ctx.calls[0]?.platform ?? "custom_webhook";
123
+ const outputSummary = [...ctx.calls].reverse().find((c) => c.outputSummary)?.outputSummary;
123
124
  const payload = {
124
125
  platform,
125
126
  agent_name: agentName,
@@ -133,6 +134,7 @@ async function run(agentName, fn, opts) {
133
134
  if (totalCost) payload.cost_usd = Math.round(totalCost * 1e6) / 1e6;
134
135
  if (models.length) payload.models = models;
135
136
  if (ctx.userId) payload.user_id = ctx.userId;
137
+ if (outputSummary) payload.output_summary = outputSummary;
136
138
  void sendExecution(payload);
137
139
  }
138
140
  });
@@ -437,7 +439,7 @@ function patchOpenAI(client, opts) {
437
439
  const cost_usd = model && input_tokens != null && output_tokens != null ? calcCost(String(model), input_tokens, output_tokens) : void 0;
438
440
  const activeRun = getActiveRun();
439
441
  if (activeRun) {
440
- activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: model ? String(model) : void 0, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage });
442
+ activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: model ? String(model) : void 0, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage, outputSummary: extractOutput(resp) });
441
443
  } else {
442
444
  void sendExecution({
443
445
  platform: opts.platform ?? "custom_webhook",
@@ -489,7 +491,7 @@ function patchAnthropic(client, opts) {
489
491
  const cost_usd = model && input_tokens != null && output_tokens != null ? calcCost(String(model), input_tokens, output_tokens) : void 0;
490
492
  const activeRun = getActiveRun();
491
493
  if (activeRun) {
492
- activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: model ? String(model) : void 0, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage });
494
+ activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: model ? String(model) : void 0, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage, outputSummary: extractOutput(resp) });
493
495
  } else {
494
496
  void sendExecution({
495
497
  platform: opts.platform ?? "custom_webhook",
@@ -539,7 +541,7 @@ function patchGemini(client, opts) {
539
541
  const cost_usd = modelName && input_tokens != null && output_tokens != null ? calcCost(modelName, input_tokens, output_tokens) : void 0;
540
542
  const activeRun = getActiveRun();
541
543
  if (activeRun) {
542
- activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: modelName, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage });
544
+ activeRun.calls.push({ platform: opts.platform ?? "custom_webhook", model: modelName, inputTokens: input_tokens, outputTokens: output_tokens, costUsd: cost_usd, status, errorMessage, outputSummary: extractOutput(resp) });
543
545
  } else {
544
546
  void sendExecution({
545
547
  platform: opts.platform ?? "custom_webhook",
@@ -643,7 +645,16 @@ function langchain(agentName, opts = {}) {
643
645
  const cost_usd = model && inputTokens != null && outputTokens != null ? calcCost(model, inputTokens, outputTokens) : void 0;
644
646
  const activeRun = getActiveRun();
645
647
  if (activeRun) {
646
- activeRun.calls.push({ platform, model, inputTokens, outputTokens, costUsd: cost_usd, status });
648
+ activeRun.calls.push({
649
+ platform,
650
+ model,
651
+ inputTokens,
652
+ outputTokens,
653
+ costUsd: cost_usd,
654
+ status,
655
+ errorMessage,
656
+ outputSummary: output ? extractText(output) : void 0
657
+ });
647
658
  } else {
648
659
  void sendExecution({
649
660
  platform,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opsveritas-sdk",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "Monitor your AI agents in 3 lines of code — tokens, cost, latency, and silent failures",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",