Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@picahq/toolkit

Package Overview
Dependencies
Maintainers
5
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@picahq/toolkit - npm Package Compare versions

Comparing version
0.1.0
to
0.2.0
+3
-1
dist/apis/action.d.ts

@@ -39,2 +39,3 @@ /**

systemIds: string[];
passthroughUrl: string;
options?: PicaOptions;

@@ -47,6 +48,7 @@ }

* @param systemIds - The system IDs to get knowledge for
* @param passthroughUrl - The passthrough URL to replace baseUrl with in knowledge
* @param options - The options for the Pica client
* @returns The knowledge for the system IDs
*/
export declare function getActionsKnowledge({ baseUrl, secret, systemIds, options, }: GetActionsKnowledgeParams): Promise<ActionsKnowledgeResponse>;
export declare function getActionsKnowledge({ baseUrl, secret, systemIds, passthroughUrl, options, }: GetActionsKnowledgeParams): Promise<ActionsKnowledgeResponse>;
/**

@@ -53,0 +55,0 @@ * Fetch action references for multiple action IDs using Promise.all

@@ -11,3 +11,3 @@ /**

import axios from "axios";
import { isInitializingWithAllActions, parseSystemId, normalizeActionId } from "../utils";
import { isInitializingWithAllActions, parseSystemId, normalizeActionId, replaceBaseUrlInKnowledge } from "../utils";
const SEARCH_ACTIONS_URL = "/v1/available-actions/search";

@@ -110,6 +110,7 @@ const KNOWLEDGE_URL = "/v1/knowledge";

* @param systemIds - The system IDs to get knowledge for
* @param passthroughUrl - The passthrough URL to replace baseUrl with in knowledge
* @param options - The options for the Pica client
* @returns The knowledge for the system IDs
*/
export async function getActionsKnowledge({ baseUrl, secret, systemIds, options, }) {
export async function getActionsKnowledge({ baseUrl, secret, systemIds, passthroughUrl, options, }) {
const knowledgeMap = {};

@@ -129,3 +130,7 @@ const promises = systemIds.map(async (systemId) => {

const actionKnowledge = response.data.rows[0];
knowledgeMap[systemId] = actionKnowledge.knowledge;
let updatedKnowledge = actionKnowledge.knowledge;
if (actionKnowledge.baseUrl && updatedKnowledge) {
updatedKnowledge = replaceBaseUrlInKnowledge(updatedKnowledge, actionKnowledge.baseUrl, passthroughUrl);
}
knowledgeMap[systemId] = updatedKnowledge;
}

@@ -132,0 +137,0 @@ }

@@ -16,9 +16,7 @@ /**

constructor(secret: string, options?: PicaOptions);
get passthroughUrl(): string;
get systemPrompt(): string;
private logConnectorInitialization;
private logActionInitialization;
/**
* @returns The system prompt for the Pica ToolKit
*/
getSystemPrompt(): Promise<string>;
/**
* @returns List of connected integrations

@@ -25,0 +23,0 @@ */

@@ -49,2 +49,11 @@ /**

}
get passthroughUrl() {
return `${this.baseUrl}/v1/passthrough`;
}
get systemPrompt() {
if (this.options?.knowledgeAgent) {
return generateKnowledgeAgentSystemPrompt();
}
return generateDefaultSystemPrompt(this.options?.connectors, this.options?.actions);
}
logConnectorInitialization() {

@@ -71,11 +80,2 @@ if (isInitializingWithAllConnectors(this.options?.connectors)) {

/**
* @returns The system prompt for the Pica ToolKit
*/
async getSystemPrompt() {
if (this.options?.knowledgeAgent) {
return generateKnowledgeAgentSystemPrompt();
}
return generateDefaultSystemPrompt(this.options?.connectors, this.options?.actions);
}
/**
* @returns List of connected integrations

@@ -160,2 +160,3 @@ */

systemIds,
passthroughUrl: this.passthroughUrl,
options: this.options?.knowledgeAgent ? { ...this.options, actions: ["*"] } : this.options

@@ -162,0 +163,0 @@ });

@@ -93,1 +93,10 @@ /**

export declare function pluralize(count: number, singular: string, plural?: string): string;
/**
* Replace all instances of the original baseUrl with the passthrough URL in the knowledge string
* Handles both HTTP and HTTPS versions, with and without trailing slashes
* @param knowledge - The knowledge string to update
* @param originalBaseUrl - The original baseUrl to replace
* @param passthroughUrl - The passthrough URL to replace with
* @returns The updated knowledge string
*/
export declare function replaceBaseUrlInKnowledge(knowledge: string, originalBaseUrl: string, passthroughUrl: string): string;

@@ -207,1 +207,33 @@ /**

}
/**
* Replace all instances of the original baseUrl with the passthrough URL in the knowledge string
* Handles both HTTP and HTTPS versions, with and without trailing slashes
* @param knowledge - The knowledge string to update
* @param originalBaseUrl - The original baseUrl to replace
* @param passthroughUrl - The passthrough URL to replace with
* @returns The updated knowledge string
*/
export function replaceBaseUrlInKnowledge(knowledge, originalBaseUrl, passthroughUrl) {
if (!knowledge || !originalBaseUrl) {
return knowledge;
}
let updatedKnowledge = knowledge;
const normalizedOriginal = originalBaseUrl.replace(/\/$/, '');
const patterns = [
normalizedOriginal,
normalizedOriginal + '/',
normalizedOriginal.replace(/^https?:\/\//, 'http://'),
normalizedOriginal.replace(/^https?:\/\//, 'http://') + '/',
normalizedOriginal.replace(/^https?:\/\//, 'https://'),
normalizedOriginal.replace(/^https?:\/\//, 'https://') + '/'
];
const uniquePatterns = [...new Set(patterns)];
uniquePatterns.forEach(pattern => {
if (pattern) {
const escapedPattern = pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const regex = new RegExp(escapedPattern, 'g');
updatedKnowledge = updatedKnowledge.replace(regex, passthroughUrl);
}
});
return updatedKnowledge;
}
{
"name": "@picahq/toolkit",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pica tools for the Vercel AI SDK",

@@ -5,0 +5,0 @@ "type": "module",

@@ -44,3 +44,3 @@ # Pica ToolKit

const systemPrompt = await pica.getSystemPrompt();
const systemPrompt = pica.systemPrompt;

@@ -47,0 +47,0 @@ const result = streamText({

Sorry, the diff of this file is not supported yet