Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ All notable changes to the Wraith Protocol SDK will be documented in this file.

### Fixed

- **Companion packages import the agent API from `@wraith-protocol/sdk-agent`** (issue #249): `@wraith-protocol/sdk-vue`, `@wraith-protocol/sdk-svelte` and `@wraith-protocol/sdk-solid` imported `Wraith`, `WraithAgent` and `Chain` from the core `@wraith-protocol/sdk`, but #193 moved those exports to `@wraith-protocol/sdk-agent`, so importing any of the three on the server threw `SyntaxError: The requested module '@wraith-protocol/sdk' does not provide an export named 'Chain'` before any code ran. Each companion now imports those names from `@wraith-protocol/sdk-agent` and declares it as a workspace dependency, and the framework SSR import smoke check no longer lists the three as known failures.
- **Stellar `findStrictReceivePath` reads and validates real Horizon responses** (issue #236): the function now reads paths from Horizon's `_embedded.records` envelope instead of expecting a bare array, and sends the query parameters Horizon accepts (`source_assets` with `destination_asset_type` / `_code` / `_issuer`; the old `destination_asset` and dummy `source_account` made every live request fail with HTTP 400).
- Every record is validated before use: amounts, asset type / code / issuer, that the source and destination assets and `destination_amount` match the request, and a path of at most 5 hops. The body is read as a stream and abandoned past 256 KiB; responses over 100 records are rejected. The cheapest valid record is returned. An invalid `destAmount` now throws before the request, and the request uses the Horizon client's default timeouts (`RPCTimeoutError`).
- New `HorizonResponseError` (`WRAITH/NETWORK/HORIZON_RESPONSE`), exported from the package root, carries the URL and the rejected field. A non-2xx status now throws `RPCRequestError` instead of a plain `Error`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"node": ">=20"
},
"scripts": {
"build": "tsup",
"build": "tsup && pnpm --filter @wraith-protocol/sdk-agent build",
"test": "vitest run --exclude 'test/chains/stellar/properties.test.ts' --exclude 'test/leaks/scan-leak.test.ts' --exclude 'test/leaks/heap-snapshot.test.ts' && pnpm --filter @wraith-protocol/sdk-svelte test",
"docs": "typedoc",
"test:exports": "node test/smoke/run.mjs",
Expand Down
1 change: 1 addition & 0 deletions packages/sdk-solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@wraith-protocol/sdk": "workspace:*",
"@wraith-protocol/sdk-agent": "workspace:*",
"solid-js": "^1.9.0"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-solid/src/primitives/createActivity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSignal } from 'solid-js';
import { Wraith, WraithAgent, Chain } from '@wraith-protocol/sdk';
import type { WraithConfig, AgentConfig, AgentInfo, ChatResponse } from '@wraith-protocol/sdk';
import { Wraith, WraithAgent, Chain } from '@wraith-protocol/sdk-agent';
import type { WraithConfig, AgentConfig, AgentInfo, ChatResponse } from '@wraith-protocol/sdk-agent';

/**
* Solid primitive for managing Wraith agent activity (chat, balance, agent lifecycle).
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-solid/test/createActivity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const mockClient = vi.hoisted(() => ({
listAgents: vi.fn().mockResolvedValue([mockAgentInfo]),
}));

vi.mock('@wraith-protocol/sdk', () => ({
vi.mock('@wraith-protocol/sdk-agent', () => ({
Wraith: vi.fn().mockImplementation(() => mockClient),
WraithAgent: vi.fn(),
Chain: {
Expand All @@ -34,7 +34,7 @@ vi.mock('@wraith-protocol/sdk', () => ({
}));

// Grab mocked references once (safe because vi.mock hoists before imports)
import { Wraith as MockWraith } from '@wraith-protocol/sdk';
import { Wraith as MockWraith } from '@wraith-protocol/sdk-agent';

describe('createActivity', () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-solid/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export default defineConfig({
splitting: true,
clean: true,
treeshake: true,
external: ['solid-js', '@wraith-protocol/sdk'],
external: ['solid-js', '@wraith-protocol/sdk', '@wraith-protocol/sdk-agent'],
});
3 changes: 2 additions & 1 deletion packages/sdk-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"clean": "rm -rf dist"
},
"dependencies": {
"@wraith-protocol/sdk": "workspace:*"
"@wraith-protocol/sdk": "workspace:*",
"@wraith-protocol/sdk-agent": "workspace:*"
},
"peerDependencies": {
"@stellar/stellar-sdk": "^13.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk-svelte/src/primitives/useWraith.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { writable, readonly, get } from 'svelte/store';
import { Wraith, WraithAgent, Chain } from '@wraith-protocol/sdk';
import type { WraithConfig, AgentConfig, AgentInfo, ChatResponse } from '@wraith-protocol/sdk';
import { Wraith, WraithAgent, Chain } from '@wraith-protocol/sdk-agent';
import type { WraithConfig, AgentConfig, AgentInfo, ChatResponse } from '@wraith-protocol/sdk-agent';

export function useWraith(config?: WraithConfig) {
const _client = writable<Wraith | null>(null);
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-svelte/test/useWraith.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';

vi.mock('@wraith-protocol/sdk', () => {
vi.mock('@wraith-protocol/sdk-agent', () => {
const mockAgent = {
info: {
id: 'agent-1',
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-svelte/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export default defineConfig({
splitting: true,
clean: true,
treeshake: true,
external: ['svelte', '@wraith-protocol/sdk'],
external: ['svelte', '@wraith-protocol/sdk', '@wraith-protocol/sdk-agent'],
});
1 change: 1 addition & 0 deletions packages/sdk-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@wraith-protocol/sdk": "workspace:*",
"@wraith-protocol/sdk-agent": "workspace:*",
"vue": "^3.5.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-vue/src/composables/useWraith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type AgentConfig,
type AgentInfo,
type ChatResponse,
} from '@wraith-protocol/sdk';
} from '@wraith-protocol/sdk-agent';

export function useWraith(config?: WraithConfig) {
const client: Ref<Wraith | null> = ref(null);
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-vue/test/useWraith.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { useWraith } from '../src/composables/useWraith';

vi.mock('@wraith-protocol/sdk', () => {
vi.mock('@wraith-protocol/sdk-agent', () => {
const mockAgent = {
info: { id: 'agent-1', name: 'test-agent', chains: [], addresses: {}, metaAddresses: {} },
chat: vi.fn(),
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-vue/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export default defineConfig({
splitting: true,
clean: true,
treeshake: true,
external: ['vue', '@wraith-protocol/sdk'],
external: ['vue', '@wraith-protocol/sdk', '@wraith-protocol/sdk-agent'],
});
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions scripts/compat/verify-ssr-imports.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,14 @@ const SCENARIOS = {
'@wraith-protocol/sdk-vue': 'vue',
};

// Companions whose server import is already broken, with the error it fails
// with. `Wraith`, `WraithAgent` and `Chain` moved from `@wraith-protocol/sdk` to
// `@wraith-protocol/sdk-agent` in #193, but these packages still import them
// from the core, so Node refuses to link them. An entry must keep failing with
// its message: once the import is fixed this check fails until the entry is
// removed, which turns the SSR render back on for that package.
const KNOWN_IMPORT_FAILURES = {
'@wraith-protocol/sdk-solid': /does not provide an export named '(Wraith|WraithAgent|Chain)'/,
'@wraith-protocol/sdk-svelte': /does not provide an export named '(Wraith|WraithAgent|Chain)'/,
'@wraith-protocol/sdk-vue': /does not provide an export named '(Wraith|WraithAgent|Chain)'/,
};
// Companions whose server import is known to be broken, mapped to the error it
// fails with, so a pre-existing failure does not mask a new one. Empty today:
// the Vue, Svelte and Solid companions import `Wraith`, `WraithAgent` and
// `Chain` from `@wraith-protocol/sdk-agent` (where #193 moved them) and link
// cleanly again. An entry must keep failing with its message: once the import
// is fixed this check fails until the entry is removed, which turns the SSR
// render back on for that package.
const KNOWN_IMPORT_FAILURES = {};

let failed = 0;

Expand Down
Loading