thaipass 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. package/dist/index.js +29 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -652,6 +652,21 @@ const toolErrorSchema = (type) => z.object({
652
652
  toolName: optionalText,
653
653
  type: z.literal(type)
654
654
  });
655
+ const SWITCH_DETAIL_LIMIT = 120;
656
+ const namedModelSchema = z.object({
657
+ model: optionalText,
658
+ modelId: optionalText,
659
+ to: optionalText
660
+ });
661
+ /** The payload is undocumented, so an unnamed one is kept verbatim for the first production sample to show. */
662
+ const switchDetailSchema = z.unknown().transform((data) => {
663
+ const named = namedModelSchema.safeParse(data);
664
+ if (named.success) {
665
+ const found = named.data.modelId ?? named.data.model ?? named.data.to;
666
+ if (found !== void 0 && found.length > 0) return found;
667
+ }
668
+ return JSON.stringify(data ?? null).slice(0, SWITCH_DETAIL_LIMIT);
669
+ });
655
670
  const upstreamEventSchema = z.discriminatedUnion("type", [
656
671
  z.object({
657
672
  delta: z.string(),
@@ -661,6 +676,10 @@ const upstreamEventSchema = z.discriminatedUnion("type", [
661
676
  delta: z.string(),
662
677
  type: z.literal("reasoning-delta")
663
678
  }),
679
+ z.object({
680
+ data: switchDetailSchema,
681
+ type: z.literal("data-model_switched")
682
+ }),
664
683
  fileFrameSchema,
665
684
  z.object({
666
685
  finishReason: optionalText,
@@ -712,6 +731,12 @@ const parseAipassSSE = async function* parseAipassSSE(body, skips) {
712
731
  text: event.delta
713
732
  };
714
733
  break;
734
+ case "data-model_switched":
735
+ yield {
736
+ detail: event.data,
737
+ kind: "switch"
738
+ };
739
+ break;
715
740
  case "file":
716
741
  yield {
717
742
  file: toFileEvent(event),
@@ -1036,7 +1061,8 @@ const readReply = (options) => {
1036
1061
  skips: {
1037
1062
  count: 0,
1038
1063
  types: /* @__PURE__ */ new Set()
1039
- }
1064
+ },
1065
+ switchedModel: void 0
1040
1066
  };
1041
1067
  const splitter = splitReply(tools);
1042
1068
  const fromParts = function* fromParts(parts) {
@@ -1068,7 +1094,8 @@ const readReply = (options) => {
1068
1094
  kind: "reasoning",
1069
1095
  text: event.text
1070
1096
  };
1071
- } else if (event.kind === "file") {
1097
+ } else if (event.kind === "switch") tally.switchedModel = event.detail;
1098
+ else if (event.kind === "file") {
1072
1099
  const asset = await resolveAsset(cookie, event.file, signal);
1073
1100
  if (asset) {
1074
1101
  tally.files += 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thaipass",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "AI SDK provider for AI Pass, using your own session cookie.",
5
5
  "keywords": [
6
6
  "ai-sdk",