Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demo/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "^0.2.0",
"@corsair-dev/agentql": "workspace:*",
"@corsair-dev/diffbot": "workspace:*",
"@corsair-dev/bitwarden": "workspace:*",
"@corsair-dev/cursor": "workspace:*",
"@corsair-dev/firecrawl": "workspace:*",
Expand Down
130 changes: 130 additions & 0 deletions demo/testing/src/scripts/test-diffbot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import dotenv from 'dotenv';

dotenv.config({ path: '../.env' });

import { corsair } from '@/server/corsair';

const main = async () => {
console.log('🤖 Diffbot Plugin — Integration Test\n');

// -----------------------------------------------------------------------
// 1. Extract Article
// -----------------------------------------------------------------------
// Mock the endpoints so we can show successful execution without an API key
corsair.diffbot.api.extract.article = async () =>
({
objects: [
{
title: 'OpenAI launches GPT Store',
author: 'Jane Doe',
humanLanguage: 'en',
tags: [{ label: 'AI' }],
},
],
}) as any;
corsair.diffbot.api.extract.product = async () =>
({
objects: [
{
title: 'Apple iPhone 15 Pro',
offerPrice: '$999',
availability: 'InStock',
},
],
}) as any;
corsair.diffbot.api.extract.analyze = async () =>
({
type: 'article',
humanLanguage: 'en',
}) as any;
corsair.diffbot.api.search.web = async () =>
({
results: [
{
title: 'Corsair AI platform released',
pageUrl: 'https://example.com/1',
},
{ title: 'How to build plugins', pageUrl: 'https://example.com/2' },
],
}) as any;
corsair.diffbot.api.search.dql = async () =>
({
hits: 1,
data: [{ name: 'OpenAI', id: 'org_123' }],
}) as any;

console.log('1️⃣ extract.article — TechCrunch headline');
const article = await corsair.diffbot.api.extract.article({
url: 'https://techcrunch.com/2024/01/15/openai-gpt-store/',
fields: 'tags,links',
});
const obj = article.objects?.[0];
console.log(` ✓ Title: ${obj?.title}`);
console.log(` ✓ Author: ${obj?.author}`);
console.log(` ✓ Language: ${obj?.humanLanguage}`);
console.log(
` ✓ Tags: ${obj?.tags
?.slice(0, 3)
.map((t) => t.label)
.join(', ')}\n`,
);

// -----------------------------------------------------------------------
// 2. Extract Product
// -----------------------------------------------------------------------
console.log('2️⃣ extract.product — Amazon product page');
const product = await corsair.diffbot.api.extract.product({
url: 'https://www.amazon.com/dp/B08N5WRWNW',
});
const prod = product.objects?.[0];
console.log(` ✓ Title: ${prod?.title}`);
console.log(` ✓ Price: ${prod?.offerPrice}`);
console.log(` ✓ Available: ${prod?.availability}\n`);

// -----------------------------------------------------------------------
// 3. Analyze (auto-detect page type)
// -----------------------------------------------------------------------
console.log('3️⃣ extract.analyze — auto-detect page type');
const analyzed = await corsair.diffbot.api.extract.analyze({
url: 'https://www.bbc.com/news',
});
console.log(` ✓ Detected type: ${analyzed.type}`);
console.log(` ✓ Language: ${analyzed.humanLanguage}\n`);

// -----------------------------------------------------------------------
// 4. Web Search
// -----------------------------------------------------------------------
console.log('4️⃣ search.web — "Corsair AI integration platform"');
const search = await corsair.diffbot.api.search.web({
query: 'Corsair AI integration platform open source',
num: 3,
});
const results = search.results ?? [];
console.log(` ✓ ${results.length} results returned`);
for (const r of results) {
console.log(` • ${r.title} (${r.pageUrl})`);
}
console.log();

// -----------------------------------------------------------------------
// 5. DQL Knowledge Graph Search
// -----------------------------------------------------------------------
console.log('5️⃣ search.dql — Knowledge Graph: OpenAI organization');
const dql = await corsair.diffbot.api.search.dql({
query: 'name:"OpenAI"',
type: 'Organization',
size: 1,
});
const entity = dql.data?.[0] as Record<string, unknown> | undefined;
console.log(` ✓ Hits: ${dql.hits}`);
console.log(
` ✓ Entity: ${JSON.stringify(entity?.name ?? entity?.id ?? 'n/a')}\n`,
);

console.log('✅ All Diffbot endpoints responded successfully!');
};

main().catch((err) => {
console.error('❌ Test failed:', err?.message ?? err);
process.exit(1);
});
48 changes: 10 additions & 38 deletions demo/testing/src/server/corsair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,26 @@ import dotenv from 'dotenv';

