@getenki/ai 0.1.92 → 0.2.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/browser.js ADDED
@@ -0,0 +1,16 @@
1
+ // Browser fallback for @getenki/ai
2
+ // This module is for browser environments where native bindings are not available
3
+
4
+ class EnkiAgent {
5
+ constructor(options = {}) {
6
+ throw new Error(
7
+ '@getenki/ai requires native bindings and cannot run in the browser. ' +
8
+ 'Please use this module only in Node.js environments or server-side code. ' +
9
+ 'For browser-based usage, consider using a server API instead.'
10
+ )
11
+ }
12
+ }
13
+
14
+ module.exports = {
15
+ EnkiAgent,
16
+ }
package/client.js CHANGED
@@ -1,6 +1,49 @@
1
1
  'use strict'
2
2
 
3
- const { NativeEnkiAgent, ...nativeBinding } = require('./index.js')
3
+ let cachedNativeBinding = null
4
+
5
+ function loadNativeBinding() {
6
+ if (cachedNativeBinding == null) {
7
+ cachedNativeBinding = require('./index.js')
8
+ }
9
+ return cachedNativeBinding
10
+ }
11
+
12
+ function getNativeEnkiAgent() {
13
+ return loadNativeBinding().NativeEnkiAgent
14
+ }
15
+
16
+ class NativeEnkiAgent {
17
+ constructor(...args) {
18
+ return Reflect.construct(getNativeEnkiAgent(), args, new.target)
19
+ }
20
+ }
21
+
22
+ for (const methodName of [
23
+ 'withToolsMemoryAndLlm',
24
+ 'with_tools_memory_and_llm',
25
+ 'withToolsAndLlm',
26
+ 'with_tools_and_llm',
27
+ 'withMemoryAndLlm',
28
+ 'with_memory_and_llm',
29
+ 'withLlm',
30
+ 'with_llm',
31
+ 'withToolsAndMemory',
32
+ 'with_tools_and_memory',
33
+ 'withTools',
34
+ 'with_tools',
35
+ 'withMemory',
36
+ 'with_memory',
37
+ ]) {
38
+ Object.defineProperty(NativeEnkiAgent, methodName, {
39
+ configurable: true,
40
+ enumerable: false,
41
+ get() {
42
+ const nativeMethod = getNativeEnkiAgent()[methodName]
43
+ return typeof nativeMethod === 'function' ? nativeMethod.bind(getNativeEnkiAgent()) : undefined
44
+ },
45
+ })
46
+ }
4
47
 
5
48
  const DEFAULT_AGENT_NAME = 'Agent'
6
49
  const DEFAULT_MAX_ITERATIONS = 20
@@ -19,6 +62,8 @@ class EnkiAgent {
19
62
  workspaceHome,
20
63
  } = options
21
64
 
65
+ const NativeEnkiAgent = getNativeEnkiAgent()
66
+
22
67
  this._native = new NativeEnkiAgent(
23
68
  optionalString(name, 'name'),
24
69
  optionalString(systemPromptPreamble, 'systemPromptPreamble'),
@@ -572,15 +617,12 @@ function stringifyToolResult(value) {
572
617
  return JSON.stringify(value)
573
618
  }
574
619
 
575
- module.exports = {
576
- ...nativeBinding,
577
- Agent,
578
- AgentRunResult,
579
- EnkiAgent,
580
- LlmProviderBackend,
581
- MemoryBackend,
582
- MemoryModule,
583
- NativeEnkiAgent,
584
- RunContext,
585
- Tool,
586
- }
620
+ module.exports.Agent = Agent
621
+ module.exports.AgentRunResult = AgentRunResult
622
+ module.exports.EnkiAgent = EnkiAgent
623
+ module.exports.LlmProviderBackend = LlmProviderBackend
624
+ module.exports.MemoryBackend = MemoryBackend
625
+ module.exports.MemoryModule = MemoryModule
626
+ module.exports.NativeEnkiAgent = NativeEnkiAgent
627
+ module.exports.RunContext = RunContext
628
+ module.exports.Tool = Tool
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getenki/ai",
3
- "version": "0.1.92",
3
+ "version": "0.2.0",
4
4
  "description": "Template project for writing node package with napi-rs",
5
5
  "main": "client.js",
6
6
  "types": "client.d.ts",
@@ -24,7 +24,8 @@
24
24
  "client.js",
25
25
  "index.d.ts",
26
26
  "index.js",
27
- "browser.js"
27
+ "browser.js",
28
+ "*.node"
28
29
  ],
29
30
  "napi": {
30
31
  "binaryName": "enki-ai",
@@ -111,11 +112,11 @@
111
112
  },
112
113
  "packageManager": "yarn@4.12.0",
113
114
  "optionalDependencies": {
114
- "@getenki/ai-win32-x64-msvc": "0.1.92",
115
- "@getenki/ai-win32-arm64-msvc": "0.1.92",
116
- "@getenki/ai-darwin-x64": "0.1.92",
117
- "@getenki/ai-darwin-arm64": "0.1.92",
118
- "@getenki/ai-linux-x64-gnu": "0.1.92",
119
- "@getenki/ai-linux-arm64-gnu": "0.1.92"
115
+ "@getenki/ai-win32-x64-msvc": "0.2.0",
116
+ "@getenki/ai-win32-arm64-msvc": "0.2.0",
117
+ "@getenki/ai-darwin-x64": "0.2.0",
118
+ "@getenki/ai-darwin-arm64": "0.2.0",
119
+ "@getenki/ai-linux-x64-gnu": "0.2.0",
120
+ "@getenki/ai-linux-arm64-gnu": "0.2.0"
120
121
  }
121
122
  }