@gram-ai/create-function 0.12.1 → 0.12.2

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.
@@ -392,6 +392,45 @@ const responsePromise = g.handleToolCall(
392
392
  setTimeout(() => controller.abort(), 5000);
393
393
  ```
394
394
 
395
+ ## OAuth / Authentication
396
+
397
+ For tools that need to access OAuth-protected APIs, Gram Functions supports automatic OAuth token injection. Configure the `authInput` option when creating your Gram instance, and the OAuth access token will be available through `ctx.env`.
398
+
399
+ For full setup instructions including configuring OAuth providers, see the [Add OAuth documentation](https://www.getgram.ai/docs/gram-functions/add-oauth).
400
+
401
+ ### Configuring OAuth
402
+
403
+ Specify which environment variable should receive the OAuth access token:
404
+
405
+ ```typescript
406
+ import { Gram } from "@gram-ai/functions";
407
+ import * as z from "zod/mini";
408
+
409
+ const gram = new Gram({
410
+ envSchema: {
411
+ OAUTH_TOKEN: z.string().describe("OAuth access token"),
412
+ },
413
+ authInput: {
414
+ oauthVariable: "OAUTH_TOKEN",
415
+ },
416
+ }).tool({
417
+ name: "get_user_profile",
418
+ description: "Fetch the authenticated user's profile",
419
+ inputSchema: {},
420
+ async execute(ctx, input) {
421
+ const response = await fetch("https://api.example.com/me", {
422
+ headers: {
423
+ Authorization: `Bearer ${ctx.env.OAUTH_TOKEN}`,
424
+ },
425
+ signal: ctx.signal,
426
+ });
427
+ return ctx.json(await response.json());
428
+ },
429
+ });
430
+ ```
431
+
432
+ When deployed to Gram, the platform handles the OAuth flow with users and automatically injects the access token into the specified environment variable before each tool execution.
433
+
395
434
  ## Type Safety
396
435
 
397
436
  The framework provides full TypeScript type inference:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gram-ai/create-function",
4
- "version": "0.12.1",
4
+ "version": "0.12.2",
5
5
  "description": "Build AI tools and deploy them to getgram.ai",
6
6
  "keywords": [],
7
7
  "homepage": "https://github.com/speakeasy-api/gram",
@@ -38,7 +38,7 @@
38
38
  "prettier": "^3.6.2",
39
39
  "typescript": "5.9.3",
40
40
  "zod": "^3.25.76",
41
- "@gram-ai/functions": "^0.12.1"
41
+ "@gram-ai/functions": "^0.12.2"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "tsc --noEmit false"