From eca52e1fe61a6b15e67f5434720ece48a84beaba Mon Sep 17 00:00:00 2001 From: speakeasybot Date: Wed, 23 Sep 2026 17:25:50 +0000 Subject: [PATCH 1/2] ## Typescript SDK Changes: * `openrouter.interns.invoke()`: **Added** --- .speakeasy/gen.lock | 102 +++++-- .speakeasy/gen.yaml | 2 +- .speakeasy/out.openapi.yaml | 253 ++++++++++++++++++ .speakeasy/workflow.lock | 10 +- RELEASES.md | 12 +- docs/models/interninvokeacceptedresponse.mdx | 23 ++ .../interninvokeacceptedresponsestatus.mdx | 21 ++ docs/models/interninvokerequest.mdx | 23 ++ .../models/operations/invokeinternglobals.mdx | 19 ++ .../models/operations/invokeinternrequest.mdx | 27 ++ .../operations/invokeinternresponse.mdx | 24 ++ docs/sdks/interns/README.mdx | 97 ++++++- jsr.json | 2 +- package.json | 10 +- src/funcs/internsInvoke.ts | 225 ++++++++++++++++ src/lib/config.ts | 4 +- src/models/index.ts | 2 + src/models/interninvokeacceptedresponse.ts | 69 +++++ src/models/interninvokerequest.ts | 48 ++++ src/models/operations/index.ts | 1 + src/models/operations/invokeintern.ts | 123 +++++++++ src/sdk/interns.ts | 24 ++ 22 files changed, 1084 insertions(+), 37 deletions(-) create mode 100644 docs/models/interninvokeacceptedresponse.mdx create mode 100644 docs/models/interninvokeacceptedresponsestatus.mdx create mode 100644 docs/models/interninvokerequest.mdx create mode 100644 docs/models/operations/invokeinternglobals.mdx create mode 100644 docs/models/operations/invokeinternrequest.mdx create mode 100644 docs/models/operations/invokeinternresponse.mdx create mode 100644 src/funcs/internsInvoke.ts create mode 100644 src/models/interninvokeacceptedresponse.ts create mode 100644 src/models/interninvokerequest.ts create mode 100644 src/models/operations/invokeintern.ts diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index cbf1bd43e..d7f14448e 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,19 @@ lockVersion: "" id: "" management: - docChecksum: 3abb6b4a8a62e373458c8480286873c4 + docChecksum: ac4bf44164b7dbc4e2d8b0cffd3312b3 docVersion: 1.0.0 speakeasyVersion: 1.787.0 generationVersion: 2.914.0 - releaseVersion: 1.3.20 - configChecksum: 40a8b3da22d107d0af11140cbb8b6e94 + releaseVersion: 1.3.21 + configChecksum: 85aaf67f952a9a8f043515c87fc3fbdb repoURL: https://github.com/OpenRouterTeam/typescript-sdk.git installationURL: https://github.com/OpenRouterTeam/typescript-sdk published: true persistentEdits: - generation_id: faebb21f-2c13-4b03-857c-1e54743bd461 - pristine_commit_hash: c12903491ba2f26a946f365e182438ff40636c7a - pristine_tree_hash: f988b051193b11b412eb26eafd43b201e9f163ae + generation_id: 42b8b673-c6d7-47a5-9111-cc94801f2ca7 + pristine_commit_hash: d041654eead3d75b5553b558354a037355d2e91d + pristine_tree_hash: 091edaf01887c1b5247803aadb6c38010a9699dd features: typescript: acceptHeaders: 2.81.2 @@ -5584,6 +5584,18 @@ trackedFiles: id: 3a5d92e71b59 last_write_checksum: sha1:2a8e44e3d6a9ee7485107a7872ff26ff16b00735 pristine_git_object: 2b3c42b383091a4fd9423c0f07b47e9de6168549 + docs/models/interninvokeacceptedresponse.mdx: + id: 10c7b75df88b + last_write_checksum: sha1:4f960296e7e4a87734933b96ee3ff4232949142e + pristine_git_object: d3a3fd46d36be4e0859e5631acd4fad40f075fdf + docs/models/interninvokeacceptedresponsestatus.mdx: + id: 1e28c33362ff + last_write_checksum: sha1:5b22c26eab36d5d4cfcac9a331dd258a42d822e6 + pristine_git_object: acefdeb83731684846db89e3f973c1df083a4fea + docs/models/interninvokerequest.mdx: + id: f9e6c8e1a954 + last_write_checksum: sha1:8bbadb5cea499b6b011a09cf7955b157922f0e26 + pristine_git_object: 0de7268e6be13b566abb2c578afa6a7dce4f2a8f docs/models/internlifecycleerrorerror.mdx: id: 03984489ae4f last_write_checksum: sha1:4500621f32eb63bb62efc51ecba5c7792239028f @@ -8652,6 +8664,18 @@ trackedFiles: id: e1966b690efd last_write_checksum: sha1:75b21f671e2bdeb55b6badd248f27a3d9a3431d6 pristine_git_object: e7222d1f3e732241030df7ab5612b086ab2bda9a + docs/models/operations/invokeinternglobals.mdx: + id: c57a588de5a8 + last_write_checksum: sha1:e75a921aa67ef0e23b8a3e179cdd8d37acce563f + pristine_git_object: 7b553ff420d9495d8a6284143b33ce07f2caca7d + docs/models/operations/invokeinternrequest.mdx: + id: 65b96c7175b1 + last_write_checksum: sha1:d05d4b77c3e4fec1f9bb1e5816d6a92a47fcd61d + pristine_git_object: fe091ea3ed10a5d4f3e08bc0e726827dd1049607 + docs/models/operations/invokeinternresponse.mdx: + id: f7ebc16e2abe + last_write_checksum: sha1:488cf9bc4bc4e9c94c03ce7f494e57177930e4a0 + pristine_git_object: d1a52c5db6e745ff7aaf53f9cbd56ffe27a24b81 docs/models/operations/keepmembers.mdx: id: 591598fdced8 last_write_checksum: sha1:19946e98301ceb2e71252f3ea74798df803c9548 @@ -13702,8 +13726,8 @@ trackedFiles: pristine_git_object: 15b7b4c80d50dd3aa0f7adc3ab4d9fb03a8efaa7 docs/sdks/interns/README.mdx: id: 2f8a053ffe78 - last_write_checksum: sha1:fec76210874b6a4e5444fb640d3ab59a2a7a20c9 - pristine_git_object: 3b6412fe44b650c8f6a9eaaffabb09b3f903c117 + last_write_checksum: sha1:db186712738ff21bce4636376524f6b80173f474 + pristine_git_object: 90132f7c5f8f9c6e4397b87f789177b658e22abb docs/sdks/models/README.mdx: id: 58f1ca464e0b last_write_checksum: sha1:dbae6f74244ab3e9fe38e075ab67f926f33ef87d @@ -13830,12 +13854,12 @@ trackedFiles: pristine_git_object: 410efafd6a7f50d91ccb87131fedbe0c3d47e15a jsr.json: id: 7f6ab7767282 - last_write_checksum: sha1:79d0d5679ace3c2a69c006e47fb16312a2a9f868 - pristine_git_object: 0b0287c37e8abbcb075c889513b28ef27cc47fbb + last_write_checksum: sha1:5dd3414f04c77ad1a9edd8eae16a0567ceb60382 + pristine_git_object: e474576ce77cae1bc9a8b8c9d194d6ee978b1922 package.json: id: 7030d0b2f71b - last_write_checksum: sha1:e8b0f189f25feb69b003ddfacb96ef1b678d0c6f - pristine_git_object: 2019515972da47f7ded2bb6e0aa23fef76c515ec + last_write_checksum: sha1:45feb91bb0f0906d2996d0fbcf69a421236b1af5 + pristine_git_object: 291d57bd6973b63d32711a4324049bdda1cd2ae6 src/core.ts: id: f431fdbcd144 last_write_checksum: sha1:5aa66b0b6a5964f3eea7f3098c2eb3c0ee9c0131 @@ -14072,6 +14096,10 @@ trackedFiles: id: 484b04c35876 last_write_checksum: sha1:95616ff94e6ef4fe3248885d25aa71a6b01f5186 pristine_git_object: 84985cfee5e79c648083370d42e07563d54f8fd2 + src/funcs/internsInvoke.ts: + id: d0be40cd89cf + last_write_checksum: sha1:e7e5db94633812351a50eca92befa7aa032e49a7 + pristine_git_object: 60325197f9d904257d8a5cfb86c1ebd1a10586d1 src/funcs/internsListInterns.ts: id: eceaf7dad653 last_write_checksum: sha1:e5dd060b7ff96038d687efc0a5495064efc84621 @@ -14346,8 +14374,8 @@ trackedFiles: pristine_git_object: a187e58707bdb726ca2aff74941efe7493422d4e src/lib/config.ts: id: 320761608fb3 - last_write_checksum: sha1:5de7b45cbce771b51fb7fc3f4116f149a80ff43d - pristine_git_object: 37bb5edfe7bd7a8325c3edf4b392d8f10c11ad4a + last_write_checksum: sha1:0fd9b2a61f5cd228392c7d0a915e6e2647fc450b + pristine_git_object: 15d23bfabf060e0871890de21120b1d94da1e028 src/lib/dlv.ts: id: b1988214835a last_write_checksum: sha1:eaac763b22717206a6199104e0403ed17a4e2711 @@ -15748,8 +15776,8 @@ trackedFiles: pristine_git_object: 7abdfe096d3adff317db6837dc689c69db92e127 src/models/index.ts: id: f93644b0f37e - last_write_checksum: sha1:fea8cd4d18c3a7a0a4b2db05aecd071dd99bb872 - pristine_git_object: af02736c24ab33900e0db2c2e9c951eb8debea40 + last_write_checksum: sha1:52a17b11012c46f7b50c4fb2c8b45367d44cb000 + pristine_git_object: 02e618be29c1573677a5952fe6a802167d3139ef src/models/inputaudio.ts: id: 9bdc14c7565f last_write_checksum: sha1:2f8dc4c1d6a9c2927d9eb186e0ecedf7b81838e6 @@ -15894,6 +15922,14 @@ trackedFiles: id: 6d3909ea9433 last_write_checksum: sha1:9a8118f0a654181dbd8dd1f1e798a50ace167520 pristine_git_object: ae6f841af0a49f34f93eded5da09e1db819b5d2f + src/models/interninvokeacceptedresponse.ts: + id: 4684252ebfd9 + last_write_checksum: sha1:7a648fb23e8bfb9ffccc70155bae637aa272d695 + pristine_git_object: d825f3099aa4c09d0c8bb75948a91a8e100cfb84 + src/models/interninvokerequest.ts: + id: 087aea86ca9d + last_write_checksum: sha1:d469f9e02cd51d5f8263ab1a8a45153af9cc9725 + pristine_git_object: ffbb6be7d210cc403cd9faac1d76c16a70b2ba2d src/models/internlifecycleerror.ts: id: 9d7cc6ac0062 last_write_checksum: sha1:c9a538da773832d841820900d5764b1b37db3e40 @@ -16596,8 +16632,12 @@ trackedFiles: pristine_git_object: a052ed42bd123e79be1f05dc823c808f8c32b383 src/models/operations/index.ts: id: 0d9ffaf774d2 - last_write_checksum: sha1:b52bbe7ff22d625b02bf92fbcf5aa834df8768b0 - pristine_git_object: 811736c154678b258d041233c1e70c50ae70cc0c + last_write_checksum: sha1:c91a1975c171f7df63bab96a23125b4b5e8c34ac + pristine_git_object: 9e8e47be027ac42abeff9ab031ba7112cbee1c58 + src/models/operations/invokeintern.ts: + id: f2b19fbd8a96 + last_write_checksum: sha1:55f0d7c3a2020919fbf3e92c2c7524a75a412504 + pristine_git_object: d2d1c887f8636c4c4cd7f3917b47349459774da1 src/models/operations/list.ts: id: ce11386ad30f last_write_checksum: sha1:357fb735d77e377eba5fec5742d7a4dca6747f47 @@ -17856,8 +17896,8 @@ trackedFiles: pristine_git_object: 5c82fe389f888827f98aa52788b850ef43422e07 src/sdk/interns.ts: id: fc3b4e6c5008 - last_write_checksum: sha1:d2cd2f18a800456031d8ccf4b49f94bcc13c3d03 - pristine_git_object: 55631fab051499b9c009aed40cf8187451d72d2b + last_write_checksum: sha1:a15427708866b525621ca8aa78df7f1f99a58206 + pristine_git_object: 305808e5f4c9c0d3fd25c31d70b1ab015641b9ac src/sdk/models.ts: id: 8c761ab180fd last_write_checksum: sha1:0c5e5cefb7079fc69eb11ef157af6d2cb5255933 @@ -21211,5 +21251,25 @@ examples: application/json: {"error": {"code": 524, "message": "Request timed out. Please try again later."}} "529": application/json: {"error": {"code": 529, "message": "Provider returned error"}} + invokeIntern: + speakeasy-default-invoke-intern: + parameters: + path: + internId: "a11e0000-0000-4000-8000-000000000005" + requestBody: + application/json: {"input": "New support ticket 48213. Case token: ct_9f2c. Investigate and reply."} + responses: + "202": + application/json: {"session_id": "b51a0e21-368b-4780-a220-14655bf28c55", "status": "started"} + "400": + application/json: {"error": {"code": 409, "message": "That question is no longer waiting for an answer."}} + "409": + application/json: {"error": {"code": 409, "message": "That question is no longer waiting for an answer."}} + "503": + application/json: {"error": {"code": 409, "message": "That question is no longer waiting for an answer."}} + "500": + application/json: {"error": {"code": 409, "message": "That question is no longer waiting for an answer."}} examplesVersion: 1.0.2 -releaseNotes: "## Typescript SDK Changes:\n* `openrouter.presets.createPresetsMessages()`: \n * `request.messagesRequest.tools[].union(class (0)).strict` **Added**\n" +releaseNotes: | + ## Typescript SDK Changes: + * `openrouter.interns.invoke()`: **Added** diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index ada4c0519..48fba800a 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -37,7 +37,7 @@ generation: documentation: mintlify preApplyUnionDiscriminators: true typescript: - version: 1.3.20 + version: 1.3.21 acceptHeaderEnum: false additionalDependencies: dependencies: diff --git a/.speakeasy/out.openapi.yaml b/.speakeasy/out.openapi.yaml index 0f9b48cd3..30dc6520c 100644 --- a/.speakeasy/out.openapi.yaml +++ b/.speakeasy/out.openapi.yaml @@ -13168,6 +13168,48 @@ components: - 'content' - 'role' type: 'object' + InternInvokeAcceptedResponse: + description: 'The intern admitted the prompt. The run continues on the intern.' + example: + session_id: 'b51a0e21-368b-4780-a220-14655bf28c55' + status: 'started' + properties: + session_id: + description: 'The session the run belongs to. Send it back to continue the conversation.' + example: 'b51a0e21-368b-4780-a220-14655bf28c55' + type: 'string' + status: + description: '`started` when a new run began. `steered` when the session already had a run going and the prompt was delivered into it instead.' + enum: + - 'started' + - 'steered' + example: 'started' + type: 'string' + x-speakeasy-unknown-values: allow + required: + - 'session_id' + - 'status' + type: 'object' + InternInvokeRequest: + description: 'A prompt to run on the intern without holding a connection open.' + example: + input: 'New support ticket 48213. Case token: ct_9f2c. Investigate and reply.' + properties: + input: + description: 'The prompt for the run, at most 32000 characters.' + example: 'New support ticket 48213. Case token: ct_9f2c. Investigate and reply.' + maxLength: 32000 + minLength: 1 + type: 'string' + session_id: + description: 'The session to run in. Send the `session_id` from an earlier `202` to continue that conversation, for example to hand the intern a decision on a case it is working. Omit it to start a new session. Only a `session_id` this endpoint issued to the same caller on the same intern is accepted; any other is refused with `404`.' + example: 'b51a0e21-368b-4780-a220-14655bf28c55' + maxLength: 256 + minLength: 1 + type: 'string' + required: + - 'input' + type: 'object' InternLifecycleError: additionalProperties: false description: 'Intern lifecycle request failure.' @@ -37674,6 +37716,217 @@ paths: - $ref: "#/components/parameters/AppIdentifier" - $ref: "#/components/parameters/AppDisplayName" - $ref: "#/components/parameters/AppCategories" + /interns/{internId}/invoke: + post: + description: "Starts a run on one of your interns and answers `202` with the `session_id` as soon as the intern accepts it. The run keeps going on the intern after the response. Nothing about its progress comes back on this request; the intern reports through its own tools, such as Slack.\n\nSend the same `session_id` later to continue the conversation, for example to hand the intern a decision on work it started. If that session already has a run going, the prompt is delivered into it and the status is `steered`. A `session_id` is accepted only from the caller it was issued to, on the same intern; any other, including sessions started from Slack or the chat endpoint, is refused with `404`.\n\nRuns started here self-drive: the intern consents to its own tool approvals, and a question it asks is answered by its own fallback. A run ends when the intern finishes it or after its execution deadline (1 hour by default).\n\nAvailable to interns programme members. Callers outside the programme receive `404` for every path under `/api/v1/interns`." + operationId: 'invokeIntern' + parameters: + - description: 'The intern to run.' + in: 'path' + name: 'internId' + required: true + schema: + description: 'The intern to run.' + example: 'a11e0000-0000-4000-8000-000000000005' + type: 'string' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/InternInvokeRequest' + required: true + responses: + '202': + content: + application/json: + schema: + $ref: '#/components/schemas/InternInvokeAcceptedResponse' + description: 'The intern accepted the prompt. The run continues on the intern.' + '400': + content: + application/json: + example: + error: + code: 400 + message: 'Invalid invoke request (input: Too small: expected string to have >=1 characters).' + metadata: + reason: 'bad_request' + retryable: false + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'The body is not a valid request (`bad_request`).' + '401': + content: + application/json: + example: + error: + code: 401 + message: 'Invalid or missing API key' + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'No valid API key.' + '403': + content: + application/json: + example: + error: + code: 403 + message: 'This API key''s creator is no longer a member of the organization. Ask an organization admin to reassign the key to an active member.' + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'The key belongs to a member who has left the organization and holds no grant.' + '404': + content: + application/json: + example: + error: + code: 404 + message: 'Intern not found' + metadata: + reason: 'not_found' + retryable: false + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'The caller is outside the interns programme, the intern does not exist for this key, or the `session_id` was not issued to this caller on this intern (`not_found`).' + '408': + content: + application/json: + example: + error: + code: 408 + message: 'Operation timed out after 60s. Please try again later.' + metadata: + reason: 'timeout' + retryable: true + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'The request exceeded the route''s own deadline before the handler answered (`timeout`).' + '409': + content: + application/json: + example: + error: + code: 409 + message: 'This intern is not running.' + metadata: + reason: 'intern_not_ready' + retryable: true + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'The intern is not running or its runtime is too old to keep a run going without a connection (`intern_not_ready`), or the session already has a run that did not take the prompt (`busy`). A `busy` refusal carries `Retry-After`.' + headers: + Retry-After: + description: 'Seconds to wait before retrying this request. Present only on a `busy` refusal.' + required: false + schema: + description: 'Seconds to wait before retrying this request. Present only on a `busy` refusal.' + example: '5' + type: 'string' + '413': + content: + application/json: + example: + error: + code: 413 + message: 'Request body exceeds 1048576 bytes' + metadata: + reason: 'payload_too_large' + retryable: false + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'The body exceeds 1 MiB (`payload_too_large`).' + '429': + content: + application/json: + example: + error: + code: 429 + message: 'Too many intern turns. Please wait a moment.' + metadata: + reason: 'rate_limited' + retryable: true + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'Too many turns for the user or organization this key acts as (`rate_limited`). It carries `Retry-After`.' + headers: + Retry-After: + description: 'Seconds to wait before retrying this request.' + required: true + schema: + description: 'Seconds to wait before retrying this request.' + example: '60' + type: 'string' + '500': + content: + application/json: + example: + error: + code: 500 + message: 'Could not look up the intern' + metadata: + reason: 'intern_unreachable' + retryable: true + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'The intern could not be looked up, or authenticating the key failed.' + '502': + content: + application/json: + example: + error: + code: 502 + message: 'The intern could not be reached.' + metadata: + reason: 'intern_unreachable' + retryable: true + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'The intern could not be reached, rejected the request, or refused the turn before it started.' + '503': + content: + application/json: + example: + error: + code: 503 + message: 'The intern cannot hold another run open across a question right now. Retry later.' + metadata: + reason: 'busy' + retryable: true + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'The intern cannot take another run right now (`busy`). It reports `retryable: true` and carries `Retry-After`.' + headers: + Retry-After: + description: 'Seconds to wait before retrying this request.' + required: true + schema: + description: 'Seconds to wait before retrying this request.' + example: '5' + type: 'string' + '504': + content: + application/json: + example: + error: + code: 504 + message: 'The intern did not answer in time.' + metadata: + reason: 'timeout' + retryable: true + schema: + $ref: '#/components/schemas/InternChatErrorResponse' + description: 'The intern did not accept the turn in time (`timeout`).' + security: + - apiKey: [] + summary: 'Start an intern run without waiting for it' + tags: + - 'Interns' + x-speakeasy-group: 'interns' + x-speakeasy-name-override: 'invoke' + parameters: + - $ref: "#/components/parameters/AppIdentifier" + - $ref: "#/components/parameters/AppDisplayName" + - $ref: "#/components/parameters/AppCategories" /interns/{internId}/provision: post: description: 'Starts the first boot, or resumes an intern after suspension. This operation takes no request body. A body carrying any field is refused with 400 rather than ignored. The API key selects the caller, workspace and visible interns. There is no default workspace fallback. Requests on regional hostnames such as `eu.openrouter.ai` are refused. [API key](/docs/api-reference/authentication) required.' diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index bf7e2b7b1..1393870a2 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.787.0 sources: OpenRouter API: sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:76adf3d72717b6eccb2f42037375a142c9196eaae6b2ad1fe7e6a8f5666abb8a - sourceBlobDigest: sha256:42cc11920dee5c95800c41ff3a44d26326cf9059cde328d00dec5befd0d17ed3 + sourceRevisionDigest: sha256:cd9b32900257073321044f129e54fbaf5702941f52d85e452cb69d72631d4ae6 + sourceBlobDigest: sha256:4bbc81d9271e69d142b8b227bbf222125bb8417ba1e9e1ef68c4767f2dee1a18 tags: - latest - 1.0.0 @@ -11,10 +11,10 @@ targets: openrouter: source: OpenRouter API sourceNamespace: open-router-chat-completions-api - sourceRevisionDigest: sha256:76adf3d72717b6eccb2f42037375a142c9196eaae6b2ad1fe7e6a8f5666abb8a - sourceBlobDigest: sha256:42cc11920dee5c95800c41ff3a44d26326cf9059cde328d00dec5befd0d17ed3 + sourceRevisionDigest: sha256:cd9b32900257073321044f129e54fbaf5702941f52d85e452cb69d72631d4ae6 + sourceBlobDigest: sha256:4bbc81d9271e69d142b8b227bbf222125bb8417ba1e9e1ef68c4767f2dee1a18 codeSamplesNamespace: open-router-chat-completions-api-typescript-code-samples - codeSamplesRevisionDigest: sha256:980c7747e820f1dd8b9973b5d2812c401eab5cc315eca8a7811b719aa750f4bc + codeSamplesRevisionDigest: sha256:ab4f37db26cbe019d642fc6d199ea7ff6fe7c9923cf1294c66cf491dcaef01bf workflow: workflowVersion: 1.0.0 speakeasyVersion: 1.787.0 diff --git a/RELEASES.md b/RELEASES.md index d1e7b3655..6b4f573ff 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -3996,4 +3996,14 @@ Based on: ### Generated - [typescript v1.3.20] . ### Releases -- [NPM v1.3.20] https://www.npmjs.com/package/@openrouter/sdk/v/1.3.20 - . \ No newline at end of file +- [NPM v1.3.20] https://www.npmjs.com/package/@openrouter/sdk/v/1.3.20 - . + +## 2026-09-23 17:23:37 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.787.0 (2.914.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v1.3.21] . +### Releases +- [NPM v1.3.21] https://www.npmjs.com/package/@openrouter/sdk/v/1.3.21 - . \ No newline at end of file diff --git a/docs/models/interninvokeacceptedresponse.mdx b/docs/models/interninvokeacceptedresponse.mdx new file mode 100644 index 000000000..d3a3fd46d --- /dev/null +++ b/docs/models/interninvokeacceptedresponse.mdx @@ -0,0 +1,23 @@ +--- +title: "InternInvokeAcceptedResponse" +--- + +The intern admitted the prompt. The run continues on the intern. + +## Example Usage + +```typescript +import { InternInvokeAcceptedResponse } from "@openrouter/sdk/models"; + +let value: InternInvokeAcceptedResponse = { + sessionId: "b51a0e21-368b-4780-a220-14655bf28c55", + status: "started", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | +| `sessionId` | *string* | :heavy_check_mark: | The session the run belongs to. Send it back to continue the conversation. | b51a0e21-368b-4780-a220-14655bf28c55 | +| `status` | [models.InternInvokeAcceptedResponseStatus](../models/interninvokeacceptedresponsestatus.mdx) | :heavy_check_mark: | `started` when a new run began. `steered` when the session already had a run going and the prompt was delivered into it instead. | started | \ No newline at end of file diff --git a/docs/models/interninvokeacceptedresponsestatus.mdx b/docs/models/interninvokeacceptedresponsestatus.mdx new file mode 100644 index 000000000..acefdeb83 --- /dev/null +++ b/docs/models/interninvokeacceptedresponsestatus.mdx @@ -0,0 +1,21 @@ +--- +title: "InternInvokeAcceptedResponseStatus" +--- + +`started` when a new run began. `steered` when the session already had a run going and the prompt was delivered into it instead. + +## Example Usage + +```typescript +import { InternInvokeAcceptedResponseStatus } from "@openrouter/sdk/models"; + +let value: InternInvokeAcceptedResponseStatus = "started"; + +// Open enum: unrecognized values are captured as Unrecognized +``` + +## Values + +```typescript +"started" | "steered" | Unrecognized +``` \ No newline at end of file diff --git a/docs/models/interninvokerequest.mdx b/docs/models/interninvokerequest.mdx new file mode 100644 index 000000000..0de7268e6 --- /dev/null +++ b/docs/models/interninvokerequest.mdx @@ -0,0 +1,23 @@ +--- +title: "InternInvokeRequest" +--- + +A prompt to run on the intern without holding a connection open. + +## Example Usage + +```typescript +import { InternInvokeRequest } from "@openrouter/sdk/models"; + +let value: InternInvokeRequest = { + input: + "New support ticket 48213. Case token: ct_9f2c. Investigate and reply.", +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `input` | *string* | :heavy_check_mark: | The prompt for the run, at most 32000 characters. | New support ticket 48213. Case token: ct_9f2c. Investigate and reply. | +| `sessionId` | *string* | :heavy_minus_sign: | The session to run in. Send the `session_id` from an earlier `202` to continue that conversation, for example to hand the intern a decision on a case it is working. Omit it to start a new session. Only a `session_id` this endpoint issued to the same caller on the same intern is accepted; any other is refused with `404`. | b51a0e21-368b-4780-a220-14655bf28c55 | \ No newline at end of file diff --git a/docs/models/operations/invokeinternglobals.mdx b/docs/models/operations/invokeinternglobals.mdx new file mode 100644 index 000000000..7b553ff42 --- /dev/null +++ b/docs/models/operations/invokeinternglobals.mdx @@ -0,0 +1,19 @@ +--- +title: "InvokeInternGlobals" +--- + +## Example Usage + +```typescript +import { InvokeInternGlobals } from "@openrouter/sdk/models/operations"; + +let value: InvokeInternGlobals = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| +| `appTitle` | *string* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| +| `appCategories` | *string* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| \ No newline at end of file diff --git a/docs/models/operations/invokeinternrequest.mdx b/docs/models/operations/invokeinternrequest.mdx new file mode 100644 index 000000000..fe091ea3e --- /dev/null +++ b/docs/models/operations/invokeinternrequest.mdx @@ -0,0 +1,27 @@ +--- +title: "InvokeInternRequest" +--- + +## Example Usage + +```typescript +import { InvokeInternRequest } from "@openrouter/sdk/models/operations"; + +let value: InvokeInternRequest = { + internId: "a11e0000-0000-4000-8000-000000000005", + internInvokeRequest: { + input: + "New support ticket 48213. Case token: ct_9f2c. Investigate and reply.", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| `httpReferer` | *string* | :heavy_minus_sign: | The app identifier should be your app's URL and is used as the primary identifier for rankings.
This is used to track API usage per application.
| | +| `appTitle` | *string* | :heavy_minus_sign: | The app display name allows you to customize how your app appears in OpenRouter's dashboard.
| | +| `appCategories` | *string* | :heavy_minus_sign: | Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings.
| | +| `internId` | *string* | :heavy_check_mark: | The intern to run. | a11e0000-0000-4000-8000-000000000005 | +| `internInvokeRequest` | [models.InternInvokeRequest](../../models/interninvokerequest.mdx) | :heavy_check_mark: | N/A | \{
"input": "New support ticket 48213. Case token: ct_9f2c. Investigate and reply."
} | \ No newline at end of file diff --git a/docs/models/operations/invokeinternresponse.mdx b/docs/models/operations/invokeinternresponse.mdx new file mode 100644 index 000000000..d1a52c5db --- /dev/null +++ b/docs/models/operations/invokeinternresponse.mdx @@ -0,0 +1,24 @@ +--- +title: "InvokeInternResponse" +--- + +## Example Usage + +```typescript +import { InvokeInternResponse } from "@openrouter/sdk/models/operations"; + +let value: InvokeInternResponse = { + headers: {}, + result: { + sessionId: "b51a0e21-368b-4780-a220-14655bf28c55", + status: "started", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `headers` | Record\ | :heavy_check_mark: | N/A | | +| `result` | [models.InternInvokeAcceptedResponse](../../models/interninvokeacceptedresponse.mdx) | :heavy_check_mark: | N/A | \{
"session_id": "b51a0e21-368b-4780-a220-14655bf28c55",
"status": "started"
} | \ No newline at end of file diff --git a/docs/sdks/interns/README.mdx b/docs/sdks/interns/README.mdx index 3b6412fe4..90132f7c5 100644 --- a/docs/sdks/interns/README.mdx +++ b/docs/sdks/interns/README.mdx @@ -17,6 +17,7 @@ Create, inspect, update, provision, suspend and delete OpenRouter interns throug * [provisionIntern](#provisionintern) - Provision an intern * [suspendIntern](#suspendintern) - Suspend an intern * [chat](#chat) - Stream a chat completion with an intern +* [invoke](#invoke) - Start an intern run without waiting for it ## listInterns @@ -712,4 +713,98 @@ run(); | errors.InternChatErrorResponse | 409, 429 | application/json | | errors.InternChatErrorResponse | 503 | application/json | | errors.InternChatErrorResponse | 502, 504 | application/json | -| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | \ No newline at end of file +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | + +## invoke + +Starts a run on one of your interns and answers `202` with the `session_id` as soon as the intern accepts it. The run keeps going on the intern after the response. Nothing about its progress comes back on this request; the intern reports through its own tools, such as Slack. + +Send the same `session_id` later to continue the conversation, for example to hand the intern a decision on work it started. If that session already has a run going, the prompt is delivered into it and the status is `steered`. A `session_id` is accepted only from the caller it was issued to, on the same intern; any other, including sessions started from Slack or the chat endpoint, is refused with `404`. + +Runs started here self-drive: the intern consents to its own tool approvals, and a question it asks is answered by its own fallback. A run ends when the intern finishes it or after its execution deadline (1 hour by default). + +Available to interns programme members. Callers outside the programme receive `404` for every path under `/api/v1/interns`. + +### Example Usage + +```typescript +import { OpenRouter } from "@openrouter/sdk"; + +const openRouter = new OpenRouter({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const result = await openRouter.interns.invoke({ + internId: "a11e0000-0000-4000-8000-000000000005", + internInvokeRequest: { + input: "New support ticket 48213. Case token: ct_9f2c. Investigate and reply.", + }, + }); + + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { OpenRouterCore } from "@openrouter/sdk/core.js"; +import { internsInvoke } from "@openrouter/sdk/funcs/internsInvoke.js"; + +// Use `OpenRouterCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const openRouter = new OpenRouterCore({ + httpReferer: "", + appTitle: "", + appCategories: "", + apiKey: process.env["OPENROUTER_API_KEY"] ?? "", +}); + +async function run() { + const res = await internsInvoke(openRouter, { + internId: "a11e0000-0000-4000-8000-000000000005", + internInvokeRequest: { + input: "New support ticket 48213. Case token: ct_9f2c. Investigate and reply.", + }, + }); + if (res.ok) { + const { value: result } = res; + console.log(result); + } else { + console.log("internsInvoke failed:", res.error); + } +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [operations.InvokeInternRequest](../../models/operations/invokeinternrequest.mdx) | :heavy_check_mark: | The request object to use for the request. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.mdx) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[operations.InvokeInternResponse](../../models/operations/invokeinternresponse.mdx)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------------------ | ------------------------------ | ------------------------------ | +| errors.InternChatErrorResponse | 400, 401, 403, 404, 408, 413 | application/json | +| errors.InternChatErrorResponse | 409, 429 | application/json | +| errors.InternChatErrorResponse | 503 | application/json | +| errors.InternChatErrorResponse | 500, 502, 504 | application/json | +| errors.OpenRouterDefaultError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/jsr.json b/jsr.json index 0b0287c37..e474576ce 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@openrouter/sdk", - "version": "1.3.20", + "version": "1.3.21", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package.json b/package.json index ca4a05e4d..4f4fbaac1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openrouter/sdk", - "version": "1.3.20", + "version": "1.3.21", "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": [ @@ -74,14 +74,14 @@ "build": "tsc", "prepublishOnly": "npm run build", "compile": "tsc", - "postinstall": "node scripts/check-types.js || true", "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:transit": "exit 0", - "typecheck:transit": "exit 0" + "test": "vitest --run --project unit" }, "peerDependencies": {}, "devDependencies": { diff --git a/src/funcs/internsInvoke.ts b/src/funcs/internsInvoke.ts new file mode 100644 index 000000000..60325197f --- /dev/null +++ b/src/funcs/internsInvoke.ts @@ -0,0 +1,225 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: d0be40cd89cf + */ + +import { OpenRouterCore } from "../core.js"; +import { encodeJSON, encodeSimple } from "../lib/encodings.js"; +import { matchStatusCode } from "../lib/http.js"; +import * as M from "../lib/matchers.js"; +import { compactMap } from "../lib/primitives.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { OpenRouterError } from "../models/errors/openroutererror.js"; +import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; +import { Result } from "../types/fp.js"; + +/** + * Start an intern run without waiting for it + * + * @remarks + * Starts a run on one of your interns and answers `202` with the `session_id` as soon as the intern accepts it. The run keeps going on the intern after the response. Nothing about its progress comes back on this request; the intern reports through its own tools, such as Slack. + * + * Send the same `session_id` later to continue the conversation, for example to hand the intern a decision on work it started. If that session already has a run going, the prompt is delivered into it and the status is `steered`. A `session_id` is accepted only from the caller it was issued to, on the same intern; any other, including sessions started from Slack or the chat endpoint, is refused with `404`. + * + * Runs started here self-drive: the intern consents to its own tool approvals, and a question it asks is answered by its own fallback. A run ends when the intern finishes it or after its execution deadline (1 hour by default). + * + * Available to interns programme members. Callers outside the programme receive `404` for every path under `/api/v1/interns`. + * + * If set, this operation will use {@link Security.apiKey} from the global security. + */ +export function internsInvoke( + client: OpenRouterCore, + request: operations.InvokeInternRequest, + options?: RequestOptions, +): APIPromise< + Result< + operations.InvokeInternResponse, + | errors.InternChatErrorResponse + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: OpenRouterCore, + request: operations.InvokeInternRequest, + options?: RequestOptions, +): Promise< + [ + Result< + operations.InvokeInternResponse, + | errors.InternChatErrorResponse + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >, + APICall, + ] +> { + const parsed = safeParse( + request, + (value) => operations.InvokeInternRequest$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return [parsed, { status: "invalid" }]; + } + const payload = parsed.value; + const body = encodeJSON("body", payload.InternInvokeRequest, { + explode: true, + }); + + const pathParams = { + internId: encodeSimple("internId", payload.internId, { + explode: false, + charEncoding: "percent", + }), + }; + const path = pathToFunc("/interns/{internId}/invoke")(pathParams); + + const headers = new Headers(compactMap({ + "Content-Type": "application/json", + Accept: "application/json", + "HTTP-Referer": encodeSimple( + "HTTP-Referer", + payload["HTTP-Referer"] ?? client._options.httpReferer, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Categories": encodeSimple( + "X-OpenRouter-Categories", + payload.appCategories ?? client._options.appCategories, + { explode: false, charEncoding: "none" }, + ), + "X-OpenRouter-Title": encodeSimple( + "X-OpenRouter-Title", + payload.appTitle ?? client._options.appTitle, + { explode: false, charEncoding: "none" }, + ), + })); + + const secConfig = await extractSecurity(client._options.apiKey); + const securityInput = secConfig == null ? {} : { apiKey: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput, [0]); + + const context = { + options: client._options, + baseURL: options?.serverURL ?? client._baseURL ?? "", + operationID: "invokeIntern", + oAuth2Scopes: null, + + resolvedSecurity: requestSecurity, + + securitySource: client._options.apiKey, + retryConfig: options?.retries + || client._options.retryConfig + || { + strategy: "backoff", + backoff: { + initialInterval: 500, + maxInterval: 60000, + exponent: 1.5, + maxElapsedTime: 3600000, + }, + retryConnectionErrors: true, + } + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["5XX"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + baseURL: options?.serverURL, + path: path, + headers: headers, + body: body, + userAgent: client._options.userAgent, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return [requestRes, { status: "invalid" }]; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + isErrorStatusCode: (statusCode: number) => + matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]), + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return [doResult, { status: "request-error", request: req }]; + } + const response = doResult.value; + + const responseFields = { + HttpMeta: { Response: response, Request: req }, + }; + + const [result] = await M.match< + operations.InvokeInternResponse, + | errors.InternChatErrorResponse + | OpenRouterError + | ResponseValidationError + | ConnectionError + | RequestAbortedError + | RequestTimeoutError + | InvalidRequestError + | UnexpectedClientError + | SDKValidationError + >( + M.json(202, operations.InvokeInternResponse$inboundSchema, { + key: "Result", + }), + M.jsonErr( + [400, 401, 403, 404, 408, 413], + errors.InternChatErrorResponse$inboundSchema, + ), + M.jsonErr([409, 429], errors.InternChatErrorResponse$inboundSchema, { + hdrs: true, + }), + M.jsonErr(503, errors.InternChatErrorResponse$inboundSchema, { + hdrs: true, + }), + M.jsonErr([500, 502, 504], errors.InternChatErrorResponse$inboundSchema), + M.fail("4XX"), + M.fail("5XX"), + )(response, req, { extraFields: responseFields }); + if (!result.ok) { + return [result, { status: "complete", request: req, response }]; + } + + return [result, { status: "complete", request: req, response }]; +} diff --git a/src/lib/config.ts b/src/lib/config.ts index 61a7a40f8..bcbb3e4ed 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.20", + sdkVersion: "1.3.21", genVersion: "2.914.0", - userAgent: "speakeasy-sdk/typescript 1.3.20 2.914.0 1.0.0 @openrouter/sdk", + userAgent: "speakeasy-sdk/typescript 1.3.21 2.914.0 1.0.0 @openrouter/sdk", } as const; diff --git a/src/models/index.ts b/src/models/index.ts index af02736c2..02e618be2 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -347,6 +347,8 @@ export * from "./internchattoolcallfunction.js"; export * from "./internchattoolmessage.js"; export * from "./internchatusage.js"; export * from "./internchatusermessage.js"; +export * from "./interninvokeacceptedresponse.js"; +export * from "./interninvokerequest.js"; export * from "./internlifecycleerror.js"; export * from "./internlistresponse.js"; export * from "./itemreferenceitem.js"; diff --git a/src/models/interninvokeacceptedresponse.ts b/src/models/interninvokeacceptedresponse.ts new file mode 100644 index 000000000..d825f3099 --- /dev/null +++ b/src/models/interninvokeacceptedresponse.ts @@ -0,0 +1,69 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 4684252ebfd9 + */ + +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 { OpenEnum } from "../types/enums.js"; +import { Result as SafeParseResult } from "../types/fp.js"; +import { SDKValidationError } from "./errors/sdkvalidationerror.js"; + +/** + * `started` when a new run began. `steered` when the session already had a run going and the prompt was delivered into it instead. + */ +export const InternInvokeAcceptedResponseStatus = { + Started: "started", + Steered: "steered", +} as const; +/** + * `started` when a new run began. `steered` when the session already had a run going and the prompt was delivered into it instead. + */ +export type InternInvokeAcceptedResponseStatus = OpenEnum< + typeof InternInvokeAcceptedResponseStatus +>; + +/** + * The intern admitted the prompt. The run continues on the intern. + */ +export type InternInvokeAcceptedResponse = { + /** + * The session the run belongs to. Send it back to continue the conversation. + */ + sessionId: string; + /** + * `started` when a new run began. `steered` when the session already had a run going and the prompt was delivered into it instead. + */ + status: InternInvokeAcceptedResponseStatus; +}; + +/** @internal */ +export const InternInvokeAcceptedResponseStatus$inboundSchema: z.ZodType< + InternInvokeAcceptedResponseStatus, + unknown +> = openEnums.inboundSchema(InternInvokeAcceptedResponseStatus); + +/** @internal */ +export const InternInvokeAcceptedResponse$inboundSchema: z.ZodType< + InternInvokeAcceptedResponse, + unknown +> = z.object({ + session_id: z.string(), + status: InternInvokeAcceptedResponseStatus$inboundSchema, +}).transform((v) => { + return remap$(v, { + "session_id": "sessionId", + }); +}); + +export function internInvokeAcceptedResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InternInvokeAcceptedResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InternInvokeAcceptedResponse' from JSON`, + ); +} diff --git a/src/models/interninvokerequest.ts b/src/models/interninvokerequest.ts new file mode 100644 index 000000000..ffbb6be7d --- /dev/null +++ b/src/models/interninvokerequest.ts @@ -0,0 +1,48 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: 087aea86ca9d + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../lib/primitives.js"; + +/** + * A prompt to run on the intern without holding a connection open. + */ +export type InternInvokeRequest = { + /** + * The prompt for the run, at most 32000 characters. + */ + input: string; + /** + * The session to run in. Send the `session_id` from an earlier `202` to continue that conversation, for example to hand the intern a decision on a case it is working. Omit it to start a new session. Only a `session_id` this endpoint issued to the same caller on the same intern is accepted; any other is refused with `404`. + */ + sessionId?: string | undefined; +}; + +/** @internal */ +export type InternInvokeRequest$Outbound = { + input: string; + session_id?: string | undefined; +}; + +/** @internal */ +export const InternInvokeRequest$outboundSchema: z.ZodType< + InternInvokeRequest$Outbound, + InternInvokeRequest +> = z.object({ + input: z.string(), + sessionId: z.string().optional(), +}).transform((v) => { + return remap$(v, { + sessionId: "session_id", + }); +}); + +export function internInvokeRequestToJSON( + internInvokeRequest: InternInvokeRequest, +): string { + return JSON.stringify( + InternInvokeRequest$outboundSchema.parse(internInvokeRequest), + ); +} diff --git a/src/models/operations/index.ts b/src/models/operations/index.ts index 811736c15..9e8e47be0 100644 --- a/src/models/operations/index.ts +++ b/src/models/operations/index.ts @@ -74,6 +74,7 @@ export * from "./getuseractivity.js"; export * from "./getvideos.js"; export * from "./getworkspace.js"; export * from "./getworkspacebudget.js"; +export * from "./invokeintern.js"; export * from "./list.js"; export * from "./listbyokkeys.js"; export * from "./listcontainerfiles.js"; diff --git a/src/models/operations/invokeintern.ts b/src/models/operations/invokeintern.ts new file mode 100644 index 000000000..d2d1c887f --- /dev/null +++ b/src/models/operations/invokeintern.ts @@ -0,0 +1,123 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + * @generated-id: f2b19fbd8a96 + */ + +import * as z from "zod/v4"; +import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; +import * as models from "../index.js"; + +export type InvokeInternGlobals = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; +}; + +export type InvokeInternRequest = { + /** + * The app identifier should be your app's URL and is used as the primary identifier for rankings. + * + * @remarks + * This is used to track API usage per application. + */ + httpReferer?: string | undefined; + /** + * The app display name allows you to customize how your app appears in OpenRouter's dashboard. + * + * @remarks + */ + appTitle?: string | undefined; + /** + * Comma-separated list of app categories (e.g. "cli-agent,cloud-agent"). Used for marketplace rankings. + * + * @remarks + */ + appCategories?: string | undefined; + /** + * The intern to run. + */ + internId: string; + internInvokeRequest: models.InternInvokeRequest; +}; + +export type InvokeInternResponse = { + headers: { [k: string]: Array }; + result: models.InternInvokeAcceptedResponse; +}; + +/** @internal */ +export type InvokeInternRequest$Outbound = { + "HTTP-Referer"?: string | undefined; + appTitle?: string | undefined; + appCategories?: string | undefined; + internId: string; + InternInvokeRequest: models.InternInvokeRequest$Outbound; +}; + +/** @internal */ +export const InvokeInternRequest$outboundSchema: z.ZodType< + InvokeInternRequest$Outbound, + InvokeInternRequest +> = z.object({ + httpReferer: z.string().optional(), + appTitle: z.string().optional(), + appCategories: z.string().optional(), + internId: z.string(), + internInvokeRequest: models.InternInvokeRequest$outboundSchema, +}).transform((v) => { + return remap$(v, { + httpReferer: "HTTP-Referer", + internInvokeRequest: "InternInvokeRequest", + }); +}); + +export function invokeInternRequestToJSON( + invokeInternRequest: InvokeInternRequest, +): string { + return JSON.stringify( + InvokeInternRequest$outboundSchema.parse(invokeInternRequest), + ); +} + +/** @internal */ +export const InvokeInternResponse$inboundSchema: z.ZodType< + InvokeInternResponse, + unknown +> = z.object({ + Headers: z.record(z.string(), z.array(z.string())).default({}), + Result: models.InternInvokeAcceptedResponse$inboundSchema, +}).transform((v) => { + return remap$(v, { + "Headers": "headers", + "Result": "result", + }); +}); + +export function invokeInternResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InvokeInternResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InvokeInternResponse' from JSON`, + ); +} diff --git a/src/sdk/interns.ts b/src/sdk/interns.ts index 55631fab0..305808e5f 100644 --- a/src/sdk/interns.ts +++ b/src/sdk/interns.ts @@ -7,6 +7,7 @@ import { internsChat } from "../funcs/internsChat.js"; import { internsCreateIntern } from "../funcs/internsCreateIntern.js"; import { internsDeleteIntern } from "../funcs/internsDeleteIntern.js"; import { internsGetIntern } from "../funcs/internsGetIntern.js"; +import { internsInvoke } from "../funcs/internsInvoke.js"; import { internsListInterns } from "../funcs/internsListInterns.js"; import { internsProvisionIntern } from "../funcs/internsProvisionIntern.js"; import { internsSuspendIntern } from "../funcs/internsSuspendIntern.js"; @@ -180,4 +181,27 @@ export class Interns extends ClientSDK { options, )); } + + /** + * Start an intern run without waiting for it + * + * @remarks + * Starts a run on one of your interns and answers `202` with the `session_id` as soon as the intern accepts it. The run keeps going on the intern after the response. Nothing about its progress comes back on this request; the intern reports through its own tools, such as Slack. + * + * Send the same `session_id` later to continue the conversation, for example to hand the intern a decision on work it started. If that session already has a run going, the prompt is delivered into it and the status is `steered`. A `session_id` is accepted only from the caller it was issued to, on the same intern; any other, including sessions started from Slack or the chat endpoint, is refused with `404`. + * + * Runs started here self-drive: the intern consents to its own tool approvals, and a question it asks is answered by its own fallback. A run ends when the intern finishes it or after its execution deadline (1 hour by default). + * + * Available to interns programme members. Callers outside the programme receive `404` for every path under `/api/v1/interns`. + */ + async invoke( + request: operations.InvokeInternRequest, + options?: RequestOptions, + ): Promise { + return unwrapAsync(internsInvoke( + this, + request, + options, + )); + } } From 383be8b2f8d78f634bcef35595cd67e145c86e4b Mon Sep 17 00:00:00 2001 From: "speakeasy-github[bot]" <128539517+speakeasy-github[bot]@users.noreply.github.com> Date: Wed, 23 Sep 2026 17:25:59 +0000 Subject: [PATCH 2/2] empty commit to trigger [run-tests] workflow