@processfork/sdk 1.0.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/package.json +42 -0
- package/processfork.darwin-arm64.node +0 -0
- package/ts/index.ts +82 -0
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@processfork/sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "ProcessFork — fork() for AI agents (TypeScript SDK).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://github.com/manav8498/processfork",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/manav8498/processfork.git",
|
|
10
|
+
"directory": "crates/pf-ts"
|
|
11
|
+
},
|
|
12
|
+
"main": "ts/index.js",
|
|
13
|
+
"types": "ts/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"ts/",
|
|
16
|
+
"*.node"
|
|
17
|
+
],
|
|
18
|
+
"napi": {
|
|
19
|
+
"name": "processfork",
|
|
20
|
+
"triples": {
|
|
21
|
+
"defaults": true,
|
|
22
|
+
"additional": [
|
|
23
|
+
"x86_64-unknown-linux-gnu",
|
|
24
|
+
"aarch64-unknown-linux-gnu",
|
|
25
|
+
"aarch64-apple-darwin",
|
|
26
|
+
"x86_64-apple-darwin"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "napi build --release --platform",
|
|
32
|
+
"build:debug": "napi build --platform",
|
|
33
|
+
"test": "node --test test/smoke.mjs"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@napi-rs/cli": "^2.18.4",
|
|
37
|
+
"typescript": "^5.4.0"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=20"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
Binary file
|
package/ts/index.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
//
|
|
3
|
+
// ProcessFork — TypeScript SDK.
|
|
4
|
+
//
|
|
5
|
+
// Wraps the napi-rs cdylib. The cdylib's TypeScript types live in
|
|
6
|
+
// `index.d.ts` (auto-generated by `napi build`); this file adds a thin
|
|
7
|
+
// ergonomic layer (Manifest typed object, JSON parsing of readManifest).
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
PfStore as _PfStore,
|
|
11
|
+
digestOf,
|
|
12
|
+
snapshotFilesystem,
|
|
13
|
+
checkoutFilesystem,
|
|
14
|
+
readManifest as _readManifestRaw,
|
|
15
|
+
merge as _merge,
|
|
16
|
+
type Message,
|
|
17
|
+
type MergeOpts,
|
|
18
|
+
type MergeReport,
|
|
19
|
+
type WorldConflict,
|
|
20
|
+
} from "../index.js";
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
digestOf,
|
|
24
|
+
snapshotFilesystem,
|
|
25
|
+
checkoutFilesystem,
|
|
26
|
+
_merge as merge,
|
|
27
|
+
type Message,
|
|
28
|
+
type MergeOpts,
|
|
29
|
+
type MergeReport,
|
|
30
|
+
type WorldConflict,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Local content-addressed `.pfimg` store. Re-exported from the cdylib;
|
|
35
|
+
* we attach `readManifest` as an instance method here so callers don't
|
|
36
|
+
* have to JSON.parse themselves.
|
|
37
|
+
*/
|
|
38
|
+
export class PfStore {
|
|
39
|
+
private inner: _PfStore;
|
|
40
|
+
|
|
41
|
+
private constructor(inner: _PfStore) {
|
|
42
|
+
this.inner = inner;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Open (or create) a store rooted at `path`. `~` is expanded. */
|
|
46
|
+
static open(path: string): PfStore {
|
|
47
|
+
return new PfStore(_PfStore.open(path));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Total compressed bytes on disk. */
|
|
51
|
+
physicalBytes(): number {
|
|
52
|
+
return this.inner.physicalBytes();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Underlying napi handle (for use with the free functions). */
|
|
56
|
+
get _raw(): _PfStore {
|
|
57
|
+
return this.inner;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Convenience wrapper around the napi `readManifest` (which returns the
|
|
63
|
+
* canonical-JSON string). Returns the parsed manifest object.
|
|
64
|
+
*/
|
|
65
|
+
export function readManifest(store: PfStore, cid: string): Manifest {
|
|
66
|
+
return JSON.parse(_readManifestRaw(store._raw, cid)) as Manifest;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// --------------------------- Manifest types ---------------------------
|
|
70
|
+
|
|
71
|
+
export interface Manifest {
|
|
72
|
+
schemaVersion: number;
|
|
73
|
+
mediaType: string;
|
|
74
|
+
agent: { kind: string; version: string; fingerprint: string };
|
|
75
|
+
model: { base: string; diff: string };
|
|
76
|
+
cache: { layout: string; manifest: string };
|
|
77
|
+
world: { fs: string; env: string; procs: string };
|
|
78
|
+
effects: { ledger: string };
|
|
79
|
+
trace: { messages: string };
|
|
80
|
+
createdAt: string;
|
|
81
|
+
parents: string[];
|
|
82
|
+
}
|