risicare 0.1.1 → 0.1.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.cjs +43 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +43 -11
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic/index.cjs +1 -1
- package/dist/providers/anthropic/index.cjs.map +1 -1
- package/dist/providers/anthropic/index.js +1 -1
- package/dist/providers/anthropic/index.js.map +1 -1
- package/dist/providers/openai/index.cjs +1 -1
- package/dist/providers/openai/index.cjs.map +1 -1
- package/dist/providers/openai/index.js +1 -1
- package/dist/providers/openai/index.js.map +1 -1
- package/dist/providers/vercel-ai/index.cjs +1 -1
- package/dist/providers/vercel-ai/index.cjs.map +1 -1
- package/dist/providers/vercel-ai/index.js +1 -1
- package/dist/providers/vercel-ai/index.js.map +1 -1
- package/package.json +10 -4
package/dist/index.cjs
CHANGED
|
@@ -176,6 +176,9 @@ var SemanticPhase = /* @__PURE__ */ ((SemanticPhase2) => {
|
|
|
176
176
|
SemanticPhase2["DECIDE"] = "decide";
|
|
177
177
|
SemanticPhase2["ACT"] = "act";
|
|
178
178
|
SemanticPhase2["OBSERVE"] = "observe";
|
|
179
|
+
SemanticPhase2["REFLECT"] = "reflect";
|
|
180
|
+
SemanticPhase2["COMMUNICATE"] = "communicate";
|
|
181
|
+
SemanticPhase2["COORDINATE"] = "coordinate";
|
|
179
182
|
return SemanticPhase2;
|
|
180
183
|
})(SemanticPhase || {});
|
|
181
184
|
var AgentRole = /* @__PURE__ */ ((AgentRole2) => {
|
|
@@ -531,8 +534,22 @@ function getCurrentSpanId() {
|
|
|
531
534
|
function getCurrentContext() {
|
|
532
535
|
const ctx = getContext();
|
|
533
536
|
return {
|
|
534
|
-
session: ctx.session ? {
|
|
535
|
-
|
|
537
|
+
session: ctx.session ? {
|
|
538
|
+
sessionId: ctx.session.sessionId,
|
|
539
|
+
userId: ctx.session.userId,
|
|
540
|
+
...ctx.session.parentSessionId !== void 0 ? { parentSessionId: ctx.session.parentSessionId } : {},
|
|
541
|
+
...ctx.session.turnNumber !== void 0 ? { turnNumber: ctx.session.turnNumber } : {},
|
|
542
|
+
...ctx.session.metadata !== void 0 ? { metadata: ctx.session.metadata } : {}
|
|
543
|
+
} : null,
|
|
544
|
+
agent: ctx.agent ? {
|
|
545
|
+
agentId: ctx.agent.agentId,
|
|
546
|
+
agentName: ctx.agent.agentName,
|
|
547
|
+
agentRole: ctx.agent.agentRole,
|
|
548
|
+
agentType: ctx.agent.agentType,
|
|
549
|
+
...ctx.agent.parentAgentId !== void 0 ? { parentAgentId: ctx.agent.parentAgentId } : {},
|
|
550
|
+
...ctx.agent.version !== void 0 ? { version: ctx.agent.version } : {},
|
|
551
|
+
...ctx.agent.metadata !== void 0 ? { metadata: ctx.agent.metadata } : {}
|
|
552
|
+
} : null,
|
|
536
553
|
span: ctx.span ? { spanId: ctx.span.spanId, traceId: ctx.span.traceId } : null,
|
|
537
554
|
phase: ctx.phase ?? null
|
|
538
555
|
};
|
|
@@ -592,7 +609,13 @@ var Tracer = class {
|
|
|
592
609
|
kind: opts.kind ?? "internal" /* INTERNAL */,
|
|
593
610
|
traceId,
|
|
594
611
|
parentSpanId,
|
|
595
|
-
attributes:
|
|
612
|
+
attributes: {
|
|
613
|
+
...opts.attributes,
|
|
614
|
+
// Propagate context fields as attributes (matching Python SDK tracer.py:497-511)
|
|
615
|
+
...agent2?.agentRole ? { "agent.role": agent2.agentRole } : {},
|
|
616
|
+
...agent2?.parentAgentId ? { "parent_agent_id": agent2.parentAgentId } : {},
|
|
617
|
+
...session2?.userId ? { "session.user_id": session2.userId } : {}
|
|
618
|
+
},
|
|
596
619
|
sessionId: session2?.sessionId,
|
|
597
620
|
agentId: agent2?.agentId,
|
|
598
621
|
agentName: agent2?.agentName,
|
|
@@ -651,7 +674,13 @@ var Tracer = class {
|
|
|
651
674
|
kind: opts.kind ?? "internal" /* INTERNAL */,
|
|
652
675
|
traceId,
|
|
653
676
|
parentSpanId,
|
|
654
|
-
attributes:
|
|
677
|
+
attributes: {
|
|
678
|
+
...opts.attributes,
|
|
679
|
+
// Propagate context fields as attributes (matching Python SDK tracer.py:497-511)
|
|
680
|
+
...agent2?.agentRole ? { "agent.role": agent2.agentRole } : {},
|
|
681
|
+
...agent2?.parentAgentId ? { "parent_agent_id": agent2.parentAgentId } : {},
|
|
682
|
+
...session2?.userId ? { "session.user_id": session2.userId } : {}
|
|
683
|
+
},
|
|
655
684
|
sessionId: session2?.sessionId,
|
|
656
685
|
agentId: agent2?.agentId,
|
|
657
686
|
agentName: agent2?.agentName,
|
|
@@ -1147,28 +1176,28 @@ function withPhase(phase, fn) {
|
|
|
1147
1176
|
}
|
|
1148
1177
|
|
|
1149
1178
|
// src/decorators/phase.ts
|
|
1150
|
-
function phaseWrapper(phase, fn) {
|
|
1179
|
+
function phaseWrapper(phase, kind, fn) {
|
|
1151
1180
|
return (...args) => {
|
|
1152
1181
|
const tracer = getTracer2();
|
|
1153
1182
|
if (!tracer) {
|
|
1154
1183
|
return fn(...args);
|
|
1155
1184
|
}
|
|
1156
1185
|
return withPhase(phase, () => {
|
|
1157
|
-
return tracer.startSpan({ name: `phase:${phase}
|
|
1186
|
+
return tracer.startSpan({ name: `phase:${phase}`, kind }, () => fn(...args));
|
|
1158
1187
|
});
|
|
1159
1188
|
};
|
|
1160
1189
|
}
|
|
1161
1190
|
function traceThink(fn) {
|
|
1162
|
-
return phaseWrapper("think" /* THINK */, fn);
|
|
1191
|
+
return phaseWrapper("think" /* THINK */, "think" /* THINK */, fn);
|
|
1163
1192
|
}
|
|
1164
1193
|
function traceDecide(fn) {
|
|
1165
|
-
return phaseWrapper("decide" /* DECIDE */, fn);
|
|
1194
|
+
return phaseWrapper("decide" /* DECIDE */, "decide" /* DECIDE */, fn);
|
|
1166
1195
|
}
|
|
1167
1196
|
function traceAct(fn) {
|
|
1168
|
-
return phaseWrapper("act" /* ACT */, fn);
|
|
1197
|
+
return phaseWrapper("act" /* ACT */, "tool_call" /* TOOL_CALL */, fn);
|
|
1169
1198
|
}
|
|
1170
1199
|
function traceObserve(fn) {
|
|
1171
|
-
return phaseWrapper("observe" /* OBSERVE */, fn);
|
|
1200
|
+
return phaseWrapper("observe" /* OBSERVE */, "observe" /* OBSERVE */, fn);
|
|
1172
1201
|
}
|
|
1173
1202
|
|
|
1174
1203
|
// src/decorators/multi-agent.ts
|
|
@@ -1299,7 +1328,10 @@ function extractTraceContext(headers) {
|
|
|
1299
1328
|
if (eqIdx > 0) {
|
|
1300
1329
|
const key = kv.slice(0, eqIdx).trim();
|
|
1301
1330
|
const value = kv.slice(eqIdx + 1).trim();
|
|
1302
|
-
if (key && value)
|
|
1331
|
+
if (key && value) {
|
|
1332
|
+
const camelKey = key === "session_id" ? "sessionId" : key === "agent_id" ? "agentId" : key;
|
|
1333
|
+
result[camelKey] = value;
|
|
1334
|
+
}
|
|
1303
1335
|
}
|
|
1304
1336
|
}
|
|
1305
1337
|
}
|