From b9be4bef3c56fe8e5ad94f7b25709206bcd83fb6 Mon Sep 17 00:00:00 2001 From: Robert Sun Date: Thu, 24 Sep 2026 13:19:16 +0000 Subject: [PATCH 1/2] fix: restore generated package.json scripts so Speakeasy regen merges cleanly Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index bddfeed18..4f4fbaac1 100644 --- a/package.json +++ b/package.json @@ -71,17 +71,17 @@ }, "scripts": { "lint": "eslint --cache --max-warnings=0 src", - "build": "tsc && node scripts/unbarrel-imports.js", + "build": "tsc", "prepublishOnly": "npm run build", - "prepare": "npm run build", - "test": "vitest --run --project unit", + "compile": "tsc", "test:e2e": "vitest --run --project e2e", "test:transit": "exit 0", "test:watch": "vitest --watch --project unit", - "compile": "tsc && node scripts/unbarrel-imports.js", "typecheck": "tsc --noEmit", "typecheck:transit": "exit 0", - "postinstall": "node scripts/check-types.js || true" + "postinstall": "node scripts/check-types.js || true", + "prepare": "npm run build", + "test": "vitest --run --project unit" }, "peerDependencies": {}, "devDependencies": { From 8ec02fff489c5b1c453f1f66cc09736a2541acb9 Mon Sep 17 00:00:00 2001 From: Robert Sun Date: Thu, 24 Sep 2026 13:24:53 +0000 Subject: [PATCH 2/2] chore: resolve Speakeasy package.json persistent-edit conflict Ran speakeasy run, kept the generated package.json scripts (which include the unbarrel-imports build/compile steps), then speakeasy run --skip-versioning so gen.lock records that output as the pristine base. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .speakeasy/gen.lock | 89 ++++++------ .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 104 ++++++++++++-- .speakeasy/workflow.lock | 2 +- docs/models/customtoolcallitem.mdx | 4 +- docs/models/functioncallitem.mdx | 3 +- docs/models/inputsunion1.mdx | 23 ---- docs/models/outputcustomtoolcallitem.mdx | 8 +- docs/models/outputcustomtoolcallitemtype.mdx | 17 --- docs/models/outputfunctioncallitem.mdx | 8 +- docs/models/outputfunctioncallitemtype.mdx | 17 --- docs/models/outputitems.mdx | 12 +- jsr.json | 2 +- package.json | 20 +-- src/lib/config.ts | 4 +- src/models/customtoolcallitem.ts | 24 ++-- src/models/functioncallitem.ts | 41 +++--- src/models/inputsunion.ts | 34 +---- src/models/outputcustomtoolcallitem.ts | 64 +-------- src/models/outputfunctioncallitem.ts | 137 +------------------ src/models/outputitems.ts | 12 +- 21 files changed, 211 insertions(+), 416 deletions(-) delete mode 100644 docs/models/outputcustomtoolcallitemtype.mdx delete mode 100644 docs/models/outputfunctioncallitemtype.mdx diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index d7f14448e..245b6b6af 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,19 @@ lockVersion: "" id: "" management: - docChecksum: ac4bf44164b7dbc4e2d8b0cffd3312b3 + docChecksum: e6cd84f8bf1959ada801dc195a7cba3b docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 1.3.21 - configChecksum: 85aaf67f952a9a8f043515c87fc3fbdb + releaseVersion: 1.3.22 + configChecksum: f085e25640bb097d0590f353c9065299 repoURL: https://github.com/OpenRouterTeam/typescript-sdk.git installationURL: https://github.com/OpenRouterTeam/typescript-sdk published: true persistentEdits: - generation_id: 42b8b673-c6d7-47a5-9111-cc94801f2ca7 - pristine_commit_hash: d041654eead3d75b5553b558354a037355d2e91d - pristine_tree_hash: 091edaf01887c1b5247803aadb6c38010a9699dd + generation_id: 50695a38-d1f3-4b3d-8322-630b2b7669bc + pristine_commit_hash: d576bb615fa11001cf537ff3b9de893fa496afbe + pristine_tree_hash: 82f61570805d4c4b4bbacf0ca6e4fe619850f3d5 features: typescript: acceptHeaders: 2.81.2 @@ -73,7 +73,7 @@ trackedFiles: pristine_git_object: 53f6ec5a48eedd8f5ea2d8881c4c926a39ff2c45 RUNTIMES.md: id: 620c490847b6 - last_write_checksum: sha1:f05738c7be58b818f2bcfa26e5d325e78f9ae2f5 + last_write_checksum: sha1:e45b854f02c357cbcfdb8c3663000e8339e16505 pristine_git_object: 27731c3b5ace66bedc454ed5acbe15075aacd3dc USAGE.md: id: 3aed33ce6e6f @@ -3311,8 +3311,8 @@ trackedFiles: deleted: true docs/models/customtoolcallitem.mdx: id: f5aefce0cc1b - last_write_checksum: sha1:9e91bd093e65dfaae3a18750f68139594330346e - pristine_git_object: 52d689f41897e2811b8c7b4b5ec524eaf5288230 + last_write_checksum: sha1:8b4f34ce88b3eb0c153ec52552331e0145d162e9 + pristine_git_object: 5750324590981e4d5d8d1aa254a8cef488057496 docs/models/customtoolcallitemtype.md: id: 695c2252b124 last_write_checksum: sha1:3ffede76adb738db02be522a1c36b1d65eec1dcb @@ -4223,8 +4223,8 @@ trackedFiles: deleted: true docs/models/functioncallitem.mdx: id: b71f02394362 - last_write_checksum: sha1:c28297d214abdd71aa62aaa69ae7ecab93197643 - pristine_git_object: 8df0e6a55407f084bc004ecc03c9d4986174d77f + last_write_checksum: sha1:8bc732d43deb7095ab5ec1e85cc10887920173cf + pristine_git_object: 2428bdf8ffe43afebe0b16bb56cc95f227b8f0b1 docs/models/functioncallitemsubagentitem.mdx: id: ca813ee9e8a8 last_write_checksum: sha1:fca2e78176a1d2fff903411a1825dc9b5a6bed57 @@ -5411,8 +5411,8 @@ trackedFiles: deleted: true docs/models/inputsunion1.mdx: id: 73179e3011e7 - last_write_checksum: sha1:e56d2163d0bb02abacb864db7c65bbd5f003f0b7 - pristine_git_object: 206b7035a65897b85efd5afcc240def7bcf6bbfd + last_write_checksum: sha1:711aa1e2cc26709b076300e4892291ac640c9d22 + pristine_git_object: e99fe68008aa343dfeac5b7c5c3affc3c43f6320 docs/models/inputtext.md: id: bc941fd800e1 last_write_checksum: sha1:3b6f4c9eb68c3769cc71805d63a2997c54551130 @@ -9952,8 +9952,8 @@ trackedFiles: deleted: true docs/models/outputcustomtoolcallitem.mdx: id: 908e60a01b9d - last_write_checksum: sha1:90d5edefa3dfe04f66df1f27abf25f1df39bbb8b - pristine_git_object: 74fd3e29f54044e2346242b32eeffdb372f48d72 + last_write_checksum: sha1:8e1a2b6f18d5ca29768e5e83cb407ee120aaf751 + pristine_git_object: 65f81dd2aa3ba8f44c686cbb459a8af35f16a8dd docs/models/outputcustomtoolcallitemstatus.mdx: id: 6d19bf9c8da3 last_write_checksum: sha1:88c00cdeeb8a9292ae4201cb6d6d270987363c78 @@ -9963,10 +9963,6 @@ trackedFiles: last_write_checksum: sha1:78e3aa761f580f6429cab5704c8d0b7bd7336459 pristine_git_object: fa7d4360a8c5ef381d1cce7b9a8366296645f053 deleted: true - docs/models/outputcustomtoolcallitemtype.mdx: - id: 4281e080ddae - last_write_checksum: sha1:21b43990c8aa8ea3a0d4d0fd9e7608fa69911818 - pristine_git_object: fd1f6247ee5abc363c27a12e4163c99f3d8b8a4c docs/models/outputdatetimeitem.md: id: a4676f917431 last_write_checksum: sha1:de420e7bd8f01778b133753fafc2927dc525e900 @@ -10046,8 +10042,8 @@ trackedFiles: deleted: true docs/models/outputfunctioncallitem.mdx: id: 728d84ca3242 - last_write_checksum: sha1:509e78ec2c1013187b2aae1afd868c70410ff2e5 - pristine_git_object: bb73d7ea845bfae600ff32464c5a258a6f0fa23b + last_write_checksum: sha1:65328b1e462cf411e274a7bdbb6a0d76be2aa451 + pristine_git_object: 9e720ebeede3eb2cf0d15f1f0df5e3a30d459071 docs/models/outputfunctioncallitemstatuscompleted.md: id: 38f4a88dba7e last_write_checksum: sha1:d71da18899b11ffc260978b45e806b2076835a74 @@ -10093,10 +10089,6 @@ trackedFiles: last_write_checksum: sha1:980c0ca43e68267bd6693d7dfed8c22de3f1e31f pristine_git_object: 4583d296ed3850987194d2698f596f3bc89091e0 deleted: true - docs/models/outputfunctioncallitemtype.mdx: - id: 3c2f5e313c89 - last_write_checksum: sha1:48366d243975cc5f403cf50142d84b1588e916ff - pristine_git_object: 90cf0cd21879dff581c5c0ff1057018c24f83aef docs/models/outputfusionservertoolitem.md: id: 50cc43eb763b last_write_checksum: sha1:d31c34a592a555ba70d4dacf7a538aad8400fd1d @@ -10176,8 +10168,8 @@ trackedFiles: deleted: true docs/models/outputitems.mdx: id: 7e0bdbedd384 - last_write_checksum: sha1:a168600483a3b70eb4caf7c29e4a3e673b203c03 - pristine_git_object: 00bdf2e0a4959f9515dd1752ed9a742fefcf9fc4 + last_write_checksum: sha1:2868b0b0029913568d4ac6acac4afd668299fcbd + pristine_git_object: 819d41a4187f07437fda65e1d9a676c871011373 docs/models/outputlogs.md: id: ad270f2dd1a9 last_write_checksum: sha1:a51670ded278546d8c604b19047f946ad8bf83d1 @@ -13854,12 +13846,12 @@ trackedFiles: pristine_git_object: 410efafd6a7f50d91ccb87131fedbe0c3d47e15a jsr.json: id: 7f6ab7767282 - last_write_checksum: sha1:5dd3414f04c77ad1a9edd8eae16a0567ceb60382 - pristine_git_object: e474576ce77cae1bc9a8b8c9d194d6ee978b1922 + last_write_checksum: sha1:fe14138ecbe4f64104dbfd42ec5ec0e530556c22 + pristine_git_object: 3364a1d51e35493c42681c346f10d4ae44ef9554 package.json: id: 7030d0b2f71b - last_write_checksum: sha1:45feb91bb0f0906d2996d0fbcf69a421236b1af5 - pristine_git_object: 291d57bd6973b63d32711a4324049bdda1cd2ae6 + last_write_checksum: sha1:7918fc0d8c6396d4605350d5c53cf915c8e4b8bf + pristine_git_object: 2f282a24fb68efbb6c9f9fdb290f5578ac5213ad src/core.ts: id: f431fdbcd144 last_write_checksum: sha1:5aa66b0b6a5964f3eea7f3098c2eb3c0ee9c0131 @@ -14374,8 +14366,8 @@ trackedFiles: pristine_git_object: a187e58707bdb726ca2aff74941efe7493422d4e src/lib/config.ts: id: 320761608fb3 - last_write_checksum: sha1:0fd9b2a61f5cd228392c7d0a915e6e2647fc450b - pristine_git_object: 15d23bfabf060e0871890de21120b1d94da1e028 + last_write_checksum: sha1:b151dbcdc259897ea99b85a488c9c76aaa83a2b6 + pristine_git_object: 014e127cdbe73cd3f079dc32a60d9e99451c86ae src/lib/dlv.ts: id: b1988214835a last_write_checksum: sha1:eaac763b22717206a6199104e0403ed17a4e2711 @@ -14387,7 +14379,7 @@ trackedFiles: pristine_git_object: 49f15904923362434dfcdd02476c0487210d2f1a src/lib/env.ts: id: c52972a3b198 - last_write_checksum: sha1:40ee3101af915d716b7b23fee10865a3f2429e9e + last_write_checksum: sha1:eb803916d3a892db4507e3b38fe6201f79e16a3a pristine_git_object: 9f50c196edccf8f1433fac289d6217fc121141ac src/lib/event-streams.ts: id: 3f731f808a79 @@ -15220,8 +15212,8 @@ trackedFiles: pristine_git_object: a63c85bd87ec074c56e7a2e7b9a458b8c8414302 src/models/customtoolcallitem.ts: id: 84d0034c7065 - last_write_checksum: sha1:948edee755c4c0476016a0ca5c6a3594933b47dd - pristine_git_object: a5565a16429ef3268a84b8ac7bd63f318f0f50bf + last_write_checksum: sha1:1691bbd3e923d885996dc7b4e8d9d02df8377c40 + pristine_git_object: fc45b823990324d5383109a3b2dcad88011e90f7 src/models/customtoolcalloutputitem.ts: id: 02aed5cefca5 last_write_checksum: sha1:bbbaca425b2a11ef70a241575da4136e86f27836 @@ -15524,8 +15516,8 @@ trackedFiles: pristine_git_object: fa8a75b45e36d1d65c5208e8b2195eadbecf4cd9 src/models/functioncallitem.ts: id: 7e96e10e664b - last_write_checksum: sha1:3413282488bf857648c8daad26471a19c7dc1e18 - pristine_git_object: e6f462bfbb6931a10bbf654f8065759ad4369b5c + last_write_checksum: sha1:f24206e3b268d5c394b73475dab406db23720852 + pristine_git_object: 57065c2b9534bd74c538e41980109b1c8dcffa65 src/models/functioncalloutputitem.ts: id: 279b91cadffe last_write_checksum: sha1:a7a91bbc9f5d767a984c89926f76ca5f81a1deae @@ -15804,8 +15796,8 @@ trackedFiles: pristine_git_object: 7347fe35ab97026006a0ef54cc3f2273033774b6 src/models/inputsunion.ts: id: 3aff2165a17d - last_write_checksum: sha1:53c2e5ebea10ec18eae9c1afd7f059ae4904bb38 - pristine_git_object: 87b5dfb0b4e52054afd93d6c527d0d341136fb89 + last_write_checksum: sha1:ef0a5c19d35a520cca7467e15fc2a69c1f00ca75 + pristine_git_object: 6735d01bde3e792bd00bddfedbccb0c925c8541b src/models/inputtext.ts: id: 8d6c10a240ae last_write_checksum: sha1:47a12dc08731a718c08ed39d5c2d3648576977a9 @@ -16872,8 +16864,8 @@ trackedFiles: pristine_git_object: 0b456de74a91e798ad764c716aaccdbe2126646f src/models/outputcustomtoolcallitem.ts: id: 71596c10c79b - last_write_checksum: sha1:cdc4f30076b0128a47861b2ca3e8792874e3a929 - pristine_git_object: 90e4caca20e6c841b02be9a609ef89380ee01387 + last_write_checksum: sha1:5c08281def86821695674821e3e51062ce52e77f + pristine_git_object: 98a994039328425b0433f03cd648bae23ab32e11 src/models/outputdatetimeitem.ts: id: 0c1828e72f98 last_write_checksum: sha1:86f98e5eb24990beb4283eba0d2ff0a12c7048b8 @@ -16892,8 +16884,8 @@ trackedFiles: pristine_git_object: 8ba4848f8854032ff11c48db57e9ac7d5b1be4f4 src/models/outputfunctioncallitem.ts: id: 9c462e9ff54b - last_write_checksum: sha1:2ab1a71ccb81ddac9942463d351450cc3abbfd2f - pristine_git_object: 9f9265c5fa4332849e1854538aa4962fe8df24b5 + last_write_checksum: sha1:7517f0cd6c3eb0aae2f6c5e6d41a31be8d35abf2 + pristine_git_object: 7ceca95161626a8148c05eca0ad540640f1907c4 src/models/outputfusionservertoolitem.ts: id: 30bcfe965217 last_write_checksum: sha1:9f08b458689579fa8750eccebe104da10a05c6d9 @@ -16912,8 +16904,8 @@ trackedFiles: pristine_git_object: a13c08e43b6203a68e0a4678aa397ba2c2c7be6b src/models/outputitems.ts: id: 0d7161b3403e - last_write_checksum: sha1:ef3c24c0bf5df887116ddb76dcc76d345d359840 - pristine_git_object: 879504243635876d60f8c18e3901b9ad494f328a + last_write_checksum: sha1:caef990812c645e6a9e492cd419b1b65e8edfd0d + pristine_git_object: 98d84602ec495628e15b22cce423a8ad428ff5ec src/models/outputmcpservertoolitem.ts: id: dd859086c9c7 last_write_checksum: sha1:9d24cb7ae62bb66e44869e2339f37444f34f12f0 @@ -18008,7 +18000,7 @@ trackedFiles: pristine_git_object: 4ccb9fff749ad463884a4375063cc21884883d92 tsconfig.json: id: 61ebb9fd6e8c - last_write_checksum: sha1:f97cb62a7710b248267b5a7adf7578affa8bf3f1 + last_write_checksum: sha1:4f9c4daf3281a9be06591b2814e5bbcf98b5c803 pristine_git_object: e6cd950ad724815ee1ed48ef2e52389cbd3a9143 examples: createResponses: @@ -21270,6 +21262,3 @@ examples: "500": application/json: {"error": {"code": 409, "message": "That question is no longer waiting for an answer."}} examplesVersion: 1.0.2 -releaseNotes: | - ## Typescript SDK Changes: - * `openrouter.interns.invoke()`: **Added** diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index a4befd20f..92d66830f 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true typescript: - version: 1.3.21 + version: 1.3.22 acceptHeaderEnum: false additionalDependencies: dependencies: diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 30dc6520c..b15863097 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -8231,12 +8231,6 @@ components: sequence_number: 6 type: 'response.custom_tool_call_input.done' CustomToolCallItem: - allOf: - - $ref: '#/components/schemas/OpenAIResponseCustomToolCall' - - properties: - status: - $ref: '#/components/schemas/ToolCallStatus' - type: 'object' description: 'A call to a custom (freeform-grammar) tool created by the model — distinct from `function_call`. Used for tools like Codex CLI''s `apply_patch` whose payload is opaque text rather than JSON arguments.' example: call_id: 'call-abc123' @@ -8244,6 +8238,42 @@ components: input: "*** Begin Patch\n*** End Patch" name: 'apply_patch' type: 'custom_tool_call' + properties: + async: + description: 'True when the model called a tool declared with `async: true` and may continue its turn before the output is returned. Return the result in a later request as a `function_call_output` with this `call_id`.' + example: true + type: + - 'boolean' + - 'null' + call_id: + type: 'string' + id: + type: + - 'string' + - 'null' + input: + type: 'string' + name: + type: 'string' + namespace: + description: 'Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)' + type: + - 'string' + - 'null' + status: + anyOf: + - $ref: '#/components/schemas/ToolCallStatus' + - type: 'null' + type: + enum: + - 'custom_tool_call' + type: 'string' + required: + - 'type' + - 'call_id' + - 'name' + - 'input' + type: 'object' CustomToolCallOutputItem: allOf: - $ref: '#/components/schemas/OpenAIResponseCustomToolCallOutput' @@ -9395,12 +9425,6 @@ components: sequence_number: 6 type: 'response.function_call_arguments.done' FunctionCallItem: - allOf: - - $ref: '#/components/schemas/OpenAIResponseFunctionToolCall' - - properties: {} - required: - - 'id' - type: 'object' description: 'A function call initiated by the model' example: arguments: '{"location":"San Francisco"}' @@ -9409,6 +9433,60 @@ components: name: 'get_weather' status: 'completed' type: 'function_call' + properties: + arguments: + type: 'string' + async: + description: 'True when the model called a tool declared with `async: true` and may continue its turn before the output is returned. Return the result in a later request as a `function_call_output` with this `call_id`.' + example: true + type: + - 'boolean' + - 'null' + call_id: + type: 'string' + id: + type: + - 'string' + - 'null' + name: + type: 'string' + namespace: + description: 'Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server)' + type: + - 'string' + - 'null' + status: + anyOf: + - $ref: '#/components/schemas/ToolCallStatus' + - type: 'null' + subagent_id: + description: 'EXPERIMENTAL — subject to change without notice. String id that matches the `call_id` of the `openrouter:subagent` server tool call that spawned the subagent. Present on every `function_call` item the subagent projects; absent on ordinary function calls.' + type: + - 'string' + - 'null' + subagent_items: + description: 'EXPERIMENTAL — subject to change without notice. The subagent''s output items produced on this turn. Treat this as an opaque object; you must replay it in the request so that the subagent can continue execution of the tool with the same context. If a subagent created multiple parallel tool calls, only the first tool call will have this field. The other tool calls will only have `subagent_id`. Present only if the tool call originates from a subagent spawned by the `openrouter:subagent` server tool.' + items: + additionalProperties: {} + properties: + type: + type: 'string' + required: + - 'type' + type: 'object' + type: + - 'array' + - 'null' + type: + enum: + - 'function_call' + type: 'string' + required: + - 'type' + - 'call_id' + - 'name' + - 'arguments' + type: 'object' FunctionCallOutputItem: allOf: - $ref: '#/components/schemas/OpenAIResponseFunctionToolCallOutput' @@ -12365,8 +12443,6 @@ components: - text: 'Analyzed the problem and found the optimal solution.' type: 'summary_text' type: 'reasoning' - - $ref: '#/components/schemas/OutputFunctionCallItem' - - $ref: '#/components/schemas/OutputCustomToolCallItem' - $ref: '#/components/schemas/OutputWebSearchCallItem' - $ref: '#/components/schemas/OutputFileSearchCallItem' - $ref: '#/components/schemas/OutputImageGenerationCallItem' diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 1393870a2..d3ba65a50 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -14,7 +14,7 @@ targets: sourceRevisionDigest: sha256:cd9b32900257073321044f129e54fbaf5702941f52d85e452cb69d72631d4ae6 sourceBlobDigest: sha256:4bbc81d9271e69d142b8b227bbf222125bb8417ba1e9e1ef68c4767f2dee1a18 codeSamplesNamespace: open-router-chat-completions-api-typescript-code-samples - codeSamplesRevisionDigest: sha256:ab4f37db26cbe019d642fc6d199ea7ff6fe7c9923cf1294c66cf491dcaef01bf + codeSamplesRevisionDigest: sha256:ca35d125ba574bc09714f7585a9b24b0b19b59c4b6c50c0fc966b2264dc1a8b8 workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/docs/models/customtoolcallitem.mdx b/docs/models/customtoolcallitem.mdx index 52d689f41..575032459 100644 --- a/docs/models/customtoolcallitem.mdx +++ b/docs/models/customtoolcallitem.mdx @@ -27,5 +27,5 @@ let value: CustomToolCallItem = { | `input` | *string* | :heavy_check_mark: | N/A | | | `name` | *string* | :heavy_check_mark: | N/A | | | `namespace` | *string* | :heavy_minus_sign: | Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server) | | -| `type` | [models.CustomToolCallItemType](../models/customtoolcallitemtype.mdx) | :heavy_check_mark: | N/A | | -| `status` | [models.ToolCallStatus](../models/toolcallstatus.mdx) | :heavy_minus_sign: | N/A | completed | \ No newline at end of file +| `status` | [models.ToolCallStatus](../models/toolcallstatus.mdx) | :heavy_minus_sign: | N/A | completed | +| `type` | [models.CustomToolCallItemType](../models/customtoolcallitemtype.mdx) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/docs/models/functioncallitem.mdx b/docs/models/functioncallitem.mdx index 8df0e6a55..2428bdf8f 100644 --- a/docs/models/functioncallitem.mdx +++ b/docs/models/functioncallitem.mdx @@ -12,7 +12,6 @@ import { FunctionCallItem } from "@openrouter/sdk/models"; let value: FunctionCallItem = { arguments: "{\"location\":\"San Francisco\"}", callId: "call-abc123", - id: "call-abc123", name: "get_weather", type: "function_call", }; @@ -25,7 +24,7 @@ let value: FunctionCallItem = { | `arguments` | *string* | :heavy_check_mark: | N/A | | | `async` | *boolean* | :heavy_minus_sign: | True when the model called a tool declared with `async: true` and may continue its turn before the output is returned. Return the result in a later request as a `function_call_output` with this `call_id`. | true | | `callId` | *string* | :heavy_check_mark: | N/A | | -| `id` | *string* | :heavy_check_mark: | N/A | | +| `id` | *string* | :heavy_minus_sign: | N/A | | | `name` | *string* | :heavy_check_mark: | N/A | | | `namespace` | *string* | :heavy_minus_sign: | Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server) | | | `status` | [models.ToolCallStatus](../models/toolcallstatus.mdx) | :heavy_minus_sign: | N/A | completed | diff --git a/docs/models/inputsunion1.mdx b/docs/models/inputsunion1.mdx index 206b7035a..e99fe6800 100644 --- a/docs/models/inputsunion1.mdx +++ b/docs/models/inputsunion1.mdx @@ -41,7 +41,6 @@ const value: models.InputMessageItem = { const value: models.FunctionCallItem = { arguments: "{\"location\":\"San Francisco\"}", callId: "call-abc123", - id: "call-abc123", name: "get_weather", type: "function_call", }; @@ -112,28 +111,6 @@ const value: models.InputsReasoning = { }; ``` -### `models.OutputFunctionCallItem` - -```typescript -const value: models.OutputFunctionCallItem = { - arguments: "{\"location\":\"San Francisco\"}", - callId: "call-abc123", - name: "get_weather", - type: "function_call", -}; -``` - -### `models.OutputCustomToolCallItem` - -```typescript -const value: models.OutputCustomToolCallItem = { - callId: "call-abc123", - input: "*** Begin Patch\n*** End Patch", - name: "apply_patch", - type: "custom_tool_call", -}; -``` - ### `models.OutputWebSearchCallItem` ```typescript diff --git a/docs/models/outputcustomtoolcallitem.mdx b/docs/models/outputcustomtoolcallitem.mdx index 74fd3e29f..65f81dd2a 100644 --- a/docs/models/outputcustomtoolcallitem.mdx +++ b/docs/models/outputcustomtoolcallitem.mdx @@ -10,9 +10,9 @@ A call to a custom (freeform-grammar) tool created by the model — distinct fro import { OutputCustomToolCallItem } from "@openrouter/sdk/models"; let value: OutputCustomToolCallItem = { - callId: "call-abc123", - input: "*** Begin Patch\n*** End Patch", - name: "apply_patch", + callId: "", + input: "", + name: "", type: "custom_tool_call", }; ``` @@ -28,4 +28,4 @@ let value: OutputCustomToolCallItem = { | `name` | *string* | :heavy_check_mark: | N/A | | | `namespace` | *string* | :heavy_minus_sign: | Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server) | | | `status` | [models.OutputCustomToolCallItemStatus](../models/outputcustomtoolcallitemstatus.mdx) | :heavy_minus_sign: | N/A | | -| `type` | [models.OutputCustomToolCallItemType](../models/outputcustomtoolcallitemtype.mdx) | :heavy_check_mark: | N/A | | \ No newline at end of file +| `type` | *"custom_tool_call"* | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/docs/models/outputcustomtoolcallitemtype.mdx b/docs/models/outputcustomtoolcallitemtype.mdx deleted file mode 100644 index fd1f6247e..000000000 --- a/docs/models/outputcustomtoolcallitemtype.mdx +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: "OutputCustomToolCallItemType" ---- - -## Example Usage - -```typescript -import { OutputCustomToolCallItemType } from "@openrouter/sdk/models"; - -let value: OutputCustomToolCallItemType = "custom_tool_call"; -``` - -## Values - -```typescript -"custom_tool_call" -``` \ No newline at end of file diff --git a/docs/models/outputfunctioncallitem.mdx b/docs/models/outputfunctioncallitem.mdx index bb73d7ea8..9e720ebee 100644 --- a/docs/models/outputfunctioncallitem.mdx +++ b/docs/models/outputfunctioncallitem.mdx @@ -8,9 +8,9 @@ title: "OutputFunctionCallItem" import { OutputFunctionCallItem } from "@openrouter/sdk/models"; let value: OutputFunctionCallItem = { - arguments: "{\"location\":\"San Francisco\"}", - callId: "call-abc123", - name: "get_weather", + arguments: "", + callId: "", + name: "", type: "function_call", }; ``` @@ -26,6 +26,6 @@ let value: OutputFunctionCallItem = { | `name` | *string* | :heavy_check_mark: | N/A | | | `namespace` | *string* | :heavy_minus_sign: | Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server) | | | `status` | *models.OutputFunctionCallItemStatusUnion* | :heavy_minus_sign: | N/A | | -| `type` | [models.OutputFunctionCallItemType](../models/outputfunctioncallitemtype.mdx) | :heavy_check_mark: | N/A | | +| `type` | *"function_call"* | :heavy_check_mark: | N/A | | | `subagentId` | *string* | :heavy_minus_sign: | EXPERIMENTAL — subject to change without notice. String id that matches the `call_id` of the `openrouter:subagent` server tool call that spawned the subagent. Present on every `function_call` item the subagent projects; absent on ordinary function calls. | | | `subagentItems` | [models.OutputFunctionCallItemSubagentItem](../models/outputfunctioncallitemsubagentitem.mdx)[] | :heavy_minus_sign: | EXPERIMENTAL — subject to change without notice. The subagent's output items produced on this turn. Treat this as an opaque object; you must replay it in the request so that the subagent can continue execution of the tool with the same context. If a subagent created multiple parallel tool calls, only the first tool call will have this field. The other tool calls will only have `subagent_id`. Present only if the tool call originates from a subagent spawned by the `openrouter:subagent` server tool. | | \ No newline at end of file diff --git a/docs/models/outputfunctioncallitemtype.mdx b/docs/models/outputfunctioncallitemtype.mdx deleted file mode 100644 index 90cf0cd21..000000000 --- a/docs/models/outputfunctioncallitemtype.mdx +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: "OutputFunctionCallItemType" ---- - -## Example Usage - -```typescript -import { OutputFunctionCallItemType } from "@openrouter/sdk/models"; - -let value: OutputFunctionCallItemType = "function_call"; -``` - -## Values - -```typescript -"function_call" -``` \ No newline at end of file diff --git a/docs/models/outputitems.mdx b/docs/models/outputitems.mdx index 00bdf2e0a..819d41a41 100644 --- a/docs/models/outputitems.mdx +++ b/docs/models/outputitems.mdx @@ -48,9 +48,9 @@ const value: models.OutputComputerCallItem = { ```typescript const value: models.OutputCustomToolCallItem = { - callId: "call-abc123", - input: "*** Begin Patch\n*** End Patch", - name: "apply_patch", + callId: "", + input: "", + name: "", type: "custom_tool_call", }; ``` @@ -72,9 +72,9 @@ const value: models.OutputFileSearchCallItem = { ```typescript const value: models.OutputFunctionCallItem = { - arguments: "{\"location\":\"San Francisco\"}", - callId: "call-abc123", - name: "get_weather", + arguments: "", + callId: "", + name: "", type: "function_call", }; ``` diff --git a/jsr.json b/jsr.json index e474576ce..3364a1d51 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@openrouter/sdk", - "version": "1.3.21", + "version": "1.3.22", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package.json b/package.json index 4f4fbaac1..2f282a24f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/sdk", - "version": "1.3.21", + "version": "1.3.22", "author": "OpenRouter", "description": "The OpenRouter TypeScript SDK is a type-safe toolkit for building AI applications with access to 400+ language models through a unified API.", "keywords": [ @@ -71,19 +71,21 @@ }, "scripts": { "lint": "eslint --cache --max-warnings=0 src", - "build": "tsc", + "build": "tsc && node scripts/unbarrel-imports.js", "prepublishOnly": "npm run build", - "compile": "tsc", - "test:e2e": "vitest --run --project e2e", - "test:transit": "exit 0", - "test:watch": "vitest --watch --project unit", "typecheck": "tsc --noEmit", "typecheck:transit": "exit 0", - "postinstall": "node scripts/check-types.js || true", "prepare": "npm run build", - "test": "vitest --run --project unit" + "test:watch": "vitest --watch --project unit", + "compile": "tsc && node scripts/unbarrel-imports.js", + "postinstall": "node scripts/check-types.js || true", + "test": "vitest --run --project unit", + "test:e2e": "vitest --run --project e2e", + "test:transit": "exit 0" + }, + "peerDependencies": { + }, - "peerDependencies": {}, "devDependencies": { "@eslint/js": "^9.26.0", "@types/node": "^22.13.12", diff --git a/src/lib/config.ts b/src/lib/config.ts index bcbb3e4ed..d719d7db6 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -79,7 +79,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "1.0.0", - sdkVersion: "1.3.21", + sdkVersion: "1.3.22", genVersion: "2.914.0", - userAgent: "speakeasy-sdk/typescript 1.3.21 2.914.0 1.0.0 @openrouter/sdk", + userAgent: "speakeasy-sdk/typescript 1.3.22 2.914.0 1.0.0 @openrouter/sdk", } as const; diff --git a/src/models/customtoolcallitem.ts b/src/models/customtoolcallitem.ts index a5565a164..fc45b8239 100644 --- a/src/models/customtoolcallitem.ts +++ b/src/models/customtoolcallitem.ts @@ -23,17 +23,17 @@ export type CustomToolCallItem = { /** * True when the model called a tool declared with `async: true` and may continue its turn before the output is returned. Return the result in a later request as a `function_call_output` with this `call_id`. */ - async?: boolean | undefined; + async?: boolean | null | undefined; callId: string; - id?: string | undefined; + id?: string | null | undefined; input: string; name: string; /** * Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server) */ - namespace?: string | undefined; + namespace?: string | null | undefined; + status?: ToolCallStatus | null | undefined; type: CustomToolCallItemType; - status?: ToolCallStatus | undefined; }; /** @internal */ @@ -43,14 +43,14 @@ export const CustomToolCallItemType$outboundSchema: z.ZodEnum< /** @internal */ export type CustomToolCallItem$Outbound = { - async?: boolean | undefined; + async?: boolean | null | undefined; call_id: string; - id?: string | undefined; + id?: string | null | undefined; input: string; name: string; - namespace?: string | undefined; + namespace?: string | null | undefined; + status?: string | null | undefined; type: string; - status?: string | undefined; }; /** @internal */ @@ -58,14 +58,14 @@ export const CustomToolCallItem$outboundSchema: z.ZodType< CustomToolCallItem$Outbound, CustomToolCallItem > = z.object({ - async: z.boolean().optional(), + async: z.nullable(z.boolean()).optional(), callId: z.string(), - id: z.string().optional(), + id: z.nullable(z.string()).optional(), input: z.string(), name: z.string(), - namespace: z.string().optional(), + namespace: z.nullable(z.string()).optional(), + status: z.nullable(ToolCallStatus$outboundSchema).optional(), type: CustomToolCallItemType$outboundSchema, - status: ToolCallStatus$outboundSchema.optional(), }).transform((v) => { return remap$(v, { callId: "call_id", diff --git a/src/models/functioncallitem.ts b/src/models/functioncallitem.ts index e6f462bfb..57065c2b9 100644 --- a/src/models/functioncallitem.ts +++ b/src/models/functioncallitem.ts @@ -29,23 +29,23 @@ export type FunctionCallItem = { /** * True when the model called a tool declared with `async: true` and may continue its turn before the output is returned. Return the result in a later request as a `function_call_output` with this `call_id`. */ - async?: boolean | undefined; + async?: boolean | null | undefined; callId: string; - id: string; + id?: string | null | undefined; name: string; /** * Namespace qualifier for tools registered as part of a namespace tool group (e.g. an MCP server) */ - namespace?: string | undefined; - status?: ToolCallStatus | undefined; + namespace?: string | null | undefined; + status?: ToolCallStatus | null | undefined; /** * EXPERIMENTAL — subject to change without notice. String id that matches the `call_id` of the `openrouter:subagent` server tool call that spawned the subagent. Present on every `function_call` item the subagent projects; absent on ordinary function calls. */ - subagentId?: string | undefined; + subagentId?: string | null | undefined; /** * EXPERIMENTAL — subject to change without notice. The subagent's output items produced on this turn. Treat this as an opaque object; you must replay it in the request so that the subagent can continue execution of the tool with the same context. If a subagent created multiple parallel tool calls, only the first tool call will have this field. The other tool calls will only have `subagent_id`. Present only if the tool call originates from a subagent spawned by the `openrouter:subagent` server tool. */ - subagentItems?: Array | undefined; + subagentItems?: Array | null | undefined; type: FunctionCallItemType; }; @@ -89,14 +89,17 @@ export const FunctionCallItemType$outboundSchema: z.ZodEnum< /** @internal */ export type FunctionCallItem$Outbound = { arguments: string; - async?: boolean | undefined; + async?: boolean | null | undefined; call_id: string; - id: string; + id?: string | null | undefined; name: string; - namespace?: string | undefined; - status?: string | undefined; - subagent_id?: string | undefined; - subagent_items?: Array | undefined; + namespace?: string | null | undefined; + status?: string | null | undefined; + subagent_id?: string | null | undefined; + subagent_items?: + | Array + | null + | undefined; type: string; }; @@ -106,15 +109,15 @@ export const FunctionCallItem$outboundSchema: z.ZodType< FunctionCallItem > = z.object({ arguments: z.string(), - async: z.boolean().optional(), + async: z.nullable(z.boolean()).optional(), callId: z.string(), - id: z.string(), + id: z.nullable(z.string()).optional(), name: z.string(), - namespace: z.string().optional(), - status: ToolCallStatus$outboundSchema.optional(), - subagentId: z.string().optional(), - subagentItems: z.array( - z.lazy(() => FunctionCallItemSubagentItem$outboundSchema), + namespace: z.nullable(z.string()).optional(), + status: z.nullable(ToolCallStatus$outboundSchema).optional(), + subagentId: z.nullable(z.string()).optional(), + subagentItems: z.nullable( + z.array(z.lazy(() => FunctionCallItemSubagentItem$outboundSchema)), ).optional(), type: FunctionCallItemType$outboundSchema, }).transform((v) => { diff --git a/src/models/inputsunion.ts b/src/models/inputsunion.ts index 87b5dfb0b..6735d01bd 100644 --- a/src/models/inputsunion.ts +++ b/src/models/inputsunion.ts @@ -146,11 +146,6 @@ import { OutputComputerCallItem$Outbound, OutputComputerCallItem$outboundSchema, } from "./outputcomputercallitem.js"; -import { - OutputCustomToolCallItem, - OutputCustomToolCallItem$Outbound, - OutputCustomToolCallItem$outboundSchema, -} from "./outputcustomtoolcallitem.js"; import { OutputDatetimeItem, OutputDatetimeItem$Outbound, @@ -171,11 +166,6 @@ import { OutputFilesServerToolItem$Outbound, OutputFilesServerToolItem$outboundSchema, } from "./outputfilesservertoolitem.js"; -import { - OutputFunctionCallItem, - OutputFunctionCallItem$Outbound, - OutputFunctionCallItem$outboundSchema, -} from "./outputfunctioncallitem.js"; import { OutputFusionServerToolItem, OutputFusionServerToolItem$Outbound, @@ -404,13 +394,11 @@ export type InputsMessage = { }; export type InputsUnion1 = - | FunctionCallItem | LocalShellCallItem | McpApprovalRequestItem | McpCallItem + | FunctionCallItem | ApplyPatchCallItem - | OutputFunctionCallItem - | OutputCustomToolCallItem | OutputFileSearchCallItem | OutputComputerCallItem | OutputDatetimeItem @@ -462,13 +450,11 @@ export type InputsUnion1 = export type InputsUnion = | string | Array< - | FunctionCallItem | LocalShellCallItem | McpApprovalRequestItem | McpCallItem + | FunctionCallItem | ApplyPatchCallItem - | OutputFunctionCallItem - | OutputCustomToolCallItem | OutputFileSearchCallItem | OutputComputerCallItem | OutputDatetimeItem @@ -767,13 +753,11 @@ export function inputsMessageToJSON(inputsMessage: InputsMessage): string { /** @internal */ export type InputsUnion1$Outbound = - | FunctionCallItem$Outbound | LocalShellCallItem$Outbound | McpApprovalRequestItem$Outbound | McpCallItem$Outbound + | FunctionCallItem$Outbound | ApplyPatchCallItem$Outbound - | OutputFunctionCallItem$Outbound - | OutputCustomToolCallItem$Outbound | OutputFileSearchCallItem$Outbound | OutputComputerCallItem$Outbound | OutputDatetimeItem$Outbound @@ -824,13 +808,11 @@ export const InputsUnion1$outboundSchema: z.ZodType< InputsUnion1$Outbound, InputsUnion1 > = z.union([ - FunctionCallItem$outboundSchema, LocalShellCallItem$outboundSchema, McpApprovalRequestItem$outboundSchema, McpCallItem$outboundSchema, + FunctionCallItem$outboundSchema, ApplyPatchCallItem$outboundSchema, - OutputFunctionCallItem$outboundSchema, - OutputCustomToolCallItem$outboundSchema, OutputFileSearchCallItem$outboundSchema, OutputComputerCallItem$outboundSchema, OutputDatetimeItem$outboundSchema, @@ -885,13 +867,11 @@ export function inputsUnion1ToJSON(inputsUnion1: InputsUnion1): string { export type InputsUnion$Outbound = | string | Array< - | FunctionCallItem$Outbound | LocalShellCallItem$Outbound | McpApprovalRequestItem$Outbound | McpCallItem$Outbound + | FunctionCallItem$Outbound | ApplyPatchCallItem$Outbound - | OutputFunctionCallItem$Outbound - | OutputCustomToolCallItem$Outbound | OutputFileSearchCallItem$Outbound | OutputComputerCallItem$Outbound | OutputDatetimeItem$Outbound @@ -946,13 +926,11 @@ export const InputsUnion$outboundSchema: z.ZodType< z.string(), z.array( z.union([ - FunctionCallItem$outboundSchema, LocalShellCallItem$outboundSchema, McpApprovalRequestItem$outboundSchema, McpCallItem$outboundSchema, + FunctionCallItem$outboundSchema, ApplyPatchCallItem$outboundSchema, - OutputFunctionCallItem$outboundSchema, - OutputCustomToolCallItem$outboundSchema, OutputFileSearchCallItem$outboundSchema, OutputComputerCallItem$outboundSchema, OutputDatetimeItem$outboundSchema, diff --git a/src/models/outputcustomtoolcallitem.ts b/src/models/outputcustomtoolcallitem.ts index 90e4caca2..98a994039 100644 --- a/src/models/outputcustomtoolcallitem.ts +++ b/src/models/outputcustomtoolcallitem.ts @@ -7,7 +7,7 @@ import * as z from "zod/v4"; import { remap as remap$ } from "../lib/primitives.js"; import { safeParse } from "../lib/schemas.js"; import * as openEnums from "../types/enums.js"; -import { ClosedEnum, OpenEnum } from "../types/enums.js"; +import { OpenEnum } from "../types/enums.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; @@ -20,13 +20,6 @@ export type OutputCustomToolCallItemStatus = OpenEnum< typeof OutputCustomToolCallItemStatus >; -export const OutputCustomToolCallItemType = { - CustomToolCall: "custom_tool_call", -} as const; -export type OutputCustomToolCallItemType = ClosedEnum< - typeof OutputCustomToolCallItemType ->; - /** * A call to a custom (freeform-grammar) tool created by the model — distinct from `function_call`. Used for tools like Codex CLI's `apply_patch` whose payload is opaque text rather than JSON arguments. */ @@ -44,7 +37,7 @@ export type OutputCustomToolCallItem = { */ namespace?: string | undefined; status?: OutputCustomToolCallItemStatus | undefined; - type: OutputCustomToolCallItemType; + type: "custom_tool_call"; }; /** @internal */ @@ -52,20 +45,6 @@ export const OutputCustomToolCallItemStatus$inboundSchema: z.ZodType< OutputCustomToolCallItemStatus, unknown > = openEnums.inboundSchema(OutputCustomToolCallItemStatus); -/** @internal */ -export const OutputCustomToolCallItemStatus$outboundSchema: z.ZodType< - string, - OutputCustomToolCallItemStatus -> = openEnums.outboundSchema(OutputCustomToolCallItemStatus); - -/** @internal */ -export const OutputCustomToolCallItemType$inboundSchema: z.ZodEnum< - typeof OutputCustomToolCallItemType -> = z.enum(OutputCustomToolCallItemType); -/** @internal */ -export const OutputCustomToolCallItemType$outboundSchema: z.ZodEnum< - typeof OutputCustomToolCallItemType -> = OutputCustomToolCallItemType$inboundSchema; /** @internal */ export const OutputCustomToolCallItem$inboundSchema: z.ZodType< @@ -79,50 +58,13 @@ export const OutputCustomToolCallItem$inboundSchema: z.ZodType< name: z.string(), namespace: z.string().optional(), status: OutputCustomToolCallItemStatus$inboundSchema.optional(), - type: OutputCustomToolCallItemType$inboundSchema, + type: z.literal("custom_tool_call"), }).transform((v) => { return remap$(v, { "call_id": "callId", }); }); -/** @internal */ -export type OutputCustomToolCallItem$Outbound = { - async?: boolean | undefined; - call_id: string; - id?: string | undefined; - input: string; - name: string; - namespace?: string | undefined; - status?: string | undefined; - type: string; -}; - -/** @internal */ -export const OutputCustomToolCallItem$outboundSchema: z.ZodType< - OutputCustomToolCallItem$Outbound, - OutputCustomToolCallItem -> = z.object({ - async: z.boolean().optional(), - callId: z.string(), - id: z.string().optional(), - input: z.string(), - name: z.string(), - namespace: z.string().optional(), - status: OutputCustomToolCallItemStatus$outboundSchema.optional(), - type: OutputCustomToolCallItemType$outboundSchema, -}).transform((v) => { - return remap$(v, { - callId: "call_id", - }); -}); -export function outputCustomToolCallItemToJSON( - outputCustomToolCallItem: OutputCustomToolCallItem, -): string { - return JSON.stringify( - OutputCustomToolCallItem$outboundSchema.parse(outputCustomToolCallItem), - ); -} export function outputCustomToolCallItemFromJSON( jsonString: string, ): SafeParseResult { diff --git a/src/models/outputfunctioncallitem.ts b/src/models/outputfunctioncallitem.ts index 9f9265c5f..7ceca9516 100644 --- a/src/models/outputfunctioncallitem.ts +++ b/src/models/outputfunctioncallitem.ts @@ -39,13 +39,6 @@ export type OutputFunctionCallItemStatusUnion = | OutputFunctionCallItemStatusIncomplete | OutputFunctionCallItemStatusInProgress; -export const OutputFunctionCallItemType = { - FunctionCall: "function_call", -} as const; -export type OutputFunctionCallItemType = ClosedEnum< - typeof OutputFunctionCallItemType ->; - export type OutputFunctionCallItemSubagentItem = { type: string; additionalProperties?: { [k: string]: any } | undefined; @@ -69,7 +62,7 @@ export type OutputFunctionCallItem = { | OutputFunctionCallItemStatusIncomplete | OutputFunctionCallItemStatusInProgress | undefined; - type: OutputFunctionCallItemType; + type: "function_call"; /** * EXPERIMENTAL — subject to change without notice. String id that matches the `call_id` of the `openrouter:subagent` server tool call that spawned the subagent. Present on every `function_call` item the subagent projects; absent on ordinary function calls. */ @@ -84,28 +77,16 @@ export type OutputFunctionCallItem = { export const OutputFunctionCallItemStatusInProgress$inboundSchema: z.ZodEnum< typeof OutputFunctionCallItemStatusInProgress > = z.enum(OutputFunctionCallItemStatusInProgress); -/** @internal */ -export const OutputFunctionCallItemStatusInProgress$outboundSchema: z.ZodEnum< - typeof OutputFunctionCallItemStatusInProgress -> = OutputFunctionCallItemStatusInProgress$inboundSchema; /** @internal */ export const OutputFunctionCallItemStatusIncomplete$inboundSchema: z.ZodEnum< typeof OutputFunctionCallItemStatusIncomplete > = z.enum(OutputFunctionCallItemStatusIncomplete); -/** @internal */ -export const OutputFunctionCallItemStatusIncomplete$outboundSchema: z.ZodEnum< - typeof OutputFunctionCallItemStatusIncomplete -> = OutputFunctionCallItemStatusIncomplete$inboundSchema; /** @internal */ export const OutputFunctionCallItemStatusCompleted$inboundSchema: z.ZodEnum< typeof OutputFunctionCallItemStatusCompleted > = z.enum(OutputFunctionCallItemStatusCompleted); -/** @internal */ -export const OutputFunctionCallItemStatusCompleted$outboundSchema: z.ZodEnum< - typeof OutputFunctionCallItemStatusCompleted -> = OutputFunctionCallItemStatusCompleted$inboundSchema; /** @internal */ export const OutputFunctionCallItemStatusUnion$inboundSchema: z.ZodType< @@ -116,31 +97,7 @@ export const OutputFunctionCallItemStatusUnion$inboundSchema: z.ZodType< OutputFunctionCallItemStatusIncomplete$inboundSchema, OutputFunctionCallItemStatusInProgress$inboundSchema, ]); -/** @internal */ -export type OutputFunctionCallItemStatusUnion$Outbound = - | string - | string - | string; - -/** @internal */ -export const OutputFunctionCallItemStatusUnion$outboundSchema: z.ZodType< - OutputFunctionCallItemStatusUnion$Outbound, - OutputFunctionCallItemStatusUnion -> = z.union([ - OutputFunctionCallItemStatusCompleted$outboundSchema, - OutputFunctionCallItemStatusIncomplete$outboundSchema, - OutputFunctionCallItemStatusInProgress$outboundSchema, -]); -export function outputFunctionCallItemStatusUnionToJSON( - outputFunctionCallItemStatusUnion: OutputFunctionCallItemStatusUnion, -): string { - return JSON.stringify( - OutputFunctionCallItemStatusUnion$outboundSchema.parse( - outputFunctionCallItemStatusUnion, - ), - ); -} export function outputFunctionCallItemStatusUnionFromJSON( jsonString: string, ): SafeParseResult { @@ -151,15 +108,6 @@ export function outputFunctionCallItemStatusUnionFromJSON( ); } -/** @internal */ -export const OutputFunctionCallItemType$inboundSchema: z.ZodEnum< - typeof OutputFunctionCallItemType -> = z.enum(OutputFunctionCallItemType); -/** @internal */ -export const OutputFunctionCallItemType$outboundSchema: z.ZodEnum< - typeof OutputFunctionCallItemType -> = OutputFunctionCallItemType$inboundSchema; - /** @internal */ export const OutputFunctionCallItemSubagentItem$inboundSchema: z.ZodType< OutputFunctionCallItemSubagentItem, @@ -171,37 +119,7 @@ export const OutputFunctionCallItemSubagentItem$inboundSchema: z.ZodType< "additionalProperties", true, ); -/** @internal */ -export type OutputFunctionCallItemSubagentItem$Outbound = { - type: string; - [additionalProperties: string]: unknown; -}; -/** @internal */ -export const OutputFunctionCallItemSubagentItem$outboundSchema: z.ZodType< - OutputFunctionCallItemSubagentItem$Outbound, - OutputFunctionCallItemSubagentItem -> = z.object({ - type: z.string(), - additionalProperties: z.record(z.string(), z.any()).optional(), -}).transform((v) => { - return { - ...v.additionalProperties, - ...remap$(v, { - additionalProperties: null, - }), - }; -}); - -export function outputFunctionCallItemSubagentItemToJSON( - outputFunctionCallItemSubagentItem: OutputFunctionCallItemSubagentItem, -): string { - return JSON.stringify( - OutputFunctionCallItemSubagentItem$outboundSchema.parse( - outputFunctionCallItemSubagentItem, - ), - ); -} export function outputFunctionCallItemSubagentItemFromJSON( jsonString: string, ): SafeParseResult { @@ -229,7 +147,7 @@ export const OutputFunctionCallItem$inboundSchema: z.ZodType< OutputFunctionCallItemStatusIncomplete$inboundSchema, OutputFunctionCallItemStatusInProgress$inboundSchema, ]).optional(), - type: OutputFunctionCallItemType$inboundSchema, + type: z.literal("function_call"), subagent_id: z.string().optional(), subagent_items: z.array( z.lazy(() => OutputFunctionCallItemSubagentItem$inboundSchema), @@ -241,58 +159,7 @@ export const OutputFunctionCallItem$inboundSchema: z.ZodType< "subagent_items": "subagentItems", }); }); -/** @internal */ -export type OutputFunctionCallItem$Outbound = { - arguments: string; - async?: boolean | undefined; - call_id: string; - id?: string | undefined; - name: string; - namespace?: string | undefined; - status?: string | string | string | undefined; - type: string; - subagent_id?: string | undefined; - subagent_items?: - | Array - | undefined; -}; -/** @internal */ -export const OutputFunctionCallItem$outboundSchema: z.ZodType< - OutputFunctionCallItem$Outbound, - OutputFunctionCallItem -> = z.object({ - arguments: z.string(), - async: z.boolean().optional(), - callId: z.string(), - id: z.string().optional(), - name: z.string(), - namespace: z.string().optional(), - status: z.union([ - OutputFunctionCallItemStatusCompleted$outboundSchema, - OutputFunctionCallItemStatusIncomplete$outboundSchema, - OutputFunctionCallItemStatusInProgress$outboundSchema, - ]).optional(), - type: OutputFunctionCallItemType$outboundSchema, - subagentId: z.string().optional(), - subagentItems: z.array( - z.lazy(() => OutputFunctionCallItemSubagentItem$outboundSchema), - ).optional(), -}).transform((v) => { - return remap$(v, { - callId: "call_id", - subagentId: "subagent_id", - subagentItems: "subagent_items", - }); -}); - -export function outputFunctionCallItemToJSON( - outputFunctionCallItem: OutputFunctionCallItem, -): string { - return JSON.stringify( - OutputFunctionCallItem$outboundSchema.parse(outputFunctionCallItem), - ); -} export function outputFunctionCallItemFromJSON( jsonString: string, ): SafeParseResult { diff --git a/src/models/outputitems.ts b/src/models/outputitems.ts index 879504243..98d84602e 100644 --- a/src/models/outputitems.ts +++ b/src/models/outputitems.ts @@ -141,9 +141,9 @@ export type OutputItems = | OutputApplyPatchCallItem | (OutputCodeInterpreterCallItem & { type: "code_interpreter_call" }) | (OutputComputerCallItem & { type: "computer_call" }) - | (OutputCustomToolCallItem & { type: "custom_tool_call" }) + | OutputCustomToolCallItem | (OutputFileSearchCallItem & { type: "file_search_call" }) - | (OutputFunctionCallItem & { type: "function_call" }) + | OutputFunctionCallItem | (OutputImageGenerationCallItem & { type: "image_generation_call" }) | OutputMessageItem | (OutputAdvisorServerToolItem & { type: "openrouter:advisor" }) @@ -187,15 +187,11 @@ export const OutputItems$inboundSchema: z.ZodType = computer_call: OutputComputerCallItem$inboundSchema.and( z.object({ type: z.literal("computer_call") }), ), - custom_tool_call: OutputCustomToolCallItem$inboundSchema.and( - z.object({ type: z.literal("custom_tool_call") }), - ), + custom_tool_call: OutputCustomToolCallItem$inboundSchema, file_search_call: OutputFileSearchCallItem$inboundSchema.and( z.object({ type: z.literal("file_search_call") }), ), - function_call: OutputFunctionCallItem$inboundSchema.and( - z.object({ type: z.literal("function_call") }), - ), + function_call: OutputFunctionCallItem$inboundSchema, image_generation_call: OutputImageGenerationCallItem$inboundSchema.and( z.object({ type: z.literal("image_generation_call") }), ),