@infolang/sdk 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ All notable changes to the InfoLang TypeScript SDK are documented here. This
4
+ project adheres to [Semantic Versioning](https://semver.org). The SDK minor
5
+ version tracks the `il-runtime` API version pinned in
6
+ `openapi/IL_RUNTIME_VERSION`.
7
+
8
+ ## [0.2.0] - 2026-07-13
9
+
10
+ ### Changed
11
+ - Pinned OpenAPI contract to **v0.2.0** (runtime-aligned).
12
+ - `forget(memoryId)` now calls `DELETE /v1/memories/{id}` (was `POST /v1/forget`).
13
+ - `listRecent({ n })` now calls `GET /v1/memories?limit=` (was `GET /v1/recent`).
14
+
15
+ ### Added
16
+ - `parseRecall` maps runtime `hits` → `chunks` (fixes empty recall results).
17
+ - Parity with Python: `recallHybrid`, `rememberBatch`, `resetNamespace`.
18
+ - npm publish workflow with provenance.
19
+
20
+ ## [0.1.0] - Unreleased
21
+
22
+ ### Added
23
+ - Initial release: `InfoLang` client (fetch-native, async).
24
+ - Auth providers: API key, dev key (`key:namespace`), OAuth session file.
25
+ - Memory API: `recall`, `investigate`, `remember`, `memorize`, `forget`,
26
+ `listBanks`, `listRecent`.
27
+ - Context API: `contextPack`, `ingestRepo`, `execute`.
28
+ - Typed error hierarchy, automatic retries with jitter, and metering metadata.
29
+ - Dual ESM + CJS builds with bundled type declarations.
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # InfoLang TypeScript SDK
2
+
3
+ Official TypeScript client for [InfoLang](https://infolang.ai) semantic memory.
4
+ Wraps the `il-runtime` REST API (Forge-compatible) with one-line construction,
5
+ typed errors, automatic retries, and ergonomic agent helpers. `fetch`-native —
6
+ runs on Node 18+, Bun, Deno, Cloudflare Workers, and browsers.
7
+
8
+ > Repository: `infolang-sdk-typescript`. Package: `@infolang/sdk` (npm).
9
+
10
+ ## Install
11
+
12
+ While the package is private, install from the repo:
13
+
14
+ ```bash
15
+ npm install github:InfoLang-Inc/infolang-sdk-typescript#v0.1.0
16
+ ```
17
+
18
+ Once published:
19
+
20
+ ```bash
21
+ npm install @infolang/sdk
22
+ ```
23
+
24
+ ## Quickstart
25
+
26
+ ```ts
27
+ import { InfoLang } from "@infolang/sdk";
28
+
29
+ const il = InfoLang.fromApiKey("il_live_..."); // managed cloud
30
+ const result = await il.investigate("How does auth middleware work?");
31
+ for (const chunk of result.chunks) console.log(chunk.score, chunk.text);
32
+ ```
33
+
34
+ Three ways to call, depending on your runtime:
35
+
36
+ ```ts
37
+ // 1. One-shot
38
+ const { chunks } = await InfoLang.fromApiKey("il_live_...").investigate("query");
39
+
40
+ // 2. OAuth via ~/.config/infolang/session.json
41
+ const il = InfoLang.fromSessionFile();
42
+ await il.memorize("a fact worth keeping", { source: "docs/auth.md" });
43
+
44
+ // 3. Self-hosted dev runtime
45
+ const local = InfoLang.fromDevKey("devsecret:default");
46
+ const recent = await local.listRecent({ n: 10 });
47
+ ```
48
+
49
+ ## Authentication
50
+
51
+ | Mode | Constructor | Target |
52
+ |------|-------------|--------|
53
+ | Managed cloud (API key) | `InfoLang.fromApiKey("il_live_...")` | `api.infolang.ai` |
54
+ | Managed cloud (OAuth) | `InfoLang.fromSessionFile()` | `api.infolang.ai` |
55
+ | Self-hosted dev | `InfoLang.fromDevKey("key:namespace")` | `127.0.0.1:8766` |
56
+
57
+ Credentials are also read from the environment: `INFOLANG_API_KEY`,
58
+ `INFOLANG_DEV_KEY`, `INFOLANG_BASE_URL`, `INFOLANG_NAMESPACE`.
59
+
60
+ Enterprise mTLS is not yet first-class in the TypeScript SDK because the Fetch
61
+ standard does not expose client-certificate configuration. Pass a custom
62
+ `fetch` (backed by a Node `https.Agent` with `cert`/`key`) via the `fetch`
63
+ option to use mTLS today; the Python SDK supports `InfoLang.from_mtls(...)`
64
+ directly.
65
+
66
+ ## Core API
67
+
68
+ | Method | Purpose |
69
+ |--------|---------|
70
+ | `recall(query, { namespace, topK, filters, verbose })` | Semantic recall |
71
+ | `investigate(query, { namespaceHint, topK = 5 })` | Agent-style recall |
72
+ | `remember(text, { source, tags, namespace })` | Store a memory |
73
+ | `memorize(content, { source, tags, namespace })` | Alias of `remember` |
74
+ | `forget(memoryId, { namespace })` | Delete a memory |
75
+ | `listBanks()` / `listRecent({ namespace, n })` | Introspection |
76
+ | `contextPack(query, { namespace, maxTokens, repoRoot })` | One-shot context string |
77
+ | `ingestRepo(namespace, { repoRoot, ref })` | Index a repository |
78
+ | `execute(operations)` | Batch ops |
79
+ | `health.check()` | Liveness/readiness |
80
+
81
+ ## Errors
82
+
83
+ All failures throw a subclass of `InfoLangError`: `AuthenticationError`,
84
+ `RateLimitError` (with `retryAfter`), `NotFoundError`, `ValidationError`,
85
+ `ServerError`, plus `InfoLangConnectionError` for transport failures. Every API
86
+ error carries `status`, `body`, and `requestId`.
87
+
88
+ ## Resilience
89
+
90
+ `recall`/`remember` and friends retry `429` and `5xx` with exponential backoff
91
+ plus full jitter (configurable via `maxRetries`), honor `Retry-After`, and abort
92
+ on the timeout budget (default 30s, set via `timeoutMs`).
93
+
94
+ ## Development
95
+
96
+ ```bash
97
+ npm install
98
+ npm run lint
99
+ npm run typecheck
100
+ npm test
101
+ npm run build
102
+ ```
103
+
104
+ The REST contract is pinned in `openapi/` (see `openapi/IL_RUNTIME_VERSION`).
105
+ Regenerate types with `npm run codegen` after bumping the pin.