@morphllm/morphsdk 0.2.173 → 0.2.175
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/{chunk-C3V5FHZI.js → chunk-2SHUV3AB.js} +2 -2
- package/dist/{chunk-JXJBF6CV.js → chunk-2WC7TSEL.js} +2 -2
- package/dist/{chunk-5RTWSAZ6.js → chunk-3TWDAXXO.js} +2 -2
- package/dist/{chunk-S5R4H5HM.js → chunk-4MNI34G7.js} +2 -2
- package/dist/{chunk-SM3OQZRS.js → chunk-4NTL6M55.js} +3 -3
- package/dist/{chunk-FN4ADWFQ.js → chunk-5HNJNDDQ.js} +2 -2
- package/dist/{chunk-GESRH23M.js → chunk-AWBZNBAD.js} +2 -2
- package/dist/{chunk-33ZRF6X3.js → chunk-BQ52QYAU.js} +2 -2
- package/dist/chunk-CABQ652L.js +42 -0
- package/dist/chunk-CABQ652L.js.map +1 -0
- package/dist/{chunk-QE6JHRVD.js → chunk-CBIXYMY2.js} +2 -2
- package/dist/{chunk-577P2AXE.js → chunk-D6C7K7T7.js} +2 -2
- package/dist/{chunk-ZFOR3LI4.js → chunk-DB4C63ND.js} +2 -2
- package/dist/{chunk-CEZQSARX.js → chunk-EYXMABTT.js} +2 -2
- package/dist/{chunk-W6AGNJ5O.js → chunk-FGSPSUZA.js} +3 -3
- package/dist/{chunk-MQTMT4OR.js → chunk-GFPOP6ZY.js} +2 -2
- package/dist/{chunk-TW3XQET2.js → chunk-GGGHLBME.js} +2 -2
- package/dist/{chunk-EJ2CQO4V.js → chunk-GIQZQM3I.js} +2 -2
- package/dist/{chunk-3I4LCNWJ.js → chunk-GMIXIA7W.js} +2 -2
- package/dist/{chunk-Z3KRXUNG.js → chunk-HBE26KJG.js} +2 -2
- package/dist/{chunk-I4FCFIBU.js → chunk-I5PAAUJW.js} +4 -4
- package/dist/{chunk-QCFHQPHC.js → chunk-ICA7P5TD.js} +6 -6
- package/dist/{chunk-RXCHMNCY.js → chunk-ICFZAOSH.js} +2 -2
- package/dist/{chunk-ACWLQFYS.js → chunk-IRBMNRZC.js} +10 -10
- package/dist/{chunk-TS56XYWB.js → chunk-JOBCDCRP.js} +3 -3
- package/dist/chunk-KRTQESOL.js +143 -0
- package/dist/chunk-KRTQESOL.js.map +1 -0
- package/dist/{chunk-VLZ6PNAD.js → chunk-LN7GNFET.js} +7 -7
- package/dist/{chunk-AZOSA7VT.js → chunk-LPXMSR5E.js} +2 -2
- package/dist/{chunk-73DQQMGR.js → chunk-OHF5K3HA.js} +17 -3
- package/dist/chunk-OHF5K3HA.js.map +1 -0
- package/dist/chunk-PICGNBUE.js +35 -0
- package/dist/chunk-PICGNBUE.js.map +1 -0
- package/dist/{chunk-3GNXTHHB.js → chunk-TNNLID5P.js} +2 -2
- package/dist/{chunk-NBKL7VWX.js → chunk-TPGWVT3F.js} +30 -30
- package/dist/{chunk-7EUJ2AKS.js → chunk-TVZ5QVUV.js} +2 -2
- package/dist/{chunk-CV7SLK6R.js → chunk-TY2GIOLP.js} +2 -2
- package/dist/{chunk-QE3SPHIM.js → chunk-XRYUQSUC.js} +4 -4
- package/dist/{chunk-YGNPVOUO.js → chunk-Y5AZ6FOQ.js} +3 -3
- package/dist/chunk-ZCEDWXQV.js +134 -0
- package/dist/chunk-ZCEDWXQV.js.map +1 -0
- package/dist/client.cjs +16 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +32 -32
- package/dist/core/client.cjs +16 -2
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.js +4 -4
- package/dist/core/error.cjs +16 -2
- package/dist/core/error.cjs.map +1 -1
- package/dist/core/error.js +3 -3
- package/dist/core/index.cjs +16 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +4 -4
- package/dist/edge.cjs +16 -2
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.js +7 -7
- package/dist/git/client.cjs +16 -2
- package/dist/git/client.cjs.map +1 -1
- package/dist/git/client.js +5 -5
- package/dist/git/index.cjs +16 -2
- package/dist/git/index.cjs.map +1 -1
- package/dist/git/index.js +5 -5
- package/dist/index.cjs +16 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -37
- package/dist/modelrouter/core.cjs +16 -2
- package/dist/modelrouter/core.cjs.map +1 -1
- package/dist/modelrouter/core.js +5 -5
- package/dist/modelrouter/index.cjs +16 -2
- package/dist/modelrouter/index.cjs.map +1 -1
- package/dist/modelrouter/index.js +5 -5
- package/dist/otel-Dk8kdhmZ.d.ts +42 -0
- package/dist/subagents/anthropic.cjs +16 -2
- package/dist/subagents/anthropic.cjs.map +1 -1
- package/dist/subagents/anthropic.js +11 -11
- package/dist/subagents/vercel.cjs +16 -2
- package/dist/subagents/vercel.cjs.map +1 -1
- package/dist/subagents/vercel.js +11 -11
- package/dist/tools/browser/anthropic.cjs +16 -2
- package/dist/tools/browser/anthropic.cjs.map +1 -1
- package/dist/tools/browser/anthropic.js +8 -8
- package/dist/tools/browser/core.cjs +16 -2
- package/dist/tools/browser/core.cjs.map +1 -1
- package/dist/tools/browser/core.js +7 -7
- package/dist/tools/browser/index.cjs +16 -2
- package/dist/tools/browser/index.cjs.map +1 -1
- package/dist/tools/browser/index.js +15 -15
- package/dist/tools/browser/openai.cjs +16 -2
- package/dist/tools/browser/openai.cjs.map +1 -1
- package/dist/tools/browser/openai.js +8 -8
- package/dist/tools/browser/profiles/core.cjs +16 -2
- package/dist/tools/browser/profiles/core.cjs.map +1 -1
- package/dist/tools/browser/profiles/core.js +3 -3
- package/dist/tools/browser/profiles/index.cjs +16 -2
- package/dist/tools/browser/profiles/index.cjs.map +1 -1
- package/dist/tools/browser/profiles/index.js +3 -3
- package/dist/tools/browser/vercel.cjs +16 -2
- package/dist/tools/browser/vercel.cjs.map +1 -1
- package/dist/tools/browser/vercel.js +8 -8
- package/dist/tools/codebase_search/anthropic.cjs +16 -2
- package/dist/tools/codebase_search/anthropic.cjs.map +1 -1
- package/dist/tools/codebase_search/anthropic.js +6 -6
- package/dist/tools/codebase_search/core.cjs +16 -2
- package/dist/tools/codebase_search/core.cjs.map +1 -1
- package/dist/tools/codebase_search/core.js +5 -5
- package/dist/tools/codebase_search/index.cjs +16 -2
- package/dist/tools/codebase_search/index.cjs.map +1 -1
- package/dist/tools/codebase_search/index.js +10 -10
- package/dist/tools/codebase_search/openai.cjs +16 -2
- package/dist/tools/codebase_search/openai.cjs.map +1 -1
- package/dist/tools/codebase_search/openai.js +6 -6
- package/dist/tools/codebase_search/vercel.cjs +16 -2
- package/dist/tools/codebase_search/vercel.cjs.map +1 -1
- package/dist/tools/codebase_search/vercel.js +6 -6
- package/dist/tools/compact/core.cjs +16 -2
- package/dist/tools/compact/core.cjs.map +1 -1
- package/dist/tools/compact/core.js +5 -5
- package/dist/tools/compact/index.cjs +16 -2
- package/dist/tools/compact/index.cjs.map +1 -1
- package/dist/tools/compact/index.js +6 -6
- package/dist/tools/fastapply/anthropic.cjs +16 -2
- package/dist/tools/fastapply/anthropic.cjs.map +1 -1
- package/dist/tools/fastapply/anthropic.js +7 -7
- package/dist/tools/fastapply/apply.cjs +16 -2
- package/dist/tools/fastapply/apply.cjs.map +1 -1
- package/dist/tools/fastapply/apply.js +2 -2
- package/dist/tools/fastapply/core.cjs +16 -2
- package/dist/tools/fastapply/core.cjs.map +1 -1
- package/dist/tools/fastapply/core.js +6 -6
- package/dist/tools/fastapply/index.cjs +16 -2
- package/dist/tools/fastapply/index.cjs.map +1 -1
- package/dist/tools/fastapply/index.js +11 -11
- package/dist/tools/fastapply/openai.cjs +16 -2
- package/dist/tools/fastapply/openai.cjs.map +1 -1
- package/dist/tools/fastapply/openai.js +7 -7
- package/dist/tools/fastapply/vercel.cjs +16 -2
- package/dist/tools/fastapply/vercel.cjs.map +1 -1
- package/dist/tools/fastapply/vercel.js +7 -7
- package/dist/tools/index.cjs +16 -2
- package/dist/tools/index.cjs.map +1 -1
- package/dist/tools/index.js +11 -11
- package/dist/tools/reflex/core.cjs +16 -2
- package/dist/tools/reflex/core.cjs.map +1 -1
- package/dist/tools/reflex/core.js +5 -5
- package/dist/tools/reflex/index.cjs +16 -2
- package/dist/tools/reflex/index.cjs.map +1 -1
- package/dist/tools/reflex/index.js +5 -5
- package/dist/tools/utils/resilience.cjs +16 -2
- package/dist/tools/utils/resilience.cjs.map +1 -1
- package/dist/tools/utils/resilience.js +2 -2
- package/dist/tools/warp_grep/agent/runner.cjs +16 -2
- package/dist/tools/warp_grep/agent/runner.cjs.map +1 -1
- package/dist/tools/warp_grep/agent/runner.js +3 -3
- package/dist/tools/warp_grep/anthropic.cjs +16 -2
- package/dist/tools/warp_grep/anthropic.cjs.map +1 -1
- package/dist/tools/warp_grep/anthropic.js +11 -11
- package/dist/tools/warp_grep/client.cjs +16 -2
- package/dist/tools/warp_grep/client.cjs.map +1 -1
- package/dist/tools/warp_grep/client.js +10 -10
- package/dist/tools/warp_grep/gemini.cjs +16 -2
- package/dist/tools/warp_grep/gemini.cjs.map +1 -1
- package/dist/tools/warp_grep/gemini.js +10 -10
- package/dist/tools/warp_grep/harness.js +6 -6
- package/dist/tools/warp_grep/index.cjs +16 -2
- package/dist/tools/warp_grep/index.cjs.map +1 -1
- package/dist/tools/warp_grep/index.js +16 -16
- package/dist/tools/warp_grep/openai.cjs +16 -2
- package/dist/tools/warp_grep/openai.cjs.map +1 -1
- package/dist/tools/warp_grep/openai.js +11 -11
- package/dist/tools/warp_grep/providers/local.js +2 -2
- package/dist/tools/warp_grep/vercel.cjs +16 -2
- package/dist/tools/warp_grep/vercel.cjs.map +1 -1
- package/dist/tools/warp_grep/vercel.js +11 -11
- package/dist/tracing/core.cjs +355 -0
- package/dist/tracing/core.cjs.map +1 -0
- package/dist/tracing/core.d.ts +50 -0
- package/dist/tracing/core.js +13 -0
- package/dist/tracing/core.js.map +1 -0
- package/dist/tracing/index.cjs +367 -0
- package/dist/tracing/index.cjs.map +1 -0
- package/dist/tracing/index.d.ts +5 -0
- package/dist/tracing/index.js +18 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/tracing/interaction.cjs +192 -0
- package/dist/tracing/interaction.cjs.map +1 -0
- package/dist/tracing/interaction.d.ts +31 -0
- package/dist/tracing/interaction.js +9 -0
- package/dist/tracing/interaction.js.map +1 -0
- package/dist/tracing/otel.cjs +56 -0
- package/dist/tracing/otel.cjs.map +1 -0
- package/dist/tracing/otel.d.ts +2 -0
- package/dist/tracing/otel.js +10 -0
- package/dist/tracing/otel.js.map +1 -0
- package/dist/tracing/signals.cjs +59 -0
- package/dist/tracing/signals.cjs.map +1 -0
- package/dist/tracing/signals.d.ts +13 -0
- package/dist/tracing/signals.js +8 -0
- package/dist/tracing/signals.js.map +1 -0
- package/dist/tracing/types.cjs +19 -0
- package/dist/tracing/types.cjs.map +1 -0
- package/dist/tracing/types.d.ts +136 -0
- package/dist/tracing/types.js +1 -0
- package/dist/tracing/types.js.map +1 -0
- package/dist/version.cjs +16 -2
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +16 -2
- package/dist/chunk-73DQQMGR.js.map +0 -1
- /package/dist/{chunk-C3V5FHZI.js.map → chunk-2SHUV3AB.js.map} +0 -0
- /package/dist/{chunk-JXJBF6CV.js.map → chunk-2WC7TSEL.js.map} +0 -0
- /package/dist/{chunk-5RTWSAZ6.js.map → chunk-3TWDAXXO.js.map} +0 -0
- /package/dist/{chunk-S5R4H5HM.js.map → chunk-4MNI34G7.js.map} +0 -0
- /package/dist/{chunk-SM3OQZRS.js.map → chunk-4NTL6M55.js.map} +0 -0
- /package/dist/{chunk-FN4ADWFQ.js.map → chunk-5HNJNDDQ.js.map} +0 -0
- /package/dist/{chunk-GESRH23M.js.map → chunk-AWBZNBAD.js.map} +0 -0
- /package/dist/{chunk-33ZRF6X3.js.map → chunk-BQ52QYAU.js.map} +0 -0
- /package/dist/{chunk-QE6JHRVD.js.map → chunk-CBIXYMY2.js.map} +0 -0
- /package/dist/{chunk-577P2AXE.js.map → chunk-D6C7K7T7.js.map} +0 -0
- /package/dist/{chunk-ZFOR3LI4.js.map → chunk-DB4C63ND.js.map} +0 -0
- /package/dist/{chunk-CEZQSARX.js.map → chunk-EYXMABTT.js.map} +0 -0
- /package/dist/{chunk-W6AGNJ5O.js.map → chunk-FGSPSUZA.js.map} +0 -0
- /package/dist/{chunk-MQTMT4OR.js.map → chunk-GFPOP6ZY.js.map} +0 -0
- /package/dist/{chunk-TW3XQET2.js.map → chunk-GGGHLBME.js.map} +0 -0
- /package/dist/{chunk-EJ2CQO4V.js.map → chunk-GIQZQM3I.js.map} +0 -0
- /package/dist/{chunk-3I4LCNWJ.js.map → chunk-GMIXIA7W.js.map} +0 -0
- /package/dist/{chunk-Z3KRXUNG.js.map → chunk-HBE26KJG.js.map} +0 -0
- /package/dist/{chunk-I4FCFIBU.js.map → chunk-I5PAAUJW.js.map} +0 -0
- /package/dist/{chunk-QCFHQPHC.js.map → chunk-ICA7P5TD.js.map} +0 -0
- /package/dist/{chunk-RXCHMNCY.js.map → chunk-ICFZAOSH.js.map} +0 -0
- /package/dist/{chunk-ACWLQFYS.js.map → chunk-IRBMNRZC.js.map} +0 -0
- /package/dist/{chunk-TS56XYWB.js.map → chunk-JOBCDCRP.js.map} +0 -0
- /package/dist/{chunk-VLZ6PNAD.js.map → chunk-LN7GNFET.js.map} +0 -0
- /package/dist/{chunk-AZOSA7VT.js.map → chunk-LPXMSR5E.js.map} +0 -0
- /package/dist/{chunk-3GNXTHHB.js.map → chunk-TNNLID5P.js.map} +0 -0
- /package/dist/{chunk-NBKL7VWX.js.map → chunk-TPGWVT3F.js.map} +0 -0
- /package/dist/{chunk-7EUJ2AKS.js.map → chunk-TVZ5QVUV.js.map} +0 -0
- /package/dist/{chunk-CV7SLK6R.js.map → chunk-TY2GIOLP.js.map} +0 -0
- /package/dist/{chunk-QE3SPHIM.js.map → chunk-XRYUQSUC.js.map} +0 -0
- /package/dist/{chunk-YGNPVOUO.js.map → chunk-Y5AZ6FOQ.js.map} +0 -0
|
@@ -5,25 +5,25 @@ import {
|
|
|
5
5
|
execute,
|
|
6
6
|
vercel_default,
|
|
7
7
|
warpGrepJsonSchema
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-CBIXYMY2.js";
|
|
9
9
|
import "../../chunk-Q6QCHAMD.js";
|
|
10
10
|
import {
|
|
11
11
|
formatResult
|
|
12
|
-
} from "../../chunk-
|
|
13
|
-
import "../../chunk-63VHBANJ.js";
|
|
14
|
-
import "../../chunk-QCFHQPHC.js";
|
|
12
|
+
} from "../../chunk-IRBMNRZC.js";
|
|
15
13
|
import "../../chunk-GVGJIXV2.js";
|
|
16
14
|
import "../../chunk-A4D2CIIT.js";
|
|
15
|
+
import "../../chunk-63VHBANJ.js";
|
|
16
|
+
import "../../chunk-ICA7P5TD.js";
|
|
17
17
|
import "../../chunk-IA5K2HTC.js";
|
|
18
|
-
import "../../chunk-FBRNUWEB.js";
|
|
19
18
|
import "../../chunk-CCJK3HTG.js";
|
|
20
|
-
import "../../chunk-
|
|
21
|
-
import "../../chunk-
|
|
22
|
-
import "../../chunk-
|
|
19
|
+
import "../../chunk-FBRNUWEB.js";
|
|
20
|
+
import "../../chunk-GIQZQM3I.js";
|
|
21
|
+
import "../../chunk-JOBCDCRP.js";
|
|
22
|
+
import "../../chunk-XRYUQSUC.js";
|
|
23
23
|
import "../../chunk-F3NCFNUX.js";
|
|
24
|
-
import "../../chunk-
|
|
25
|
-
import "../../chunk-
|
|
26
|
-
import "../../chunk-
|
|
24
|
+
import "../../chunk-DB4C63ND.js";
|
|
25
|
+
import "../../chunk-2WC7TSEL.js";
|
|
26
|
+
import "../../chunk-OHF5K3HA.js";
|
|
27
27
|
import "../../chunk-LKFZBBTD.js";
|
|
28
28
|
import "../../chunk-PZ5AY32C.js";
|
|
29
29
|
export {
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// tracing/core.ts
|
|
31
|
+
var core_exports = {};
|
|
32
|
+
__export(core_exports, {
|
|
33
|
+
MorphTracing: () => MorphTracing,
|
|
34
|
+
morphTracing: () => morphTracing
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(core_exports);
|
|
37
|
+
var import_exporter_trace_otlp_http = require("@opentelemetry/exporter-trace-otlp-http");
|
|
38
|
+
var traceloop2 = __toESM(require("@traceloop/node-server-sdk"), 1);
|
|
39
|
+
|
|
40
|
+
// tracing/interaction.ts
|
|
41
|
+
var import_api = require("@opentelemetry/api");
|
|
42
|
+
var traceloop = __toESM(require("@traceloop/node-server-sdk"), 1);
|
|
43
|
+
|
|
44
|
+
// tracing/otel.ts
|
|
45
|
+
var RESERVED_KEYS = /* @__PURE__ */ new Set(["user_id", "convo_id", "event_id", "event_name"]);
|
|
46
|
+
function uuid() {
|
|
47
|
+
const c = globalThis.crypto;
|
|
48
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
49
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (ch) => {
|
|
50
|
+
const r = Math.random() * 16 | 0;
|
|
51
|
+
const v = ch === "x" ? r : r & 3 | 8;
|
|
52
|
+
return v.toString(16);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function metadata(opts) {
|
|
56
|
+
const result = {
|
|
57
|
+
user_id: opts.userId,
|
|
58
|
+
event_id: opts.eventId ?? uuid()
|
|
59
|
+
};
|
|
60
|
+
if (opts.convoId) result.convo_id = opts.convoId;
|
|
61
|
+
if (opts.eventName) result.event_name = opts.eventName;
|
|
62
|
+
if (opts.properties) {
|
|
63
|
+
for (const [key, value] of Object.entries(opts.properties)) {
|
|
64
|
+
if (!RESERVED_KEYS.has(key)) result[key] = value;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// tracing/interaction.ts
|
|
71
|
+
var ASSOC = "traceloop.association.properties.";
|
|
72
|
+
var ENTITY_INPUT = "traceloop.entity.input";
|
|
73
|
+
var ENTITY_OUTPUT = "traceloop.entity.output";
|
|
74
|
+
var ENTITY_NAME = "traceloop.entity.name";
|
|
75
|
+
var SPAN_KIND = "traceloop.span.kind";
|
|
76
|
+
function uuid2() {
|
|
77
|
+
const c = globalThis.crypto;
|
|
78
|
+
if (c?.randomUUID) return c.randomUUID();
|
|
79
|
+
return "xxxxxxxxxxxx4xxxyxxx".replace(/[xy]/g, (ch) => {
|
|
80
|
+
const r = Math.random() * 16 | 0;
|
|
81
|
+
return (ch === "x" ? r : r & 3 | 8).toString(16);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function asString(v) {
|
|
85
|
+
if (v == null) return "";
|
|
86
|
+
return typeof v === "string" ? v : JSON.stringify(v);
|
|
87
|
+
}
|
|
88
|
+
function associationProps(ctx, extra) {
|
|
89
|
+
const props = { ...extra };
|
|
90
|
+
if (ctx.userId) props.user_id = ctx.userId;
|
|
91
|
+
if (ctx.convoId) props.convo_id = ctx.convoId;
|
|
92
|
+
if (ctx.eventId) props.event_id = ctx.eventId;
|
|
93
|
+
if (ctx.event) props.event_name = ctx.event;
|
|
94
|
+
return props;
|
|
95
|
+
}
|
|
96
|
+
function createInteractionApi(initial, traceContent) {
|
|
97
|
+
const ctx = {
|
|
98
|
+
...initial,
|
|
99
|
+
eventId: initial.eventId ?? uuid2()
|
|
100
|
+
};
|
|
101
|
+
const properties = { ...initial.properties ?? {} };
|
|
102
|
+
let input = initial.input;
|
|
103
|
+
const withAssoc = (fn) => traceloop.withAssociationProperties(associationProps(ctx, properties), fn);
|
|
104
|
+
const toolName = (p) => typeof p === "string" ? p : p.name;
|
|
105
|
+
function startToolSpan(params) {
|
|
106
|
+
const name = toolName(params);
|
|
107
|
+
const span = traceloop.getTraceloopTracer().startSpan(name);
|
|
108
|
+
span.setAttribute(SPAN_KIND, "tool");
|
|
109
|
+
span.setAttribute(ENTITY_NAME, name);
|
|
110
|
+
for (const [k, v] of Object.entries(associationProps(ctx, properties))) {
|
|
111
|
+
span.setAttribute(ASSOC + k, v);
|
|
112
|
+
}
|
|
113
|
+
if (typeof params !== "string" && params.properties) {
|
|
114
|
+
for (const [k, v] of Object.entries(params.properties)) span.setAttribute(k, v);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
setInput(value) {
|
|
118
|
+
if (traceContent) span.setAttribute(ENTITY_INPUT, asString(value));
|
|
119
|
+
},
|
|
120
|
+
setOutput(value) {
|
|
121
|
+
if (traceContent) span.setAttribute(ENTITY_OUTPUT, asString(value));
|
|
122
|
+
},
|
|
123
|
+
setError(error) {
|
|
124
|
+
const e = typeof error === "string" ? new Error(error) : error;
|
|
125
|
+
span.recordException(e);
|
|
126
|
+
span.setStatus({ code: import_api.SpanStatusCode.ERROR, message: e.message });
|
|
127
|
+
},
|
|
128
|
+
end() {
|
|
129
|
+
span.end();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
getEventId: () => ctx.eventId,
|
|
135
|
+
setInput(value) {
|
|
136
|
+
input = value;
|
|
137
|
+
},
|
|
138
|
+
setProperty(key, value) {
|
|
139
|
+
properties[key] = value;
|
|
140
|
+
},
|
|
141
|
+
setProperties(props) {
|
|
142
|
+
Object.assign(properties, props);
|
|
143
|
+
},
|
|
144
|
+
vercelAiSdkMetadata() {
|
|
145
|
+
return metadata({
|
|
146
|
+
userId: ctx.userId ?? "unknown",
|
|
147
|
+
convoId: ctx.convoId,
|
|
148
|
+
eventName: ctx.event,
|
|
149
|
+
eventId: ctx.eventId,
|
|
150
|
+
properties
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
run(fn) {
|
|
154
|
+
return Promise.resolve(withAssoc(fn));
|
|
155
|
+
},
|
|
156
|
+
withSpan(params, fn) {
|
|
157
|
+
const name = typeof params === "string" ? params : params.name;
|
|
158
|
+
return Promise.resolve(withAssoc(() => traceloop.withTask({ name }, fn)));
|
|
159
|
+
},
|
|
160
|
+
withTool(params, fn) {
|
|
161
|
+
const name = toolName(params);
|
|
162
|
+
const version = typeof params === "string" ? void 0 : params.version;
|
|
163
|
+
return Promise.resolve(withAssoc(() => traceloop.withTool({ name, version }, fn)));
|
|
164
|
+
},
|
|
165
|
+
startToolSpan,
|
|
166
|
+
trackTool(params) {
|
|
167
|
+
const span = startToolSpan({ name: params.name, properties: params.properties });
|
|
168
|
+
if (params.input !== void 0) span.setInput(params.input);
|
|
169
|
+
if (params.output !== void 0) span.setOutput(params.output);
|
|
170
|
+
if (params.error) span.setError(params.error);
|
|
171
|
+
span.end();
|
|
172
|
+
},
|
|
173
|
+
async finish(opts) {
|
|
174
|
+
const output = typeof opts === "string" ? opts : opts.output;
|
|
175
|
+
if (typeof opts !== "string" && opts.properties) Object.assign(properties, opts.properties);
|
|
176
|
+
await Promise.resolve(
|
|
177
|
+
withAssoc(
|
|
178
|
+
() => traceloop.withTask({ name: ctx.event ?? "interaction" }, () => {
|
|
179
|
+
const span = traceloop.getTraceloopTracer().startSpan(ctx.event ?? "interaction");
|
|
180
|
+
span.setAttribute(SPAN_KIND, "workflow");
|
|
181
|
+
for (const [k, v] of Object.entries(associationProps(ctx, properties))) {
|
|
182
|
+
span.setAttribute(ASSOC + k, v);
|
|
183
|
+
}
|
|
184
|
+
if (traceContent && input) span.setAttribute(ENTITY_INPUT, input);
|
|
185
|
+
if (traceContent) span.setAttribute(ENTITY_OUTPUT, output);
|
|
186
|
+
span.end();
|
|
187
|
+
})
|
|
188
|
+
)
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// tracing/signals.ts
|
|
195
|
+
async function shipSignal(endpoint, apiKey, signals, debug = false, timeoutMs = 1e4) {
|
|
196
|
+
if (signals.length === 0) return;
|
|
197
|
+
const controller = new AbortController();
|
|
198
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
199
|
+
try {
|
|
200
|
+
const res = await fetch(endpoint, {
|
|
201
|
+
method: "POST",
|
|
202
|
+
headers: {
|
|
203
|
+
"Content-Type": "application/json",
|
|
204
|
+
Authorization: `Bearer ${apiKey}`
|
|
205
|
+
},
|
|
206
|
+
body: JSON.stringify({ signals }),
|
|
207
|
+
signal: controller.signal
|
|
208
|
+
});
|
|
209
|
+
if (!res.ok) {
|
|
210
|
+
const body = await res.text().catch(() => "");
|
|
211
|
+
console.warn(`[morph-tracing] signal POST failed (${res.status}): ${body}`);
|
|
212
|
+
} else if (debug) {
|
|
213
|
+
console.log(`[morph-tracing] shipped ${signals.length} signal(s)`);
|
|
214
|
+
}
|
|
215
|
+
} catch (err) {
|
|
216
|
+
console.warn(
|
|
217
|
+
"[morph-tracing] signal POST error:",
|
|
218
|
+
err instanceof Error ? err.message : err
|
|
219
|
+
);
|
|
220
|
+
} finally {
|
|
221
|
+
clearTimeout(timer);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// tracing/core.ts
|
|
226
|
+
var DEFAULT_BASE_URL = "https://api.morphllm.com";
|
|
227
|
+
function log(debug, ...args) {
|
|
228
|
+
if (debug) console.log("[morph-tracing]", ...args);
|
|
229
|
+
}
|
|
230
|
+
var MorphTracing = class {
|
|
231
|
+
cfg;
|
|
232
|
+
active = /* @__PURE__ */ new Map();
|
|
233
|
+
enabled;
|
|
234
|
+
constructor(config = {}) {
|
|
235
|
+
const debug = config.debug ?? process.env.MORPH_TRACING_DEBUG === "1";
|
|
236
|
+
const apiKey = config.apiKey ?? process.env.MORPH_API_KEY ?? "";
|
|
237
|
+
const baseUrlRaw = config.baseUrl ?? process.env.MORPH_TRACES_URL ?? DEFAULT_BASE_URL;
|
|
238
|
+
const baseUrl = baseUrlRaw.replace(/\/+$/, "");
|
|
239
|
+
const isProd = process.env.NODE_ENV === "production";
|
|
240
|
+
this.cfg = {
|
|
241
|
+
apiKey,
|
|
242
|
+
baseUrl,
|
|
243
|
+
signalsEndpoint: `${baseUrl}/v1/signals`,
|
|
244
|
+
appName: config.appName ?? process.env.npm_package_name ?? "morph-app",
|
|
245
|
+
disableBatching: config.disableBatching ?? !isProd,
|
|
246
|
+
traceContent: config.traceContent ?? true,
|
|
247
|
+
debug
|
|
248
|
+
};
|
|
249
|
+
if (config.disabled) {
|
|
250
|
+
log(debug, "disabled \u2014 no tracing initialized");
|
|
251
|
+
this.enabled = false;
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (!apiKey) {
|
|
255
|
+
console.warn(
|
|
256
|
+
"[morph-tracing] No API key (set MORPH_API_KEY or pass { apiKey }). Tracing disabled."
|
|
257
|
+
);
|
|
258
|
+
this.enabled = false;
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
this.enabled = true;
|
|
262
|
+
if (config.useExternalOtel) {
|
|
263
|
+
traceloop2.initialize({
|
|
264
|
+
baseUrl,
|
|
265
|
+
apiKey,
|
|
266
|
+
appName: this.cfg.appName,
|
|
267
|
+
tracingEnabled: false,
|
|
268
|
+
traceContent: this.cfg.traceContent,
|
|
269
|
+
silenceInitializationMessage: true
|
|
270
|
+
});
|
|
271
|
+
log(debug, "external OTEL mode \u2014 add createSpanProcessor() to your NodeSDK");
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const exporter = new import_exporter_trace_otlp_http.OTLPTraceExporter({
|
|
275
|
+
url: `${baseUrl}/v1/traces`,
|
|
276
|
+
headers: { Authorization: `Bearer ${apiKey}`, ...config.headers }
|
|
277
|
+
});
|
|
278
|
+
traceloop2.initialize({
|
|
279
|
+
baseUrl,
|
|
280
|
+
apiKey,
|
|
281
|
+
appName: this.cfg.appName,
|
|
282
|
+
exporter,
|
|
283
|
+
disableBatch: this.cfg.disableBatching,
|
|
284
|
+
traceContent: this.cfg.traceContent,
|
|
285
|
+
instrumentModules: config.instrumentModules,
|
|
286
|
+
tracingEnabled: true,
|
|
287
|
+
traceloopSyncEnabled: false,
|
|
288
|
+
silenceInitializationMessage: !debug
|
|
289
|
+
});
|
|
290
|
+
log(
|
|
291
|
+
debug,
|
|
292
|
+
`initialized \u2192 ${baseUrl}/v1/traces (batching ${this.cfg.disableBatching ? "off" : "on"})`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
/** Begin a new traced interaction (a single user turn / agent run). */
|
|
296
|
+
begin(ctx) {
|
|
297
|
+
const interaction = createInteractionApi(ctx, this.cfg.traceContent);
|
|
298
|
+
this.active.set(interaction.getEventId(), interaction);
|
|
299
|
+
return interaction;
|
|
300
|
+
}
|
|
301
|
+
/** Look up an in-flight interaction by its eventId. */
|
|
302
|
+
getActiveInteraction(eventId) {
|
|
303
|
+
return this.active.get(eventId);
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Non-interactive tracer for batch jobs where you only care about
|
|
307
|
+
* spans/token usage, not a user-facing interaction.
|
|
308
|
+
*/
|
|
309
|
+
tracer(globalProperties = {}) {
|
|
310
|
+
return createInteractionApi(
|
|
311
|
+
{ userId: globalProperties.userId ?? "batch", properties: globalProperties },
|
|
312
|
+
this.cfg.traceContent
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
/** Build Vercel AI SDK telemetry metadata (see `morphsdk/tracing/otel`). */
|
|
316
|
+
metadata(opts) {
|
|
317
|
+
return metadata(opts);
|
|
318
|
+
}
|
|
319
|
+
/** Attach a feedback/quality signal to an interaction by eventId. */
|
|
320
|
+
async trackSignal(signal) {
|
|
321
|
+
if (!this.enabled) return;
|
|
322
|
+
const signals = Array.isArray(signal) ? signal : [signal];
|
|
323
|
+
await shipSignal(this.cfg.signalsEndpoint, this.cfg.apiKey, signals, this.cfg.debug);
|
|
324
|
+
}
|
|
325
|
+
/** Span processor for `useExternalOtel: true` integrations. */
|
|
326
|
+
createSpanProcessor(options) {
|
|
327
|
+
return traceloop2.createSpanProcessor({
|
|
328
|
+
apiKey: this.cfg.apiKey,
|
|
329
|
+
baseUrl: this.cfg.baseUrl,
|
|
330
|
+
...options
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
/** Flush any batched spans immediately. Safe to call when idle. */
|
|
334
|
+
async forceFlush() {
|
|
335
|
+
if (!this.enabled) return;
|
|
336
|
+
try {
|
|
337
|
+
await traceloop2.forceFlush();
|
|
338
|
+
} catch (err) {
|
|
339
|
+
log(this.cfg.debug, "forceFlush error (ignored):", err);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
/** Flush and stop tracing. */
|
|
343
|
+
async shutdown() {
|
|
344
|
+
await this.forceFlush();
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
function morphTracing(config = {}) {
|
|
348
|
+
return new MorphTracing(config);
|
|
349
|
+
}
|
|
350
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
351
|
+
0 && (module.exports = {
|
|
352
|
+
MorphTracing,
|
|
353
|
+
morphTracing
|
|
354
|
+
});
|
|
355
|
+
//# sourceMappingURL=core.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../tracing/core.ts","../../tracing/interaction.ts","../../tracing/otel.ts","../../tracing/signals.ts"],"sourcesContent":["/**\n * Morph Tracing — core initialization.\n *\n * Thin Morph layer over OpenLLMetry / Traceloop. `morphTracing()` initializes\n * Traceloop with a JSON OTLP exporter pointed at Morph's ingest endpoint\n * (`${baseUrl}/v1/traces`, `Authorization: Bearer <apiKey>`) and returns a\n * `MorphTracing` handle for interactions, tools, and signals.\n *\n * We deliberately override Traceloop's default protobuf exporter with the\n * JSON-over-HTTP exporter so the ingest service can parse plain OTLP/JSON.\n */\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport * as traceloop from '@traceloop/node-server-sdk';\n\nimport { createInteractionApi, type Interaction, type Tracer } from './interaction.js';\nimport { metadata as buildMetadata } from './otel.js';\nimport { shipSignal } from './signals.js';\nimport type {\n MetadataOptions,\n MorphTracingConfig,\n SignalEvent,\n TraceContext,\n} from './types.js';\n\nconst DEFAULT_BASE_URL = 'https://api.morphllm.com';\n\nexport interface ResolvedConfig {\n apiKey: string;\n baseUrl: string;\n signalsEndpoint: string;\n appName: string;\n disableBatching: boolean;\n traceContent: boolean;\n debug: boolean;\n}\n\nfunction log(debug: boolean, ...args: unknown[]): void {\n if (debug) console.log('[morph-tracing]', ...args);\n}\n\n/**\n * Handle returned by {@link morphTracing}. Create interactions with `begin()`,\n * get a non-interactive `tracer()`, attach feedback with `trackSignal()`, and\n * flush/shutdown the exporter.\n */\nexport class MorphTracing {\n private readonly cfg: ResolvedConfig;\n private readonly active = new Map<string, Interaction>();\n readonly enabled: boolean;\n\n constructor(config: MorphTracingConfig = {}) {\n const debug = config.debug ?? process.env.MORPH_TRACING_DEBUG === '1';\n const apiKey = config.apiKey ?? process.env.MORPH_API_KEY ?? '';\n const baseUrlRaw =\n config.baseUrl ?? process.env.MORPH_TRACES_URL ?? DEFAULT_BASE_URL;\n const baseUrl = baseUrlRaw.replace(/\\/+$/, '');\n const isProd = process.env.NODE_ENV === 'production';\n\n this.cfg = {\n apiKey,\n baseUrl,\n signalsEndpoint: `${baseUrl}/v1/signals`,\n appName: config.appName ?? process.env.npm_package_name ?? 'morph-app',\n disableBatching: config.disableBatching ?? !isProd,\n traceContent: config.traceContent ?? true,\n debug,\n };\n\n if (config.disabled) {\n log(debug, 'disabled — no tracing initialized');\n this.enabled = false;\n return;\n }\n if (!apiKey) {\n console.warn(\n '[morph-tracing] No API key (set MORPH_API_KEY or pass { apiKey }). Tracing disabled.',\n );\n this.enabled = false;\n return;\n }\n\n this.enabled = true;\n if (config.useExternalOtel) {\n // Customer drives their own NodeSDK; just register config, no SDK start.\n traceloop.initialize({\n baseUrl,\n apiKey,\n appName: this.cfg.appName,\n tracingEnabled: false,\n traceContent: this.cfg.traceContent,\n silenceInitializationMessage: true,\n });\n log(debug, 'external OTEL mode — add createSpanProcessor() to your NodeSDK');\n return;\n }\n\n const exporter = new OTLPTraceExporter({\n url: `${baseUrl}/v1/traces`,\n headers: { Authorization: `Bearer ${apiKey}`, ...config.headers },\n });\n\n traceloop.initialize({\n baseUrl,\n apiKey,\n appName: this.cfg.appName,\n exporter,\n disableBatch: this.cfg.disableBatching,\n traceContent: this.cfg.traceContent,\n instrumentModules: config.instrumentModules as NonNullable<\n Parameters<typeof traceloop.initialize>[0]\n >['instrumentModules'],\n tracingEnabled: true,\n traceloopSyncEnabled: false,\n silenceInitializationMessage: !debug,\n });\n log(\n debug,\n `initialized → ${baseUrl}/v1/traces (batching ${this.cfg.disableBatching ? 'off' : 'on'})`,\n );\n }\n\n /** Begin a new traced interaction (a single user turn / agent run). */\n begin(ctx: TraceContext & { userId: string; event?: string }): Interaction {\n const interaction = createInteractionApi(ctx, this.cfg.traceContent);\n this.active.set(interaction.getEventId()!, interaction);\n return interaction;\n }\n\n /** Look up an in-flight interaction by its eventId. */\n getActiveInteraction(eventId: string): Interaction | undefined {\n return this.active.get(eventId);\n }\n\n /**\n * Non-interactive tracer for batch jobs where you only care about\n * spans/token usage, not a user-facing interaction.\n */\n tracer(globalProperties: Record<string, string> = {}): Tracer {\n return createInteractionApi(\n { userId: globalProperties.userId ?? 'batch', properties: globalProperties },\n this.cfg.traceContent,\n );\n }\n\n /** Build Vercel AI SDK telemetry metadata (see `morphsdk/tracing/otel`). */\n metadata(opts: MetadataOptions): Record<string, string> {\n return buildMetadata(opts);\n }\n\n /** Attach a feedback/quality signal to an interaction by eventId. */\n async trackSignal(signal: SignalEvent | SignalEvent[]): Promise<void> {\n if (!this.enabled) return;\n const signals = Array.isArray(signal) ? signal : [signal];\n await shipSignal(this.cfg.signalsEndpoint, this.cfg.apiKey, signals, this.cfg.debug);\n }\n\n /** Span processor for `useExternalOtel: true` integrations. */\n createSpanProcessor(\n options?: Parameters<typeof traceloop.createSpanProcessor>[0],\n ): ReturnType<typeof traceloop.createSpanProcessor> {\n return traceloop.createSpanProcessor({\n apiKey: this.cfg.apiKey,\n baseUrl: this.cfg.baseUrl,\n ...options,\n });\n }\n\n /** Flush any batched spans immediately. Safe to call when idle. */\n async forceFlush(): Promise<void> {\n if (!this.enabled) return;\n try {\n await traceloop.forceFlush();\n } catch (err) {\n log(this.cfg.debug, 'forceFlush error (ignored):', err);\n }\n }\n\n /** Flush and stop tracing. */\n async shutdown(): Promise<void> {\n await this.forceFlush();\n }\n}\n\n/** Initialize Morph Tracing and auto-instrument supported AI SDKs. */\nexport function morphTracing(config: MorphTracingConfig = {}): MorphTracing {\n return new MorphTracing(config);\n}\n","/**\n * Morph Tracing — interactions, tools, and manual spans.\n *\n * An `Interaction` is one user turn / agent run. It threads association\n * properties (user_id / convo_id / event_id) onto every span created inside it —\n * including the auto-instrumented LLM spans — so a whole conversation stitches\n * together in the Morph UI. Built on Traceloop's `withTask` / `withTool` and a\n * manual tracer for already-completed tool spans.\n */\nimport { SpanStatusCode, type Span } from '@opentelemetry/api';\nimport * as traceloop from '@traceloop/node-server-sdk';\n\nimport { metadata as buildMetadata } from './otel.js';\nimport type {\n FinishOptions,\n SpanParams,\n ToolParams,\n ToolSpan,\n TrackToolParams,\n TraceContext,\n} from './types.js';\n\n// Traceloop semantic-convention attribute keys.\nconst ASSOC = 'traceloop.association.properties.';\nconst ENTITY_INPUT = 'traceloop.entity.input';\nconst ENTITY_OUTPUT = 'traceloop.entity.output';\nconst ENTITY_NAME = 'traceloop.entity.name';\nconst SPAN_KIND = 'traceloop.span.kind';\n\nfunction uuid(): string {\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n if (c?.randomUUID) return c.randomUUID();\n return 'xxxxxxxxxxxx4xxxyxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0;\n return (ch === 'x' ? r : (r & 0x3) | 0x8).toString(16);\n });\n}\n\nfunction asString(v: unknown): string {\n if (v == null) return '';\n return typeof v === 'string' ? v : JSON.stringify(v);\n}\n\nexport interface Interaction {\n getEventId(): string | undefined;\n setInput(input: string): void;\n setProperty(key: string, value: string): void;\n setProperties(props: Record<string, string>): void;\n /**\n * Run `fn` with this interaction's association properties active — required so\n * auto-instrumented OpenAI/Anthropic spans inherit user_id / convo_id / tags.\n */\n run<T>(fn: () => Promise<T> | T): Promise<T>;\n /** Run `fn` inside a traced task span; LLM calls within inherit attribution. */\n withSpan<T>(params: SpanParams | string, fn: () => Promise<T> | T): Promise<T>;\n /** Run `fn` inside a traced tool span. */\n withTool<T>(params: ToolParams | string, fn: () => Promise<T> | T): Promise<T>;\n /** Start a tool span you end manually. */\n startToolSpan(params: ToolParams | string): ToolSpan;\n /** Record an already-completed tool invocation. */\n trackTool(params: TrackToolParams): void;\n /** Metadata for the Vercel AI SDK `experimental_telemetry.metadata`. */\n vercelAiSdkMetadata(): Record<string, string>;\n /** End the interaction with its final output. */\n finish(opts: FinishOptions | string): Promise<void>;\n}\n\nexport type Tracer = Pick<Interaction, 'withSpan' | 'withTool' | 'startToolSpan' | 'trackTool'>;\n\n/** Build the association-property bag Traceloop propagates onto child spans. */\nfunction associationProps(\n ctx: TraceContext & { userId?: string },\n extra: Record<string, string>,\n): Record<string, string> {\n const props: Record<string, string> = { ...extra };\n if (ctx.userId) props.user_id = ctx.userId;\n if (ctx.convoId) props.convo_id = ctx.convoId;\n if (ctx.eventId) props.event_id = ctx.eventId;\n if (ctx.event) props.event_name = ctx.event;\n return props;\n}\n\nexport function createInteractionApi(\n initial: TraceContext & { userId?: string },\n traceContent: boolean,\n): Interaction {\n const ctx: TraceContext & { userId?: string } = {\n ...initial,\n eventId: initial.eventId ?? uuid(),\n };\n const properties: Record<string, string> = { ...(initial.properties ?? {}) };\n let input = initial.input;\n\n const withAssoc = <T>(fn: () => Promise<T> | T): Promise<T> | T =>\n traceloop.withAssociationProperties(associationProps(ctx, properties), fn);\n\n const toolName = (p: ToolParams | string) => (typeof p === 'string' ? p : p.name);\n\n function startToolSpan(params: ToolParams | string): ToolSpan {\n const name = toolName(params);\n const span: Span = traceloop.getTraceloopTracer().startSpan(name);\n span.setAttribute(SPAN_KIND, 'tool');\n span.setAttribute(ENTITY_NAME, name);\n for (const [k, v] of Object.entries(associationProps(ctx, properties))) {\n span.setAttribute(ASSOC + k, v);\n }\n if (typeof params !== 'string' && params.properties) {\n for (const [k, v] of Object.entries(params.properties)) span.setAttribute(k, v);\n }\n return {\n setInput(value: unknown) {\n if (traceContent) span.setAttribute(ENTITY_INPUT, asString(value));\n },\n setOutput(value: unknown) {\n if (traceContent) span.setAttribute(ENTITY_OUTPUT, asString(value));\n },\n setError(error: Error | string) {\n const e = typeof error === 'string' ? new Error(error) : error;\n span.recordException(e);\n span.setStatus({ code: SpanStatusCode.ERROR, message: e.message });\n },\n end() {\n span.end();\n },\n };\n }\n\n return {\n getEventId: () => ctx.eventId,\n setInput(value: string) {\n input = value;\n },\n setProperty(key: string, value: string) {\n properties[key] = value;\n },\n setProperties(props: Record<string, string>) {\n Object.assign(properties, props);\n },\n vercelAiSdkMetadata() {\n return buildMetadata({\n userId: ctx.userId ?? 'unknown',\n convoId: ctx.convoId,\n eventName: ctx.event,\n eventId: ctx.eventId,\n properties,\n });\n },\n run(fn) {\n return Promise.resolve(withAssoc(fn));\n },\n withSpan(params, fn) {\n const name = typeof params === 'string' ? params : params.name;\n return Promise.resolve(withAssoc(() => traceloop.withTask({ name }, fn)));\n },\n withTool(params, fn) {\n const name = toolName(params);\n const version = typeof params === 'string' ? undefined : params.version;\n return Promise.resolve(withAssoc(() => traceloop.withTool({ name, version }, fn)));\n },\n startToolSpan,\n trackTool(params: TrackToolParams) {\n const span = startToolSpan({ name: params.name, properties: params.properties });\n if (params.input !== undefined) span.setInput(params.input);\n if (params.output !== undefined) span.setOutput(params.output);\n if (params.error) span.setError(params.error);\n span.end();\n },\n async finish(opts) {\n const output = typeof opts === 'string' ? opts : opts.output;\n if (typeof opts !== 'string' && opts.properties) Object.assign(properties, opts.properties);\n // Emit a top-level interaction span carrying input/output + attribution.\n await Promise.resolve(\n withAssoc(() =>\n traceloop.withTask({ name: ctx.event ?? 'interaction' }, () => {\n const span = traceloop.getTraceloopTracer().startSpan(ctx.event ?? 'interaction');\n span.setAttribute(SPAN_KIND, 'workflow');\n for (const [k, v] of Object.entries(associationProps(ctx, properties))) {\n span.setAttribute(ASSOC + k, v);\n }\n if (traceContent && input) span.setAttribute(ENTITY_INPUT, input);\n if (traceContent) span.setAttribute(ENTITY_OUTPUT, output);\n span.end();\n }),\n ),\n );\n },\n };\n}\n","/**\n * Morph Tracing — Vercel AI SDK helper.\n *\n * The Vercel AI SDK emits its own OpenTelemetry spans when you pass\n * `experimental_telemetry`. There is nothing to monkey-patch; instead you tag\n * each call with `metadata()` so Morph can attribute the resulting spans to a\n * user/conversation/event.\n *\n * @example\n * ```ts\n * import { generateText } from \"ai\";\n * import { metadata } from \"morphsdk/tracing/otel\";\n *\n * const res = await generateText({\n * model: openai(\"gpt-4o\"),\n * prompt: \"Hello!\",\n * experimental_telemetry: {\n * isEnabled: true,\n * metadata: metadata({ userId: \"user-123\", convoId: \"convo-456\" }),\n * },\n * });\n * ```\n */\nimport type { MetadataOptions } from './types.js';\n\n/**\n * Reserved metadata keys Morph owns. Custom `properties` can't overwrite these,\n * so attribution (user_id / convo_id / event_id) stays intact.\n *\n * The AI SDK stores metadata as `ai.telemetry.metadata.<key>`; Traceloop's span\n * processor copies them to `traceloop.association.properties.<key>`, which is\n * what ClickHouse views read. Use snake_case names (user_id, convo_id, …).\n */\nconst RESERVED_KEYS = new Set(['user_id', 'convo_id', 'event_id', 'event_name']);\n\nfunction uuid(): string {\n // Node 18+ and modern runtimes expose globalThis.crypto.randomUUID.\n const c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto;\n if (c?.randomUUID) return c.randomUUID();\n // Fallback: RFC4122-ish without crypto.\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0;\n const v = ch === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\n/**\n * Build the metadata object for the Vercel AI SDK's\n * `experimental_telemetry.metadata`. The values are propagated to every span the\n * AI SDK creates for that call. Generate a fresh `eventId` per call for grouping.\n */\nexport function metadata(opts: MetadataOptions): Record<string, string> {\n const result: Record<string, string> = {\n user_id: opts.userId,\n event_id: opts.eventId ?? uuid(),\n };\n if (opts.convoId) result.convo_id = opts.convoId;\n if (opts.eventName) result.event_name = opts.eventName;\n if (opts.properties) {\n for (const [key, value] of Object.entries(opts.properties)) {\n if (!RESERVED_KEYS.has(key)) result[key] = value;\n }\n }\n return result;\n}\n\nexport default { metadata };\n","/**\n * Morph Tracing — feedback signals.\n *\n * Signals (👍/👎, free-text feedback, user edits) attach to an interaction by\n * `eventId` and ship directly over HTTP — they are low-volume and need no OTel\n * pipeline. Mirrors the request shape of `tools/fastapply/core.ts`.\n */\nimport type { SignalEvent } from './types.js';\n\nexport async function shipSignal(\n endpoint: string,\n apiKey: string,\n signals: SignalEvent[],\n debug = false,\n timeoutMs = 10_000,\n): Promise<void> {\n if (signals.length === 0) return;\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n const res = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({ signals }),\n signal: controller.signal,\n });\n if (!res.ok) {\n const body = await res.text().catch(() => '');\n // Signals are best-effort; never throw into the caller's hot path.\n console.warn(`[morph-tracing] signal POST failed (${res.status}): ${body}`);\n } else if (debug) {\n console.log(`[morph-tracing] shipped ${signals.length} signal(s)`);\n }\n } catch (err) {\n console.warn(\n '[morph-tracing] signal POST error:',\n err instanceof Error ? err.message : err,\n );\n } finally {\n clearTimeout(timer);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,sCAAkC;AAClC,IAAAA,aAA2B;;;ACH3B,iBAA0C;AAC1C,gBAA2B;;;ACuB3B,IAAM,gBAAgB,oBAAI,IAAI,CAAC,WAAW,YAAY,YAAY,YAAY,CAAC;AAE/E,SAAS,OAAe;AAEtB,QAAM,IAAK,WAA0D;AACrE,MAAI,GAAG,WAAY,QAAO,EAAE,WAAW;AAEvC,SAAO,uCAAuC,QAAQ,SAAS,CAAC,OAAO;AACrE,UAAM,IAAK,KAAK,OAAO,IAAI,KAAM;AACjC,UAAM,IAAI,OAAO,MAAM,IAAK,IAAI,IAAO;AACvC,WAAO,EAAE,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IAAI;AAAA,MACjB,SAAS,KAAK,IAAI;AAAA,MAClB,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AAAA;AAAA,EAGA,MAAM,aAA4B;AAChC,QAAI,CAAC,KAAK,QAAS;AACnB,QAAI;AACF,YAAgB,sBAAW;AAAA,IAC7B,SAAS,KAAK;AACZ,UAAI,KAAK,IAAI,OAAO,+BAA+B,GAAG;AAAA,IACxD;AAAA,EACF;AAAA;AAAA,EAGA,MAAM,WAA0B;AAC9B,UAAM,KAAK,WAAW;AAAA,EACxB;AACF;AAGO,SAAS,aAAa,SAA6B,CAAC,GAAiB;AAC1E,SAAO,IAAI,aAAa,MAAM;AAChC;","names":["traceloop","uuid"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as traceloop from '@traceloop/node-server-sdk';
|
|
2
|
+
import { Interaction, Tracer } from './interaction.js';
|
|
3
|
+
import { MorphTracingConfig, TraceContext, MetadataOptions, SignalEvent } from './types.js';
|
|
4
|
+
|
|
5
|
+
interface ResolvedConfig {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
signalsEndpoint: string;
|
|
9
|
+
appName: string;
|
|
10
|
+
disableBatching: boolean;
|
|
11
|
+
traceContent: boolean;
|
|
12
|
+
debug: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Handle returned by {@link morphTracing}. Create interactions with `begin()`,
|
|
16
|
+
* get a non-interactive `tracer()`, attach feedback with `trackSignal()`, and
|
|
17
|
+
* flush/shutdown the exporter.
|
|
18
|
+
*/
|
|
19
|
+
declare class MorphTracing {
|
|
20
|
+
private readonly cfg;
|
|
21
|
+
private readonly active;
|
|
22
|
+
readonly enabled: boolean;
|
|
23
|
+
constructor(config?: MorphTracingConfig);
|
|
24
|
+
/** Begin a new traced interaction (a single user turn / agent run). */
|
|
25
|
+
begin(ctx: TraceContext & {
|
|
26
|
+
userId: string;
|
|
27
|
+
event?: string;
|
|
28
|
+
}): Interaction;
|
|
29
|
+
/** Look up an in-flight interaction by its eventId. */
|
|
30
|
+
getActiveInteraction(eventId: string): Interaction | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Non-interactive tracer for batch jobs where you only care about
|
|
33
|
+
* spans/token usage, not a user-facing interaction.
|
|
34
|
+
*/
|
|
35
|
+
tracer(globalProperties?: Record<string, string>): Tracer;
|
|
36
|
+
/** Build Vercel AI SDK telemetry metadata (see `morphsdk/tracing/otel`). */
|
|
37
|
+
metadata(opts: MetadataOptions): Record<string, string>;
|
|
38
|
+
/** Attach a feedback/quality signal to an interaction by eventId. */
|
|
39
|
+
trackSignal(signal: SignalEvent | SignalEvent[]): Promise<void>;
|
|
40
|
+
/** Span processor for `useExternalOtel: true` integrations. */
|
|
41
|
+
createSpanProcessor(options?: Parameters<typeof traceloop.createSpanProcessor>[0]): ReturnType<typeof traceloop.createSpanProcessor>;
|
|
42
|
+
/** Flush any batched spans immediately. Safe to call when idle. */
|
|
43
|
+
forceFlush(): Promise<void>;
|
|
44
|
+
/** Flush and stop tracing. */
|
|
45
|
+
shutdown(): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
/** Initialize Morph Tracing and auto-instrument supported AI SDKs. */
|
|
48
|
+
declare function morphTracing(config?: MorphTracingConfig): MorphTracing;
|
|
49
|
+
|
|
50
|
+
export { MorphTracing, type ResolvedConfig, morphTracing };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MorphTracing,
|
|
3
|
+
morphTracing
|
|
4
|
+
} from "../chunk-KRTQESOL.js";
|
|
5
|
+
import "../chunk-PICGNBUE.js";
|
|
6
|
+
import "../chunk-ZCEDWXQV.js";
|
|
7
|
+
import "../chunk-CABQ652L.js";
|
|
8
|
+
import "../chunk-PZ5AY32C.js";
|
|
9
|
+
export {
|
|
10
|
+
MorphTracing,
|
|
11
|
+
morphTracing
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|