@eazo/sdk 0.6.0 → 0.7.0

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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export { auth } from "./internal/capabilities/auth";
2
2
  export { device } from "./internal/capabilities/device";
3
3
  export { storage } from "./internal/capabilities/storage";
4
+ export { ai } from "./internal/capabilities/ai";
4
5
  export type { LoginOptions } from "./internal/capabilities/auth";
5
6
  export type { StorageCredentials, UploadResult } from "./internal/capabilities/storage";
7
+ export type { ChatCompletion, ChatCompletionChunk, ChatCompletionCreateParamsNonStreaming, ChatCompletionCreateParamsStreaming, } from "./internal/capabilities/ai";
6
8
  export type { User, DeviceContext, AuthState, EazoState } from "./types";
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAE1D,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACxF,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,EAAE,EAAE,MAAM,4BAA4B,CAAC;AAEhD,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACxF,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.storage = exports.device = exports.auth = void 0;
3
+ exports.ai = exports.storage = exports.device = exports.auth = void 0;
4
4
  var auth_1 = require("./internal/capabilities/auth");
5
5
  Object.defineProperty(exports, "auth", { enumerable: true, get: function () { return auth_1.auth; } });
6
6
  var device_1 = require("./internal/capabilities/device");
7
7
  Object.defineProperty(exports, "device", { enumerable: true, get: function () { return device_1.device; } });
8
8
  var storage_1 = require("./internal/capabilities/storage");
9
9
  Object.defineProperty(exports, "storage", { enumerable: true, get: function () { return storage_1.storage; } });
