@partite-ai/particle-kv 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.
Files changed (4) hide show
  1. package/README.md +28 -0
  2. package/index.d.ts +24 -0
  3. package/index.js +10 -0
  4. package/package.json +24 -0
package/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # @partite-ai/particle-kv
2
+
3
+ TypeScript types for the `@partite-ai/particle-kv` built-in
4
+ consumed by [Particle](https://github.com/partite-ai/particles) particles.
5
+
6
+ Types only — the runtime implementation lives in the Particle wasm
7
+ runtime. The store is per-particle: two particles using the same key
8
+ see independent values. Unlike credentials or HTTP, KV is not a
9
+ capability you declare — every particle gets a key/value store
10
+ unconditionally.
11
+
12
+ ```ts
13
+ import { kv } from "@partite-ai/particle-kv";
14
+
15
+ await kv.set("last-run", new Date().toISOString());
16
+ const last = await kv.get("last-run"); // string | null
17
+ const keys = await kv.list("user:"); // string[]
18
+ ```
19
+
20
+ ## API
21
+
22
+ - `kv.get(key)` — `string | null`
23
+ - `kv.set(key, value)` — replace or create
24
+ - `kv.delete(key)` — idempotent
25
+ - `kv.list(prefix)` — keys with that prefix, unspecified order
26
+
27
+ See the [Particle README](https://github.com/partite-ai/particles) for
28
+ the manifest schema.
package/index.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ // TypeScript types for the host-provided `@partite-ai/particle-kv`
2
+ // module. The runtime resolves this import to a JS shim that wraps
3
+ // the WIT-imported `particle:host/kv@0.1.0` interface — see the
4
+ // Particle repository for the implementation. Types only.
5
+
6
+ /**
7
+ * Per-particle key/value store. Strings only — base64-encode
8
+ * binary if you must. Keys and values are scoped by particle name;
9
+ * two particles using the same key see independent values.
10
+ */
11
+ export const kv: {
12
+ /** Returns the stored string, or null if no entry exists. */
13
+ get(key: string): Promise<string | null>;
14
+ /** Replaces or creates the entry. */
15
+ set(key: string, value: string): Promise<void>;
16
+ /** Idempotent — removing an absent key is fine. */
17
+ delete(key: string): Promise<void>;
18
+ /** Returns keys with the given prefix, in unspecified order. */
19
+ list(prefix: string): Promise<string[]>;
20
+ };
21
+
22
+ export type KVError =
23
+ | { tag: "storage-error"; val: string }
24
+ | { tag: "quota-exceeded" };
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ // This package ships TypeScript types only. The runtime
2
+ // implementation is provided by the Particle wasm runtime — see
3
+ // components/runtime/src/host-shim.ts in the Particle repo.
4
+ // Loading this file outside that runtime throws so the misuse is
5
+ // loud rather than silent.
6
+ throw new Error(
7
+ "@partite-ai/particle-kv is only callable inside the Particle runtime. " +
8
+ "Run your particle with `particle run` / `particle serve-mcp`, or build it into " +
9
+ "a .particle artifact.",
10
+ );
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@partite-ai/particle-kv",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript types for `@partite-ai/particle-kv` — per-particle persistent key/value store for Particle particles.",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/partite-ai/particles",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/partite-ai/particles.git",
10
+ "directory": "js-types/particle-kv"
11
+ },
12
+ "main": "index.js",
13
+ "types": "index.d.ts",
14
+ "files": [
15
+ "index.js",
16
+ "index.d.ts",
17
+ "README.md"
18
+ ],
19
+ "keywords": ["particle", "wasm", "kv", "storage", "mcp"],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "sideEffects": false
24
+ }