@inkeep/agents-manage-mcp 0.39.5 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +5 -0
- package/README.md +38 -139
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +27 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8462 -6978
- package/dist/index.js.map +1 -1
- package/manifest.json +61 -6
- package/package.json +12 -12
- package/scripts/fetch-openapi.mjs +22 -40
- package/scripts/generate.mjs +33 -66
- package/src/core.ts +3 -1
- package/src/funcs/agentArtifactComponentRelationsAssociateArtifactComponentWithAgent.ts +94 -78
- package/src/funcs/agentArtifactComponentRelationsCheckArtifactComponentAgentAssociation.ts +98 -81
- package/src/funcs/agentArtifactComponentRelationsGetAgentsUsingArtifactComponent.ts +94 -78
- package/src/funcs/agentArtifactComponentRelationsGetArtifactComponentsForAgent.ts +91 -76
- package/src/funcs/agentArtifactComponentRelationsRemoveArtifactComponentFromAgent.ts +96 -80
- package/src/funcs/agentDataComponentRelationsAssociateDataComponentWithAgent.ts +92 -77
- package/src/funcs/agentDataComponentRelationsCheckDataComponentAgentAssociation.ts +95 -79
- package/src/funcs/agentDataComponentRelationsGetAgentsUsingDataComponent.ts +91 -76
- package/src/funcs/agentDataComponentRelationsGetDataComponentsForAgent.ts +91 -76
- package/src/funcs/agentDataComponentRelationsRemoveDataComponentFromAgent.ts +93 -78
- package/src/funcs/agentGetFullAgentDefinition.ts +89 -74
- package/src/funcs/agentGetRelatedAgentInfos.ts +91 -76
- package/src/funcs/agentsCreateAgent.ts +88 -73
- package/src/funcs/agentsDeleteAgent.ts +74 -58
- package/src/funcs/agentsGetAgent.ts +90 -73
- package/src/funcs/agentsListAgents.ts +89 -74
- package/src/funcs/agentsUpdateAgent.ts +92 -75
- package/src/funcs/apiKeysCreateAPIKey.ts +88 -73
- package/src/funcs/apiKeysDeleteAPIKey.ts +74 -58
- package/src/funcs/apiKeysGetAPIKeyById.ts +90 -73
- package/src/funcs/apiKeysListAPIKeys.ts +90 -75
- package/src/funcs/apiKeysUpdateAPIKey.ts +92 -75
- package/src/funcs/artifactComponentCreateArtifactComponent.ts +89 -74
- package/src/funcs/artifactComponentDeleteArtifactComponent.ts +74 -60
- package/src/funcs/artifactComponentGetArtifactComponentById.ts +89 -74
- package/src/funcs/artifactComponentListArtifactComponents.ts +90 -75
- package/src/funcs/artifactComponentUpdateArtifactComponent.ts +91 -76
- package/src/funcs/cliGetApiCliMe.ts +144 -0
- package/src/funcs/contextConfigCreateContextConfig.ts +91 -76
- package/src/funcs/contextConfigDeleteContextConfig.ts +87 -73
- package/src/funcs/contextConfigGetContextConfigById.ts +91 -76
- package/src/funcs/contextConfigListContextConfigs.ts +92 -77
- package/src/funcs/contextConfigUpdateContextConfig.ts +93 -78
- package/src/funcs/conversationsGetConversation.ts +92 -77
- package/src/funcs/credentialCreateCredential.ts +90 -73
- package/src/funcs/credentialDeleteCredential.ts +73 -59
- package/src/funcs/credentialGetCredentialById.ts +89 -74
- package/src/funcs/credentialListCredentials.ts +91 -74
- package/src/funcs/credentialStoreCreateCredentialInStore.ts +91 -76
- package/src/funcs/credentialStoreListCredentialStores.ts +87 -72
- package/src/funcs/credentialUpdateCredential.ts +91 -76
- package/src/funcs/dataComponentCreateDataComponent.ts +90 -73
- package/src/funcs/dataComponentDeleteDataComponent.ts +74 -60
- package/src/funcs/dataComponentGetDataComponentById.ts +89 -74
- package/src/funcs/dataComponentListDataComponents.ts +91 -74
- package/src/funcs/dataComponentUpdateDataComponent.ts +91 -76
- package/src/funcs/externalAgentsCreateExternalAgent.ts +90 -73
- package/src/funcs/externalAgentsDeleteExternalAgent.ts +74 -60
- package/src/funcs/externalAgentsGetExternalAgentById.ts +89 -74
- package/src/funcs/externalAgentsListExternalAgents.ts +91 -74
- package/src/funcs/externalAgentsUpdateExternalAgent.ts +91 -76
- package/src/funcs/fullAgentCreateFullAgent.ts +89 -74
- package/src/funcs/fullAgentDeleteFullAgent.ts +86 -70
- package/src/funcs/fullAgentGetFullAgent.ts +90 -73
- package/src/funcs/fullAgentUpdateFullAgent.ts +92 -75
- package/src/funcs/fullProjectCreateFullProject.ts +87 -72
- package/src/funcs/fullProjectDeleteFullProject.ts +82 -68
- package/src/funcs/fullProjectGetFullProject.ts +86 -71
- package/src/funcs/fullProjectUpdateFullProject.ts +88 -73
- package/src/funcs/functionToolsCreateFunctionTool.ts +91 -76
- package/src/funcs/functionToolsDeleteFunctionTool.ts +87 -73
- package/src/funcs/functionToolsGetFunctionTool.ts +91 -76
- package/src/funcs/functionToolsListFunctionTools.ts +92 -77
- package/src/funcs/functionToolsUpdateFunctionTool.ts +93 -78
- package/src/funcs/functionsCreateFunction.ts +90 -73
- package/src/funcs/functionsDeleteFunction.ts +86 -70
- package/src/funcs/functionsGetFunction.ts +90 -73
- package/src/funcs/functionsListFunctions.ts +91 -74
- package/src/funcs/functionsUpdateFunction.ts +92 -75
- package/src/funcs/health.ts +61 -45
- package/src/funcs/invitationsGetApiInvitationsPending.ts +60 -52
- package/src/funcs/mcpCatalogListMCPCatalog.ts +88 -71
- package/src/funcs/oAuthInitiateOauthLoginPublic.ts +74 -62
- package/src/funcs/oAuthOauthCallback.ts +73 -61
- package/src/funcs/playgroundCreatePlaygroundToken.ts +75 -62
- package/src/funcs/projectsCreateProject.ts +87 -72
- package/src/funcs/projectsDeleteProject.ts +86 -71
- package/src/funcs/projectsGetProjectById.ts +86 -71
- package/src/funcs/projectsListProjects.ts +87 -72
- package/src/funcs/projectsUpdateProject.ts +88 -73
- package/src/funcs/subAgentCreateSubagent.ts +91 -76
- package/src/funcs/subAgentDeleteSubagent.ts +77 -61
- package/src/funcs/subAgentExternalAgentRelationsCreateSubAgentExternalAgentRelation.ts +95 -79
- package/src/funcs/subAgentExternalAgentRelationsDeleteSubAgentExternalAgentRelation.ts +80 -65
- package/src/funcs/subAgentExternalAgentRelationsGetSubAgentExternalAgentRelationById.ts +95 -79
- package/src/funcs/subAgentExternalAgentRelationsListSubAgentExternalAgentRelations.ts +96 -80
- package/src/funcs/subAgentExternalAgentRelationsUpdateSubAgentExternalAgentRelation.ts +97 -81
- package/src/funcs/subAgentGetSubagentById.ts +91 -76
- package/src/funcs/subAgentListSubagents.ts +92 -77
- package/src/funcs/subAgentRelationsCreateSubAgentRelation.ts +91 -76
- package/src/funcs/subAgentRelationsDeleteSubAgentRelation.ts +76 -62
- package/src/funcs/subAgentRelationsGetSubAgentRelationById.ts +91 -76
- package/src/funcs/subAgentRelationsListSubAgentRelations.ts +96 -81
- package/src/funcs/subAgentRelationsUpdateSubAgentRelation.ts +93 -78
- package/src/funcs/subAgentTeamAgentRelationsCreateSubAgentTeamAgentRelation.ts +93 -78
- package/src/funcs/subAgentTeamAgentRelationsDeleteSubAgentTeamAgentRelation.ts +78 -64
- package/src/funcs/subAgentTeamAgentRelationsGetSubAgentTeamAgentRelationById.ts +93 -78
- package/src/funcs/subAgentTeamAgentRelationsListSubAgentTeamAgentRelations.ts +94 -79
- package/src/funcs/subAgentTeamAgentRelationsUpdateSubAgentTeamAgentRelation.ts +95 -80
- package/src/funcs/subAgentToolRelationsCreateSubagentToolRelation.ts +91 -76
- package/src/funcs/subAgentToolRelationsDeleteSubagentToolRelation.ts +76 -62
- package/src/funcs/subAgentToolRelationsGetSubagentToolRelation.ts +91 -76
- package/src/funcs/subAgentToolRelationsGetSubagentsForTool.ts +94 -79
- package/src/funcs/subAgentToolRelationsListSubagentToolRelations.ts +94 -79
- package/src/funcs/subAgentToolRelationsUpdateSubagentToolRelation.ts +93 -78
- package/src/funcs/subAgentUpdateSubagent.ts +93 -78
- package/src/funcs/thirdPartyMCPServersGetOauthRedirectUrl.ts +209 -0
- package/src/funcs/thirdPartyMCPServersGetThirdPartyMCPServer.ts +89 -74
- package/src/funcs/toolsCreateTool.ts +88 -73
- package/src/funcs/toolsDeleteTool.ts +97 -58
- package/src/funcs/toolsGetTool.ts +90 -73
- package/src/funcs/toolsGetUserCredentialForTool.ts +211 -0
- package/src/funcs/toolsListTools.ts +90 -75
- package/src/funcs/toolsUpdateTool.ts +92 -75
- package/src/funcs/userOrganizationsGetApiUsersUserIdOrganizations.ts +62 -52
- package/src/funcs/userOrganizationsPostApiUsersUserIdOrganizations.ts +64 -54
- package/src/hooks/header-forwarding-hook.ts +4 -2
- package/src/hooks/hooks.ts +25 -14
- package/src/hooks/registration.ts +5 -4
- package/src/hooks/types.ts +18 -8
- package/src/index.ts +2 -1
- package/src/lib/base64.ts +8 -3
- package/src/lib/config.ts +19 -11
- package/src/lib/dlv.ts +3 -2
- package/src/lib/encodings.ts +118 -87
- package/src/lib/env.ts +17 -7
- package/src/lib/files.ts +29 -28
- package/src/lib/http.ts +66 -46
- package/src/lib/is-plain-object.ts +2 -1
- package/src/lib/logger.ts +1 -0
- package/src/lib/matchers.ts +111 -94
- package/src/lib/primitives.ts +14 -8
- package/src/lib/result.ts +4 -1
- package/src/lib/retries.ts +26 -18
- package/src/lib/schemas.ts +20 -26
- package/src/lib/sdks.ts +115 -85
- package/src/lib/security.ts +90 -46
- package/src/lib/url.ts +10 -5
- package/src/mcp-server/cli/start/command.ts +54 -41
- package/src/mcp-server/cli/start/impl.ts +52 -38
- package/src/mcp-server/cli.ts +2 -1
- package/src/mcp-server/console-logger.ts +27 -12
- package/src/mcp-server/extensions.ts +11 -6
- package/src/mcp-server/mcp-server.ts +8 -7
- package/src/mcp-server/prompts.ts +64 -51
- package/src/mcp-server/resources.ts +54 -35
- package/src/mcp-server/scopes.ts +1 -0
- package/src/mcp-server/server.ts +25 -6
- package/src/mcp-server/shared.ts +35 -24
- package/src/mcp-server/tools/agentArtifactComponentRelationsAssociateArtifactComponentWithAgent.ts +34 -33
- package/src/mcp-server/tools/agentArtifactComponentRelationsCheckArtifactComponentAgentAssociation.ts +34 -33
- package/src/mcp-server/tools/agentArtifactComponentRelationsGetAgentsUsingArtifactComponent.ts +34 -32
- package/src/mcp-server/tools/agentArtifactComponentRelationsGetArtifactComponentsForAgent.ts +34 -32
- package/src/mcp-server/tools/agentArtifactComponentRelationsRemoveArtifactComponentFromAgent.ts +34 -32
- package/src/mcp-server/tools/agentDataComponentRelationsAssociateDataComponentWithAgent.ts +33 -32
- package/src/mcp-server/tools/agentDataComponentRelationsCheckDataComponentAgentAssociation.ts +34 -32
- package/src/mcp-server/tools/agentDataComponentRelationsGetAgentsUsingDataComponent.ts +33 -32
- package/src/mcp-server/tools/agentDataComponentRelationsGetDataComponentsForAgent.ts +33 -32
- package/src/mcp-server/tools/agentDataComponentRelationsRemoveDataComponentFromAgent.ts +33 -32
- package/src/mcp-server/tools/agentGetFullAgentDefinition.ts +16 -13
- package/src/mcp-server/tools/agentGetRelatedAgentInfos.ts +16 -13
- package/src/mcp-server/tools/agentsCreateAgent.ts +16 -13
- package/src/mcp-server/tools/agentsDeleteAgent.ts +16 -13
- package/src/mcp-server/tools/agentsGetAgent.ts +16 -13
- package/src/mcp-server/tools/agentsListAgents.ts +16 -13
- package/src/mcp-server/tools/agentsUpdateAgent.ts +16 -13
- package/src/mcp-server/tools/apiKeysCreateAPIKey.ts +16 -13
- package/src/mcp-server/tools/apiKeysDeleteAPIKey.ts +16 -13
- package/src/mcp-server/tools/apiKeysGetAPIKeyById.ts +16 -13
- package/src/mcp-server/tools/apiKeysListAPIKeys.ts +16 -13
- package/src/mcp-server/tools/apiKeysUpdateAPIKey.ts +16 -13
- package/src/mcp-server/tools/artifactComponentCreateArtifactComponent.ts +19 -14
- package/src/mcp-server/tools/artifactComponentDeleteArtifactComponent.ts +19 -14
- package/src/mcp-server/tools/artifactComponentGetArtifactComponentById.ts +15 -12
- package/src/mcp-server/tools/artifactComponentListArtifactComponents.ts +19 -14
- package/src/mcp-server/tools/artifactComponentUpdateArtifactComponent.ts +19 -14
- package/src/mcp-server/tools/cliGetApiCliMe.ts +38 -0
- package/src/mcp-server/tools/contextConfigCreateContextConfig.ts +19 -14
- package/src/mcp-server/tools/contextConfigDeleteContextConfig.ts +19 -14
- package/src/mcp-server/tools/contextConfigGetContextConfigById.ts +19 -14
- package/src/mcp-server/tools/contextConfigListContextConfigs.ts +32 -28
- package/src/mcp-server/tools/contextConfigUpdateContextConfig.ts +19 -14
- package/src/mcp-server/tools/conversationsGetConversation.ts +16 -13
- package/src/mcp-server/tools/credentialCreateCredential.ts +16 -13
- package/src/mcp-server/tools/credentialDeleteCredential.ts +16 -13
- package/src/mcp-server/tools/credentialGetCredentialById.ts +16 -13
- package/src/mcp-server/tools/credentialListCredentials.ts +16 -13
- package/src/mcp-server/tools/credentialStoreCreateCredentialInStore.ts +19 -14
- package/src/mcp-server/tools/credentialStoreListCredentialStores.ts +19 -14
- package/src/mcp-server/tools/credentialUpdateCredential.ts +16 -13
- package/src/mcp-server/tools/dataComponentCreateDataComponent.ts +19 -14
- package/src/mcp-server/tools/dataComponentDeleteDataComponent.ts +19 -14
- package/src/mcp-server/tools/dataComponentGetDataComponentById.ts +19 -14
- package/src/mcp-server/tools/dataComponentListDataComponents.ts +32 -28
- package/src/mcp-server/tools/dataComponentUpdateDataComponent.ts +19 -14
- package/src/mcp-server/tools/externalAgentsCreateExternalAgent.ts +19 -14
- package/src/mcp-server/tools/externalAgentsDeleteExternalAgent.ts +19 -14
- package/src/mcp-server/tools/externalAgentsGetExternalAgentById.ts +19 -14
- package/src/mcp-server/tools/externalAgentsListExternalAgents.ts +19 -14
- package/src/mcp-server/tools/externalAgentsUpdateExternalAgent.ts +19 -14
- package/src/mcp-server/tools/fullAgentCreateFullAgent.ts +16 -13
- package/src/mcp-server/tools/fullAgentDeleteFullAgent.ts +16 -13
- package/src/mcp-server/tools/fullAgentGetFullAgent.ts +16 -13
- package/src/mcp-server/tools/fullAgentUpdateFullAgent.ts +16 -13
- package/src/mcp-server/tools/fullProjectCreateFullProject.ts +16 -13
- package/src/mcp-server/tools/fullProjectDeleteFullProject.ts +16 -13
- package/src/mcp-server/tools/fullProjectGetFullProject.ts +16 -13
- package/src/mcp-server/tools/fullProjectUpdateFullProject.ts +16 -13
- package/src/mcp-server/tools/functionToolsCreateFunctionTool.ts +32 -28
- package/src/mcp-server/tools/functionToolsDeleteFunctionTool.ts +32 -28
- package/src/mcp-server/tools/functionToolsGetFunctionTool.ts +16 -13
- package/src/mcp-server/tools/functionToolsListFunctionTools.ts +32 -28
- package/src/mcp-server/tools/functionToolsUpdateFunctionTool.ts +32 -28
- package/src/mcp-server/tools/functionsCreateFunction.ts +16 -13
- package/src/mcp-server/tools/functionsDeleteFunction.ts +16 -13
- package/src/mcp-server/tools/functionsGetFunction.ts +16 -13
- package/src/mcp-server/tools/functionsListFunctions.ts +16 -13
- package/src/mcp-server/tools/functionsUpdateFunction.ts +16 -13
- package/src/mcp-server/tools/health.ts +14 -12
- package/src/mcp-server/tools/invitationsGetApiInvitationsPending.ts +19 -14
- package/src/mcp-server/tools/mcpCatalogListMCPCatalog.ts +16 -13
- package/src/mcp-server/tools/oAuthInitiateOauthLoginPublic.ts +16 -13
- package/src/mcp-server/tools/oAuthOauthCallback.ts +16 -13
- package/src/mcp-server/tools/projectsCreateProject.ts +16 -13
- package/src/mcp-server/tools/projectsDeleteProject.ts +16 -13
- package/src/mcp-server/tools/projectsGetProjectById.ts +16 -13
- package/src/mcp-server/tools/projectsListProjects.ts +16 -13
- package/src/mcp-server/tools/projectsUpdateProject.ts +16 -13
- package/src/mcp-server/tools/subAgentCreateSubagent.ts +16 -13
- package/src/mcp-server/tools/subAgentDeleteSubagent.ts +16 -13
- package/src/mcp-server/tools/subAgentExternalAgentRelationsCreateSubAgentExternalAgentRelation.ts +34 -33
- package/src/mcp-server/tools/subAgentExternalAgentRelationsDeleteSubAgentExternalAgentRelation.ts +34 -33
- package/src/mcp-server/tools/subAgentExternalAgentRelationsGetSubAgentExternalAgentRelationById.ts +34 -33
- package/src/mcp-server/tools/subAgentExternalAgentRelationsListSubAgentExternalAgentRelations.ts +34 -31
- package/src/mcp-server/tools/subAgentExternalAgentRelationsUpdateSubAgentExternalAgentRelation.ts +34 -33
- package/src/mcp-server/tools/subAgentGetSubagentById.ts +16 -13
- package/src/mcp-server/tools/subAgentListSubagents.ts +16 -13
- package/src/mcp-server/tools/subAgentRelationsCreateSubAgentRelation.ts +19 -14
- package/src/mcp-server/tools/subAgentRelationsDeleteSubAgentRelation.ts +19 -14
- package/src/mcp-server/tools/subAgentRelationsGetSubAgentRelationById.ts +19 -14
- package/src/mcp-server/tools/subAgentRelationsListSubAgentRelations.ts +19 -14
- package/src/mcp-server/tools/subAgentRelationsUpdateSubAgentRelation.ts +19 -14
- package/src/mcp-server/tools/subAgentTeamAgentRelationsCreateSubAgentTeamAgentRelation.ts +33 -32
- package/src/mcp-server/tools/subAgentTeamAgentRelationsDeleteSubAgentTeamAgentRelation.ts +33 -32
- package/src/mcp-server/tools/subAgentTeamAgentRelationsGetSubAgentTeamAgentRelationById.ts +34 -32
- package/src/mcp-server/tools/subAgentTeamAgentRelationsListSubAgentTeamAgentRelations.ts +33 -32
- package/src/mcp-server/tools/subAgentTeamAgentRelationsUpdateSubAgentTeamAgentRelation.ts +33 -32
- package/src/mcp-server/tools/subAgentToolRelationsCreateSubagentToolRelation.ts +33 -30
- package/src/mcp-server/tools/subAgentToolRelationsDeleteSubagentToolRelation.ts +33 -30
- package/src/mcp-server/tools/subAgentToolRelationsGetSubagentToolRelation.ts +20 -16
- package/src/mcp-server/tools/subAgentToolRelationsGetSubagentsForTool.ts +19 -14
- package/src/mcp-server/tools/subAgentToolRelationsListSubagentToolRelations.ts +33 -30
- package/src/mcp-server/tools/subAgentToolRelationsUpdateSubagentToolRelation.ts +33 -30
- package/src/mcp-server/tools/subAgentUpdateSubagent.ts +16 -13
- package/src/mcp-server/tools/thirdPartyMCPServersGetOauthRedirectUrl.ts +47 -0
- package/src/mcp-server/tools/thirdPartyMCPServersGetThirdPartyMCPServer.ts +15 -12
- package/src/mcp-server/tools/toolsCreateTool.ts +16 -13
- package/src/mcp-server/tools/toolsDeleteTool.ts +16 -13
- package/src/mcp-server/tools/toolsGetTool.ts +16 -13
- package/src/mcp-server/tools/toolsGetUserCredentialForTool.ts +43 -0
- package/src/mcp-server/tools/toolsListTools.ts +16 -13
- package/src/mcp-server/tools/toolsUpdateTool.ts +16 -13
- package/src/mcp-server/tools/userOrganizationsGetApiUsersUserIdOrganizations.ts +33 -30
- package/src/mcp-server/tools/userOrganizationsPostApiUsersUserIdOrganizations.ts +33 -30
- package/src/mcp-server/tools.ts +111 -79
- package/src/models/agent.ts +3 -2
- package/src/models/agentcreate.ts +3 -2
- package/src/models/agentlistresponse.ts +6 -5
- package/src/models/agentresponse.ts +4 -3
- package/src/models/agentstopwhen.ts +3 -2
- package/src/models/agentupdate.ts +3 -2
- package/src/models/agentwithincontextofproject.ts +30 -21
- package/src/models/agentwithincontextofprojectresponse.ts +5 -6
- package/src/models/apikey.ts +3 -2
- package/src/models/apikeycreate.ts +3 -2
- package/src/models/apikeylistresponse.ts +6 -5
- package/src/models/apikeyresponse.ts +4 -3
- package/src/models/apikeyupdate.ts +3 -2
- package/src/models/artifactcomponent.ts +6 -5
- package/src/models/artifactcomponentarrayresponse.ts +7 -5
- package/src/models/artifactcomponentcreate.ts +5 -6
- package/src/models/artifactcomponentlistresponse.ts +8 -6
- package/src/models/artifactcomponentresponse.ts +7 -5
- package/src/models/artifactcomponentupdate.ts +5 -6
- package/src/models/associateartifactcomponentwithagentop.ts +36 -32
- package/src/models/associatedatacomponentwithagentop.ts +28 -25
- package/src/models/badrequest.ts +28 -16
- package/src/models/candelegatetoexternalagent.ts +4 -5
- package/src/models/candelegatetoteamagent.ts +4 -5
- package/src/models/canuseitem.ts +9 -10
- package/src/models/checkartifactcomponentagentassociationop.ts +33 -31
- package/src/models/checkdatacomponentagentassociationop.ts +22 -19
- package/src/models/componentassociation.ts +7 -9
- package/src/models/componentassociationlistresponse.ts +5 -6
- package/src/models/contextconfig.ts +5 -6
- package/src/models/contextconfigcreate.ts +15 -13
- package/src/models/contextconfiglistresponse.ts +5 -6
- package/src/models/contextconfigresponse.ts +7 -9
- package/src/models/contextconfigupdate.ts +15 -13
- package/src/models/conversationwithformattedmessagesresponse.ts +5 -8
- package/src/models/createagentop.ts +23 -16
- package/src/models/createapikeyop.ts +41 -40
- package/src/models/createartifactcomponentop.ts +23 -20
- package/src/models/createcontextconfigop.ts +26 -20
- package/src/models/createcredentialinstoreop.ts +26 -22
- package/src/models/createcredentialinstorerequest.ts +4 -5
- package/src/models/createcredentialinstoreresponse.ts +4 -7
- package/src/models/createcredentialop.ts +23 -20
- package/src/models/createdatacomponentop.ts +25 -19
- package/src/models/createexternalagentop.ts +25 -19
- package/src/models/createfullagentop.ts +29 -23
- package/src/models/createfullprojectop.ts +25 -21
- package/src/models/createfunctionop.ts +27 -22
- package/src/models/createfunctiontoolop.ts +26 -20
- package/src/models/createplaygroundtokenop.ts +17 -30
- package/src/models/createprojectop.ts +39 -35
- package/src/models/createsubagentexternalagentrelationop.ts +30 -24
- package/src/models/createsubagentop.ts +28 -23
- package/src/models/createsubagentrelationop.ts +24 -21
- package/src/models/createsubagentteamagentrelationop.ts +30 -24
- package/src/models/createsubagenttoolrelationop.ts +26 -22
- package/src/models/createtoolop.ts +26 -16
- package/src/models/credentialreference.ts +35 -14
- package/src/models/credentialreferencecreate.ts +25 -7
- package/src/models/credentialreferencelistresponse.ts +8 -6
- package/src/models/credentialreferenceresponse.ts +7 -5
- package/src/models/credentialreferenceupdate.ts +25 -7
- package/src/models/credentialstore.ts +20 -10
- package/src/models/credentialstorelistresponse.ts +7 -5
- package/src/models/datacomponent.ts +5 -4
- package/src/models/datacomponentarrayresponse.ts +4 -5
- package/src/models/datacomponentcreate.ts +6 -5
- package/src/models/datacomponentlistresponse.ts +5 -6
- package/src/models/datacomponentresponse.ts +7 -9
- package/src/models/datacomponentupdate.ts +6 -5
- package/src/models/deleteagentop.ts +11 -10
- package/src/models/deleteapikeyop.ts +15 -17
- package/src/models/deleteartifactcomponentop.ts +9 -12
- package/src/models/deletecontextconfigop.ts +21 -18
- package/src/models/deletecredentialop.ts +9 -12
- package/src/models/deletedatacomponentop.ts +9 -12
- package/src/models/deleteexternalagentop.ts +9 -12
- package/src/models/deletefullagentop.ts +20 -17
- package/src/models/deletefullprojectop.ts +19 -16
- package/src/models/deletefunctionop.ts +22 -20
- package/src/models/deletefunctiontoolop.ts +21 -18
- package/src/models/deleteprojectop.ts +33 -32
- package/src/models/deletesubagentexternalagentrelationop.ts +11 -14
- package/src/models/deletesubagentop.ts +12 -16
- package/src/models/deletesubagentrelationop.ts +10 -13
- package/src/models/deletesubagentteamagentrelationop.ts +11 -14
- package/src/models/deletesubagenttoolrelationop.ts +10 -13
- package/src/models/deletetoolop.ts +34 -12
- package/src/models/errorresponse.ts +3 -2
- package/src/models/errors/apierror.ts +5 -4
- package/src/models/errors/httpclienterrors.ts +8 -7
- package/src/models/errors/sdkvalidationerror.ts +7 -58
- package/src/models/existsresponse.ts +3 -2
- package/src/models/externalagent.ts +5 -4
- package/src/models/externalagentcreate.ts +6 -5
- package/src/models/externalagentlistresponse.ts +5 -6
- package/src/models/externalagentresponse.ts +7 -9
- package/src/models/externalagentupdate.ts +6 -5
- package/src/models/forbidden.ts +28 -16
- package/src/models/fullagentagentinsert.ts +50 -39
- package/src/models/fullprojectdefinition.ts +52 -38
- package/src/models/fullprojectdefinitionresponse.ts +5 -6
- package/src/models/function.ts +3 -2
- package/src/models/functioncreate.ts +3 -2
- package/src/models/functionlistresponse.ts +9 -11
- package/src/models/functionresponse.ts +7 -5
- package/src/models/functiontool.ts +3 -2
- package/src/models/functiontoolcreate.ts +4 -3
- package/src/models/functiontoollistresponse.ts +5 -6
- package/src/models/functiontoolresponse.ts +7 -9
- package/src/models/functiontoolupdate.ts +4 -3
- package/src/models/functionupdate.ts +3 -2
- package/src/models/getagentop.ts +25 -18
- package/src/models/getagentsusingartifactcomponentop.ts +27 -21
- package/src/models/getagentsusingdatacomponentop.ts +27 -21
- package/src/models/getapiclimeop.ts +58 -0
- package/src/models/getapiinvitationspendingop.ts +10 -16
- package/src/models/getapikeybyidop.ts +34 -33
- package/src/models/getapiusersuseridorganizationsop.ts +13 -17
- package/src/models/getartifactcomponentbyidop.ts +22 -19
- package/src/models/getartifactcomponentsforagentop.ts +25 -21
- package/src/models/getcontextconfigbyidop.ts +23 -20
- package/src/models/getconversationop.ts +25 -20
- package/src/models/getcredentialbyidop.ts +22 -19
- package/src/models/getdatacomponentbyidop.ts +22 -19
- package/src/models/getdatacomponentsforagentop.ts +23 -20
- package/src/models/getexternalagentbyidop.ts +22 -19
- package/src/models/getfullagentdefinitionop.ts +27 -21
- package/src/models/getfullagentop.ts +38 -31
- package/src/models/getfullprojectop.ts +25 -22
- package/src/models/getfunctionop.ts +26 -16
- package/src/models/getfunctiontoolop.ts +23 -20
- package/src/models/getoauthredirecturlop.ts +111 -0
- package/src/models/getprojectbyidop.ts +25 -20
- package/src/models/getrelatedagentinfosop.ts +25 -21
- package/src/models/getsubagentbyidop.ts +25 -19
- package/src/models/getsubagentexternalagentrelationbyidop.ts +29 -23
- package/src/models/getsubagentrelationbyidop.ts +23 -20
- package/src/models/getsubagentsfortoolop.ts +27 -21
- package/src/models/getsubagentteamagentrelationbyidop.ts +29 -23
- package/src/models/getsubagenttoolrelationop.ts +25 -21
- package/src/models/getthirdpartymcpserverop.ts +43 -22
- package/src/models/gettoolop.ts +34 -25
- package/src/models/getusercredentialfortoolop.ts +64 -0
- package/src/models/healthop.ts +4 -3
- package/src/models/initiateoauthloginpublicop.ts +11 -13
- package/src/models/internalservererror.ts +34 -20
- package/src/models/listagentsop.ts +25 -15
- package/src/models/listapikeysop.ts +26 -16
- package/src/models/listartifactcomponentsop.ts +23 -19
- package/src/models/listcontextconfigsop.ts +22 -19
- package/src/models/listcredentialsop.ts +23 -19
- package/src/models/listcredentialstoresop.ts +21 -18
- package/src/models/listdatacomponentsop.ts +21 -18
- package/src/models/listexternalagentsop.ts +21 -18
- package/src/models/listfunctionsop.ts +36 -35
- package/src/models/listfunctiontoolsop.ts +22 -19
- package/src/models/listmcpcatalogop.ts +23 -21
- package/src/models/listprojectsop.ts +34 -27
- package/src/models/listsubagentexternalagentrelationsop.ts +26 -21
- package/src/models/listsubagentrelationsop.ts +24 -20
- package/src/models/listsubagentsop.ts +37 -36
- package/src/models/listsubagentteamagentrelationsop.ts +28 -22
- package/src/models/listsubagenttoolrelationsop.ts +27 -21
- package/src/models/listtoolsop.ts +41 -18
- package/src/models/mcpcataloglistresponse.ts +19 -13
- package/src/models/mcptool.ts +54 -25
- package/src/models/mcptoollistresponse.ts +6 -5
- package/src/models/mcptoolresponse.ts +6 -6
- package/src/models/model.ts +4 -3
- package/src/models/modelsettings.ts +4 -3
- package/src/models/notfound.ts +28 -16
- package/src/models/oauthcallbackop.ts +20 -22
- package/src/models/pagination.ts +3 -2
- package/src/models/postapiusersuseridorganizationsop.ts +18 -25
- package/src/models/project.ts +7 -6
- package/src/models/projectcreate.ts +7 -6
- package/src/models/projectlistresponse.ts +6 -5
- package/src/models/projectmodel.ts +4 -3
- package/src/models/projectresponse.ts +6 -6
- package/src/models/projectupdate.ts +7 -6
- package/src/models/relatedagentinfo.ts +8 -6
- package/src/models/relatedagentinfolistresponse.ts +8 -6
- package/src/models/removeartifactcomponentfromagentop.ts +25 -19
- package/src/models/removedatacomponentfromagentop.ts +25 -19
- package/src/models/removedresponse.ts +6 -6
- package/src/models/security.ts +9 -12
- package/src/models/statuscomponent.ts +17 -11
- package/src/models/statusupdate.ts +7 -3
- package/src/models/stopwhen.ts +3 -2
- package/src/models/subagent.ts +7 -6
- package/src/models/subagentartifactcomponentresponse.ts +4 -7
- package/src/models/subagentcreate.ts +8 -7
- package/src/models/subagentdatacomponentresponse.ts +4 -7
- package/src/models/subagentexternalagentrelation.ts +3 -4
- package/src/models/subagentexternalagentrelationcreate.ts +4 -5
- package/src/models/subagentexternalagentrelationlistresponse.ts +6 -7
- package/src/models/subagentexternalagentrelationresponse.ts +5 -6
- package/src/models/subagentexternalagentrelationupdate.ts +4 -5
- package/src/models/subagentlistresponse.ts +9 -11
- package/src/models/subagentrelation.ts +6 -4
- package/src/models/subagentrelationcreate.ts +15 -8
- package/src/models/subagentrelationlistresponse.ts +8 -6
- package/src/models/subagentrelationresponse.ts +7 -5
- package/src/models/subagentrelationupdate.ts +15 -8
- package/src/models/subagentresponse.ts +7 -5
- package/src/models/subagentteamagentrelation.ts +3 -4
- package/src/models/subagentteamagentrelationcreate.ts +4 -5
- package/src/models/subagentteamagentrelationlistresponse.ts +6 -7
- package/src/models/subagentteamagentrelationresponse.ts +5 -6
- package/src/models/subagentteamagentrelationupdate.ts +4 -5
- package/src/models/subagenttoolrelation.ts +13 -15
- package/src/models/subagenttoolrelationcreate.ts +13 -13
- package/src/models/subagenttoolrelationlistresponse.ts +6 -7
- package/src/models/subagenttoolrelationresponse.ts +5 -6
- package/src/models/subagenttoolrelationupdate.ts +13 -13
- package/src/models/subagentupdate.ts +8 -7
- package/src/models/teamagent.ts +3 -2
- package/src/models/thirdpartymcpserverresponse.ts +19 -13
- package/src/models/toolcreate.ts +43 -24
- package/src/models/toolupdate.ts +43 -24
- package/src/models/unauthorized.ts +26 -13
- package/src/models/unprocessableentity.ts +34 -20
- package/src/models/updateagentop.ts +24 -17
- package/src/models/updateapikeyop.ts +34 -30
- package/src/models/updateartifactcomponentop.ts +24 -21
- package/src/models/updatecontextconfigop.ts +27 -21
- package/src/models/updatecredentialop.ts +24 -21
- package/src/models/updatedatacomponentop.ts +26 -20
- package/src/models/updateexternalagentop.ts +26 -20
- package/src/models/updatefullagentop.ts +29 -23
- package/src/models/updatefullprojectop.ts +25 -21
- package/src/models/updatefunctionop.ts +28 -23
- package/src/models/updatefunctiontoolop.ts +27 -21
- package/src/models/updateprojectop.ts +38 -34
- package/src/models/updatesubagentexternalagentrelationop.ts +31 -25
- package/src/models/updatesubagentop.ts +29 -24
- package/src/models/updatesubagentrelationop.ts +25 -22
- package/src/models/updatesubagentteamagentrelationop.ts +31 -25
- package/src/models/updatesubagenttoolrelationop.ts +27 -23
- package/src/models/updatetoolop.ts +27 -17
- package/src/types/async.ts +24 -9
- package/src/types/bigint.ts +88 -0
- package/src/types/blobs.ts +5 -4
- package/src/types/enums.ts +2 -1
- package/src/types/fp.ts +4 -1
- package/src/types/rfcdate.ts +8 -5
- package/src/types/streams.ts +8 -5
- package/src/zod-int.ts +9 -0
- package/tsconfig.json +3 -2
- package/openapi.json +0 -17114
- package/scripts/watch-and-fetch.mjs +0 -72
- package/src/hooks/auth-hook.ts +0 -32
- package/src/http-server.ts +0 -34
package/src/lib/http.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 68dbaf7d3ff1
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
export type Fetcher = (
|
|
6
|
+
export type Fetcher = (
|
|
7
|
+
input: RequestInfo | URL,
|
|
8
|
+
init?: RequestInit,
|
|
9
|
+
) => Promise<Response>;
|
|
6
10
|
|
|
7
11
|
export type Awaitable<T> = T | Promise<T>;
|
|
8
12
|
|
|
@@ -13,8 +17,9 @@ const DEFAULT_FETCHER: Fetcher = (input, init) => {
|
|
|
13
17
|
// therefore needed for interop with Bun.
|
|
14
18
|
if (init == null) {
|
|
15
19
|
return fetch(input);
|
|
20
|
+
} else {
|
|
21
|
+
return fetch(input, init);
|
|
16
22
|
}
|
|
17
|
-
return fetch(input, init);
|
|
18
23
|
};
|
|
19
24
|
|
|
20
25
|
export type RequestInput = {
|
|
@@ -77,28 +82,28 @@ export class HTTPClient {
|
|
|
77
82
|
* can mutate the request or return a new request. This may be useful to add
|
|
78
83
|
* additional information to request such as request IDs and tracing headers.
|
|
79
84
|
*/
|
|
80
|
-
addHook(hook:
|
|
85
|
+
addHook(hook: "beforeRequest", fn: BeforeRequestHook): this;
|
|
81
86
|
/**
|
|
82
87
|
* Registers a hook that is called when a request cannot be made due to a
|
|
83
88
|
* network error.
|
|
84
89
|
*/
|
|
85
|
-
addHook(hook:
|
|
90
|
+
addHook(hook: "requestError", fn: RequestErrorHook): this;
|
|
86
91
|
/**
|
|
87
92
|
* Registers a hook that is called when a response has been received from the
|
|
88
93
|
* server.
|
|
89
94
|
*/
|
|
90
|
-
addHook(hook:
|
|
95
|
+
addHook(hook: "response", fn: ResponseHook): this;
|
|
91
96
|
addHook(
|
|
92
97
|
...args:
|
|
93
|
-
| [hook:
|
|
94
|
-
| [hook:
|
|
95
|
-
| [hook:
|
|
98
|
+
| [hook: "beforeRequest", fn: BeforeRequestHook]
|
|
99
|
+
| [hook: "requestError", fn: RequestErrorHook]
|
|
100
|
+
| [hook: "response", fn: ResponseHook]
|
|
96
101
|
) {
|
|
97
|
-
if (args[0] ===
|
|
102
|
+
if (args[0] === "beforeRequest") {
|
|
98
103
|
this.requestHooks.push(args[1]);
|
|
99
|
-
} else if (args[0] ===
|
|
104
|
+
} else if (args[0] === "requestError") {
|
|
100
105
|
this.requestErrorHooks.push(args[1]);
|
|
101
|
-
} else if (args[0] ===
|
|
106
|
+
} else if (args[0] === "response") {
|
|
102
107
|
this.responseHooks.push(args[1]);
|
|
103
108
|
} else {
|
|
104
109
|
throw new Error(`Invalid hook type: ${args[0]}`);
|
|
@@ -107,23 +112,23 @@ export class HTTPClient {
|
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
/** Removes a hook that was previously registered with `addHook`. */
|
|
110
|
-
removeHook(hook:
|
|
115
|
+
removeHook(hook: "beforeRequest", fn: BeforeRequestHook): this;
|
|
111
116
|
/** Removes a hook that was previously registered with `addHook`. */
|
|
112
|
-
removeHook(hook:
|
|
117
|
+
removeHook(hook: "requestError", fn: RequestErrorHook): this;
|
|
113
118
|
/** Removes a hook that was previously registered with `addHook`. */
|
|
114
|
-
removeHook(hook:
|
|
119
|
+
removeHook(hook: "response", fn: ResponseHook): this;
|
|
115
120
|
removeHook(
|
|
116
121
|
...args:
|
|
117
|
-
| [hook:
|
|
118
|
-
| [hook:
|
|
119
|
-
| [hook:
|
|
122
|
+
| [hook: "beforeRequest", fn: BeforeRequestHook]
|
|
123
|
+
| [hook: "requestError", fn: RequestErrorHook]
|
|
124
|
+
| [hook: "response", fn: ResponseHook]
|
|
120
125
|
): this {
|
|
121
126
|
let target: unknown[];
|
|
122
|
-
if (args[0] ===
|
|
127
|
+
if (args[0] === "beforeRequest") {
|
|
123
128
|
target = this.requestHooks;
|
|
124
|
-
} else if (args[0] ===
|
|
129
|
+
} else if (args[0] === "requestError") {
|
|
125
130
|
target = this.requestErrorHooks;
|
|
126
|
-
} else if (args[0] ===
|
|
131
|
+
} else if (args[0] === "response") {
|
|
127
132
|
target = this.responseHooks;
|
|
128
133
|
} else {
|
|
129
134
|
throw new Error(`Invalid hook type: ${args[0]}`);
|
|
@@ -155,30 +160,31 @@ const mediaParamSeparator = /\s*;\s*/g;
|
|
|
155
160
|
|
|
156
161
|
export function matchContentType(response: Response, pattern: string): boolean {
|
|
157
162
|
// `*` is a special case which means anything is acceptable.
|
|
158
|
-
if (pattern ===
|
|
163
|
+
if (pattern === "*") {
|
|
159
164
|
return true;
|
|
160
165
|
}
|
|
161
166
|
|
|
162
|
-
let contentType =
|
|
167
|
+
let contentType =
|
|
168
|
+
response.headers.get("content-type")?.trim() || "application/octet-stream";
|
|
163
169
|
contentType = contentType.toLowerCase();
|
|
164
170
|
|
|
165
171
|
const wantParts = pattern.toLowerCase().trim().split(mediaParamSeparator);
|
|
166
|
-
const [wantType =
|
|
172
|
+
const [wantType = "", ...wantParams] = wantParts;
|
|
167
173
|
|
|
168
|
-
if (wantType.split(
|
|
174
|
+
if (wantType.split("/").length !== 2) {
|
|
169
175
|
return false;
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
const gotParts = contentType.split(mediaParamSeparator);
|
|
173
|
-
const [gotType =
|
|
179
|
+
const [gotType = "", ...gotParams] = gotParts;
|
|
174
180
|
|
|
175
|
-
const [type =
|
|
181
|
+
const [type = "", subtype = ""] = gotType.split("/");
|
|
176
182
|
if (!type || !subtype) {
|
|
177
183
|
return false;
|
|
178
184
|
}
|
|
179
185
|
|
|
180
186
|
if (
|
|
181
|
-
wantType !==
|
|
187
|
+
wantType !== "*/*" &&
|
|
182
188
|
gotType !== wantType &&
|
|
183
189
|
`${type}/*` !== wantType &&
|
|
184
190
|
`*/${subtype}` !== wantType
|
|
@@ -200,9 +206,12 @@ export function matchContentType(response: Response, pattern: string): boolean {
|
|
|
200
206
|
return true;
|
|
201
207
|
}
|
|
202
208
|
|
|
203
|
-
const codeRangeRE =
|
|
209
|
+
const codeRangeRE = new RegExp("^[0-9]xx$", "i");
|
|
204
210
|
|
|
205
|
-
export function matchStatusCode(
|
|
211
|
+
export function matchStatusCode(
|
|
212
|
+
response: Response,
|
|
213
|
+
codes: StatusCodePredicate,
|
|
214
|
+
): boolean {
|
|
206
215
|
const actual = `${response.status}`;
|
|
207
216
|
const expectedCodes = Array.isArray(codes) ? codes : [codes];
|
|
208
217
|
if (!expectedCodes.length) {
|
|
@@ -212,7 +221,7 @@ export function matchStatusCode(response: Response, codes: StatusCodePredicate):
|
|
|
212
221
|
return expectedCodes.some((ec) => {
|
|
213
222
|
const code = `${ec}`;
|
|
214
223
|
|
|
215
|
-
if (code ===
|
|
224
|
+
if (code === "default") {
|
|
216
225
|
return true;
|
|
217
226
|
}
|
|
218
227
|
|
|
@@ -222,7 +231,7 @@ export function matchStatusCode(response: Response, codes: StatusCodePredicate):
|
|
|
222
231
|
|
|
223
232
|
const expectFamily = code.charAt(0);
|
|
224
233
|
if (!expectFamily) {
|
|
225
|
-
throw new Error(
|
|
234
|
+
throw new Error("Invalid status code range");
|
|
226
235
|
}
|
|
227
236
|
|
|
228
237
|
const actualFamily = actual.charAt(0);
|
|
@@ -237,30 +246,37 @@ export function matchStatusCode(response: Response, codes: StatusCodePredicate):
|
|
|
237
246
|
export function matchResponse(
|
|
238
247
|
response: Response,
|
|
239
248
|
code: StatusCodePredicate,
|
|
240
|
-
contentTypePattern: string
|
|
249
|
+
contentTypePattern: string,
|
|
241
250
|
): boolean {
|
|
242
|
-
return
|
|
251
|
+
return (
|
|
252
|
+
matchStatusCode(response, code) &&
|
|
253
|
+
matchContentType(response, contentTypePattern)
|
|
254
|
+
);
|
|
243
255
|
}
|
|
244
256
|
|
|
245
257
|
/**
|
|
246
258
|
* Uses various heurisitics to determine if an error is a connection error.
|
|
247
259
|
*/
|
|
248
260
|
export function isConnectionError(err: unknown): boolean {
|
|
249
|
-
if (typeof err !==
|
|
261
|
+
if (typeof err !== "object" || err == null) {
|
|
250
262
|
return false;
|
|
251
263
|
}
|
|
252
264
|
|
|
253
265
|
// Covers fetch in Deno as well
|
|
254
266
|
const isBrowserErr =
|
|
255
|
-
err instanceof TypeError &&
|
|
267
|
+
err instanceof TypeError &&
|
|
268
|
+
err.message.toLowerCase().startsWith("failed to fetch");
|
|
256
269
|
|
|
257
270
|
const isNodeErr =
|
|
258
|
-
err instanceof TypeError &&
|
|
271
|
+
err instanceof TypeError &&
|
|
272
|
+
err.message.toLowerCase().startsWith("fetch failed");
|
|
259
273
|
|
|
260
|
-
const isBunErr =
|
|
274
|
+
const isBunErr = "name" in err && err.name === "ConnectionError";
|
|
261
275
|
|
|
262
276
|
const isGenericErr =
|
|
263
|
-
|
|
277
|
+
"code" in err &&
|
|
278
|
+
typeof err.code === "string" &&
|
|
279
|
+
err.code.toLowerCase() === "econnreset";
|
|
264
280
|
|
|
265
281
|
return isBrowserErr || isNodeErr || isGenericErr || isBunErr;
|
|
266
282
|
}
|
|
@@ -269,17 +285,19 @@ export function isConnectionError(err: unknown): boolean {
|
|
|
269
285
|
* Uses various heurisitics to determine if an error is a timeout error.
|
|
270
286
|
*/
|
|
271
287
|
export function isTimeoutError(err: unknown): boolean {
|
|
272
|
-
if (typeof err !==
|
|
288
|
+
if (typeof err !== "object" || err == null) {
|
|
273
289
|
return false;
|
|
274
290
|
}
|
|
275
291
|
|
|
276
292
|
// Fetch in browser, Node.js, Bun, Deno
|
|
277
|
-
const isNative =
|
|
278
|
-
const isLegacyNative =
|
|
293
|
+
const isNative = "name" in err && err.name === "TimeoutError";
|
|
294
|
+
const isLegacyNative = "code" in err && err.code === 23;
|
|
279
295
|
|
|
280
296
|
// Node.js HTTP client and Axios
|
|
281
297
|
const isGenericErr =
|
|
282
|
-
|
|
298
|
+
"code" in err &&
|
|
299
|
+
typeof err.code === "string" &&
|
|
300
|
+
err.code.toLowerCase() === "econnaborted";
|
|
283
301
|
|
|
284
302
|
return isNative || isLegacyNative || isGenericErr;
|
|
285
303
|
}
|
|
@@ -288,17 +306,19 @@ export function isTimeoutError(err: unknown): boolean {
|
|
|
288
306
|
* Uses various heurisitics to determine if an error is a abort error.
|
|
289
307
|
*/
|
|
290
308
|
export function isAbortError(err: unknown): boolean {
|
|
291
|
-
if (typeof err !==
|
|
309
|
+
if (typeof err !== "object" || err == null) {
|
|
292
310
|
return false;
|
|
293
311
|
}
|
|
294
312
|
|
|
295
313
|
// Fetch in browser, Node.js, Bun, Deno
|
|
296
|
-
const isNative =
|
|
297
|
-
const isLegacyNative =
|
|
314
|
+
const isNative = "name" in err && err.name === "AbortError";
|
|
315
|
+
const isLegacyNative = "code" in err && err.code === 20;
|
|
298
316
|
|
|
299
317
|
// Node.js HTTP client and Axios
|
|
300
318
|
const isGenericErr =
|
|
301
|
-
|
|
319
|
+
"code" in err &&
|
|
320
|
+
typeof err.code === "string" &&
|
|
321
|
+
err.code.toLowerCase() === "econnaborted";
|
|
302
322
|
|
|
303
323
|
return isNative || isLegacyNative || isGenericErr;
|
|
304
324
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 5f8254094900
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
6
|
/*
|
|
@@ -28,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
28
29
|
// Taken from https://github.com/sindresorhus/is-plain-obj/blob/97f38e8836f86a642cce98fc6ab3058bc36df181/index.js
|
|
29
30
|
|
|
30
31
|
export function isPlainObject(value: unknown): value is object {
|
|
31
|
-
if (typeof value !==
|
|
32
|
+
if (typeof value !== "object" || value === null) {
|
|
32
33
|
return false;
|
|
33
34
|
}
|
|
34
35
|
|
package/src/lib/logger.ts
CHANGED
package/src/lib/matchers.ts
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
* @generated-id: 9d898ced9f46
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
import { APIError } from
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { matchResponse, matchStatusCode,
|
|
9
|
-
import { isPlainObject } from
|
|
10
|
-
import { safeParse } from
|
|
6
|
+
import { APIError } from "../models/errors/apierror.js";
|
|
7
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
8
|
+
import { Result } from "../types/fp.js";
|
|
9
|
+
import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
|
|
10
|
+
import { isPlainObject } from "./is-plain-object.js";
|
|
11
|
+
import { safeParse } from "./schemas.js";
|
|
11
12
|
|
|
12
|
-
export type Encoding =
|
|
13
|
+
export type Encoding =
|
|
14
|
+
| "jsonl"
|
|
15
|
+
| "json"
|
|
16
|
+
| "text"
|
|
17
|
+
| "bytes"
|
|
18
|
+
| "stream"
|
|
19
|
+
| "sse"
|
|
20
|
+
| "nil"
|
|
21
|
+
| "fail";
|
|
13
22
|
|
|
14
23
|
const DEFAULT_CONTENT_TYPES: Record<Encoding, string> = {
|
|
15
|
-
jsonl:
|
|
16
|
-
json:
|
|
17
|
-
text:
|
|
18
|
-
bytes:
|
|
19
|
-
stream:
|
|
20
|
-
sse:
|
|
21
|
-
nil:
|
|
22
|
-
fail:
|
|
24
|
+
jsonl: "application/jsonl",
|
|
25
|
+
json: "application/json",
|
|
26
|
+
text: "text/plain",
|
|
27
|
+
bytes: "application/octet-stream",
|
|
28
|
+
stream: "application/octet-stream",
|
|
29
|
+
sse: "text/event-stream",
|
|
30
|
+
nil: "*",
|
|
31
|
+
fail: "*",
|
|
23
32
|
};
|
|
24
33
|
|
|
25
34
|
type Schema<T> = { parse(raw: unknown): T };
|
|
@@ -45,7 +54,7 @@ export type ErrorMatcher<E> = MatchOptions & {
|
|
|
45
54
|
};
|
|
46
55
|
|
|
47
56
|
export type FailMatcher = {
|
|
48
|
-
enc:
|
|
57
|
+
enc: "fail";
|
|
49
58
|
codes: StatusCodePredicate;
|
|
50
59
|
};
|
|
51
60
|
|
|
@@ -54,118 +63,122 @@ export type Matcher<T, E> = ValueMatcher<T> | ErrorMatcher<E> | FailMatcher;
|
|
|
54
63
|
export function jsonErr<E>(
|
|
55
64
|
codes: StatusCodePredicate,
|
|
56
65
|
schema: Schema<E>,
|
|
57
|
-
options?: MatchOptions
|
|
66
|
+
options?: MatchOptions,
|
|
58
67
|
): ErrorMatcher<E> {
|
|
59
|
-
return { ...options, err: true, enc:
|
|
68
|
+
return { ...options, err: true, enc: "json", codes, schema };
|
|
60
69
|
}
|
|
61
70
|
export function json<T>(
|
|
62
71
|
codes: StatusCodePredicate,
|
|
63
72
|
schema: Schema<T>,
|
|
64
|
-
options?: MatchOptions
|
|
73
|
+
options?: MatchOptions,
|
|
65
74
|
): ValueMatcher<T> {
|
|
66
|
-
return { ...options, enc:
|
|
75
|
+
return { ...options, enc: "json", codes, schema };
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
export function jsonl<T>(
|
|
70
79
|
codes: StatusCodePredicate,
|
|
71
80
|
schema: Schema<T>,
|
|
72
|
-
options?: MatchOptions
|
|
81
|
+
options?: MatchOptions,
|
|
73
82
|
): ValueMatcher<T> {
|
|
74
|
-
return { ...options, enc:
|
|
83
|
+
return { ...options, enc: "jsonl", codes, schema };
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
export function jsonlErr<E>(
|
|
78
87
|
codes: StatusCodePredicate,
|
|
79
88
|
schema: Schema<E>,
|
|
80
|
-
options?: MatchOptions
|
|
89
|
+
options?: MatchOptions,
|
|
81
90
|
): ErrorMatcher<E> {
|
|
82
|
-
return { ...options, err: true, enc:
|
|
91
|
+
return { ...options, err: true, enc: "jsonl", codes, schema };
|
|
83
92
|
}
|
|
84
93
|
export function textErr<E>(
|
|
85
94
|
codes: StatusCodePredicate,
|
|
86
95
|
schema: Schema<E>,
|
|
87
|
-
options?: MatchOptions
|
|
96
|
+
options?: MatchOptions,
|
|
88
97
|
): ErrorMatcher<E> {
|
|
89
|
-
return { ...options, err: true, enc:
|
|
98
|
+
return { ...options, err: true, enc: "text", codes, schema };
|
|
90
99
|
}
|
|
91
100
|
export function text<T>(
|
|
92
101
|
codes: StatusCodePredicate,
|
|
93
102
|
schema: Schema<T>,
|
|
94
|
-
options?: MatchOptions
|
|
103
|
+
options?: MatchOptions,
|
|
95
104
|
): ValueMatcher<T> {
|
|
96
|
-
return { ...options, enc:
|
|
105
|
+
return { ...options, enc: "text", codes, schema };
|
|
97
106
|
}
|
|
98
107
|
|
|
99
108
|
export function bytesErr<E>(
|
|
100
109
|
codes: StatusCodePredicate,
|
|
101
110
|
schema: Schema<E>,
|
|
102
|
-
options?: MatchOptions
|
|
111
|
+
options?: MatchOptions,
|
|
103
112
|
): ErrorMatcher<E> {
|
|
104
|
-
return { ...options, err: true, enc:
|
|
113
|
+
return { ...options, err: true, enc: "bytes", codes, schema };
|
|
105
114
|
}
|
|
106
115
|
export function bytes<T>(
|
|
107
116
|
codes: StatusCodePredicate,
|
|
108
117
|
schema: Schema<T>,
|
|
109
|
-
options?: MatchOptions
|
|
118
|
+
options?: MatchOptions,
|
|
110
119
|
): ValueMatcher<T> {
|
|
111
|
-
return { ...options, enc:
|
|
120
|
+
return { ...options, enc: "bytes", codes, schema };
|
|
112
121
|
}
|
|
113
122
|
|
|
114
123
|
export function streamErr<E>(
|
|
115
124
|
codes: StatusCodePredicate,
|
|
116
125
|
schema: Schema<E>,
|
|
117
|
-
options?: MatchOptions
|
|
126
|
+
options?: MatchOptions,
|
|
118
127
|
): ErrorMatcher<E> {
|
|
119
|
-
return { ...options, err: true, enc:
|
|
128
|
+
return { ...options, err: true, enc: "stream", codes, schema };
|
|
120
129
|
}
|
|
121
130
|
export function stream<T>(
|
|
122
131
|
codes: StatusCodePredicate,
|
|
123
132
|
schema: Schema<T>,
|
|
124
|
-
options?: MatchOptions
|
|
133
|
+
options?: MatchOptions,
|
|
125
134
|
): ValueMatcher<T> {
|
|
126
|
-
return { ...options, enc:
|
|
135
|
+
return { ...options, enc: "stream", codes, schema };
|
|
127
136
|
}
|
|
128
137
|
|
|
129
138
|
export function sseErr<E>(
|
|
130
139
|
codes: StatusCodePredicate,
|
|
131
140
|
schema: Schema<E>,
|
|
132
|
-
options?: MatchOptions
|
|
141
|
+
options?: MatchOptions,
|
|
133
142
|
): ErrorMatcher<E> {
|
|
134
|
-
return { ...options, err: true, enc:
|
|
143
|
+
return { ...options, err: true, enc: "sse", codes, schema };
|
|
135
144
|
}
|
|
136
145
|
export function sse<T>(
|
|
137
146
|
codes: StatusCodePredicate,
|
|
138
147
|
schema: Schema<T>,
|
|
139
|
-
options?: MatchOptions
|
|
148
|
+
options?: MatchOptions,
|
|
140
149
|
): ValueMatcher<T> {
|
|
141
|
-
return { ...options, enc:
|
|
150
|
+
return { ...options, enc: "sse", codes, schema };
|
|
142
151
|
}
|
|
143
152
|
|
|
144
153
|
export function nilErr<E>(
|
|
145
154
|
codes: StatusCodePredicate,
|
|
146
155
|
schema: Schema<E>,
|
|
147
|
-
options?: MatchOptions
|
|
156
|
+
options?: MatchOptions,
|
|
148
157
|
): ErrorMatcher<E> {
|
|
149
|
-
return { ...options, err: true, enc:
|
|
158
|
+
return { ...options, err: true, enc: "nil", codes, schema };
|
|
150
159
|
}
|
|
151
160
|
export function nil<T>(
|
|
152
161
|
codes: StatusCodePredicate,
|
|
153
162
|
schema: Schema<T>,
|
|
154
|
-
options?: MatchOptions
|
|
163
|
+
options?: MatchOptions,
|
|
155
164
|
): ValueMatcher<T> {
|
|
156
|
-
return { ...options, enc:
|
|
165
|
+
return { ...options, enc: "nil", codes, schema };
|
|
157
166
|
}
|
|
158
167
|
|
|
159
168
|
export function fail(codes: StatusCodePredicate): FailMatcher {
|
|
160
|
-
return { enc:
|
|
169
|
+
return { enc: "fail", codes };
|
|
161
170
|
}
|
|
162
171
|
|
|
163
|
-
export type MatchedValue<Matchers> = Matchers extends Matcher<infer T, any>[]
|
|
164
|
-
|
|
172
|
+
export type MatchedValue<Matchers> = Matchers extends Matcher<infer T, any>[]
|
|
173
|
+
? T
|
|
174
|
+
: never;
|
|
175
|
+
export type MatchedError<Matchers> = Matchers extends Matcher<any, infer E>[]
|
|
176
|
+
? E
|
|
177
|
+
: never;
|
|
165
178
|
export type MatchFunc<T, E> = (
|
|
166
179
|
response: Response,
|
|
167
180
|
request: Request,
|
|
168
|
-
options?: { resultKey?: string; extraFields?: Record<string, unknown> }
|
|
181
|
+
options?: { resultKey?: string; extraFields?: Record<string, unknown> },
|
|
169
182
|
) => Promise<[result: Result<T, E>, raw: unknown]>;
|
|
170
183
|
|
|
171
184
|
export function match<T, E>(
|
|
@@ -174,18 +187,21 @@ export function match<T, E>(
|
|
|
174
187
|
return async function matchFunc(
|
|
175
188
|
response: Response,
|
|
176
189
|
request: Request,
|
|
177
|
-
options?: { resultKey?: string; extraFields?: Record<string, unknown> }
|
|
178
|
-
): Promise<
|
|
190
|
+
options?: { resultKey?: string; extraFields?: Record<string, unknown> },
|
|
191
|
+
): Promise<
|
|
192
|
+
[result: Result<T, E | APIError | SDKValidationError>, raw: unknown]
|
|
193
|
+
> {
|
|
179
194
|
let raw: unknown;
|
|
180
195
|
let matcher: Matcher<T, E> | undefined;
|
|
181
196
|
for (const match of matchers) {
|
|
182
197
|
const { codes } = match;
|
|
183
|
-
const ctpattern =
|
|
198
|
+
const ctpattern = "ctype" in match
|
|
199
|
+
? match.ctype
|
|
200
|
+
: DEFAULT_CONTENT_TYPES[match.enc];
|
|
184
201
|
if (ctpattern && matchResponse(response, codes, ctpattern)) {
|
|
185
202
|
matcher = match;
|
|
186
203
|
break;
|
|
187
|
-
}
|
|
188
|
-
if (!ctpattern && matchStatusCode(response, codes)) {
|
|
204
|
+
} else if (!ctpattern && matchStatusCode(response, codes)) {
|
|
189
205
|
matcher = match;
|
|
190
206
|
break;
|
|
191
207
|
}
|
|
@@ -193,43 +209,40 @@ export function match<T, E>(
|
|
|
193
209
|
|
|
194
210
|
if (!matcher) {
|
|
195
211
|
const body = await response.text();
|
|
196
|
-
return [
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
},
|
|
205
|
-
raw,
|
|
206
|
-
];
|
|
212
|
+
return [{
|
|
213
|
+
ok: false,
|
|
214
|
+
error: new APIError("Unexpected API response status or content-type", {
|
|
215
|
+
response,
|
|
216
|
+
request,
|
|
217
|
+
body,
|
|
218
|
+
}),
|
|
219
|
+
}, raw];
|
|
207
220
|
}
|
|
208
221
|
|
|
209
222
|
const encoding = matcher.enc;
|
|
210
223
|
switch (encoding) {
|
|
211
|
-
case
|
|
224
|
+
case "json":
|
|
212
225
|
raw = await response.json();
|
|
213
226
|
break;
|
|
214
|
-
case
|
|
227
|
+
case "jsonl":
|
|
215
228
|
raw = response.body;
|
|
216
229
|
break;
|
|
217
|
-
case
|
|
230
|
+
case "bytes":
|
|
218
231
|
raw = new Uint8Array(await response.arrayBuffer());
|
|
219
232
|
break;
|
|
220
|
-
case
|
|
233
|
+
case "stream":
|
|
221
234
|
raw = response.body;
|
|
222
235
|
break;
|
|
223
|
-
case
|
|
236
|
+
case "text":
|
|
224
237
|
raw = await response.text();
|
|
225
238
|
break;
|
|
226
|
-
case
|
|
239
|
+
case "sse":
|
|
227
240
|
raw = response.body;
|
|
228
241
|
break;
|
|
229
|
-
case
|
|
242
|
+
case "nil":
|
|
230
243
|
raw = await discardResponseBody(response);
|
|
231
244
|
break;
|
|
232
|
-
case
|
|
245
|
+
case "fail":
|
|
233
246
|
raw = await response.text();
|
|
234
247
|
break;
|
|
235
248
|
default:
|
|
@@ -237,29 +250,26 @@ export function match<T, E>(
|
|
|
237
250
|
throw new Error(`Unsupported response type: ${encoding}`);
|
|
238
251
|
}
|
|
239
252
|
|
|
240
|
-
if (matcher.enc ===
|
|
241
|
-
return [
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
},
|
|
250
|
-
raw,
|
|
251
|
-
];
|
|
253
|
+
if (matcher.enc === "fail") {
|
|
254
|
+
return [{
|
|
255
|
+
ok: false,
|
|
256
|
+
error: new APIError("API error occurred", {
|
|
257
|
+
response,
|
|
258
|
+
request,
|
|
259
|
+
body: raw as string,
|
|
260
|
+
}),
|
|
261
|
+
}, raw];
|
|
252
262
|
}
|
|
253
263
|
|
|
254
264
|
const resultKey = matcher.key || options?.resultKey;
|
|
255
265
|
let data: unknown;
|
|
256
266
|
|
|
257
|
-
if (
|
|
267
|
+
if ("err" in matcher) {
|
|
258
268
|
data = {
|
|
259
269
|
...options?.extraFields,
|
|
260
270
|
...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
|
|
261
271
|
...(isPlainObject(raw) ? raw : null),
|
|
262
|
-
ContentType: response.headers.get(
|
|
272
|
+
ContentType: response.headers.get("content-type") || "",
|
|
263
273
|
StatusCode: response.status,
|
|
264
274
|
RawResponse: response,
|
|
265
275
|
};
|
|
@@ -268,7 +278,7 @@ export function match<T, E>(
|
|
|
268
278
|
...options?.extraFields,
|
|
269
279
|
...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
|
|
270
280
|
[resultKey]: raw,
|
|
271
|
-
ContentType: response.headers.get(
|
|
281
|
+
ContentType: response.headers.get("content-type") || "",
|
|
272
282
|
StatusCode: response.status,
|
|
273
283
|
RawResponse: response,
|
|
274
284
|
};
|
|
@@ -276,24 +286,31 @@ export function match<T, E>(
|
|
|
276
286
|
data = {
|
|
277
287
|
...options?.extraFields,
|
|
278
288
|
...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
|
|
279
|
-
ContentType: response.headers.get(
|
|
289
|
+
ContentType: response.headers.get("content-type") || "",
|
|
280
290
|
StatusCode: response.status,
|
|
281
291
|
RawResponse: response,
|
|
282
292
|
};
|
|
283
293
|
}
|
|
284
294
|
|
|
285
|
-
if (
|
|
295
|
+
if ("err" in matcher) {
|
|
286
296
|
const result = safeParse(
|
|
287
297
|
data,
|
|
288
298
|
(v: unknown) => matcher.schema.parse(v),
|
|
289
|
-
|
|
299
|
+
"Response validation failed",
|
|
290
300
|
);
|
|
291
301
|
return [result.ok ? { ok: false, error: result.value } : result, raw];
|
|
302
|
+
} else {
|
|
303
|
+
const valueToParse = data;
|
|
304
|
+
|
|
305
|
+
return [
|
|
306
|
+
safeParse(
|
|
307
|
+
valueToParse,
|
|
308
|
+
(v: unknown) => matcher.schema.parse(v),
|
|
309
|
+
"Response validation failed",
|
|
310
|
+
),
|
|
311
|
+
raw,
|
|
312
|
+
];
|
|
292
313
|
}
|
|
293
|
-
return [
|
|
294
|
-
safeParse(data, (v: unknown) => matcher.schema.parse(v), 'Response validation failed'),
|
|
295
|
-
raw,
|
|
296
|
-
];
|
|
297
314
|
};
|
|
298
315
|
}
|
|
299
316
|
|