thaipass 0.1.3 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +30 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -199,8 +199,7 @@ const fetchCatalog = async (clientId, cookie, signal) => {
199
199
  * The AI Pass edge answers some requests itself with a 403 before the chat
200
200
  * backend runs, scoring what the prompt contains rather than its length. A
201
201
  * retry of the same body gets the same verdict, so the proxy reports it as a
202
- * request error and hands back the edge's own body, since the trigger set is
203
- * undocumented.
202
+ * request error and hands back the edge's own body.
204
203
  */
205
204
  const EDGE_REFUSAL_STATUS = 403;
206
205
  const EDGE_REFUSAL_HINT = "; the AI Pass edge refused this before the model ran, on what the prompt contains rather than how long it is — resending the same text will be refused again";
@@ -652,6 +651,21 @@ const toolErrorSchema = (type) => z.object({
652
651
  toolName: optionalText,
653
652
  type: z.literal(type)
654
653
  });
654
+ const SWITCH_DETAIL_LIMIT = 120;
655
+ const namedModelSchema = z.object({
656
+ model: optionalText,
657
+ modelId: optionalText,
658
+ to: optionalText
659
+ });
660
+ /** The payload is undocumented, so an unnamed one is kept verbatim for the first production sample to show. */
661
+ const switchDetailSchema = z.unknown().transform((data) => {
662
+ const named = namedModelSchema.safeParse(data);
663
+ if (named.success) {
664
+ const found = named.data.modelId ?? named.data.model ?? named.data.to;
665
+ if (found !== void 0 && found.length > 0) return found;
666
+ }
667
+ return JSON.stringify(data ?? null).slice(0, SWITCH_DETAIL_LIMIT);
668
+ });
655
669
  const upstreamEventSchema = z.discriminatedUnion("type", [
656
670
  z.object({
657
671
  delta: z.string(),
@@ -661,6 +675,10 @@ const upstreamEventSchema = z.discriminatedUnion("type", [
661
675
  delta: z.string(),
662
676
  type: z.literal("reasoning-delta")
663
677
  }),
678
+ z.object({
679
+ data: switchDetailSchema,
680
+ type: z.literal("data-model_switched")
681
+ }),
664
682
  fileFrameSchema,
665
683
  z.object({
666
684
  finishReason: optionalText,
@@ -712,6 +730,12 @@ const parseAipassSSE = async function* parseAipassSSE(body, skips) {
712
730
  text: event.delta
713
731
  };
714
732
  break;
733
+ case "data-model_switched":
734
+ yield {
735
+ detail: event.data,
736
+ kind: "switch"
737
+ };
738
+ break;
715
739
  case "file":
716
740
  yield {
717
741
  file: toFileEvent(event),
@@ -1036,7 +1060,8 @@ const readReply = (options) => {
1036
1060
  skips: {
1037
1061
  count: 0,
1038
1062
  types: /* @__PURE__ */ new Set()
1039
- }
1063
+ },
1064
+ switchedModel: void 0
1040
1065
  };
1041
1066
  const splitter = splitReply(tools);
1042
1067
  const fromParts = function* fromParts(parts) {
@@ -1068,7 +1093,8 @@ const readReply = (options) => {
1068
1093
  kind: "reasoning",
1069
1094
  text: event.text
1070
1095
  };
1071
- } else if (event.kind === "file") {
1096
+ } else if (event.kind === "switch") tally.switchedModel = event.detail;
1097
+ else if (event.kind === "file") {
1072
1098
  const asset = await resolveAsset(cookie, event.file, signal);
1073
1099
  if (asset) {
1074
1100
  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.5",
4
4
  "description": "AI SDK provider for AI Pass, using your own session cookie.",
5
5
  "keywords": [
6
6
  "ai-sdk",