Add Action Gateway TypeScript SDK surface - #196
Open
tgillam-do wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Action Gateway TypeScript SDK surface to the @digitalocean/dots package, including session creation, tool discovery/invocation helpers across multiple inference “tool” formats, and a generated Toolbelts CRUD surface wired into the existing Kiota-based DO API client.
Changes:
- Introduces
ActionGatewayClientwith session lifecycle, tool listing/search/invoke helpers, and provider adapters for Chat Completions / Messages / Responses tool formats. - Adds generated
v2.toolbeltsrequest builders and associated model types/serializers to the DO API SDK. - Adds docs, examples, and mocked tests covering session creation, gateway invocation, tool formatting, and toolbelt operations.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/mocked/action-gateway.test.ts | Adds mocked Jest/Nock coverage for Action Gateway sessions, tool invocation, tool formatting, and toolbelt CRUD wiring. |
| src/action-gateway/index.ts | Implements the Action Gateway SDK client, providers, session management, tool operations, and a createToolbelt convenience wrapper. |
| src/dots/v2/toolbelts/index.ts | Adds generated request builder for /v2/toolbelts list/create + navigation to item operations. |
| src/dots/v2/toolbelts/item/index.ts | Adds generated request builder for /v2/toolbelts/{name} get/delete + navigation to tools subresource. |
| src/dots/v2/toolbelts/item/tools/index.ts | Adds generated navigation request builder for /v2/toolbelts/{name}/tools with add/remove children. |
| src/dots/v2/toolbelts/item/tools/add/index.ts | Adds generated POST request builder for adding tools to a toolbelt version. |
| src/dots/v2/toolbelts/item/tools/remove/index.ts | Adds generated POST request builder for removing tools from a toolbelt version. |
| src/dots/v2/index.ts | Exposes the new toolbelts navigation property on the v2 request builder. |
| src/dots/models/index.ts | Adds toolbelt-related models + (de)serialization helpers used by the generated builders. |
| src/dots/kiota-lock.json | Updates Kiota lock hash to reflect spec/client generation changes. |
| README.md | Documents the new @digitalocean/dots/action_gateway entrypoint and pointers to docs/examples. |
| package.json | Exports ./action_gateway subpath to the Action Gateway SDK entry. |
| docs/action-gateway.md | Adds an Action Gateway guide covering sessions, tool invocation, and toolbelts. |
| examples/action-gateway/*.ts | Adds runnable examples for chat completions, messages, responses, direct tools, async usage, and toolbelt policy flows. |
Comments suppressed due to low confidence (3)
src/action-gateway/index.ts:381
GatewayTransportcurrently callsrequestJSONwith the API key, which means Gateway REST calls will include the bearer token (in addition to the session/actor headers). If the gateway domain only needsX-Session-Id/X-Actor-Id(as described in docs), omit Authorization for these requests.
class GatewayTransport {
public readonly sessionId: string;
public constructor(
private readonly apiKey: string,
src/action-gateway/index.ts:592
- After removing the API key from
GatewayTransport, update the constructor call accordingly.
const transport = new GatewayTransport(this.apiKey, this.gatewayBaseURL, sessionUrn, actorId);
src/action-gateway/index.ts:459
- The META_INVOKE tool schema uses
tool_slug, butToolsOperations.invoke()only checkstoolandtoolSlug. If a model follows the provided schema and sendstool_slug, this will currently throw "each invoke entry requires tool".
const normalized = tools.map((tool) => {
const name = tool.tool ?? tool.toolSlug;
if (!name) throw new Error("each invoke entry requires tool");
return { tool: name, arguments: tool.arguments ?? {} };
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+281
to
+294
| async function requestJSON( | ||
| url: string, | ||
| apiKey: string, | ||
| init: RequestInit, | ||
| ): Promise<unknown> { | ||
| const response = await fetch(url, { | ||
| ...init, | ||
| headers: { | ||
| Authorization: `Bearer ${apiKey}`, | ||
| Accept: "application/json", | ||
| "Content-Type": "application/json", | ||
| ...init.headers, | ||
| }, | ||
| }); |
Comment on lines
+94
to
+98
| export interface InvokeTool { | ||
| tool?: string; | ||
| toolSlug?: string; | ||
| arguments?: JsonObject; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
mcpUrlvalues/v2/toolbeltsBackend contract alignment
actor_id,name, typedpolicy, optionaltools, and optionalconfigasktools(all tools) fromtools: [](no tools)2025-06-18withX-Session-IdandX-Actor-IdPOST /approvals/{id}and supports retrying the tool callexecute_codetoolbelt:name@1Validation
npm run buildnpm run lint(one pre-existing unused eslint-disable warning)npm run test:mock(26 suites, 180 tests)git diff --check