@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.
@@ -0,0 +1,2 @@
1
+
2
+ $ tsc
@@ -0,0 +1,11 @@
1
+ $ vitest run
2
+
3
+ RUN v3.2.4 /Users/vserifsaglam/work/memory-experiment/packages/cloud-platforms
4
+
5
+ ✓ src/__tests__/client.test.ts (4 tests) 5ms
6
+
7
+ Test Files 1 passed (1)
8
+ Tests 4 passed (4)
9
+ Start at 17:30:10
10
+ Duration 786ms (transform 56ms, setup 0ms, collect 62ms, tests 5ms, environment 0ms, prepare 328ms)
11
+
package/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # @kognitivedev/cloud-platforms
2
+
3
+ ## 0.2.29
4
+
5
+ ### Patch Changes
6
+
7
+ - release
8
+
9
+ - Updated dependencies []:
10
+ - @kognitivedev/agents@0.2.29
11
+ - @kognitivedev/client-core@0.2.29
12
+ - @kognitivedev/tools@0.2.29
@@ -0,0 +1,15 @@
1
+ import type { AgentContextAdapter } from "@kognitivedev/agents";
2
+ import type { CloudPlatformsClient, CloudPlatformsConfig, CloudPlatformsContextAdapterOptions, CloudPlatformToolsInput, ConnectLinkInput, ConnectLinkResult, ExecutePlatformActionInput, ListPlatformActionsInput, PlatformAction, PlatformActionResult, PlatformCatalog, PlatformConnection, PlatformTool, PlatformToolDefinition, SyncConnectionsInput } from "./types";
3
+ export declare class CloudPlatforms implements CloudPlatformsClient {
4
+ private readonly transport;
5
+ constructor(config: CloudPlatformsConfig);
6
+ catalog(): Promise<PlatformCatalog>;
7
+ connections(): Promise<PlatformConnection[]>;
8
+ connectLink(input: ConnectLinkInput): Promise<ConnectLinkResult>;
9
+ syncConnections(input?: SyncConnectionsInput): Promise<PlatformConnection[]>;
10
+ actions(input?: ListPlatformActionsInput): Promise<PlatformAction[]>;
11
+ toolDefinitions(input?: CloudPlatformToolsInput): Promise<PlatformToolDefinition[]>;
12
+ tools(input?: CloudPlatformToolsInput): Promise<PlatformTool[]>;
13
+ execute(input: ExecutePlatformActionInput): Promise<PlatformActionResult>;
14
+ contextAdapter(options?: CloudPlatformsContextAdapterOptions): AgentContextAdapter;
15
+ }
package/dist/client.js ADDED
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudPlatforms = void 0;
4
+ const client_core_1 = require("@kognitivedev/client-core");
5
+ const validation_1 = require("./validation");
6
+ const CLOUD_PLATFORMS_PATH = "/api/cloud/platforms";
7
+ function requireNonEmptyConfigValue(value, name) {
8
+ if (typeof value !== "string" || !value.trim()) {
9
+ throw new Error(`CloudPlatforms requires ${name}`);
10
+ }
11
+ return value.trim();
12
+ }
13
+ function normalizeSelectedConnectionIds(input) {
14
+ return (0, validation_1.validateOptionalStringArray)(input === null || input === void 0 ? void 0 : input.selectedConnectionIds, "selectedConnectionIds");
15
+ }
16
+ function getPlatformsMetadata(metadata) {
17
+ if (!(0, validation_1.isPlainObject)(metadata)) {
18
+ return null;
19
+ }
20
+ const platforms = metadata.platforms;
21
+ return (0, validation_1.isPlainObject)(platforms) ? platforms : null;
22
+ }
23
+ function getSelectedConnectionIdsFromMetadata(metadata) {
24
+ const platforms = getPlatformsMetadata(metadata);
25
+ if (!platforms) {
26
+ return undefined;
27
+ }
28
+ return (0, validation_1.validateOptionalStringArray)(platforms.selectedConnectionIds, "metadata.platforms.selectedConnectionIds");
29
+ }
30
+ function getApprovalFromMetadata(metadata) {
31
+ const platforms = getPlatformsMetadata(metadata);
32
+ if (!platforms) {
33
+ return undefined;
34
+ }
35
+ const approval = platforms.approval;
36
+ if (!(0, validation_1.isPlainObject)(approval)) {
37
+ return undefined;
38
+ }
39
+ return Object.assign(Object.assign(Object.assign({ approved: approval.approved === true }, (typeof approval.toolCallId === "string" ? { toolCallId: approval.toolCallId } : {})), (typeof approval.approvedBy === "string" ? { approvedBy: approval.approvedBy } : {})), (typeof approval.approvedAt === "string" ? { approvedAt: approval.approvedAt } : {}));
40
+ }
41
+ function parseToolInput(value) {
42
+ if (!(0, validation_1.isPlainObject)(value)) {
43
+ throw new Error("Platform tool input must be an object");
44
+ }
45
+ if (typeof value.connectionId !== "string" || !value.connectionId.trim()) {
46
+ throw new Error("Platform tool input requires connectionId");
47
+ }
48
+ const args = {};
49
+ for (const [key, entry] of Object.entries(value)) {
50
+ if (key !== "connectionId") {
51
+ args[key] = (0, validation_1.cloneUnknown)(entry);
52
+ }
53
+ }
54
+ return {
55
+ connectionId: value.connectionId.trim(),
56
+ arguments: args,
57
+ };
58
+ }
59
+ function createPlatformTool(client, definition) {
60
+ return {
61
+ id: definition.id,
62
+ description: definition.description,
63
+ inputSchema: (0, validation_1.cloneUnknown)(definition.inputSchema),
64
+ outputSchema: (0, validation_1.cloneUnknown)(definition.outputSchema),
65
+ requireApproval: definition.requireApproval,
66
+ execute: async (input, context) => {
67
+ const parsed = parseToolInput(input);
68
+ return client.execute({
69
+ actionSlug: definition.actionSlug,
70
+ connectionId: parsed.connectionId,
71
+ arguments: parsed.arguments,
72
+ approval: getApprovalFromMetadata(context.metadata),
73
+ });
74
+ },
75
+ toModelOutput: (output) => JSON.stringify(output.result),
76
+ };
77
+ }
78
+ class CloudPlatforms {
79
+ constructor(config) {
80
+ const apiKey = requireNonEmptyConfigValue(config.apiKey, "apiKey");
81
+ const baseUrl = requireNonEmptyConfigValue(config.baseUrl, "baseUrl");
82
+ this.transport = new client_core_1.HttpTransport({
83
+ apiKey,
84
+ baseUrl,
85
+ fetch: config.fetch,
86
+ timeout: config.timeout,
87
+ logLevel: config.logLevel,
88
+ });
89
+ }
90
+ async catalog() {
91
+ const response = await this.transport.json(`${CLOUD_PLATFORMS_PATH}/catalog`);
92
+ return (0, validation_1.decodeCatalog)(response);
93
+ }
94
+ async connections() {
95
+ const response = await this.transport.json(`${CLOUD_PLATFORMS_PATH}/connections`);
96
+ return (0, validation_1.decodeConnectionsEnvelope)(response);
97
+ }
98
+ async connectLink(input) {
99
+ const response = await this.transport.json(`${CLOUD_PLATFORMS_PATH}/connect-link`, {
100
+ method: "POST",
101
+ body: JSON.stringify(input),
102
+ });
103
+ return (0, validation_1.decodeConnectLink)(response);
104
+ }
105
+ async syncConnections(input = {}) {
106
+ const response = await this.transport.json(`${CLOUD_PLATFORMS_PATH}/connections/sync`, {
107
+ method: "POST",
108
+ body: JSON.stringify(input),
109
+ });
110
+ return (0, validation_1.decodeConnectionsEnvelope)(response);
111
+ }
112
+ async actions(input = {}) {
113
+ const response = await this.transport.json(`${CLOUD_PLATFORMS_PATH}/actions`);
114
+ const actions = (0, validation_1.decodeActionsEnvelope)(response);
115
+ if (!input.toolkitSlug) {
116
+ return actions;
117
+ }
118
+ return actions.filter((action) => action.toolkitSlug === input.toolkitSlug);
119
+ }
120
+ async toolDefinitions(input = {}) {
121
+ const selectedConnectionIds = normalizeSelectedConnectionIds(input);
122
+ const path = selectedConnectionIds
123
+ ? (0, client_core_1.withQuery)(`${CLOUD_PLATFORMS_PATH}/tools`, { selectedConnectionIds: selectedConnectionIds.join(",") })
124
+ : `${CLOUD_PLATFORMS_PATH}/tools`;
125
+ const response = await this.transport.json(path);
126
+ return (0, validation_1.decodeToolsEnvelope)(response);
127
+ }
128
+ async tools(input = {}) {
129
+ const definitions = await this.toolDefinitions(input);
130
+ return definitions.map((definition) => createPlatformTool(this, definition));
131
+ }
132
+ async execute(input) {
133
+ const response = await this.transport.json(`${CLOUD_PLATFORMS_PATH}/actions/${encodeURIComponent(input.actionSlug)}/execute`, {
134
+ method: "POST",
135
+ body: JSON.stringify(Object.assign({ connectionId: input.connectionId, arguments: input.arguments }, (input.approval ? { approval: input.approval } : {}))),
136
+ });
137
+ return (0, validation_1.decodeActionResult)(response);
138
+ }
139
+ contextAdapter(options = {}) {
140
+ return {
141
+ resolve: async (input) => {
142
+ const metadataSelectedConnectionIds = getSelectedConnectionIdsFromMetadata(input.metadata);
143
+ const selectedConnectionIds = metadataSelectedConnectionIds !== null && metadataSelectedConnectionIds !== void 0 ? metadataSelectedConnectionIds : options.selectedConnectionIds;
144
+ const tools = await this.tools({ selectedConnectionIds });
145
+ return { tools };
146
+ },
147
+ };
148
+ }
149
+ }
150
+ exports.CloudPlatforms = CloudPlatforms;
@@ -0,0 +1,3 @@
1
+ export { CloudPlatforms } from "./client";
2
+ export { CloudPlatformsValidationError } from "./validation";
3
+ export type { CloudPlatformsClient, CloudPlatformsConfig, CloudPlatformsContextAdapterOptions, CloudPlatformToolsInput, ConnectLinkInput, ConnectLinkResult, ExecutePlatformActionInput, ListPlatformActionsInput, PlatformAction, PlatformActionResult, PlatformApprovalMetadata, PlatformCatalog, PlatformConnection, PlatformTool, PlatformToolConnection, PlatformToolDefinition, PlatformToolkit, SyncConnectionsInput, } from "./types";
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudPlatformsValidationError = exports.CloudPlatforms = void 0;
4
+ var client_1 = require("./client");
5
+ Object.defineProperty(exports, "CloudPlatforms", { enumerable: true, get: function () { return client_1.CloudPlatforms; } });
6
+ var validation_1 = require("./validation");
7
+ Object.defineProperty(exports, "CloudPlatformsValidationError", { enumerable: true, get: function () { return validation_1.CloudPlatformsValidationError; } });
@@ -0,0 +1,117 @@
1
+ import type { AgentContextAdapter } from "@kognitivedev/agents";
2
+ import type { LogLevel } from "@kognitivedev/client-core";
3
+ import type { Tool } from "@kognitivedev/tools";
4
+ export interface CloudPlatformsConfig {
5
+ apiKey: string;
6
+ baseUrl: string;
7
+ fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
8
+ timeout?: number;
9
+ logLevel?: LogLevel;
10
+ }
11
+ export interface PlatformToolkit {
12
+ id: string;
13
+ slug: string;
14
+ name: string;
15
+ description: string | null;
16
+ iconUrl: string | null;
17
+ categories: string[];
18
+ managedAuthSchemes: string[];
19
+ }
20
+ export interface PlatformAction {
21
+ id: string;
22
+ slug: string;
23
+ toolkitSlug: string;
24
+ name: string;
25
+ description: string | null;
26
+ version: string | null;
27
+ inputSchema: Record<string, unknown>;
28
+ outputSchema: Record<string, unknown>;
29
+ tags: string[];
30
+ isDangerous: boolean;
31
+ requireApproval: boolean;
32
+ }
33
+ export interface PlatformConnection {
34
+ id: string;
35
+ toolkitSlug: string;
36
+ alias: string | null;
37
+ displayName: string | null;
38
+ status: string;
39
+ externalAccountLabel: string | null;
40
+ metadata: Record<string, unknown>;
41
+ createdAt: string;
42
+ updatedAt: string;
43
+ lastSyncedAt: string;
44
+ lastVerifiedAt: string | null;
45
+ }
46
+ export interface PlatformCatalog {
47
+ toolkits: PlatformToolkit[];
48
+ actions: PlatformAction[];
49
+ lastSyncedAt: string | null;
50
+ }
51
+ export interface ConnectLinkInput {
52
+ toolkitSlug: string;
53
+ alias?: string | null;
54
+ }
55
+ export interface ConnectLinkResult {
56
+ toolkitSlug: string;
57
+ connectionRequestId: string;
58
+ redirectUrl: string;
59
+ }
60
+ export interface SyncConnectionsInput {
61
+ toolkitSlugs?: string[];
62
+ }
63
+ export interface ListPlatformActionsInput {
64
+ toolkitSlug?: string;
65
+ }
66
+ export interface CloudPlatformToolsInput {
67
+ selectedConnectionIds?: string[];
68
+ }
69
+ export interface PlatformToolConnection {
70
+ id: string;
71
+ label: string;
72
+ toolkitSlug: string;
73
+ }
74
+ export interface PlatformToolDefinition {
75
+ id: string;
76
+ actionSlug: string;
77
+ toolkitSlug: string;
78
+ name: string;
79
+ description: string;
80
+ inputSchema: Record<string, unknown>;
81
+ outputSchema: Record<string, unknown>;
82
+ requireApproval: boolean;
83
+ connections: PlatformToolConnection[];
84
+ }
85
+ export interface PlatformApprovalMetadata {
86
+ approved: boolean;
87
+ toolCallId?: string;
88
+ approvedBy?: string;
89
+ approvedAt?: string;
90
+ }
91
+ export interface ExecutePlatformActionInput {
92
+ actionSlug: string;
93
+ connectionId: string;
94
+ arguments: Record<string, unknown>;
95
+ approval?: PlatformApprovalMetadata;
96
+ }
97
+ export interface PlatformActionResult {
98
+ actionSlug: string;
99
+ toolkitSlug: string;
100
+ connectionId: string;
101
+ version: string | null;
102
+ result: unknown;
103
+ }
104
+ export interface CloudPlatformsContextAdapterOptions {
105
+ selectedConnectionIds?: string[];
106
+ }
107
+ export type PlatformTool = Tool<Record<string, unknown>, PlatformActionResult>;
108
+ export interface CloudPlatformsClient {
109
+ catalog(): Promise<PlatformCatalog>;
110
+ connections(): Promise<PlatformConnection[]>;
111
+ connectLink(input: ConnectLinkInput): Promise<ConnectLinkResult>;
112
+ syncConnections(input?: SyncConnectionsInput): Promise<PlatformConnection[]>;
113
+ actions(input?: ListPlatformActionsInput): Promise<PlatformAction[]>;
114
+ tools(input?: CloudPlatformToolsInput): Promise<PlatformTool[]>;
115
+ execute(input: ExecutePlatformActionInput): Promise<PlatformActionResult>;
116
+ contextAdapter(options?: CloudPlatformsContextAdapterOptions): AgentContextAdapter;
117
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ import type { ConnectLinkResult, PlatformAction, PlatformActionResult, PlatformCatalog, PlatformConnection, PlatformToolkit, PlatformToolConnection, PlatformToolDefinition } from "./types";
2
+ export declare class CloudPlatformsValidationError extends Error {
3
+ readonly path: string;
4
+ readonly expected: string;
5
+ readonly actual: unknown;
6
+ constructor(path: string, expected: string, actual: unknown);
7
+ }
8
+ type PlainObject = Record<string, unknown>;
9
+ export declare function isPlainObject(value: unknown): value is PlainObject;
10
+ export declare function cloneUnknown<T>(value: T): T;
11
+ export declare function decodeToolkit(value: unknown, path: string): PlatformToolkit;
12
+ export declare function decodeAction(value: unknown, path: string): PlatformAction;
13
+ export declare function decodeConnection(value: unknown, path: string): PlatformConnection;
14
+ export declare function decodeCatalog(value: unknown, path?: string): PlatformCatalog;
15
+ export declare function decodeConnectionsEnvelope(value: unknown): PlatformConnection[];
16
+ export declare function decodeActionsEnvelope(value: unknown): PlatformAction[];
17
+ export declare function decodeToolConnection(value: unknown, path: string): PlatformToolConnection;
18
+ export declare function decodeToolDefinition(value: unknown, path: string): PlatformToolDefinition;
19
+ export declare function decodeToolsEnvelope(value: unknown): PlatformToolDefinition[];
20
+ export declare function decodeConnectLink(value: unknown): ConnectLinkResult;
21
+ export declare function decodeActionResult(value: unknown): PlatformActionResult;
22
+ export declare function validateOptionalStringArray(value: unknown, path: string): string[] | undefined;
23
+ export {};
@@ -0,0 +1,199 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudPlatformsValidationError = void 0;
4
+ exports.isPlainObject = isPlainObject;
5
+ exports.cloneUnknown = cloneUnknown;
6
+ exports.decodeToolkit = decodeToolkit;
7
+ exports.decodeAction = decodeAction;
8
+ exports.decodeConnection = decodeConnection;
9
+ exports.decodeCatalog = decodeCatalog;
10
+ exports.decodeConnectionsEnvelope = decodeConnectionsEnvelope;
11
+ exports.decodeActionsEnvelope = decodeActionsEnvelope;
12
+ exports.decodeToolConnection = decodeToolConnection;
13
+ exports.decodeToolDefinition = decodeToolDefinition;
14
+ exports.decodeToolsEnvelope = decodeToolsEnvelope;
15
+ exports.decodeConnectLink = decodeConnectLink;
16
+ exports.decodeActionResult = decodeActionResult;
17
+ exports.validateOptionalStringArray = validateOptionalStringArray;
18
+ class CloudPlatformsValidationError extends Error {
19
+ constructor(path, expected, actual) {
20
+ super(`${path} must be ${expected}`);
21
+ this.name = "CloudPlatformsValidationError";
22
+ this.path = path;
23
+ this.expected = expected;
24
+ this.actual = actual;
25
+ }
26
+ }
27
+ exports.CloudPlatformsValidationError = CloudPlatformsValidationError;
28
+ function isPlainObject(value) {
29
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
30
+ return false;
31
+ }
32
+ const prototype = Object.getPrototypeOf(value);
33
+ return prototype === Object.prototype || prototype === null;
34
+ }
35
+ function cloneUnknown(value) {
36
+ if (Array.isArray(value)) {
37
+ return value.map((entry) => cloneUnknown(entry));
38
+ }
39
+ if (isPlainObject(value)) {
40
+ const cloned = {};
41
+ for (const [key, entry] of Object.entries(value)) {
42
+ cloned[key] = cloneUnknown(entry);
43
+ }
44
+ return cloned;
45
+ }
46
+ return value;
47
+ }
48
+ function invalid(path, expected, actual) {
49
+ throw new CloudPlatformsValidationError(path, expected, actual);
50
+ }
51
+ function expectObject(value, path) {
52
+ if (!isPlainObject(value)) {
53
+ invalid(path, "an object", value);
54
+ }
55
+ return value;
56
+ }
57
+ function expectArray(value, path) {
58
+ if (!Array.isArray(value)) {
59
+ invalid(path, "an array", value);
60
+ }
61
+ return value;
62
+ }
63
+ function expectString(value, path) {
64
+ if (typeof value !== "string") {
65
+ invalid(path, "a string", value);
66
+ }
67
+ return value;
68
+ }
69
+ function expectBoolean(value, path) {
70
+ if (typeof value !== "boolean") {
71
+ invalid(path, "a boolean", value);
72
+ }
73
+ return value;
74
+ }
75
+ function expectNullableString(value, path) {
76
+ if (value === null) {
77
+ return null;
78
+ }
79
+ return expectString(value, path);
80
+ }
81
+ function expectRecord(value, path) {
82
+ return cloneUnknown(expectObject(value, path));
83
+ }
84
+ function expectStringArray(value, path) {
85
+ return expectArray(value, path).map((entry, index) => expectString(entry, `${path}[${index}]`));
86
+ }
87
+ function optionalStringArray(value, path) {
88
+ if (value === undefined) {
89
+ return undefined;
90
+ }
91
+ return expectStringArray(value, path);
92
+ }
93
+ function decodeToolkit(value, path) {
94
+ const object = expectObject(value, path);
95
+ return {
96
+ id: expectString(object.id, `${path}.id`),
97
+ slug: expectString(object.slug, `${path}.slug`),
98
+ name: expectString(object.name, `${path}.name`),
99
+ description: expectNullableString(object.description, `${path}.description`),
100
+ iconUrl: expectNullableString(object.iconUrl, `${path}.iconUrl`),
101
+ categories: expectStringArray(object.categories, `${path}.categories`),
102
+ managedAuthSchemes: expectStringArray(object.managedAuthSchemes, `${path}.managedAuthSchemes`),
103
+ };
104
+ }
105
+ function decodeAction(value, path) {
106
+ const object = expectObject(value, path);
107
+ return {
108
+ id: expectString(object.id, `${path}.id`),
109
+ slug: expectString(object.slug, `${path}.slug`),
110
+ toolkitSlug: expectString(object.toolkitSlug, `${path}.toolkitSlug`),
111
+ name: expectString(object.name, `${path}.name`),
112
+ description: expectNullableString(object.description, `${path}.description`),
113
+ version: expectNullableString(object.version, `${path}.version`),
114
+ inputSchema: expectRecord(object.inputSchema, `${path}.inputSchema`),
115
+ outputSchema: expectRecord(object.outputSchema, `${path}.outputSchema`),
116
+ tags: expectStringArray(object.tags, `${path}.tags`),
117
+ isDangerous: expectBoolean(object.isDangerous, `${path}.isDangerous`),
118
+ requireApproval: expectBoolean(object.requireApproval, `${path}.requireApproval`),
119
+ };
120
+ }
121
+ function decodeConnection(value, path) {
122
+ const object = expectObject(value, path);
123
+ return {
124
+ id: expectString(object.id, `${path}.id`),
125
+ toolkitSlug: expectString(object.toolkitSlug, `${path}.toolkitSlug`),
126
+ alias: expectNullableString(object.alias, `${path}.alias`),
127
+ displayName: expectNullableString(object.displayName, `${path}.displayName`),
128
+ status: expectString(object.status, `${path}.status`),
129
+ externalAccountLabel: expectNullableString(object.externalAccountLabel, `${path}.externalAccountLabel`),
130
+ metadata: expectRecord(object.metadata, `${path}.metadata`),
131
+ createdAt: expectString(object.createdAt, `${path}.createdAt`),
132
+ updatedAt: expectString(object.updatedAt, `${path}.updatedAt`),
133
+ lastSyncedAt: expectString(object.lastSyncedAt, `${path}.lastSyncedAt`),
134
+ lastVerifiedAt: expectNullableString(object.lastVerifiedAt, `${path}.lastVerifiedAt`),
135
+ };
136
+ }
137
+ function decodeCatalog(value, path = "catalog") {
138
+ const object = expectObject(value, path);
139
+ return {
140
+ toolkits: expectArray(object.toolkits, `${path}.toolkits`).map((entry, index) => decodeToolkit(entry, `${path}.toolkits[${index}]`)),
141
+ actions: expectArray(object.actions, `${path}.actions`).map((entry, index) => decodeAction(entry, `${path}.actions[${index}]`)),
142
+ lastSyncedAt: expectNullableString(object.lastSyncedAt, `${path}.lastSyncedAt`),
143
+ };
144
+ }
145
+ function decodeConnectionsEnvelope(value) {
146
+ const object = expectObject(value, "response");
147
+ return expectArray(object.connections, "response.connections").map((entry, index) => decodeConnection(entry, `response.connections[${index}]`));
148
+ }
149
+ function decodeActionsEnvelope(value) {
150
+ const object = expectObject(value, "response");
151
+ return expectArray(object.actions, "response.actions").map((entry, index) => decodeAction(entry, `response.actions[${index}]`));
152
+ }
153
+ function decodeToolConnection(value, path) {
154
+ const object = expectObject(value, path);
155
+ return {
156
+ id: expectString(object.id, `${path}.id`),
157
+ label: expectString(object.label, `${path}.label`),
158
+ toolkitSlug: expectString(object.toolkitSlug, `${path}.toolkitSlug`),
159
+ };
160
+ }
161
+ function decodeToolDefinition(value, path) {
162
+ const object = expectObject(value, path);
163
+ return {
164
+ id: expectString(object.id, `${path}.id`),
165
+ actionSlug: expectString(object.actionSlug, `${path}.actionSlug`),
166
+ toolkitSlug: expectString(object.toolkitSlug, `${path}.toolkitSlug`),
167
+ name: expectString(object.name, `${path}.name`),
168
+ description: expectString(object.description, `${path}.description`),
169
+ inputSchema: expectRecord(object.inputSchema, `${path}.inputSchema`),
170
+ outputSchema: expectRecord(object.outputSchema, `${path}.outputSchema`),
171
+ requireApproval: expectBoolean(object.requireApproval, `${path}.requireApproval`),
172
+ connections: expectArray(object.connections, `${path}.connections`).map((entry, index) => decodeToolConnection(entry, `${path}.connections[${index}]`)),
173
+ };
174
+ }
175
+ function decodeToolsEnvelope(value) {
176
+ const object = expectObject(value, "response");
177
+ return expectArray(object.tools, "response.tools").map((entry, index) => decodeToolDefinition(entry, `response.tools[${index}]`));
178
+ }
179
+ function decodeConnectLink(value) {
180
+ const object = expectObject(value, "response");
181
+ return {
182
+ toolkitSlug: expectString(object.toolkitSlug, "response.toolkitSlug"),
183
+ connectionRequestId: expectString(object.connectionRequestId, "response.connectionRequestId"),
184
+ redirectUrl: expectString(object.redirectUrl, "response.redirectUrl"),
185
+ };
186
+ }
187
+ function decodeActionResult(value) {
188
+ const object = expectObject(value, "response");
189
+ return {
190
+ actionSlug: expectString(object.actionSlug, "response.actionSlug"),
191
+ toolkitSlug: expectString(object.toolkitSlug, "response.toolkitSlug"),
192
+ connectionId: expectString(object.connectionId, "response.connectionId"),
193
+ version: expectNullableString(object.version, "response.version"),
194
+ result: cloneUnknown(object.result),
195
+ };
196
+ }
197
+ function validateOptionalStringArray(value, path) {
198
+ return optionalStringArray(value, path);
199
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@kognitivedev/cloud-platforms",
3
+ "version": "0.2.29",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "dev": "tsc -w --noCheck",
12
+ "prepublishOnly": "npm run build",
13
+ "test": "vitest run"
14
+ },
15
+ "dependencies": {
16
+ "@kognitivedev/agents": "^0.2.29",
17
+ "@kognitivedev/client-core": "^0.2.29",
18
+ "@kognitivedev/tools": "^0.2.29"
19
+ },
20
+ "devDependencies": {
21
+ "@types/node": "^20.0.0",
22
+ "typescript": "^5.0.0",
23
+ "vitest": "^3.0.0",
24
+ "zod": "^3.23.8"
25
+ },
26
+ "peerDependencies": {
27
+ "zod": ">=3.23.0"
28
+ },
29
+ "description": "Provider-neutral cloud platform connector SDK for Kognitive hosted APIs",
30
+ "keywords": [
31
+ "kognitive",
32
+ "cloud",
33
+ "platforms",
34
+ "connectors",
35
+ "tools"
36
+ ],
37
+ "license": "MIT",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/kognitivedev/kognitive",
41
+ "directory": "packages/cloud-platforms"
42
+ },
43
+ "homepage": "https://kognitive.dev"
44
+ }