@fro.bot/opencode-plugin 0.3.1 → 0.3.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/README.md CHANGED
@@ -42,6 +42,8 @@ To turn it on, create `~/.config/fro-bot/opencode-plugin/tracing.json` (under `$
42
42
 
43
43
  Every span carries `langfuse.session.id` set to the **root** session's id, so Langfuse's Sessions view groups a subagent's spans with its parent's, while the standard `session.id` stays each span's own session. In the Action, each span also carries the run's repository, run id, attempt, job and trigger as `langfuse.trace.metadata.*` (`repository`, `run_id`, `run_attempt`, `job`, `trigger`), so Langfuse shows and filters by them; a local session has none of these.
44
44
 
45
+ The root span of every trace (a turn's `invoke_agent`, and the root of a late continuation trace) also carries `langfuse.trace.name` set to the fixed string `fro-bot run`, which Langfuse shows as the trace's name. No other span has it, and it holds no content.
46
+
45
47
  **Joining a turn to its Action run.** The Action's launcher document (`OPENCODE_FROBOT_TRACING`) may carry three optional fields. The plugin accepts the document with or without them, refuses any other key, and turns tracing off, with a fixed reason and no value in the log line (`launcher-run-invalid`), when a field it carries is malformed:
46
48
 
47
49
  - `sessionId`: the telemetry session the Action computed, `<owner>/<repo>:<logical key>`: 1 to 200 characters, no control characters. The plugin sets `langfuse.session.id` to it **verbatim** on every span, and never derives or alters it. Every exported string is scrubbed, so a session id the scrub would change or withhold (a repository named `password-manager` reads as a name and a value) is never exported redacted, which would merge conversations into one session: that span falls back to the OpenCode root session instead. The Action avoids the fallback by passing the id through `scrubSafeSessionId` (`@fro-bot/runtime/tracing/session-id`) first, which returns the id as is when the scrub leaves it alone, else `sha256:` and 32 hex characters of its SHA-256, else none. Without it, and in every local session, `langfuse.session.id` stays the OpenCode root session as described above. **Upgrading:** turns exported before the Action sent a `sessionId` stay in Langfuse under the OpenCode root session id, and new Action turns use the qualified conversation key, so one conversation shows as two sessions across the upgrade. Every span of both kinds carries `fro_bot.root_session.id` (the OpenCode root session id, whatever `langfuse.session.id` is), so a dashboard or a query can still join the old and the new turns of a conversation on it. `session.id` and `gen_ai.conversation.id` keep each span's own OpenCode session either way.
package/dist/index.mjs CHANGED
@@ -1092,7 +1092,7 @@ function resolveTracingSettings(input) {
1092
1092
  */
1093
1093
  async function startTracing(host, settings, env, log) {
1094
1094
  try {
1095
- const handle = await (await import("./tracing-B4QJ2-E2.mjs")).startTracing({
1095
+ const handle = await (await import("./tracing-CHrTlTyx.mjs")).startTracing({
1096
1096
  session: host.session,
1097
1097
  tool: { hook: async (name, callback) => name === "execute.before" ? host.tool.hook(name, callback) : host.tool.hook(name, callback) },
1098
1098
  event: host.event
@@ -5735,6 +5735,29 @@ function toPendingSpan(record, options = {}) {
5735
5735
  }
5736
5736
  const SESSION_ATTRIBUTE = "langfuse.session.id";
5737
5737
  /**
5738
+ * The trace's name in Langfuse, whose OTLP ingestion reads it from this attribute on the trace's root span (the span names
5739
+ * `invoke_agent <agent>` name observations, not the trace). One fixed string for every trace, so it holds no content.
5740
+ */
5741
+ const TRACE_NAME_ATTRIBUTE = "langfuse.trace.name";
5742
+ const TRACE_NAME = "fro-bot run";
5743
+ /**
5744
+ * Names the trace on a span that is its root, and on nothing else. A span with no parent is the root: the turn model opens
5745
+ * every trace with a parentless `invoke_agent` (a continuation of a closed trace included) and gives every other span a parent.
5746
+ *
5747
+ * Added after the scrub, never through it: the string is fixed text, and a scrubber that rewrote it (a registered value that
5748
+ * happens to match a word of it) would split one name into several in Langfuse. A span that is not a root is returned as is.
5749
+ */
5750
+ function withTraceName(span) {
5751
+ if (span.parentSpanId !== void 0) return span;
5752
+ return {
5753
+ ...span,
5754
+ attributes: {
5755
+ ...span.attributes,
5756
+ [TRACE_NAME_ATTRIBUTE]: TRACE_NAME
5757
+ }
5758
+ };
5759
+ }
5760
+ /**
5738
5761
  * Whether the span carries the launcher's session id exactly as given. Equal text is not enough: a value the scrubber withheld
5739
5762
  * is exported as the fixed marker `[omitted]`, so an id that is literally `[omitted]` would equal its own withheld form. The
5740
5763
  * omission status the scrub wrote (`<attribute>:<reason>`) is what says whether it was withheld.
@@ -5754,11 +5777,11 @@ function sessionIdExportedAsGiven(span, sessionId) {
5754
5777
  */
5755
5778
  function toExportSpan(record, options, scrubber, limits) {
5756
5779
  const span = scrubSpan(toPendingSpan(record, options), scrubber, limits);
5757
- if (options.sessionId === void 0 || sessionIdExportedAsGiven(span, options.sessionId)) return span;
5758
- return scrubSpan(toPendingSpan(record, {
5780
+ if (options.sessionId === void 0 || sessionIdExportedAsGiven(span, options.sessionId)) return withTraceName(span);
5781
+ return withTraceName(scrubSpan(toPendingSpan(record, {
5759
5782
  ...options,
5760
5783
  sessionId: void 0
5761
- }), scrubber, limits);
5784
+ }), scrubber, limits));
5762
5785
  }
5763
5786
  // src/tracing/turn-model.ts
5764
5787
  const DEFAULT_LIMITS = {
@@ -7954,4 +7977,4 @@ async function startTracing(host, settings, options) {
7954
7977
  }
7955
7978
  export { startTracing };
7956
7979
 
7957
- //# sourceMappingURL=tracing-B4QJ2-E2.mjs.map
7980
+ //# sourceMappingURL=tracing-CHrTlTyx.mjs.map