@aithos/sdk 0.1.0-alpha.1
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/LICENSE +17 -0
- package/README.md +70 -0
- package/dist/src/compute.d.ts +71 -0
- package/dist/src/compute.js +104 -0
- package/dist/src/endpoints.d.ts +25 -0
- package/dist/src/endpoints.js +28 -0
- package/dist/src/ethos.d.ts +2 -0
- package/dist/src/ethos.js +21 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.js +34 -0
- package/dist/src/mandates.d.ts +2 -0
- package/dist/src/mandates.js +13 -0
- package/dist/src/onboarding.d.ts +2 -0
- package/dist/src/onboarding.js +12 -0
- package/dist/src/sdk.d.ts +18 -0
- package/dist/src/sdk.js +56 -0
- package/dist/src/types.d.ts +40 -0
- package/dist/src/types.js +20 -0
- package/dist/src/wallet.d.ts +49 -0
- package/dist/src/wallet.js +71 -0
- package/dist/test/compute.test.d.ts +2 -0
- package/dist/test/compute.test.js +179 -0
- package/dist/test/endpoints.test.d.ts +2 -0
- package/dist/test/endpoints.test.js +43 -0
- package/dist/test/sdk.test.d.ts +2 -0
- package/dist/test/sdk.test.js +86 -0
- package/dist/test/wallet.test.d.ts +2 -0
- package/dist/test/wallet.test.js +110 -0
- package/package.json +66 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 Mathieu Colla
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @aithos/sdk
|
|
2
|
+
|
|
3
|
+
> High-level developer SDK for building agentic apps on the
|
|
4
|
+
> [Aithos](https://aithos.be) protocol.
|
|
5
|
+
|
|
6
|
+
`@aithos/sdk` is the recommended entry point for app developers. It wraps
|
|
7
|
+
[`@aithos/protocol-client`](https://github.com/aithos-protocol/protocol-client)
|
|
8
|
+
(low-level cryptography, signed envelopes, DID and mandate primitives) and
|
|
9
|
+
adds the Aithos-hosted endpoints — the **compute proxy** for Bedrock /
|
|
10
|
+
Claude inference and the **wallet** for Stripe credit-pack top-ups — behind
|
|
11
|
+
a single, stable, batteries-included surface.
|
|
12
|
+
|
|
13
|
+
## Status
|
|
14
|
+
|
|
15
|
+
Pre-alpha. The public API may change between releases until `0.1.0`. Pin
|
|
16
|
+
exact versions in production.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install @aithos/sdk @aithos/protocol-client
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`@aithos/protocol-client` is a peer dependency. Apps that already vend their
|
|
25
|
+
own copy keep using it; the SDK re-exports its primitives so you do not
|
|
26
|
+
need to import both directly in app code.
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { AithosSDK, createIdentity } from "@aithos/sdk";
|
|
32
|
+
|
|
33
|
+
// 1. Get or restore the user's identity (a key pair + DID).
|
|
34
|
+
const identity = await createIdentity();
|
|
35
|
+
|
|
36
|
+
// 2. Construct the SDK. Endpoints default to the production Aithos hosts;
|
|
37
|
+
// pass `endpoints` to override (staging, self-host, tests).
|
|
38
|
+
const sdk = new AithosSDK({ identity });
|
|
39
|
+
|
|
40
|
+
// 3. Top up the wallet via Stripe Checkout.
|
|
41
|
+
const { checkoutUrl } = await sdk.wallet.createTopupSession({
|
|
42
|
+
packId: "credits-100k",
|
|
43
|
+
successUrl: "https://my-app.example.com/?topup=success",
|
|
44
|
+
cancelUrl: "https://my-app.example.com/?topup=cancel",
|
|
45
|
+
});
|
|
46
|
+
window.location.href = checkoutUrl;
|
|
47
|
+
|
|
48
|
+
// 4. Once the user has credits, invoke Bedrock through the compute proxy.
|
|
49
|
+
const reply = await sdk.compute.invokeBedrock({
|
|
50
|
+
model: "claude-sonnet-4-6",
|
|
51
|
+
mandateId: "mandate:…",
|
|
52
|
+
messages: [{ role: "user", content: "Hello, Aithos!" }],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
console.log(reply.content);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## What lives where
|
|
59
|
+
|
|
60
|
+
| Namespace | Purpose |
|
|
61
|
+
| ---------------- | ------------------------------------------------------------------------------------------ |
|
|
62
|
+
| `sdk.compute` | Bedrock invocation through the Aithos compute proxy (signed envelope, wallet enforcement). |
|
|
63
|
+
| `sdk.wallet` | Stripe Checkout sessions for credit-pack top-ups, balance helpers. |
|
|
64
|
+
| `sdk.ethos` | Ethos-zone composition / parsing — re-exported from `@aithos/protocol-client`. |
|
|
65
|
+
| `sdk.onboarding` | First-run identity / DID flows — re-exported. |
|
|
66
|
+
| `sdk.mandates` | Mint / verify mandates — re-exported. |
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
Apache-2.0 © 2026 Mathieu Colla. See [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type BrowserIdentity } from "@aithos/protocol-client";
|
|
2
|
+
import { type AithosSdkEndpoints } from "./endpoints.js";
|
|
3
|
+
export interface ComputeMessage {
|
|
4
|
+
readonly role: "user" | "assistant";
|
|
5
|
+
readonly content: string;
|
|
6
|
+
}
|
|
7
|
+
export interface InvokeBedrockArgs {
|
|
8
|
+
/** Mandate ID granting this app the right to spend the user's wallet. */
|
|
9
|
+
readonly mandateId: string;
|
|
10
|
+
/**
|
|
11
|
+
* Model id. Today the proxy accepts the canonical Aithos identifiers:
|
|
12
|
+
* `claude-sonnet-4-6`, `claude-haiku-4-5`, `claude-opus-4-7`.
|
|
13
|
+
* The proxy maps these to Bedrock cross-region inference profiles.
|
|
14
|
+
*/
|
|
15
|
+
readonly model: string;
|
|
16
|
+
/** Conversation messages (user / assistant turns). */
|
|
17
|
+
readonly messages: readonly ComputeMessage[];
|
|
18
|
+
/** Optional system prompt (Bedrock convention — sent as a separate field). */
|
|
19
|
+
readonly system?: string;
|
|
20
|
+
/** Hard cap on output tokens for this call. Server further caps by mandate. */
|
|
21
|
+
readonly maxTokens?: number;
|
|
22
|
+
/** Sampling temperature. Default model-dependent. */
|
|
23
|
+
readonly temperature?: number;
|
|
24
|
+
/** Idempotency key for retries. The SDK generates one if omitted. */
|
|
25
|
+
readonly idempotencyKey?: string;
|
|
26
|
+
/** Abort signal to cancel the request. */
|
|
27
|
+
readonly signal?: AbortSignal;
|
|
28
|
+
}
|
|
29
|
+
export type StopReason = "end_turn" | "max_tokens" | "stop_sequence";
|
|
30
|
+
export interface InvokeBedrockResult {
|
|
31
|
+
/** Plain text response from the model. */
|
|
32
|
+
readonly content: string;
|
|
33
|
+
/** Why the model stopped generating. */
|
|
34
|
+
readonly stopReason: StopReason;
|
|
35
|
+
/** Token accounting from the model. */
|
|
36
|
+
readonly usage: {
|
|
37
|
+
readonly inputTokens: number;
|
|
38
|
+
readonly outputTokens: number;
|
|
39
|
+
};
|
|
40
|
+
/** Microcredits debited from the user wallet for this call. */
|
|
41
|
+
readonly creditsCharged: number;
|
|
42
|
+
/** New wallet balance (microcredits) after debit. */
|
|
43
|
+
readonly walletBalance: number;
|
|
44
|
+
/** Audit log id for traceability. */
|
|
45
|
+
readonly auditId: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ComputeNamespaceDeps {
|
|
48
|
+
readonly identity: BrowserIdentity;
|
|
49
|
+
readonly appDid: string;
|
|
50
|
+
readonly endpoints: AithosSdkEndpoints;
|
|
51
|
+
readonly fetch: typeof fetch;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* `sdk.compute` namespace. Constructed once by the {@link AithosSDK}
|
|
55
|
+
* constructor; all calls share the SDK's identity, app DID, and endpoint
|
|
56
|
+
* configuration.
|
|
57
|
+
*/
|
|
58
|
+
export declare class ComputeNamespace {
|
|
59
|
+
#private;
|
|
60
|
+
constructor(deps: ComputeNamespaceDeps);
|
|
61
|
+
/**
|
|
62
|
+
* Invoke a Bedrock model through the compute proxy. See
|
|
63
|
+
* {@link InvokeBedrockArgs} and {@link InvokeBedrockResult}.
|
|
64
|
+
*
|
|
65
|
+
* @throws {AithosSDKError} on protocol errors. The `code` field is one of
|
|
66
|
+
* `network`, `http`, `empty`, or any code returned by the proxy
|
|
67
|
+
* (`quota_exceeded`, `mandate_revoked`, `insufficient_credits`, …).
|
|
68
|
+
*/
|
|
69
|
+
invokeBedrock(args: InvokeBedrockArgs): Promise<InvokeBedrockResult>;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=compute.d.ts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// Compute namespace — Bedrock invocation through the Aithos compute proxy.
|
|
4
|
+
//
|
|
5
|
+
// Wraps the JSON-RPC + signed-envelope protocol of `compute.aithos.be`
|
|
6
|
+
// behind an ergonomic method on the SDK. Internally builds a §11 envelope
|
|
7
|
+
// signed with the user's public-sphere key and posts it to
|
|
8
|
+
// `${compute}/v1/invoke`.
|
|
9
|
+
//
|
|
10
|
+
// Server-side guarantees (enforced by the proxy, not by this lib):
|
|
11
|
+
// - Envelope signature verified against the user's `did.json`.
|
|
12
|
+
// - Mandate at `mandateId` authorizes `appDid` for this model.
|
|
13
|
+
// - Wallet balance & per-call / daily / total caps respected.
|
|
14
|
+
// - Atomic debit on success.
|
|
15
|
+
// - 90/10 markup split between dev and Aithos.
|
|
16
|
+
//
|
|
17
|
+
// MVP scope: single-shot invocation. Multi-turn agentic loops (with native
|
|
18
|
+
// tool calling on the proxy) will land in a follow-up.
|
|
19
|
+
import { buildSignedEnvelope, } from "@aithos/protocol-client";
|
|
20
|
+
import { computeInvokeUrl, } from "./endpoints.js";
|
|
21
|
+
import { AithosSDKError } from "./types.js";
|
|
22
|
+
/**
|
|
23
|
+
* `sdk.compute` namespace. Constructed once by the {@link AithosSDK}
|
|
24
|
+
* constructor; all calls share the SDK's identity, app DID, and endpoint
|
|
25
|
+
* configuration.
|
|
26
|
+
*/
|
|
27
|
+
export class ComputeNamespace {
|
|
28
|
+
#deps;
|
|
29
|
+
constructor(deps) {
|
|
30
|
+
this.#deps = deps;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Invoke a Bedrock model through the compute proxy. See
|
|
34
|
+
* {@link InvokeBedrockArgs} and {@link InvokeBedrockResult}.
|
|
35
|
+
*
|
|
36
|
+
* @throws {AithosSDKError} on protocol errors. The `code` field is one of
|
|
37
|
+
* `network`, `http`, `empty`, or any code returned by the proxy
|
|
38
|
+
* (`quota_exceeded`, `mandate_revoked`, `insufficient_credits`, …).
|
|
39
|
+
*/
|
|
40
|
+
async invokeBedrock(args) {
|
|
41
|
+
const { identity, appDid, endpoints, fetch: fetchImpl } = this.#deps;
|
|
42
|
+
const url = computeInvokeUrl(endpoints);
|
|
43
|
+
const idempotencyKey = args.idempotencyKey ?? generateIdempotencyKey();
|
|
44
|
+
const params = {
|
|
45
|
+
app_did: appDid,
|
|
46
|
+
mandate_id: args.mandateId,
|
|
47
|
+
model: args.model,
|
|
48
|
+
messages: args.messages,
|
|
49
|
+
idempotency_key: idempotencyKey,
|
|
50
|
+
};
|
|
51
|
+
if (args.system !== undefined)
|
|
52
|
+
params.system = args.system;
|
|
53
|
+
if (args.maxTokens !== undefined)
|
|
54
|
+
params.max_tokens = args.maxTokens;
|
|
55
|
+
if (args.temperature !== undefined)
|
|
56
|
+
params.temperature = args.temperature;
|
|
57
|
+
const envelope = buildSignedEnvelope({
|
|
58
|
+
iss: identity.did,
|
|
59
|
+
aud: url,
|
|
60
|
+
method: "aithos.compute_invoke",
|
|
61
|
+
verificationMethod: `${identity.did}#public`,
|
|
62
|
+
params,
|
|
63
|
+
signer: identity.public,
|
|
64
|
+
});
|
|
65
|
+
let res;
|
|
66
|
+
try {
|
|
67
|
+
res = await fetchImpl(url, {
|
|
68
|
+
method: "POST",
|
|
69
|
+
headers: { "content-type": "application/json" },
|
|
70
|
+
body: JSON.stringify({
|
|
71
|
+
jsonrpc: "2.0",
|
|
72
|
+
id: "aithos.compute_invoke",
|
|
73
|
+
method: "aithos.compute_invoke",
|
|
74
|
+
params: { ...params, _envelope: envelope },
|
|
75
|
+
}),
|
|
76
|
+
...(args.signal ? { signal: args.signal } : {}),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
throw new AithosSDKError("network", e.message);
|
|
81
|
+
}
|
|
82
|
+
if (!res.ok) {
|
|
83
|
+
throw new AithosSDKError("http", `HTTP ${res.status} ${res.statusText}`, { status: res.status });
|
|
84
|
+
}
|
|
85
|
+
const body = (await res.json());
|
|
86
|
+
if (body.error) {
|
|
87
|
+
throw new AithosSDKError(String(body.error.code), body.error.message, body.error.data ? { data: body.error.data } : undefined);
|
|
88
|
+
}
|
|
89
|
+
if (!body.result) {
|
|
90
|
+
throw new AithosSDKError("empty", "empty result from compute proxy");
|
|
91
|
+
}
|
|
92
|
+
return body.result;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function generateIdempotencyKey() {
|
|
96
|
+
const bytes = new Uint8Array(16);
|
|
97
|
+
crypto.getRandomValues(bytes);
|
|
98
|
+
let hex = "";
|
|
99
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
100
|
+
hex += bytes[i].toString(16).padStart(2, "0");
|
|
101
|
+
}
|
|
102
|
+
return hex;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=compute.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Endpoints owned and resolved by the SDK. */
|
|
2
|
+
export interface AithosSdkEndpoints {
|
|
3
|
+
/** Compute proxy base URL — Bedrock invocation. Default `https://compute.aithos.be`. */
|
|
4
|
+
readonly compute: string;
|
|
5
|
+
/**
|
|
6
|
+
* Wallet base URL — Stripe top-up Checkout session creation.
|
|
7
|
+
*
|
|
8
|
+
* Production target: `https://wallet.aithos.be`. During the alpha we accept
|
|
9
|
+
* a raw AWS Lambda Function URL; both shapes work because the SDK only
|
|
10
|
+
* suffixes a fixed path to it.
|
|
11
|
+
*/
|
|
12
|
+
readonly wallet: string;
|
|
13
|
+
}
|
|
14
|
+
/** Production defaults. */
|
|
15
|
+
export declare const DEFAULT_SDK_ENDPOINTS: AithosSdkEndpoints;
|
|
16
|
+
/** Compose the full compute-invoke URL: `${compute}/v1/invoke`. */
|
|
17
|
+
export declare function computeInvokeUrl(endpoints: AithosSdkEndpoints): string;
|
|
18
|
+
/** Compose the full top-up-checkout URL: `${wallet}/v1/wallet/topup/checkout`. */
|
|
19
|
+
export declare function walletTopupCheckoutUrl(endpoints: AithosSdkEndpoints): string;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve a partial override on top of the production defaults. Used by the
|
|
22
|
+
* SDK constructor.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveEndpoints(override?: Partial<AithosSdkEndpoints>): AithosSdkEndpoints;
|
|
25
|
+
//# sourceMappingURL=endpoints.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
/** Production defaults. */
|
|
4
|
+
export const DEFAULT_SDK_ENDPOINTS = {
|
|
5
|
+
compute: "https://compute.aithos.be",
|
|
6
|
+
wallet: "https://wallet.aithos.be",
|
|
7
|
+
};
|
|
8
|
+
/** Compose the full compute-invoke URL: `${compute}/v1/invoke`. */
|
|
9
|
+
export function computeInvokeUrl(endpoints) {
|
|
10
|
+
return `${trimSlash(endpoints.compute)}/v1/invoke`;
|
|
11
|
+
}
|
|
12
|
+
/** Compose the full top-up-checkout URL: `${wallet}/v1/wallet/topup/checkout`. */
|
|
13
|
+
export function walletTopupCheckoutUrl(endpoints) {
|
|
14
|
+
return `${trimSlash(endpoints.wallet)}/v1/wallet/topup/checkout`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a partial override on top of the production defaults. Used by the
|
|
18
|
+
* SDK constructor.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveEndpoints(override) {
|
|
21
|
+
if (!override)
|
|
22
|
+
return { ...DEFAULT_SDK_ENDPOINTS };
|
|
23
|
+
return { ...DEFAULT_SDK_ENDPOINTS, ...override };
|
|
24
|
+
}
|
|
25
|
+
function trimSlash(url) {
|
|
26
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=endpoints.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { parsePublicZone, type ParsedZone, loadEditSnapshot, publishZoneEdit, publishPublicZoneAsDelegate, publishPrivateZoneAsDelegate, type EditSnapshot, type AddSectionInput, type ModifySectionInput, type PublishEditArgs, type PublishEditResult, addSectionToList, modifySectionInList, deleteSectionFromList, buildSignedFirstEdition, buildSignedNextEdition, type ZoneDoc, type ZoneManifest, type Section, SPHERES, type Sphere, } from "@aithos/protocol-client";
|
|
2
|
+
//# sourceMappingURL=ethos.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// Ethos namespace — re-exports of `@aithos/protocol-client` ethos primitives.
|
|
4
|
+
//
|
|
5
|
+
// The SDK exposes these so app developers don't need a direct dependency on
|
|
6
|
+
// `@aithos/protocol-client` for the common operations: parsing zone
|
|
7
|
+
// markdown, composing zone documents, building signed editions of the
|
|
8
|
+
// user's ethos.
|
|
9
|
+
//
|
|
10
|
+
// The full protocol-client API surface remains available for advanced cases
|
|
11
|
+
// — `import { … } from "@aithos/protocol-client"` is fully supported.
|
|
12
|
+
export {
|
|
13
|
+
// Zone parser — public-zone markdown → sections.
|
|
14
|
+
parsePublicZone,
|
|
15
|
+
// Editor — high-level load / mutate / publish flow.
|
|
16
|
+
loadEditSnapshot, publishZoneEdit, publishPublicZoneAsDelegate, publishPrivateZoneAsDelegate, addSectionToList, modifySectionInList, deleteSectionFromList,
|
|
17
|
+
// Manifest builders — sign editions of the public, circle, or self zones.
|
|
18
|
+
buildSignedFirstEdition, buildSignedNextEdition,
|
|
19
|
+
// Sphere taxonomy — "public" | "circle" | "self".
|
|
20
|
+
SPHERES, } from "@aithos/protocol-client";
|
|
21
|
+
//# sourceMappingURL=ethos.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const VERSION = "0.1.0-alpha.0";
|
|
2
|
+
export { AithosSDK } from "./sdk.js";
|
|
3
|
+
export type { AithosSDKConfig } from "./types.js";
|
|
4
|
+
export { AithosSDKError } from "./types.js";
|
|
5
|
+
export type { AithosSdkEndpoints } from "./endpoints.js";
|
|
6
|
+
export { DEFAULT_SDK_ENDPOINTS } from "./endpoints.js";
|
|
7
|
+
export type { ComputeMessage, InvokeBedrockArgs, InvokeBedrockResult, StopReason, } from "./compute.js";
|
|
8
|
+
export { ComputeNamespace } from "./compute.js";
|
|
9
|
+
export type { CreditPackId, CreateTopupSessionArgs, CreateTopupSessionResult, } from "./wallet.js";
|
|
10
|
+
export { WalletNamespace } from "./wallet.js";
|
|
11
|
+
export * as ethos from "./ethos.js";
|
|
12
|
+
export * as onboarding from "./onboarding.js";
|
|
13
|
+
export * as mandates from "./mandates.js";
|
|
14
|
+
export { createBrowserIdentity, browserIdentityFromStored, type BrowserIdentity, } from "@aithos/protocol-client";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// @aithos/sdk — public API surface.
|
|
4
|
+
//
|
|
5
|
+
// Two entry points:
|
|
6
|
+
//
|
|
7
|
+
// 1. The {@link AithosSDK} class — the recommended ergonomic surface.
|
|
8
|
+
// Construct once with the user's identity and the app DID, then call
|
|
9
|
+
// `sdk.compute.invokeBedrock(...)`, `sdk.wallet.createTopupSession(...)`,
|
|
10
|
+
// etc. through namespaced methods.
|
|
11
|
+
//
|
|
12
|
+
// 2. Direct named exports — for callers who only need a primitive (e.g.
|
|
13
|
+
// `createBrowserIdentity` during onboarding before the SDK exists).
|
|
14
|
+
// These are re-exports of `@aithos/protocol-client`; identical to
|
|
15
|
+
// what protocol-client itself exposes.
|
|
16
|
+
//
|
|
17
|
+
// Public types specific to the SDK (`AithosSDKConfig`, `AithosSDKError`)
|
|
18
|
+
// are exported from here. Endpoint config (`AithosSdkEndpoints`,
|
|
19
|
+
// `DEFAULT_SDK_ENDPOINTS`) likewise.
|
|
20
|
+
export const VERSION = "0.1.0-alpha.0";
|
|
21
|
+
export { AithosSDK } from "./sdk.js";
|
|
22
|
+
export { AithosSDKError } from "./types.js";
|
|
23
|
+
export { DEFAULT_SDK_ENDPOINTS } from "./endpoints.js";
|
|
24
|
+
export { ComputeNamespace } from "./compute.js";
|
|
25
|
+
export { WalletNamespace } from "./wallet.js";
|
|
26
|
+
// Re-exports under stable namespace modules. Apps may also import these
|
|
27
|
+
// directly via `@aithos/protocol-client`; the SDK simply curates them.
|
|
28
|
+
export * as ethos from "./ethos.js";
|
|
29
|
+
export * as onboarding from "./onboarding.js";
|
|
30
|
+
export * as mandates from "./mandates.js";
|
|
31
|
+
// Convenience direct re-exports of the most-used identity primitives so the
|
|
32
|
+
// quick-start example doesn't need a namespace import.
|
|
33
|
+
export { createBrowserIdentity, browserIdentityFromStored, } from "@aithos/protocol-client";
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// Mandates namespace — re-exports of mandate mint/sign primitives.
|
|
4
|
+
//
|
|
5
|
+
// A mandate is a signed delegation bundle that grants an app DID the right
|
|
6
|
+
// to act on the user's behalf within a scoped set of operations (read
|
|
7
|
+
// scopes, compute spend cap, TTL). Mandates are required by the compute
|
|
8
|
+
// proxy on every Bedrock call.
|
|
9
|
+
//
|
|
10
|
+
// See `@aithos/protocol-client/src/mandate-mint.ts` for the canonical
|
|
11
|
+
// implementation; this namespace re-exports the public surface verbatim.
|
|
12
|
+
export { mintDelegateBundle, signAndPublishMandate, MintError, DEFAULT_READ_SCOPES, TTL_PRESETS, } from "@aithos/protocol-client";
|
|
13
|
+
//# sourceMappingURL=mandates.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { runOnboarding, OnboardError, type OnboardArgs, type OnboardResult, createBrowserIdentity, browserIdentityFromStored, signedDidDocument, sphereDidUrl, type BrowserIdentity, type DidDocumentProof, type KeyAgreementMethod, type VerificationMethod, } from "@aithos/protocol-client";
|
|
2
|
+
//# sourceMappingURL=onboarding.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// Onboarding namespace — first-run identity and DID-document publishing.
|
|
4
|
+
//
|
|
5
|
+
// Re-exports of `@aithos/protocol-client` so app developers can drive a
|
|
6
|
+
// new-user flow without pulling protocol-client directly:
|
|
7
|
+
//
|
|
8
|
+
// const { identity, edition } = await sdk.onboarding.runOnboarding({ ... });
|
|
9
|
+
export { runOnboarding, OnboardError,
|
|
10
|
+
// Identity primitives — used to seed and restore the user's keys/DID.
|
|
11
|
+
createBrowserIdentity, browserIdentityFromStored, signedDidDocument, sphereDidUrl, } from "@aithos/protocol-client";
|
|
12
|
+
//# sourceMappingURL=onboarding.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ComputeNamespace } from "./compute.js";
|
|
2
|
+
import { type AithosSdkEndpoints } from "./endpoints.js";
|
|
3
|
+
import { WalletNamespace } from "./wallet.js";
|
|
4
|
+
import type { AithosSDKConfig } from "./types.js";
|
|
5
|
+
export declare class AithosSDK {
|
|
6
|
+
/** Resolved endpoint configuration (defaults + caller overrides). */
|
|
7
|
+
readonly endpoints: AithosSdkEndpoints;
|
|
8
|
+
/** Application DID (as declared in mandates). */
|
|
9
|
+
readonly appDid: string;
|
|
10
|
+
/** User DID (derived from `config.identity`). */
|
|
11
|
+
readonly userDid: string;
|
|
12
|
+
/** Compute proxy namespace — Bedrock invocation. */
|
|
13
|
+
readonly compute: ComputeNamespace;
|
|
14
|
+
/** Wallet namespace — Stripe top-up. */
|
|
15
|
+
readonly wallet: WalletNamespace;
|
|
16
|
+
constructor(config: AithosSDKConfig);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=sdk.d.ts.map
|
package/dist/src/sdk.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// AithosSDK — top-level developer surface.
|
|
4
|
+
//
|
|
5
|
+
// One construction, namespaced methods. The SDK takes the user's identity
|
|
6
|
+
// (a `BrowserIdentity` from `@aithos/protocol-client`) and the calling
|
|
7
|
+
// app's DID, then exposes:
|
|
8
|
+
//
|
|
9
|
+
// sdk.compute — Bedrock invocation through the compute proxy.
|
|
10
|
+
// sdk.wallet — Stripe Checkout for credit-pack top-ups.
|
|
11
|
+
// sdk.ethos — re-exports from protocol-client (zone editor, signers).
|
|
12
|
+
// sdk.onboarding / sdk.mandates — likewise.
|
|
13
|
+
//
|
|
14
|
+
// The class is intentionally thin: the heavy lifting lives in dedicated
|
|
15
|
+
// namespace classes (`ComputeNamespace`, `WalletNamespace`) so each can be
|
|
16
|
+
// tested in isolation with a mock fetch and so an advanced caller could
|
|
17
|
+
// instantiate just one of them if needed.
|
|
18
|
+
import { ComputeNamespace } from "./compute.js";
|
|
19
|
+
import { resolveEndpoints } from "./endpoints.js";
|
|
20
|
+
import { WalletNamespace } from "./wallet.js";
|
|
21
|
+
export class AithosSDK {
|
|
22
|
+
/** Resolved endpoint configuration (defaults + caller overrides). */
|
|
23
|
+
endpoints;
|
|
24
|
+
/** Application DID (as declared in mandates). */
|
|
25
|
+
appDid;
|
|
26
|
+
/** User DID (derived from `config.identity`). */
|
|
27
|
+
userDid;
|
|
28
|
+
/** Compute proxy namespace — Bedrock invocation. */
|
|
29
|
+
compute;
|
|
30
|
+
/** Wallet namespace — Stripe top-up. */
|
|
31
|
+
wallet;
|
|
32
|
+
constructor(config) {
|
|
33
|
+
if (!config.identity) {
|
|
34
|
+
throw new TypeError("AithosSDK: config.identity is required");
|
|
35
|
+
}
|
|
36
|
+
if (!config.appDid || typeof config.appDid !== "string") {
|
|
37
|
+
throw new TypeError("AithosSDK: config.appDid is required (string)");
|
|
38
|
+
}
|
|
39
|
+
this.endpoints = resolveEndpoints(config.endpoints);
|
|
40
|
+
this.appDid = config.appDid;
|
|
41
|
+
this.userDid = config.identity.did;
|
|
42
|
+
const fetchImpl = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
43
|
+
this.compute = new ComputeNamespace({
|
|
44
|
+
identity: config.identity,
|
|
45
|
+
appDid: config.appDid,
|
|
46
|
+
endpoints: this.endpoints,
|
|
47
|
+
fetch: fetchImpl,
|
|
48
|
+
});
|
|
49
|
+
this.wallet = new WalletNamespace({
|
|
50
|
+
userDid: config.identity.did,
|
|
51
|
+
endpoints: this.endpoints,
|
|
52
|
+
fetch: fetchImpl,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { BrowserIdentity } from "@aithos/protocol-client";
|
|
2
|
+
import type { AithosSdkEndpoints } from "./endpoints.js";
|
|
3
|
+
/**
|
|
4
|
+
* Construction options for {@link AithosSDK}.
|
|
5
|
+
*/
|
|
6
|
+
export interface AithosSDKConfig {
|
|
7
|
+
/** User identity (Ed25519/X25519 keypairs + DID). */
|
|
8
|
+
readonly identity: BrowserIdentity;
|
|
9
|
+
/**
|
|
10
|
+
* Application DID. Identifies the calling app in mandates, audit logs,
|
|
11
|
+
* billing splits. Issued at developer onboarding (will be self-service
|
|
12
|
+
* before 0.1.0 stable).
|
|
13
|
+
*/
|
|
14
|
+
readonly appDid: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional endpoint overrides. Production defaults point at the Aithos
|
|
17
|
+
* infrastructure; pass overrides for staging, self-hosting, tests.
|
|
18
|
+
*/
|
|
19
|
+
readonly endpoints?: Partial<AithosSdkEndpoints>;
|
|
20
|
+
/**
|
|
21
|
+
* Optional fetch implementation. Defaults to the global `fetch`. Used by
|
|
22
|
+
* tests to inject a mock without monkeypatching globals.
|
|
23
|
+
*/
|
|
24
|
+
readonly fetch?: typeof fetch;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* SDK-level error class. The `code` field is a stable string suitable for
|
|
28
|
+
* `switch` statements; the underlying HTTP status (when applicable) is in
|
|
29
|
+
* `status`.
|
|
30
|
+
*/
|
|
31
|
+
export declare class AithosSDKError extends Error {
|
|
32
|
+
readonly code: string;
|
|
33
|
+
readonly status: number | undefined;
|
|
34
|
+
readonly data: Record<string, unknown> | undefined;
|
|
35
|
+
constructor(code: string, message: string, options?: {
|
|
36
|
+
status?: number;
|
|
37
|
+
data?: Record<string, unknown>;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
/**
|
|
4
|
+
* SDK-level error class. The `code` field is a stable string suitable for
|
|
5
|
+
* `switch` statements; the underlying HTTP status (when applicable) is in
|
|
6
|
+
* `status`.
|
|
7
|
+
*/
|
|
8
|
+
export class AithosSDKError extends Error {
|
|
9
|
+
code;
|
|
10
|
+
status;
|
|
11
|
+
data;
|
|
12
|
+
constructor(code, message, options) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "AithosSDKError";
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.status = options?.status;
|
|
17
|
+
this.data = options?.data;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type AithosSdkEndpoints } from "./endpoints.js";
|
|
2
|
+
/**
|
|
3
|
+
* Canonical credit-pack identifiers. Pricing and microcredit amounts are
|
|
4
|
+
* authoritative server-side; the SDK only forwards the pack id.
|
|
5
|
+
*
|
|
6
|
+
* - `credits-100k` — 100K microcredits (S, ~5 €)
|
|
7
|
+
* - `credits-1m` — 1M microcredits + 10 % bonus (M, ~45 €)
|
|
8
|
+
* - `credits-5m` — 5M microcredits + 20 % bonus (L, ~200 €)
|
|
9
|
+
*/
|
|
10
|
+
export type CreditPackId = "credits-100k" | "credits-1m" | "credits-5m";
|
|
11
|
+
export interface CreateTopupSessionArgs {
|
|
12
|
+
/** Pack to purchase. */
|
|
13
|
+
readonly packId: CreditPackId;
|
|
14
|
+
/** Where Stripe redirects after a successful payment. */
|
|
15
|
+
readonly successUrl: string;
|
|
16
|
+
/** Where Stripe redirects if the user cancels. */
|
|
17
|
+
readonly cancelUrl: string;
|
|
18
|
+
/** Abort signal to cancel the request. */
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
export interface CreateTopupSessionResult {
|
|
22
|
+
/** Hosted Stripe Checkout URL — redirect the user there. */
|
|
23
|
+
readonly checkoutUrl: string;
|
|
24
|
+
/** Stripe Checkout session id (for diagnostics). */
|
|
25
|
+
readonly sessionId: string;
|
|
26
|
+
}
|
|
27
|
+
export interface WalletNamespaceDeps {
|
|
28
|
+
readonly userDid: string;
|
|
29
|
+
readonly endpoints: AithosSdkEndpoints;
|
|
30
|
+
readonly fetch: typeof fetch;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* `sdk.wallet` namespace.
|
|
34
|
+
*/
|
|
35
|
+
export declare class WalletNamespace {
|
|
36
|
+
#private;
|
|
37
|
+
constructor(deps: WalletNamespaceDeps);
|
|
38
|
+
/**
|
|
39
|
+
* Create a Stripe Checkout session for a credit-pack purchase. Returns the
|
|
40
|
+
* hosted URL — the caller is responsible for redirecting the user (e.g.
|
|
41
|
+
* `window.location.href = result.checkoutUrl`).
|
|
42
|
+
*
|
|
43
|
+
* On success, the Stripe webhook will credit `userDid`'s wallet once the
|
|
44
|
+
* payment clears. Wallet balances are shared across all Aithos apps that
|
|
45
|
+
* use the same DID.
|
|
46
|
+
*/
|
|
47
|
+
createTopupSession(args: CreateTopupSessionArgs): Promise<CreateTopupSessionResult>;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// Wallet namespace — Stripe Checkout for credit-pack top-ups.
|
|
4
|
+
//
|
|
5
|
+
// Posts to `${wallet}/v1/wallet/topup/checkout`. The Lambda creates a
|
|
6
|
+
// Stripe Checkout session bound to the user's DID via `metadata`, returns
|
|
7
|
+
// the hosted URL. The frontend then redirects the user. Stripe webhook
|
|
8
|
+
// (server-side) credits the wallet on `checkout.session.completed`.
|
|
9
|
+
//
|
|
10
|
+
// v0 scope: no envelope verify on the checkout endpoint — the link is
|
|
11
|
+
// single-use and metadata-bound to `user_did`. Anyone creating a session
|
|
12
|
+
// for someone else's DID would just gift them credits, no value to an
|
|
13
|
+
// attacker. Envelope-verify gets added in a follow-up if abuse appears.
|
|
14
|
+
import { walletTopupCheckoutUrl, } from "./endpoints.js";
|
|
15
|
+
import { AithosSDKError } from "./types.js";
|
|
16
|
+
/**
|
|
17
|
+
* `sdk.wallet` namespace.
|
|
18
|
+
*/
|
|
19
|
+
export class WalletNamespace {
|
|
20
|
+
#deps;
|
|
21
|
+
constructor(deps) {
|
|
22
|
+
this.#deps = deps;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a Stripe Checkout session for a credit-pack purchase. Returns the
|
|
26
|
+
* hosted URL — the caller is responsible for redirecting the user (e.g.
|
|
27
|
+
* `window.location.href = result.checkoutUrl`).
|
|
28
|
+
*
|
|
29
|
+
* On success, the Stripe webhook will credit `userDid`'s wallet once the
|
|
30
|
+
* payment clears. Wallet balances are shared across all Aithos apps that
|
|
31
|
+
* use the same DID.
|
|
32
|
+
*/
|
|
33
|
+
async createTopupSession(args) {
|
|
34
|
+
const { userDid, endpoints, fetch: fetchImpl } = this.#deps;
|
|
35
|
+
const url = walletTopupCheckoutUrl(endpoints);
|
|
36
|
+
let res;
|
|
37
|
+
try {
|
|
38
|
+
res = await fetchImpl(url, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers: { "content-type": "application/json" },
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
user_did: userDid,
|
|
43
|
+
pack_id: args.packId,
|
|
44
|
+
success_url: args.successUrl,
|
|
45
|
+
cancel_url: args.cancelUrl,
|
|
46
|
+
}),
|
|
47
|
+
...(args.signal ? { signal: args.signal } : {}),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
throw new AithosSDKError("network", e.message);
|
|
52
|
+
}
|
|
53
|
+
let body;
|
|
54
|
+
try {
|
|
55
|
+
body = await res.json();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new AithosSDKError("http", `HTTP ${res.status} ${res.statusText} — non-JSON response`, { status: res.status });
|
|
59
|
+
}
|
|
60
|
+
if (!res.ok) {
|
|
61
|
+
const err = body;
|
|
62
|
+
throw new AithosSDKError(err.error ?? "http", err.detail ?? `HTTP ${res.status} ${res.statusText}`, { status: res.status });
|
|
63
|
+
}
|
|
64
|
+
const ok = body;
|
|
65
|
+
if (typeof ok.checkout_url !== "string" || typeof ok.session_id !== "string") {
|
|
66
|
+
throw new AithosSDKError("empty", "wallet response missing checkout_url or session_id");
|
|
67
|
+
}
|
|
68
|
+
return { checkoutUrl: ok.checkout_url, sessionId: ok.session_id };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// Unit tests for sdk.compute.invokeBedrock with a mock fetch.
|
|
4
|
+
//
|
|
5
|
+
// We construct a real BrowserIdentity (Ed25519 keypairs are synchronous)
|
|
6
|
+
// rather than stubbing it out — that way the envelope-signing path runs
|
|
7
|
+
// for real and any signature/canonicalization regression in the SDK or
|
|
8
|
+
// in protocol-client surfaces here.
|
|
9
|
+
import { strict as assert } from "node:assert";
|
|
10
|
+
import { describe, it } from "node:test";
|
|
11
|
+
import { createBrowserIdentity } from "@aithos/protocol-client";
|
|
12
|
+
import { AithosSDK, AithosSDKError } from "../src/index.js";
|
|
13
|
+
const APP_DID = "did:aithos:app:test";
|
|
14
|
+
function makeSdk(fetchImpl) {
|
|
15
|
+
const identity = createBrowserIdentity("test-handle", "Test User");
|
|
16
|
+
return new AithosSDK({
|
|
17
|
+
identity,
|
|
18
|
+
appDid: APP_DID,
|
|
19
|
+
endpoints: { compute: "https://compute.example.test" },
|
|
20
|
+
fetch: fetchImpl,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const HAPPY_RESULT = {
|
|
24
|
+
content: "Hello, Aithos!",
|
|
25
|
+
stopReason: "end_turn",
|
|
26
|
+
usage: { inputTokens: 12, outputTokens: 8 },
|
|
27
|
+
creditsCharged: 9,
|
|
28
|
+
walletBalance: 99_991,
|
|
29
|
+
auditId: "audit-1",
|
|
30
|
+
};
|
|
31
|
+
describe("compute.invokeBedrock — happy path", () => {
|
|
32
|
+
it("posts to ${compute}/v1/invoke with a JSON-RPC envelope and parses the result", async () => {
|
|
33
|
+
let capturedUrl;
|
|
34
|
+
let capturedInit;
|
|
35
|
+
const fakeFetch = async (input, init) => {
|
|
36
|
+
capturedUrl = typeof input === "string" ? input : input.toString();
|
|
37
|
+
capturedInit = init;
|
|
38
|
+
return new Response(JSON.stringify({ result: HAPPY_RESULT }), {
|
|
39
|
+
status: 200,
|
|
40
|
+
headers: { "content-type": "application/json" },
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const sdk = makeSdk(fakeFetch);
|
|
44
|
+
const out = await sdk.compute.invokeBedrock({
|
|
45
|
+
mandateId: "mandate:abc",
|
|
46
|
+
model: "claude-sonnet-4-6",
|
|
47
|
+
messages: [{ role: "user", content: "Hi" }],
|
|
48
|
+
});
|
|
49
|
+
assert.deepEqual(out, HAPPY_RESULT);
|
|
50
|
+
assert.equal(capturedUrl, "https://compute.example.test/v1/invoke");
|
|
51
|
+
assert.equal(capturedInit?.method, "POST");
|
|
52
|
+
const headers = capturedInit?.headers;
|
|
53
|
+
assert.equal(headers["content-type"], "application/json");
|
|
54
|
+
const body = JSON.parse(capturedInit?.body);
|
|
55
|
+
assert.equal(body.jsonrpc, "2.0");
|
|
56
|
+
assert.equal(body.method, "aithos.compute_invoke");
|
|
57
|
+
assert.equal(body.params.app_did, APP_DID);
|
|
58
|
+
assert.equal(body.params.mandate_id, "mandate:abc");
|
|
59
|
+
assert.equal(body.params.model, "claude-sonnet-4-6");
|
|
60
|
+
// Idempotency key is auto-generated when not provided.
|
|
61
|
+
assert.match(body.params.idempotency_key, /^[0-9a-f]{32}$/);
|
|
62
|
+
// Envelope is present on the wire.
|
|
63
|
+
assert.ok(body.params._envelope, "request must carry a signed envelope");
|
|
64
|
+
});
|
|
65
|
+
it("forwards optional system / max_tokens / temperature and respects a caller-provided idempotencyKey", async () => {
|
|
66
|
+
let capturedBody;
|
|
67
|
+
const fakeFetch = async (_input, init) => {
|
|
68
|
+
capturedBody = JSON.parse(init?.body).params;
|
|
69
|
+
return new Response(JSON.stringify({ result: HAPPY_RESULT }), {
|
|
70
|
+
status: 200,
|
|
71
|
+
headers: { "content-type": "application/json" },
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
const sdk = makeSdk(fakeFetch);
|
|
75
|
+
await sdk.compute.invokeBedrock({
|
|
76
|
+
mandateId: "mandate:abc",
|
|
77
|
+
model: "claude-sonnet-4-6",
|
|
78
|
+
messages: [{ role: "user", content: "Hi" }],
|
|
79
|
+
system: "You are concise.",
|
|
80
|
+
maxTokens: 256,
|
|
81
|
+
temperature: 0.2,
|
|
82
|
+
idempotencyKey: "idem-1",
|
|
83
|
+
});
|
|
84
|
+
assert.equal(capturedBody?.system, "You are concise.");
|
|
85
|
+
assert.equal(capturedBody?.max_tokens, 256);
|
|
86
|
+
assert.equal(capturedBody?.temperature, 0.2);
|
|
87
|
+
assert.equal(capturedBody?.idempotency_key, "idem-1");
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
describe("compute.invokeBedrock — errors", () => {
|
|
91
|
+
it("wraps a network failure as AithosSDKError(code='network')", async () => {
|
|
92
|
+
const fakeFetch = async () => {
|
|
93
|
+
throw new Error("fetch failed: ECONNREFUSED");
|
|
94
|
+
};
|
|
95
|
+
const sdk = makeSdk(fakeFetch);
|
|
96
|
+
await assert.rejects(sdk.compute.invokeBedrock({
|
|
97
|
+
mandateId: "mandate:abc",
|
|
98
|
+
model: "claude-sonnet-4-6",
|
|
99
|
+
messages: [{ role: "user", content: "Hi" }],
|
|
100
|
+
}), (err) => {
|
|
101
|
+
assert.ok(err instanceof AithosSDKError);
|
|
102
|
+
assert.equal(err.code, "network");
|
|
103
|
+
assert.match(err.message, /ECONNREFUSED/);
|
|
104
|
+
return true;
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
it("wraps an HTTP non-2xx as AithosSDKError(code='http')", async () => {
|
|
108
|
+
const fakeFetch = async () => new Response("nope", { status: 503, statusText: "Service Unavailable" });
|
|
109
|
+
const sdk = makeSdk(fakeFetch);
|
|
110
|
+
await assert.rejects(sdk.compute.invokeBedrock({
|
|
111
|
+
mandateId: "mandate:abc",
|
|
112
|
+
model: "claude-sonnet-4-6",
|
|
113
|
+
messages: [{ role: "user", content: "Hi" }],
|
|
114
|
+
}), (err) => {
|
|
115
|
+
assert.ok(err instanceof AithosSDKError);
|
|
116
|
+
assert.equal(err.code, "http");
|
|
117
|
+
assert.equal(err.status, 503);
|
|
118
|
+
return true;
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
it("wraps a JSON-RPC error response with the proxy's code and message", async () => {
|
|
122
|
+
const fakeFetch = async () => new Response(JSON.stringify({
|
|
123
|
+
error: {
|
|
124
|
+
code: 402,
|
|
125
|
+
message: "insufficient_credits",
|
|
126
|
+
data: { balance: 0, required: 1 },
|
|
127
|
+
},
|
|
128
|
+
}), { status: 200, headers: { "content-type": "application/json" } });
|
|
129
|
+
const sdk = makeSdk(fakeFetch);
|
|
130
|
+
await assert.rejects(sdk.compute.invokeBedrock({
|
|
131
|
+
mandateId: "mandate:abc",
|
|
132
|
+
model: "claude-sonnet-4-6",
|
|
133
|
+
messages: [{ role: "user", content: "Hi" }],
|
|
134
|
+
}), (err) => {
|
|
135
|
+
assert.ok(err instanceof AithosSDKError);
|
|
136
|
+
assert.equal(err.code, "402");
|
|
137
|
+
assert.equal(err.message, "insufficient_credits");
|
|
138
|
+
return true;
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
it("rejects an empty result payload as AithosSDKError(code='empty')", async () => {
|
|
142
|
+
const fakeFetch = async () => new Response(JSON.stringify({}), {
|
|
143
|
+
status: 200,
|
|
144
|
+
headers: { "content-type": "application/json" },
|
|
145
|
+
});
|
|
146
|
+
const sdk = makeSdk(fakeFetch);
|
|
147
|
+
await assert.rejects(sdk.compute.invokeBedrock({
|
|
148
|
+
mandateId: "mandate:abc",
|
|
149
|
+
model: "claude-sonnet-4-6",
|
|
150
|
+
messages: [{ role: "user", content: "Hi" }],
|
|
151
|
+
}), (err) => {
|
|
152
|
+
assert.ok(err instanceof AithosSDKError);
|
|
153
|
+
assert.equal(err.code, "empty");
|
|
154
|
+
return true;
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
describe("compute.invokeBedrock — abort", () => {
|
|
159
|
+
it("propagates an AbortSignal to fetch", async () => {
|
|
160
|
+
let receivedSignal;
|
|
161
|
+
const fakeFetch = async (_input, init) => {
|
|
162
|
+
receivedSignal = init?.signal;
|
|
163
|
+
return new Response(JSON.stringify({ result: HAPPY_RESULT }), {
|
|
164
|
+
status: 200,
|
|
165
|
+
headers: { "content-type": "application/json" },
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
const sdk = makeSdk(fakeFetch);
|
|
169
|
+
const ac = new AbortController();
|
|
170
|
+
await sdk.compute.invokeBedrock({
|
|
171
|
+
mandateId: "mandate:abc",
|
|
172
|
+
model: "claude-sonnet-4-6",
|
|
173
|
+
messages: [{ role: "user", content: "Hi" }],
|
|
174
|
+
signal: ac.signal,
|
|
175
|
+
});
|
|
176
|
+
assert.equal(receivedSignal, ac.signal);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
//# sourceMappingURL=compute.test.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// Unit tests for endpoint resolution + URL composition.
|
|
4
|
+
import { strict as assert } from "node:assert";
|
|
5
|
+
import { describe, it } from "node:test";
|
|
6
|
+
import { DEFAULT_SDK_ENDPOINTS } from "../src/index.js";
|
|
7
|
+
import { computeInvokeUrl, resolveEndpoints, walletTopupCheckoutUrl, } from "../src/endpoints.js";
|
|
8
|
+
describe("resolveEndpoints", () => {
|
|
9
|
+
it("returns a fresh copy of the defaults when no override is given", () => {
|
|
10
|
+
const a = resolveEndpoints();
|
|
11
|
+
const b = resolveEndpoints();
|
|
12
|
+
assert.deepEqual(a, DEFAULT_SDK_ENDPOINTS);
|
|
13
|
+
assert.notEqual(a, b, "resolveEndpoints must not return a shared instance");
|
|
14
|
+
});
|
|
15
|
+
it("merges partial overrides on top of the defaults", () => {
|
|
16
|
+
const e = resolveEndpoints({ compute: "https://staging.aithos.be" });
|
|
17
|
+
assert.equal(e.compute, "https://staging.aithos.be");
|
|
18
|
+
assert.equal(e.wallet, DEFAULT_SDK_ENDPOINTS.wallet);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe("computeInvokeUrl", () => {
|
|
22
|
+
it("appends /v1/invoke to the compute base", () => {
|
|
23
|
+
assert.equal(computeInvokeUrl({
|
|
24
|
+
compute: "https://compute.aithos.be",
|
|
25
|
+
wallet: "https://wallet.aithos.be",
|
|
26
|
+
}), "https://compute.aithos.be/v1/invoke");
|
|
27
|
+
});
|
|
28
|
+
it("trims a trailing slash on the compute base", () => {
|
|
29
|
+
assert.equal(computeInvokeUrl({
|
|
30
|
+
compute: "https://compute.aithos.be/",
|
|
31
|
+
wallet: "https://wallet.aithos.be",
|
|
32
|
+
}), "https://compute.aithos.be/v1/invoke");
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe("walletTopupCheckoutUrl", () => {
|
|
36
|
+
it("appends /v1/wallet/topup/checkout to the wallet base", () => {
|
|
37
|
+
assert.equal(walletTopupCheckoutUrl({
|
|
38
|
+
compute: "https://compute.aithos.be",
|
|
39
|
+
wallet: "https://wallet.aithos.be",
|
|
40
|
+
}), "https://wallet.aithos.be/v1/wallet/topup/checkout");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=endpoints.test.js.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// Smoke tests for the AithosSDK construction surface.
|
|
4
|
+
//
|
|
5
|
+
// Runtime tests of `compute.invokeBedrock` and `wallet.createTopupSession`
|
|
6
|
+
// require either a running compute proxy or a more elaborate fetch mock
|
|
7
|
+
// pattern; we land them in a follow-up commit alongside the rest of Phase 4
|
|
8
|
+
// (mock-fetch unit tests for both namespaces).
|
|
9
|
+
import { strict as assert } from "node:assert";
|
|
10
|
+
import { describe, it } from "node:test";
|
|
11
|
+
import { AithosSDK, AithosSDKError, DEFAULT_SDK_ENDPOINTS, VERSION, } from "../src/index.js";
|
|
12
|
+
// We can't easily mint a real BrowserIdentity in a synchronous unit test
|
|
13
|
+
// without crypto setup; the constructor only reads `.did` from it, so a
|
|
14
|
+
// minimal stub is enough for the construction-surface tests below.
|
|
15
|
+
function fakeIdentity(did) {
|
|
16
|
+
return { did };
|
|
17
|
+
}
|
|
18
|
+
describe("VERSION", () => {
|
|
19
|
+
it("is a non-empty semver-ish string", () => {
|
|
20
|
+
assert.equal(typeof VERSION, "string");
|
|
21
|
+
assert.match(VERSION, /^\d+\.\d+\.\d+/);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe("DEFAULT_SDK_ENDPOINTS", () => {
|
|
25
|
+
it("points at the production Aithos hosts", () => {
|
|
26
|
+
assert.equal(DEFAULT_SDK_ENDPOINTS.compute, "https://compute.aithos.be");
|
|
27
|
+
assert.equal(DEFAULT_SDK_ENDPOINTS.wallet, "https://wallet.aithos.be");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
describe("AithosSDK constructor", () => {
|
|
31
|
+
const id = fakeIdentity("did:aithos:smoke");
|
|
32
|
+
const appDid = "did:aithos:app:smoke";
|
|
33
|
+
it("requires an identity", () => {
|
|
34
|
+
assert.throws(() =>
|
|
35
|
+
// @ts-expect-error: deliberately passing an invalid config
|
|
36
|
+
new AithosSDK({ appDid }), /identity/);
|
|
37
|
+
});
|
|
38
|
+
it("requires an appDid", () => {
|
|
39
|
+
assert.throws(() =>
|
|
40
|
+
// @ts-expect-error: deliberately passing an invalid config
|
|
41
|
+
new AithosSDK({ identity: id }), /appDid/);
|
|
42
|
+
});
|
|
43
|
+
it("exposes endpoints, appDid, userDid", () => {
|
|
44
|
+
const sdk = new AithosSDK({ identity: id, appDid });
|
|
45
|
+
assert.equal(sdk.appDid, appDid);
|
|
46
|
+
assert.equal(sdk.userDid, "did:aithos:smoke");
|
|
47
|
+
assert.equal(sdk.endpoints.compute, DEFAULT_SDK_ENDPOINTS.compute);
|
|
48
|
+
assert.equal(sdk.endpoints.wallet, DEFAULT_SDK_ENDPOINTS.wallet);
|
|
49
|
+
});
|
|
50
|
+
it("merges endpoint overrides on top of defaults", () => {
|
|
51
|
+
const sdk = new AithosSDK({
|
|
52
|
+
identity: id,
|
|
53
|
+
appDid,
|
|
54
|
+
endpoints: { wallet: "https://staging-wallet.aithos.be" },
|
|
55
|
+
});
|
|
56
|
+
assert.equal(sdk.endpoints.compute, DEFAULT_SDK_ENDPOINTS.compute);
|
|
57
|
+
assert.equal(sdk.endpoints.wallet, "https://staging-wallet.aithos.be");
|
|
58
|
+
});
|
|
59
|
+
it("trims trailing slashes on endpoint URLs at compose time", async () => {
|
|
60
|
+
// Inject a fetch that captures the URL the SDK chose.
|
|
61
|
+
let capturedUrl;
|
|
62
|
+
const fakeFetch = async (input) => {
|
|
63
|
+
capturedUrl = typeof input === "string" ? input : input.toString();
|
|
64
|
+
// Reject so we don't have to construct a full happy-path response.
|
|
65
|
+
throw new Error("captured");
|
|
66
|
+
};
|
|
67
|
+
const sdk = new AithosSDK({
|
|
68
|
+
identity: id,
|
|
69
|
+
appDid,
|
|
70
|
+
endpoints: { wallet: "https://wallet.example.com/" }, // trailing slash
|
|
71
|
+
fetch: fakeFetch,
|
|
72
|
+
});
|
|
73
|
+
await assert.rejects(sdk.wallet.createTopupSession({
|
|
74
|
+
packId: "credits-100k",
|
|
75
|
+
successUrl: "https://app.example.com/?ok",
|
|
76
|
+
cancelUrl: "https://app.example.com/?ko",
|
|
77
|
+
}), AithosSDKError);
|
|
78
|
+
assert.equal(capturedUrl, "https://wallet.example.com/v1/wallet/topup/checkout");
|
|
79
|
+
});
|
|
80
|
+
it("exposes namespaces compute, wallet", () => {
|
|
81
|
+
const sdk = new AithosSDK({ identity: id, appDid });
|
|
82
|
+
assert.equal(typeof sdk.compute.invokeBedrock, "function");
|
|
83
|
+
assert.equal(typeof sdk.wallet.createTopupSession, "function");
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=sdk.test.js.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright 2026 Mathieu Colla
|
|
3
|
+
// Unit tests for sdk.wallet.createTopupSession with a mock fetch.
|
|
4
|
+
import { strict as assert } from "node:assert";
|
|
5
|
+
import { describe, it } from "node:test";
|
|
6
|
+
import { createBrowserIdentity } from "@aithos/protocol-client";
|
|
7
|
+
import { AithosSDK, AithosSDKError } from "../src/index.js";
|
|
8
|
+
const APP_DID = "did:aithos:app:test";
|
|
9
|
+
function makeSdk(fetchImpl) {
|
|
10
|
+
const identity = createBrowserIdentity("test-handle", "Test User");
|
|
11
|
+
return new AithosSDK({
|
|
12
|
+
identity,
|
|
13
|
+
appDid: APP_DID,
|
|
14
|
+
endpoints: { wallet: "https://wallet.example.test" },
|
|
15
|
+
fetch: fetchImpl,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
describe("wallet.createTopupSession — happy path", () => {
|
|
19
|
+
it("posts user_did + pack_id + urls and returns the hosted URL", async () => {
|
|
20
|
+
let capturedUrl;
|
|
21
|
+
let capturedBody;
|
|
22
|
+
const fakeFetch = async (input, init) => {
|
|
23
|
+
capturedUrl = typeof input === "string" ? input : input.toString();
|
|
24
|
+
capturedBody = JSON.parse(init?.body);
|
|
25
|
+
return new Response(JSON.stringify({
|
|
26
|
+
checkout_url: "https://checkout.stripe.com/c/pay/cs_test_xyz",
|
|
27
|
+
session_id: "cs_test_xyz",
|
|
28
|
+
}), { status: 200, headers: { "content-type": "application/json" } });
|
|
29
|
+
};
|
|
30
|
+
const sdk = makeSdk(fakeFetch);
|
|
31
|
+
const out = await sdk.wallet.createTopupSession({
|
|
32
|
+
packId: "credits-1m",
|
|
33
|
+
successUrl: "https://app.example.com/?topup=success",
|
|
34
|
+
cancelUrl: "https://app.example.com/?topup=cancel",
|
|
35
|
+
});
|
|
36
|
+
assert.equal(out.checkoutUrl, "https://checkout.stripe.com/c/pay/cs_test_xyz");
|
|
37
|
+
assert.equal(out.sessionId, "cs_test_xyz");
|
|
38
|
+
assert.equal(capturedUrl, "https://wallet.example.test/v1/wallet/topup/checkout");
|
|
39
|
+
assert.equal(capturedBody?.user_did, sdk.userDid);
|
|
40
|
+
assert.equal(capturedBody?.pack_id, "credits-1m");
|
|
41
|
+
assert.equal(capturedBody?.success_url, "https://app.example.com/?topup=success");
|
|
42
|
+
assert.equal(capturedBody?.cancel_url, "https://app.example.com/?topup=cancel");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe("wallet.createTopupSession — errors", () => {
|
|
46
|
+
it("wraps a network failure as AithosSDKError(code='network')", async () => {
|
|
47
|
+
const fakeFetch = async () => {
|
|
48
|
+
throw new TypeError("Failed to fetch");
|
|
49
|
+
};
|
|
50
|
+
const sdk = makeSdk(fakeFetch);
|
|
51
|
+
await assert.rejects(sdk.wallet.createTopupSession({
|
|
52
|
+
packId: "credits-100k",
|
|
53
|
+
successUrl: "https://app.example.com/?ok",
|
|
54
|
+
cancelUrl: "https://app.example.com/?ko",
|
|
55
|
+
}), (err) => {
|
|
56
|
+
assert.ok(err instanceof AithosSDKError);
|
|
57
|
+
assert.equal(err.code, "network");
|
|
58
|
+
return true;
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
it("surfaces the proxy's structured error (error/detail) on a 4xx", async () => {
|
|
62
|
+
const fakeFetch = async () => new Response(JSON.stringify({ error: "unknown_pack", pack_id: "credits-9999" }), { status: 400, headers: { "content-type": "application/json" } });
|
|
63
|
+
const sdk = makeSdk(fakeFetch);
|
|
64
|
+
await assert.rejects(sdk.wallet.createTopupSession({
|
|
65
|
+
// @ts-expect-error: deliberately invalid pack id
|
|
66
|
+
packId: "credits-9999",
|
|
67
|
+
successUrl: "https://app.example.com/?ok",
|
|
68
|
+
cancelUrl: "https://app.example.com/?ko",
|
|
69
|
+
}), (err) => {
|
|
70
|
+
assert.ok(err instanceof AithosSDKError);
|
|
71
|
+
assert.equal(err.code, "unknown_pack");
|
|
72
|
+
assert.equal(err.status, 400);
|
|
73
|
+
return true;
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
it("rejects a non-JSON response as AithosSDKError(code='http')", async () => {
|
|
77
|
+
const fakeFetch = async () => new Response("<html>500</html>", {
|
|
78
|
+
status: 500,
|
|
79
|
+
headers: { "content-type": "text/html" },
|
|
80
|
+
});
|
|
81
|
+
const sdk = makeSdk(fakeFetch);
|
|
82
|
+
await assert.rejects(sdk.wallet.createTopupSession({
|
|
83
|
+
packId: "credits-100k",
|
|
84
|
+
successUrl: "https://app.example.com/?ok",
|
|
85
|
+
cancelUrl: "https://app.example.com/?ko",
|
|
86
|
+
}), (err) => {
|
|
87
|
+
assert.ok(err instanceof AithosSDKError);
|
|
88
|
+
assert.equal(err.code, "http");
|
|
89
|
+
assert.equal(err.status, 500);
|
|
90
|
+
return true;
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
it("rejects a 200 with missing fields as AithosSDKError(code='empty')", async () => {
|
|
94
|
+
const fakeFetch = async () => new Response(JSON.stringify({}), {
|
|
95
|
+
status: 200,
|
|
96
|
+
headers: { "content-type": "application/json" },
|
|
97
|
+
});
|
|
98
|
+
const sdk = makeSdk(fakeFetch);
|
|
99
|
+
await assert.rejects(sdk.wallet.createTopupSession({
|
|
100
|
+
packId: "credits-100k",
|
|
101
|
+
successUrl: "https://app.example.com/?ok",
|
|
102
|
+
cancelUrl: "https://app.example.com/?ko",
|
|
103
|
+
}), (err) => {
|
|
104
|
+
assert.ok(err instanceof AithosSDKError);
|
|
105
|
+
assert.equal(err.code, "empty");
|
|
106
|
+
return true;
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=wallet.test.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aithos/sdk",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "Aithos SDK — high-level TypeScript developer kit for building agentic apps on the Aithos protocol. Wraps @aithos/protocol-client and exposes the Aithos compute proxy and wallet (Stripe top-up) endpoints.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"aithos",
|
|
7
|
+
"sdk",
|
|
8
|
+
"agent",
|
|
9
|
+
"bedrock",
|
|
10
|
+
"claude",
|
|
11
|
+
"wallet",
|
|
12
|
+
"stripe",
|
|
13
|
+
"did",
|
|
14
|
+
"ed25519"
|
|
15
|
+
],
|
|
16
|
+
"license": "Apache-2.0",
|
|
17
|
+
"author": "Aithos",
|
|
18
|
+
"homepage": "https://aithos.be",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/aithos-protocol/aithos-sdk.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/aithos-protocol/aithos-sdk/issues"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/src/index.d.ts",
|
|
30
|
+
"import": "./dist/src/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"main": "./dist/src/index.js",
|
|
35
|
+
"types": "./dist/src/index.d.ts",
|
|
36
|
+
"files": [
|
|
37
|
+
"dist/**/*.js",
|
|
38
|
+
"dist/**/*.d.ts",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc",
|
|
44
|
+
"build:test": "tsc -p tsconfig.test.json",
|
|
45
|
+
"check-types": "tsc --noEmit && tsc -p tsconfig.test.json --noEmit",
|
|
46
|
+
"test": "npm run clean && npm run build && npm run build:test && cd dist && node --test",
|
|
47
|
+
"test:watch": "cd dist && node --test --watch",
|
|
48
|
+
"clean": "rm -rf dist",
|
|
49
|
+
"prepublishOnly": "npm run clean && npm run build && npm test"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=20"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@aithos/protocol-client": ">=0.1.0-alpha.7 <0.2.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@aithos/protocol-client": "^0.1.0-alpha.7",
|
|
59
|
+
"@types/node": "^24.12.2",
|
|
60
|
+
"typescript": "^5.9.2"
|
|
61
|
+
},
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public",
|
|
64
|
+
"tag": "alpha"
|
|
65
|
+
}
|
|
66
|
+
}
|