@goodtiming/baton-sdk 0.6.8 → 1.0.1
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 +56 -4
- package/dist/index.cjs +808 -282
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +357 -139
- package/dist/index.d.ts +357 -139
- package/dist/index.js +808 -232
- 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.
|
|
2
|
+
var SDK_VERSION = "ts-1.0.1";
|
|
3
3
|
|
|
4
4
|
// src/events.ts
|
|
5
5
|
import { z } from "zod";
|
|
@@ -129,6 +129,11 @@ var ClientObservedSchema = z.object({
|
|
|
129
129
|
info: z.object({ name: z.string().optional(), version: z.string().optional() }).strict().optional(),
|
|
130
130
|
headers: z.object({ "user-agent": z.string().optional(), "x-anthropic-client": z.string().optional() }).strict().optional()
|
|
131
131
|
}).strict();
|
|
132
|
+
var CaptureObservedSchema = z.object({
|
|
133
|
+
settings_version: z.number().int().min(1).optional(),
|
|
134
|
+
audience: z.string().optional(),
|
|
135
|
+
overlay: z.string().optional()
|
|
136
|
+
}).strict();
|
|
132
137
|
var PrincipalWireSchema = z.object({
|
|
133
138
|
id: z.string(),
|
|
134
139
|
source: z.string(),
|
|
@@ -149,6 +154,10 @@ var envelopeShape = {
|
|
|
149
154
|
agent_runtime: z.string().default("unknown"),
|
|
150
155
|
principal: PrincipalWireSchema.nullable().default(null),
|
|
151
156
|
organization: PrincipalWireSchema.nullable().default(null),
|
|
157
|
+
// No length rules here: zod counts UTF-16 units, SPEC §11.4 code points.
|
|
158
|
+
// `cleanLabels` applies them.
|
|
159
|
+
labels: z.array(z.string()).nullable().default(null),
|
|
160
|
+
capture: CaptureObservedSchema.nullable().default(null),
|
|
152
161
|
transport_observed: z.string().nullable().default(null),
|
|
153
162
|
session_id_origin: z.string().nullable().default(null),
|
|
154
163
|
client_observed: ClientObservedSchema.nullable().default(null),
|
|
@@ -508,7 +517,8 @@ function identityScrub(value) {
|
|
|
508
517
|
}
|
|
509
518
|
|
|
510
519
|
// src/sinks.ts
|
|
511
|
-
import {
|
|
520
|
+
import { appendFileSync } from "fs";
|
|
521
|
+
import { open } from "fs/promises";
|
|
512
522
|
|
|
513
523
|
// src/_text.ts
|
|
514
524
|
var WHITE_SPACE = /^\p{White_Space}$/u;
|
|
@@ -648,6 +658,7 @@ function timerMsOption(given, name, fallback) {
|
|
|
648
658
|
function shutdownBudgetMs(sink) {
|
|
649
659
|
try {
|
|
650
660
|
if (sink instanceof MultiSink) return Math.max(...sink["sinks"].map(shutdownBudgetMs));
|
|
661
|
+
if (sink instanceof QueuedSink) return shutdownBudgetMs(sink.inner);
|
|
651
662
|
const budget = sink instanceof HttpSink ? sink["shutdownFlushTimeoutMs"] : void 0;
|
|
652
663
|
if (isTimerMs(budget)) return budget;
|
|
653
664
|
} catch {
|
|
@@ -692,22 +703,32 @@ var FileSink = class {
|
|
|
692
703
|
this.path = path;
|
|
693
704
|
}
|
|
694
705
|
path;
|
|
695
|
-
|
|
706
|
+
file = null;
|
|
707
|
+
closeOnce;
|
|
708
|
+
/** Writes run one after another: two at once on one file can interleave. */
|
|
709
|
+
last = Promise.resolve();
|
|
696
710
|
closed = false;
|
|
697
711
|
async write(event) {
|
|
698
712
|
if (this.closed) throw new SinkClosedError("FileSink is closed");
|
|
699
|
-
|
|
700
|
-
|
|
713
|
+
const line = JSON.stringify(event) + "\n";
|
|
714
|
+
const written = this.last.then(async () => {
|
|
715
|
+
this.file ??= await open(this.path, "a");
|
|
716
|
+
await this.file.appendFile(line);
|
|
717
|
+
});
|
|
718
|
+
this.last = written.catch(() => void 0);
|
|
719
|
+
await written;
|
|
701
720
|
}
|
|
702
721
|
async flush() {
|
|
722
|
+
await this.last;
|
|
703
723
|
}
|
|
704
|
-
|
|
705
|
-
|
|
724
|
+
/** A second call waits for the first (SPEC §11.2 rule 7). */
|
|
725
|
+
aclose() {
|
|
706
726
|
this.closed = true;
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
this.
|
|
710
|
-
}
|
|
727
|
+
this.closeOnce ??= this.last.then(async () => {
|
|
728
|
+
await this.file?.close();
|
|
729
|
+
this.file = null;
|
|
730
|
+
});
|
|
731
|
+
return this.closeOnce;
|
|
711
732
|
}
|
|
712
733
|
};
|
|
713
734
|
var MultiSink = class {
|
|
@@ -740,6 +761,194 @@ var MultiSink = class {
|
|
|
740
761
|
throw new AggregateError(errors, "MultiSink fan-out failures");
|
|
741
762
|
}
|
|
742
763
|
};
|
|
764
|
+
var QUEUE_BOUND = 1e3;
|
|
765
|
+
var WRITES_PER_TURN = 100;
|
|
766
|
+
var CLOSE_GRACE_MS = 250;
|
|
767
|
+
var later = (run) => {
|
|
768
|
+
if (typeof setImmediate === "function") setImmediate(run);
|
|
769
|
+
else setTimeout(run, 0);
|
|
770
|
+
};
|
|
771
|
+
var withUnwrittenEvents = /* @__PURE__ */ new Set();
|
|
772
|
+
var exitHooked = false;
|
|
773
|
+
function hookExit() {
|
|
774
|
+
if (exitHooked) return;
|
|
775
|
+
exitHooked = true;
|
|
776
|
+
try {
|
|
777
|
+
process.on("exit", () => {
|
|
778
|
+
try {
|
|
779
|
+
let unsure = 0;
|
|
780
|
+
for (const sink of withUnwrittenEvents) unsure += sink.handOffAtExit();
|
|
781
|
+
if (unsure > 0) stderrLine(`baton: process exiting; ${unsure} event(s) may not have been written.`);
|
|
782
|
+
} catch {
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
} catch {
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function writeNow(sink, events) {
|
|
789
|
+
const lines = events.map((event) => JSON.stringify(event) + "\n").join("");
|
|
790
|
+
if (sink instanceof StdoutSink) {
|
|
791
|
+
const stream = sink["stream"];
|
|
792
|
+
if (stream !== process.stdout && stream !== process.stderr) return false;
|
|
793
|
+
if (!sink["closed"]) stream.write(lines);
|
|
794
|
+
} else if (sink instanceof FileSink) {
|
|
795
|
+
if (!sink["closed"]) appendFileSync(sink["path"], lines);
|
|
796
|
+
} else return false;
|
|
797
|
+
return true;
|
|
798
|
+
}
|
|
799
|
+
var QueuedSink = class {
|
|
800
|
+
constructor(inner) {
|
|
801
|
+
this.inner = inner;
|
|
802
|
+
}
|
|
803
|
+
inner;
|
|
804
|
+
queue = [];
|
|
805
|
+
closed = false;
|
|
806
|
+
draining = false;
|
|
807
|
+
/** Set when close ran out of time or the process is exiting: what was left is already handled. */
|
|
808
|
+
abandoned = false;
|
|
809
|
+
inFlight = 0;
|
|
810
|
+
/** A flush waits until `settled`, the events written or lost, reaches `taken` as it was. */
|
|
811
|
+
taken = 0;
|
|
812
|
+
settled = 0;
|
|
813
|
+
/** Writes that returned, so a dropped event does not look like progress. */
|
|
814
|
+
ended = 0;
|
|
815
|
+
/** `ended` when a flush waited its whole budget: until a write ends, later flushes return at once. */
|
|
816
|
+
stuckAt = null;
|
|
817
|
+
waiters = [];
|
|
818
|
+
overflowWarned = false;
|
|
819
|
+
failWarned = false;
|
|
820
|
+
copyWarned = false;
|
|
821
|
+
closeOnce;
|
|
822
|
+
get unwritten() {
|
|
823
|
+
return this.queue.length + this.inFlight;
|
|
824
|
+
}
|
|
825
|
+
/** Writes what waits to a `StdoutSink` or `FileSink` at once; answers how
|
|
826
|
+
* many events may not be written. */
|
|
827
|
+
handOffAtExit() {
|
|
828
|
+
this.abandoned = true;
|
|
829
|
+
const waiting = this.queue.splice(0);
|
|
830
|
+
let written = false;
|
|
831
|
+
try {
|
|
832
|
+
written = waiting.length === 0 || writeNow(this.inner, waiting);
|
|
833
|
+
} catch {
|
|
834
|
+
}
|
|
835
|
+
return this.inFlight + (written ? 0 : waiting.length);
|
|
836
|
+
}
|
|
837
|
+
async write(event) {
|
|
838
|
+
if (this.closed) throw new SinkClosedError("the sink is closed");
|
|
839
|
+
let copy;
|
|
840
|
+
try {
|
|
841
|
+
copy = JSON.parse(JSON.stringify(event));
|
|
842
|
+
} catch (err) {
|
|
843
|
+
PROCESS_DROPS.add("encode_failed");
|
|
844
|
+
if (!this.copyWarned) {
|
|
845
|
+
this.copyWarned = true;
|
|
846
|
+
warn(`baton: an event could not be copied and was dropped (${err?.name ?? "Error"}). Later ones are not logged.`);
|
|
847
|
+
}
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
this.queue.push(copy);
|
|
851
|
+
this.taken++;
|
|
852
|
+
if (this.queue.length > QUEUE_BOUND) {
|
|
853
|
+
this.queue.shift();
|
|
854
|
+
this.settle();
|
|
855
|
+
PROCESS_DROPS.add("buffer_full");
|
|
856
|
+
if (!this.overflowWarned) {
|
|
857
|
+
this.overflowWarned = true;
|
|
858
|
+
warn(`baton: the sink's queue is full (${QUEUE_BOUND}); oldest events dropped. Further overflows will be silent.`);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
withUnwrittenEvents.add(this);
|
|
862
|
+
hookExit();
|
|
863
|
+
if (!this.draining) {
|
|
864
|
+
this.draining = true;
|
|
865
|
+
later(() => void this.drain());
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
/** Waits for the events written before it, not for later ones (SPEC §11.2 rule 7). */
|
|
869
|
+
async flush() {
|
|
870
|
+
if (this.closed || this.stuckAt === this.ended) return;
|
|
871
|
+
const budget = shutdownBudgetMs(this.inner);
|
|
872
|
+
const start = performance.now();
|
|
873
|
+
if (await raceDeadline(this.settledUpTo(this.taken), budget) === TIMED_OUT) this.stuckAt = this.ended;
|
|
874
|
+
await callWithin(this.inner, "flush", Math.max(0, budget - (performance.now() - start)));
|
|
875
|
+
}
|
|
876
|
+
/** A second call waits for the first (SPEC §11.2 rule 7). */
|
|
877
|
+
aclose() {
|
|
878
|
+
this.closeOnce ??= this.close(shutdownBudgetMs(this.inner));
|
|
879
|
+
return this.closeOnce;
|
|
880
|
+
}
|
|
881
|
+
/** Takes events until the queue is empty, as `HttpSink` does, so an event
|
|
882
|
+
* recorded while close runs is not refused. */
|
|
883
|
+
async close(ms) {
|
|
884
|
+
const start = performance.now();
|
|
885
|
+
const deadline = start + ms - Math.min(CLOSE_GRACE_MS, ms / 2);
|
|
886
|
+
let timedOut = false;
|
|
887
|
+
while (this.settled < this.taken && !timedOut) {
|
|
888
|
+
timedOut = await raceDeadline(this.settledUpTo(this.taken), deadline - performance.now()) === TIMED_OUT;
|
|
889
|
+
}
|
|
890
|
+
this.closed = true;
|
|
891
|
+
if (timedOut) {
|
|
892
|
+
const unwritten = this.unwritten;
|
|
893
|
+
this.abandoned = true;
|
|
894
|
+
this.queue.length = 0;
|
|
895
|
+
withUnwrittenEvents.delete(this);
|
|
896
|
+
PROCESS_DROPS.add("unsent_at_close", unwritten);
|
|
897
|
+
warn(`baton: closed with ${unwritten} event(s) not yet written to the sink.`);
|
|
898
|
+
}
|
|
899
|
+
await callWithin(this.inner, "aclose", Math.max(0, ms - (performance.now() - start)));
|
|
900
|
+
}
|
|
901
|
+
async drain() {
|
|
902
|
+
try {
|
|
903
|
+
let event;
|
|
904
|
+
let written = 0;
|
|
905
|
+
while (!this.abandoned && (event = this.queue.shift()) !== void 0) {
|
|
906
|
+
this.inFlight = 1;
|
|
907
|
+
try {
|
|
908
|
+
await this.inner.write(event);
|
|
909
|
+
} catch (err) {
|
|
910
|
+
if (!this.abandoned) this.lose(err);
|
|
911
|
+
} finally {
|
|
912
|
+
this.inFlight = 0;
|
|
913
|
+
this.ended++;
|
|
914
|
+
this.settle();
|
|
915
|
+
}
|
|
916
|
+
if (++written % WRITES_PER_TURN === 0) await new Promise((resolve) => later(resolve));
|
|
917
|
+
}
|
|
918
|
+
} catch {
|
|
919
|
+
} finally {
|
|
920
|
+
this.draining = false;
|
|
921
|
+
if (this.queue.length === 0) withUnwrittenEvents.delete(this);
|
|
922
|
+
else if (!this.abandoned) {
|
|
923
|
+
this.draining = true;
|
|
924
|
+
later(() => void this.drain());
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
lose(err) {
|
|
929
|
+
if (isSinkClosed(err)) return droppedAfterClose(this);
|
|
930
|
+
PROCESS_DROPS.add("write_failed");
|
|
931
|
+
if (this.failWarned) return;
|
|
932
|
+
this.failWarned = true;
|
|
933
|
+
warn(`baton: the sink failed to write an event; it was dropped. Later failures are not logged: ${printable(err)}`);
|
|
934
|
+
}
|
|
935
|
+
settle() {
|
|
936
|
+
this.settled++;
|
|
937
|
+
this.waiters = this.waiters.filter((w) => {
|
|
938
|
+
if (w.upTo > this.settled) return true;
|
|
939
|
+
w.resolve();
|
|
940
|
+
return false;
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
settledUpTo(upTo) {
|
|
944
|
+
if (this.settled >= upTo) return Promise.resolve();
|
|
945
|
+
return new Promise((resolve) => this.waiters.push({ upTo, resolve }));
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
function offTheCall(sink) {
|
|
949
|
+
if (sink instanceof QueuedSink || sink instanceof HttpSink && sink.write === HttpSink.prototype.write) return sink;
|
|
950
|
+
return new QueuedSink(sink);
|
|
951
|
+
}
|
|
743
952
|
var BATCH_OPEN = '{"events":[';
|
|
744
953
|
var BATCH_CLOSE = "]}";
|
|
745
954
|
var BATCH_FRAME_BYTES = (BATCH_OPEN + BATCH_CLOSE).length;
|
|
@@ -1509,6 +1718,9 @@ function buildServerInstructions(options) {
|
|
|
1509
1718
|
function buildAnnotationToolDescription(options) {
|
|
1510
1719
|
return ANNOTATION_TOOL_DESCRIPTION_TEMPLATE(options.vendorDisplayName);
|
|
1511
1720
|
}
|
|
1721
|
+
function buildRefusalText(options) {
|
|
1722
|
+
return `${options.annotationToolName} is reactive-only on this server. Call it only AFTER a tool call returns an unhelpful, empty, failed or contradictory result, or when no tool covers what the user asked for. What the user is trying to do is already recorded on each tool call, so no pre-call annotation is needed \u2014 nothing was lost. If a tool call really went wrong, or no tool covers the request, call this again and say what_happened. If neither is true, do NOT re-send: that would file a report for a call that did not go wrong.`;
|
|
1723
|
+
}
|
|
1512
1724
|
var USER_GOAL_PARAM_NAME = "user_goal";
|
|
1513
1725
|
var EXPECTED_RESULT_PARAM_NAME = "expected_result";
|
|
1514
1726
|
var OVERALL_TASK_PARAM_NAME = "overall_task";
|
|
@@ -1586,9 +1798,12 @@ var PYTHON_SPACE = new RegExp(`^[\\p{White_Space}${SEPARATORS}]$`, "u");
|
|
|
1586
1798
|
function pythonStrip(value) {
|
|
1587
1799
|
return stripEdges(value, PYTHON_SPACE);
|
|
1588
1800
|
}
|
|
1801
|
+
function isPlaceholderLiteral(name) {
|
|
1802
|
+
return PLACEHOLDER_LITERALS.has(pythonStrip(name).toLowerCase());
|
|
1803
|
+
}
|
|
1589
1804
|
function isLibraryPlaceholder(serverName, className) {
|
|
1805
|
+
if (isPlaceholderLiteral(serverName)) return true;
|
|
1590
1806
|
const stripped = pythonStrip(serverName);
|
|
1591
|
-
if (PLACEHOLDER_LITERALS.has(stripped.toLowerCase())) return true;
|
|
1592
1807
|
const stem = stripped.replace(RANDOM_SUFFIX, "");
|
|
1593
1808
|
return stem !== stripped && stem === className;
|
|
1594
1809
|
}
|
|
@@ -1643,8 +1858,15 @@ function annotationToolNameFromServer(serverName, vendorDisplayName) {
|
|
|
1643
1858
|
}
|
|
1644
1859
|
return candidate;
|
|
1645
1860
|
}
|
|
1861
|
+
function toolNameForDisplayName(vendorDisplayName) {
|
|
1862
|
+
if (isPlaceholderLiteral(vendorDisplayName)) return void 0;
|
|
1863
|
+
const candidate = toolNameCandidate(vendorDisplayName);
|
|
1864
|
+
return candidate !== void 0 && fitsInstructionsCap({ vendorDisplayName, annotationToolName: candidate }) ? candidate : void 0;
|
|
1865
|
+
}
|
|
1646
1866
|
function deriveAnnotationToolName(vendorId2, override) {
|
|
1647
|
-
|
|
1867
|
+
return validateAnnotationToolName(override || `${vendorId2}${SUFFIX}`);
|
|
1868
|
+
}
|
|
1869
|
+
function validateAnnotationToolName(name) {
|
|
1648
1870
|
if (!TOOL_NAME_PATTERN.test(name)) {
|
|
1649
1871
|
throw new Error(
|
|
1650
1872
|
`Annotation tool name ${JSON.stringify(name)} violates the cross-runtime pattern ${TOOL_NAME_PATTERN.source} (Claude Desktop and others reject names with dots or other separators).`
|
|
@@ -1680,9 +1902,27 @@ var PRINCIPAL_FORM_RAW = "raw";
|
|
|
1680
1902
|
var PRINCIPAL_ID_MAX_LEN = 128;
|
|
1681
1903
|
var DISPLAY_NAME_MAX_LEN = 128;
|
|
1682
1904
|
function wireDisplayName(value) {
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1905
|
+
return usableText(value, DISPLAY_NAME_MAX_LEN) ? value : null;
|
|
1906
|
+
}
|
|
1907
|
+
function usableText(value, maxCodePoints) {
|
|
1908
|
+
if (typeof value !== "string" || exceedsCodePoints(value, maxCodePoints)) return false;
|
|
1909
|
+
return !LONE_SURROGATE.test(value) && !value.includes("\0") && !isBlank(value);
|
|
1910
|
+
}
|
|
1911
|
+
var LABELS_MAX = 20;
|
|
1912
|
+
var LABEL_MAX_LEN = 64;
|
|
1913
|
+
var LABELS_READ_MAX = 1e3;
|
|
1914
|
+
function wireLabels(labels) {
|
|
1915
|
+
return labels.length > 0 ? labels : null;
|
|
1916
|
+
}
|
|
1917
|
+
function cleanLabels(values) {
|
|
1918
|
+
const kept = /* @__PURE__ */ new Set();
|
|
1919
|
+
for (const value of values) {
|
|
1920
|
+
if (usableText(value, LABEL_MAX_LEN)) {
|
|
1921
|
+
kept.add(value);
|
|
1922
|
+
if (kept.size === LABELS_MAX) break;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
return [...kept];
|
|
1686
1926
|
}
|
|
1687
1927
|
var PRINCIPAL_FORMS = /* @__PURE__ */ new Set([PRINCIPAL_FORM_RAW, PRINCIPAL_FORM_HASHED]);
|
|
1688
1928
|
var LONE_SURROGATE = /\p{Surrogate}/u;
|
|
@@ -1700,7 +1940,7 @@ function readIdentity(result, idKey) {
|
|
|
1700
1940
|
const displayName = typeof candidate.displayName === "string" ? candidate.displayName : void 0;
|
|
1701
1941
|
return { id, form: candidate.form, displayName };
|
|
1702
1942
|
}
|
|
1703
|
-
var NO_CALLER = Object.freeze({ principal: null, organization: null });
|
|
1943
|
+
var NO_CALLER = Object.freeze({ principal: null, organization: null, labels: [] });
|
|
1704
1944
|
function callerFor(result, warn3) {
|
|
1705
1945
|
try {
|
|
1706
1946
|
return readCaller(result, warn3);
|
|
@@ -1717,7 +1957,11 @@ function readCaller(result, warn3) {
|
|
|
1717
1957
|
}
|
|
1718
1958
|
if (!("principalId" in result) && !("organization" in result)) {
|
|
1719
1959
|
if ("organizationId" in result) {
|
|
1720
|
-
return {
|
|
1960
|
+
return {
|
|
1961
|
+
principal: null,
|
|
1962
|
+
organization: identityFor(result, "organization", warn3),
|
|
1963
|
+
labels: labelsOf([result], warn3)
|
|
1964
|
+
};
|
|
1721
1965
|
}
|
|
1722
1966
|
if (typeof result.userId === "string") {
|
|
1723
1967
|
warn3(
|
|
@@ -1735,9 +1979,29 @@ function readCaller(result, warn3) {
|
|
|
1735
1979
|
const nested = result.organization;
|
|
1736
1980
|
return {
|
|
1737
1981
|
principal: identityFor(result, "principal", warn3),
|
|
1738
|
-
organization: nested == null ? null : identityFor(nested, "organization", warn3)
|
|
1982
|
+
organization: nested == null ? null : identityFor(nested, "organization", warn3),
|
|
1983
|
+
labels: labelsOf([result, nested], warn3)
|
|
1739
1984
|
};
|
|
1740
1985
|
}
|
|
1986
|
+
function labelsOf(sources, warn3) {
|
|
1987
|
+
const labels = [];
|
|
1988
|
+
for (const source of sources) {
|
|
1989
|
+
try {
|
|
1990
|
+
const given = source?.labels;
|
|
1991
|
+
if (typeof given === "string" || typeof given?.[Symbol.iterator] !== "function") {
|
|
1992
|
+
continue;
|
|
1993
|
+
}
|
|
1994
|
+
let read = 0;
|
|
1995
|
+
for (const label of given) {
|
|
1996
|
+
labels.push(label);
|
|
1997
|
+
if (++read === LABELS_READ_MAX) break;
|
|
1998
|
+
}
|
|
1999
|
+
} catch {
|
|
2000
|
+
warn3("labels", "labels could not be read \u2014 sending the ones read before the failure.");
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
return cleanLabels(labels);
|
|
2004
|
+
}
|
|
1741
2005
|
function identityFor(value, member, warn3) {
|
|
1742
2006
|
const idKey = member === "principal" ? "principalId" : "organizationId";
|
|
1743
2007
|
const identity = readIdentity(value, idKey);
|
|
@@ -1848,7 +2112,34 @@ function warnOnce(key, message) {
|
|
|
1848
2112
|
warned.add(key);
|
|
1849
2113
|
warn(`baton: resolvePrincipal ${message}`);
|
|
1850
2114
|
}
|
|
1851
|
-
|
|
2115
|
+
function callerEnvelope(caller) {
|
|
2116
|
+
return {
|
|
2117
|
+
principal: caller.principal,
|
|
2118
|
+
organization: caller.organization,
|
|
2119
|
+
labels: wireLabels(caller.labels),
|
|
2120
|
+
capture: caller.settings?.capture ?? null
|
|
2121
|
+
};
|
|
2122
|
+
}
|
|
2123
|
+
var settingsWarned = false;
|
|
2124
|
+
async function resolveCaller(hook, call, settings, client = null) {
|
|
2125
|
+
const caller = await resolveIdentity(hook, call);
|
|
2126
|
+
if (settings === void 0) return caller;
|
|
2127
|
+
try {
|
|
2128
|
+
const callSettings = settings.forCaller({
|
|
2129
|
+
labels: caller.labels,
|
|
2130
|
+
clientName: client?.info?.name ?? null,
|
|
2131
|
+
shareKey: caller.principal?.id ?? null
|
|
2132
|
+
});
|
|
2133
|
+
return callSettings === void 0 ? caller : { ...caller, settings: callSettings };
|
|
2134
|
+
} catch {
|
|
2135
|
+
if (!settingsWarned) {
|
|
2136
|
+
settingsWarned = true;
|
|
2137
|
+
warn("baton: applying capture settings failed; this request uses the config's values");
|
|
2138
|
+
}
|
|
2139
|
+
return caller;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
async function resolveIdentity(hook, call) {
|
|
1852
2143
|
if (hook === void 0) return NO_CALLER;
|
|
1853
2144
|
try {
|
|
1854
2145
|
const context = buildPrincipalResolutionContext(call.extra, call.toolName, call.arguments);
|
|
@@ -1998,6 +2289,15 @@ function sessionIdFromHeader(extra) {
|
|
|
1998
2289
|
|
|
1999
2290
|
// src/integrations/mcp/annotation.ts
|
|
2000
2291
|
var TOOL_NAME_PARAM_NAME = "tool_name";
|
|
2292
|
+
var ANNOTATION_INPUT_SHAPE = {
|
|
2293
|
+
user_goal: z2.string(),
|
|
2294
|
+
what_happened: z2.string().optional(),
|
|
2295
|
+
// Nullable so a report whose agent sends an explicit null is taken,
|
|
2296
|
+
// not rejected by validation.
|
|
2297
|
+
tool_name: z2.string().nullable().optional(),
|
|
2298
|
+
suggested_improvement: z2.string().optional(),
|
|
2299
|
+
context: z2.record(z2.string(), z2.unknown()).optional()
|
|
2300
|
+
};
|
|
2001
2301
|
function isReport(whatHappened) {
|
|
2002
2302
|
return typeof whatHappened === "string" && !isBlank(whatHappened);
|
|
2003
2303
|
}
|
|
@@ -2006,19 +2306,12 @@ function registerAnnotationTool(server, options) {
|
|
|
2006
2306
|
const description = buildAnnotationToolDescription({
|
|
2007
2307
|
vendorDisplayName: options.vendorDisplayName
|
|
2008
2308
|
});
|
|
2309
|
+
const refusal = buildRefusalText({ annotationToolName: name });
|
|
2009
2310
|
server.registerTool(
|
|
2010
2311
|
name,
|
|
2011
2312
|
{
|
|
2012
2313
|
description,
|
|
2013
|
-
inputSchema:
|
|
2014
|
-
user_goal: z2.string(),
|
|
2015
|
-
what_happened: z2.string().optional(),
|
|
2016
|
-
// Nullable so a report whose agent sends an explicit null is taken,
|
|
2017
|
-
// not rejected by validation.
|
|
2018
|
-
tool_name: z2.string().nullable().optional(),
|
|
2019
|
-
suggested_improvement: z2.string().optional(),
|
|
2020
|
-
context: z2.record(z2.string(), z2.unknown()).optional()
|
|
2021
|
-
}
|
|
2314
|
+
inputSchema: ANNOTATION_INPUT_SHAPE
|
|
2022
2315
|
},
|
|
2023
2316
|
async (args, extra) => {
|
|
2024
2317
|
const whatHappened = args.what_happened;
|
|
@@ -2029,7 +2322,7 @@ function registerAnnotationTool(server, options) {
|
|
|
2029
2322
|
type: "text",
|
|
2030
2323
|
text: JSON.stringify({
|
|
2031
2324
|
ok: false,
|
|
2032
|
-
error:
|
|
2325
|
+
error: refusal
|
|
2033
2326
|
})
|
|
2034
2327
|
}
|
|
2035
2328
|
]
|
|
@@ -2043,9 +2336,12 @@ function registerAnnotationTool(server, options) {
|
|
|
2043
2336
|
"_meta"
|
|
2044
2337
|
);
|
|
2045
2338
|
const session = await resolveSessionId(options.fallbackSessionId, extra);
|
|
2339
|
+
const client = observeClient(extra, { server, scrubber: options.scrubber });
|
|
2046
2340
|
const caller = await resolveCaller(
|
|
2047
2341
|
options.resolvePrincipal,
|
|
2048
|
-
{ extra, toolName: name, arguments: args }
|
|
2342
|
+
{ extra, toolName: name, arguments: args },
|
|
2343
|
+
options.captureSettings,
|
|
2344
|
+
client
|
|
2049
2345
|
);
|
|
2050
2346
|
await emit(
|
|
2051
2347
|
options.sink,
|
|
@@ -2056,11 +2352,10 @@ function registerAnnotationTool(server, options) {
|
|
|
2056
2352
|
sequence_number: options.counter.nextFor(session),
|
|
2057
2353
|
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2058
2354
|
consent_token: options.consentToken,
|
|
2059
|
-
|
|
2060
|
-
organization: caller.organization,
|
|
2355
|
+
...callerEnvelope(caller),
|
|
2061
2356
|
transport_observed: observeTransport(extra),
|
|
2062
2357
|
session_id_origin: session.origin,
|
|
2063
|
-
client_observed:
|
|
2358
|
+
client_observed: client,
|
|
2064
2359
|
runtime_meta: scrubbedMeta,
|
|
2065
2360
|
payload: {
|
|
2066
2361
|
// The agent-facing `user_goal` is stored as the wire key `intent`.
|
|
@@ -2353,10 +2648,195 @@ function scrubbedErrorBody(scrubber, text) {
|
|
|
2353
2648
|
return capCodePoints(String(scrubber(text)), ERROR_BODY_MAX_CODE_POINTS);
|
|
2354
2649
|
}
|
|
2355
2650
|
|
|
2356
|
-
// src/integrations/mcp/
|
|
2651
|
+
// src/integrations/mcp/captureSettings.ts
|
|
2652
|
+
import { createHash } from "crypto";
|
|
2653
|
+
var SETTINGS_PATH = "/v0/settings";
|
|
2654
|
+
var TENANT_HEADER = "X-Baton-Tenant-Id";
|
|
2655
|
+
var SETTINGS_MODES = ["local", "console"];
|
|
2656
|
+
var DEFAULT_SETTINGS_REFRESH_MS = 6e4;
|
|
2657
|
+
var MIN_SETTINGS_REFRESH_MS = 15e3;
|
|
2658
|
+
var REQUEST_TIMEOUT_MS = 1e4;
|
|
2659
|
+
var MATCH_KEYS = /* @__PURE__ */ new Set(["label", "client", "share"]);
|
|
2357
2660
|
var INTENT_PARAM_MODES = /* @__PURE__ */ new Set(["optional", "required"]);
|
|
2358
2661
|
var REPORT_MODES = /* @__PURE__ */ new Set(["on", "off"]);
|
|
2359
2662
|
var RESULT_CAPTURE_MODE_SET = new Set(RESULT_CAPTURE_MODES);
|
|
2663
|
+
function shareBucket(vendorId2, key) {
|
|
2664
|
+
const digest = createHash("sha256").update(`${vendorId2}
|
|
2665
|
+
${key}`, "utf-8").digest();
|
|
2666
|
+
return Number(digest.readBigUInt64BE(0) % 10000n);
|
|
2667
|
+
}
|
|
2668
|
+
function matchesEveryone(audience) {
|
|
2669
|
+
return audience.labels === null && audience.clients === null && audience.shareThreshold === null;
|
|
2670
|
+
}
|
|
2671
|
+
function matches(audience, caller, bucket) {
|
|
2672
|
+
if (audience.labels !== null && !caller.labels.some((label) => audience.labels.has(label))) return false;
|
|
2673
|
+
if (audience.clients !== null && (caller.clientName === null || !audience.clients.has(caller.clientName))) {
|
|
2674
|
+
return false;
|
|
2675
|
+
}
|
|
2676
|
+
if (audience.shareThreshold !== null && (bucket === null || bucket >= audience.shareThreshold)) return false;
|
|
2677
|
+
return true;
|
|
2678
|
+
}
|
|
2679
|
+
var SettingsDocument = class {
|
|
2680
|
+
constructor(version, audiences) {
|
|
2681
|
+
this.version = version;
|
|
2682
|
+
this.audiences = audiences;
|
|
2683
|
+
this.usesShare = audiences.some((a) => a.shareThreshold !== null);
|
|
2684
|
+
this.unmatched = { capture: { settings_version: version } };
|
|
2685
|
+
this.reportsOnForAnyone = audiences.some((a) => a.settings.reportMode !== "off") || !audiences.some(matchesEveryone);
|
|
2686
|
+
}
|
|
2687
|
+
version;
|
|
2688
|
+
audiences;
|
|
2689
|
+
usesShare;
|
|
2690
|
+
unmatched;
|
|
2691
|
+
/** Whether some caller can get reports, so the instructions point to the
|
|
2692
|
+
* tool. Read only where the code's value is "on": no tool exists otherwise. */
|
|
2693
|
+
reportsOnForAnyone;
|
|
2694
|
+
settingsFor(caller, vendorId2) {
|
|
2695
|
+
const bucket = caller.shareKey !== null && this.usesShare ? shareBucket(vendorId2, caller.shareKey) : null;
|
|
2696
|
+
return this.audiences.find((audience) => matches(audience, caller, bucket))?.settings ?? this.unmatched;
|
|
2697
|
+
}
|
|
2698
|
+
};
|
|
2699
|
+
function stringSet(value) {
|
|
2700
|
+
if (!Array.isArray(value) || !value.every((v) => typeof v === "string")) return null;
|
|
2701
|
+
return new Set(value);
|
|
2702
|
+
}
|
|
2703
|
+
function readAudience(version, id, match, capture) {
|
|
2704
|
+
if (!Object.keys(match).every((key) => MATCH_KEYS.has(key))) return null;
|
|
2705
|
+
let labels = null;
|
|
2706
|
+
let clients = null;
|
|
2707
|
+
let shareThreshold = null;
|
|
2708
|
+
if (Object.hasOwn(match, "label") && (labels = stringSet(match.label)) === null) return null;
|
|
2709
|
+
if (Object.hasOwn(match, "client") && (clients = stringSet(match.client)) === null) return null;
|
|
2710
|
+
if (Object.hasOwn(match, "share")) {
|
|
2711
|
+
const share = match.share;
|
|
2712
|
+
if (typeof share !== "number" || !(share > 0 && share <= 1)) return null;
|
|
2713
|
+
shareThreshold = Math.floor(share * 1e4 + 0.5);
|
|
2714
|
+
}
|
|
2715
|
+
const settings = { capture: { settings_version: version, audience: id } };
|
|
2716
|
+
const { results, goal, reports } = capture;
|
|
2717
|
+
if (typeof results === "string" && RESULT_CAPTURE_MODE_SET.has(results)) {
|
|
2718
|
+
settings.resultCaptureMode = results;
|
|
2719
|
+
}
|
|
2720
|
+
if (typeof goal === "string" && INTENT_PARAM_MODES.has(goal)) settings.intentParamMode = goal;
|
|
2721
|
+
if (typeof reports === "string" && REPORT_MODES.has(reports)) settings.reportMode = reports;
|
|
2722
|
+
return { settings, labels, clients, shareThreshold };
|
|
2723
|
+
}
|
|
2724
|
+
function parseDocument(body) {
|
|
2725
|
+
let data;
|
|
2726
|
+
try {
|
|
2727
|
+
data = JSON.parse(body);
|
|
2728
|
+
} catch {
|
|
2729
|
+
return null;
|
|
2730
|
+
}
|
|
2731
|
+
if (!isRecord(data)) return null;
|
|
2732
|
+
const { version, audiences } = data;
|
|
2733
|
+
if (typeof version !== "number" || !Number.isInteger(version) || version < 1) return null;
|
|
2734
|
+
if (!Array.isArray(audiences) || audiences.length === 0) return null;
|
|
2735
|
+
const parsed = [];
|
|
2736
|
+
for (const audience of audiences) {
|
|
2737
|
+
if (!isRecord(audience)) return null;
|
|
2738
|
+
const { id, match, capture } = audience;
|
|
2739
|
+
if (typeof id !== "string" || !isRecord(match) || !isRecord(capture)) return null;
|
|
2740
|
+
const readable = readAudience(version, id, match, capture);
|
|
2741
|
+
if (readable !== null) parsed.push(readable);
|
|
2742
|
+
}
|
|
2743
|
+
return new SettingsDocument(version, parsed);
|
|
2744
|
+
}
|
|
2745
|
+
var SettingsFetcher = class {
|
|
2746
|
+
url;
|
|
2747
|
+
// `#`, not `private`, so logging a config shows no key: "logging the config shows no key".
|
|
2748
|
+
#headers;
|
|
2749
|
+
refreshMs;
|
|
2750
|
+
fetchImpl;
|
|
2751
|
+
etag = null;
|
|
2752
|
+
held = null;
|
|
2753
|
+
timer = null;
|
|
2754
|
+
reading = null;
|
|
2755
|
+
warned = false;
|
|
2756
|
+
constructor(options) {
|
|
2757
|
+
this.url = `${options.origin}${SETTINGS_PATH}?${new URLSearchParams({ server: options.vendorId }).toString()}`;
|
|
2758
|
+
this.#headers = { Authorization: `Bearer ${options.apiKey}`, [TENANT_HEADER]: options.tenantId };
|
|
2759
|
+
this.refreshMs = options.refreshMs;
|
|
2760
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
2761
|
+
}
|
|
2762
|
+
get document() {
|
|
2763
|
+
return this.held;
|
|
2764
|
+
}
|
|
2765
|
+
start() {
|
|
2766
|
+
if (this.timer !== null) return;
|
|
2767
|
+
this.timer = setInterval(() => void this.readOnce(), this.refreshMs);
|
|
2768
|
+
this.timer.unref?.();
|
|
2769
|
+
void this.readOnce();
|
|
2770
|
+
}
|
|
2771
|
+
stop() {
|
|
2772
|
+
if (this.timer !== null) clearInterval(this.timer);
|
|
2773
|
+
this.timer = null;
|
|
2774
|
+
this.reading?.abort();
|
|
2775
|
+
this.reading = null;
|
|
2776
|
+
}
|
|
2777
|
+
/** One request. Never rejects: a failure keeps what is held. */
|
|
2778
|
+
async readOnce() {
|
|
2779
|
+
if (this.reading !== null) return;
|
|
2780
|
+
const reading = new AbortController();
|
|
2781
|
+
this.reading = reading;
|
|
2782
|
+
const timeout = setTimeout(() => reading.abort(), REQUEST_TIMEOUT_MS);
|
|
2783
|
+
timeout.unref?.();
|
|
2784
|
+
try {
|
|
2785
|
+
await this.read(reading.signal);
|
|
2786
|
+
} catch {
|
|
2787
|
+
} finally {
|
|
2788
|
+
clearTimeout(timeout);
|
|
2789
|
+
if (this.reading === reading) this.reading = null;
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
async read(signal) {
|
|
2793
|
+
const headers = this.etag === null ? this.#headers : { ...this.#headers, "If-None-Match": this.etag };
|
|
2794
|
+
const response = await this.fetchImpl(this.url, { method: "GET", headers, redirect: "manual", signal });
|
|
2795
|
+
if (response.status !== 200) {
|
|
2796
|
+
void response.body?.cancel().catch(() => void 0);
|
|
2797
|
+
}
|
|
2798
|
+
if (signal.aborted) return;
|
|
2799
|
+
if (response.status === 204) {
|
|
2800
|
+
this.held = null;
|
|
2801
|
+
this.etag = null;
|
|
2802
|
+
} else if (response.status === 200) {
|
|
2803
|
+
const document = parseDocument(await response.text());
|
|
2804
|
+
if (signal.aborted) return;
|
|
2805
|
+
if (document === null) {
|
|
2806
|
+
if (!this.warned) {
|
|
2807
|
+
this.warned = true;
|
|
2808
|
+
warn("baton: the collector sent capture settings this SDK cannot read");
|
|
2809
|
+
}
|
|
2810
|
+
return;
|
|
2811
|
+
}
|
|
2812
|
+
this.held = document;
|
|
2813
|
+
this.etag = response.headers.get("etag");
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
};
|
|
2817
|
+
var CaptureSettings = class {
|
|
2818
|
+
constructor(vendorId2, source) {
|
|
2819
|
+
this.vendorId = vendorId2;
|
|
2820
|
+
this.source = source;
|
|
2821
|
+
}
|
|
2822
|
+
vendorId;
|
|
2823
|
+
source;
|
|
2824
|
+
start() {
|
|
2825
|
+
this.source.start();
|
|
2826
|
+
}
|
|
2827
|
+
stop() {
|
|
2828
|
+
this.source.stop();
|
|
2829
|
+
}
|
|
2830
|
+
get document() {
|
|
2831
|
+
return this.source.document;
|
|
2832
|
+
}
|
|
2833
|
+
/** `undefined` while no document is held, and the config's values apply. */
|
|
2834
|
+
forCaller(caller) {
|
|
2835
|
+
return this.document?.settingsFor(caller, this.vendorId);
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
|
|
2839
|
+
// src/integrations/mcp/config.ts
|
|
2360
2840
|
function resolveTenantId(explicit, vendorId2) {
|
|
2361
2841
|
if (explicit) return explicit;
|
|
2362
2842
|
const fromEnv2 = typeof process !== "undefined" ? process.env?.BATON_TENANT_ID : void 0;
|
|
@@ -2394,6 +2874,11 @@ function resolveBatonConfig(config) {
|
|
|
2394
2874
|
consentToken: config.consentToken ?? DEFAULT_CONSENT_TOKEN
|
|
2395
2875
|
};
|
|
2396
2876
|
validateBatonConfig(defaulted);
|
|
2877
|
+
if (defaulted.settings === "console") {
|
|
2878
|
+
throw new Error(
|
|
2879
|
+
`BatonConfig.settings: "console" reads the Capture page with the dsn's key, so it needs a dsn.`
|
|
2880
|
+
);
|
|
2881
|
+
}
|
|
2397
2882
|
return defaulted;
|
|
2398
2883
|
}
|
|
2399
2884
|
const dsn = parseDsn(dsnString);
|
|
@@ -2415,14 +2900,27 @@ function resolveBatonConfig(config) {
|
|
|
2415
2900
|
// `??`, not `||`: an explicit empty string must survive to the validation
|
|
2416
2901
|
// below and be REFUSED there, rather than be quietly replaced by the
|
|
2417
2902
|
// default it was deliberately not left as.
|
|
2418
|
-
consentToken: config.consentToken ?? DEFAULT_CONSENT_TOKEN
|
|
2903
|
+
consentToken: config.consentToken ?? DEFAULT_CONSENT_TOKEN,
|
|
2904
|
+
...config.reportMode === void 0 && config.settings === "console" ? { reportMode: "on" } : {}
|
|
2419
2905
|
};
|
|
2420
2906
|
validateBatonConfig(identity);
|
|
2421
2907
|
return {
|
|
2422
2908
|
...identity,
|
|
2423
2909
|
// The origin is scheme + authority; `HttpSink` appends `/v0/events/batch`
|
|
2424
2910
|
// itself, exactly as it does for an explicitly-constructed sink.
|
|
2425
|
-
sink: new HttpSink(dsn.origin, { apiKey: dsn.key })
|
|
2911
|
+
sink: new HttpSink(dsn.origin, { apiKey: dsn.key }),
|
|
2912
|
+
...identity.settings === "console" ? {
|
|
2913
|
+
captureSettings: new CaptureSettings(
|
|
2914
|
+
dsn.vendorId,
|
|
2915
|
+
new SettingsFetcher({
|
|
2916
|
+
origin: dsn.origin,
|
|
2917
|
+
apiKey: dsn.key,
|
|
2918
|
+
tenantId: dsn.tenantId,
|
|
2919
|
+
vendorId: dsn.vendorId,
|
|
2920
|
+
refreshMs: identity.settingsRefreshMs ?? DEFAULT_SETTINGS_REFRESH_MS
|
|
2921
|
+
})
|
|
2922
|
+
)
|
|
2923
|
+
} : {}
|
|
2426
2924
|
};
|
|
2427
2925
|
}
|
|
2428
2926
|
function withServerDisplayName(resolved, supplied, serverName) {
|
|
@@ -2487,6 +2985,17 @@ function validateBatonConfig(config) {
|
|
|
2487
2985
|
`BatonConfig.resultCaptureMode ${JSON.stringify(config.resultCaptureMode)} must be one of ${JSON.stringify([...RESULT_CAPTURE_MODES].sort())}.`
|
|
2488
2986
|
);
|
|
2489
2987
|
}
|
|
2988
|
+
if (config.settings !== void 0 && !SETTINGS_MODES.includes(config.settings)) {
|
|
2989
|
+
throw new Error(
|
|
2990
|
+
`BatonConfig.settings ${JSON.stringify(config.settings)} must be one of ${JSON.stringify(SETTINGS_MODES)}.`
|
|
2991
|
+
);
|
|
2992
|
+
}
|
|
2993
|
+
const refresh = config.settingsRefreshMs;
|
|
2994
|
+
if (refresh !== void 0 && (typeof refresh !== "number" || !(refresh >= MIN_SETTINGS_REFRESH_MS && refresh <= MAX_TIMER_MS))) {
|
|
2995
|
+
throw new Error(
|
|
2996
|
+
`BatonConfig.settingsRefreshMs must be a number of milliseconds from ${String(MIN_SETTINGS_REFRESH_MS)} to ${String(MAX_TIMER_MS)}.`
|
|
2997
|
+
);
|
|
2998
|
+
}
|
|
2490
2999
|
if (config.scrubber !== void 0 && typeof config.scrubber !== "function") {
|
|
2491
3000
|
throw new Error("BatonConfig.scrubber must be a function.");
|
|
2492
3001
|
}
|
|
@@ -2548,7 +3057,9 @@ function resumesPausedCall(extra) {
|
|
|
2548
3057
|
|
|
2549
3058
|
// src/integrations/mcp/handle.ts
|
|
2550
3059
|
var BatonHandle = class {
|
|
3060
|
+
/** The sink the vendor passed, or the default one. */
|
|
2551
3061
|
sink;
|
|
3062
|
+
#queue;
|
|
2552
3063
|
vendorId;
|
|
2553
3064
|
/** The install's own session id: what stdio and in-memory calls, and the
|
|
2554
3065
|
* surface snapshot, carry when no session id resolves. A call over HTTP
|
|
@@ -2560,6 +3071,7 @@ var BatonHandle = class {
|
|
|
2560
3071
|
annotationToolName;
|
|
2561
3072
|
constructor(options) {
|
|
2562
3073
|
this.sink = options.sink;
|
|
3074
|
+
this.#queue = options.queue ?? options.sink;
|
|
2563
3075
|
this.vendorId = options.vendorId;
|
|
2564
3076
|
this.sessionId = options.sessionId;
|
|
2565
3077
|
this.annotationToolName = options.annotationToolName;
|
|
@@ -2567,14 +3079,83 @@ var BatonHandle = class {
|
|
|
2567
3079
|
/** Flush any pending events held by the sink. Never rejects; returns within
|
|
2568
3080
|
* the shutdown budget (SPEC §11.2 rule 7). */
|
|
2569
3081
|
async flush() {
|
|
2570
|
-
await boundedSinkCall(this
|
|
3082
|
+
await boundedSinkCall(this.#queue, "flush");
|
|
2571
3083
|
}
|
|
2572
3084
|
/** Flush and release sink resources, on the same terms as `flush()`. */
|
|
2573
3085
|
async aclose() {
|
|
2574
|
-
await boundedSinkCall(this
|
|
3086
|
+
await boundedSinkCall(this.#queue, "aclose");
|
|
2575
3087
|
}
|
|
2576
3088
|
};
|
|
2577
3089
|
|
|
3090
|
+
// src/integrations/mcp/perCaller.ts
|
|
3091
|
+
var PerCallerSurface = class {
|
|
3092
|
+
constructor(options) {
|
|
3093
|
+
this.options = options;
|
|
3094
|
+
}
|
|
3095
|
+
options;
|
|
3096
|
+
pointerOn = true;
|
|
3097
|
+
/** Called at install and on every request; writes only when the report
|
|
3098
|
+
* pointer should change. */
|
|
3099
|
+
followSettings() {
|
|
3100
|
+
if (this.options.annotationToolName === "") return;
|
|
3101
|
+
try {
|
|
3102
|
+
const document = this.options.settings.document;
|
|
3103
|
+
const pointerOn = document === null || document.reportsOnForAnyone;
|
|
3104
|
+
if (pointerOn === this.pointerOn) return;
|
|
3105
|
+
this.options.writeInstructions(pointerOn ? this.options.instructions : INTENT_INSTRUCTIONS);
|
|
3106
|
+
this.pointerOn = pointerOn;
|
|
3107
|
+
} catch (err) {
|
|
3108
|
+
process.stderr.write(`baton: could not update the server instructions for new settings: ${printable(err)}
|
|
3109
|
+
`);
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
/** `result` with the caller's goal and reports settings; as served on any failure. */
|
|
3113
|
+
toolsFor(result, caller) {
|
|
3114
|
+
const settings = caller.settings;
|
|
3115
|
+
if (settings === void 0) return result;
|
|
3116
|
+
const { intentParamMode, annotationToolName, injectsGoal } = this.options;
|
|
3117
|
+
const goal = settings.intentParamMode ?? intentParamMode;
|
|
3118
|
+
const hideReports = annotationToolName !== "" && settings.reportMode === "off";
|
|
3119
|
+
if (goal === intentParamMode && !hideReports) return result;
|
|
3120
|
+
try {
|
|
3121
|
+
const tools = result?.tools;
|
|
3122
|
+
if (!Array.isArray(tools)) return result;
|
|
3123
|
+
const served = [];
|
|
3124
|
+
for (const tool of tools) {
|
|
3125
|
+
const name = tool?.name;
|
|
3126
|
+
if (hideReports && name === annotationToolName) continue;
|
|
3127
|
+
const rewrite = goal !== intentParamMode && typeof name === "string" && injectsGoal(name);
|
|
3128
|
+
served.push(rewrite ? withGoalMode(tool, goal) : tool);
|
|
3129
|
+
}
|
|
3130
|
+
return { ...result, tools: served };
|
|
3131
|
+
} catch (err) {
|
|
3132
|
+
process.stderr.write(`baton: could not apply capture settings to the tool list: ${printable(err)}
|
|
3133
|
+
`);
|
|
3134
|
+
return result;
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
};
|
|
3138
|
+
function withGoalMode(tool, goal) {
|
|
3139
|
+
const entry = tool;
|
|
3140
|
+
const schema = entry.inputSchema;
|
|
3141
|
+
const properties = schema?.properties;
|
|
3142
|
+
const param = properties?.[USER_GOAL_PARAM_NAME];
|
|
3143
|
+
if (typeof param !== "object" || param === null) return tool;
|
|
3144
|
+
const others = Array.isArray(schema.required) ? schema.required.filter((name) => name !== USER_GOAL_PARAM_NAME) : [];
|
|
3145
|
+
const required = goal === "required" ? [...others, USER_GOAL_PARAM_NAME] : others;
|
|
3146
|
+
return {
|
|
3147
|
+
...entry,
|
|
3148
|
+
inputSchema: {
|
|
3149
|
+
...schema,
|
|
3150
|
+
properties: {
|
|
3151
|
+
...properties,
|
|
3152
|
+
[USER_GOAL_PARAM_NAME]: { ...param, description: buildUserGoalParamDescription({ intentParamMode: goal }) }
|
|
3153
|
+
},
|
|
3154
|
+
...required.length > 0 || Array.isArray(schema.required) ? { required } : {}
|
|
3155
|
+
}
|
|
3156
|
+
};
|
|
3157
|
+
}
|
|
3158
|
+
|
|
2578
3159
|
// src/integrations/mcp/sessionCounter.ts
|
|
2579
3160
|
var SESSION_CAP = 4096;
|
|
2580
3161
|
var SessionCounter = class {
|
|
@@ -2687,16 +3268,16 @@ import { z as zV4 } from "zod";
|
|
|
2687
3268
|
import { z as zV3 } from "zod/v3";
|
|
2688
3269
|
var DEFAULT_INTENT_PARAM_MODE = "required";
|
|
2689
3270
|
var EMPTY_OBJECT_JSON_SCHEMA = { type: "object", properties: {} };
|
|
2690
|
-
function injectGoalParams(
|
|
2691
|
-
const objSchema = normalizeObjectSchema(
|
|
2692
|
-
if (!objSchema) return { schema:
|
|
3271
|
+
function injectGoalParams(inputSchema2, intentParamMode) {
|
|
3272
|
+
const objSchema = normalizeObjectSchema(inputSchema2);
|
|
3273
|
+
if (!objSchema) return { schema: inputSchema2, dispositions: {} };
|
|
2693
3274
|
const existingShape = getObjectShape(objSchema) ?? {};
|
|
2694
3275
|
const values = Object.values(existingShape);
|
|
2695
3276
|
const useV4 = values.length === 0 || isZ4Schema(values[0]);
|
|
2696
3277
|
const zodImpl = useV4 ? zV4 : zV3;
|
|
2697
3278
|
const { dispositions, toInject } = buildIntentFields(existingShape, zodImpl, intentParamMode);
|
|
2698
3279
|
if (Object.keys(toInject).length === 0)
|
|
2699
|
-
return { schema:
|
|
3280
|
+
return { schema: inputSchema2, dispositions };
|
|
2700
3281
|
const mergedShape = { ...existingShape, ...toInject };
|
|
2701
3282
|
const newSchema = objectFromShape(mergedShape);
|
|
2702
3283
|
return { schema: newSchema, dispositions };
|
|
@@ -2715,15 +3296,15 @@ function buildIntentFields(existingShape, zodImpl, intentParamMode) {
|
|
|
2715
3296
|
}
|
|
2716
3297
|
return { dispositions, toInject };
|
|
2717
3298
|
}
|
|
2718
|
-
function injectGoalParamsV2(
|
|
2719
|
-
const candidate =
|
|
3299
|
+
function injectGoalParamsV2(inputSchema2, intentParamMode) {
|
|
3300
|
+
const candidate = inputSchema2;
|
|
2720
3301
|
const shape = candidate?.shape;
|
|
2721
3302
|
if (!shape || typeof shape !== "object" || typeof candidate?.extend !== "function") {
|
|
2722
|
-
return { schema:
|
|
3303
|
+
return { schema: inputSchema2, dispositions: {} };
|
|
2723
3304
|
}
|
|
2724
3305
|
const { dispositions, toInject } = buildIntentFields(shape, zV4, intentParamMode);
|
|
2725
3306
|
if (Object.keys(toInject).length === 0)
|
|
2726
|
-
return { schema:
|
|
3307
|
+
return { schema: inputSchema2, dispositions };
|
|
2727
3308
|
return { schema: candidate.extend(toInject), dispositions };
|
|
2728
3309
|
}
|
|
2729
3310
|
function advertiseIntentParamsRequired(result, names, isInjected) {
|
|
@@ -2746,8 +3327,8 @@ function advertiseIntentParamsRequired(result, names, isInjected) {
|
|
|
2746
3327
|
});
|
|
2747
3328
|
return changed ? { ...result, tools: advertised } : result;
|
|
2748
3329
|
}
|
|
2749
|
-
function toolInputJsonSchema(
|
|
2750
|
-
const objSchema = normalizeObjectSchema(
|
|
3330
|
+
function toolInputJsonSchema(inputSchema2) {
|
|
3331
|
+
const objSchema = normalizeObjectSchema(inputSchema2);
|
|
2751
3332
|
if (!objSchema) return EMPTY_OBJECT_JSON_SCHEMA;
|
|
2752
3333
|
return toJsonSchemaCompat(objSchema, {
|
|
2753
3334
|
strictUnions: true,
|
|
@@ -2756,10 +3337,10 @@ function toolInputJsonSchema(inputSchema) {
|
|
|
2756
3337
|
}
|
|
2757
3338
|
|
|
2758
3339
|
// src/integrations/mcp/surface.ts
|
|
2759
|
-
import { createHash } from "crypto";
|
|
3340
|
+
import { createHash as createHash2 } from "crypto";
|
|
2760
3341
|
function surfaceHash(surface) {
|
|
2761
3342
|
const canonical = canonicalJson(surface);
|
|
2762
|
-
const digest =
|
|
3343
|
+
const digest = createHash2("sha256").update(canonical, "utf-8").digest("hex");
|
|
2763
3344
|
return `sha256:${digest}`;
|
|
2764
3345
|
}
|
|
2765
3346
|
function canonicalJson(value) {
|
|
@@ -2803,9 +3384,6 @@ var SentSurfaces = class {
|
|
|
2803
3384
|
this.hashes.delete(this.hashes.values().next().value);
|
|
2804
3385
|
}
|
|
2805
3386
|
}
|
|
2806
|
-
unmark(digest) {
|
|
2807
|
-
this.hashes.delete(digest);
|
|
2808
|
-
}
|
|
2809
3387
|
};
|
|
2810
3388
|
function buildSeamAugmentations(options) {
|
|
2811
3389
|
return {
|
|
@@ -2895,10 +3473,14 @@ async function openCall(ctx, toolName, extra, params, stripped, registered = tru
|
|
|
2895
3473
|
const [scrubbedExpected = null, scrubbedWorkflow = null] = RETIRED_PARAM_NAMES.map(
|
|
2896
3474
|
(name) => dispositions === void 0 || dispositions[name] === "native" ? null : scrubOrNull(ctx.scrubber, stripped[name] ?? popText(params, name), name)
|
|
2897
3475
|
);
|
|
3476
|
+
const client = observeClient(extra, ctx);
|
|
2898
3477
|
const caller = await resolveCaller(
|
|
2899
3478
|
ctx.resolvePrincipal,
|
|
2900
|
-
{ extra, toolName, arguments: params }
|
|
3479
|
+
{ extra, toolName, arguments: params },
|
|
3480
|
+
ctx.captureSettings,
|
|
3481
|
+
client
|
|
2901
3482
|
);
|
|
3483
|
+
const resultCaptureMode = caller.settings?.resultCaptureMode ?? ctx.configResultCaptureMode;
|
|
2902
3484
|
const common = {
|
|
2903
3485
|
tenant_id: ctx.tenantId,
|
|
2904
3486
|
vendor_id: ctx.vendorId,
|
|
@@ -2908,15 +3490,14 @@ async function openCall(ctx, toolName, extra, params, stripped, registered = tru
|
|
|
2908
3490
|
// it. `surface_snapshot` is deliberately not among them: it describes the
|
|
2909
3491
|
// SERVER and is captured outside any call, so it has no caller, transport
|
|
2910
3492
|
// or client to name.
|
|
2911
|
-
|
|
2912
|
-
organization: caller.organization,
|
|
3493
|
+
...callerEnvelope(caller),
|
|
2913
3494
|
transport_observed: observeTransport(extra),
|
|
2914
3495
|
session_id_origin: session.origin,
|
|
2915
|
-
client_observed:
|
|
3496
|
+
client_observed: client,
|
|
2916
3497
|
runtime_meta: scrubbedMeta,
|
|
2917
3498
|
call_id: uuid7()
|
|
2918
3499
|
};
|
|
2919
|
-
if (resumesPausedCall(extra)) return { common, session };
|
|
3500
|
+
if (resumesPausedCall(extra)) return { common, session, resultCaptureMode };
|
|
2920
3501
|
await emit(
|
|
2921
3502
|
ctx.sink,
|
|
2922
3503
|
() => ToolCallStartEventSchema.parse({
|
|
@@ -2934,7 +3515,7 @@ async function openCall(ctx, toolName, extra, params, stripped, registered = tru
|
|
|
2934
3515
|
}
|
|
2935
3516
|
})
|
|
2936
3517
|
);
|
|
2937
|
-
return { common, session };
|
|
3518
|
+
return { common, session, resultCaptureMode };
|
|
2938
3519
|
}
|
|
2939
3520
|
function batonWrap(nameRef, original, ctx) {
|
|
2940
3521
|
return async (...callArgs) => {
|
|
@@ -2945,7 +3526,7 @@ function batonWrap(nameRef, original, ctx) {
|
|
|
2945
3526
|
const params = (callArgs.length > 1 ? callArgs[0] : void 0) ?? {};
|
|
2946
3527
|
const stripped = slot?.strippedFor === toolName ? slot.stripped : {};
|
|
2947
3528
|
if (slot) slot.strippedFor = null;
|
|
2948
|
-
const { common, session } = await openCall(ctx, toolName, extra, params, stripped);
|
|
3529
|
+
const { common, session, resultCaptureMode } = await openCall(ctx, toolName, extra, params, stripped);
|
|
2949
3530
|
const terminate = async (build, replacement) => {
|
|
2950
3531
|
if (!slot) {
|
|
2951
3532
|
if (build !== null) await emit(ctx.sink, build);
|
|
@@ -2978,7 +3559,7 @@ function batonWrap(nameRef, original, ctx) {
|
|
|
2978
3559
|
// SPEC §11.4.3(1): the MCP SDK has no tool-error class to mark a
|
|
2979
3560
|
// raised message public, so under "off" every one is withheld.
|
|
2980
3561
|
...resultDerivedFields(
|
|
2981
|
-
|
|
3562
|
+
resultCaptureMode,
|
|
2982
3563
|
() => messageOf(err),
|
|
2983
3564
|
null,
|
|
2984
3565
|
(text) => errorBody(ctx, text),
|
|
@@ -3038,7 +3619,7 @@ function batonWrap(nameRef, original, ctx) {
|
|
|
3038
3619
|
// nothing on the wire has; the loss is deliberate and worth
|
|
3039
3620
|
// knowing when debugging one of these.
|
|
3040
3621
|
...resultDerivedFields(
|
|
3041
|
-
|
|
3622
|
+
resultCaptureMode,
|
|
3042
3623
|
() => outcome.raised ? messageOf(outcome.err) : errorText(outcome.result),
|
|
3043
3624
|
// ⚠ `null` on the `raised` lane, never `undefined`, and the
|
|
3044
3625
|
// union is what forces the branch rather than a comment: the
|
|
@@ -3077,7 +3658,7 @@ function batonWrap(nameRef, original, ctx) {
|
|
|
3077
3658
|
// `ToolCallErrorPayloadSchema` in `events.ts` holds that claim and
|
|
3078
3659
|
// names the test that enforces it.
|
|
3079
3660
|
...returnedErrorFields(
|
|
3080
|
-
|
|
3661
|
+
resultCaptureMode,
|
|
3081
3662
|
result,
|
|
3082
3663
|
(text) => errorBody(ctx, text),
|
|
3083
3664
|
ctx.scrubber
|
|
@@ -3095,7 +3676,7 @@ function batonWrap(nameRef, original, ctx) {
|
|
|
3095
3676
|
payload: {
|
|
3096
3677
|
tool_name: toolName,
|
|
3097
3678
|
duration_ms: durationMs,
|
|
3098
|
-
...endResultFields(
|
|
3679
|
+
...endResultFields(resultCaptureMode, result, ctx.scrubber)
|
|
3099
3680
|
}
|
|
3100
3681
|
}),
|
|
3101
3682
|
(outcome) => failedAbove(outcome, OUTPUT_SCHEMA_MISMATCH)
|
|
@@ -3158,14 +3739,7 @@ async function maybeEmitSurfaceSnapshot(ctx) {
|
|
|
3158
3739
|
requiredParamNames: requiredParamNames(ctx.intentParamMode),
|
|
3159
3740
|
instructionsSuffix: instructionsSuffixServed(ctx.annotationToolName, ctx.servedInstructions())
|
|
3160
3741
|
});
|
|
3161
|
-
|
|
3162
|
-
await ctx.emitSurface(ctx.fallbackSessionId, digest, { ...snapshot, seam_augmentations: seam });
|
|
3163
|
-
} catch (err) {
|
|
3164
|
-
process.stderr.write(`baton: surface snapshot capture failed: ${String(err)}
|
|
3165
|
-
`);
|
|
3166
|
-
sent.unmark(digest);
|
|
3167
|
-
ctx.surfaceState.dirty = true;
|
|
3168
|
-
}
|
|
3742
|
+
await ctx.emitSurface(ctx.fallbackSessionId, digest, { ...snapshot, seam_augmentations: seam });
|
|
3169
3743
|
}
|
|
3170
3744
|
function declaredIntentParams(vendorSchema) {
|
|
3171
3745
|
const declared2 = {};
|
|
@@ -3248,6 +3822,7 @@ var LIFECYCLE_SEAMS = {
|
|
|
3248
3822
|
};
|
|
3249
3823
|
function installLifecycleSeam(lowLevel, ctx, spec) {
|
|
3250
3824
|
installRequestSeam(lowLevel, spec.method, spec.seamTag, (handler) => async (...args) => {
|
|
3825
|
+
ctx.perCaller?.followSettings();
|
|
3251
3826
|
const request = args[0];
|
|
3252
3827
|
const requestParams = request?.params ?? {};
|
|
3253
3828
|
const extra = args[1];
|
|
@@ -3268,8 +3843,9 @@ function installLifecycleSeam(lowLevel, ctx, spec) {
|
|
|
3268
3843
|
const startedAt = performance.now();
|
|
3269
3844
|
const elapsed = () => Math.round(performance.now() - startedAt);
|
|
3270
3845
|
try {
|
|
3271
|
-
const
|
|
3272
|
-
if (isInputRequired(
|
|
3846
|
+
const served = await handler(...args);
|
|
3847
|
+
if (isInputRequired(served)) return served;
|
|
3848
|
+
const result = opened !== null && spec.rewriteResult !== void 0 ? spec.rewriteResult(ctx, served, opened.caller) : served;
|
|
3273
3849
|
await fire(spec.schemas.end, {
|
|
3274
3850
|
...spec.countKey === void 0 ? {} : { count: countOf(result, spec.countKey) },
|
|
3275
3851
|
duration_ms: elapsed()
|
|
@@ -3291,24 +3867,26 @@ function installLifecycleSeam(lowLevel, ctx, spec) {
|
|
|
3291
3867
|
async function openLifecycleCall(ctx, spec, requestParams, extra) {
|
|
3292
3868
|
try {
|
|
3293
3869
|
const { scrubbedMeta, ...session } = await resolveEnvelopeParts(ctx, extra);
|
|
3294
|
-
const
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
arguments: {}
|
|
3298
|
-
|
|
3870
|
+
const client = observeClient(extra, ctx);
|
|
3871
|
+
const caller = await resolveCaller(
|
|
3872
|
+
ctx.resolvePrincipal,
|
|
3873
|
+
{ extra, toolName: null, arguments: {} },
|
|
3874
|
+
ctx.captureSettings,
|
|
3875
|
+
client
|
|
3876
|
+
);
|
|
3299
3877
|
return {
|
|
3300
3878
|
session,
|
|
3879
|
+
caller,
|
|
3301
3880
|
subject: spec.subjectKey === void 0 ? {} : { [spec.subjectKey]: stringSubject(requestParams[spec.subjectKey]) },
|
|
3302
3881
|
common: {
|
|
3303
3882
|
tenant_id: ctx.tenantId,
|
|
3304
3883
|
vendor_id: ctx.vendorId,
|
|
3305
3884
|
session_id: session.sessionId,
|
|
3306
3885
|
consent_token: ctx.consentToken,
|
|
3307
|
-
|
|
3308
|
-
organization: caller.organization,
|
|
3886
|
+
...callerEnvelope(caller),
|
|
3309
3887
|
transport_observed: observeTransport(extra),
|
|
3310
3888
|
session_id_origin: session.origin,
|
|
3311
|
-
client_observed:
|
|
3889
|
+
client_observed: client,
|
|
3312
3890
|
runtime_meta: scrubbedMeta
|
|
3313
3891
|
}
|
|
3314
3892
|
};
|
|
@@ -3391,7 +3969,8 @@ var LIFECYCLE_SPECS = [
|
|
|
3391
3969
|
error: ToolListErrorEventSchema
|
|
3392
3970
|
},
|
|
3393
3971
|
countKey: "tools",
|
|
3394
|
-
startParams: NO_PARAMS
|
|
3972
|
+
startParams: NO_PARAMS,
|
|
3973
|
+
rewriteResult: (ctx, result, caller) => ctx.perCaller?.toolsFor(result, caller) ?? result
|
|
3395
3974
|
}
|
|
3396
3975
|
];
|
|
3397
3976
|
function installLifecycleSeams(lowLevel, ctx) {
|
|
@@ -3433,6 +4012,7 @@ function installToolsCallSeam(lowLevel, toolEntry, ctx) {
|
|
|
3433
4012
|
TOOLS_CALL_METHOD,
|
|
3434
4013
|
TOOLS_CALL_SEAM,
|
|
3435
4014
|
(handler) => async (...args) => {
|
|
4015
|
+
ctx.perCaller?.followSettings();
|
|
3436
4016
|
const request = args[0];
|
|
3437
4017
|
const name = request?.params?.name;
|
|
3438
4018
|
const slot = {
|
|
@@ -3500,7 +4080,7 @@ async function emitRequestSideFailure(outcome, args, slot, toolEntry, ctx) {
|
|
|
3500
4080
|
const entry = toolEntry(toolName);
|
|
3501
4081
|
if (entry != null && dispatchTarget(entry)?.[BATON_WRAPPED] !== true) return;
|
|
3502
4082
|
const params = { ...request?.params?.arguments ?? {} };
|
|
3503
|
-
const { common, session } = await openCall(
|
|
4083
|
+
const { common, session, resultCaptureMode } = await openCall(
|
|
3504
4084
|
ctx,
|
|
3505
4085
|
toolName,
|
|
3506
4086
|
args[1],
|
|
@@ -3543,7 +4123,7 @@ async function emitRequestSideFailure(outcome, args, slot, toolEntry, ctx) {
|
|
|
3543
4123
|
...failureKind === void 0 ? {} : { failure_kind: failureKind },
|
|
3544
4124
|
...requestSideFailureFields(
|
|
3545
4125
|
failureKind,
|
|
3546
|
-
|
|
4126
|
+
resultCaptureMode,
|
|
3547
4127
|
text,
|
|
3548
4128
|
outcome.raised ? null : outcome.result,
|
|
3549
4129
|
(value) => errorBody(ctx, value),
|
|
@@ -3620,8 +4200,28 @@ function withBaton(server, supplied = {}) {
|
|
|
3620
4200
|
const handle = install(server, supplied, resolved, newBatonState(resolved), unconfigured);
|
|
3621
4201
|
if (unconfigured) logUnconfigured("withBaton");
|
|
3622
4202
|
else warnAboutSettings(resolved);
|
|
3623
|
-
|
|
3624
|
-
|
|
4203
|
+
const settings = resolved.captureSettings;
|
|
4204
|
+
if (settings === void 0) return handle;
|
|
4205
|
+
settings.start();
|
|
4206
|
+
return new SettingsHandle(handle, settings);
|
|
4207
|
+
}
|
|
4208
|
+
var SettingsHandle = class extends BatonHandle {
|
|
4209
|
+
constructor(inner, settings) {
|
|
4210
|
+
super(inner);
|
|
4211
|
+
this.inner = inner;
|
|
4212
|
+
this.settings = settings;
|
|
4213
|
+
}
|
|
4214
|
+
inner;
|
|
4215
|
+
settings;
|
|
4216
|
+
// The inner handle holds the queue in front of the sink.
|
|
4217
|
+
flush() {
|
|
4218
|
+
return this.inner.flush();
|
|
4219
|
+
}
|
|
4220
|
+
async aclose() {
|
|
4221
|
+
this.settings.stop();
|
|
4222
|
+
await this.inner.aclose();
|
|
4223
|
+
}
|
|
4224
|
+
};
|
|
3625
4225
|
function createBaton(supplied = {}) {
|
|
3626
4226
|
const disabledBy = captureDisabled();
|
|
3627
4227
|
if (disabledBy !== null) {
|
|
@@ -3638,19 +4238,23 @@ function createBaton(supplied = {}) {
|
|
|
3638
4238
|
if (resolved.reportMode === "on") deriveAnnotationToolName(resolved.vendorId, supplied.annotationToolName);
|
|
3639
4239
|
if (unconfigured) logUnconfigured("createBaton");
|
|
3640
4240
|
else warnAboutSettings(resolved);
|
|
3641
|
-
const sink = unconfigured ? new DisabledSink() : resolved.sink ?? new StdoutSink();
|
|
4241
|
+
const sink = unconfigured ? new DisabledSink() : offTheCall(resolved.sink ?? new StdoutSink());
|
|
3642
4242
|
const config = {
|
|
3643
4243
|
...resolved,
|
|
3644
4244
|
sink,
|
|
3645
4245
|
tenantId: resolveTenantId(resolved.tenantId, resolved.vendorId)
|
|
3646
4246
|
};
|
|
3647
4247
|
const state = newBatonState(resolved);
|
|
4248
|
+
resolved.captureSettings?.start();
|
|
3648
4249
|
return {
|
|
3649
4250
|
wrap: (server) => {
|
|
3650
4251
|
install(server, supplied, config, state, unconfigured);
|
|
3651
4252
|
},
|
|
3652
4253
|
flush: () => boundedSinkCall(sink, "flush"),
|
|
3653
|
-
aclose: () =>
|
|
4254
|
+
aclose: () => {
|
|
4255
|
+
resolved.captureSettings?.stop();
|
|
4256
|
+
return boundedSinkCall(sink, "aclose");
|
|
4257
|
+
}
|
|
3654
4258
|
};
|
|
3655
4259
|
}
|
|
3656
4260
|
function inertHandle(sink, sessionId) {
|
|
@@ -3684,7 +4288,8 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned3, co
|
|
|
3684
4288
|
const annotationToolName = reports ? resolveAnnotationToolName(serverName, { ...config, vendorDisplayName: reports.vendorDisplayName }) : "";
|
|
3685
4289
|
const ours = reports ? buildServerInstructions({ vendorDisplayName: reports.vendorDisplayName, annotationToolName }) : INTENT_INSTRUCTIONS;
|
|
3686
4290
|
if (unconfigured) return inertHandle(new DisabledSink(), "baton-unconfigured");
|
|
3687
|
-
const
|
|
4291
|
+
const given = config.sink ?? new StdoutSink();
|
|
4292
|
+
const sink = offTheCall(given);
|
|
3688
4293
|
const intentParamMode = config.intentParamMode ?? DEFAULT_INTENT_PARAM_MODE;
|
|
3689
4294
|
const fallbackSessionId = `sdk-${uuid7()}`;
|
|
3690
4295
|
const counter2 = new ServerCounter(sharedCounter, fallbackSessionId);
|
|
@@ -3692,29 +4297,26 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned3, co
|
|
|
3692
4297
|
const serverMeta = buildServerMeta(server.server);
|
|
3693
4298
|
const surfaceState = new SurfaceState(serverMeta, sentSurfaces);
|
|
3694
4299
|
const emitSurface = async (sessionId, digest, snapshot) => {
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
if (isSinkClosed(err)) return droppedAfterClose(sink);
|
|
3716
|
-
throw err;
|
|
3717
|
-
}
|
|
4300
|
+
await emit(
|
|
4301
|
+
sink,
|
|
4302
|
+
() => SurfaceSnapshotEventSchema.parse({
|
|
4303
|
+
tenant_id: tenantId,
|
|
4304
|
+
vendor_id: config.vendorId,
|
|
4305
|
+
session_id: sessionId,
|
|
4306
|
+
session_id_origin: "minted",
|
|
4307
|
+
consent_token: config.consentToken,
|
|
4308
|
+
sequence_number: counter2.next(sessionId, false),
|
|
4309
|
+
captured_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4310
|
+
payload: {
|
|
4311
|
+
surface_hash: digest,
|
|
4312
|
+
server_info: snapshot.server_info,
|
|
4313
|
+
capabilities: snapshot.capabilities,
|
|
4314
|
+
instructions: snapshot.instructions,
|
|
4315
|
+
tools: snapshot.tools,
|
|
4316
|
+
seam_augmentations: snapshot.seam_augmentations
|
|
4317
|
+
}
|
|
4318
|
+
})
|
|
4319
|
+
);
|
|
3718
4320
|
};
|
|
3719
4321
|
const bustSchemaMemo = (name) => {
|
|
3720
4322
|
const memo = internals._toolInputSchemaJson;
|
|
@@ -3741,7 +4343,7 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned3, co
|
|
|
3741
4343
|
);
|
|
3742
4344
|
};
|
|
3743
4345
|
const isV2Server = typeof internals.toolInputSchemaJson === "function";
|
|
3744
|
-
const vendorToolJsonSchema = (name,
|
|
4346
|
+
const vendorToolJsonSchema = (name, inputSchema2) => {
|
|
3745
4347
|
if (isV2Server) {
|
|
3746
4348
|
try {
|
|
3747
4349
|
const json = internals.toolInputSchemaJson(name);
|
|
@@ -3749,14 +4351,14 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned3, co
|
|
|
3749
4351
|
} catch {
|
|
3750
4352
|
}
|
|
3751
4353
|
try {
|
|
3752
|
-
const standard =
|
|
4354
|
+
const standard = inputSchema2?.["~standard"];
|
|
3753
4355
|
const json = standard?.jsonSchema?.input?.({ target: "draft-2020-12" });
|
|
3754
4356
|
if (json) return json;
|
|
3755
4357
|
} catch {
|
|
3756
4358
|
}
|
|
3757
4359
|
}
|
|
3758
4360
|
try {
|
|
3759
|
-
return toolInputJsonSchema(
|
|
4361
|
+
return toolInputJsonSchema(inputSchema2);
|
|
3760
4362
|
} catch {
|
|
3761
4363
|
return { type: "object", properties: {} };
|
|
3762
4364
|
}
|
|
@@ -3773,9 +4375,11 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned3, co
|
|
|
3773
4375
|
scrubber,
|
|
3774
4376
|
annotationToolName,
|
|
3775
4377
|
intentParamMode,
|
|
3776
|
-
|
|
4378
|
+
configResultCaptureMode: config.resultCaptureMode ?? "full",
|
|
3777
4379
|
paramRegistry: /* @__PURE__ */ new Map(),
|
|
3778
4380
|
resolvePrincipal: config.resolvePrincipal,
|
|
4381
|
+
captureSettings: config.captureSettings,
|
|
4382
|
+
perCaller: void 0,
|
|
3779
4383
|
vendorToolJsonSchema,
|
|
3780
4384
|
bustSchemaMemo,
|
|
3781
4385
|
dropSubagentClause,
|
|
@@ -3783,11 +4387,29 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned3, co
|
|
|
3783
4387
|
surfaceState,
|
|
3784
4388
|
emitSurface
|
|
3785
4389
|
};
|
|
3786
|
-
|
|
3787
|
-
internals.server
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
4390
|
+
const writeInstructions = (text) => {
|
|
4391
|
+
internals.server._instructions = withVendorInstructions(
|
|
4392
|
+
internals.server,
|
|
4393
|
+
text,
|
|
4394
|
+
(message) => warnOnce2("instructions-length", message)
|
|
4395
|
+
);
|
|
4396
|
+
};
|
|
4397
|
+
writeInstructions(ours);
|
|
4398
|
+
if (config.captureSettings !== void 0) {
|
|
4399
|
+
ctx.perCaller = new PerCallerSurface({
|
|
4400
|
+
settings: config.captureSettings,
|
|
4401
|
+
intentParamMode,
|
|
4402
|
+
annotationToolName,
|
|
4403
|
+
instructions: ours,
|
|
4404
|
+
writeInstructions: (text) => {
|
|
4405
|
+
writeInstructions(text);
|
|
4406
|
+
const native = [...ctx.paramRegistry].find(([, d]) => d[USER_GOAL_PARAM_NAME] === "native");
|
|
4407
|
+
if (native !== void 0) dropSubagentClause(native[0]);
|
|
4408
|
+
},
|
|
4409
|
+
injectsGoal: (name) => ctx.paramRegistry.get(name)?.[USER_GOAL_PARAM_NAME] === "injected"
|
|
4410
|
+
});
|
|
4411
|
+
ctx.perCaller.followSettings();
|
|
4412
|
+
}
|
|
3791
4413
|
installToolsListSeam(internals.server, ctx);
|
|
3792
4414
|
installToolsCallSeam(
|
|
3793
4415
|
internals.server,
|
|
@@ -3813,6 +4435,7 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned3, co
|
|
|
3813
4435
|
vendorDisplayName: reports.vendorDisplayName,
|
|
3814
4436
|
consentToken: ctx.consentToken,
|
|
3815
4437
|
resolvePrincipal: ctx.resolvePrincipal,
|
|
4438
|
+
captureSettings: ctx.captureSettings,
|
|
3816
4439
|
fallbackSessionId: ctx.fallbackSessionId,
|
|
3817
4440
|
scrubber: ctx.scrubber,
|
|
3818
4441
|
// The RESOLVED name, never `config.annotationToolName`: handing over the
|
|
@@ -3833,7 +4456,8 @@ function install(server, supplied, resolved, { sentSurfaces, warned: warned3, co
|
|
|
3833
4456
|
return registered;
|
|
3834
4457
|
};
|
|
3835
4458
|
return new BatonHandle({
|
|
3836
|
-
sink,
|
|
4459
|
+
sink: given,
|
|
4460
|
+
queue: sink,
|
|
3837
4461
|
vendorId: config.vendorId,
|
|
3838
4462
|
sessionId: fallbackSessionId,
|
|
3839
4463
|
annotationToolName: resolvedAnnotationToolName
|
|
@@ -3899,6 +4523,7 @@ function sessionEnvelope(session) {
|
|
|
3899
4523
|
transport_observed: TRANSPORT_LIBRARY,
|
|
3900
4524
|
principal: session.principal,
|
|
3901
4525
|
organization: session.organization,
|
|
4526
|
+
labels: wireLabels(session.labels),
|
|
3902
4527
|
client_observed: session.clientObserved,
|
|
3903
4528
|
runtime_meta: session.runtimeMeta
|
|
3904
4529
|
};
|
|
@@ -4097,10 +4722,8 @@ function paramsOf(args) {
|
|
|
4097
4722
|
}
|
|
4098
4723
|
var Core = class {
|
|
4099
4724
|
closed = false;
|
|
4100
|
-
pending = /* @__PURE__ */ new Set();
|
|
4101
|
-
closedWarned = false;
|
|
4102
4725
|
// A snapshot describes the server, so it takes no block's session,
|
|
4103
|
-
// principal or client
|
|
4726
|
+
// principal or client (SPEC §5.6 rule 7).
|
|
4104
4727
|
surfaceSessionId = uuid7();
|
|
4105
4728
|
sentSurfaces = new SentSurfaces();
|
|
4106
4729
|
sink;
|
|
@@ -4111,7 +4734,7 @@ var Core = class {
|
|
|
4111
4734
|
scrubber;
|
|
4112
4735
|
disabled;
|
|
4113
4736
|
constructor(resolved) {
|
|
4114
|
-
this.sink = resolved.sink;
|
|
4737
|
+
this.sink = offTheCall(resolved.sink);
|
|
4115
4738
|
this.vendorId = resolved.vendorId;
|
|
4116
4739
|
this.tenantId = resolved.tenantId;
|
|
4117
4740
|
this.consentToken = resolved.consentToken;
|
|
@@ -4135,25 +4758,15 @@ var Core = class {
|
|
|
4135
4758
|
live() {
|
|
4136
4759
|
if (this.disabled) return false;
|
|
4137
4760
|
if (!this.closed) return true;
|
|
4138
|
-
|
|
4139
|
-
if (!this.closedWarned) {
|
|
4140
|
-
this.closedWarned = true;
|
|
4141
|
-
process.stderr.write("baton: Client is closed; further events are dropped.\n");
|
|
4142
|
-
}
|
|
4761
|
+
droppedAfterClose(this.sink);
|
|
4143
4762
|
return false;
|
|
4144
4763
|
}
|
|
4145
|
-
/** Never rejects.
|
|
4764
|
+
/** Never rejects. */
|
|
4146
4765
|
emit(build) {
|
|
4147
|
-
return
|
|
4148
|
-
}
|
|
4149
|
-
track(work) {
|
|
4150
|
-
const tracked = work.finally(() => this.pending.delete(tracked));
|
|
4151
|
-
this.pending.add(tracked);
|
|
4152
|
-
return tracked;
|
|
4766
|
+
return emit(this.sink, build);
|
|
4153
4767
|
}
|
|
4154
|
-
/** Sends `surface` unless this client already has. Never rejects
|
|
4155
|
-
* write
|
|
4156
|
-
* not fit the schema stays marked: it would fail the same way every time. */
|
|
4768
|
+
/** Sends `surface` unless this client already has. Never rejects. The
|
|
4769
|
+
* write only queues, so a surface counts as sent once queued. */
|
|
4157
4770
|
sendSurface(surface) {
|
|
4158
4771
|
if (this.sentSurfaces.wasSent(surface.digest) || !this.live()) return Promise.resolve();
|
|
4159
4772
|
this.sentSurfaces.mark(surface.digest);
|
|
@@ -4175,32 +4788,7 @@ var Core = class {
|
|
|
4175
4788
|
`);
|
|
4176
4789
|
return Promise.resolve();
|
|
4177
4790
|
}
|
|
4178
|
-
return this.
|
|
4179
|
-
(async () => {
|
|
4180
|
-
try {
|
|
4181
|
-
await this.sink.write(event);
|
|
4182
|
-
} catch (err) {
|
|
4183
|
-
if (isSinkClosed(err)) return droppedAfterClose(this.sink);
|
|
4184
|
-
process.stderr.write(`baton: surface snapshot not sent; will retry: ${printable(err)}
|
|
4185
|
-
`);
|
|
4186
|
-
this.sentSurfaces.unmark(surface.digest);
|
|
4187
|
-
}
|
|
4188
|
-
})()
|
|
4189
|
-
);
|
|
4190
|
-
}
|
|
4191
|
-
/** Waits up to `ms` for pending events to reach the sink; with `untilEmpty`,
|
|
4192
|
-
* also for ones emitted while it waits. A write still pending when time runs
|
|
4193
|
-
* out is not waited on again, so one stuck write costs one wait. */
|
|
4194
|
-
async settleWithin(ms, untilEmpty) {
|
|
4195
|
-
const deadline = performance.now() + ms;
|
|
4196
|
-
do {
|
|
4197
|
-
const waiting = [...this.pending];
|
|
4198
|
-
if (await raceDeadline(Promise.allSettled(waiting), deadline - performance.now()) === TIMED_OUT) {
|
|
4199
|
-
const left = waiting.filter((write) => this.pending.delete(write));
|
|
4200
|
-
if (untilEmpty) PROCESS_DROPS.add("unsent_at_close", left.length);
|
|
4201
|
-
return;
|
|
4202
|
-
}
|
|
4203
|
-
} while (untilEmpty && this.pending.size > 0);
|
|
4791
|
+
return safeWrite(this.sink, event);
|
|
4204
4792
|
}
|
|
4205
4793
|
scrub(value, field) {
|
|
4206
4794
|
return scrubOrNull(this.scrubber, value, field);
|
|
@@ -4471,93 +5059,81 @@ var Client = class {
|
|
|
4471
5059
|
/** Wait for events so far to reach the sink, then flush it. Never rejects;
|
|
4472
5060
|
* returns within the sink's shutdown budget plus 250 ms (SPEC §11.2 rule 7). */
|
|
4473
5061
|
async flush() {
|
|
4474
|
-
await this.#
|
|
5062
|
+
await boundedSinkCall(this.#core.sink, "flush");
|
|
4475
5063
|
}
|
|
4476
5064
|
/** Flush, then close the sink. Later events are dropped. */
|
|
4477
5065
|
aclose() {
|
|
4478
|
-
this.#closing ??= this.#
|
|
4479
|
-
|
|
4480
|
-
}
|
|
4481
|
-
/** One budget: events in flight get until its end to reach the sink, then
|
|
4482
|
-
* the sink gets the time left. */
|
|
4483
|
-
async #settleThen(method) {
|
|
4484
|
-
await boundedSinkCall(this.#core.sink, method, async (budgetMs) => {
|
|
4485
|
-
const deadline = performance.now() + budgetMs;
|
|
4486
|
-
await this.#core.settleWithin(budgetMs, method === "aclose");
|
|
4487
|
-
if (method === "aclose") this.#core.closed = true;
|
|
4488
|
-
await callWithin(this.#core.sink, method, Math.max(0, deadline - performance.now()));
|
|
5066
|
+
this.#closing ??= boundedSinkCall(this.#core.sink, "aclose").then(() => {
|
|
5067
|
+
this.#core.closed = true;
|
|
4489
5068
|
});
|
|
5069
|
+
return this.#closing;
|
|
4490
5070
|
}
|
|
4491
5071
|
};
|
|
5072
|
+
|
|
5073
|
+
// src/library/reportTool.ts
|
|
5074
|
+
function inputSchema() {
|
|
5075
|
+
const schema = toolInputJsonSchema(ANNOTATION_INPUT_SHAPE);
|
|
5076
|
+
delete schema.$schema;
|
|
5077
|
+
return { ...schema, required: [...schema.required, TOOL_NAME_PARAM_NAME] };
|
|
5078
|
+
}
|
|
5079
|
+
var nonEmptyText = (value) => typeof value === "string" && value !== "";
|
|
5080
|
+
var nonEmptyObject = (value) => isRecord(value) && Object.keys(value).length > 0;
|
|
5081
|
+
function annotateArgs(args) {
|
|
5082
|
+
const whatHappened = args.what_happened;
|
|
5083
|
+
if (!isReport(whatHappened)) return null;
|
|
5084
|
+
const options = { whatHappened };
|
|
5085
|
+
const toolName = args[TOOL_NAME_PARAM_NAME];
|
|
5086
|
+
if (typeof toolName === "string") options.toolName = toolName;
|
|
5087
|
+
const intent = args[USER_GOAL_PARAM_NAME];
|
|
5088
|
+
if (nonEmptyText(intent)) options.intent = intent;
|
|
5089
|
+
if (nonEmptyText(args.suggested_improvement)) {
|
|
5090
|
+
options.suggestedImprovement = args.suggested_improvement;
|
|
5091
|
+
}
|
|
5092
|
+
if (nonEmptyObject(args.context)) options.context = args.context;
|
|
5093
|
+
return options;
|
|
5094
|
+
}
|
|
5095
|
+
function reportTool(options) {
|
|
5096
|
+
const { vendorDisplayName } = options;
|
|
5097
|
+
const derived = options.name ?? toolNameForDisplayName(vendorDisplayName);
|
|
5098
|
+
if (derived === void 0) {
|
|
5099
|
+
throw new Error(
|
|
5100
|
+
`vendorDisplayName ${JSON.stringify(vendorDisplayName)} gives no usable tool name, or one too long for the instructions. Pass name.`
|
|
5101
|
+
);
|
|
5102
|
+
}
|
|
5103
|
+
const name = validateAnnotationToolName(derived);
|
|
5104
|
+
if (!fitsInstructionsCap({ vendorDisplayName, annotationToolName: name })) {
|
|
5105
|
+
throw new Error(
|
|
5106
|
+
`vendorDisplayName and name ${JSON.stringify(name)} are too long together for the instructions. Shorten one of them.`
|
|
5107
|
+
);
|
|
5108
|
+
}
|
|
5109
|
+
return {
|
|
5110
|
+
name,
|
|
5111
|
+
description: buildAnnotationToolDescription({ vendorDisplayName }),
|
|
5112
|
+
inputSchema: inputSchema(),
|
|
5113
|
+
instructions: buildServerInstructions({ vendorDisplayName, annotationToolName: name }),
|
|
5114
|
+
refusal: buildRefusalText({ annotationToolName: name }),
|
|
5115
|
+
annotateArgs
|
|
5116
|
+
};
|
|
5117
|
+
}
|
|
4492
5118
|
export {
|
|
4493
|
-
AnnotationEventSchema,
|
|
4494
|
-
AnnotationPayloadSchema,
|
|
4495
5119
|
BatonHandle,
|
|
4496
5120
|
Client,
|
|
4497
|
-
ClientReportEventSchema,
|
|
4498
|
-
ClientReportPayloadSchema,
|
|
4499
|
-
DEFAULT_CONSENT_TOKEN,
|
|
4500
|
-
DEPTH_LIMIT,
|
|
4501
|
-
DEPTH_MARKER,
|
|
4502
5121
|
EventSchema,
|
|
4503
|
-
EventTypeSchema,
|
|
4504
5122
|
FileSink,
|
|
4505
5123
|
HttpSink,
|
|
4506
5124
|
INTENT_INSTRUCTIONS,
|
|
4507
5125
|
INTENT_PARAMS,
|
|
4508
5126
|
MultiSink,
|
|
4509
|
-
PRINCIPAL_FORM_HASHED,
|
|
4510
|
-
PRINCIPAL_FORM_RAW,
|
|
4511
|
-
PRINCIPAL_SOURCE_ASSERTED,
|
|
4512
|
-
PrincipalWireSchema,
|
|
4513
|
-
PromptGetEndEventSchema,
|
|
4514
|
-
PromptGetEndPayloadSchema,
|
|
4515
|
-
PromptGetErrorEventSchema,
|
|
4516
|
-
PromptGetErrorPayloadSchema,
|
|
4517
|
-
PromptGetStartEventSchema,
|
|
4518
|
-
PromptGetStartPayloadSchema,
|
|
4519
|
-
PromptListEndEventSchema,
|
|
4520
|
-
PromptListEndPayloadSchema,
|
|
4521
|
-
PromptListErrorEventSchema,
|
|
4522
|
-
PromptListErrorPayloadSchema,
|
|
4523
|
-
PromptListStartEventSchema,
|
|
4524
|
-
PromptListStartPayloadSchema,
|
|
4525
|
-
ResourceListEndEventSchema,
|
|
4526
|
-
ResourceListEndPayloadSchema,
|
|
4527
|
-
ResourceListErrorEventSchema,
|
|
4528
|
-
ResourceListErrorPayloadSchema,
|
|
4529
|
-
ResourceListStartEventSchema,
|
|
4530
|
-
ResourceListStartPayloadSchema,
|
|
4531
|
-
ResourceReadEndEventSchema,
|
|
4532
|
-
ResourceReadEndPayloadSchema,
|
|
4533
|
-
ResourceReadErrorEventSchema,
|
|
4534
|
-
ResourceReadErrorPayloadSchema,
|
|
4535
|
-
ResourceReadStartEventSchema,
|
|
4536
|
-
ResourceReadStartPayloadSchema,
|
|
4537
5127
|
SDK_VERSION,
|
|
4538
5128
|
Scrubber,
|
|
4539
5129
|
SinkClosedError,
|
|
4540
5130
|
StdoutSink,
|
|
4541
|
-
SurfaceSnapshotEventSchema,
|
|
4542
|
-
SurfaceSnapshotPayloadSchema,
|
|
4543
|
-
ToolCallEndEventSchema,
|
|
4544
|
-
ToolCallEndPayloadSchema,
|
|
4545
|
-
ToolCallErrorEventSchema,
|
|
4546
|
-
ToolCallErrorPayloadSchema,
|
|
4547
|
-
ToolCallStartEventSchema,
|
|
4548
|
-
ToolCallStartPayloadSchema,
|
|
4549
|
-
ToolListEndEventSchema,
|
|
4550
|
-
ToolListEndPayloadSchema,
|
|
4551
|
-
ToolListErrorEventSchema,
|
|
4552
|
-
ToolListErrorPayloadSchema,
|
|
4553
|
-
ToolListStartEventSchema,
|
|
4554
|
-
ToolListStartPayloadSchema,
|
|
4555
5131
|
Trace,
|
|
4556
5132
|
createBaton,
|
|
4557
5133
|
identityScrub,
|
|
4558
5134
|
principalFromOAuthEmail,
|
|
4559
5135
|
principalFromOAuthSub,
|
|
4560
|
-
|
|
5136
|
+
reportTool,
|
|
4561
5137
|
withBaton
|
|
4562
5138
|
};
|
|
4563
5139
|
//# sourceMappingURL=index.js.map
|