Skip to content

Commit d014c57

Browse files
asprouseclaude
andcommitted
feat: add purchase order agent integration
Add @takeshape/purchase-order-chat integration with: - Purchase order agent page at /purchase-order-agent - BigCommerce GraphQL proxy route to avoid CORS issues - Tailwind config for library styles - Environment variable documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7fd9b69 commit d014c57

7 files changed

Lines changed: 2263 additions & 51 deletions

File tree

.mcp.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"mcpServers": {
3+
"playwright": {
4+
"type": "stdio",
5+
"command": "npx",
6+
"args": ["@playwright/mcp@latest"],
7+
"env": {}
8+
},
9+
"context7": {
10+
"type": "http",
11+
"url": "https://mcp.context7.com/mcp",
12+
"headers": {
13+
"CONTEXT7_API_KEY": "${CONTEXT7_API_KEY:-}"
14+
}
15+
},
16+
"shortcut": {
17+
"type": "stdio",
18+
"command": "npx",
19+
"args": ["-y", "@shortcut/mcp@latest"],
20+
"env": {
21+
"SHORTCUT_API_TOKEN": "${SHORTCUT_API_TOKEN:-}"
22+
}
23+
}
24+
}
25+
}

core/.env.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,17 @@ TURBO_REMOTE_CACHE_SIGNATURE_KEY=
4040
# https://nextjs.org/docs/app/building-your-application/caching#data-cache
4141
# This sets a sensible revalidation target for cached requests
4242
DEFAULT_REVALIDATE_TARGET=3600
43+
44+
# TakeShape Purchase Order Agent Configuration
45+
# Required: Get these from your TakeShape dashboard
46+
NEXT_PUBLIC_TAKESHAPE_PROJECT_ID=
47+
NEXT_PUBLIC_TAKESHAPE_API_KEY=
48+
NEXT_PUBLIC_BIGCOMMERCE_CHANNEL_ID=1
49+
50+
# Optional: Defaults to https://api.takeshape.io
51+
# NEXT_PUBLIC_TAKESHAPE_ORIGIN=https://api.takeshape.io
52+
# NEXT_PUBLIC_TAKESHAPE_SSE_ORIGIN=https://sse.takeshape.io
53+
54+
# Optional: Agent configuration (defaults shown)
55+
# NEXT_PUBLIC_TAKESHAPE_AGENT_NAME=purchase-order-agent
56+
# NEXT_PUBLIC_TAKESHAPE_INPUT_NAME=purchaseOrder
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use client';
2+
3+
import { useRouter } from '~/i18n/routing';
4+
import { PurchaseOrderChat } from '@takeshape/purchase-order-chat';
5+
6+
const takeShape = {
7+
projectId: process.env.NEXT_PUBLIC_TAKESHAPE_PROJECT_ID!,
8+
apiKey: process.env.NEXT_PUBLIC_TAKESHAPE_API_KEY!,
9+
origin: process.env.NEXT_PUBLIC_TAKESHAPE_ORIGIN ?? 'https://api.takeshape.io',
10+
sseOrigin: process.env.NEXT_PUBLIC_TAKESHAPE_SSE_ORIGIN ?? process.env.NEXT_PUBLIC_TAKESHAPE_ORIGIN ?? 'https://api.takeshape.io',
11+
};
12+
13+
const bigCommerce = {
14+
endpoint: '/api/bigcommerce/graphql',
15+
channelId: Number(process.env.NEXT_PUBLIC_BIGCOMMERCE_CHANNEL_ID),
16+
};
17+
18+
const agentName = process.env.NEXT_PUBLIC_TAKESHAPE_AGENT_NAME ?? 'purchase-order-agent';
19+
const inputName = process.env.NEXT_PUBLIC_TAKESHAPE_INPUT_NAME ?? 'purchaseOrder';
20+
21+
export default function PurchaseOrderAgentPage() {
22+
const router = useRouter();
23+
24+
return (
25+
<div className="container mx-auto px-4 py-8">
26+
<PurchaseOrderChat
27+
takeShape={takeShape}
28+
bigCommerce={bigCommerce}
29+
agentName={agentName}
30+
inputName={inputName}
31+
onViewProduct={(product) => product.path && router.push(product.path)}
32+
onCheckout={(checkoutUrl) => router.push(checkoutUrl)}
33+
/>
34+
</div>
35+
);
36+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { NextRequest, NextResponse } from 'next/server';
2+
3+
const BIGCOMMERCE_STORE_HASH = process.env.BIGCOMMERCE_STORE_HASH;
4+
const BIGCOMMERCE_STOREFRONT_TOKEN = process.env.BIGCOMMERCE_STOREFRONT_TOKEN;
5+
6+
function getBigCommerceEndpoint(storeHash: string): string {
7+
return `https://store-${storeHash}.mybigcommerce.com/graphql`;
8+
}
9+
10+
export async function POST(request: NextRequest) {
11+
if (!BIGCOMMERCE_STORE_HASH || !BIGCOMMERCE_STOREFRONT_TOKEN) {
12+
return NextResponse.json(
13+
{ errors: [{ message: 'BigCommerce configuration missing' }] },
14+
{ status: 500 }
15+
);
16+
}
17+
18+
try {
19+
const body = await request.json();
20+
21+
const response = await fetch(getBigCommerceEndpoint(BIGCOMMERCE_STORE_HASH), {
22+
method: 'POST',
23+
headers: {
24+
'Content-Type': 'application/json',
25+
'Authorization': `Bearer ${BIGCOMMERCE_STOREFRONT_TOKEN}`,
26+
},
27+
body: JSON.stringify(body),
28+
});
29+
30+
const data = await response.json();
31+
32+
return NextResponse.json(data, { status: response.status });
33+
} catch (error) {
34+
console.error('[BigCommerce Proxy] Error:', error);
35+
return NextResponse.json(
36+
{ errors: [{ message: 'Failed to proxy request to BigCommerce' }] },
37+
{ status: 500 }
38+
);
39+
}
40+
}

core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@radix-ui/react-toggle-group": "^1.1.10",
3636
"@radix-ui/react-tooltip": "^1.2.7",
3737
"@t3-oss/env-core": "^0.13.6",
38+
"@takeshape/purchase-order-chat": "file:../../bigcommerce-app/packages/purchase-order-chat",
3839
"@upstash/redis": "^1.35.0",
3940
"@vercel/analytics": "^1.5.0",
4041
"@vercel/functions": "^2.2.12",

core/tailwind.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const config = {
44
'./app/**/*.{ts,tsx}',
55
'./components/**/*.{ts,tsx}',
66
'./vibes/**/*.{ts,tsx}',
7+
'./node_modules/@takeshape/purchase-order-chat/src/**/*.{ts,tsx}',
78
'!./node_modules/**', // Exclude everything in node_modules to speed up builds
89
],
910
theme: {

0 commit comments

Comments
 (0)