thingd 0.8.0 → 0.10.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.
@@ -1 +1 @@
1
- {"version":3,"file":"native-thing-store.d.ts","sourceRoot":"","sources":["../../src/stores/native-thing-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACX,MAAM,aAAa,CAAC;AA+ErB,qBAAa,gBAAiB,YAAW,UAAU;IAM7B,OAAO,CAAC,QAAQ,CAAC,OAAO;WAL/B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAK1D,OAAO;IAED,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQ1E,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAMvE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAMlE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAQ3E,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAIzD,OAAO,CACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,eAAe,EACxB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,QAAQ,CAAC;IAcd,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,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AO,CAAC,MAAM,CAAC;IAI/B,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9B,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAIlC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAIhC,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIpC,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIhC,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAGtC"}
@@ -1,4 +1,5 @@
1
1
  import { randomUUID } from "node:crypto";
2
+ import { createRequire } from "node:module";
2
3
  const DEFAULT_LEASE_MS = 30_000;
3
4
  const NATIVE_PACKAGE_NAME = "thingd-native";
4
5
  export class NativeThingStore {
@@ -109,11 +110,66 @@ export class NativeThingStore {
109
110
  }
110
111
  }
111
112
  async function loadNativeModule() {
113
+ const customPath = process.env.THINGD_NATIVE_PATH;
114
+ if (customPath) {
115
+ try {
116
+ const require = createRequire(import.meta.url);
117
+ const binding = require(customPath);
118
+ return { NativeThingStore: binding.NativeThingStore };
119
+ }
120
+ catch (error) {
121
+ throw new Error(`Failed to load native store from THINGD_NATIVE_PATH="${customPath}": ${error instanceof Error ? error.message : String(error)}`);
122
+ }
123
+ }
124
+ // Try direct import first
112
125
  try {
113
126
  return (await import(NATIVE_PACKAGE_NAME));
114
127
  }
115
- catch (error) {
116
- throw new Error(`The native thingd driver is not available. Run "pnpm --filter thingd-native build" before using driver: "native". ${formatUnknownError(error)}`);
128
+ catch (importError) {
129
+ // If direct import fails, try to auto-detect from known locations
130
+ try {
131
+ const { existsSync } = await import("node:fs");
132
+ const { homedir } = await import("node:os");
133
+ const { join, dirname } = await import("node:path");
134
+ const { fileURLToPath } = await import("node:url");
135
+ const candidates = [];
136
+ try {
137
+ const __dirname = dirname(fileURLToPath(import.meta.url));
138
+ // standard monorepo workspace path relative to packages/thingd/dist/stores/native-thing-store.js:
139
+ candidates.push(join(__dirname, "../../../../thingd-native/dist/thingd_native.node"));
140
+ // sibling to thingd-cli if installed in global node_modules:
141
+ candidates.push(join(__dirname, "../../../../../../thingd-native/dist/thingd_native.node"));
142
+ // inside thingd-cli node_modules:
143
+ candidates.push(join(__dirname, "../../../../thingd-native/dist/thingd_native.node"));
144
+ }
145
+ catch {
146
+ // Ignore URL/path resolution errors
147
+ }
148
+ try {
149
+ const home = homedir();
150
+ candidates.push(join(home, "Space/Programming/personal/thingd/packages/thingd-native/dist/thingd_native.node"));
151
+ candidates.push(join(home, "Space/Programming/personal/thingd-cloud/packages/thingd-native/dist/thingd_native.node"));
152
+ }
153
+ catch {
154
+ // Ignore home dir resolution errors
155
+ }
156
+ for (const candidate of candidates) {
157
+ if (existsSync(candidate)) {
158
+ try {
159
+ const require = createRequire(import.meta.url);
160
+ const binding = require(candidate);
161
+ return { NativeThingStore: binding.NativeThingStore };
162
+ }
163
+ catch {
164
+ // Ignore loading failures for this candidate, try others
165
+ }
166
+ }
167
+ }
168
+ }
169
+ catch {
170
+ // Ignore resolution errors, fall through to throwing the main error
171
+ }
172
+ throw new Error(`The native thingd driver is not available. Run "pnpm --filter thingd-native build" before using driver: "native". ${formatUnknownError(importError)}`);
117
173
  }
118
174
  }
119
175
  function objectFromNative(record) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thingd",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Object-shaped local memory for AI-native apps.",
5
5
  "type": "module",
6
6
  "author": "Sayan Mohsin",