@picahq/toolkit 0.1.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.
Files changed (40) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +97 -0
  3. package/dist/apis/action.d.ts +69 -0
  4. package/dist/apis/action.js +201 -0
  5. package/dist/apis/available-actions.d.ts +26 -0
  6. package/dist/apis/available-actions.js +41 -0
  7. package/dist/apis/available-connectors.d.ts +24 -0
  8. package/dist/apis/available-connectors.js +40 -0
  9. package/dist/apis/connections.d.ts +29 -0
  10. package/dist/apis/connections.js +74 -0
  11. package/dist/apis/execute.d.ts +42 -0
  12. package/dist/apis/execute.js +185 -0
  13. package/dist/index.d.ts +36 -0
  14. package/dist/index.js +228 -0
  15. package/dist/prompts/default.d.ts +16 -0
  16. package/dist/prompts/default.js +114 -0
  17. package/dist/prompts/knowledge.d.ts +15 -0
  18. package/dist/prompts/knowledge.js +109 -0
  19. package/dist/schemas/actions.d.ts +69 -0
  20. package/dist/schemas/actions.js +43 -0
  21. package/dist/schemas/connections.d.ts +69 -0
  22. package/dist/schemas/connections.js +42 -0
  23. package/dist/schemas/execute.d.ts +128 -0
  24. package/dist/schemas/execute.js +69 -0
  25. package/dist/schemas/index.d.ts +3 -0
  26. package/dist/schemas/index.js +3 -0
  27. package/dist/tsconfig.tsbuildinfo +1 -0
  28. package/dist/types/client.d.ts +144 -0
  29. package/dist/types/client.js +9 -0
  30. package/dist/types/index.d.ts +2 -0
  31. package/dist/types/index.js +2 -0
  32. package/dist/types/pica.d.ts +133 -0
  33. package/dist/types/pica.js +9 -0
  34. package/dist/utils/helpers.d.ts +92 -0
  35. package/dist/utils/helpers.js +206 -0
  36. package/dist/utils/index.d.ts +2 -0
  37. package/dist/utils/index.js +2 -0
  38. package/dist/utils/log-messages.d.ts +21 -0
  39. package/dist/utils/log-messages.js +26 -0
  40. package/package.json +73 -0
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Pica ToolKit - Knowledge Agent System Prompt
3
+ *
4
+ * This is the knowledge agent system prompt for the Pica ToolKit.
5
+ * Used when knowledgeAgent mode is enabled to generate Edge Function prompts.
6
+ *
7
+ * @fileoverview Knowledge agent system prompt for the Pica ToolKit
8
+ * @author Pica
9
+ */
10
+ const KNOWLEDGE_AGENT_SYSTEM_PROMPT = `
11
+ === PICA: KNOWLEDGE AGENT ===
12
+
13
+ Generate a complete Edge Function prompt in markdown format for integrating with external APIs through Pica's passthrough system.
14
+
15
+ Current Time: ${new Date().toLocaleString('en-US', { timeZone: 'GMT' })} (GMT)
16
+
17
+ You have access to all available actions across all platforms. You can explore any platform's actions and generate prompts without needing actual connections.
18
+
19
+ **IMPORTANT**: You are in Knowledge Agent mode - you can only retrieve knowledge and generate prompts, never execute actual API calls.
20
+
21
+ ## Your Tasks:
22
+ 1. **Load Knowledge**: Retrieve the necessary API documentation for all requested actions on the specified platforms
23
+ 2. **Generate API Call Prompt**: Construct a detailed prompt that helps developers create an **Edge Function** to call the appropriate endpoint(s)
24
+ 3. **Inform User**: Tell the user you are processing their request and will provide a prompt shortly
25
+ 4. **Use Pica Passthrough API**: Structure all API calls through the Pica Passthrough system with correct endpoints and headers
26
+
27
+ ## Workflow rules you MUST follow for every request:
28
+
29
+ Step 1: **searchPlatformActions** - Find available actions on a platform
30
+ - Search by platform name (e.g., 'gmail', 'shopify', 'notion')
31
+ - When passing the query, pass a descriptive intent phrase without the platform name.
32
+ For example, if the platform is 'gmail', and the user's main query is
33
+ "Generate code to fetch my 5 latest emails from Gmail",
34
+ then the query for getting Gmail actions should be {platform: gmail, query: "Fetch my 5 latest emails"}.
35
+ - When you are selecting the action, select the action that is most relevant to the user's query.
36
+ If you are between two very similar actions and one has a 'custom' tag, select the action with the 'custom' tag.
37
+ - Returns actions with system IDs and basic info
38
+
39
+ Step 2: **getActionsKnowledge** - Get detailed documentation for actions
40
+ - Takes array of system IDs from search results
41
+ - Returns comprehensive API documentation and usage examples
42
+ - Essential before generating request configuration
43
+
44
+ Step 3: **execute** - Generate request configuration (no actual execution)
45
+ IMPORTANT: Must always call getActionsKnowledge before generating configuration.
46
+
47
+ Required Parameters:
48
+ * actionSystemId: The action system ID from searchPlatformActions results
49
+ * connectionKey: Use placeholder connection key (will be replaced with environment variable)
50
+ * data: The request payload
51
+
52
+ Optional Parameters:
53
+ * pathVariables: Values for path template variables like {{spreadsheetId}}
54
+ * queryParams: Query parameters to append to the URL
55
+ * headers: Additional HTTP headers
56
+ * isFormData: Set to true to send data as multipart/form-data
57
+ * isFormUrlEncoded: Set to true to send data as application/x-www-form-urlencoded
58
+
59
+ ## Pica Passthrough API Structure:
60
+ All integration API calls must be structured through the Pica Passthrough system:
61
+
62
+ - **Base URL**: \`https://api.picaos.com/v1/passthrough/{path}\` (path from action object)
63
+ - **Method**: \`GET | POST | PUT | DELETE | etc.\` (method from action object)
64
+ - **Required Headers**:
65
+ - \`x-pica-secret: <PICA_SECRET_KEY>\` (from environment variables)
66
+ - \`x-pica-connection-key: <PICA_[PLATFORM]_CONNECTION_KEY>\` (from environment variables)
67
+ - \`x-pica-action-id: <ACTION_ID>\` (from action object)
68
+ - \`Content-Type: application/json\` (unless using form data)
69
+
70
+ ## Output Requirements:
71
+ Generate a properly formatted **Edge Function prompt** in Markdown with:
72
+ - **API Endpoint**: Complete endpoint URL for each action
73
+ - **HTTP Method**: (GET, POST, PUT, DELETE, etc.)
74
+ - **Required Headers**: All necessary authentication and request headers
75
+ - **Request Body**: Complete schema (if applicable)
76
+ - **Response Body**: Expected response structure from action knowledge
77
+ - **Example Code**: Working TypeScript implementation for Edge Functions
78
+
79
+ **Output Guidelines:**
80
+ - Print ONLY the Markdown without additional explanations
81
+ - Include complete JSON schemas for all inputs and outputs
82
+ - Never expose secret values - reference environment variables
83
+ - Use TypeScript unless user specifies another language
84
+
85
+ ## Best Practices:
86
+ - **Follow the workflow**: search → knowledge → generate config for best results
87
+ - **Use Pica Passthrough API**: All integration calls must use the Pica Passthrough structure with correct base URL and headers
88
+ - **Use keys VERBATIM**: Action system IDs must be used exactly as returned
89
+ - **Handle templates**: Path variables like {{spreadsheetId}} need actual values provided in pathVariables
90
+ - **Use correct data format**: Check if action requires isFormData or isFormUrlEncoded based on API requirements
91
+ - **Include complete schemas**: Provide full JSON schemas for inputs and outputs when available
92
+ - **Reference environment variables**: Never expose actual secret values in generated code
93
+ - **Structure API calls correctly**: Always use \`https://api.picaos.com/v1/passthrough/{path}\` with required Pica headers
94
+
95
+ ## Error Handling:
96
+ - If actions fail, read the error message and provide helpful guidance
97
+ - Always provide clear error messages and next steps
98
+ - Ask the user for additional information if needed
99
+
100
+ Be thorough, accurate, and helpful in generating comprehensive Edge Function prompts.
101
+ `;
102
+ /**
103
+ * Generates the knowledge agent system prompt
104
+ * Knowledge agents have access to all actions by default and don't need connection management
105
+ * @returns The formatted knowledge agent system prompt string
106
+ */
107
+ export const generateKnowledgeAgentSystemPrompt = () => {
108
+ return KNOWLEDGE_AGENT_SYSTEM_PROMPT;
109
+ };
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Pica ToolKit - Actions Schema
3
+ *
4
+ * These are the schemas for the actions tool for the Pica ToolKit.
5
+ *
6
+ * @fileoverview Actions schema for the Pica ToolKit
7
+ * @author Pica
8
+ */
9
+ import { z } from "zod/v4";
10
+ export declare const searchPlatformActionsSchema: z.ZodObject<{
11
+ platform: z.ZodString;
12
+ query: z.ZodString;
13
+ }, z.core.$strip>;
14
+ export type SearchPlatformActionsParams = z.infer<typeof searchPlatformActionsSchema>;
15
+ export declare const ActionSystemIdSchema: z.ZodObject<{
16
+ fullId: z.ZodString;
17
+ parts: z.ZodObject<{
18
+ prefix: z.ZodString;
19
+ metadata: z.ZodString;
20
+ suffix: z.ZodString;
21
+ }, z.core.$strip>;
22
+ }, z.core.$strip>;
23
+ export declare const ActionReferenceSchema: z.ZodObject<{
24
+ title: z.ZodString;
25
+ method: z.ZodString;
26
+ path: z.ZodString;
27
+ systemId: z.ZodObject<{
28
+ fullId: z.ZodString;
29
+ parts: z.ZodObject<{
30
+ prefix: z.ZodString;
31
+ metadata: z.ZodString;
32
+ suffix: z.ZodString;
33
+ }, z.core.$strip>;
34
+ }, z.core.$strip>;
35
+ }, z.core.$strip>;
36
+ export declare const getActionsKnowledgeSchema: z.ZodObject<{
37
+ systemIds: z.ZodArray<z.ZodString>;
38
+ }, z.core.$strip>;
39
+ export type GetActionsKnowledgeParams = z.infer<typeof getActionsKnowledgeSchema>;
40
+ export declare const ActionsKnowledgeResponseSchema: z.ZodRecord<z.ZodString, z.ZodString>;
41
+ export declare const SEARCH_PLATFORM_ACTIONS_TOOL_CONFIG: {
42
+ name: string;
43
+ description: string;
44
+ schema: z.ZodObject<{
45
+ platform: z.ZodString;
46
+ query: z.ZodString;
47
+ }, z.core.$strip>;
48
+ outputSchema: z.ZodArray<z.ZodObject<{
49
+ title: z.ZodString;
50
+ method: z.ZodString;
51
+ path: z.ZodString;
52
+ systemId: z.ZodObject<{
53
+ fullId: z.ZodString;
54
+ parts: z.ZodObject<{
55
+ prefix: z.ZodString;
56
+ metadata: z.ZodString;
57
+ suffix: z.ZodString;
58
+ }, z.core.$strip>;
59
+ }, z.core.$strip>;
60
+ }, z.core.$strip>>;
61
+ };
62
+ export declare const GET_ACTIONS_KNOWLEDGE_TOOL_CONFIG: {
63
+ name: string;
64
+ description: string;
65
+ schema: z.ZodObject<{
66
+ systemIds: z.ZodArray<z.ZodString>;
67
+ }, z.core.$strip>;
68
+ outputSchema: z.ZodRecord<z.ZodString, z.ZodString>;
69
+ };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Pica ToolKit - Actions Schema
3
+ *
4
+ * These are the schemas for the actions tool for the Pica ToolKit.
5
+ *
6
+ * @fileoverview Actions schema for the Pica ToolKit
7
+ * @author Pica
8
+ */
9
+ import { z } from "zod/v4";
10
+ export const searchPlatformActionsSchema = z.object({
11
+ platform: z.string().describe("Platform name to search actions for (e.g., 'google-sheets', 'shopify')"),
12
+ query: z.string().describe("Search query to find relevant actions")
13
+ });
14
+ export const ActionSystemIdSchema = z.object({
15
+ fullId: z.string().describe("Opaque system ID. MUST be displayed exactly as provided. Do not trim."),
16
+ parts: z.object({
17
+ prefix: z.string(), // e.g. 'conn_mod_def'
18
+ metadata: z.string(), // e.g. 'GEoTH7-tRU0'
19
+ suffix: z.string(), // e.g. 'RbyDQmffR5C14QTGEdELhg'
20
+ }),
21
+ });
22
+ export const ActionReferenceSchema = z.object({
23
+ title: z.string(),
24
+ method: z.string(),
25
+ path: z.string(),
26
+ systemId: ActionSystemIdSchema,
27
+ });
28
+ export const getActionsKnowledgeSchema = z.object({
29
+ systemIds: z.array(z.string()).describe("Array of full system IDs to get knowledge for")
30
+ });
31
+ export const ActionsKnowledgeResponseSchema = z.record(z.string(), z.string());
32
+ export const SEARCH_PLATFORM_ACTIONS_TOOL_CONFIG = {
33
+ name: "searchPlatformActions",
34
+ description: "Search for available actions on a specific platform. Use this to find APIs and operations you can perform on integrated platforms. Results are filtered based on your permission level: 'read' shows only GET methods, 'write' shows POST/PUT/PATCH methods, 'admin' shows all methods.",
35
+ schema: searchPlatformActionsSchema,
36
+ outputSchema: z.array(ActionReferenceSchema)
37
+ };
38
+ export const GET_ACTIONS_KNOWLEDGE_TOOL_CONFIG = {
39
+ name: "getActionsKnowledge",
40
+ description: "Get detailed knowledge and documentation for specific actions using their system IDs. Call this after searching for actions to get comprehensive information about how to use them.",
41
+ schema: getActionsKnowledgeSchema,
42
+ outputSchema: ActionsKnowledgeResponseSchema
43
+ };
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Pica ToolKit - Connections Schema
3
+ *
4
+ * These are the schemas for the connections tool for the Pica ToolKit.
5
+ *
6
+ * @fileoverview Connections schema for the Pica ToolKit
7
+ * @author Pica
8
+ */
9
+ import { z } from "zod/v4";
10
+ export declare const ConnectionKeySchema: z.ZodObject<{
11
+ fullKey: z.ZodString;
12
+ parts: z.ZodObject<{
13
+ environment: z.ZodString;
14
+ platform: z.ZodString;
15
+ namespace: z.ZodString;
16
+ id: z.ZodString;
17
+ identity: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strip>;
19
+ }, z.core.$strip>;
20
+ export declare const ConnectionReferenceSchema: z.ZodObject<{
21
+ platform: z.ZodString;
22
+ key: z.ZodObject<{
23
+ fullKey: z.ZodString;
24
+ parts: z.ZodObject<{
25
+ environment: z.ZodString;
26
+ platform: z.ZodString;
27
+ namespace: z.ZodString;
28
+ id: z.ZodString;
29
+ identity: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strip>;
31
+ }, z.core.$strip>;
32
+ }, z.core.$strip>;
33
+ export declare const listPicaIntegrationsSchema: z.ZodObject<{}, z.core.$strip>;
34
+ export type ListPicaIntegrationsParams = z.infer<typeof listPicaIntegrationsSchema>;
35
+ export declare const LIST_PICA_INTEGRATIONS_TOOL_CONFIG: {
36
+ name: string;
37
+ description: string;
38
+ schema: z.ZodObject<{}, z.core.$strip>;
39
+ outputSchema: z.ZodArray<z.ZodObject<{
40
+ platform: z.ZodString;
41
+ key: z.ZodObject<{
42
+ fullKey: z.ZodString;
43
+ parts: z.ZodObject<{
44
+ environment: z.ZodString;
45
+ platform: z.ZodString;
46
+ namespace: z.ZodString;
47
+ id: z.ZodString;
48
+ identity: z.ZodOptional<z.ZodString>;
49
+ }, z.core.$strip>;
50
+ }, z.core.$strip>;
51
+ }, z.core.$strip>>;
52
+ };
53
+ export declare const promptToConnectIntegrationSchema: z.ZodObject<{
54
+ platformName: z.ZodString;
55
+ }, z.core.$strip>;
56
+ export type PromptToConnectIntegrationParams = z.infer<typeof promptToConnectIntegrationSchema>;
57
+ export declare const PromptToConnectIntegrationResponseSchema: z.ZodObject<{
58
+ response: z.ZodString;
59
+ }, z.core.$strip>;
60
+ export declare const PROMPT_TO_CONNECT_INTEGRATION_TOOL_CONFIG: {
61
+ name: string;
62
+ description: string;
63
+ schema: z.ZodObject<{
64
+ platformName: z.ZodString;
65
+ }, z.core.$strip>;
66
+ outputSchema: z.ZodObject<{
67
+ response: z.ZodString;
68
+ }, z.core.$strip>;
69
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Pica ToolKit - Connections Schema
3
+ *
4
+ * These are the schemas for the connections tool for the Pica ToolKit.
5
+ *
6
+ * @fileoverview Connections schema for the Pica ToolKit
7
+ * @author Pica
8
+ */
9
+ import { z } from "zod/v4";
10
+ export const ConnectionKeySchema = z.object({
11
+ fullKey: z.string().describe("Opaque connection key. MUST be displayed exactly as provided, including prefixes like 'test::...'. Do not trim."),
12
+ parts: z.object({
13
+ environment: z.string(), // e.g. 'test'
14
+ platform: z.string(), // e.g. 'postgresql'
15
+ namespace: z.string(), // e.g. 'default'
16
+ id: z.string(), // e.g. 'c76d7a...'
17
+ identity: z.string().optional(), // e.g. 'user-abc'
18
+ }),
19
+ });
20
+ export const ConnectionReferenceSchema = z.object({
21
+ platform: z.string(),
22
+ key: ConnectionKeySchema,
23
+ });
24
+ export const listPicaIntegrationsSchema = z.object({});
25
+ export const LIST_PICA_INTEGRATIONS_TOOL_CONFIG = {
26
+ name: "listPicaConnections",
27
+ description: "List all connected integrations in the user's Pica account. IMPORTANT: Keys are opaque identifiers and must be shown VERBATIM. Do NOT drop prefixes (e.g., 'test::'). When summarizing, include the `fullKey` exactly as returned.",
28
+ schema: listPicaIntegrationsSchema,
29
+ outputSchema: z.array(ConnectionReferenceSchema)
30
+ };
31
+ export const promptToConnectIntegrationSchema = z.object({
32
+ platformName: z.string(),
33
+ });
34
+ export const PromptToConnectIntegrationResponseSchema = z.object({
35
+ response: z.string(),
36
+ });
37
+ export const PROMPT_TO_CONNECT_INTEGRATION_TOOL_CONFIG = {
38
+ name: "promptToConnectIntegration",
39
+ description: "Prompt the user to connect to a platform that they do not currently have access to via AuthKit",
40
+ schema: promptToConnectIntegrationSchema,
41
+ outputSchema: PromptToConnectIntegrationResponseSchema
42
+ };
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Pica ToolKit - Execute Schema
3
+ *
4
+ * These are the schemas for the execute tool for the Pica ToolKit.
5
+ *
6
+ * @fileoverview Execute schema for the Pica ToolKit
7
+ * @author Pica
8
+ */
9
+ import { z } from "zod/v4";
10
+ export declare const executeActionSchema: z.ZodObject<{
11
+ actionSystemId: z.ZodString;
12
+ connectionKey: z.ZodString;
13
+ data: z.ZodAny;
14
+ pathVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
15
+ queryParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
16
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
17
+ isFormData: z.ZodOptional<z.ZodBoolean>;
18
+ isFormUrlEncoded: z.ZodOptional<z.ZodBoolean>;
19
+ }, z.core.$strip>;
20
+ export type ExecuteActionParams = z.infer<typeof executeActionSchema>;
21
+ export declare const ExecuteActionResponseSchema: z.ZodUnion<readonly [z.ZodObject<{
22
+ success: z.ZodBoolean;
23
+ responseData: z.ZodOptional<z.ZodAny>;
24
+ requestConfig: z.ZodObject<{
25
+ url: z.ZodString;
26
+ method: z.ZodOptional<z.ZodString>;
27
+ headers: z.ZodRecord<z.ZodString, z.ZodAny>;
28
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
29
+ data: z.ZodOptional<z.ZodAny>;
30
+ }, z.core.$strip>;
31
+ }, z.core.$strip>, z.ZodObject<{
32
+ success: z.ZodBoolean;
33
+ error: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strip>, z.ZodObject<{
35
+ executed: z.ZodBoolean;
36
+ requestConfig: z.ZodObject<{
37
+ url: z.ZodString;
38
+ method: z.ZodOptional<z.ZodString>;
39
+ headers: z.ZodRecord<z.ZodString, z.ZodAny>;
40
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
41
+ data: z.ZodOptional<z.ZodAny>;
42
+ }, z.core.$strip>;
43
+ }, z.core.$strip>]>;
44
+ export declare const EXECUTE_ACTION_TOOL_CONFIG: {
45
+ name: string;
46
+ description: string;
47
+ schema: z.ZodObject<{
48
+ actionSystemId: z.ZodString;
49
+ connectionKey: z.ZodString;
50
+ data: z.ZodAny;
51
+ pathVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
52
+ queryParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
53
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
54
+ isFormData: z.ZodOptional<z.ZodBoolean>;
55
+ isFormUrlEncoded: z.ZodOptional<z.ZodBoolean>;
56
+ }, z.core.$strip>;
57
+ outputSchema: z.ZodUnion<readonly [z.ZodObject<{
58
+ success: z.ZodBoolean;
59
+ responseData: z.ZodOptional<z.ZodAny>;
60
+ requestConfig: z.ZodObject<{
61
+ url: z.ZodString;
62
+ method: z.ZodOptional<z.ZodString>;
63
+ headers: z.ZodRecord<z.ZodString, z.ZodAny>;
64
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
65
+ data: z.ZodOptional<z.ZodAny>;
66
+ }, z.core.$strip>;
67
+ }, z.core.$strip>, z.ZodObject<{
68
+ success: z.ZodBoolean;
69
+ error: z.ZodOptional<z.ZodString>;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ executed: z.ZodBoolean;
72
+ requestConfig: z.ZodObject<{
73
+ url: z.ZodString;
74
+ method: z.ZodOptional<z.ZodString>;
75
+ headers: z.ZodRecord<z.ZodString, z.ZodAny>;
76
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
77
+ data: z.ZodOptional<z.ZodAny>;
78
+ }, z.core.$strip>;
79
+ }, z.core.$strip>]>;
80
+ };
81
+ export declare const knowledgeAgentExecuteActionSchema: z.ZodObject<{
82
+ actionSystemId: z.ZodString;
83
+ connectionKey: z.ZodString;
84
+ data: z.ZodAny;
85
+ pathVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
86
+ queryParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
87
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
88
+ isFormData: z.ZodOptional<z.ZodBoolean>;
89
+ isFormUrlEncoded: z.ZodOptional<z.ZodBoolean>;
90
+ }, z.core.$strip>;
91
+ export type KnowledgeAgentExecuteActionParams = z.infer<typeof knowledgeAgentExecuteActionSchema>;
92
+ export declare const KNOWLEDGE_AGENT_EXECUTE_ACTION_TOOL_CONFIG: {
93
+ name: string;
94
+ description: string;
95
+ schema: z.ZodObject<{
96
+ actionSystemId: z.ZodString;
97
+ connectionKey: z.ZodString;
98
+ data: z.ZodAny;
99
+ pathVariables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
100
+ queryParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
101
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
102
+ isFormData: z.ZodOptional<z.ZodBoolean>;
103
+ isFormUrlEncoded: z.ZodOptional<z.ZodBoolean>;
104
+ }, z.core.$strip>;
105
+ outputSchema: z.ZodUnion<readonly [z.ZodObject<{
106
+ success: z.ZodBoolean;
107
+ responseData: z.ZodOptional<z.ZodAny>;
108
+ requestConfig: z.ZodObject<{
109
+ url: z.ZodString;
110
+ method: z.ZodOptional<z.ZodString>;
111
+ headers: z.ZodRecord<z.ZodString, z.ZodAny>;
112
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
113
+ data: z.ZodOptional<z.ZodAny>;
114
+ }, z.core.$strip>;
115
+ }, z.core.$strip>, z.ZodObject<{
116
+ success: z.ZodBoolean;
117
+ error: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strip>, z.ZodObject<{
119
+ executed: z.ZodBoolean;
120
+ requestConfig: z.ZodObject<{
121
+ url: z.ZodString;
122
+ method: z.ZodOptional<z.ZodString>;
123
+ headers: z.ZodRecord<z.ZodString, z.ZodAny>;
124
+ params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
125
+ data: z.ZodOptional<z.ZodAny>;
126
+ }, z.core.$strip>;
127
+ }, z.core.$strip>]>;
128
+ };
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Pica ToolKit - Execute Schema
3
+ *
4
+ * These are the schemas for the execute tool for the Pica ToolKit.
5
+ *
6
+ * @fileoverview Execute schema for the Pica ToolKit
7
+ * @author Pica
8
+ */
9
+ import { z } from "zod/v4";
10
+ export const executeActionSchema = z.object({
11
+ actionSystemId: z.string().describe("The action system ID from searchPlatformActions results - method and path will be fetched automatically"),
12
+ connectionKey: z.string().describe("The connection key for authentication - use the full connection key exactly"),
13
+ data: z.any().describe("The request payload/body data"),
14
+ pathVariables: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional().describe("Values for path variables like {{spreadsheetId}} - optional if no template variables"),
15
+ queryParams: z.record(z.string(), z.any()).optional().describe("Query parameters to append to the URL - optional"),
16
+ headers: z.record(z.string(), z.any()).optional().describe("Additional HTTP headers - optional"),
17
+ isFormData: z.boolean().optional().describe("Set to true to send data as multipart/form-data - optional, defaults to false"),
18
+ isFormUrlEncoded: z.boolean().optional().describe("Set to true to send data as application/x-www-form-urlencoded - optional, defaults to false"),
19
+ });
20
+ export const ExecuteActionResponseSchema = z.union([
21
+ z.object({
22
+ success: z.boolean(),
23
+ responseData: z.any().optional(),
24
+ requestConfig: z.object({
25
+ url: z.string(),
26
+ method: z.string().optional(),
27
+ headers: z.record(z.string(), z.any()),
28
+ params: z.record(z.string(), z.any()).optional(),
29
+ data: z.any().optional()
30
+ })
31
+ }),
32
+ z.object({
33
+ success: z.boolean(),
34
+ error: z.string().optional()
35
+ }),
36
+ z.object({
37
+ executed: z.boolean(),
38
+ requestConfig: z.object({
39
+ url: z.string(),
40
+ method: z.string().optional(),
41
+ headers: z.record(z.string(), z.any()),
42
+ params: z.record(z.string(), z.any()).optional(),
43
+ data: z.any().optional()
44
+ })
45
+ })
46
+ ]);
47
+ export const EXECUTE_ACTION_TOOL_CONFIG = {
48
+ name: "execute",
49
+ description: "Execute an action on a connected platform. Automatically fetches method and path from the knowledge endpoint using actionSystemId. Provide the actionSystemId, connection key, and any required data.",
50
+ schema: executeActionSchema,
51
+ outputSchema: ExecuteActionResponseSchema
52
+ };
53
+ // Knowledge Agent Execute Tool - returns request config without execution
54
+ export const knowledgeAgentExecuteActionSchema = z.object({
55
+ actionSystemId: z.string().describe("The action system ID from searchPlatformActions results - method and path will be fetched automatically"),
56
+ connectionKey: z.string().describe("The connection key for authentication - use the full connection key exactly"),
57
+ data: z.any().describe("The request payload/body data"),
58
+ pathVariables: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional().describe("Values for path variables like {{spreadsheetId}} - optional if no template variables"),
59
+ queryParams: z.record(z.string(), z.any()).optional().describe("Query parameters to append to the URL - optional"),
60
+ headers: z.record(z.string(), z.any()).optional().describe("Additional HTTP headers - optional"),
61
+ isFormData: z.boolean().optional().describe("Set to true to send data as multipart/form-data - optional, defaults to false"),
62
+ isFormUrlEncoded: z.boolean().optional().describe("Set to true to send data as application/x-www-form-urlencoded - optional, defaults to false"),
63
+ });
64
+ export const KNOWLEDGE_AGENT_EXECUTE_ACTION_TOOL_CONFIG = {
65
+ name: "execute",
66
+ description: "Generate request configuration for an action without executing it. Returns the complete request config that can be used to create Edge Function code. Automatically fetches method and path from the knowledge endpoint using actionSystemId.",
67
+ schema: knowledgeAgentExecuteActionSchema,
68
+ outputSchema: ExecuteActionResponseSchema
69
+ };
@@ -0,0 +1,3 @@
1
+ export * from "./connections";
2
+ export * from "./actions";
3
+ export * from "./execute";
@@ -0,0 +1,3 @@
1
+ export * from "./connections";
2
+ export * from "./actions";
3
+ export * from "./execute";