@goodtiming/baton-sdk 0.5.4 → 0.5.5
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 +24 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -93,7 +93,7 @@ __export(index_exports, {
|
|
|
93
93
|
module.exports = __toCommonJS(index_exports);
|
|
94
94
|
|
|
95
95
|
// src/version.ts
|
|
96
|
-
var SDK_VERSION = "ts-0.5.
|
|
96
|
+
var SDK_VERSION = "ts-0.5.5";
|
|
97
97
|
|
|
98
98
|
// src/events.ts
|
|
99
99
|
var import_zod = require("zod");
|
|
@@ -240,6 +240,7 @@ var envelopeShape = {
|
|
|
240
240
|
agent_runtime: import_zod.z.string().default("unknown"),
|
|
241
241
|
principal: PrincipalWireSchema.nullable().default(null),
|
|
242
242
|
transport_observed: import_zod.z.string().nullable().default(null),
|
|
243
|
+
session_id_origin: import_zod.z.string().nullable().default(null),
|
|
243
244
|
client_observed: ClientObservedSchema.nullable().default(null),
|
|
244
245
|
call_id: import_zod.z.string().nullable().default(null),
|
|
245
246
|
runtime_meta: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).nullable().default(null)
|
|
@@ -1213,8 +1214,20 @@ function observeClient(extra, options) {
|
|
|
1213
1214
|
|
|
1214
1215
|
// src/integrations/mcp/sessionResolution.ts
|
|
1215
1216
|
async function resolveSessionId(fallbackSessionId, extra) {
|
|
1216
|
-
if (typeof extra.sessionId === "string" && extra.sessionId)
|
|
1217
|
-
|
|
1217
|
+
if (typeof extra.sessionId === "string" && extra.sessionId) {
|
|
1218
|
+
return { sessionId: extra.sessionId, origin: "observed" };
|
|
1219
|
+
}
|
|
1220
|
+
const fromHeader = sessionIdFromHeader(extra);
|
|
1221
|
+
if (fromHeader !== null) return { sessionId: fromHeader, origin: "observed" };
|
|
1222
|
+
return { sessionId: fallbackSessionId, origin: "minted" };
|
|
1223
|
+
}
|
|
1224
|
+
function sessionIdFromHeader(extra) {
|
|
1225
|
+
try {
|
|
1226
|
+
const value = extraHeaders(extra)?.get("mcp-session-id")?.trim();
|
|
1227
|
+
return value ? value : null;
|
|
1228
|
+
} catch {
|
|
1229
|
+
return null;
|
|
1230
|
+
}
|
|
1218
1231
|
}
|
|
1219
1232
|
|
|
1220
1233
|
// src/integrations/mcp/annotation.ts
|
|
@@ -1265,7 +1278,7 @@ function registerAnnotationTool(server, options) {
|
|
|
1265
1278
|
meta ? roundMetaCoordinates(meta) : null,
|
|
1266
1279
|
"_meta"
|
|
1267
1280
|
);
|
|
1268
|
-
const sessionId = await resolveSessionId(options.fallbackSessionId, extra);
|
|
1281
|
+
const { sessionId, origin } = await resolveSessionId(options.fallbackSessionId, extra);
|
|
1269
1282
|
const principal = await resolveCallPrincipal(
|
|
1270
1283
|
options.resolvePrincipal,
|
|
1271
1284
|
{ extra, toolName: name, arguments: args }
|
|
@@ -1281,6 +1294,7 @@ function registerAnnotationTool(server, options) {
|
|
|
1281
1294
|
consent_token: options.consentToken,
|
|
1282
1295
|
principal,
|
|
1283
1296
|
transport_observed: observeTransport(extra),
|
|
1297
|
+
session_id_origin: origin,
|
|
1284
1298
|
client_observed: observeClient(extra, { server, scrubber: options.scrubber }),
|
|
1285
1299
|
runtime_meta: scrubbedMeta,
|
|
1286
1300
|
payload: {
|
|
@@ -2040,12 +2054,12 @@ function messageOf(err) {
|
|
|
2040
2054
|
async function resolveEnvelopeParts(ctx, extra) {
|
|
2041
2055
|
const meta = extraMeta(extra);
|
|
2042
2056
|
const scrubbedMeta = scrubOrNull(ctx.scrubber, meta ? roundMetaCoordinates(meta) : null, "_meta");
|
|
2043
|
-
const
|
|
2044
|
-
return {
|
|
2057
|
+
const session = await resolveSessionId(ctx.fallbackSessionId, extra);
|
|
2058
|
+
return { ...session, scrubbedMeta };
|
|
2045
2059
|
}
|
|
2046
2060
|
async function openCall(ctx, toolName, extra, params, registered = true) {
|
|
2047
2061
|
await maybeEmitSurfaceSnapshot(ctx);
|
|
2048
|
-
const { sessionId, scrubbedMeta } = await resolveEnvelopeParts(ctx, extra);
|
|
2062
|
+
const { sessionId, origin, scrubbedMeta } = await resolveEnvelopeParts(ctx, extra);
|
|
2049
2063
|
const dispositions = ctx.paramRegistry.get(toolName);
|
|
2050
2064
|
const rawIntent = extractGoalParam(params, USER_GOAL_PARAM_NAME, toolName, dispositions, registered);
|
|
2051
2065
|
const rawExpected = extractGoalParam(
|
|
@@ -2074,6 +2088,7 @@ async function openCall(ctx, toolName, extra, params, registered = true) {
|
|
|
2074
2088
|
// outside any call, so it has no caller, transport or client to name.
|
|
2075
2089
|
principal,
|
|
2076
2090
|
transport_observed: observeTransport(extra),
|
|
2091
|
+
session_id_origin: origin,
|
|
2077
2092
|
client_observed: observeClient(extra, ctx),
|
|
2078
2093
|
runtime_meta: scrubbedMeta
|
|
2079
2094
|
};
|
|
@@ -2459,6 +2474,7 @@ async function openLifecycleCall(ctx, spec, requestParams, extra) {
|
|
|
2459
2474
|
consent_token: ctx.consentToken,
|
|
2460
2475
|
principal,
|
|
2461
2476
|
transport_observed: observeTransport(extra),
|
|
2477
|
+
session_id_origin: parts.origin,
|
|
2462
2478
|
client_observed: observeClient(extra, ctx),
|
|
2463
2479
|
runtime_meta: parts.scrubbedMeta
|
|
2464
2480
|
}
|
|
@@ -2796,6 +2812,7 @@ function install(server, supplied, resolved, emittedSurfaceHashes) {
|
|
|
2796
2812
|
tenant_id: tenantId,
|
|
2797
2813
|
vendor_id: config.vendorId,
|
|
2798
2814
|
session_id: sessionId,
|
|
2815
|
+
session_id_origin: "minted",
|
|
2799
2816
|
consent_token: config.consentToken,
|
|
2800
2817
|
sequence_number: counter2.next(sessionId),
|
|
2801
2818
|
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|