Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pickforge/auth",
"version": "0.6.0",
"version": "0.7.0",
"description": "UI-free Supabase Auth and entitlements wrapper for Pickforge apps.",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/billing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pickforge/billing",
"version": "0.6.0",
"version": "0.7.0",
"description": "UI-free Stripe billing and credit-ledger helpers for Pickforge apps.",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/brand/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pickforge/brand",
"version": "0.6.0",
"version": "0.7.0",
"description": "Pickforge CSS tokens, fonts, reset, and primitives.",
"license": "MIT",
"repository": {
Expand Down
16 changes: 15 additions & 1 deletion packages/edge-shared/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

Deno-compatible helpers for Pickforge Edge Functions. Clients are injected structurally, so app functions can use Supabase service clients without coupling this package to a specific SDK import.

`assertRouteRequest` accepts only the hosted-router wire shape: `commandText` plus optional `context.projectName`, `context.chatNames`, and `context.widgetLabels`. Command text is user-authored and passed through unchanged; attached context is guarded against paths, host identifiers, tailnet IPs, and long serial-like tokens with `boundary_violation`.

`createOperatorRouterHandler` composes bearer-token authentication, request boundary validation, idempotent credit debiting, and an injected chat completion. A replayed idempotency key returns its stored proposal without another model call.

Hosted routing is limited to 10 uncached attempts per user in each 10-second window. Its responses are `200` with a proposal, `402` for insufficient credits, `429` for `rate_limited`, boundary/auth `4xx`, and `5xx` for server or provider failures.

## Usage

```ts
Expand All @@ -13,7 +19,7 @@ import {
jsonResponse,
newIdempotencyKey,
requireEntitlement,
} from "npm:@pickforge/edge-shared@0.4.0";
} from "npm:@pickforge/edge-shared@0.7.0";

Deno.serve(async (req) => {
const supabase = createClient(
Expand Down Expand Up @@ -57,6 +63,14 @@ Deno.serve(async (req) => {
- Use `SUPABASE_SERVICE_ROLE_KEY` only in server-side Edge Functions.
- Deploy app Edge Functions with access to `SUPABASE_URL` and `SUPABASE_SERVICE_ROLE_KEY`.

## Hosted function environment

`operator-router` uses `SUPABASE_URL`, `SUPABASE_ANON_KEY`, `SUPABASE_SERVICE_ROLE_KEY`, and `OPENAI_API_KEY`. Optional settings are `OPENAI_ROUTER_MODEL` (default `gpt-5.4-mini`), `OPENAI_BASE_URL` (default `https://api.openai.com/v1`), and `ROUTER_CREDIT_COST_CENTS` (default `2`). It sets `verify_jwt = false` because `getUserFromRequest` verifies the caller bearer token in the handler; the service-role client is used only for the debit RPC.

`create-credit-checkout` uses `SUPABASE_URL`, `SUPABASE_ANON_KEY`, `STRIPE_SECRET_KEY`, `STRIPE_PRICE_PACK_10`, `STRIPE_PRICE_PACK_25`, `STRIPE_PRICE_PACK_50`, `CHECKOUT_SUCCESS_URL`, and `CHECKOUT_CANCEL_URL`. Its accepted body is `{ "pack": "p10" | "p25" | "p50" }`.

The new edge-shared exports require a `0.7.0` package publish before deploying functions that import them.

## Cross-repo imports

Supabase `_shared/` relative imports only work inside one functions tree. Pickforge app-specific Edge Functions live in other repos, so shared Edge utilities ship as `@pickforge/edge-shared` and are imported with `npm:` specifiers from each repo.
2 changes: 1 addition & 1 deletion packages/edge-shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pickforge/edge-shared",
"version": "0.6.0",
"version": "0.7.0",
"description": "Deno-compatible shared helpers for Pickforge Edge Functions.",
"license": "MIT",
"repository": {
Expand Down
Loading