risicare 0.2.0 → 0.2.2

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.d.cts CHANGED
@@ -502,14 +502,34 @@ declare function session<TArgs extends unknown[], TReturn>(optionsOrResolver: Se
502
502
  * return await llm.invoke(`Decide action: ${analysis}`);
503
503
  * });
504
504
  */
505
- /** Wrap a function in a THINK phase context with auto-span. */
506
- declare function traceThink<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
507
- /** Wrap a function in a DECIDE phase context with auto-span. */
508
- declare function traceDecide<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
509
- /** Wrap a function in an ACT phase context with auto-span. */
510
- declare function traceAct<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
511
- /** Wrap a function in an OBSERVE phase context with auto-span. */
512
- declare function traceObserve<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
505
+ /**
506
+ * Wrap a function in a THINK phase context with auto-span.
507
+ *
508
+ * @example traceThink(async () => { ... })
509
+ * @example traceThink("analyze-data", async () => { ... })
510
+ */
511
+ declare function traceThink<TArgs extends unknown[], TReturn>(fnOrName: ((...args: TArgs) => TReturn) | string, maybeFn?: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
512
+ /**
513
+ * Wrap a function in a DECIDE phase context with auto-span.
514
+ *
515
+ * @example traceDecide(async () => { ... })
516
+ * @example traceDecide("choose-action", async () => { ... })
517
+ */
518
+ declare function traceDecide<TArgs extends unknown[], TReturn>(fnOrName: ((...args: TArgs) => TReturn) | string, maybeFn?: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
519
+ /**
520
+ * Wrap a function in an ACT phase context with auto-span.
521
+ *
522
+ * @example traceAct(async () => { ... })
523
+ * @example traceAct("execute-tool", async () => { ... })
524
+ */
525
+ declare function traceAct<TArgs extends unknown[], TReturn>(fnOrName: ((...args: TArgs) => TReturn) | string, maybeFn?: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
526
+ /**
527
+ * Wrap a function in an OBSERVE phase context with auto-span.
528
+ *
529
+ * @example traceObserve(async () => { ... })
530
+ * @example traceObserve("check-result", async () => { ... })
531
+ */
532
+ declare function traceObserve<TArgs extends unknown[], TReturn>(fnOrName: ((...args: TArgs) => TReturn) | string, maybeFn?: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
513
533
 
514
534
  /**
515
535
  * Phase context — cognitive phase tracking (THINK/DECIDE/ACT/OBSERVE).
package/dist/index.d.ts CHANGED
@@ -502,14 +502,34 @@ declare function session<TArgs extends unknown[], TReturn>(optionsOrResolver: Se
502
502
  * return await llm.invoke(`Decide action: ${analysis}`);
503
503
  * });
504
504
  */
505
- /** Wrap a function in a THINK phase context with auto-span. */
506
- declare function traceThink<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
507
- /** Wrap a function in a DECIDE phase context with auto-span. */
508
- declare function traceDecide<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
509
- /** Wrap a function in an ACT phase context with auto-span. */
510
- declare function traceAct<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
511
- /** Wrap a function in an OBSERVE phase context with auto-span. */
512
- declare function traceObserve<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
505
+ /**
506
+ * Wrap a function in a THINK phase context with auto-span.
507
+ *
508
+ * @example traceThink(async () => { ... })
509
+ * @example traceThink("analyze-data", async () => { ... })
510
+ */
511
+ declare function traceThink<TArgs extends unknown[], TReturn>(fnOrName: ((...args: TArgs) => TReturn) | string, maybeFn?: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
512
+ /**
513
+ * Wrap a function in a DECIDE phase context with auto-span.
514
+ *
515
+ * @example traceDecide(async () => { ... })
516
+ * @example traceDecide("choose-action", async () => { ... })
517
+ */
518
+ declare function traceDecide<TArgs extends unknown[], TReturn>(fnOrName: ((...args: TArgs) => TReturn) | string, maybeFn?: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
519
+ /**
520
+ * Wrap a function in an ACT phase context with auto-span.
521
+ *
522
+ * @example traceAct(async () => { ... })
523
+ * @example traceAct("execute-tool", async () => { ... })
524
+ */
525
+ declare function traceAct<TArgs extends unknown[], TReturn>(fnOrName: ((...args: TArgs) => TReturn) | string, maybeFn?: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
526
+ /**
527
+ * Wrap a function in an OBSERVE phase context with auto-span.
528
+ *
529
+ * @example traceObserve(async () => { ... })
530
+ * @example traceObserve("check-result", async () => { ... })
531
+ */
532
+ declare function traceObserve<TArgs extends unknown[], TReturn>(fnOrName: ((...args: TArgs) => TReturn) | string, maybeFn?: (...args: TArgs) => TReturn): (...args: TArgs) => TReturn;
513
533
 
514
534
  /**
515
535
  * Phase context — cognitive phase tracking (THINK/DECIDE/ACT/OBSERVE).
package/dist/index.js CHANGED
@@ -1179,28 +1179,36 @@ function withPhase(phase, fn) {
1179
1179
  }
1180
1180
 
1181
1181
  // src/decorators/phase.ts
1182
- function phaseWrapper(phase, kind, fn) {
1182
+ function phaseWrapper(phase, kind, name, fn) {
1183
1183
  return (...args) => {
1184
1184
  const tracer = getTracer2();
1185
1185
  if (!tracer) {
1186
1186
  return fn(...args);
1187
1187
  }
1188
1188
  return withPhase(phase, () => {
1189
- return tracer.startSpan({ name: `phase:${phase}`, kind }, () => fn(...args));
1189
+ return tracer.startSpan({ name, kind }, () => fn(...args));
1190
1190
  });
1191
1191
  };
1192
1192
  }
1193
- function traceThink(fn) {
1194
- return phaseWrapper("think" /* THINK */, "think" /* THINK */, fn);
1195
- }
1196
- function traceDecide(fn) {
1197
- return phaseWrapper("decide" /* DECIDE */, "decide" /* DECIDE */, fn);
1198
- }
1199
- function traceAct(fn) {
1200
- return phaseWrapper("act" /* ACT */, "tool_call" /* TOOL_CALL */, fn);
1201
- }
1202
- function traceObserve(fn) {
1203
- return phaseWrapper("observe" /* OBSERVE */, "observe" /* OBSERVE */, fn);
1193
+ function traceThink(fnOrName, maybeFn) {
1194
+ const name = typeof fnOrName === "string" ? fnOrName : `phase:think`;
1195
+ const fn = typeof fnOrName === "function" ? fnOrName : maybeFn;
1196
+ return phaseWrapper("think" /* THINK */, "think" /* THINK */, name, fn);
1197
+ }
1198
+ function traceDecide(fnOrName, maybeFn) {
1199
+ const name = typeof fnOrName === "string" ? fnOrName : `phase:decide`;
1200
+ const fn = typeof fnOrName === "function" ? fnOrName : maybeFn;
1201
+ return phaseWrapper("decide" /* DECIDE */, "decide" /* DECIDE */, name, fn);
1202
+ }
1203
+ function traceAct(fnOrName, maybeFn) {
1204
+ const name = typeof fnOrName === "string" ? fnOrName : `phase:act`;
1205
+ const fn = typeof fnOrName === "function" ? fnOrName : maybeFn;
1206
+ return phaseWrapper("act" /* ACT */, "tool_call" /* TOOL_CALL */, name, fn);
1207
+ }
1208
+ function traceObserve(fnOrName, maybeFn) {
1209
+ const name = typeof fnOrName === "string" ? fnOrName : `phase:observe`;
1210
+ const fn = typeof fnOrName === "function" ? fnOrName : maybeFn;
1211
+ return phaseWrapper("observe" /* OBSERVE */, "observe" /* OBSERVE */, name, fn);
1204
1212
  }
1205
1213
 
1206
1214
  // src/decorators/multi-agent.ts