@wraith-ai/core 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 xFroty
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,43 @@
1
- # Temporary Holding Version
1
+ # @wraith-ai/core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A general-purpose AI agent as a library: the tool loop, any
4
+ [AI SDK](https://ai-sdk.dev) provider, file, shell and web tools, permissions
5
+ and approvals, sessions that resume exactly, compaction, background tasks,
6
+ sub-agents and MCP servers. It emits typed events and knows nothing about a
7
+ terminal, so the same agent runs in a CLI, behind a server or under an eval
8
+ harness. Runs on Node 22+ and Bun.
9
+
10
+ ```bash
11
+ npm i @wraith-ai/core
12
+ ```
13
+
14
+ ```ts
15
+ import { createAgent, createConversation } from "@wraith-ai/core";
16
+ import { openrouter } from "@wraith-ai/core/providers/openrouter";
17
+
18
+ const model = openrouter({ apiKey: process.env.OPENROUTER_API_KEY ?? "" }).model("anthropic/claude-opus-5");
19
+ const chat = createConversation({ agent: createAgent({ model }) });
20
+
21
+ chat.subscribe((event) => {
22
+ if (event.type === "text-delta") process.stdout.write(event.text);
23
+ });
24
+ await chat.send("What is a prompt cache?");
25
+ ```
26
+
27
+ Entry points:
28
+
29
+ | Import | What |
30
+ | --- | --- |
31
+ | `@wraith-ai/core` | the agent, tools, permissions, sessions, config; loads no vendor SDK |
32
+ | `@wraith-ai/core/providers/openrouter` | OpenRouter |
33
+ | `@wraith-ai/core/providers/openai-compatible` | any OpenAI-shaped endpoint: vLLM, Ollama, a gateway |
34
+ | `@wraith-ai/core/providers/openai-codex` | a ChatGPT subscription, by sign-in |
35
+ | `@wraith-ai/core/snapshot` | the model catalog as of the release, for prices and windows offline |
36
+
37
+ A whole coding agent in one call is [`@wraith-ai/agents`](https://www.npmjs.com/package/@wraith-ai/agents).
38
+
39
+ The guide, with the rules the types do not tell you:
40
+ [USING-WRAITH.md](https://github.com/xFroty/wraith/blob/main/USING-WRAITH.md).
41
+ Programs that compile: [examples](https://github.com/xFroty/wraith/tree/main/examples).
42
+
43
+ MIT
@@ -0,0 +1,25 @@
1
+ /**
2
+ * One browser sign-in under way, the same for every kind of server.
3
+ *
4
+ * The answer reaches it two ways: the browser comes back to a port on this
5
+ * machine, or the host passes on an address — one a person pasted, or one its
6
+ * own callback route received. Both go through the same checks.
7
+ */
8
+ interface SignIn<T> {
9
+ /** The page to open in a browser. Opening it is the host's: only it knows where the person is. */
10
+ url: string;
11
+ /** The `state` the answer carries, for a host that routes several sign-ins through one address. */
12
+ state: string;
13
+ /** False when nothing listens for the browser: only `complete` can finish it. */
14
+ listening: boolean;
15
+ /** Settles once the sign-in is stored and usable; fails with why it was not. */
16
+ done: Promise<T>;
17
+ /**
18
+ * The address the browser ended up on, whole or as the path a route received.
19
+ * A wrong address fails this call and the sign-in keeps waiting; a refusal
20
+ * from the server ends the sign-in.
21
+ */
22
+ complete(address: string): Promise<void>;
23
+ cancel(): void;
24
+ }
25
+ export { SignIn as t };
@@ -0,0 +1,63 @@
1
+ /**
2
+ * What a given model can actually be asked to do.
3
+ *
4
+ * Capability data may improve error messages but must never gate a call: the
5
+ * default answers "I don't know" to everything, and the provider decides.
6
+ *
7
+ * `models-dev.ts` implements this interface against models.dev. Everything
8
+ * above reads through it, so the source in use changes nothing for callers.
9
+ */
10
+ interface ModelInfo {
11
+ /** What people call the model, when the catalog says. */
12
+ name?: string;
13
+ /**
14
+ * Whether the catalog says it reasons. `false` is an answer, absent is not:
15
+ * `/effort` tells the two apart and blocks neither.
16
+ */
17
+ reasoning?: boolean;
18
+ /** "2026-07-14". Newest first is the order of an empty search. */
19
+ releaseDate?: string;
20
+ status?: "alpha" | "beta" | "deprecated";
21
+ contextLimit?: number;
22
+ outputLimit?: number;
23
+ /** Effort levels this model accepts. Vocabularies differ per vendor. */
24
+ reasoningEfforts?: string[];
25
+ supportsTemperature?: boolean;
26
+ supportsToolCall?: boolean;
27
+ /**
28
+ * What the model takes in, as models.dev names it: "text", "image", "pdf",
29
+ * "audio", "video". Absent is "not known", never "text only".
30
+ */
31
+ input?: string[];
32
+ inputPricePerMillion?: number;
33
+ outputPricePerMillion?: number;
34
+ /**
35
+ * Cache rates, when the catalog publishes them. Missing ones are derived from
36
+ * the input rate; a bill computed from them is always labelled an estimate.
37
+ */
38
+ cacheReadPricePerMillion?: number;
39
+ cacheWritePricePerMillion?: number;
40
+ }
41
+ interface ModelListing {
42
+ id: string;
43
+ info: ModelInfo;
44
+ }
45
+ /**
46
+ * Keyed by catalog table, not by provider: which table a provider reads is
47
+ * `catalogView`'s answer.
48
+ */
49
+ interface ModelCapabilities {
50
+ lookup(table: string, modelId: string): ModelInfo | null;
51
+ /**
52
+ * What the catalog lists in a table, for a model picker. Never more than
53
+ * `lookup` finds: each row must resolve through `lookup`. Empty means "no
54
+ * list", never "no models"; a provider the catalog does not know still
55
+ * takes any id typed by hand.
56
+ */
57
+ list(table: string): readonly ModelListing[];
58
+ }
59
+ /** Knows nothing, blocks nothing: the default source. */
60
+ declare const permissiveCapabilities: ModelCapabilities;
61
+ /** Builds a capability source from a plain table, for tests and for config. */
62
+ declare function capabilitiesFromTable(table: Record<string, Record<string, ModelInfo>>): ModelCapabilities;
63
+ export { permissiveCapabilities as a, capabilitiesFromTable as i, ModelInfo as n, ModelListing as r, ModelCapabilities as t };