@oneie/sdk 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/README.md +74 -0
- package/dist/client.d.ts +29 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +88 -0
- package/dist/client.js.map +1 -0
- package/dist/handoff.d.ts +3 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +15 -0
- package/dist/handoff.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/launch.d.ts +16 -0
- package/dist/launch.d.ts.map +1 -0
- package/dist/launch.js +49 -0
- package/dist/launch.js.map +1 -0
- package/dist/storage.d.ts +9 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +42 -0
- package/dist/storage.js.map +1 -0
- package/dist/telemetry.d.ts +4 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +60 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/types.d.ts +81 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/dist/urls.d.ts +11 -0
- package/dist/urls.d.ts.map +1 -0
- package/dist/urls.js +35 -0
- package/dist/urls.js.map +1 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# @oneie/sdk
|
|
2
|
+
|
|
3
|
+
Client SDK for the ONE substrate — signals, units, persist, launch handoff.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @oneie/sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { getApiUrl, resolveApiKey } from "@oneie/sdk/urls";
|
|
13
|
+
import * as storage from "@oneie/sdk/storage";
|
|
14
|
+
|
|
15
|
+
// Resolve base URL (env: ONEIE_API_URL, default: https://api.one.ie)
|
|
16
|
+
const url = getApiUrl();
|
|
17
|
+
|
|
18
|
+
// Storage CRUD
|
|
19
|
+
await storage.put("my-key", { hello: "world" }, { apiKey: resolveApiKey() });
|
|
20
|
+
const value = await storage.get("my-key");
|
|
21
|
+
await storage.del("my-key");
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Modules
|
|
25
|
+
|
|
26
|
+
| Import | What |
|
|
27
|
+
|--------|------|
|
|
28
|
+
| `@oneie/sdk` | Types + all re-exports |
|
|
29
|
+
| `@oneie/sdk/urls` | `getApiUrl()`, `resolveApiKey()`, `resolveBaseUrl()` |
|
|
30
|
+
| `@oneie/sdk/storage` | `get()`, `put()`, `del()`, `list()` — `/api/storage/*` |
|
|
31
|
+
| `@oneie/sdk/launch` | `launchToken()` — generate agent launch tokens |
|
|
32
|
+
| `@oneie/sdk/handoff` | Token handoff helpers |
|
|
33
|
+
|
|
34
|
+
## Types
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import type { SdkConfig, OneSdkError, Outcome } from "@oneie/sdk";
|
|
38
|
+
|
|
39
|
+
// Outcome — the 4-result type from the substrate
|
|
40
|
+
type Outcome<T> =
|
|
41
|
+
| { result: T } // success
|
|
42
|
+
| { timeout: true } // slow, not bad
|
|
43
|
+
| { dissolved: true } // missing unit/capability
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Environment Variables
|
|
47
|
+
|
|
48
|
+
| Variable | Default | Purpose |
|
|
49
|
+
|----------|---------|---------|
|
|
50
|
+
| `ONEIE_API_URL` | `https://api.one.ie` | Substrate API base URL |
|
|
51
|
+
| `ONEIE_API_KEY` | — | Bearer token |
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
[one.ie/free-license](https://one.ie/free-license)
|
|
56
|
+
|
|
57
|
+
## Telemetry
|
|
58
|
+
|
|
59
|
+
`@oneie/sdk` sends anonymous usage signals to the ONE substrate to improve routing quality.
|
|
60
|
+
|
|
61
|
+
**What we send:** package version, method name, outcome type, anonymous session ID (hex hash — no PII), call latency.
|
|
62
|
+
|
|
63
|
+
**What we never send:** your API key, user IDs, email addresses, file paths, or any personally identifiable information.
|
|
64
|
+
|
|
65
|
+
**Opt out:**
|
|
66
|
+
```bash
|
|
67
|
+
# Environment variable (per-session)
|
|
68
|
+
ONEIE_TELEMETRY_DISABLE=1 node your-script.js
|
|
69
|
+
|
|
70
|
+
# Permanent opt-out
|
|
71
|
+
echo '{"telemetry":false}' > ~/.oneie/config.json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
When opt-out is active, `oneie --version` prints `telemetry: disabled`.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { DecayResponse, HighwaysResponse, HypothesesResponse, MarkDimsResponse, Outcome, SdkConfig, SignalResponse } from "./types.js";
|
|
2
|
+
export declare class SubstrateClient {
|
|
3
|
+
private readonly baseUrl;
|
|
4
|
+
private readonly apiKey;
|
|
5
|
+
constructor(cfg?: SdkConfig);
|
|
6
|
+
signal(sender: string, receiver: string, data?: unknown): Promise<SignalResponse>;
|
|
7
|
+
ask(receiver: string, data?: unknown, timeout?: number, from?: string): Promise<Outcome<unknown>>;
|
|
8
|
+
mark(edge: string, scores?: Partial<{
|
|
9
|
+
fit: number;
|
|
10
|
+
form: number;
|
|
11
|
+
truth: number;
|
|
12
|
+
taste: number;
|
|
13
|
+
}>): Promise<MarkDimsResponse>;
|
|
14
|
+
warn(edge: string, scores?: Partial<{
|
|
15
|
+
fit: number;
|
|
16
|
+
form: number;
|
|
17
|
+
truth: number;
|
|
18
|
+
taste: number;
|
|
19
|
+
}>): Promise<MarkDimsResponse>;
|
|
20
|
+
fade(trailRate?: number, resistanceRate?: number): Promise<DecayResponse>;
|
|
21
|
+
highways(limit?: number): Promise<HighwaysResponse>;
|
|
22
|
+
recall(status?: string): Promise<HypothesesResponse>;
|
|
23
|
+
reveal(uid: string): Promise<unknown>;
|
|
24
|
+
forget(uid: string): Promise<unknown>;
|
|
25
|
+
frontier(uid: string): Promise<unknown>;
|
|
26
|
+
know(): Promise<unknown>;
|
|
27
|
+
select(): Promise<unknown>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,SAAS,EACT,cAAc,EACf,MAAM,YAAY,CAAC;AAsBpB,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;gBAEhC,GAAG,GAAE,SAAc;IAKzB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;IAWjF,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAiBjG,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,GAC5E,OAAO,CAAC,gBAAgB,CAAC;IAWtB,IAAI,CACR,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,GAC5E,OAAO,CAAC,gBAAgB,CAAC;IAWtB,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAWzE,QAAQ,CAAC,KAAK,SAAK,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAW/C,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAYpD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWrC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWrC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAWvC,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAMxB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;CAUjC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { OneSdkError } from "./types.js";
|
|
2
|
+
import { resolveApiKey, resolveBaseUrl } from "./urls.js";
|
|
3
|
+
import { emit } from "./telemetry.js";
|
|
4
|
+
async function req(baseUrl, path, init = {}, apiKey) {
|
|
5
|
+
const headers = { "Content-Type": "application/json" };
|
|
6
|
+
if (apiKey)
|
|
7
|
+
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
8
|
+
const res = await fetch(`${baseUrl}${path}`, { ...init, headers });
|
|
9
|
+
if (!res.ok) {
|
|
10
|
+
throw new OneSdkError(`${(init.method ?? "GET")} ${path} → ${res.status}`, res.status);
|
|
11
|
+
}
|
|
12
|
+
return res.json();
|
|
13
|
+
}
|
|
14
|
+
export class SubstrateClient {
|
|
15
|
+
baseUrl;
|
|
16
|
+
apiKey;
|
|
17
|
+
constructor(cfg = {}) {
|
|
18
|
+
this.baseUrl = resolveBaseUrl(cfg.baseUrl);
|
|
19
|
+
this.apiKey = resolveApiKey(cfg.apiKey);
|
|
20
|
+
}
|
|
21
|
+
async signal(sender, receiver, data) {
|
|
22
|
+
const result = await req(this.baseUrl, "/api/signal", { method: "POST", body: JSON.stringify({ sender, receiver, data }) }, this.apiKey);
|
|
23
|
+
emit("toolkit:sdk:signal", ["sdk", "method-signal", result.success ? "200" : "error"]);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
async ask(receiver, data, timeout, from) {
|
|
27
|
+
const t = Date.now();
|
|
28
|
+
const result = await req(this.baseUrl, "/api/ask", { method: "POST", body: JSON.stringify({ receiver, data, timeout, from }) }, this.apiKey);
|
|
29
|
+
const outcome = "result" in result ? "result"
|
|
30
|
+
: "timeout" in result ? "timeout"
|
|
31
|
+
: "dissolved" in result ? "dissolved"
|
|
32
|
+
: "failure";
|
|
33
|
+
emit("toolkit:sdk:ask", ["sdk", "method-ask", `outcome-${outcome}`], { latencyMs: Date.now() - t });
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
async mark(edge, scores) {
|
|
37
|
+
const result = await req(this.baseUrl, "/api/loop/mark-dims", { method: "POST", body: JSON.stringify({ edge, ...(scores ?? { fit: 1, form: 1, truth: 1, taste: 1 }) }) }, this.apiKey);
|
|
38
|
+
emit("toolkit:sdk:mark", ["sdk", "method-mark"]);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
async warn(edge, scores) {
|
|
42
|
+
const result = await req(this.baseUrl, "/api/loop/mark-dims", { method: "POST", body: JSON.stringify({ edge, ...(scores ?? { fit: 0, form: 0, truth: 0, taste: 0 }) }) }, this.apiKey);
|
|
43
|
+
emit("toolkit:sdk:warn", ["sdk", "method-warn"]);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
async fade(trailRate, resistanceRate) {
|
|
47
|
+
const result = await req(this.baseUrl, "/api/decay-cycle", { method: "POST", body: JSON.stringify({ trailRate, resistanceRate }) }, this.apiKey);
|
|
48
|
+
emit("toolkit:sdk:fade", ["sdk", "method-fade"]);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
async highways(limit = 10) {
|
|
52
|
+
const result = await req(this.baseUrl, `/api/loop/highways?limit=${limit}`, {}, this.apiKey);
|
|
53
|
+
emit("toolkit:sdk:highways", ["sdk", "method-highways"]);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
async recall(status) {
|
|
57
|
+
const qs = status ? `?status=${encodeURIComponent(status)}` : "";
|
|
58
|
+
const result = await req(this.baseUrl, `/api/hypotheses${qs}`, {}, this.apiKey);
|
|
59
|
+
emit("toolkit:sdk:recall", ["sdk", "method-recall"]);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
async reveal(uid) {
|
|
63
|
+
const result = await req(this.baseUrl, `/api/memory/reveal/${encodeURIComponent(uid)}`, {}, this.apiKey);
|
|
64
|
+
emit("toolkit:sdk:reveal", ["sdk", "method-reveal"]);
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
async forget(uid) {
|
|
68
|
+
const result = await req(this.baseUrl, `/api/memory/forget/${encodeURIComponent(uid)}`, { method: "DELETE" }, this.apiKey);
|
|
69
|
+
emit("toolkit:sdk:forget", ["sdk", "method-forget"]);
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
async frontier(uid) {
|
|
73
|
+
const result = await req(this.baseUrl, `/api/memory/frontier/${encodeURIComponent(uid)}`, {}, this.apiKey);
|
|
74
|
+
emit("toolkit:sdk:frontier", ["sdk", "method-frontier"]);
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
async know() {
|
|
78
|
+
const result = await req(this.baseUrl, "/api/tick", {}, this.apiKey);
|
|
79
|
+
emit("toolkit:sdk:know", ["sdk", "method-know"]);
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
async select() {
|
|
83
|
+
const result = await req(this.baseUrl, "/api/loop/stage", { method: "POST", body: JSON.stringify({}) }, this.apiKey);
|
|
84
|
+
emit("toolkit:sdk:select", ["sdk", "method-select"]);
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAUzC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,KAAK,UAAU,GAAG,CAChB,OAAe,EACf,IAAY,EACZ,OAAoB,EAAE,EACtB,MAAe;IAEf,MAAM,OAAO,GAA2B,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;IAC/E,IAAI,MAAM;QAAE,OAAO,CAAC,eAAe,CAAC,GAAG,UAAU,MAAM,EAAE,CAAC;IAC1D,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,GAAG,IAAI,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACnE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,WAAW,CACnB,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,MAAM,GAAG,CAAC,MAAM,EAAE,EACnD,GAAG,CAAC,MAAM,CACX,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAC;AAClC,CAAC;AAED,MAAM,OAAO,eAAe;IACT,OAAO,CAAS;IAChB,MAAM,CAAqB;IAE5C,YAAY,MAAiB,EAAE;QAC7B,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1C,CAA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"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAEA,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAOxD;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAI7E"}
|
package/dist/handoff.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getFrontendUrl } from "./urls.js";
|
|
2
|
+
export function validateEthAddress(address) {
|
|
3
|
+
if (!address || typeof address !== "string") {
|
|
4
|
+
throw new Error("validateEthAddress: address required");
|
|
5
|
+
}
|
|
6
|
+
if (!/^0x[a-fA-F0-9]{40}$/.test(address)) {
|
|
7
|
+
throw new Error(`validateEthAddress: invalid address ${address}`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function generateDeployLink(agentUid, baseUrl) {
|
|
11
|
+
const root = baseUrl ?? getFrontendUrl();
|
|
12
|
+
const safe = encodeURIComponent(agentUid);
|
|
13
|
+
return `${root.replace(/\/$/, "")}/deploy/${safe}`;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,uCAAuC,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAgB,EAAE,OAAgB;IACnE,MAAM,IAAI,GAAG,OAAO,IAAI,cAAc,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,IAAI,EAAE,CAAC;AACrD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./urls.js";
|
|
3
|
+
export * as storage from "./storage.js";
|
|
4
|
+
export * from "./handoff.js";
|
|
5
|
+
export { launchToken } from "./launch.js";
|
|
6
|
+
export type { LaunchOpts, LaunchResult } from "./launch.js";
|
|
7
|
+
export { SubstrateClient } from "./client.js";
|
|
8
|
+
export { emit as telemetryEmit, isDisabled as isTelemetryDisabled, sessionId } from "./telemetry.js";
|
|
9
|
+
export declare const SDK_VERSION = "0.2.0";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,UAAU,IAAI,mBAAmB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAErG,eAAO,MAAM,WAAW,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./types.js";
|
|
2
|
+
export * from "./urls.js";
|
|
3
|
+
export * as storage from "./storage.js";
|
|
4
|
+
export * from "./handoff.js";
|
|
5
|
+
export { launchToken } from "./launch.js";
|
|
6
|
+
export { SubstrateClient } from "./client.js";
|
|
7
|
+
export { emit as telemetryEmit, isDisabled as isTelemetryDisabled, sessionId } from "./telemetry.js";
|
|
8
|
+
export const SDK_VERSION = "0.2.0";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,UAAU,IAAI,mBAAmB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAErG,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC"}
|
package/dist/launch.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface LaunchOpts {
|
|
2
|
+
agentLaunchUrl?: string;
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
dryRun?: boolean;
|
|
5
|
+
chain?: "sui" | "base" | "solana";
|
|
6
|
+
meta?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export interface LaunchResult {
|
|
9
|
+
tokenId: string;
|
|
10
|
+
address?: string;
|
|
11
|
+
chain: string;
|
|
12
|
+
dryRun: boolean;
|
|
13
|
+
raw: unknown;
|
|
14
|
+
}
|
|
15
|
+
export declare function launchToken(agentUid: string, opts?: LaunchOpts): Promise<LaunchResult>;
|
|
16
|
+
//# sourceMappingURL=launch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../src/launch.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,OAAO,CAAC;CACd;AAID,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,GAAE,UAAe,GAAG,OAAO,CAAC,YAAY,CAAC,CAyChG"}
|
package/dist/launch.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { resolveApiKey, resolveBaseUrl } from "./urls.js";
|
|
2
|
+
import { OneSdkError } from "./types.js";
|
|
3
|
+
const DEFAULT_AGENT_LAUNCH_URL = "https://agent-launch.ai/api";
|
|
4
|
+
export async function launchToken(agentUid, opts = {}) {
|
|
5
|
+
const base = opts.agentLaunchUrl ?? process.env.AGENT_LAUNCH_URL ?? DEFAULT_AGENT_LAUNCH_URL;
|
|
6
|
+
const key = resolveApiKey(opts.apiKey);
|
|
7
|
+
const body = {
|
|
8
|
+
agentUid,
|
|
9
|
+
chain: opts.chain ?? "sui",
|
|
10
|
+
dryRun: opts.dryRun ?? false,
|
|
11
|
+
meta: opts.meta ?? {},
|
|
12
|
+
};
|
|
13
|
+
const headers = new Headers({ "Content-Type": "application/json" });
|
|
14
|
+
if (key)
|
|
15
|
+
headers.set("Authorization", `Bearer ${key}`);
|
|
16
|
+
const res = await fetch(`${base.replace(/\/$/, "")}/v1/tokens`, {
|
|
17
|
+
method: "POST",
|
|
18
|
+
headers,
|
|
19
|
+
body: JSON.stringify(body),
|
|
20
|
+
});
|
|
21
|
+
if (!res.ok)
|
|
22
|
+
throw new OneSdkError(`launch ${res.status}`, res.status);
|
|
23
|
+
const raw = (await res.json());
|
|
24
|
+
const tokenId = String(raw.tokenId ?? raw.id ?? `dry-${Date.now()}`);
|
|
25
|
+
const result = {
|
|
26
|
+
tokenId,
|
|
27
|
+
address: typeof raw.address === "string" ? raw.address : undefined,
|
|
28
|
+
chain: body.chain,
|
|
29
|
+
dryRun: body.dryRun,
|
|
30
|
+
raw,
|
|
31
|
+
};
|
|
32
|
+
// Emit token-launched signal to the substrate (best-effort).
|
|
33
|
+
try {
|
|
34
|
+
await fetch(`${resolveBaseUrl(undefined)}/api/signal`, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
headers: { "Content-Type": "application/json" },
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
receiver: `agent:${agentUid}`,
|
|
39
|
+
data: { tags: ["token-launched"], content: result },
|
|
40
|
+
scope: "public",
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// signal emit is best-effort; the launch itself is authoritative
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=launch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launch.js","sourceRoot":"","sources":["../src/launch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAkBzC,MAAM,wBAAwB,GAAG,6BAA6B,CAAC;AAE/D,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAgB,EAAE,OAAmB,EAAE;IACvE,MAAM,IAAI,G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KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,GAAG;KACJ,CAAC;IACF,6DAA6D;IAC7D,IAAI,CAAC;QACH,MAAM,KAAK,CAAC,GAAG,cAAc,CAAC,SAAS,CAAC,aAAa,EAAE;YACrD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,QAAQ,EAAE,SAAS,QAAQ,EAAE;gBAC7B,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE;gBACnD,KAAK,EAAE,QAAQ;aAChB,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,iEAAiE;IACnE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface StorageEntry {
|
|
2
|
+
key: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function listStorage(uid: string, apiKey?: string): Promise<StorageEntry[]>;
|
|
6
|
+
export declare function getStorage(uid: string, key: string, apiKey?: string): Promise<string | null>;
|
|
7
|
+
export declare function putStorage(uid: string, key: string, value: string, apiKey?: string): Promise<void>;
|
|
8
|
+
export declare function deleteStorage(uid: string, key: string, apiKey?: string): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAcD,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAGvF;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQlG;AAED,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKxG;AAED,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5F"}
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { resolveApiKey, resolveBaseUrl } from "./urls.js";
|
|
2
|
+
import { OneSdkError } from "./types.js";
|
|
3
|
+
async function req(path, init, apiKey, baseUrl) {
|
|
4
|
+
const key = resolveApiKey(apiKey);
|
|
5
|
+
const url = `${resolveBaseUrl(baseUrl)}${path}`;
|
|
6
|
+
const headers = new Headers(init.headers);
|
|
7
|
+
if (key)
|
|
8
|
+
headers.set("Authorization", `Bearer ${key}`);
|
|
9
|
+
if (init.body && !headers.has("Content-Type"))
|
|
10
|
+
headers.set("Content-Type", "application/json");
|
|
11
|
+
const res = await fetch(url, { ...init, headers });
|
|
12
|
+
if (!res.ok)
|
|
13
|
+
throw new OneSdkError(`storage ${res.status}`, res.status);
|
|
14
|
+
if (res.status === 204)
|
|
15
|
+
return undefined;
|
|
16
|
+
return (await res.json());
|
|
17
|
+
}
|
|
18
|
+
export async function listStorage(uid, apiKey) {
|
|
19
|
+
const data = await req(`/api/storage/${encodeURIComponent(uid)}`, { method: "GET" }, apiKey);
|
|
20
|
+
return data.items ?? [];
|
|
21
|
+
}
|
|
22
|
+
export async function getStorage(uid, key, apiKey) {
|
|
23
|
+
try {
|
|
24
|
+
const data = await req(`/api/storage/${encodeURIComponent(uid)}/${encodeURIComponent(key)}`, { method: "GET" }, apiKey);
|
|
25
|
+
return data.value;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
if (err instanceof OneSdkError && err.status === 404)
|
|
29
|
+
return null;
|
|
30
|
+
throw err;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export async function putStorage(uid, key, value, apiKey) {
|
|
34
|
+
await req(`/api/storage/${encodeURIComponent(uid)}/${encodeURIComponent(key)}`, {
|
|
35
|
+
method: "PUT",
|
|
36
|
+
body: JSON.stringify({ value }),
|
|
37
|
+
}, apiKey);
|
|
38
|
+
}
|
|
39
|
+
export async function deleteStorage(uid, key, apiKey) {
|
|
40
|
+
await req(`/api/storage/${encodeURIComponent(uid)}/${encodeURIComponent(key)}`, { method: "DELETE" }, apiKey);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAOzC,KAAK,UAAU,GAAG,CAAI,IAAY,EAAE,IAAiB,EAAE,MAAe,EAAE,OAAgB;IACtF,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,IAAI,EAAE,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,IAAI,GAAG;QAAE,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,GAAG,EAAE,CAAC,CAAC;IACvD,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,c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AC,GAAW,EAAE,GAAW,EAAE,KAAa,EAAE,MAAe;IACvF,MAAM,GAAG,CAAC,gBAAgB,kBAAkB,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE,EAAE;QAC9E,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC;KAChC,EAAE,MAAM,CAAC,CAAC;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,GAAW,EAAE,GAAW,EAAE,MAAe;IAC3E,MAAM,GAAG,CAAC,gBAAgB,kBAAkB,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;AAChH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,SAAS,QAGP,CAAC;AA2BhB,wBAAgB,IAAI,CAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI,CAeN;AAED,wBAAgB,UAAU,IAAI,OAAO,CAEpC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
const DISABLE_KEY = "ONEIE_TELEMETRY_DISABLE";
|
|
5
|
+
const ENDPOINT = "https://api.one.ie/api/signal";
|
|
6
|
+
const RATE_LIMIT = 100;
|
|
7
|
+
const RATE_WINDOW_MS = 3_600_000;
|
|
8
|
+
let tokenCount = 0;
|
|
9
|
+
let windowStart = Date.now();
|
|
10
|
+
export const sessionId = createHash("sha256")
|
|
11
|
+
.update(randomBytes(16))
|
|
12
|
+
.digest("hex")
|
|
13
|
+
.slice(0, 16);
|
|
14
|
+
function isEnabled() {
|
|
15
|
+
if (typeof process === "undefined")
|
|
16
|
+
return false;
|
|
17
|
+
if (process.env[DISABLE_KEY])
|
|
18
|
+
return false;
|
|
19
|
+
try {
|
|
20
|
+
const cfg = JSON.parse(readFileSync(join(process.env["HOME"] ?? "~", ".oneie", "config.json"), "utf8"));
|
|
21
|
+
if (cfg["telemetry"] === false)
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Config file absent or unreadable — default to enabled
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
function consume() {
|
|
30
|
+
const now = Date.now();
|
|
31
|
+
if (now - windowStart > RATE_WINDOW_MS) {
|
|
32
|
+
tokenCount = 0;
|
|
33
|
+
windowStart = now;
|
|
34
|
+
}
|
|
35
|
+
if (tokenCount >= RATE_LIMIT)
|
|
36
|
+
return false;
|
|
37
|
+
tokenCount++;
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
export function emit(receiver, tags, content) {
|
|
41
|
+
if (!isEnabled() || !consume())
|
|
42
|
+
return;
|
|
43
|
+
void fetch(ENDPOINT, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: { "Content-Type": "application/json" },
|
|
46
|
+
body: JSON.stringify({
|
|
47
|
+
sender: `toolkit:${sessionId}`,
|
|
48
|
+
receiver,
|
|
49
|
+
data: JSON.stringify({
|
|
50
|
+
tags: ["telemetry", ...tags],
|
|
51
|
+
weight: 1,
|
|
52
|
+
content: { id: sessionId, ...content },
|
|
53
|
+
}),
|
|
54
|
+
}),
|
|
55
|
+
}).catch(() => undefined);
|
|
56
|
+
}
|
|
57
|
+
export function isDisabled() {
|
|
58
|
+
return !isEnabled();
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=telemetry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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AAE,CAAC;IACvB,IAAI,GAAG,GAAG,WAAW,GAAG,cAAc,EAAE,CAAC;QACvC,UAAU,GAAG,CAAC,CAAC;QACf,WAAW,GAAG,GAAG,CAAC;IACpB,CAAC;IACD,IAAI,UAAU,IAAI,UAAU;QAAE,OAAO,KAAK,CAAC;IAC3C,UAAU,EAAE,CAAC;IACb,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,IAAI,CAClB,QAAgB,EAChB,IAAc,EACd,OAAiC;IAEjC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE;QAAE,OAAO;IACvC,KAAK,KAAK,CAAC,QAAQ,EAAE;QACnB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,MAAM,EAAE,WAAW,SAAS,EAAE;YAC9B,QAAQ;YACR,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,IAAI,EAAE,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC;gBAC5B,MAAM,EAAE,CAAC;gBACT,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE;aACvC,CAAC;SACH,CAAC;KACH,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,CAAC,SAAS,EAAE,CAAC;AACtB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface SdkConfig {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class OneSdkError extends Error {
|
|
6
|
+
readonly status?: number | undefined;
|
|
7
|
+
readonly code?: string | undefined;
|
|
8
|
+
constructor(message: string, status?: number | undefined, code?: string | undefined);
|
|
9
|
+
}
|
|
10
|
+
export type Outcome<T> = {
|
|
11
|
+
result: T;
|
|
12
|
+
latency: number;
|
|
13
|
+
} | {
|
|
14
|
+
timeout: true;
|
|
15
|
+
latency: number;
|
|
16
|
+
} | {
|
|
17
|
+
dissolved: true;
|
|
18
|
+
latency: number;
|
|
19
|
+
} | {
|
|
20
|
+
failure: true;
|
|
21
|
+
latency: number;
|
|
22
|
+
};
|
|
23
|
+
export interface SignalResponse {
|
|
24
|
+
ok: boolean;
|
|
25
|
+
routed: string | null;
|
|
26
|
+
result?: unknown;
|
|
27
|
+
latency: number;
|
|
28
|
+
success: boolean;
|
|
29
|
+
sui?: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface HighwaysResponse {
|
|
32
|
+
highways: Array<{
|
|
33
|
+
path: string;
|
|
34
|
+
strength: number;
|
|
35
|
+
resistance: number;
|
|
36
|
+
net: number;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
export interface HypothesesResponse {
|
|
40
|
+
hypotheses: Array<{
|
|
41
|
+
hid: string;
|
|
42
|
+
statement: string;
|
|
43
|
+
status: string;
|
|
44
|
+
observations: number;
|
|
45
|
+
pValue: number;
|
|
46
|
+
actionReady: boolean;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export interface MarkDimsResponse {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
edge: string;
|
|
52
|
+
scores: {
|
|
53
|
+
fit: number;
|
|
54
|
+
form: number;
|
|
55
|
+
truth: number;
|
|
56
|
+
taste: number;
|
|
57
|
+
};
|
|
58
|
+
marks: Array<{
|
|
59
|
+
edge: string;
|
|
60
|
+
action: "mark" | "warn";
|
|
61
|
+
strength: number;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
export interface DecayResponse {
|
|
65
|
+
before: {
|
|
66
|
+
edges: number;
|
|
67
|
+
avgStrength: number;
|
|
68
|
+
avgResistance: number;
|
|
69
|
+
};
|
|
70
|
+
after: {
|
|
71
|
+
edges: number;
|
|
72
|
+
avgStrength: number;
|
|
73
|
+
avgResistance: number;
|
|
74
|
+
};
|
|
75
|
+
decayed: {
|
|
76
|
+
trailRate: number;
|
|
77
|
+
resistanceRate: number;
|
|
78
|
+
};
|
|
79
|
+
timestamp: string;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAY,SAAQ,KAAK;IAGlC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM;gBAFtB,OAAO,EAAE,MAAM,EACN,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,IAAI,CAAC,EAAE,MAAM,YAAA;CAKzB;AAED,MAAM,MAAM,OAAO,CAAC,CAAC,IACjB;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,SAAS,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B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ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,WAAY,SAAQ,KAAK;IAGzB;IACA;IAHX,YACE,OAAe,EACN,MAAe,EACf,IAAa;QAEtB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHN,WAAM,GAAN,MAAM,CAAS;QACf,SAAI,GAAJ,IAAI,CAAS;QAGtB,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF"}
|
package/dist/urls.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const PROD_API_URL = "https://api.one.ie";
|
|
2
|
+
declare const PROD_FRONTEND_URL = "https://one.ie";
|
|
3
|
+
declare const DEV_API_URL = "http://localhost:4321";
|
|
4
|
+
declare const DEV_FRONTEND_URL = "http://localhost:4321";
|
|
5
|
+
export declare function getEnvironment(): "dev" | "production";
|
|
6
|
+
export declare function getApiUrl(): string;
|
|
7
|
+
export declare function getFrontendUrl(): string;
|
|
8
|
+
export declare function resolveApiKey(configKey?: string): string | undefined;
|
|
9
|
+
export declare function resolveBaseUrl(configUrl?: string): string;
|
|
10
|
+
export { PROD_API_URL, PROD_FRONTEND_URL, DEV_API_URL, DEV_FRONTEND_URL };
|
|
11
|
+
//# sourceMappingURL=urls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../src/urls.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,YAAY,uBAAuB,CAAC;AAC1C,QAAA,MAAM,iBAAiB,mBAAmB,CAAC;AAC3C,QAAA,MAAM,WAAW,0BAA0B,CAAC;AAC5C,QAAA,MAAM,gBAAgB,0BAA0B,CAAC;AAEjD,wBAAgB,cAAc,IAAI,KAAK,GAAG,YAAY,CAGrD;AAED,wBAAgB,SAAS,IAAI,MAAM,CAIlC;AAED,wBAAgB,cAAc,IAAI,MAAM,CAIvC;AAED,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIpE;AAED,wBAAgB,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC"}
|
package/dist/urls.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const PROD_API_URL = "https://api.one.ie";
|
|
2
|
+
const PROD_FRONTEND_URL = "https://one.ie";
|
|
3
|
+
const DEV_API_URL = "http://localhost:4321";
|
|
4
|
+
const DEV_FRONTEND_URL = "http://localhost:4321";
|
|
5
|
+
export function getEnvironment() {
|
|
6
|
+
if (typeof process === "undefined")
|
|
7
|
+
return "production";
|
|
8
|
+
return process.env.NODE_ENV === "production" ? "production" : "dev";
|
|
9
|
+
}
|
|
10
|
+
export function getApiUrl() {
|
|
11
|
+
const override = typeof process !== "undefined" ? process.env.ONEIE_API_URL : undefined;
|
|
12
|
+
if (override)
|
|
13
|
+
return override;
|
|
14
|
+
return getEnvironment() === "production" ? PROD_API_URL : DEV_API_URL;
|
|
15
|
+
}
|
|
16
|
+
export function getFrontendUrl() {
|
|
17
|
+
const override = typeof process !== "undefined" ? process.env.ONEIE_FRONTEND_URL : undefined;
|
|
18
|
+
if (override)
|
|
19
|
+
return override;
|
|
20
|
+
return getEnvironment() === "production" ? PROD_FRONTEND_URL : DEV_FRONTEND_URL;
|
|
21
|
+
}
|
|
22
|
+
export function resolveApiKey(configKey) {
|
|
23
|
+
if (configKey)
|
|
24
|
+
return configKey;
|
|
25
|
+
if (typeof process === "undefined")
|
|
26
|
+
return undefined;
|
|
27
|
+
return process.env.ONEIE_API_KEY ?? process.env.ONE_API_KEY;
|
|
28
|
+
}
|
|
29
|
+
export function resolveBaseUrl(configUrl) {
|
|
30
|
+
if (configUrl)
|
|
31
|
+
return configUrl;
|
|
32
|
+
return getApiUrl();
|
|
33
|
+
}
|
|
34
|
+
export { PROD_API_URL, PROD_FRONTEND_URL, DEV_API_URL, DEV_FRONTEND_URL };
|
|
35
|
+
//# sourceMappingURL=urls.js.map
|
package/dist/urls.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../src/urls.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAC1C,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAC3C,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAC5C,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAEjD,MAAM,UAAU,cAAc;IAC5B,IAAI,OAAO,OAAO,KAAK,WAAW;QAAE,OAAO,YAAY,CAAC;IACxD,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,MAAM,QAAQ,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;IACxF,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,OAAO,cAAc,EAAE,KAAK,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,WAAW,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,MAAM,QAAQ,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7F,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,OAAO,cAAc,EAAE,KAAK,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,SAAkB;IAC9C,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAChC,IAAI,OAAO,OAAO,KAAK,WAAW;QAAE,OAAO,SAAS,CAAC;IACrD,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,SAAkB;IAC/C,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAChC,OAAO,SAAS,EAAE,CAAC;AACrB,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oneie/sdk",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "ONE substrate SDK — signals, units, persist, launch handoff.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./urls": "./dist/urls.js",
|
|
14
|
+
"./storage": "./dist/storage.js",
|
|
15
|
+
"./handoff": "./dist/handoff.js",
|
|
16
|
+
"./launch": "./dist/launch.js",
|
|
17
|
+
"./client": "./dist/client.js",
|
|
18
|
+
"./telemetry": "./dist/telemetry.js"
|
|
19
|
+
},
|
|
20
|
+
"files": ["dist", "README.md"],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"dev": "tsc --watch",
|
|
24
|
+
"prepublishOnly": "bun run build"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript": "5.9.2"
|
|
28
|
+
},
|
|
29
|
+
"license": "SEE LICENSE IN https://one.ie/free-license",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/one-ie/envelopes.git",
|
|
33
|
+
"directory": "packages/sdk"
|
|
34
|
+
}
|
|
35
|
+
}
|