@kognitivedev/cloud-platforms 0.2.29
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/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-test.log +11 -0
- package/CHANGELOG.md +12 -0
- package/dist/client.d.ts +15 -0
- package/dist/client.js +150 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +7 -0
- package/dist/types.d.ts +117 -0
- package/dist/types.js +2 -0
- package/dist/validation.d.ts +23 -0
- package/dist/validation.js +199 -0
- package/package.json +44 -0
- package/src/__tests__/client.test.ts +144 -0
- package/src/client.ts +211 -0
- package/src/index.ts +22 -0
- package/src/types.ts +135 -0
- package/src/validation.ts +221 -0
- package/tsconfig.json +17 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { CloudPlatforms } from "../client";
|
|
3
|
+
|
|
4
|
+
function jsonResponse(value: unknown, status = 200): Response {
|
|
5
|
+
return new Response(JSON.stringify(value), {
|
|
6
|
+
status,
|
|
7
|
+
headers: { "Content-Type": "application/json" },
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function makeFetch() {
|
|
12
|
+
const calls: Array<{ url: string; init: RequestInit | undefined }> = [];
|
|
13
|
+
const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
14
|
+
const url = String(input);
|
|
15
|
+
calls.push({ url, init });
|
|
16
|
+
|
|
17
|
+
if (url.endsWith("/api/cloud/platforms/catalog")) {
|
|
18
|
+
return jsonResponse({
|
|
19
|
+
toolkits: [],
|
|
20
|
+
actions: [],
|
|
21
|
+
lastSyncedAt: null,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (url.includes("/api/cloud/platforms/tools")) {
|
|
26
|
+
return jsonResponse({
|
|
27
|
+
tools: [
|
|
28
|
+
{
|
|
29
|
+
id: "platform_slack_send_message",
|
|
30
|
+
actionSlug: "SEND_MESSAGE",
|
|
31
|
+
toolkitSlug: "slack",
|
|
32
|
+
name: "Send message",
|
|
33
|
+
description: "Send a Slack message\n\nAvailable connections: Acme Slack (conn-1).",
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: "object",
|
|
36
|
+
properties: {
|
|
37
|
+
connectionId: { type: "string", enum: ["conn-1"] },
|
|
38
|
+
text: { type: "string" },
|
|
39
|
+
},
|
|
40
|
+
required: ["connectionId", "text"],
|
|
41
|
+
},
|
|
42
|
+
outputSchema: { type: "object" },
|
|
43
|
+
requireApproval: true,
|
|
44
|
+
connections: [{ id: "conn-1", label: "Acme Slack", toolkitSlug: "slack" }],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (url.endsWith("/api/cloud/platforms/actions/SEND_MESSAGE/execute")) {
|
|
51
|
+
return jsonResponse({
|
|
52
|
+
actionSlug: "SEND_MESSAGE",
|
|
53
|
+
toolkitSlug: "slack",
|
|
54
|
+
connectionId: "conn-1",
|
|
55
|
+
version: "20260424",
|
|
56
|
+
result: { ok: true },
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return jsonResponse({ error: "not found" }, 404);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return { fetchMock, calls };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
describe("CloudPlatforms", () => {
|
|
67
|
+
it("requires explicit apiKey and baseUrl", () => {
|
|
68
|
+
expect(() => new CloudPlatforms({ apiKey: "", baseUrl: "https://api.example.com" })).toThrow("apiKey");
|
|
69
|
+
expect(() => new CloudPlatforms({ apiKey: "key", baseUrl: "" })).toThrow("baseUrl");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("sends API-key scoped requests", async () => {
|
|
73
|
+
const { fetchMock, calls } = makeFetch();
|
|
74
|
+
const platforms = new CloudPlatforms({
|
|
75
|
+
apiKey: "kog_test",
|
|
76
|
+
baseUrl: "https://api.example.com",
|
|
77
|
+
fetch: fetchMock,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
await platforms.catalog();
|
|
81
|
+
|
|
82
|
+
expect(calls[0].url).toBe("https://api.example.com/api/cloud/platforms/catalog");
|
|
83
|
+
expect(new Headers(calls[0].init?.headers).get("Authorization")).toBe("Bearer kog_test");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("creates one executable model tool per backend action", async () => {
|
|
87
|
+
const { fetchMock, calls } = makeFetch();
|
|
88
|
+
const platforms = new CloudPlatforms({
|
|
89
|
+
apiKey: "kog_test",
|
|
90
|
+
baseUrl: "https://api.example.com",
|
|
91
|
+
fetch: fetchMock,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const tools = await platforms.tools({ selectedConnectionIds: ["conn-1"] });
|
|
95
|
+
const result = await tools[0].execute(
|
|
96
|
+
{ connectionId: "conn-1", text: "hello" },
|
|
97
|
+
{
|
|
98
|
+
abortSignal: new AbortController().signal,
|
|
99
|
+
resourceId: {},
|
|
100
|
+
emit: () => undefined,
|
|
101
|
+
metadata: {
|
|
102
|
+
platforms: {
|
|
103
|
+
approval: { approved: true, toolCallId: "call-1" },
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(tools[0]).toMatchObject({
|
|
110
|
+
id: "platform_slack_send_message",
|
|
111
|
+
requireApproval: true,
|
|
112
|
+
});
|
|
113
|
+
expect(result.result).toEqual({ ok: true });
|
|
114
|
+
const executeCall = calls.find((call) => call.url.endsWith("/api/cloud/platforms/actions/SEND_MESSAGE/execute"));
|
|
115
|
+
expect(JSON.parse(String(executeCall?.init?.body))).toEqual({
|
|
116
|
+
connectionId: "conn-1",
|
|
117
|
+
arguments: { text: "hello" },
|
|
118
|
+
approval: { approved: true, toolCallId: "call-1" },
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("context adapter reads selected connection ids from metadata", async () => {
|
|
123
|
+
const { fetchMock, calls } = makeFetch();
|
|
124
|
+
const platforms = new CloudPlatforms({
|
|
125
|
+
apiKey: "kog_test",
|
|
126
|
+
baseUrl: "https://api.example.com",
|
|
127
|
+
fetch: fetchMock,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const result = await platforms.contextAdapter().resolve({
|
|
131
|
+
resourceId: {},
|
|
132
|
+
messages: [],
|
|
133
|
+
abortSignal: new AbortController().signal,
|
|
134
|
+
metadata: {
|
|
135
|
+
platforms: {
|
|
136
|
+
selectedConnectionIds: ["conn-1"],
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
expect(result.tools).toHaveLength(1);
|
|
142
|
+
expect(calls.some((call) => call.url.includes("selectedConnectionIds=conn-1"))).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
});
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { HttpTransport, withQuery } from "@kognitivedev/client-core";
|
|
2
|
+
import type { AgentContextAdapter } from "@kognitivedev/agents";
|
|
3
|
+
import type { ToolContext } from "@kognitivedev/tools";
|
|
4
|
+
import type {
|
|
5
|
+
CloudPlatformsClient,
|
|
6
|
+
CloudPlatformsConfig,
|
|
7
|
+
CloudPlatformsContextAdapterOptions,
|
|
8
|
+
CloudPlatformToolsInput,
|
|
9
|
+
ConnectLinkInput,
|
|
10
|
+
ConnectLinkResult,
|
|
11
|
+
ExecutePlatformActionInput,
|
|
12
|
+
ListPlatformActionsInput,
|
|
13
|
+
PlatformAction,
|
|
14
|
+
PlatformActionResult,
|
|
15
|
+
PlatformCatalog,
|
|
16
|
+
PlatformConnection,
|
|
17
|
+
PlatformTool,
|
|
18
|
+
PlatformToolDefinition,
|
|
19
|
+
SyncConnectionsInput,
|
|
20
|
+
} from "./types";
|
|
21
|
+
import {
|
|
22
|
+
cloneUnknown,
|
|
23
|
+
decodeActionResult,
|
|
24
|
+
decodeActionsEnvelope,
|
|
25
|
+
decodeCatalog,
|
|
26
|
+
decodeConnectLink,
|
|
27
|
+
decodeConnectionsEnvelope,
|
|
28
|
+
decodeToolsEnvelope,
|
|
29
|
+
isPlainObject,
|
|
30
|
+
validateOptionalStringArray,
|
|
31
|
+
} from "./validation";
|
|
32
|
+
|
|
33
|
+
const CLOUD_PLATFORMS_PATH = "/api/cloud/platforms";
|
|
34
|
+
|
|
35
|
+
function requireNonEmptyConfigValue(value: string | undefined, name: string): string {
|
|
36
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
37
|
+
throw new Error(`CloudPlatforms requires ${name}`);
|
|
38
|
+
}
|
|
39
|
+
return value.trim();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function normalizeSelectedConnectionIds(input?: CloudPlatformToolsInput): string[] | undefined {
|
|
43
|
+
return validateOptionalStringArray(input?.selectedConnectionIds, "selectedConnectionIds");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getPlatformsMetadata(metadata: unknown): Record<string, unknown> | null {
|
|
47
|
+
if (!isPlainObject(metadata)) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const platforms = metadata.platforms;
|
|
51
|
+
return isPlainObject(platforms) ? platforms : null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getSelectedConnectionIdsFromMetadata(metadata: unknown): string[] | undefined {
|
|
55
|
+
const platforms = getPlatformsMetadata(metadata);
|
|
56
|
+
if (!platforms) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return validateOptionalStringArray(platforms.selectedConnectionIds, "metadata.platforms.selectedConnectionIds");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getApprovalFromMetadata(metadata: unknown): ExecutePlatformActionInput["approval"] | undefined {
|
|
63
|
+
const platforms = getPlatformsMetadata(metadata);
|
|
64
|
+
if (!platforms) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const approval = platforms.approval;
|
|
69
|
+
if (!isPlainObject(approval)) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
approved: approval.approved === true,
|
|
75
|
+
...(typeof approval.toolCallId === "string" ? { toolCallId: approval.toolCallId } : {}),
|
|
76
|
+
...(typeof approval.approvedBy === "string" ? { approvedBy: approval.approvedBy } : {}),
|
|
77
|
+
...(typeof approval.approvedAt === "string" ? { approvedAt: approval.approvedAt } : {}),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function parseToolInput(value: unknown): { connectionId: string; arguments: Record<string, unknown> } {
|
|
82
|
+
if (!isPlainObject(value)) {
|
|
83
|
+
throw new Error("Platform tool input must be an object");
|
|
84
|
+
}
|
|
85
|
+
if (typeof value.connectionId !== "string" || !value.connectionId.trim()) {
|
|
86
|
+
throw new Error("Platform tool input requires connectionId");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const args: Record<string, unknown> = {};
|
|
90
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
91
|
+
if (key !== "connectionId") {
|
|
92
|
+
args[key] = cloneUnknown(entry);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
connectionId: value.connectionId.trim(),
|
|
98
|
+
arguments: args,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function createPlatformTool(client: CloudPlatforms, definition: PlatformToolDefinition): PlatformTool {
|
|
103
|
+
return {
|
|
104
|
+
id: definition.id,
|
|
105
|
+
description: definition.description,
|
|
106
|
+
inputSchema: cloneUnknown(definition.inputSchema),
|
|
107
|
+
outputSchema: cloneUnknown(definition.outputSchema),
|
|
108
|
+
requireApproval: definition.requireApproval,
|
|
109
|
+
execute: async (input: Record<string, unknown>, context: ToolContext) => {
|
|
110
|
+
const parsed = parseToolInput(input);
|
|
111
|
+
return client.execute({
|
|
112
|
+
actionSlug: definition.actionSlug,
|
|
113
|
+
connectionId: parsed.connectionId,
|
|
114
|
+
arguments: parsed.arguments,
|
|
115
|
+
approval: getApprovalFromMetadata(context.metadata),
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
toModelOutput: (output: PlatformActionResult) => JSON.stringify(output.result),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class CloudPlatforms implements CloudPlatformsClient {
|
|
123
|
+
private readonly transport: HttpTransport;
|
|
124
|
+
|
|
125
|
+
constructor(config: CloudPlatformsConfig) {
|
|
126
|
+
const apiKey = requireNonEmptyConfigValue(config.apiKey, "apiKey");
|
|
127
|
+
const baseUrl = requireNonEmptyConfigValue(config.baseUrl, "baseUrl");
|
|
128
|
+
this.transport = new HttpTransport({
|
|
129
|
+
apiKey,
|
|
130
|
+
baseUrl,
|
|
131
|
+
fetch: config.fetch,
|
|
132
|
+
timeout: config.timeout,
|
|
133
|
+
logLevel: config.logLevel,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async catalog(): Promise<PlatformCatalog> {
|
|
138
|
+
const response = await this.transport.json<unknown>(`${CLOUD_PLATFORMS_PATH}/catalog`);
|
|
139
|
+
return decodeCatalog(response);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async connections(): Promise<PlatformConnection[]> {
|
|
143
|
+
const response = await this.transport.json<unknown>(`${CLOUD_PLATFORMS_PATH}/connections`);
|
|
144
|
+
return decodeConnectionsEnvelope(response);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async connectLink(input: ConnectLinkInput): Promise<ConnectLinkResult> {
|
|
148
|
+
const response = await this.transport.json<unknown>(`${CLOUD_PLATFORMS_PATH}/connect-link`, {
|
|
149
|
+
method: "POST",
|
|
150
|
+
body: JSON.stringify(input),
|
|
151
|
+
});
|
|
152
|
+
return decodeConnectLink(response);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async syncConnections(input: SyncConnectionsInput = {}): Promise<PlatformConnection[]> {
|
|
156
|
+
const response = await this.transport.json<unknown>(`${CLOUD_PLATFORMS_PATH}/connections/sync`, {
|
|
157
|
+
method: "POST",
|
|
158
|
+
body: JSON.stringify(input),
|
|
159
|
+
});
|
|
160
|
+
return decodeConnectionsEnvelope(response);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async actions(input: ListPlatformActionsInput = {}): Promise<PlatformAction[]> {
|
|
164
|
+
const response = await this.transport.json<unknown>(`${CLOUD_PLATFORMS_PATH}/actions`);
|
|
165
|
+
const actions = decodeActionsEnvelope(response);
|
|
166
|
+
if (!input.toolkitSlug) {
|
|
167
|
+
return actions;
|
|
168
|
+
}
|
|
169
|
+
return actions.filter((action) => action.toolkitSlug === input.toolkitSlug);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async toolDefinitions(input: CloudPlatformToolsInput = {}): Promise<PlatformToolDefinition[]> {
|
|
173
|
+
const selectedConnectionIds = normalizeSelectedConnectionIds(input);
|
|
174
|
+
const path = selectedConnectionIds
|
|
175
|
+
? withQuery(`${CLOUD_PLATFORMS_PATH}/tools`, { selectedConnectionIds: selectedConnectionIds.join(",") })
|
|
176
|
+
: `${CLOUD_PLATFORMS_PATH}/tools`;
|
|
177
|
+
const response = await this.transport.json<unknown>(path);
|
|
178
|
+
return decodeToolsEnvelope(response);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async tools(input: CloudPlatformToolsInput = {}): Promise<PlatformTool[]> {
|
|
182
|
+
const definitions = await this.toolDefinitions(input);
|
|
183
|
+
return definitions.map((definition) => createPlatformTool(this, definition));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async execute(input: ExecutePlatformActionInput): Promise<PlatformActionResult> {
|
|
187
|
+
const response = await this.transport.json<unknown>(
|
|
188
|
+
`${CLOUD_PLATFORMS_PATH}/actions/${encodeURIComponent(input.actionSlug)}/execute`,
|
|
189
|
+
{
|
|
190
|
+
method: "POST",
|
|
191
|
+
body: JSON.stringify({
|
|
192
|
+
connectionId: input.connectionId,
|
|
193
|
+
arguments: input.arguments,
|
|
194
|
+
...(input.approval ? { approval: input.approval } : {}),
|
|
195
|
+
}),
|
|
196
|
+
},
|
|
197
|
+
);
|
|
198
|
+
return decodeActionResult(response);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
contextAdapter(options: CloudPlatformsContextAdapterOptions = {}): AgentContextAdapter {
|
|
202
|
+
return {
|
|
203
|
+
resolve: async (input) => {
|
|
204
|
+
const metadataSelectedConnectionIds = getSelectedConnectionIdsFromMetadata(input.metadata);
|
|
205
|
+
const selectedConnectionIds = metadataSelectedConnectionIds ?? options.selectedConnectionIds;
|
|
206
|
+
const tools = await this.tools({ selectedConnectionIds });
|
|
207
|
+
return { tools };
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { CloudPlatforms } from "./client";
|
|
2
|
+
export { CloudPlatformsValidationError } from "./validation";
|
|
3
|
+
export type {
|
|
4
|
+
CloudPlatformsClient,
|
|
5
|
+
CloudPlatformsConfig,
|
|
6
|
+
CloudPlatformsContextAdapterOptions,
|
|
7
|
+
CloudPlatformToolsInput,
|
|
8
|
+
ConnectLinkInput,
|
|
9
|
+
ConnectLinkResult,
|
|
10
|
+
ExecutePlatformActionInput,
|
|
11
|
+
ListPlatformActionsInput,
|
|
12
|
+
PlatformAction,
|
|
13
|
+
PlatformActionResult,
|
|
14
|
+
PlatformApprovalMetadata,
|
|
15
|
+
PlatformCatalog,
|
|
16
|
+
PlatformConnection,
|
|
17
|
+
PlatformTool,
|
|
18
|
+
PlatformToolConnection,
|
|
19
|
+
PlatformToolDefinition,
|
|
20
|
+
PlatformToolkit,
|
|
21
|
+
SyncConnectionsInput,
|
|
22
|
+
} from "./types";
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { AgentContextAdapter } from "@kognitivedev/agents";
|
|
2
|
+
import type { LogLevel } from "@kognitivedev/client-core";
|
|
3
|
+
import type { Tool } from "@kognitivedev/tools";
|
|
4
|
+
|
|
5
|
+
export interface CloudPlatformsConfig {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
logLevel?: LogLevel;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface PlatformToolkit {
|
|
14
|
+
id: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string | null;
|
|
18
|
+
iconUrl: string | null;
|
|
19
|
+
categories: string[];
|
|
20
|
+
managedAuthSchemes: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface PlatformAction {
|
|
24
|
+
id: string;
|
|
25
|
+
slug: string;
|
|
26
|
+
toolkitSlug: string;
|
|
27
|
+
name: string;
|
|
28
|
+
description: string | null;
|
|
29
|
+
version: string | null;
|
|
30
|
+
inputSchema: Record<string, unknown>;
|
|
31
|
+
outputSchema: Record<string, unknown>;
|
|
32
|
+
tags: string[];
|
|
33
|
+
isDangerous: boolean;
|
|
34
|
+
requireApproval: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface PlatformConnection {
|
|
38
|
+
id: string;
|
|
39
|
+
toolkitSlug: string;
|
|
40
|
+
alias: string | null;
|
|
41
|
+
displayName: string | null;
|
|
42
|
+
status: string;
|
|
43
|
+
externalAccountLabel: string | null;
|
|
44
|
+
metadata: Record<string, unknown>;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
lastSyncedAt: string;
|
|
48
|
+
lastVerifiedAt: string | null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface PlatformCatalog {
|
|
52
|
+
toolkits: PlatformToolkit[];
|
|
53
|
+
actions: PlatformAction[];
|
|
54
|
+
lastSyncedAt: string | null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ConnectLinkInput {
|
|
58
|
+
toolkitSlug: string;
|
|
59
|
+
alias?: string | null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ConnectLinkResult {
|
|
63
|
+
toolkitSlug: string;
|
|
64
|
+
connectionRequestId: string;
|
|
65
|
+
redirectUrl: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface SyncConnectionsInput {
|
|
69
|
+
toolkitSlugs?: string[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ListPlatformActionsInput {
|
|
73
|
+
toolkitSlug?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface CloudPlatformToolsInput {
|
|
77
|
+
selectedConnectionIds?: string[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface PlatformToolConnection {
|
|
81
|
+
id: string;
|
|
82
|
+
label: string;
|
|
83
|
+
toolkitSlug: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface PlatformToolDefinition {
|
|
87
|
+
id: string;
|
|
88
|
+
actionSlug: string;
|
|
89
|
+
toolkitSlug: string;
|
|
90
|
+
name: string;
|
|
91
|
+
description: string;
|
|
92
|
+
inputSchema: Record<string, unknown>;
|
|
93
|
+
outputSchema: Record<string, unknown>;
|
|
94
|
+
requireApproval: boolean;
|
|
95
|
+
connections: PlatformToolConnection[];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface PlatformApprovalMetadata {
|
|
99
|
+
approved: boolean;
|
|
100
|
+
toolCallId?: string;
|
|
101
|
+
approvedBy?: string;
|
|
102
|
+
approvedAt?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface ExecutePlatformActionInput {
|
|
106
|
+
actionSlug: string;
|
|
107
|
+
connectionId: string;
|
|
108
|
+
arguments: Record<string, unknown>;
|
|
109
|
+
approval?: PlatformApprovalMetadata;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface PlatformActionResult {
|
|
113
|
+
actionSlug: string;
|
|
114
|
+
toolkitSlug: string;
|
|
115
|
+
connectionId: string;
|
|
116
|
+
version: string | null;
|
|
117
|
+
result: unknown;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface CloudPlatformsContextAdapterOptions {
|
|
121
|
+
selectedConnectionIds?: string[];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type PlatformTool = Tool<Record<string, unknown>, PlatformActionResult>;
|
|
125
|
+
|
|
126
|
+
export interface CloudPlatformsClient {
|
|
127
|
+
catalog(): Promise<PlatformCatalog>;
|
|
128
|
+
connections(): Promise<PlatformConnection[]>;
|
|
129
|
+
connectLink(input: ConnectLinkInput): Promise<ConnectLinkResult>;
|
|
130
|
+
syncConnections(input?: SyncConnectionsInput): Promise<PlatformConnection[]>;
|
|
131
|
+
actions(input?: ListPlatformActionsInput): Promise<PlatformAction[]>;
|
|
132
|
+
tools(input?: CloudPlatformToolsInput): Promise<PlatformTool[]>;
|
|
133
|
+
execute(input: ExecutePlatformActionInput): Promise<PlatformActionResult>;
|
|
134
|
+
contextAdapter(options?: CloudPlatformsContextAdapterOptions): AgentContextAdapter;
|
|
135
|
+
}
|