@earendil-works/pi-ai 1.4.0 → 1.5.0
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 +35 -35
- package/dist/api/anthropic-messages.d.ts.map +1 -1
- package/dist/api/anthropic-messages.js +59 -71
- package/dist/api/anthropic-messages.js.map +1 -1
- package/dist/api/azure-openai-responses.d.ts.map +1 -1
- package/dist/api/azure-openai-responses.js +0 -6
- package/dist/api/azure-openai-responses.js.map +1 -1
- package/dist/api/bedrock-converse-stream.d.ts.map +1 -1
- package/dist/api/bedrock-converse-stream.js +125 -103
- package/dist/api/bedrock-converse-stream.js.map +1 -1
- package/dist/api/constrained-sampling.d.ts +15 -1
- package/dist/api/constrained-sampling.d.ts.map +1 -1
- package/dist/api/constrained-sampling.js +51 -18
- package/dist/api/constrained-sampling.js.map +1 -1
- package/dist/api/google-generative-ai.d.ts.map +1 -1
- package/dist/api/google-generative-ai.js +0 -6
- package/dist/api/google-generative-ai.js.map +1 -1
- package/dist/api/google-shared.d.ts +2 -1
- package/dist/api/google-shared.d.ts.map +1 -1
- package/dist/api/google-shared.js +57 -2
- package/dist/api/google-shared.js.map +1 -1
- package/dist/api/google-vertex.d.ts.map +1 -1
- package/dist/api/google-vertex.js +0 -6
- package/dist/api/google-vertex.js.map +1 -1
- package/dist/api/mistral-conversations.d.ts.map +1 -1
- package/dist/api/mistral-conversations.js +17 -44
- package/dist/api/mistral-conversations.js.map +1 -1
- package/dist/api/openai-codex-responses.d.ts.map +1 -1
- package/dist/api/openai-codex-responses.js +0 -5
- package/dist/api/openai-codex-responses.js.map +1 -1
- package/dist/api/openai-completions.d.ts.map +1 -1
- package/dist/api/openai-completions.js +42 -54
- package/dist/api/openai-completions.js.map +1 -1
- package/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/dist/api/openai-responses-shared.js +58 -57
- package/dist/api/openai-responses-shared.js.map +1 -1
- package/dist/api/openai-responses.d.ts.map +1 -1
- package/dist/api/openai-responses.js +0 -6
- package/dist/api/openai-responses.js.map +1 -1
- package/dist/api/openrouter-images.js +1 -0
- package/dist/api/openrouter-images.js.map +1 -1
- package/dist/api/pi-messages.d.ts +2 -0
- package/dist/api/pi-messages.d.ts.map +1 -1
- package/dist/api/pi-messages.js +24 -9
- package/dist/api/pi-messages.js.map +1 -1
- package/dist/auth/oauth/github-copilot.d.ts.map +1 -1
- package/dist/auth/oauth/github-copilot.js +4 -11
- package/dist/auth/oauth/github-copilot.js.map +1 -1
- package/dist/auth/oauth/kimi-coding.d.ts.map +1 -1
- package/dist/auth/oauth/kimi-coding.js +4 -22
- package/dist/auth/oauth/kimi-coding.js.map +1 -1
- package/dist/auth/oauth/meta.d.ts.map +1 -1
- package/dist/auth/oauth/meta.js +1 -14
- package/dist/auth/oauth/meta.js.map +1 -1
- package/dist/auth/oauth/radius.d.ts.map +1 -1
- package/dist/auth/oauth/radius.js +9 -3
- package/dist/auth/oauth/radius.js.map +1 -1
- package/dist/auth/oauth/trusted-url.d.ts +7 -0
- package/dist/auth/oauth/trusted-url.d.ts.map +1 -0
- package/dist/auth/oauth/trusted-url.js +12 -0
- package/dist/auth/oauth/trusted-url.js.map +1 -0
- package/dist/auth/types.d.ts +4 -0
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/cli.js +6 -2
- package/dist/cli.js.map +1 -1
- package/dist/compat/extension-oauth-types.d.ts +4 -0
- package/dist/compat/extension-oauth-types.d.ts.map +1 -1
- package/dist/compat/extension-oauth-types.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.generated.js +1 -1
- package/dist/models.generated.js.map +1 -1
- package/dist/models.js +1 -0
- package/dist/models.js.map +1 -1
- package/dist/providers/amazon-bedrock.models.js +1 -1
- package/dist/providers/amazon-bedrock.models.js.map +1 -1
- package/dist/providers/ant-ling.models.js +1 -1
- package/dist/providers/ant-ling.models.js.map +1 -1
- package/dist/providers/anthropic.models.js +1 -1
- package/dist/providers/anthropic.models.js.map +1 -1
- package/dist/providers/azure.models.js +1 -1
- package/dist/providers/azure.models.js.map +1 -1
- package/dist/providers/baseten.models.js +1 -1
- package/dist/providers/baseten.models.js.map +1 -1
- package/dist/providers/cerebras.models.js +1 -1
- package/dist/providers/cerebras.models.js.map +1 -1
- package/dist/providers/cloudflare-ai-gateway.models.js +1 -1
- package/dist/providers/cloudflare-ai-gateway.models.js.map +1 -1
- package/dist/providers/cloudflare-workers-ai.models.js +1 -1
- package/dist/providers/cloudflare-workers-ai.models.js.map +1 -1
- package/dist/providers/compat-schema.d.ts +428 -456
- package/dist/providers/compat-schema.d.ts.map +1 -1
- package/dist/providers/compat-schema.js +144 -111
- package/dist/providers/compat-schema.js.map +1 -1
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/providers/data/anthropic.json +1 -1
- package/dist/providers/data/azure.json +1 -1
- package/dist/providers/data/baseten.json +1 -1
- package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/providers/data/fireworks.json +1 -1
- package/dist/providers/data/github-copilot.json +1 -1
- package/dist/providers/data/google-vertex.json +1 -1
- package/dist/providers/data/google.json +1 -1
- package/dist/providers/data/huggingface.json +1 -1
- package/dist/providers/data/kimi-coding.json +1 -1
- package/dist/providers/data/mistral.json +1 -1
- package/dist/providers/data/moonshotai-cn.json +1 -1
- package/dist/providers/data/moonshotai.json +1 -1
- package/dist/providers/data/nvidia.json +1 -1
- package/dist/providers/data/openai-codex.json +1 -1
- package/dist/providers/data/openai.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/qwen-token-plan-cn.json +1 -1
- package/dist/providers/data/qwen-token-plan-individual.json +1 -1
- package/dist/providers/data/qwen-token-plan.json +1 -1
- package/dist/providers/data/radius.json +1 -1
- package/dist/providers/data/together.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/providers/data/xai.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-ams.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-cn.json +1 -1
- package/dist/providers/data/xiaomi-token-plan-sgp.json +1 -1
- package/dist/providers/data/xiaomi.json +1 -1
- package/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/providers/data/zai.json +1 -1
- package/dist/providers/deepseek.models.js +1 -1
- package/dist/providers/deepseek.models.js.map +1 -1
- package/dist/providers/faux.d.ts.map +1 -1
- package/dist/providers/faux.js +7 -2
- package/dist/providers/faux.js.map +1 -1
- package/dist/providers/fireworks.models.js +1 -1
- package/dist/providers/fireworks.models.js.map +1 -1
- package/dist/providers/github-copilot.models.js +1 -1
- package/dist/providers/github-copilot.models.js.map +1 -1
- package/dist/providers/google-vertex.models.js +1 -1
- package/dist/providers/google-vertex.models.js.map +1 -1
- package/dist/providers/google.models.js +1 -1
- package/dist/providers/google.models.js.map +1 -1
- package/dist/providers/groq.models.js +1 -1
- package/dist/providers/groq.models.js.map +1 -1
- package/dist/providers/huggingface.models.js +1 -1
- package/dist/providers/huggingface.models.js.map +1 -1
- package/dist/providers/kimi-coding.models.js +1 -1
- package/dist/providers/kimi-coding.models.js.map +1 -1
- package/dist/providers/meta.models.js +1 -1
- package/dist/providers/meta.models.js.map +1 -1
- package/dist/providers/minimax-cn.models.js +1 -1
- package/dist/providers/minimax-cn.models.js.map +1 -1
- package/dist/providers/minimax.models.js +1 -1
- package/dist/providers/minimax.models.js.map +1 -1
- package/dist/providers/mistral.models.js +1 -1
- package/dist/providers/mistral.models.js.map +1 -1
- package/dist/providers/model-schema.d.ts +65 -65
- package/dist/providers/model-schema.d.ts.map +1 -1
- package/dist/providers/model-schema.js +41 -30
- package/dist/providers/model-schema.js.map +1 -1
- package/dist/providers/moonshotai-cn.models.js +1 -1
- package/dist/providers/moonshotai-cn.models.js.map +1 -1
- package/dist/providers/moonshotai.models.js +1 -1
- package/dist/providers/moonshotai.models.js.map +1 -1
- package/dist/providers/nvidia.models.js +1 -1
- package/dist/providers/nvidia.models.js.map +1 -1
- package/dist/providers/openai-codex.models.js +1 -1
- package/dist/providers/openai-codex.models.js.map +1 -1
- package/dist/providers/openai.models.js +1 -1
- package/dist/providers/openai.models.js.map +1 -1
- package/dist/providers/opencode-go.models.js +1 -1
- package/dist/providers/opencode-go.models.js.map +1 -1
- package/dist/providers/opencode.js +1 -1
- package/dist/providers/opencode.js.map +1 -1
- package/dist/providers/opencode.models.js +1 -1
- package/dist/providers/opencode.models.js.map +1 -1
- package/dist/providers/openrouter.models.js +1 -1
- package/dist/providers/openrouter.models.js.map +1 -1
- package/dist/providers/qwen-token-plan-cn.models.js +1 -1
- package/dist/providers/qwen-token-plan-cn.models.js.map +1 -1
- package/dist/providers/qwen-token-plan-individual.models.js +1 -1
- package/dist/providers/qwen-token-plan-individual.models.js.map +1 -1
- package/dist/providers/qwen-token-plan.models.js +1 -1
- package/dist/providers/qwen-token-plan.models.js.map +1 -1
- package/dist/providers/radius-config.d.ts.map +1 -1
- package/dist/providers/radius-config.js +2 -1
- package/dist/providers/radius-config.js.map +1 -1
- package/dist/providers/radius.models.js +1 -1
- package/dist/providers/radius.models.js.map +1 -1
- package/dist/providers/schema-builders.d.ts +10 -0
- package/dist/providers/schema-builders.d.ts.map +1 -0
- package/dist/providers/schema-builders.js +18 -0
- package/dist/providers/schema-builders.js.map +1 -0
- package/dist/providers/together.models.js +1 -1
- package/dist/providers/together.models.js.map +1 -1
- package/dist/providers/typesafe.models.js +1 -1
- package/dist/providers/typesafe.models.js.map +1 -1
- package/dist/providers/vercel-ai-gateway.models.js +1 -1
- package/dist/providers/vercel-ai-gateway.models.js.map +1 -1
- package/dist/providers/xai.models.js +1 -1
- package/dist/providers/xai.models.js.map +1 -1
- package/dist/providers/xiaomi-token-plan-ams.models.js +1 -1
- package/dist/providers/xiaomi-token-plan-ams.models.js.map +1 -1
- package/dist/providers/xiaomi-token-plan-cn.models.js +1 -1
- package/dist/providers/xiaomi-token-plan-cn.models.js.map +1 -1
- package/dist/providers/xiaomi-token-plan-sgp.models.js +1 -1
- package/dist/providers/xiaomi-token-plan-sgp.models.js.map +1 -1
- package/dist/providers/xiaomi.models.js +1 -1
- package/dist/providers/xiaomi.models.js.map +1 -1
- package/dist/providers/zai-coding-cn.models.js +1 -1
- package/dist/providers/zai-coding-cn.models.js.map +1 -1
- package/dist/providers/zai.models.js +1 -1
- package/dist/providers/zai.models.js.map +1 -1
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +2 -1
- package/dist/telemetry.js.map +1 -1
- package/dist/types.d.ts +12 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/error-body.d.ts.map +1 -1
- package/dist/utils/error-body.js +2 -1
- package/dist/utils/error-body.js.map +1 -1
- package/dist/utils/openrouter-cost.d.ts +24 -0
- package/dist/utils/openrouter-cost.d.ts.map +1 -0
- package/dist/utils/openrouter-cost.js +34 -0
- package/dist/utils/openrouter-cost.js.map +1 -0
- package/dist/utils/overflow.d.ts.map +1 -1
- package/dist/utils/overflow.js +2 -0
- package/dist/utils/overflow.js.map +1 -1
- package/dist/utils/retry.d.ts.map +1 -1
- package/dist/utils/retry.js +3 -0
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/streaming-json.d.ts +84 -0
- package/dist/utils/streaming-json.d.ts.map +1 -0
- package/dist/utils/streaming-json.js +513 -0
- package/dist/utils/streaming-json.js.map +1 -0
- package/dist/utils/{typebox-helpers.d.ts → string-enum.d.ts} +5 -5
- package/dist/utils/string-enum.d.ts.map +1 -0
- package/dist/utils/{typebox-helpers.js → string-enum.js} +5 -6
- package/dist/utils/string-enum.js.map +1 -0
- package/dist/utils/text.d.ts +7 -0
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -1
- package/dist/utils/transcript.d.ts +1 -1
- package/dist/utils/transcript.js +1 -1
- package/dist/utils/transcript.js.map +1 -1
- package/dist/utils/validation.d.ts +5 -3
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +27 -277
- package/dist/utils/validation.js.map +1 -1
- package/dist/utils/version.d.ts +1 -1
- package/dist/utils/version.js +1 -1
- package/dist/utils/version.js.map +1 -1
- package/package.json +11 -10
- package/dist/utils/typebox-helpers.d.ts.map +0 -1
- package/dist/utils/typebox-helpers.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openrouter.models.js","sourceRoot":"","sources":["../../src/providers/openrouter.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"openrouter.models.js","sourceRoot":"","sources":["../../src/providers/openrouter.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,wBAAwB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,iBAAiB,GAC7B,uBAAuB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAE/C,MAAM,CAAC,MAAM,uBAAuB,GACnC,wBAAwB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAEhD,MAAM,CAAC,MAAM,4BAA4B,GACxC,6BAA6B,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/openrouter.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const OPENROUTER_MODELS: ChatModelCatalog<typeof values, \"openrouter\"> =\n\tflattenChatModelCatalog(\"openrouter\", values);\n\nexport const OPENROUTER_IMAGE_MODELS: ImageModelCatalog<typeof values, \"openrouter\"> =\n\tflattenImageModelCatalog(\"openrouter\", values);\n\nexport const OPENROUTER_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"openrouter\"> =\n\tflattenClassifierModelCatalog(\"openrouter\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/qwen-token-plan-cn.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qwen-token-plan-cn.models.js","sourceRoot":"","sources":["../../src/providers/qwen-token-plan-cn.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"qwen-token-plan-cn.models.js","sourceRoot":"","sources":["../../src/providers/qwen-token-plan-cn.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,gCAAgC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,yBAAyB,GACrC,uBAAuB,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,+BAA+B,GAC3C,wBAAwB,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;AAExD,MAAM,CAAC,MAAM,oCAAoC,GAChD,6BAA6B,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/qwen-token-plan-cn.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const QWEN_TOKEN_PLAN_CN_MODELS: ChatModelCatalog<typeof values, \"qwen-token-plan-cn\"> =\n\tflattenChatModelCatalog(\"qwen-token-plan-cn\", values);\n\nexport const QWEN_TOKEN_PLAN_CN_IMAGE_MODELS: ImageModelCatalog<typeof values, \"qwen-token-plan-cn\"> =\n\tflattenImageModelCatalog(\"qwen-token-plan-cn\", values);\n\nexport const QWEN_TOKEN_PLAN_CN_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"qwen-token-plan-cn\"> =\n\tflattenClassifierModelCatalog(\"qwen-token-plan-cn\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/qwen-token-plan-individual.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qwen-token-plan-individual.models.js","sourceRoot":"","sources":["../../src/providers/qwen-token-plan-individual.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"qwen-token-plan-individual.models.js","sourceRoot":"","sources":["../../src/providers/qwen-token-plan-individual.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,wCAAwC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,iCAAiC,GAC7C,uBAAuB,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;AAE/D,MAAM,CAAC,MAAM,uCAAuC,GACnD,wBAAwB,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC;AAEhE,MAAM,CAAC,MAAM,4CAA4C,GACxD,6BAA6B,CAAC,4BAA4B,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/qwen-token-plan-individual.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const QWEN_TOKEN_PLAN_INDIVIDUAL_MODELS: ChatModelCatalog<typeof values, \"qwen-token-plan-individual\"> =\n\tflattenChatModelCatalog(\"qwen-token-plan-individual\", values);\n\nexport const QWEN_TOKEN_PLAN_INDIVIDUAL_IMAGE_MODELS: ImageModelCatalog<typeof values, \"qwen-token-plan-individual\"> =\n\tflattenImageModelCatalog(\"qwen-token-plan-individual\", values);\n\nexport const QWEN_TOKEN_PLAN_INDIVIDUAL_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"qwen-token-plan-individual\"> =\n\tflattenClassifierModelCatalog(\"qwen-token-plan-individual\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/qwen-token-plan.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qwen-token-plan.models.js","sourceRoot":"","sources":["../../src/providers/qwen-token-plan.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"qwen-token-plan.models.js","sourceRoot":"","sources":["../../src/providers/qwen-token-plan.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,6BAA6B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,sBAAsB,GAClC,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,4BAA4B,GACxC,wBAAwB,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,iCAAiC,GAC7C,6BAA6B,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/qwen-token-plan.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const QWEN_TOKEN_PLAN_MODELS: ChatModelCatalog<typeof values, \"qwen-token-plan\"> =\n\tflattenChatModelCatalog(\"qwen-token-plan\", values);\n\nexport const QWEN_TOKEN_PLAN_IMAGE_MODELS: ImageModelCatalog<typeof values, \"qwen-token-plan\"> =\n\tflattenImageModelCatalog(\"qwen-token-plan\", values);\n\nexport const QWEN_TOKEN_PLAN_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"qwen-token-plan\"> =\n\tflattenClassifierModelCatalog(\"qwen-token-plan\", values);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radius-config.d.ts","sourceRoot":"","sources":["../../src/providers/radius-config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E,CAOjH;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,GAAG,SAAS,GAAG,KAAK,CAAC,aAAa,CAAC,EAAE,CAGnH;AAOD,wBAAsB,uBAAuB,CAC5C,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,mBAAmB,CAAC,CAY9B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ownedSlice } from "../utils/text.js";
|
|
1
2
|
export const DEFAULT_RADIUS_GATEWAY = "https://radius.pi.dev";
|
|
2
3
|
function isRadiusGatewayModel(value) {
|
|
3
4
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
@@ -45,7 +46,7 @@ export function getRadiusModels(providerId, credential) {
|
|
|
45
46
|
}
|
|
46
47
|
function truncateHttpBody(body) {
|
|
47
48
|
const trimmed = body.trim();
|
|
48
|
-
return trimmed.length > 512 ? `${trimmed
|
|
49
|
+
return trimmed.length > 512 ? `${ownedSlice(trimmed, 0, 512)}…` : trimmed;
|
|
49
50
|
}
|
|
50
51
|
export async function loadRadiusGatewayConfig(gateway, apiKey, signal) {
|
|
51
52
|
const headers = { accept: "application/json" };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radius-config.js","sourceRoot":"","sources":["../../src/providers/radius-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"radius-config.js","sourceRoot":"","sources":["../../src/providers/radius-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAsB9D,SAAS,oBAAoB,CAAC,KAAc;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,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ClF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CACd,qCAAqC,OAAO,KAAK,QAAQ,CAAC,MAAM,KAAK,gBAAgB,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAC9G,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,2BAA2B,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import type { OAuthCredential } from \"../auth/types.ts\";\nimport type { Model, ThinkingLevelMap } from \"../types.ts\";\nimport { ownedSlice } from \"../utils/text.ts\";\n\nexport const DEFAULT_RADIUS_GATEWAY = \"https://radius.pi.dev\";\n\nexport type RadiusGatewayModel = {\n\tid: string;\n\tname: string;\n\treasoning: boolean;\n\tthinkingLevelMap?: ThinkingLevelMap;\n\tinput: (\"text\" | \"image\")[];\n\tcost: Model<\"pi-messages\">[\"cost\"];\n\tcontextWindow: number;\n\tmaxTokens: number;\n};\n\nexport type RadiusGatewayConfig = {\n\tbaseUrl: string;\n\tmodels: RadiusGatewayModel[];\n};\n\nexport type RadiusOAuthCredential = OAuthCredential & {\n\tgatewayConfig?: RadiusGatewayConfig;\n};\n\nfunction isRadiusGatewayModel(value: unknown): value is RadiusGatewayModel {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return false;\n\tconst model = value as Partial<RadiusGatewayModel>;\n\treturn (\n\t\ttypeof model.id === \"string\" &&\n\t\ttypeof model.name === \"string\" &&\n\t\ttypeof model.reasoning === \"boolean\" &&\n\t\tArray.isArray(model.input) &&\n\t\ttypeof model.cost === \"object\" &&\n\t\tmodel.cost !== null &&\n\t\t!Array.isArray(model.cost) &&\n\t\ttypeof model.contextWindow === \"number\" &&\n\t\ttypeof model.maxTokens === \"number\"\n\t);\n}\n\nfunction sanitizeRadiusGatewayConfig(config: unknown): RadiusGatewayConfig | undefined {\n\tif (typeof config !== \"object\" || config === null || Array.isArray(config)) return undefined;\n\tconst { baseUrl, models } = config as Partial<RadiusGatewayConfig>;\n\tif (typeof baseUrl !== \"string\" || !Array.isArray(models)) return undefined;\n\treturn {\n\t\tbaseUrl,\n\t\tmodels: models.filter(isRadiusGatewayModel).map((model) => ({ ...model })),\n\t};\n}\n\nexport function normalizeRadiusGatewayUrl(value: string): string {\n\tconst withScheme = /^https?:\\/\\//iu.test(value) ? value : `https://${value}`;\n\treturn withScheme.replace(/\\/+$/u, \"\");\n}\n\nexport function getRadiusCredentialConfig(credential: OAuthCredential | undefined): RadiusGatewayConfig | undefined {\n\treturn sanitizeRadiusGatewayConfig((credential as RadiusOAuthCredential | undefined)?.gatewayConfig);\n}\n\nexport function getRadiusModelsFromConfig(providerId: string, config: RadiusGatewayConfig): Model<\"pi-messages\">[] {\n\treturn config.models.map((model) => ({\n\t\t...model,\n\t\tapi: \"pi-messages\",\n\t\tprovider: providerId,\n\t\tbaseUrl: config.baseUrl,\n\t}));\n}\n\nexport function getRadiusModels(providerId: string, credential: OAuthCredential | undefined): Model<\"pi-messages\">[] {\n\tconst config = getRadiusCredentialConfig(credential);\n\treturn config ? getRadiusModelsFromConfig(providerId, config) : [];\n}\n\nfunction truncateHttpBody(body: string): string {\n\tconst trimmed = body.trim();\n\treturn trimmed.length > 512 ? `${ownedSlice(trimmed, 0, 512)}…` : trimmed;\n}\n\nexport async function loadRadiusGatewayConfig(\n\tgateway: string,\n\tapiKey?: string,\n\tsignal?: AbortSignal,\n): Promise<RadiusGatewayConfig> {\n\tconst headers: Record<string, string> = { accept: \"application/json\" };\n\tif (apiKey) headers.authorization = `Bearer ${apiKey}`;\n\tconst response = await fetch(new URL(\"/v1/config\", gateway), { headers, signal });\n\tif (!response.ok) {\n\t\tthrow new Error(\n\t\t\t`Could not load Radius config from ${gateway}: ${response.status}: ${truncateHttpBody(await response.text())}`,\n\t\t);\n\t}\n\tconst config = sanitizeRadiusGatewayConfig(await response.json());\n\tif (!config) throw new Error(`Invalid Radius config from ${gateway}`);\n\treturn config;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/radius.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radius.models.js","sourceRoot":"","sources":["../../src/providers/radius.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"radius.models.js","sourceRoot":"","sources":["../../src/providers/radius.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,aAAa,GACzB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,mBAAmB,GAC/B,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,wBAAwB,GACpC,6BAA6B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/radius.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const RADIUS_MODELS: ChatModelCatalog<typeof values, \"radius\"> =\n\tflattenChatModelCatalog(\"radius\", values);\n\nexport const RADIUS_IMAGE_MODELS: ImageModelCatalog<typeof values, \"radius\"> =\n\tflattenImageModelCatalog(\"radius\", values);\n\nexport const RADIUS_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"radius\"> =\n\tflattenClassifierModelCatalog(\"radius\", values);\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Annotations, type Properties, type Schema, type Static, type StaticObject } from "@earendil-works/pi-schema";
|
|
2
|
+
/** An object that allows other properties; `additionalProperties: true` says so explicitly. */
|
|
3
|
+
export declare function openObject<const P extends Properties>(properties: P, options?: Annotations<StaticObject<P>> & {
|
|
4
|
+
readonly additionalProperties?: true;
|
|
5
|
+
}): Schema<StaticObject<P>>;
|
|
6
|
+
/** One string: `{ type: "string", const: value }`. */
|
|
7
|
+
export declare function stringLiteral<const V extends string>(value: V, options?: Annotations<V>): Schema<V>;
|
|
8
|
+
/** An object with any string keys and values of `value`: `{ type: "object", patternProperties: { "^.*$": value } }`. */
|
|
9
|
+
export declare function stringRecord<S extends Schema>(value: S, options?: Annotations<Record<string, Static<S>>>): Schema<Record<string, Static<S>>>;
|
|
10
|
+
//# sourceMappingURL=schema-builders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-builders.d.ts","sourceRoot":"","sources":["../../src/providers/schema-builders.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,KAAK,WAAW,EAEhB,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,MAAM,2BAA2B,CAAC;AAEnC,+FAA+F;AAC/F,wBAAgB,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,UAAU,EACpD,UAAU,EAAE,CAAC,EACb,OAAO,GAAE,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,oBAAoB,CAAC,EAAE,IAAI,CAAA;CAAO,GACnF,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAIzB;AAED,sDAAsD;AACtD,wBAAgB,aAAa,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,GAAE,WAAW,CAAC,CAAC,CAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAEvG;AAED,wHAAwH;AACxH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC5C,KAAK,EAAE,CAAC,EACR,OAAO,GAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAM,GAClD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAEnC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Builders for pi-ai's own configuration schemas (model metadata, compat settings): pi-schema's builders, shaped like the
|
|
2
|
+
// TypeBox schemas they replace, so models.json and the catalog validate exactly as before.
|
|
3
|
+
import { obj, } from "@earendil-works/pi-schema";
|
|
4
|
+
/** An object that allows other properties; `additionalProperties: true` says so explicitly. */
|
|
5
|
+
export function openObject(properties, options = {}) {
|
|
6
|
+
const { additionalProperties, ...annotations } = options;
|
|
7
|
+
const schema = obj(properties, { ...annotations, open: true });
|
|
8
|
+
return additionalProperties ? { ...schema, additionalProperties } : schema;
|
|
9
|
+
}
|
|
10
|
+
/** One string: `{ type: "string", const: value }`. */
|
|
11
|
+
export function stringLiteral(value, options = {}) {
|
|
12
|
+
return { type: "string", const: value, ...options };
|
|
13
|
+
}
|
|
14
|
+
/** An object with any string keys and values of `value`: `{ type: "object", patternProperties: { "^.*$": value } }`. */
|
|
15
|
+
export function stringRecord(value, options = {}) {
|
|
16
|
+
return { type: "object", patternProperties: { "^.*$": value }, ...options };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=schema-builders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-builders.js","sourceRoot":"","sources":["../../src/providers/schema-builders.ts"],"names":[],"mappings":"AAAA,0HAA0H;AAC1H,2FAA2F;AAE3F,OAAO,EAEN,GAAG,GAKH,MAAM,2BAA2B,CAAC;AAEnC,+FAA+F;AAC/F,MAAM,UAAU,UAAU,CACzB,UAAa,EACb,OAAO,GAA4E,EAAE;IAErF,MAAM,EAAE,oBAAoB,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;IACzD,MAAM,MAAM,GAAG,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,OAAO,oBAAoB,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAC5E,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,aAAa,CAAyB,KAAQ,EAAE,OAAO,GAAmB,EAAE;IAC3F,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC;AACrD,CAAC;AAED,wHAAwH;AACxH,MAAM,UAAU,YAAY,CAC3B,KAAQ,EACR,OAAO,GAA2C,EAAE;IAEpD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["// Builders for pi-ai's own configuration schemas (model metadata, compat settings): pi-schema's builders, shaped like the\n// TypeBox schemas they replace, so models.json and the catalog validate exactly as before.\n\nimport {\n\ttype Annotations,\n\tobj,\n\ttype Properties,\n\ttype Schema,\n\ttype Static,\n\ttype StaticObject,\n} from \"@earendil-works/pi-schema\";\n\n/** An object that allows other properties; `additionalProperties: true` says so explicitly. */\nexport function openObject<const P extends Properties>(\n\tproperties: P,\n\toptions: Annotations<StaticObject<P>> & { readonly additionalProperties?: true } = {},\n): Schema<StaticObject<P>> {\n\tconst { additionalProperties, ...annotations } = options;\n\tconst schema = obj(properties, { ...annotations, open: true });\n\treturn additionalProperties ? { ...schema, additionalProperties } : schema;\n}\n\n/** One string: `{ type: \"string\", const: value }`. */\nexport function stringLiteral<const V extends string>(value: V, options: Annotations<V> = {}): Schema<V> {\n\treturn { type: \"string\", const: value, ...options };\n}\n\n/** An object with any string keys and values of `value`: `{ type: \"object\", patternProperties: { \"^.*$\": value } }`. */\nexport function stringRecord<S extends Schema>(\n\tvalue: S,\n\toptions: Annotations<Record<string, Static<S>>> = {},\n): Schema<Record<string, Static<S>>> {\n\treturn { type: \"object\", patternProperties: { \"^.*$\": value }, ...options };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/together.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"together.models.js","sourceRoot":"","sources":["../../src/providers/together.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"together.models.js","sourceRoot":"","sources":["../../src/providers/together.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,sBAAsB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,eAAe,GAC3B,uBAAuB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GACjC,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,CAAC,MAAM,0BAA0B,GACtC,6BAA6B,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/together.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const TOGETHER_MODELS: ChatModelCatalog<typeof values, \"together\"> =\n\tflattenChatModelCatalog(\"together\", values);\n\nexport const TOGETHER_IMAGE_MODELS: ImageModelCatalog<typeof values, \"together\"> =\n\tflattenImageModelCatalog(\"together\", values);\n\nexport const TOGETHER_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"together\"> =\n\tflattenClassifierModelCatalog(\"together\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/typesafe.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesafe.models.js","sourceRoot":"","sources":["../../src/providers/typesafe.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"typesafe.models.js","sourceRoot":"","sources":["../../src/providers/typesafe.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,sBAAsB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,eAAe,GAC3B,uBAAuB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAE7C,MAAM,CAAC,MAAM,qBAAqB,GACjC,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,CAAC,MAAM,0BAA0B,GACtC,6BAA6B,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/typesafe.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const TYPESAFE_MODELS: ChatModelCatalog<typeof values, \"typesafe\"> =\n\tflattenChatModelCatalog(\"typesafe\", values);\n\nexport const TYPESAFE_IMAGE_MODELS: ImageModelCatalog<typeof values, \"typesafe\"> =\n\tflattenImageModelCatalog(\"typesafe\", values);\n\nexport const TYPESAFE_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"typesafe\"> =\n\tflattenClassifierModelCatalog(\"typesafe\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/vercel-ai-gateway.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-ai-gateway.models.js","sourceRoot":"","sources":["../../src/providers/vercel-ai-gateway.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"vercel-ai-gateway.models.js","sourceRoot":"","sources":["../../src/providers/vercel-ai-gateway.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,+BAA+B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,wBAAwB,GACpC,uBAAuB,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAEtD,MAAM,CAAC,MAAM,8BAA8B,GAC1C,wBAAwB,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAEvD,MAAM,CAAC,MAAM,mCAAmC,GAC/C,6BAA6B,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/vercel-ai-gateway.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const VERCEL_AI_GATEWAY_MODELS: ChatModelCatalog<typeof values, \"vercel-ai-gateway\"> =\n\tflattenChatModelCatalog(\"vercel-ai-gateway\", values);\n\nexport const VERCEL_AI_GATEWAY_IMAGE_MODELS: ImageModelCatalog<typeof values, \"vercel-ai-gateway\"> =\n\tflattenImageModelCatalog(\"vercel-ai-gateway\", values);\n\nexport const VERCEL_AI_GATEWAY_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"vercel-ai-gateway\"> =\n\tflattenClassifierModelCatalog(\"vercel-ai-gateway\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/xai.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xai.models.js","sourceRoot":"","sources":["../../src/providers/xai.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"xai.models.js","sourceRoot":"","sources":["../../src/providers/xai.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,UAAU,GACtB,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAExC,MAAM,CAAC,MAAM,gBAAgB,GAC5B,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEzC,MAAM,CAAC,MAAM,qBAAqB,GACjC,6BAA6B,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/xai.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const XAI_MODELS: ChatModelCatalog<typeof values, \"xai\"> =\n\tflattenChatModelCatalog(\"xai\", values);\n\nexport const XAI_IMAGE_MODELS: ImageModelCatalog<typeof values, \"xai\"> =\n\tflattenImageModelCatalog(\"xai\", values);\n\nexport const XAI_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"xai\"> =\n\tflattenClassifierModelCatalog(\"xai\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/xiaomi-token-plan-ams.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xiaomi-token-plan-ams.models.js","sourceRoot":"","sources":["../../src/providers/xiaomi-token-plan-ams.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"xiaomi-token-plan-ams.models.js","sourceRoot":"","sources":["../../src/providers/xiaomi-token-plan-ams.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,mCAAmC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,4BAA4B,GACxC,uBAAuB,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,kCAAkC,GAC9C,wBAAwB,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,uCAAuC,GACnD,6BAA6B,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/xiaomi-token-plan-ams.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const XIAOMI_TOKEN_PLAN_AMS_MODELS: ChatModelCatalog<typeof values, \"xiaomi-token-plan-ams\"> =\n\tflattenChatModelCatalog(\"xiaomi-token-plan-ams\", values);\n\nexport const XIAOMI_TOKEN_PLAN_AMS_IMAGE_MODELS: ImageModelCatalog<typeof values, \"xiaomi-token-plan-ams\"> =\n\tflattenImageModelCatalog(\"xiaomi-token-plan-ams\", values);\n\nexport const XIAOMI_TOKEN_PLAN_AMS_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"xiaomi-token-plan-ams\"> =\n\tflattenClassifierModelCatalog(\"xiaomi-token-plan-ams\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/xiaomi-token-plan-cn.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xiaomi-token-plan-cn.models.js","sourceRoot":"","sources":["../../src/providers/xiaomi-token-plan-cn.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"xiaomi-token-plan-cn.models.js","sourceRoot":"","sources":["../../src/providers/xiaomi-token-plan-cn.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,kCAAkC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,2BAA2B,GACvC,uBAAuB,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,iCAAiC,GAC7C,wBAAwB,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,sCAAsC,GAClD,6BAA6B,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/xiaomi-token-plan-cn.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const XIAOMI_TOKEN_PLAN_CN_MODELS: ChatModelCatalog<typeof values, \"xiaomi-token-plan-cn\"> =\n\tflattenChatModelCatalog(\"xiaomi-token-plan-cn\", values);\n\nexport const XIAOMI_TOKEN_PLAN_CN_IMAGE_MODELS: ImageModelCatalog<typeof values, \"xiaomi-token-plan-cn\"> =\n\tflattenImageModelCatalog(\"xiaomi-token-plan-cn\", values);\n\nexport const XIAOMI_TOKEN_PLAN_CN_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"xiaomi-token-plan-cn\"> =\n\tflattenClassifierModelCatalog(\"xiaomi-token-plan-cn\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/xiaomi-token-plan-sgp.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xiaomi-token-plan-sgp.models.js","sourceRoot":"","sources":["../../src/providers/xiaomi-token-plan-sgp.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"xiaomi-token-plan-sgp.models.js","sourceRoot":"","sources":["../../src/providers/xiaomi-token-plan-sgp.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,mCAAmC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,4BAA4B,GACxC,uBAAuB,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,kCAAkC,GAC9C,wBAAwB,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;AAE3D,MAAM,CAAC,MAAM,uCAAuC,GACnD,6BAA6B,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/xiaomi-token-plan-sgp.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const XIAOMI_TOKEN_PLAN_SGP_MODELS: ChatModelCatalog<typeof values, \"xiaomi-token-plan-sgp\"> =\n\tflattenChatModelCatalog(\"xiaomi-token-plan-sgp\", values);\n\nexport const XIAOMI_TOKEN_PLAN_SGP_IMAGE_MODELS: ImageModelCatalog<typeof values, \"xiaomi-token-plan-sgp\"> =\n\tflattenImageModelCatalog(\"xiaomi-token-plan-sgp\", values);\n\nexport const XIAOMI_TOKEN_PLAN_SGP_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"xiaomi-token-plan-sgp\"> =\n\tflattenClassifierModelCatalog(\"xiaomi-token-plan-sgp\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/xiaomi.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xiaomi.models.js","sourceRoot":"","sources":["../../src/providers/xiaomi.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"xiaomi.models.js","sourceRoot":"","sources":["../../src/providers/xiaomi.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,oBAAoB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,aAAa,GACzB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAE3C,MAAM,CAAC,MAAM,mBAAmB,GAC/B,wBAAwB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,wBAAwB,GACpC,6BAA6B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/xiaomi.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const XIAOMI_MODELS: ChatModelCatalog<typeof values, \"xiaomi\"> =\n\tflattenChatModelCatalog(\"xiaomi\", values);\n\nexport const XIAOMI_IMAGE_MODELS: ImageModelCatalog<typeof values, \"xiaomi\"> =\n\tflattenImageModelCatalog(\"xiaomi\", values);\n\nexport const XIAOMI_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"xiaomi\"> =\n\tflattenClassifierModelCatalog(\"xiaomi\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/zai-coding-cn.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zai-coding-cn.models.js","sourceRoot":"","sources":["../../src/providers/zai-coding-cn.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"zai-coding-cn.models.js","sourceRoot":"","sources":["../../src/providers/zai-coding-cn.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,2BAA2B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,oBAAoB,GAChC,uBAAuB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,0BAA0B,GACtC,wBAAwB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,+BAA+B,GAC3C,6BAA6B,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/zai-coding-cn.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const ZAI_CODING_CN_MODELS: ChatModelCatalog<typeof values, \"zai-coding-cn\"> =\n\tflattenChatModelCatalog(\"zai-coding-cn\", values);\n\nexport const ZAI_CODING_CN_IMAGE_MODELS: ImageModelCatalog<typeof values, \"zai-coding-cn\"> =\n\tflattenImageModelCatalog(\"zai-coding-cn\", values);\n\nexport const ZAI_CODING_CN_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"zai-coding-cn\"> =\n\tflattenClassifierModelCatalog(\"zai-coding-cn\", values);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// This file is auto-generated by
|
|
1
|
+
// This file is auto-generated by catalog/generate.ts
|
|
2
2
|
// Do not edit manually - run 'npm run generate-models' to update
|
|
3
3
|
import values from "./data/zai.json" with { type: "json" };
|
|
4
4
|
import { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog } from "../model-catalog.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zai.models.js","sourceRoot":"","sources":["../../src/providers/zai.models.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"zai.models.js","sourceRoot":"","sources":["../../src/providers/zai.models.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,iEAAiE;AAEjE,OAAO,MAAM,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,wBAAwB,EAA8E,MAAM,qBAAqB,CAAC;AAEnM,MAAM,CAAC,MAAM,UAAU,GACtB,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAExC,MAAM,CAAC,MAAM,gBAAgB,GAC5B,wBAAwB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEzC,MAAM,CAAC,MAAM,qBAAqB,GACjC,6BAA6B,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC","sourcesContent":["// This file is auto-generated by catalog/generate.ts\n// Do not edit manually - run 'npm run generate-models' to update\n\nimport values from \"./data/zai.json\" with { type: \"json\" };\nimport { flattenChatModelCatalog, flattenClassifierModelCatalog, flattenImageModelCatalog, type ChatModelCatalog, type ClassifierModelCatalog, type ImageModelCatalog } from \"../model-catalog.ts\";\n\nexport const ZAI_MODELS: ChatModelCatalog<typeof values, \"zai\"> =\n\tflattenChatModelCatalog(\"zai\", values);\n\nexport const ZAI_IMAGE_MODELS: ImageModelCatalog<typeof values, \"zai\"> =\n\tflattenImageModelCatalog(\"zai\", values);\n\nexport const ZAI_CLASSIFIER_MODELS: ClassifierModelCatalog<typeof values, \"zai\"> =\n\tflattenClassifierModelCatalog(\"zai\", values);\n"]}
|
package/dist/telemetry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAQN,KAAK,aAAa,EAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EAQN,KAAK,aAAa,EAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAmD7C,4FAA4F;AAC5F,eAAO,MAAM,mBAAmB;;;;kCAzClB,yEAAyE;;yBAC3E,IAAI,EAAE,KAAK;;;;mCATE,QAAQ;0CAAe,sBAAsB;;;;6BAY7D,IAAI,EAAE,QAAQ;6BAAE,WAAW,EAAE,iBAAiB;6BAAE,QAAQ;;;mCAX3C,QAAQ;0CAAe,6BAA6B;;;;6BAa3D,IAAI,EAAE,QAAQ;6BAAE,WAAW,EAAE,mCAAmC;6BAAE,QAAQ;;;;;mCAXlF,QAAQ;0CACD,yBAAyB;+CAC7B,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU;;;6BAa7D,IAAI,EAAE,QAAQ;6BAAE,WAAW,EAAE,wBAAwB;;;6BACpD,IAAI,EAAE,QAAQ;6BAAE,WAAW,EAAE,gBAAgB;;;6BAC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K;qCAAI,IAAI,EAAE,QAAQ;qCAAE,WAAW,EAAE,yBAAyB;qCAAE,QAAQ;;iCACzE,IAAI;qCAAI,IAAI,EAAE,QAAQ;qCAAE,WAAW,EAAE,uCAAuC;qCAAE,QAAQ;;;;;;yBAKxF,OAAO,EAAE,IAAI;yBACb,SAAS,EAAE,mGAAmG;;;;;;;;;;;;;;;;;;;;;;mCAzCzG,QAAQ;0CACD,yBAAyB;+CAC7B,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqF9E,CAAC;AAgBH,wBAAgB,mBAAmB,CAClC,cAAc,EAAE,KAAK,CAAC,GAAG,CAAC,EAC1B,OAAO,EAAE;IAAE,SAAS,CAAC,EAAE,aAAa,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,EACvE,IAAI,EAAE,OAAO,GACX,kBAAkB,CAqFpB"}
|
package/dist/telemetry.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createTypedMetrics, createTypedSpanStarter, defineTelemetrySchema, NOOP_TELEMETRY_CONTEXT, NOOP_TELEMETRY_METRICS, } from "@earendil-works/pi-telemetry";
|
|
2
|
+
import { ownedSlice } from "./utils/text.js";
|
|
2
3
|
const provider = { type: "string", description: "Provider identifier.", required: true };
|
|
3
4
|
const model = { type: "string", description: "Requested model identifier.", required: true };
|
|
4
5
|
const stop = {
|
|
@@ -172,7 +173,7 @@ export function observeModelRequest(requestedModel, options, poll) {
|
|
|
172
173
|
if (message.stopReason === "error") {
|
|
173
174
|
span.setStatus({
|
|
174
175
|
status: "error",
|
|
175
|
-
error: { name: "provider_error", message: message.errorMessage
|
|
176
|
+
error: { name: "provider_error", message: ownedSlice(message.errorMessage ?? "", 0, 500) },
|
|
176
177
|
});
|
|
177
178
|
}
|
|
178
179
|
requestDuration.record(performance.now() - started, { ...attributes, stop: message.stopReason }, span);
|
package/dist/telemetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,GAItB,MAAM,8BAA8B,CAAC;AAItC,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE,QAAQ,EAAE,IAAI,EAAW,CAAC;AAClG,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6BAA6B,EAAE,QAAQ,EAAE,IAAI,EAAW,CAAC;AACtG,MAAM,IAAI,GAAG;IACZ,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,yBAAyB;IACtC,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC;CACvE,CAAC;AACX,MAAM,OAAO,GAAG;IACf,WAAW,EAAE,yEAAyE;IACtF,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;IACxB,eAAe,EAAE;QAChB,QAAQ;QACR,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACvE,KAAK;QACL,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mCAAmC,EAAE,QAAQ,EAAE,KAAK,EAAE;KAChG;IACD,aAAa,EAAE;QACd,IAAI;QACJ,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,wBAAwB,EAAE;QACxE,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAA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UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;gBACvG,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,UAAU,KAAK,UAAU,CAAC,EAAE,CAAC;oBACtF,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;oBAClE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;oBACpE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;oBAC3E,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;oBAC7E,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;gBAChD,CAAC;YACF,CAAC;YACD,MAAM,EAAE,CAAC;QACV,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\tcreateTypedMetrics,\n\tcreateTypedSpanStarter,\n\tdefineTelemetrySchema,\n\tNOOP_TELEMETRY_CONTEXT,\n\tNOOP_TELEMETRY_METRICS,\n\ttype SchemaTelemetrySpan,\n\ttype TelemetryMetrics,\n\ttype TelemetrySpan,\n} from \"@earendil-works/pi-telemetry\";\nimport type { LazyStreamObserver } from \"./api/lazy.ts\";\nimport type { Api, Model } from \"./types.ts\";\n\nconst provider = { type: \"string\", description: \"Provider identifier.\", required: true } as const;\nconst model = { type: \"string\", description: \"Requested model identifier.\", required: true } as const;\nconst stop = {\n\ttype: \"string\",\n\tdescription: \"Normalized stop reason.\",\n\tvalues: [\"pending\", \"stop\", \"length\", \"toolUse\", \"error\", \"aborted\", \"deferred\"],\n} as const;\nconst request = {\n\tdescription: \"One logical model request, including authentication and provider setup.\",\n\tparents: { kind: \"any\" },\n\tstartAttributes: {\n\t\tprovider,\n\t\tapi: { type: \"string\", description: \"API identifier.\", required: true },\n\t\tmodel,\n\t\treasoning: { type: \"string\", description: \"Scalar requested reasoning level.\", required: false },\n\t},\n\tendAttributes: {\n\t\tstop,\n\t\t\"usage.input\": { type: \"number\", description: \"Uncached input tokens.\" },\n\t\t\"usage.output\": { type: \"number\", description: \"Output tokens.\" },\n\t\t\"usage.cache_read\": { type: \"number\", description: \"Cache-read tokens.\" },\n\t\t\"usage.cache_write\": { type: \"number\", description: \"Cache-write tokens.\" },\n\t\t\"cost.total\": { type: \"number\", description: \"Total request cost in USD.\" },\n\t\t\"response.id\": { type: \"string\", description: \"Provider response identifier.\", cardinality: \"high\" },\n\t},\n\tevents: {\n\t\t\"pi.ai.first_chunk\": { description: \"First normalized stream event delivered.\", attributes: {} },\n\t\t\"pi.ai.block\": {\n\t\t\tdescription: \"A completed content block; content is never recorded.\",\n\t\t\tattributes: {\n\t\t\t\ttype: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tdescription: \"Block kind.\",\n\t\t\t\t\tvalues: [\"text\", \"thinking\", \"tool_call\"],\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\tindex: { type: \"number\", description: \"Content block index.\", required: true },\n\t\t\t\tchars: { type: \"number\", description: \"UTF-16 character count.\", required: true },\n\t\t\t\ttool: { type: \"string\", description: \"Tool name, for tool-call blocks only.\", required: false },\n\t\t\t},\n\t\t},\n\t},\n\tstatus: {\n\t\tdefault: \"ok\",\n\t\terrorWhen: \"Stop reason is error: provider_error with at most 500 error-message characters. Aborted stays ok.\",\n\t},\n} as const;\n\n/** Pi-owned request metadata, bounded error status, events, and low-cardinality metrics. */\nexport const AI_TELEMETRY_SCHEMA = defineTelemetrySchema({\n\tversion: 1,\n\tspans: {\n\t\t\"pi.ai.request\": request,\n\t\t\"pi.ai.poll\": { ...request, description: \"One deferred-response poll, not the deferred request's lifetime.\" },\n\t},\n\tmetrics: {\n\t\t\"pi.ai.request.duration\": {\n\t\t\tkind: \"histogram\",\n\t\t\tdescription: \"Logical request or poll duration.\",\n\t\t\tunit: \"ms\",\n\t\t\tattributes: { provider, model, stop: { ...stop, required: true } },\n\t\t},\n\t\t\"pi.ai.first_chunk.duration\": {\n\t\t\tkind: \"histogram\",\n\t\t\tdescription: \"Time to the first normalized stream event.\",\n\t\t\tunit: \"ms\",\n\t\t\tattributes: { provider, model },\n\t\t},\n\t\t\"pi.ai.tokens\": {\n\t\t\tkind: \"counter\",\n\t\t\tdescription: \"Reported model token usage; pending and deferred polls are excluded.\",\n\t\t\tunit: \"token\",\n\t\t\tattributes: {\n\t\t\t\tprovider,\n\t\t\t\tmodel,\n\t\t\t\tkind: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tdescription: \"Token usage category.\",\n\t\t\t\t\tvalues: [\"input\", \"output\", \"cache_read\", \"cache_write\"],\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t\"pi.ai.cost\": {\n\t\t\tkind: \"counter\",\n\t\t\tdescription: \"Reported model cost; pending and deferred polls are excluded.\",\n\t\t\tunit: \"USD\",\n\t\t\tattributes: { provider, model },\n\t\t},\n\t},\n});\n\ntype RequestSpan = SchemaTelemetrySpan<typeof AI_TELEMETRY_SCHEMA, \"pi.ai.request\">;\n\nfunction createInstruments(adapter: TelemetryMetrics) {\n\tconst metrics = createTypedMetrics(adapter, [AI_TELEMETRY_SCHEMA]);\n\treturn {\n\t\trequestDuration: metrics.histogram(\"pi.ai.request.duration\"),\n\t\tfirstChunkDuration: metrics.histogram(\"pi.ai.first_chunk.duration\"),\n\t\ttokens: metrics.counter(\"pi.ai.tokens\"),\n\t\tcost: metrics.counter(\"pi.ai.cost\"),\n\t};\n}\n\nconst instrumentCache = new WeakMap<TelemetryMetrics, ReturnType<typeof createInstruments>>();\n\nexport function observeModelRequest(\n\trequestedModel: Model<Api>,\n\toptions: { telemetry?: TelemetrySpan; reasoning?: unknown } | undefined,\n\tpoll: boolean,\n): LazyStreamObserver {\n\tconst started = performance.now();\n\tconst attributes = { provider: requestedModel.provider, model: requestedModel.id };\n\tconst adapter = options?.telemetry?.metrics ?? NOOP_TELEMETRY_METRICS;\n\tlet instruments = instrumentCache.get(adapter);\n\tif (!instruments) {\n\t\tinstruments = createInstruments(adapter);\n\t\tinstrumentCache.set(adapter, instruments);\n\t}\n\tconst { requestDuration, firstChunkDuration, tokens, cost } = instruments;\n\tlet span!: RequestSpan;\n\tlet finish!: () => void;\n\tlet first = true;\n\tconst toolChars = new Map<number, number>();\n\tconst finished = new Promise<void>((resolve) => {\n\t\tfinish = resolve;\n\t});\n\tconst run = (activeSpan: RequestSpan): Promise<void> => {\n\t\tspan = activeSpan;\n\t\treturn finished;\n\t};\n\tconst startAttributes = {\n\t\t...attributes,\n\t\tapi: requestedModel.api,\n\t\t...(typeof options?.reasoning === \"string\" ? { reasoning: options.reasoning } : {}),\n\t};\n\tconst start = createTypedSpanStarter(options?.telemetry ?? NOOP_TELEMETRY_CONTEXT, [AI_TELEMETRY_SCHEMA]);\n\tif (poll) void start(\"pi.ai.poll\", startAttributes, run);\n\telse void start(\"pi.ai.request\", startAttributes, run);\n\n\treturn {\n\t\tonEvent(event) {\n\t\t\tif (first) {\n\t\t\t\tfirst = false;\n\t\t\t\tspan.addEvent(\"pi.ai.first_chunk\");\n\t\t\t\tfirstChunkDuration.record(performance.now() - started, attributes, span);\n\t\t\t}\n\t\t\tif (event.type === \"toolcall_delta\") {\n\t\t\t\ttoolChars.set(event.contentIndex, (toolChars.get(event.contentIndex) ?? 0) + event.delta.length);\n\t\t\t} else if (event.type === \"text_end\" || event.type === \"thinking_end\") {\n\t\t\t\tspan.addEvent(\"pi.ai.block\", {\n\t\t\t\t\ttype: event.type === \"text_end\" ? \"text\" : \"thinking\",\n\t\t\t\t\tindex: event.contentIndex,\n\t\t\t\t\tchars: event.content.length,\n\t\t\t\t});\n\t\t\t} else if (event.type === \"toolcall_end\") {\n\t\t\t\tconst chars = toolChars.get(event.contentIndex) ?? 0;\n\t\t\t\ttoolChars.delete(event.contentIndex);\n\t\t\t\tspan.addEvent(\"pi.ai.block\", {\n\t\t\t\t\ttype: \"tool_call\",\n\t\t\t\t\tindex: event.contentIndex,\n\t\t\t\t\tchars,\n\t\t\t\t\ttool: event.toolCall.name,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tonResult(message) {\n\t\t\tif (message) {\n\t\t\t\tspan.setAttributes({\n\t\t\t\t\tstop: message.stopReason,\n\t\t\t\t\t\"usage.input\": message.usage.input,\n\t\t\t\t\t\"usage.output\": message.usage.output,\n\t\t\t\t\t\"usage.cache_read\": message.usage.cacheRead,\n\t\t\t\t\t\"usage.cache_write\": message.usage.cacheWrite,\n\t\t\t\t\t\"cost.total\": message.usage.cost.total,\n\t\t\t\t\t\"response.id\": message.responseId,\n\t\t\t\t});\n\t\t\t\tif (message.stopReason === \"error\") {\n\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\t\terror: { name: \"provider_error\", message: message.errorMessage?.slice(0, 500) ?? \"\" },\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\trequestDuration.record(performance.now() - started, { ...attributes, stop: message.stopReason }, span);\n\t\t\t\tif (!poll || (message.stopReason !== \"pending\" && message.stopReason !== \"deferred\")) {\n\t\t\t\t\ttokens.add(message.usage.input, { ...attributes, kind: \"input\" });\n\t\t\t\t\ttokens.add(message.usage.output, { ...attributes, kind: \"output\" });\n\t\t\t\t\ttokens.add(message.usage.cacheRead, { ...attributes, kind: \"cache_read\" });\n\t\t\t\t\ttokens.add(message.usage.cacheWrite, { ...attributes, kind: \"cache_write\" });\n\t\t\t\t\tcost.add(message.usage.cost.total, attributes);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinish();\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,GAItB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE,QAAQ,EAAE,IAAI,EAAW,CAAC;AAClG,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6BAA6B,EAAE,QAAQ,EAAE,IAAI,EAAW,CAAC;AACtG,MAAM,IAAI,GAAG;IACZ,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,yBAAyB;IACtC,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC;CACvE,CAAC;AACX,MAAM,OAAO,GAAG;IACf,WAAW,EAAE,yEAAyE;IACtF,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;IACxB,eAAe,EAAE;QAChB,QAAQ;QACR,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACvE,KAAK;QACL,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,mCAAmC,EAAE,QAAQ,EAAE,KAAK,EAAE;KAChG;IACD,aAAa,EAAE;QACd,IAAI;QACJ,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,wBAAwB,EAAE;QACx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AAC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;gBACvG,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,UAAU,KAAK,UAAU,CAAC,EAAE,CAAC;oBACtF,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;oBAClE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;oBACpE,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;oBAC3E,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;oBAC7E,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;gBAChD,CAAC;YACF,CAAC;YACD,MAAM,EAAE,CAAC;QACV,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import {\n\tcreateTypedMetrics,\n\tcreateTypedSpanStarter,\n\tdefineTelemetrySchema,\n\tNOOP_TELEMETRY_CONTEXT,\n\tNOOP_TELEMETRY_METRICS,\n\ttype SchemaTelemetrySpan,\n\ttype TelemetryMetrics,\n\ttype TelemetrySpan,\n} from \"@earendil-works/pi-telemetry\";\nimport type { LazyStreamObserver } from \"./api/lazy.ts\";\nimport type { Api, Model } from \"./types.ts\";\nimport { ownedSlice } from \"./utils/text.ts\";\n\nconst provider = { type: \"string\", description: \"Provider identifier.\", required: true } as const;\nconst model = { type: \"string\", description: \"Requested model identifier.\", required: true } as const;\nconst stop = {\n\ttype: \"string\",\n\tdescription: \"Normalized stop reason.\",\n\tvalues: [\"pending\", \"stop\", \"length\", \"toolUse\", \"error\", \"aborted\", \"deferred\"],\n} as const;\nconst request = {\n\tdescription: \"One logical model request, including authentication and provider setup.\",\n\tparents: { kind: \"any\" },\n\tstartAttributes: {\n\t\tprovider,\n\t\tapi: { type: \"string\", description: \"API identifier.\", required: true },\n\t\tmodel,\n\t\treasoning: { type: \"string\", description: \"Scalar requested reasoning level.\", required: false },\n\t},\n\tendAttributes: {\n\t\tstop,\n\t\t\"usage.input\": { type: \"number\", description: \"Uncached input tokens.\" },\n\t\t\"usage.output\": { type: \"number\", description: \"Output tokens.\" },\n\t\t\"usage.cache_read\": { type: \"number\", description: \"Cache-read tokens.\" },\n\t\t\"usage.cache_write\": { type: \"number\", description: \"Cache-write tokens.\" },\n\t\t\"cost.total\": { type: \"number\", description: \"Total request cost in USD.\" },\n\t\t\"response.id\": { type: \"string\", description: \"Provider response identifier.\", cardinality: \"high\" },\n\t},\n\tevents: {\n\t\t\"pi.ai.first_chunk\": { description: \"First normalized stream event delivered.\", attributes: {} },\n\t\t\"pi.ai.block\": {\n\t\t\tdescription: \"A completed content block; content is never recorded.\",\n\t\t\tattributes: {\n\t\t\t\ttype: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tdescription: \"Block kind.\",\n\t\t\t\t\tvalues: [\"text\", \"thinking\", \"tool_call\"],\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t\tindex: { type: \"number\", description: \"Content block index.\", required: true },\n\t\t\t\tchars: { type: \"number\", description: \"UTF-16 character count.\", required: true },\n\t\t\t\ttool: { type: \"string\", description: \"Tool name, for tool-call blocks only.\", required: false },\n\t\t\t},\n\t\t},\n\t},\n\tstatus: {\n\t\tdefault: \"ok\",\n\t\terrorWhen: \"Stop reason is error: provider_error with at most 500 error-message characters. Aborted stays ok.\",\n\t},\n} as const;\n\n/** Pi-owned request metadata, bounded error status, events, and low-cardinality metrics. */\nexport const AI_TELEMETRY_SCHEMA = defineTelemetrySchema({\n\tversion: 1,\n\tspans: {\n\t\t\"pi.ai.request\": request,\n\t\t\"pi.ai.poll\": { ...request, description: \"One deferred-response poll, not the deferred request's lifetime.\" },\n\t},\n\tmetrics: {\n\t\t\"pi.ai.request.duration\": {\n\t\t\tkind: \"histogram\",\n\t\t\tdescription: \"Logical request or poll duration.\",\n\t\t\tunit: \"ms\",\n\t\t\tattributes: { provider, model, stop: { ...stop, required: true } },\n\t\t},\n\t\t\"pi.ai.first_chunk.duration\": {\n\t\t\tkind: \"histogram\",\n\t\t\tdescription: \"Time to the first normalized stream event.\",\n\t\t\tunit: \"ms\",\n\t\t\tattributes: { provider, model },\n\t\t},\n\t\t\"pi.ai.tokens\": {\n\t\t\tkind: \"counter\",\n\t\t\tdescription: \"Reported model token usage; pending and deferred polls are excluded.\",\n\t\t\tunit: \"token\",\n\t\t\tattributes: {\n\t\t\t\tprovider,\n\t\t\t\tmodel,\n\t\t\t\tkind: {\n\t\t\t\t\ttype: \"string\",\n\t\t\t\t\tdescription: \"Token usage category.\",\n\t\t\t\t\tvalues: [\"input\", \"output\", \"cache_read\", \"cache_write\"],\n\t\t\t\t\trequired: true,\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\t\"pi.ai.cost\": {\n\t\t\tkind: \"counter\",\n\t\t\tdescription: \"Reported model cost; pending and deferred polls are excluded.\",\n\t\t\tunit: \"USD\",\n\t\t\tattributes: { provider, model },\n\t\t},\n\t},\n});\n\ntype RequestSpan = SchemaTelemetrySpan<typeof AI_TELEMETRY_SCHEMA, \"pi.ai.request\">;\n\nfunction createInstruments(adapter: TelemetryMetrics) {\n\tconst metrics = createTypedMetrics(adapter, [AI_TELEMETRY_SCHEMA]);\n\treturn {\n\t\trequestDuration: metrics.histogram(\"pi.ai.request.duration\"),\n\t\tfirstChunkDuration: metrics.histogram(\"pi.ai.first_chunk.duration\"),\n\t\ttokens: metrics.counter(\"pi.ai.tokens\"),\n\t\tcost: metrics.counter(\"pi.ai.cost\"),\n\t};\n}\n\nconst instrumentCache = new WeakMap<TelemetryMetrics, ReturnType<typeof createInstruments>>();\n\nexport function observeModelRequest(\n\trequestedModel: Model<Api>,\n\toptions: { telemetry?: TelemetrySpan; reasoning?: unknown } | undefined,\n\tpoll: boolean,\n): LazyStreamObserver {\n\tconst started = performance.now();\n\tconst attributes = { provider: requestedModel.provider, model: requestedModel.id };\n\tconst adapter = options?.telemetry?.metrics ?? NOOP_TELEMETRY_METRICS;\n\tlet instruments = instrumentCache.get(adapter);\n\tif (!instruments) {\n\t\tinstruments = createInstruments(adapter);\n\t\tinstrumentCache.set(adapter, instruments);\n\t}\n\tconst { requestDuration, firstChunkDuration, tokens, cost } = instruments;\n\tlet span!: RequestSpan;\n\tlet finish!: () => void;\n\tlet first = true;\n\tconst toolChars = new Map<number, number>();\n\tconst finished = new Promise<void>((resolve) => {\n\t\tfinish = resolve;\n\t});\n\tconst run = (activeSpan: RequestSpan): Promise<void> => {\n\t\tspan = activeSpan;\n\t\treturn finished;\n\t};\n\tconst startAttributes = {\n\t\t...attributes,\n\t\tapi: requestedModel.api,\n\t\t...(typeof options?.reasoning === \"string\" ? { reasoning: options.reasoning } : {}),\n\t};\n\tconst start = createTypedSpanStarter(options?.telemetry ?? NOOP_TELEMETRY_CONTEXT, [AI_TELEMETRY_SCHEMA]);\n\tif (poll) void start(\"pi.ai.poll\", startAttributes, run);\n\telse void start(\"pi.ai.request\", startAttributes, run);\n\n\treturn {\n\t\tonEvent(event) {\n\t\t\tif (first) {\n\t\t\t\tfirst = false;\n\t\t\t\tspan.addEvent(\"pi.ai.first_chunk\");\n\t\t\t\tfirstChunkDuration.record(performance.now() - started, attributes, span);\n\t\t\t}\n\t\t\tif (event.type === \"toolcall_delta\") {\n\t\t\t\ttoolChars.set(event.contentIndex, (toolChars.get(event.contentIndex) ?? 0) + event.delta.length);\n\t\t\t} else if (event.type === \"text_end\" || event.type === \"thinking_end\") {\n\t\t\t\tspan.addEvent(\"pi.ai.block\", {\n\t\t\t\t\ttype: event.type === \"text_end\" ? \"text\" : \"thinking\",\n\t\t\t\t\tindex: event.contentIndex,\n\t\t\t\t\tchars: event.content.length,\n\t\t\t\t});\n\t\t\t} else if (event.type === \"toolcall_end\") {\n\t\t\t\tconst chars = toolChars.get(event.contentIndex) ?? 0;\n\t\t\t\ttoolChars.delete(event.contentIndex);\n\t\t\t\tspan.addEvent(\"pi.ai.block\", {\n\t\t\t\t\ttype: \"tool_call\",\n\t\t\t\t\tindex: event.contentIndex,\n\t\t\t\t\tchars,\n\t\t\t\t\ttool: event.toolCall.name,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tonResult(message) {\n\t\t\tif (message) {\n\t\t\t\tspan.setAttributes({\n\t\t\t\t\tstop: message.stopReason,\n\t\t\t\t\t\"usage.input\": message.usage.input,\n\t\t\t\t\t\"usage.output\": message.usage.output,\n\t\t\t\t\t\"usage.cache_read\": message.usage.cacheRead,\n\t\t\t\t\t\"usage.cache_write\": message.usage.cacheWrite,\n\t\t\t\t\t\"cost.total\": message.usage.cost.total,\n\t\t\t\t\t\"response.id\": message.responseId,\n\t\t\t\t});\n\t\t\t\tif (message.stopReason === \"error\") {\n\t\t\t\t\tspan.setStatus({\n\t\t\t\t\t\tstatus: \"error\",\n\t\t\t\t\t\terror: { name: \"provider_error\", message: ownedSlice(message.errorMessage ?? \"\", 0, 500) },\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\trequestDuration.record(performance.now() - started, { ...attributes, stop: message.stopReason }, span);\n\t\t\t\tif (!poll || (message.stopReason !== \"pending\" && message.stopReason !== \"deferred\")) {\n\t\t\t\t\ttokens.add(message.usage.input, { ...attributes, kind: \"input\" });\n\t\t\t\t\ttokens.add(message.usage.output, { ...attributes, kind: \"output\" });\n\t\t\t\t\ttokens.add(message.usage.cacheRead, { ...attributes, kind: \"cache_read\" });\n\t\t\t\t\ttokens.add(message.usage.cacheWrite, { ...attributes, kind: \"cache_write\" });\n\t\t\t\t\tcost.add(message.usage.cost.total, attributes);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinish();\n\t\t},\n\t};\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -297,11 +297,18 @@ export interface Usage {
|
|
|
297
297
|
reasoning?: number;
|
|
298
298
|
totalTokens: number;
|
|
299
299
|
cost: {
|
|
300
|
+
/** Catalog-derived input cost. */
|
|
300
301
|
input: number;
|
|
302
|
+
/** Catalog-derived output cost. */
|
|
301
303
|
output: number;
|
|
304
|
+
/** Catalog-derived cache-read cost. */
|
|
302
305
|
cacheRead: number;
|
|
306
|
+
/** Catalog-derived cache-write cost. */
|
|
303
307
|
cacheWrite: number;
|
|
308
|
+
/** Best available total: provider-reported billed cost when supported, otherwise the catalog estimate. */
|
|
304
309
|
total: number;
|
|
310
|
+
/** True when `total` is the billed cost reported by the provider. False when it is a catalog estimate; absent also means false. */
|
|
311
|
+
totalFromProvider?: boolean;
|
|
305
312
|
};
|
|
306
313
|
}
|
|
307
314
|
export type StopReason = "pending" | "stop" | "length" | "toolUse" | "error" | "aborted" | "deferred";
|
|
@@ -507,7 +514,6 @@ export interface ClassifierResult {
|
|
|
507
514
|
errorMessage?: string;
|
|
508
515
|
timestamp: number;
|
|
509
516
|
}
|
|
510
|
-
import type { TSchema } from "typebox";
|
|
511
517
|
/** OpenAI grammar variants for constrained sampling. */
|
|
512
518
|
export type GrammarFormat = "openai_lark" | "openai_regex";
|
|
513
519
|
export type GrammarVariants = Partial<Record<GrammarFormat, string>>;
|
|
@@ -525,7 +531,11 @@ export type ConstrainedSamplingConfig = {
|
|
|
525
531
|
type: "grammar";
|
|
526
532
|
variants: GrammarVariants;
|
|
527
533
|
};
|
|
528
|
-
|
|
534
|
+
/**
|
|
535
|
+
* A tool the model may call. `parameters` is the JSON Schema of its arguments: pi-schema's builders (which also type
|
|
536
|
+
* the arguments, see `Static` in `@earendil-works/pi-schema`), TypeBox schemas, or any JSON Schema object.
|
|
537
|
+
*/
|
|
538
|
+
export interface Tool<TParameters extends object = object> {
|
|
529
539
|
name: string;
|
|
530
540
|
description: string;
|
|
531
541
|
parameters: TParameters;
|