@intelli-1113/stratos-sdk 1.2.2 → 1.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +18 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intelli-1113/stratos-sdk",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "One install for Stratos AI: OpenLLMetry agent telemetry (--import) AND the stratos-mcp-proxy for MCP servers.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -48,7 +48,8 @@ function detectFramework() {
48
48
  // Best-effort model from common env vars (or opts.model). Spans still refine it.
49
49
  function detectModel(opts) {
50
50
  return opts.model || process.env.STRATOS_MODEL || process.env.NVIDIA_MODEL || process.env.OPENAI_MODEL
51
- || process.env.ANTHROPIC_MODEL || process.env.LLM_MODEL || process.env.MODEL || null;
51
+ || process.env.ANTHROPIC_MODEL || process.env.GEMINI_MODEL || process.env.GOOGLE_MODEL
52
+ || process.env.LLM_MODEL || process.env.MODEL || null;
52
53
  }
53
54
 
54
55
  let started = false;
@@ -91,6 +92,22 @@ export function start(opts = {}) {
91
92
  ping();
92
93
  if (heartbeatMs > 0) setInterval(ping, heartbeatMs).unref();
93
94
 
95
+ // disableBatch exports each span the moment it ends via an async HTTP POST —
96
+ // fine for long-running servers, but a one-shot script (no open server/handle)
97
+ // drains the event loop and exits the instant it's done, killing that request
98
+ // mid-flight before it reaches Stratos. 'beforeExit' fires exactly at that point
99
+ // (and, unlike 'exit', still lets us start async work), so flushing there makes
100
+ // every consumer — script or server — deliver its spans with zero code changes.
101
+ process.on("beforeExit", () => {
102
+ traceloop.forceFlush().catch(() => {});
103
+ });
104
+ // Also flush on Ctrl+C / kill so a killed server doesn't lose its last spans.
105
+ for (const sig of ["SIGINT", "SIGTERM"]) {
106
+ process.on(sig, () => {
107
+ traceloop.forceFlush().finally(() => process.exit(0));
108
+ });
109
+ }
110
+
94
111
  console.log(`[stratos] telemetry → ${ingest} (heartbeat ${heartbeatMs}ms, framework=${meta.framework || "?"})`);
95
112
  }
96
113