Protocol Execution Strategies
Relevant source files
The following files were used as context for generating this wiki page:
- packages/web/src/lib/agent/skills/content/superglue-concepts.md
- packages/web/src/lib/agent/registries/tool-registry.ts
- packages/web/src/lib/agent/skills/content/systems-handling.md
- packages/web/src/lib/agent/skills/content/access-rules.md
- packages/web/src/lib/agent/agent-prompts.ts
- packages/core/api/systems-documentation.ts
Protocol Execution Strategies determine how superglue routes and executes atomic operations across different communication protocols. The system uses a deterministic execution pipeline to connect with APIs, databases, and file servers by matching step configurations to specific protocol handlers.
The strategy routing mechanism identifies the appropriate execution path based on the URL scheme or the step configuration type. This ensures that every step in a tool—whether it is a REST API call, a SQL query, or a data transformation—is handled by the correct specialized strategy.
Strategy Routing and Dispatch
The ToolExecutor routes steps to specific execution strategies by evaluating the protocol. It uses a "first match wins" priority logic to determine which handler to use for a given step configuration.
The diagram shows the priority-based routing logic used to select an execution strategy for a tool step.
Sources: packages/web/src/lib/agent/skills/content/superglue-concepts.md:46-56
Routing Criteria
| Protocol | URL Scheme / Discriminator | Description |
|---|---|---|
| Transform | config.type === "transform" | Pure JavaScript data transformation in a sandbox. |
| HTTP | http:// or https:// | REST and GraphQL API interactions. |
| PostgreSQL | postgres:// or postgresql:// | SQL query execution for Postgres databases. |
| MSSQL | mssql:// or sqlserver:// | SQL query execution for Azure SQL and MSSQL. |
| Redis | redis:// or rediss:// | Command execution for Redis instances. |
| File Transfer | ftp://, ftps://, or sftp:// | File operations via FTP or SFTP. |
| SMB | smb:// | File operations on SMB shares. |
Sources: packages/web/src/lib/agent/skills/content/superglue-concepts.md:48-56, packages/web/src/lib/agent/registries/tool-registry.ts:863-870
HTTP Strategy
The HTTP strategy handles communication with web APIs. It resolves system credentials, manages OAuth token refreshes, and processes request payloads.
Execution Flow
- Credential Resolution: The system resolves
<<systemId_credKey>>placeholders in the URL, headers, and body. - OAuth Refresh: If the system uses OAuth, the strategy auto-refreshes tokens before the request.
- Payload Construction: It builds the request, including handling
multipart/form-dataif the body contains file references. - Execution: The request is dispatched via the underlying fetch implementation.
Sources: packages/web/src/lib/agent/skills/content/systems-handling.md:144-150, packages/web/src/lib/agent/registries/tool-registry.ts:881-900
Security and RBAC
The HTTP strategy enforces read-only constraints by blocking mutating methods if the user's role is restricted.
- Read-Only Methods:
GET,HEAD. - Mutating Methods:
POST,PUT,PATCH,DELETE.
Sources: packages/web/src/lib/agent/skills/content/access-rules.md:47-48
Database Strategies (Postgres and MSSQL)
Database strategies execute SQL commands against relational databases. They use the provided URL as a connection string and the step body as the query container.
Query Structure
Database steps typically accept a JSON body containing:
query: The SQL statement to execute.params: Optional parameters for prepared statements.
Sources: packages/web/src/lib/agent/registries/tool-registry.ts:875-876
Mutation Detection
To prevent unauthorized data modification in read-only roles, the strategies inspect SQL statements. Any statement containing keywords such as INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, or TRUNCATE is classified as mutating. SELECT statements are classified as read-only.
Sources: packages/web/src/lib/agent/skills/content/access-rules.md:49-50
File and Key-Value Strategies
Specialized strategies handle Redis and file server protocols (SFTP/SMB).
Redis Strategy
The Redis strategy executes commands passed in a JSON body.
- Read-Only Commands:
GET,MGET,EXISTS,KEYS,SCAN,TTL,TYPE,HGET,HGETALL,LRANGE,SMEMBERS,SCARD. - Mutating: Any command not present in the read-only allowlist.
Sources: packages/web/src/lib/agent/skills/content/access-rules.md:52-53, packages/web/src/lib/agent/registries/tool-registry.ts:876-877
File Server Strategy (SFTP/SMB)
These strategies manage file operations based on the operation specified in the JSON body.
- Read-Only Operations:
list,get,exists,stat. - Mutating Operations: All other operations (e.g., upload, delete, rename).
Sources: packages/web/src/lib/agent/skills/content/access-rules.md:51, packages/web/src/lib/agent/registries/tool-registry.ts:877-878
Execution Pipeline Integration
Every protocol strategy follows a unified execution sequence managed by the ToolExecutor.
The sequence diagram illustrates how the ToolExecutor interacts with individual protocol strategies to produce standardized results.
Sources: packages/web/src/lib/agent/skills/content/superglue-concepts.md:27-41, packages/web/src/lib/agent/registries/tool-registry.ts:881-900
Error Handling
Strategies must return a standardized object containing the success status, the resulting data, and any error messages. If a step fails, the pipeline aborts unless the step's failureBehavior is explicitly set to "continue".
Sources: packages/web/src/lib/agent/skills/content/superglue-concepts.md:33-35, packages/web/src/lib/agent/registries/tool-registry.ts:902-915
Summary
Protocol Execution Strategies provide the deterministic foundation of the superglue platform. By routing tool steps through specialized handlers for HTTP, SQL, Redis, and File protocols, the system ensures consistent behavior, integrated security via RBAC, and reliable credential management across diverse external systems.