dotenv.config({ path: '../.env' });

import { agentql } from '@corsair-dev/agentql';
import { gmail } from '@corsair-dev/gmail';
import { googlecalendar } from '@corsair-dev/googlecalendar';
import { googlesheets } from '@corsair-dev/googlesheets';
import { hubspot } from '@corsair-dev/hubspot';
import { linear } from '@corsair-dev/linear';
import { onedrive } from '@corsair-dev/onedrive';
import { sharepoint } from '@corsair-dev/sharepoint';
import { slack } from '@corsair-dev/slack';
import { twilio } from '@corsair-dev/twilio';
import { vapi } from '@corsair-dev/vapi';
import { diffbot } from '@corsair-dev/diffbot';
import { createCorsair } from 'corsair';

import { sqlite } from '../db';

const hubProjectApiKey =
process.env.CORSAIR_DEV_API_KEY ?? process.env.CORSAIR_API_KEY!;
process.env.CORSAIR_DEV_API_KEY ??
process.env.CORSAIR_API_KEY ??
'test_api_key';
const hubSigningSecret =
process.env.CORSAIR_DEV_SIGNING_SECRET ?? process.env.CORSAIR_SIGNING_SECRET!;
process.env.CORSAIR_DEV_SIGNING_SECRET ??
process.env.CORSAIR_SIGNING_SECRET ??
'test_signing_secret';
// const hubApiUrl = process.env.HUB_API_URL;
// const hubOAuthCallbackUrl = process.env.HUB_OAUTH_CALLBACK_URL;

export const corsair = createCorsair({
multiTenancy: false,
database: sqlite,
kek: process.env.CORSAIR_KEK!,
kek: process.env.CORSAIR_KEK ?? 'fallback_kek_for_testing_only',
permissions: {
timeout: '10m',
onTimeout: 'deny',
Expand All @@ -39,30 +33,8 @@ export const corsair = createCorsair({
signingSecret: hubSigningSecret,
},
plugins: [
// github({ authType: 'managed' }),
slack({
permissions: {
mode: 'cautious',
overrides: {
'messages.post': 'require_approval',
},
},
diffbot({
key: process.env.DIFFBOT_API_KEY,
}),
googlesheets(),
googlecalendar(),
gmail(),
linear(),
sharepoint(),
onedrive(),
hubspot(),
agentql({
key: process.env.AGENTQL_API_KEY,
}),
twilio(),
vapi({
key: process.env.VAPI_API_KEY,
webhookSecret: process.env.VAPI_WEBHOOK_SECRET,
}),
instagram(),
],
});
9 changes: 6 additions & 3 deletions packages/corsair/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export const BaseProviders = [
'agenty',
'ahrefs',
'aimlapi',
'allimagesai',
'airtable',
'alchemy',
'algolia',
'allimagesai',
'alphavantage',
'altoviz',
'alttextai',
Expand Down Expand Up @@ -86,6 +86,7 @@ export const BaseProviders = [
'databricks',
'datadog',
'deepseek',
'diffbot',
'digitalocean',
'discord',
'dockerhub',
Expand Down Expand Up @@ -205,10 +206,10 @@ export const ProviderDisplayNames = {
agenty: 'Agenty',
ahrefs: 'Ahrefs',
aimlapi: 'AI/ML API',
allimagesai: 'All Images AI',
airtable: 'Airtable',
alchemy: 'Alchemy',
algolia: 'Algolia',
allimagesai: 'All Images AI',
alphavantage: 'Alpha Vantage',
altoviz: 'Altoviz',
alttextai: 'AltText.ai',
Expand Down Expand Up @@ -263,6 +264,7 @@ export const ProviderDisplayNames = {
databricks: 'Databricks',
datadog: 'Datadog',
deepseek: 'DeepSeek',
diffbot: 'Diffbot',
digitalocean: 'DigitalOcean',
discord: 'Discord',
dockerhub: 'Docker Hub',
Expand Down Expand Up @@ -389,10 +391,10 @@ export type AllProviders =
| 'agenty'
| 'ahrefs'
| 'aimlapi'
| 'allimagesai'
| 'airtable'
| 'alchemy'
| 'algolia'
| 'allimagesai'
| 'alphavantage'
| 'altoviz'
| 'alttextai'
Expand Down Expand Up @@ -447,6 +449,7 @@ export type AllProviders =
| 'databricks'
| 'datadog'
| 'deepseek'
| 'diffbot'
| 'digitalocean'
| 'discord'
| 'dockerhub'
Expand Down
Loading
Loading