10
+ var ai_1 = require("./internal/capabilities/ai");
11
+ Object.defineProperty(exports, "ai", { enumerable: true, get: function () { return ai_1.ai; } });
10
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAA3C,4FAAA,IAAI,OAAA;AACb,yDAAwD;AAA/C,gGAAA,MAAM,OAAA;AACf,2DAA0D;AAAjD,kGAAA,OAAO,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAA3C,4FAAA,IAAI,OAAA;AACb,yDAAwD;AAA/C,gGAAA,MAAM,OAAA;AACf,2DAA0D;AAAjD,kGAAA,OAAO,OAAA;AAChB,iDAAgD;AAAvC,wFAAA,EAAE,OAAA"}
@@ -0,0 +1,54 @@
1
+ import OpenAI from "openai";
2
+ export type { ChatCompletion, ChatCompletionChunk } from "openai/resources/chat/completions";
3
+ export type { ChatCompletionCreateParamsNonStreaming, ChatCompletionCreateParamsStreaming, } from "openai/resources/chat/completions";
4
+ /**
5
+ * Send a chat completion request to the built-in AI (AWS Bedrock via bedrock-mantle).
6
+ *
7
+ * Uses the official `openai` package under the hood — all parameter types are
8
+ * identical to the OpenAI SDK. The response is returned as-is in OpenAI standard
9
+ * format, including streaming chunks.
10
+ *
11
+ * @example Non-streaming
12
+ * ```ts
13
+ * const result = await ai.chat({
14
+ * model: 'deepseek.v3.1',
15
+ * messages: [{ role: 'user', content: 'Hello!' }],
16
+ * });
17
+ * console.log(result.choices[0].message.content);
18
+ * ```
19
+ *
20
+ * @example Streaming
21
+ * ```ts
22
+ * const stream = await ai.chat({
23
+ * model: 'deepseek.v3.1',
24
+ * messages: [{ role: 'user', content: 'Tell me a story.' }],
25
+ * stream: true,
26
+ * });
27
+ * for await (const chunk of stream) {
28
+ * process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
29
+ * }
30
+ * ```
31
+ *
32
+ * @example Function calling
33
+ * ```ts
34
+ * const result = await ai.chat({
35
+ * model: 'deepseek.v3.1',
36
+ * messages: [{ role: 'user', content: 'What is the weather in Shanghai?' }],
37
+ * tools: [{ type: 'function', function: { name: 'get_weather', description: '...', parameters: {...} } }],
38
+ * tool_choice: 'auto',
39
+ * });
40
+ * ```
41
+ */
42
+ declare function chat(params: OpenAI.Chat.ChatCompletionCreateParamsNonStreaming): Promise<OpenAI.Chat.ChatCompletion>;
43
+ declare function chat(params: OpenAI.Chat.ChatCompletionCreateParamsStreaming): Promise<AsyncIterable<OpenAI.Chat.ChatCompletionChunk>>;
44
+ export declare const ai: {
45
+ /**
46
+ * Configure the private key for AI requests.
47
+ * Alternative to setting the EAZO_PRIVATE_KEY environment variable.
48
+ */
49
+ configure(opts: {
50
+ privateKey: string;
51
+ }): void;
52
+ chat: typeof chat;
53
+ };
54
+ //# sourceMappingURL=ai.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/ai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAmC5B,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7F,YAAY,EACV,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,mCAAmC,CAAC;AAM3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,iBAAe,IAAI,CACjB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,sCAAsC,GACzD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AACvC,iBAAe,IAAI,CACjB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,mCAAmC,GACtD,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAwB3D,eAAO,MAAM,EAAE;IACb;;;OAGG;oBACa;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;;CAK9C,CAAC"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ai = void 0;
7
+ const openai_1 = __importDefault(require("openai"));
8
+ const config_1 = require("../config");
9
+ // ---------------------------------------------------------------------------
10
+ // Private key storage
11
+ // ---------------------------------------------------------------------------
12
+ let privateKey = null;
13
+ function setPrivateKey(key) {
14
+ privateKey = key;
15
+ }
16
+ function getPrivateKey() {
17
+ if (privateKey)
18
+ return privateKey;
19
+ if (typeof process !== "undefined" && process.env.EAZO_PRIVATE_KEY) {
20
+ return process.env.EAZO_PRIVATE_KEY;
21
+ }
22
+ return null;
23
+ }
24
+ function buildClient() {
25
+ const key = getPrivateKey();
26
+ if (!key) {
27
+ throw new Error("@eazo/sdk: missing private key. Set EAZO_PRIVATE_KEY env var or call ai.configure({ privateKey }).");
28
+ }
29
+ return new openai_1.default({
30
+ baseURL: `${(0, config_1.getApiBase)()}/v1`,
31
+ apiKey: key,
32
+ });
33
+ }
34
+ async function chat(params) {
35
+ const client = buildClient();
36
+ if (params.stream) {
37
+ // openai SDK Stream is itself an AsyncIterable<ChatCompletionChunk>
38
+ return client.chat.completions.create(params);
39
+ }
40
+ return client.chat.completions.create(params);
41
+ }
42
+ // ---------------------------------------------------------------------------
43
+ // Public API
44
+ // ---------------------------------------------------------------------------
45
+ exports.ai = {
46
+ /**
47
+ * Configure the private key for AI requests.
48
+ * Alternative to setting the EAZO_PRIVATE_KEY environment variable.
49
+ */
50
+ configure(opts) {
51
+ setPrivateKey(opts.privateKey);
52
+ },
53
+ chat,
54
+ };
55
+ //# sourceMappingURL=ai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ai.js","sourceRoot":"","sources":["../../../src/internal/capabilities/ai.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,sCAAuC;AAEvC,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,IAAI,UAAU,GAAkB,IAAI,CAAC;AAErC,SAAS,aAAa,CAAC,GAAW;IAChC,UAAU,GAAG,GAAG,CAAC;AACnB,CAAC;AAED,SAAS,aAAa;IACpB,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC;IAClC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACnE,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,WAAW;IAClB,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,gBAAM,CAAC;QAChB,OAAO,EAAE,GAAG,IAAA,mBAAU,GAAE,KAAK;QAC7B,MAAM,EAAE,GAAG;KACZ,CAAC,CAAC;AACL,CAAC;AAyDD,KAAK,UAAU,IAAI,CACjB,MAEmD;IAEnD,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAE7B,IAAK,MAA0D,CAAC,MAAM,EAAE,CAAC;QACvE,oEAAoE;QACpE,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CACnC,MAAyD,CACC,CAAC;IAC/D,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CACnC,MAA4D,CAC7D,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAEjE,QAAA,EAAE,GAAG;IAChB;;;OAGG;IACH,SAAS,CAAC,IAA4B;QACpC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,IAAI;CACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eazo/sdk",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Eazo platform SDK — capability-first API for web apps that run on Eazo Mobile and the web browser",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -45,7 +45,8 @@
45
45
  "dependencies": {
46
46
  "@radix-ui/react-dialog": "^1.1.4",
47
47
  "authing-js-sdk": "^4.23.55",
48
- "elliptic": "^6.6.1"
48
+ "elliptic": "^6.6.1",
49
+ "openai": "^6.34.0"
49
50
  },
50
51
  "peerDependencies": {
51
52
  "react": ">=18"