@smithers-orchestrator/observability 0.21.0 → 0.23.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithers-orchestrator/observability",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Concrete Smithers metrics, logging, tracing, and observability integrations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@effect/platform": "^0.96.0",
|
|
30
30
|
"@effect/platform-bun": "^0.89.0",
|
|
31
31
|
"effect": "^3.21.1",
|
|
32
|
-
"@smithers-orchestrator/agents": "0.
|
|
32
|
+
"@smithers-orchestrator/agents": "0.23.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/bun": "latest",
|
|
@@ -11,5 +11,12 @@ import { mergeCorrelationContext } from "./mergeCorrelationContext.js";
|
|
|
11
11
|
*/
|
|
12
12
|
export function withCorrelationContext(effect, patch) {
|
|
13
13
|
const next = mergeCorrelationContext(correlationStorage.getStore(), patch);
|
|
14
|
-
|
|
14
|
+
if (!next)
|
|
15
|
+
return effect;
|
|
16
|
+
const located = effect.pipe(Effect.locally(correlationContextFiberRef, next));
|
|
17
|
+
return Effect.acquireUseRelease(Effect.sync(() => {
|
|
18
|
+
const previous = correlationStorage.getStore();
|
|
19
|
+
correlationStorage.enterWith(next);
|
|
20
|
+
return previous;
|
|
21
|
+
}), () => located, (previous) => Effect.sync(() => correlationStorage.enterWith(previous)));
|
|
15
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile, readdir, stat } from "node:fs/promises";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
3
|
+
import { basename, join } from "node:path";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @param {string} dir
|
|
@@ -111,7 +111,7 @@ export async function resolveClaudeSessionFile(agent, cwd, sessionId) {
|
|
|
111
111
|
if (info.isFile()) return direct;
|
|
112
112
|
} catch {}
|
|
113
113
|
const files = await listJsonlFiles(root);
|
|
114
|
-
const match = files.find((file) => file
|
|
114
|
+
const match = files.find((file) => basename(file) === `${sessionId}.jsonl`);
|
|
115
115
|
if (match) return match;
|
|
116
116
|
}
|
|
117
117
|
return null;
|
|
@@ -124,8 +124,13 @@ export async function resolveClaudeSessionFile(agent, cwd, sessionId) {
|
|
|
124
124
|
* @returns {Promise<string | null>}
|
|
125
125
|
*/
|
|
126
126
|
export async function resolveCodexSessionFile(agent, cwd, startedAtMs) {
|
|
127
|
-
const
|
|
128
|
-
|
|
127
|
+
const dayFolders = new Set();
|
|
128
|
+
for (const offset of [-1, 0, 1]) {
|
|
129
|
+
const day = new Date(startedAtMs + offset * 24 * 60 * 60 * 1000);
|
|
130
|
+
dayFolders.add(join(String(day.getUTCFullYear()), String(day.getUTCMonth() + 1).padStart(2, "0"), String(day.getUTCDate()).padStart(2, "0")));
|
|
131
|
+
dayFolders.add(join(String(day.getFullYear()), String(day.getMonth() + 1).padStart(2, "0"), String(day.getDate()).padStart(2, "0")));
|
|
132
|
+
}
|
|
133
|
+
const dayRoots = buildCodexSessionRoots(agent).flatMap((root) => [...dayFolders].map((folder) => join(root, folder)));
|
|
129
134
|
const candidates = (await Promise.all(dayRoots.map((root) => listJsonlFiles(root)))).flat();
|
|
130
135
|
/** @type {{ file: string; delta: number } | null} */
|
|
131
136
|
let best = null;
|
package/src/correlation.js
CHANGED
|
@@ -5,14 +5,38 @@ import { getCurrentCorrelationContext as getCoreCurrentCorrelationContext, merge
|
|
|
5
5
|
|
|
6
6
|
export { correlationContextFiberRef, correlationContextToLogAnnotations, CorrelationContextLive, CorrelationContextService, getCurrentCorrelationContext, getCurrentCorrelationContextEffect, mergeCorrelationContext, runWithCorrelationContext, withCorrelationContext, withCurrentCorrelationContext, } from "./_coreCorrelation/index.js";
|
|
7
7
|
/**
|
|
8
|
+
* Temporary compatibility shim for legacy, non-Effect callers.
|
|
9
|
+
*
|
|
10
|
+
* Unlike the FiberRef-based core implementation
|
|
11
|
+
* ({@link import("./_coreCorrelation/updateCurrentCorrelationContext.js").updateCurrentCorrelationContext}),
|
|
12
|
+
* which returns an Effect and sets a fresh merged context on the
|
|
13
|
+
* `correlationContextFiberRef`, this shim runs synchronously and applies the
|
|
14
|
+
* patch by **mutating the current context object in place** via
|
|
15
|
+
* `Object.assign(current, next)`. Any references already holding the current
|
|
16
|
+
* context object will observe the mutation. This in-place semantics is
|
|
17
|
+
* intentional and exists only to preserve behavior for callers that captured a
|
|
18
|
+
* context reference before the Effect-based API existed.
|
|
19
|
+
*
|
|
20
|
+
* If there is no current context, the patch is a no-op (nothing is created).
|
|
21
|
+
*
|
|
22
|
+
* @deprecated Prefer the Effect-returning
|
|
23
|
+
* `updateCurrentCorrelationContext` from
|
|
24
|
+
* `@smithers-orchestrator/observability` (the `_coreCorrelation` version),
|
|
25
|
+
* which does not mutate shared state. This shim will be removed once legacy
|
|
26
|
+
* callers migrate.
|
|
27
|
+
*
|
|
8
28
|
* @param {CorrelationPatch} patch
|
|
29
|
+
* @returns {void}
|
|
9
30
|
*/
|
|
10
31
|
export function updateCurrentCorrelationContext(patch) {
|
|
11
32
|
const current = getCoreCurrentCorrelationContext();
|
|
12
33
|
if (!current)
|
|
13
34
|
return;
|
|
14
|
-
//
|
|
15
|
-
//
|
|
35
|
+
// Compatibility shim: mutate the current context in place rather than
|
|
36
|
+
// setting a new FiberRef value. See the JSDoc above — this preserves
|
|
37
|
+
// behavior for legacy callers and is intentional, not a bug. Remove once
|
|
38
|
+
// those callers adopt the Effect-returning core
|
|
39
|
+
// updateCurrentCorrelationContext.
|
|
16
40
|
const next = mergeCoreCorrelationContext(current, patch);
|
|
17
41
|
if (!next)
|
|
18
42
|
return;
|
package/src/index.d.ts
CHANGED
|
@@ -342,6 +342,7 @@ type SmithersEvent$2 = {
|
|
|
342
342
|
nodeId: string;
|
|
343
343
|
iteration: number;
|
|
344
344
|
attempt: number;
|
|
345
|
+
toolCallId: string;
|
|
345
346
|
toolName: string;
|
|
346
347
|
seq: number;
|
|
347
348
|
timestampMs: number;
|
|
@@ -351,6 +352,7 @@ type SmithersEvent$2 = {
|
|
|
351
352
|
nodeId: string;
|
|
352
353
|
iteration: number;
|
|
353
354
|
attempt: number;
|
|
355
|
+
toolCallId: string;
|
|
354
356
|
toolName: string;
|
|
355
357
|
seq: number;
|
|
356
358
|
status: "success" | "error";
|