@base44-preview/sdk 0.8.39-pr.231.0f61b59 → 0.8.39-pr.231.1187092

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.
@@ -35,10 +35,11 @@ export interface AiGatewayModuleConfig {
35
35
  * setup with the underlying model provider required.
36
36
  *
37
37
  * Call `connection()` from a backend function rather than the browser. That's
38
- * where you can wire tools that read and write your app's own entities and
39
- * business logic without shipping that logic to the client. It also keeps the
40
- * gateway token out of the browser, where it could be stolen and used to
41
- * spend against your app's shared credit quota.
38
+ * where your instructions, tools, and business logic stay server-side, where
39
+ * users can't inspect or tamper with them, and where you can enforce your own
40
+ * auth checks, rate limits, or spend limits around the call. `token` is the
41
+ * caller's own session token, the same one the SDK already uses for every
42
+ * other call, so calling from the browser doesn't expose anything new.
42
43
  *
43
44
  * ## Models
44
45
  *
@@ -78,8 +79,10 @@ export interface AiGatewayModule {
78
79
  * @example
79
80
  * ```typescript
80
81
  * // Call a model directly with the OpenAI SDK, inside a backend function
82
+ * import { createClientFromRequest } from "@base44/sdk";
81
83
  * import OpenAI from "openai";
82
84
  *
85
+ * const base44 = createClientFromRequest(request);
83
86
  * const { baseURL, token } = base44.aiGateway.connection();
84
87
  * const openai = new OpenAI({ baseURL, apiKey: token });
85
88
  *
@@ -94,11 +97,13 @@ export interface AiGatewayModule {
94
97
  * @example
95
98
  * ```typescript
96
99
  * // Review a return request with a tool-using agent, inside a backend function
100
+ * import { createClientFromRequest } from "@base44/sdk";
97
101
  * import { ToolLoopAgent, tool, stepCountIs, hasToolCall } from "ai";
98
102
  * import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
99
103
  * import { z } from "zod";
100
104
  *
101
- * const request = await base44.entities.ReturnRequest.get(returnId);
105
+ * const base44 = createClientFromRequest(request);
106
+ * const returnRequest = await base44.entities.ReturnRequest.get(returnId);
102
107
  * const { baseURL, token } = base44.aiGateway.connection();
103
108
  * // Point any OpenAI-compatible client at `baseURL` with `apiKey: token`.
104
109
  * const models = createOpenAICompatible({ name: "base44", baseURL, apiKey: token });
@@ -113,7 +118,7 @@ export interface AiGatewayModule {
113
118
  * description: "This customer's past orders, optionally filtered by status",
114
119
  * inputSchema: z.object({ status: z.string().optional() }),
115
120
  * execute: ({ status }) => {
116
- * const query = { customer_email: request.customer_email };
121
+ * const query = { customer_email: returnRequest.customer_email };
117
122
  * if (status) query.status = status;
118
123
  * return base44.entities.Order.filter(query, "-created_date", 50);
119
124
  * },
@@ -128,7 +133,7 @@ export interface AiGatewayModule {
128
133
  * stopWhen: [stepCountIs(8), hasToolCall("submitVerdict")],
129
134
  * });
130
135
  *
131
- * await agent.generate({ prompt: `Review this return request: ${JSON.stringify(request)}` });
136
+ * await agent.generate({ prompt: `Review this return request: ${JSON.stringify(returnRequest)}` });
132
137
  * ```
133
138
  */
134
139
  connection(): AiGatewayConnection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.39-pr.231.0f61b59",
3
+ "version": "0.8.39-pr.231.1187092",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",