@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.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = "ts-0.5.
|
|
2
|
+
var SDK_VERSION = "ts-0.5.5";
|
|
3
3
|
|
|
4
4
|
// src/events.ts
|
|
5
5
|
import { z } from "zod";
|
|
@@ -146,6 +146,7 @@ var envelopeShape = {
|
|
|
146
146
|
agent_runtime: z.string().default("unknown"),
|
|
147
147
|
principal: PrincipalWireSchema.nullable().default(null),
|
|
148
148
|
transport_observed: z.string().nullable().default(null),
|
|
149
|
+
session_id_origin: z.string().nullable().default(null),
|
|
149
150
|
client_observed: ClientObservedSchema.nullable().default(null),
|
|
150
151
|
call_id: z.string().nullable().default(null),
|
|
151
152
|
runtime_meta: z.record(z.string(), z.unknown()).nullable().default(null)
|
|
@@ -1119,8 +1120,20 @@ function observeClient(extra, options) {
|
|
|
1119
1120
|
|
|
1120
1121
|
// src/integrations/mcp/sessionResolution.ts
|
|
1121
1122
|
async function resolveSessionId(fallbackSessionId, extra) {
|
|
1122
|
-
if (typeof extra.sessionId === "string" && extra.sessionId)
|
|
1123
|
-
|
|
1123
|
+
if (typeof extra.sessionId === "string" && extra.sessionId) {
|
|
1124
|
+
return { sessionId: extra.sessionId, origin: "observed" };
|
|
1125
|
+
}
|
|
1126
|
+
const fromHeader = sessionIdFromHeader(extra);
|
|
1127
|
+
if (fromHeader !== null) return { sessionId: fromHeader, origin: "observed" };
|
|
1128
|
+
return { sessionId: fallbackSessionId, origin: "minted" };
|
|
1129
|
+
}
|
|
1130
|
+
function sessionIdFromHeader(extra) {
|
|
1131
|
+
try {
|
|
1132
|
+
const value = extraHeaders(extra)?.get("mcp-session-id")?.trim();
|
|
1133
|
+
return value ? value : null;
|
|
1134
|
+
} catch {
|
|
1135
|
+
return null;
|
|
1136
|
+
}
|
|
1124
1137
|
}
|
|
1125
1138
|
|
|
1126
1139
|
// src/integrations/mcp/annotation.ts
|
|
@@ -1171,7 +1184,7 @@ function registerAnnotationTool(server, options) {
|
|
|
1171
1184
|
meta ? roundMetaCoordinates(meta) : null,
|
|
1172
1185
|
"_meta"
|
|
1173
1186
|
);
|
|
1174
|
-
const sessionId = await resolveSessionId(options.fallbackSessionId, extra);
|
|
1187
|
+
const { sessionId, origin } = await resolveSessionId(options.fallbackSessionId, extra);
|
|
1175
1188
|
const principal = await resolveCallPrincipal(
|
|
1176
1189
|
options.resolvePrincipal,
|
|
1177
1190
|
{ extra, toolName: name, arguments: args }
|
|
@@ -1187,6 +1200,7 @@ function registerAnnotationTool(server, options) {
|
|
|
1187
1200
|
consent_token: options.consentToken,
|
|
1188
1201
|
principal,
|
|
1189
1202
|
transport_observed: observeTransport(extra),
|
|
1203
|
+
session_id_origin: origin,
|
|
1190
1204
|
client_observed: observeClient(extra, { server, scrubber: options.scrubber }),
|
|
1191
1205
|
runtime_meta: scrubbedMeta,
|
|
1192
1206
|
payload: {
|
|
@@ -1946,12 +1960,12 @@ function messageOf(err) {
|
|
|
1946
1960
|
async function resolveEnvelopeParts(ctx, extra) {
|
|
1947
1961
|
const meta = extraMeta(extra);
|
|
1948
1962
|
const scrubbedMeta = scrubOrNull(ctx.scrubber, meta ? roundMetaCoordinates(meta) : null, "_meta");
|
|
1949
|
-
const
|
|
1950
|
-
return {
|
|
1963
|
+
const session = await resolveSessionId(ctx.fallbackSessionId, extra);
|
|
1964
|
+
return { ...session, scrubbedMeta };
|
|
1951
1965
|
}
|
|
1952
1966
|
async function openCall(ctx, toolName, extra, params, registered = true) {
|
|
1953
1967
|
await maybeEmitSurfaceSnapshot(ctx);
|
|
1954
|
-
const { sessionId, scrubbedMeta } = await resolveEnvelopeParts(ctx, extra);
|
|
1968
|
+
const { sessionId, origin, scrubbedMeta } = await resolveEnvelopeParts(ctx, extra);
|
|
1955
1969
|
const dispositions = ctx.paramRegistry.get(toolName);
|
|
1956
1970
|
const rawIntent = extractGoalParam(params, USER_GOAL_PARAM_NAME, toolName, dispositions, registered);
|
|
1957
1971
|
const rawExpected = extractGoalParam(
|
|
@@ -1980,6 +1994,7 @@ async function openCall(ctx, toolName, extra, params, registered = true) {
|
|
|
1980
1994
|
// outside any call, so it has no caller, transport or client to name.
|
|
1981
1995
|
principal,
|
|
1982
1996
|
transport_observed: observeTransport(extra),
|
|
1997
|
+
session_id_origin: origin,
|
|
1983
1998
|
client_observed: observeClient(extra, ctx),
|
|
1984
1999
|
runtime_meta: scrubbedMeta
|
|
1985
2000
|
};
|
|
@@ -2365,6 +2380,7 @@ async function openLifecycleCall(ctx, spec, requestParams, extra) {
|
|
|
2365
2380
|
consent_token: ctx.consentToken,
|
|
2366
2381
|
principal,
|
|
2367
2382
|
transport_observed: observeTransport(extra),
|
|
2383
|
+
session_id_origin: parts.origin,
|
|
2368
2384
|
client_observed: observeClient(extra, ctx),
|
|
2369
2385
|
runtime_meta: parts.scrubbedMeta
|
|
2370
2386
|
}
|
|
@@ -2702,6 +2718,7 @@ function install(server, supplied, resolved, emittedSurfaceHashes) {
|
|
|
2702
2718
|
tenant_id: tenantId,
|
|
2703
2719
|
vendor_id: config.vendorId,
|
|
2704
2720
|
session_id: sessionId,
|
|
2721
|
+
session_id_origin: "minted",
|
|
2705
2722
|
consent_token: config.consentToken,
|
|
2706
2723
|
sequence_number: counter2.next(sessionId),
|
|
2707
2724
|
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|