@aithos/sdk 0.1.0-alpha.39 → 0.1.0-alpha.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/assets.d.ts +207 -0
- package/dist/src/assets.js +533 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/react/AithosAsset.d.ts +66 -0
- package/dist/src/react/AithosAsset.js +67 -0
- package/dist/src/react/context.d.ts +29 -0
- package/dist/src/react/context.js +31 -0
- package/dist/src/react/index.d.ts +28 -0
- package/dist/src/react/index.js +30 -0
- package/dist/src/react/use-aithos-asset.d.ts +39 -0
- package/dist/src/react/use-aithos-asset.js +118 -0
- package/package.json +16 -2
- package/dist/test/auth-j3.test.d.ts +0 -2
- package/dist/test/auth-j3.test.js +0 -391
- package/dist/test/auth.test.d.ts +0 -2
- package/dist/test/auth.test.js +0 -175
- package/dist/test/compute-delegate-path.test.d.ts +0 -2
- package/dist/test/compute-delegate-path.test.js +0 -183
- package/dist/test/compute.test.d.ts +0 -2
- package/dist/test/compute.test.js +0 -194
- package/dist/test/endpoints.test.d.ts +0 -2
- package/dist/test/endpoints.test.js +0 -62
- package/dist/test/envelope.test.d.ts +0 -2
- package/dist/test/envelope.test.js +0 -318
- package/dist/test/ethos-first-edition.test.d.ts +0 -2
- package/dist/test/ethos-first-edition.test.js +0 -248
- package/dist/test/ethos.test.d.ts +0 -2
- package/dist/test/ethos.test.js +0 -219
- package/dist/test/key-store.test.d.ts +0 -2
- package/dist/test/key-store.test.js +0 -161
- package/dist/test/mandates-compute.test.d.ts +0 -2
- package/dist/test/mandates-compute.test.js +0 -256
- package/dist/test/mandates.test.d.ts +0 -2
- package/dist/test/mandates.test.js +0 -93
- package/dist/test/sdk.test.d.ts +0 -2
- package/dist/test/sdk.test.js +0 -126
- package/dist/test/signer.test.d.ts +0 -2
- package/dist/test/signer.test.js +0 -117
- package/dist/test/signup-bootstrap.test.d.ts +0 -2
- package/dist/test/signup-bootstrap.test.js +0 -311
- package/dist/test/wallet.test.d.ts +0 -2
- package/dist/test/wallet.test.js +0 -121
- package/dist/test/web.test.d.ts +0 -2
- package/dist/test/web.test.js +0 -270
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Copyright 2026 Mathieu Colla
|
|
3
|
-
// Tests for the delegate signing path on sdk.compute.invokeBedrock.
|
|
4
|
-
// Until alpha.9 the method ALWAYS required an owner — a session that
|
|
5
|
-
// only held a mandate (no owner signers) failed with sdk_no_owner
|
|
6
|
-
// before any network call. From alpha.9 onward, when no owner is
|
|
7
|
-
// loaded but a delegate matches the requested mandate id, the SDK
|
|
8
|
-
// signs the envelope with the delegate's keypair and attaches the
|
|
9
|
-
// SignedMandate.
|
|
10
|
-
import { strict as assert } from "node:assert";
|
|
11
|
-
import { afterEach, beforeEach, describe, it } from "node:test";
|
|
12
|
-
import { createBrowserIdentity } from "@aithos/protocol-client";
|
|
13
|
-
import { AithosAuth, AithosSDKError, ComputeNamespace, memoryKeyStore, noopStore, } from "../src/index.js";
|
|
14
|
-
import { DEFAULT_SDK_ENDPOINTS } from "../src/endpoints.js";
|
|
15
|
-
/* -------------------------------------------------------------------------- */
|
|
16
|
-
/* Test plumbing */
|
|
17
|
-
/* -------------------------------------------------------------------------- */
|
|
18
|
-
let savedFetch;
|
|
19
|
-
let lastRequestBody = null;
|
|
20
|
-
function installFetchMock(response) {
|
|
21
|
-
savedFetch = globalThis.fetch;
|
|
22
|
-
lastRequestBody = null;
|
|
23
|
-
globalThis.fetch = (async (_input, init) => {
|
|
24
|
-
lastRequestBody = JSON.parse(init?.body);
|
|
25
|
-
return new Response(JSON.stringify(response.json), {
|
|
26
|
-
status: response.status ?? 200,
|
|
27
|
-
headers: { "content-type": "application/json" },
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
function uninstallFetchMock() {
|
|
32
|
-
if (savedFetch)
|
|
33
|
-
globalThis.fetch = savedFetch;
|
|
34
|
-
savedFetch = undefined;
|
|
35
|
-
lastRequestBody = null;
|
|
36
|
-
}
|
|
37
|
-
const okResponse = {
|
|
38
|
-
json: {
|
|
39
|
-
jsonrpc: "2.0",
|
|
40
|
-
id: "x",
|
|
41
|
-
result: {
|
|
42
|
-
content: "ok",
|
|
43
|
-
stopReason: "end_turn",
|
|
44
|
-
usage: { inputTokens: 1, outputTokens: 1 },
|
|
45
|
-
creditsCharged: 1,
|
|
46
|
-
walletBalance: 999,
|
|
47
|
-
auditId: "audit-test",
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
function freshAuth() {
|
|
52
|
-
return new AithosAuth({
|
|
53
|
-
sessionStore: noopStore(),
|
|
54
|
-
keyStore: memoryKeyStore(),
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
function freshCompute(auth) {
|
|
58
|
-
return new ComputeNamespace({
|
|
59
|
-
auth,
|
|
60
|
-
appDid: "did:aithos:app:example-placeholder",
|
|
61
|
-
endpoints: DEFAULT_SDK_ENDPOINTS,
|
|
62
|
-
fetch: globalThis.fetch.bind(globalThis),
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Build a delegate bundle JSON that matches the wire shape importMandate
|
|
67
|
-
* accepts. Uses a real SignedMandate-like object minted from a fresh
|
|
68
|
-
* issuer so signature verification on import succeeds.
|
|
69
|
-
*/
|
|
70
|
-
function makeDelegateBundleText(args) {
|
|
71
|
-
const issuer = createBrowserIdentity("alice", "Alice");
|
|
72
|
-
return JSON.stringify({
|
|
73
|
-
aithos_delegate_version: "0.1.0",
|
|
74
|
-
mandate: {
|
|
75
|
-
"aithos-mandate": "0.4.0",
|
|
76
|
-
id: args.mandateId,
|
|
77
|
-
issuer: issuer.did,
|
|
78
|
-
issued_by_key: `${issuer.did}#self`,
|
|
79
|
-
grantee: {
|
|
80
|
-
id: args.granteeId ?? "urn:aithos:agent:test",
|
|
81
|
-
pubkey: "z6MkqGenericPubKey",
|
|
82
|
-
},
|
|
83
|
-
actor_sphere: "self",
|
|
84
|
-
scopes: args.scopes,
|
|
85
|
-
not_before: "2026-05-10T00:00:00Z",
|
|
86
|
-
not_after: "2026-05-11T00:00:00Z",
|
|
87
|
-
issued_at: "2026-05-10T00:00:00Z",
|
|
88
|
-
nonce: "abc",
|
|
89
|
-
signature: { alg: "ed25519", key: `${issuer.did}#self`, value: "..." },
|
|
90
|
-
},
|
|
91
|
-
delegate_seed_hex: "11".repeat(32),
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
/* -------------------------------------------------------------------------- */
|
|
95
|
-
/* Tests */
|
|
96
|
-
/* -------------------------------------------------------------------------- */
|
|
97
|
-
describe("ComputeNamespace.invokeBedrock — delegate path", () => {
|
|
98
|
-
beforeEach(() => {
|
|
99
|
-
installFetchMock(okResponse);
|
|
100
|
-
});
|
|
101
|
-
afterEach(() => {
|
|
102
|
-
uninstallFetchMock();
|
|
103
|
-
});
|
|
104
|
-
it("rejects with sdk_no_delegate_for_mandate when delegate-only and mandateId doesn't match", async () => {
|
|
105
|
-
const auth = freshAuth();
|
|
106
|
-
const compute = freshCompute(auth);
|
|
107
|
-
// Import a delegate with a DIFFERENT mandate id than the one the call
|
|
108
|
-
// requests. Should error with the new code (NOT sdk_no_owner anymore).
|
|
109
|
-
await auth.importMandate({
|
|
110
|
-
bundle: makeDelegateBundleText({
|
|
111
|
-
mandateId: "mandate:held",
|
|
112
|
-
scopes: ["compute.invoke"],
|
|
113
|
-
}),
|
|
114
|
-
});
|
|
115
|
-
await assert.rejects(() => compute.invokeBedrock({
|
|
116
|
-
mandateId: "mandate:other-not-held",
|
|
117
|
-
model: "claude-haiku-4-5",
|
|
118
|
-
messages: [{ role: "user", content: "Hi" }],
|
|
119
|
-
maxTokens: 1,
|
|
120
|
-
}), (e) => e instanceof AithosSDKError &&
|
|
121
|
-
e.code === "sdk_no_delegate_for_mandate");
|
|
122
|
-
});
|
|
123
|
-
it("signs with the delegate keypair + attaches the mandate when delegate-only matches", async () => {
|
|
124
|
-
const auth = freshAuth();
|
|
125
|
-
const compute = freshCompute(auth);
|
|
126
|
-
const mandateId = "mandate:matching";
|
|
127
|
-
await auth.importMandate({
|
|
128
|
-
bundle: makeDelegateBundleText({
|
|
129
|
-
mandateId,
|
|
130
|
-
scopes: ["compute.invoke"],
|
|
131
|
-
}),
|
|
132
|
-
});
|
|
133
|
-
await compute.invokeBedrock({
|
|
134
|
-
mandateId,
|
|
135
|
-
model: "claude-haiku-4-5",
|
|
136
|
-
messages: [{ role: "user", content: "Hi" }],
|
|
137
|
-
maxTokens: 1,
|
|
138
|
-
});
|
|
139
|
-
const env = lastRequestBody?.params?._envelope;
|
|
140
|
-
assert.ok(env, "envelope must be present");
|
|
141
|
-
// verificationMethod must be the delegate's bare multibase pubkey
|
|
142
|
-
// (NOT a `#sphere` DID URL). And the SignedMandate must be inside.
|
|
143
|
-
assert.match(env.proof.verificationMethod, /^z[1-9A-HJ-NP-Za-km-z]+$/, `expected multibase pubkey, got ${env.proof.verificationMethod}`);
|
|
144
|
-
assert.ok(env.mandate, "delegate envelopes must attach the SignedMandate");
|
|
145
|
-
assert.equal(env.mandate.id, mandateId);
|
|
146
|
-
});
|
|
147
|
-
it("still works the owner path when an owner is signed in", async () => {
|
|
148
|
-
const auth = freshAuth();
|
|
149
|
-
const compute = freshCompute(auth);
|
|
150
|
-
// Owner sign-in via recovery — picks up four sphere keys from the
|
|
151
|
-
// recovery file format. Build one inline.
|
|
152
|
-
const issuer = createBrowserIdentity("owner", "Owner");
|
|
153
|
-
const seedHex = (b) => Array.from(b).map((x) => x.toString(16).padStart(2, "0")).join("");
|
|
154
|
-
const recoveryText = JSON.stringify({
|
|
155
|
-
aithos_recovery_version: "0.1.0-plaintext",
|
|
156
|
-
handle: issuer.handle,
|
|
157
|
-
display_name: issuer.displayName,
|
|
158
|
-
did: issuer.did,
|
|
159
|
-
created_at: new Date().toISOString(),
|
|
160
|
-
seeds_hex: {
|
|
161
|
-
root: seedHex(issuer.root.seed),
|
|
162
|
-
public: seedHex(issuer.public.seed),
|
|
163
|
-
circle: seedHex(issuer.circle.seed),
|
|
164
|
-
self: seedHex(issuer.self.seed),
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
await auth.signInWithRecovery({ file: recoveryText });
|
|
168
|
-
await compute.invokeBedrock({
|
|
169
|
-
mandateId: "mandate:owner-managed",
|
|
170
|
-
model: "claude-haiku-4-5",
|
|
171
|
-
messages: [{ role: "user", content: "Hi" }],
|
|
172
|
-
maxTokens: 1,
|
|
173
|
-
});
|
|
174
|
-
const env = lastRequestBody?.params?._envelope;
|
|
175
|
-
assert.ok(env, "envelope must be present");
|
|
176
|
-
// Owner path: verificationMethod is a `#public` DID URL, and the
|
|
177
|
-
// envelope MUST NOT carry a mandate (server resolves from
|
|
178
|
-
// params.mandate_id).
|
|
179
|
-
assert.match(env.proof.verificationMethod, /#public$/);
|
|
180
|
-
assert.equal(env.mandate, undefined, "owner-signed envelopes should not attach a mandate");
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
//# sourceMappingURL=compute-delegate-path.test.js.map
|
|
@@ -1,194 +0,0 @@
|
|
|
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 { AithosAuth, AithosSDK, AithosSDKError, memoryKeyStore, noopStore, } from "../src/index.js";
|
|
13
|
-
import { serializeRecoveryFile } from "../src/internal/recovery-file.js";
|
|
14
|
-
const APP_DID = "did:aithos:app:test";
|
|
15
|
-
async function makeSdk(fetchImpl) {
|
|
16
|
-
const id = createBrowserIdentity("test-handle", "Test User");
|
|
17
|
-
const auth = new AithosAuth({
|
|
18
|
-
authBaseUrl: "https://auth.test",
|
|
19
|
-
fetch: (() => {
|
|
20
|
-
throw new Error("auth not used in compute tests");
|
|
21
|
-
}),
|
|
22
|
-
sessionStore: noopStore(),
|
|
23
|
-
keyStore: memoryKeyStore(),
|
|
24
|
-
});
|
|
25
|
-
const { text } = serializeRecoveryFile(id);
|
|
26
|
-
await auth.signInWithRecovery({ file: text });
|
|
27
|
-
return new AithosSDK({
|
|
28
|
-
auth,
|
|
29
|
-
appDid: APP_DID,
|
|
30
|
-
endpoints: { compute: "https://compute.example.test" },
|
|
31
|
-
fetch: fetchImpl,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
const HAPPY_RESULT = {
|
|
35
|
-
content: "Hello, Aithos!",
|
|
36
|
-
stopReason: "end_turn",
|
|
37
|
-
usage: { inputTokens: 12, outputTokens: 8 },
|
|
38
|
-
creditsCharged: 9,
|
|
39
|
-
walletBalance: 99_991,
|
|
40
|
-
auditId: "audit-1",
|
|
41
|
-
};
|
|
42
|
-
describe("compute.invokeBedrock — happy path", () => {
|
|
43
|
-
it("posts to ${compute}/v1/invoke with a JSON-RPC envelope and parses the result", async () => {
|
|
44
|
-
let capturedUrl;
|
|
45
|
-
let capturedInit;
|
|
46
|
-
const fakeFetch = async (input, init) => {
|
|
47
|
-
capturedUrl = typeof input === "string" ? input : input.toString();
|
|
48
|
-
capturedInit = init;
|
|
49
|
-
return new Response(JSON.stringify({ result: HAPPY_RESULT }), {
|
|
50
|
-
status: 200,
|
|
51
|
-
headers: { "content-type": "application/json" },
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
const sdk = await makeSdk(fakeFetch);
|
|
55
|
-
const out = await sdk.compute.invokeBedrock({
|
|
56
|
-
mandateId: "mandate:abc",
|
|
57
|
-
model: "claude-sonnet-4-6",
|
|
58
|
-
messages: [{ role: "user", content: "Hi" }],
|
|
59
|
-
});
|
|
60
|
-
assert.deepEqual(out, HAPPY_RESULT);
|
|
61
|
-
assert.equal(capturedUrl, "https://compute.example.test/v1/invoke");
|
|
62
|
-
assert.equal(capturedInit?.method, "POST");
|
|
63
|
-
const headers = capturedInit?.headers;
|
|
64
|
-
assert.equal(headers["content-type"], "application/json");
|
|
65
|
-
const body = JSON.parse(capturedInit?.body);
|
|
66
|
-
assert.equal(body.jsonrpc, "2.0");
|
|
67
|
-
assert.equal(body.method, "aithos.compute_invoke");
|
|
68
|
-
assert.equal(body.params.app_did, APP_DID);
|
|
69
|
-
assert.equal(body.params.mandate_id, "mandate:abc");
|
|
70
|
-
assert.equal(body.params.model, "claude-sonnet-4-6");
|
|
71
|
-
// Idempotency key is auto-generated when not provided.
|
|
72
|
-
assert.match(body.params.idempotency_key, /^[0-9a-f]{32}$/);
|
|
73
|
-
// Envelope is present on the wire.
|
|
74
|
-
assert.ok(body.params._envelope, "request must carry a signed envelope");
|
|
75
|
-
});
|
|
76
|
-
it("forwards optional system / max_tokens / temperature and respects a caller-provided idempotencyKey", async () => {
|
|
77
|
-
let capturedBody;
|
|
78
|
-
const fakeFetch = async (_input, init) => {
|
|
79
|
-
capturedBody = JSON.parse(init?.body).params;
|
|
80
|
-
return new Response(JSON.stringify({ result: HAPPY_RESULT }), {
|
|
81
|
-
status: 200,
|
|
82
|
-
headers: { "content-type": "application/json" },
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
const sdk = await makeSdk(fakeFetch);
|
|
86
|
-
await sdk.compute.invokeBedrock({
|
|
87
|
-
mandateId: "mandate:abc",
|
|
88
|
-
model: "claude-sonnet-4-6",
|
|
89
|
-
messages: [{ role: "user", content: "Hi" }],
|
|
90
|
-
system: "You are concise.",
|
|
91
|
-
maxTokens: 256,
|
|
92
|
-
temperature: 0.2,
|
|
93
|
-
idempotencyKey: "idem-1",
|
|
94
|
-
});
|
|
95
|
-
assert.equal(capturedBody?.system, "You are concise.");
|
|
96
|
-
assert.equal(capturedBody?.max_tokens, 256);
|
|
97
|
-
assert.equal(capturedBody?.temperature, 0.2);
|
|
98
|
-
assert.equal(capturedBody?.idempotency_key, "idem-1");
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
describe("compute.invokeBedrock — errors", () => {
|
|
102
|
-
it("wraps a network failure as AithosSDKError(code='network')", async () => {
|
|
103
|
-
const fakeFetch = async () => {
|
|
104
|
-
throw new Error("fetch failed: ECONNREFUSED");
|
|
105
|
-
};
|
|
106
|
-
const sdk = await makeSdk(fakeFetch);
|
|
107
|
-
await assert.rejects(sdk.compute.invokeBedrock({
|
|
108
|
-
mandateId: "mandate:abc",
|
|
109
|
-
model: "claude-sonnet-4-6",
|
|
110
|
-
messages: [{ role: "user", content: "Hi" }],
|
|
111
|
-
}), (err) => {
|
|
112
|
-
assert.ok(err instanceof AithosSDKError);
|
|
113
|
-
assert.equal(err.code, "network");
|
|
114
|
-
assert.match(err.message, /ECONNREFUSED/);
|
|
115
|
-
return true;
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
it("wraps an HTTP non-2xx as AithosSDKError(code='http')", async () => {
|
|
119
|
-
const fakeFetch = async () => new Response("nope", { status: 503, statusText: "Service Unavailable" });
|
|
120
|
-
const sdk = await makeSdk(fakeFetch);
|
|
121
|
-
await assert.rejects(sdk.compute.invokeBedrock({
|
|
122
|
-
mandateId: "mandate:abc",
|
|
123
|
-
model: "claude-sonnet-4-6",
|
|
124
|
-
messages: [{ role: "user", content: "Hi" }],
|
|
125
|
-
}), (err) => {
|
|
126
|
-
assert.ok(err instanceof AithosSDKError);
|
|
127
|
-
assert.equal(err.code, "http");
|
|
128
|
-
assert.equal(err.status, 503);
|
|
129
|
-
return true;
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
it("wraps a JSON-RPC error response with the proxy's code and message", async () => {
|
|
133
|
-
const fakeFetch = async () => new Response(JSON.stringify({
|
|
134
|
-
error: {
|
|
135
|
-
code: 402,
|
|
136
|
-
message: "insufficient_credits",
|
|
137
|
-
data: { balance: 0, required: 1 },
|
|
138
|
-
},
|
|
139
|
-
}), { status: 200, headers: { "content-type": "application/json" } });
|
|
140
|
-
const sdk = await makeSdk(fakeFetch);
|
|
141
|
-
await assert.rejects(sdk.compute.invokeBedrock({
|
|
142
|
-
mandateId: "mandate:abc",
|
|
143
|
-
model: "claude-sonnet-4-6",
|
|
144
|
-
messages: [{ role: "user", content: "Hi" }],
|
|
145
|
-
}), (err) => {
|
|
146
|
-
assert.ok(err instanceof AithosSDKError);
|
|
147
|
-
assert.equal(err.code, "402");
|
|
148
|
-
assert.equal(err.message, "insufficient_credits");
|
|
149
|
-
return true;
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
it("rejects an empty result payload as AithosSDKError(code='empty')", async () => {
|
|
153
|
-
const fakeFetch = async () => new Response(JSON.stringify({}), {
|
|
154
|
-
status: 200,
|
|
155
|
-
headers: { "content-type": "application/json" },
|
|
156
|
-
});
|
|
157
|
-
const sdk = await makeSdk(fakeFetch);
|
|
158
|
-
await assert.rejects(sdk.compute.invokeBedrock({
|
|
159
|
-
mandateId: "mandate:abc",
|
|
160
|
-
model: "claude-sonnet-4-6",
|
|
161
|
-
messages: [{ role: "user", content: "Hi" }],
|
|
162
|
-
}), (err) => {
|
|
163
|
-
assert.ok(err instanceof AithosSDKError);
|
|
164
|
-
assert.equal(err.code, "empty");
|
|
165
|
-
return true;
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
describe("compute.invokeBedrock — abort", () => {
|
|
170
|
-
it("propagates an AbortSignal to fetch", async () => {
|
|
171
|
-
let receivedSignal;
|
|
172
|
-
const fakeFetch = async (_input, init) => {
|
|
173
|
-
receivedSignal = init?.signal;
|
|
174
|
-
return new Response(JSON.stringify({ result: HAPPY_RESULT }), {
|
|
175
|
-
status: 200,
|
|
176
|
-
headers: { "content-type": "application/json" },
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
const sdk = await makeSdk(fakeFetch);
|
|
180
|
-
const ac = new AbortController();
|
|
181
|
-
await sdk.compute.invokeBedrock({
|
|
182
|
-
mandateId: "mandate:abc",
|
|
183
|
-
model: "claude-sonnet-4-6",
|
|
184
|
-
messages: [{ role: "user", content: "Hi" }],
|
|
185
|
-
signal: ac.signal,
|
|
186
|
-
});
|
|
187
|
-
assert.equal(receivedSignal, ac.signal);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
// `compute.invokeUrlFetch` was removed in alpha.24 (BREAKING). The
|
|
191
|
-
// Anthropic API-direct + web_fetch tool path is replaced by the
|
|
192
|
-
// `sdk.web.extract` namespace which routes through the deterministic
|
|
193
|
-
// web-extractor Lambda. No tests here anymore.
|
|
194
|
-
//# sourceMappingURL=compute.test.js.map
|
|
@@ -1,62 +0,0 @@
|
|
|
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, webInvokeUrl, } 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
|
-
web: "https://extract.aithos.be",
|
|
27
|
-
}), "https://compute.aithos.be/v1/invoke");
|
|
28
|
-
});
|
|
29
|
-
it("trims a trailing slash on the compute base", () => {
|
|
30
|
-
assert.equal(computeInvokeUrl({
|
|
31
|
-
compute: "https://compute.aithos.be/",
|
|
32
|
-
wallet: "https://wallet.aithos.be",
|
|
33
|
-
web: "https://extract.aithos.be",
|
|
34
|
-
}), "https://compute.aithos.be/v1/invoke");
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
describe("walletTopupCheckoutUrl", () => {
|
|
38
|
-
it("appends /v1/wallet/topup/checkout to the wallet base", () => {
|
|
39
|
-
assert.equal(walletTopupCheckoutUrl({
|
|
40
|
-
compute: "https://compute.aithos.be",
|
|
41
|
-
wallet: "https://wallet.aithos.be",
|
|
42
|
-
web: "https://extract.aithos.be",
|
|
43
|
-
}), "https://wallet.aithos.be/v1/wallet/topup/checkout");
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
describe("webInvokeUrl", () => {
|
|
47
|
-
it("appends /v1/invoke to the web base", () => {
|
|
48
|
-
assert.equal(webInvokeUrl({
|
|
49
|
-
compute: "https://compute.aithos.be",
|
|
50
|
-
wallet: "https://wallet.aithos.be",
|
|
51
|
-
web: "https://extract.aithos.be",
|
|
52
|
-
}), "https://extract.aithos.be/v1/invoke");
|
|
53
|
-
});
|
|
54
|
-
it("trims a trailing slash on the web base", () => {
|
|
55
|
-
assert.equal(webInvokeUrl({
|
|
56
|
-
compute: "https://compute.aithos.be",
|
|
57
|
-
wallet: "https://wallet.aithos.be",
|
|
58
|
-
web: "https://extract.aithos.be/",
|
|
59
|
-
}), "https://extract.aithos.be/v1/invoke");
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
//# sourceMappingURL=endpoints.test.js.map
|