@goodtiming/baton-sdk 0.5.5 → 0.5.6

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 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.5";
96
+ var SDK_VERSION = "ts-0.5.6";
97
97
 
98
98
  // src/events.ts
99
99
  var import_zod = require("zod");
@@ -204,7 +204,6 @@ var AnnotationPayloadSchema = import_zod.z.object({
204
204
  workflow: import_zod.z.string().nullable().default(null),
205
205
  suggested_improvement: import_zod.z.string().nullable().default(null),
206
206
  context: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).nullable().default(null),
207
- intent_source: import_zod.z.string().nullable().default(null),
208
207
  tool_name: import_zod.z.string().nullable().default(null)
209
208
  }).strict();
210
209
  var SurfaceSnapshotPayloadSchema = import_zod.z.object({
@@ -1767,18 +1766,6 @@ var BatonHandle = class {
1767
1766
  }
1768
1767
  };
1769
1768
 
1770
- // src/integrations/mcp/proactiveTracker.ts
1771
- var ProactiveTracker = class {
1772
- emitted = /* @__PURE__ */ new Set();
1773
- /** Claim the session's proactive slot. Returns true exactly once per
1774
- * session (the caller should then emit); false if already claimed. */
1775
- claim(sessionId) {
1776
- if (this.emitted.has(sessionId)) return false;
1777
- this.emitted.add(sessionId);
1778
- return true;
1779
- }
1780
- };
1781
-
1782
1769
  // src/integrations/mcp/sessionCounter.ts
1783
1770
  var SessionCounter = class {
1784
1771
  counters = /* @__PURE__ */ new Map();
@@ -2073,7 +2060,6 @@ async function openCall(ctx, toolName, extra, params, registered = true) {
2073
2060
  const scrubbedIntent = scrubOrNull(ctx.scrubber, rawIntent, USER_GOAL_PARAM_NAME);
2074
2061
  const scrubbedExpected = scrubOrNull(ctx.scrubber, rawExpected, EXPECTED_RESULT_PARAM_NAME);
2075
2062
  const scrubbedWorkflow = scrubOrNull(ctx.scrubber, rawWorkflow, OVERALL_TASK_PARAM_NAME);
2076
- const callId = uuid7();
2077
2063
  const principal = await resolveCallPrincipal(
2078
2064
  ctx.resolvePrincipal,
2079
2065
  { extra, toolName, arguments: params }
@@ -2083,36 +2069,21 @@ async function openCall(ctx, toolName, extra, params, registered = true) {
2083
2069
  vendor_id: ctx.vendorId,
2084
2070
  session_id: sessionId,
2085
2071
  consent_token: ctx.consentToken,
2086
- // Every `...common` site is an event with a caller. `surface_snapshot`
2087
- // is deliberately not among them: it describes the SERVER and is captured
2088
- // outside any call, so it has no caller, transport or client to name.
2072
+ // Every `...common` site is an event of this call, so `call_id` rides in
2073
+ // it. `surface_snapshot` is deliberately not among them: it describes the
2074
+ // SERVER and is captured outside any call, so it has no caller, transport
2075
+ // or client to name.
2089
2076
  principal,
2090
2077
  transport_observed: observeTransport(extra),
2091
2078
  session_id_origin: origin,
2092
2079
  client_observed: observeClient(extra, ctx),
2093
- runtime_meta: scrubbedMeta
2080
+ runtime_meta: scrubbedMeta,
2081
+ call_id: uuid7()
2094
2082
  };
2095
- if (scrubbedIntent !== null && ctx.tracker.claim(sessionId)) {
2096
- await emit(
2097
- ctx.sink,
2098
- () => AnnotationEventSchema.parse({
2099
- ...common,
2100
- sequence_number: ctx.counter.next(sessionId),
2101
- captured_at: (/* @__PURE__ */ new Date()).toISOString(),
2102
- payload: {
2103
- intent: scrubbedIntent,
2104
- expected_outcome: scrubbedExpected,
2105
- intent_source: INTENT_SOURCE_PARAM,
2106
- tool_name: toolName
2107
- }
2108
- })
2109
- );
2110
- }
2111
2083
  await emit(
2112
2084
  ctx.sink,
2113
2085
  () => ToolCallStartEventSchema.parse({
2114
2086
  ...common,
2115
- call_id: callId,
2116
2087
  sequence_number: ctx.counter.next(sessionId),
2117
2088
  captured_at: (/* @__PURE__ */ new Date()).toISOString(),
2118
2089
  payload: {
@@ -2126,7 +2097,7 @@ async function openCall(ctx, toolName, extra, params, registered = true) {
2126
2097
  }
2127
2098
  })
2128
2099
  );
2129
- return { common, callId, sessionId };
2100
+ return { common, sessionId };
2130
2101
  }
2131
2102
  function batonWrap(nameRef, original, ctx) {
2132
2103
  return async (...callArgs) => {
@@ -2135,7 +2106,7 @@ function batonWrap(nameRef, original, ctx) {
2135
2106
  if (slot) slot.innerFired = true;
2136
2107
  const extra = callArgs[callArgs.length - 1];
2137
2108
  const params = (callArgs.length > 1 ? callArgs[0] : void 0) ?? {};
2138
- const { common, callId, sessionId } = await openCall(ctx, toolName, extra, params);
2109
+ const { common, sessionId } = await openCall(ctx, toolName, extra, params);
2139
2110
  const terminate = async (build, replacement) => {
2140
2111
  if (!slot) {
2141
2112
  await emit(ctx.sink, build);
@@ -2161,7 +2132,6 @@ function batonWrap(nameRef, original, ctx) {
2161
2132
  await parkFailure(
2162
2133
  () => ToolCallErrorEventSchema.parse({
2163
2134
  ...common,
2164
- call_id: callId,
2165
2135
  sequence_number: ctx.counter.next(sessionId),
2166
2136
  captured_at: (/* @__PURE__ */ new Date()).toISOString(),
2167
2137
  payload: {
@@ -2197,7 +2167,6 @@ function batonWrap(nameRef, original, ctx) {
2197
2167
  await parkFailure(
2198
2168
  () => ToolCallErrorEventSchema.parse({
2199
2169
  ...common,
2200
- call_id: callId,
2201
2170
  sequence_number: ctx.counter.next(sessionId),
2202
2171
  captured_at: (/* @__PURE__ */ new Date()).toISOString(),
2203
2172
  payload: {
@@ -2228,7 +2197,6 @@ function batonWrap(nameRef, original, ctx) {
2228
2197
  await parkSuccess(
2229
2198
  () => ToolCallEndEventSchema.parse({
2230
2199
  ...common,
2231
- call_id: callId,
2232
2200
  sequence_number: ctx.counter.next(sessionId),
2233
2201
  captured_at: (/* @__PURE__ */ new Date()).toISOString(),
2234
2202
  payload: {
@@ -2245,7 +2213,6 @@ function batonWrap(nameRef, original, ctx) {
2245
2213
  // CALLER saw fail, which is a success the product invented.
2246
2214
  (outcome) => ToolCallErrorEventSchema.parse({
2247
2215
  ...common,
2248
- call_id: callId,
2249
2216
  sequence_number: ctx.counter.next(sessionId),
2250
2217
  captured_at: (/* @__PURE__ */ new Date()).toISOString(),
2251
2218
  payload: {
@@ -2639,7 +2606,7 @@ async function emitRequestSideFailure(outcome, args, toolEntry, ctx) {
2639
2606
  const entry = toolEntry(toolName);
2640
2607
  if (entry != null && dispatchTarget(entry)?.[BATON_WRAPPED] !== true) return;
2641
2608
  const params = { ...request?.params?.arguments ?? {} };
2642
- const { common, callId, sessionId } = await openCall(
2609
+ const { common, sessionId } = await openCall(
2643
2610
  ctx,
2644
2611
  toolName,
2645
2612
  args[1],
@@ -2651,7 +2618,6 @@ async function emitRequestSideFailure(outcome, args, toolEntry, ctx) {
2651
2618
  ctx.sink,
2652
2619
  () => ToolCallErrorEventSchema.parse({
2653
2620
  ...common,
2654
- call_id: callId,
2655
2621
  sequence_number: ctx.counter.next(sessionId),
2656
2622
  captured_at: (/* @__PURE__ */ new Date()).toISOString(),
2657
2623
  payload: {
@@ -2861,7 +2827,6 @@ function install(server, supplied, resolved, emittedSurfaceHashes) {
2861
2827
  return { type: "object", properties: {} };
2862
2828
  }
2863
2829
  };
2864
- const tracker = new ProactiveTracker();
2865
2830
  const ctx = {
2866
2831
  sink,
2867
2832
  counter: counter2,
@@ -2879,7 +2844,6 @@ function install(server, supplied, resolved, emittedSurfaceHashes) {
2879
2844
  vendorToolJsonSchema,
2880
2845
  bustSchemaMemo,
2881
2846
  dropSubagentClause,
2882
- tracker,
2883
2847
  surfaceState,
2884
2848
  emitSurface
2885
2849
  };