@engramx/client 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 +21 -0
- package/README.md +116 -0
- package/dist/EngramClient.d.ts +204 -0
- package/dist/EngramClient.js +1168 -0
- package/dist/EngramClient.js.map +1 -0
- package/dist/ProfileManager.d.ts +61 -0
- package/dist/ProfileManager.js +116 -0
- package/dist/ProfileManager.js.map +1 -0
- package/dist/SessionManager.d.ts +46 -0
- package/dist/SessionManager.js +114 -0
- package/dist/SessionManager.js.map +1 -0
- package/dist/agent-skill.d.ts +150 -0
- package/dist/agent-skill.js +152 -0
- package/dist/agent-skill.js.map +1 -0
- package/dist/auth.d.ts +17 -0
- package/dist/auth.js +65 -0
- package/dist/auth.js.map +1 -0
- package/dist/bootstrap.d.ts +21 -0
- package/dist/bootstrap.js +71 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/cache.d.ts +11 -0
- package/dist/cache.js +41 -0
- package/dist/cache.js.map +1 -0
- package/dist/claude-setup.d.ts +29 -0
- package/dist/claude-setup.js +57 -0
- package/dist/claude-setup.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1078 -0
- package/dist/cli.js.map +1 -0
- package/dist/encryption.d.ts +44 -0
- package/dist/encryption.js +108 -0
- package/dist/encryption.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/migrate.d.ts +106 -0
- package/dist/migrate.js +882 -0
- package/dist/migrate.js.map +1 -0
- package/dist/offline.d.ts +21 -0
- package/dist/offline.js +90 -0
- package/dist/offline.js.map +1 -0
- package/dist/openclaw-setup.d.ts +24 -0
- package/dist/openclaw-setup.js +249 -0
- package/dist/openclaw-setup.js.map +1 -0
- package/dist/pair.d.ts +20 -0
- package/dist/pair.js +68 -0
- package/dist/pair.js.map +1 -0
- package/dist/path-utils.d.ts +16 -0
- package/dist/path-utils.js +29 -0
- package/dist/path-utils.js.map +1 -0
- package/dist/schema.d.ts +54 -0
- package/dist/schema.js +101 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.d.ts +452 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +67 -0
package/dist/schema.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EngramX Memory Schema — shared path conventions for all integrations.
|
|
3
|
+
*
|
|
4
|
+
* Formalises the memory layout so that Claude, OpenClaw, and any future
|
|
5
|
+
* MCP-compatible platform share the same vocabulary for what files mean
|
|
6
|
+
* and where they live inside an engram canister.
|
|
7
|
+
*/
|
|
8
|
+
export declare const IDENTITY: {
|
|
9
|
+
/** Agent personality & principles (owner-write-only) */
|
|
10
|
+
readonly SOUL: "identity/soul.md";
|
|
11
|
+
/** Human profile — name, role, preferences (owner-write-only) */
|
|
12
|
+
readonly USER: "identity/user.md";
|
|
13
|
+
/** Communication style, formatting, tool preferences */
|
|
14
|
+
readonly PREFERENCES: "identity/preferences.md";
|
|
15
|
+
};
|
|
16
|
+
export declare const KNOWLEDGE: {
|
|
17
|
+
/** Cross-platform accumulated lessons and insights */
|
|
18
|
+
readonly LESSONS: "knowledge/lessons.md";
|
|
19
|
+
/** Decision log with rationale */
|
|
20
|
+
readonly DECISIONS: "knowledge/decisions.md";
|
|
21
|
+
/** Domain-specific knowledge file */
|
|
22
|
+
readonly domain: (topic: string) => string;
|
|
23
|
+
};
|
|
24
|
+
export declare const SESSIONS: {
|
|
25
|
+
/** Session summary for a specific platform and date */
|
|
26
|
+
readonly summary: (platform: string, date: string) => string;
|
|
27
|
+
/** Session directory prefix for a platform */
|
|
28
|
+
readonly platformDir: (platform: string) => string;
|
|
29
|
+
};
|
|
30
|
+
export declare const CONFIG: {
|
|
31
|
+
/** Platform-specific config file */
|
|
32
|
+
readonly platform: (name: string) => string;
|
|
33
|
+
readonly OPENCLAW: "config/openclaw.json";
|
|
34
|
+
readonly CLAUDE: "config/claude.json";
|
|
35
|
+
};
|
|
36
|
+
/** Default protected paths (owner-write-only). */
|
|
37
|
+
export declare const DEFAULT_PROTECTED_PATHS: readonly ["identity/soul.md", "identity/user.md"];
|
|
38
|
+
/** All well-known identity paths for batch reads. */
|
|
39
|
+
export declare const IDENTITY_PATHS: readonly ["identity/soul.md", "identity/user.md", "identity/preferences.md"];
|
|
40
|
+
/** All well-known knowledge paths for batch reads. */
|
|
41
|
+
export declare const KNOWLEDGE_PATHS: readonly ["knowledge/lessons.md", "knowledge/decisions.md"];
|
|
42
|
+
/** All well-known profile paths (identity + lessons). */
|
|
43
|
+
export declare const PROFILE_PATHS: readonly ["identity/soul.md", "identity/user.md", "identity/preferences.md", "knowledge/lessons.md"];
|
|
44
|
+
export declare const PLATFORMS: readonly ["claude", "openclaw", "cursor", "windsurf"];
|
|
45
|
+
export type Platform = (typeof PLATFORMS)[number];
|
|
46
|
+
/** Check whether a path falls under a schema namespace. */
|
|
47
|
+
export declare function isIdentityPath(path: string): boolean;
|
|
48
|
+
export declare function isKnowledgePath(path: string): boolean;
|
|
49
|
+
export declare function isSessionPath(path: string): boolean;
|
|
50
|
+
export declare function isConfigPath(path: string): boolean;
|
|
51
|
+
/** Extract the platform name from a session path, or null. */
|
|
52
|
+
export declare function sessionPlatform(path: string): string | null;
|
|
53
|
+
/** Today's date as YYYY-MM-DD. */
|
|
54
|
+
export declare function today(): string;
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EngramX Memory Schema — shared path conventions for all integrations.
|
|
3
|
+
*
|
|
4
|
+
* Formalises the memory layout so that Claude, OpenClaw, and any future
|
|
5
|
+
* MCP-compatible platform share the same vocabulary for what files mean
|
|
6
|
+
* and where they live inside an engram canister.
|
|
7
|
+
*/
|
|
8
|
+
// ── Path constants ─────────────────────────────────────────────
|
|
9
|
+
export const IDENTITY = {
|
|
10
|
+
/** Agent personality & principles (owner-write-only) */
|
|
11
|
+
SOUL: 'identity/soul.md',
|
|
12
|
+
/** Human profile — name, role, preferences (owner-write-only) */
|
|
13
|
+
USER: 'identity/user.md',
|
|
14
|
+
/** Communication style, formatting, tool preferences */
|
|
15
|
+
PREFERENCES: 'identity/preferences.md',
|
|
16
|
+
};
|
|
17
|
+
export const KNOWLEDGE = {
|
|
18
|
+
/** Cross-platform accumulated lessons and insights */
|
|
19
|
+
LESSONS: 'knowledge/lessons.md',
|
|
20
|
+
/** Decision log with rationale */
|
|
21
|
+
DECISIONS: 'knowledge/decisions.md',
|
|
22
|
+
/** Domain-specific knowledge file */
|
|
23
|
+
domain: (topic) => {
|
|
24
|
+
validateTopic(topic);
|
|
25
|
+
return `knowledge/domains/${topic}.md`;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
export const SESSIONS = {
|
|
29
|
+
/** Session summary for a specific platform and date */
|
|
30
|
+
summary: (platform, date) => {
|
|
31
|
+
validatePlatform(platform);
|
|
32
|
+
validateDate(date);
|
|
33
|
+
return `sessions/${platform}/${date}.md`;
|
|
34
|
+
},
|
|
35
|
+
/** Session directory prefix for a platform */
|
|
36
|
+
platformDir: (platform) => {
|
|
37
|
+
validatePlatform(platform);
|
|
38
|
+
return `sessions/${platform}/`;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
export const CONFIG = {
|
|
42
|
+
/** Platform-specific config file */
|
|
43
|
+
platform: (name) => {
|
|
44
|
+
validatePlatform(name);
|
|
45
|
+
return `config/${name}.json`;
|
|
46
|
+
},
|
|
47
|
+
OPENCLAW: 'config/openclaw.json',
|
|
48
|
+
CLAUDE: 'config/claude.json',
|
|
49
|
+
};
|
|
50
|
+
/** Default protected paths (owner-write-only). */
|
|
51
|
+
export const DEFAULT_PROTECTED_PATHS = [IDENTITY.SOUL, IDENTITY.USER];
|
|
52
|
+
/** All well-known identity paths for batch reads. */
|
|
53
|
+
export const IDENTITY_PATHS = [IDENTITY.SOUL, IDENTITY.USER, IDENTITY.PREFERENCES];
|
|
54
|
+
/** All well-known knowledge paths for batch reads. */
|
|
55
|
+
export const KNOWLEDGE_PATHS = [KNOWLEDGE.LESSONS, KNOWLEDGE.DECISIONS];
|
|
56
|
+
/** All well-known profile paths (identity + lessons). */
|
|
57
|
+
export const PROFILE_PATHS = [...IDENTITY_PATHS, KNOWLEDGE.LESSONS];
|
|
58
|
+
// ── Known platforms ────────────────────────────────────────────
|
|
59
|
+
export const PLATFORMS = ['claude', 'openclaw', 'cursor', 'windsurf'];
|
|
60
|
+
// ── Validators ─────────────────────────────────────────────────
|
|
61
|
+
const SAFE_NAME_RE = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
62
|
+
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
63
|
+
function validateTopic(topic) {
|
|
64
|
+
if (!SAFE_NAME_RE.test(topic)) {
|
|
65
|
+
throw new Error(`Invalid topic "${topic}": must be lowercase alphanumeric with hyphens/underscores, 1-63 chars`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function validatePlatform(platform) {
|
|
69
|
+
if (!SAFE_NAME_RE.test(platform)) {
|
|
70
|
+
throw new Error(`Invalid platform "${platform}": must be lowercase alphanumeric with hyphens/underscores, 1-63 chars`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function validateDate(date) {
|
|
74
|
+
if (!DATE_RE.test(date)) {
|
|
75
|
+
throw new Error(`Invalid date "${date}": expected YYYY-MM-DD format`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// ── Helpers ────────────────────────────────────────────────────
|
|
79
|
+
/** Check whether a path falls under a schema namespace. */
|
|
80
|
+
export function isIdentityPath(path) {
|
|
81
|
+
return path.startsWith('identity/');
|
|
82
|
+
}
|
|
83
|
+
export function isKnowledgePath(path) {
|
|
84
|
+
return path.startsWith('knowledge/');
|
|
85
|
+
}
|
|
86
|
+
export function isSessionPath(path) {
|
|
87
|
+
return path.startsWith('sessions/');
|
|
88
|
+
}
|
|
89
|
+
export function isConfigPath(path) {
|
|
90
|
+
return path.startsWith('config/');
|
|
91
|
+
}
|
|
92
|
+
/** Extract the platform name from a session path, or null. */
|
|
93
|
+
export function sessionPlatform(path) {
|
|
94
|
+
const match = path.match(/^sessions\/([a-z0-9_-]+)\//);
|
|
95
|
+
return match ? match[1] : null;
|
|
96
|
+
}
|
|
97
|
+
/** Today's date as YYYY-MM-DD. */
|
|
98
|
+
export function today() {
|
|
99
|
+
return new Date().toISOString().slice(0, 10);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kEAAkE;AAElE,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,wDAAwD;IACxD,IAAI,EAAE,kBAAkB;IACxB,iEAAiE;IACjE,IAAI,EAAE,kBAAkB;IACxB,wDAAwD;IACxD,WAAW,EAAE,yBAAyB;CAC9B,CAAC;AAEX,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,sDAAsD;IACtD,OAAO,EAAE,sBAAsB;IAC/B,kCAAkC;IAClC,SAAS,EAAE,wBAAwB;IACnC,qCAAqC;IACrC,MAAM,EAAE,CAAC,KAAa,EAAU,EAAE;QAChC,aAAa,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,qBAAqB,KAAK,KAAK,CAAC;IACzC,CAAC;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,uDAAuD;IACvD,OAAO,EAAE,CAAC,QAAgB,EAAE,IAAY,EAAU,EAAE;QAClD,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC3B,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO,YAAY,QAAQ,IAAI,IAAI,KAAK,CAAC;IAC3C,CAAC;IACD,8CAA8C;IAC9C,WAAW,EAAE,CAAC,QAAgB,EAAU,EAAE;QACxC,gBAAgB,CAA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
|
+
export type Role = {
|
|
3
|
+
Owner: null;
|
|
4
|
+
} | {
|
|
5
|
+
Operator: null;
|
|
6
|
+
} | {
|
|
7
|
+
Guardian: null;
|
|
8
|
+
};
|
|
9
|
+
export type OperatorStatus = {
|
|
10
|
+
Active: null;
|
|
11
|
+
} | {
|
|
12
|
+
Revoked: null;
|
|
13
|
+
} | {
|
|
14
|
+
Expired: null;
|
|
15
|
+
};
|
|
16
|
+
export interface OperatorPermissions {
|
|
17
|
+
canReadMemory: boolean;
|
|
18
|
+
canAppendMemory: boolean;
|
|
19
|
+
canReadWallet: boolean;
|
|
20
|
+
callsPerMinute: bigint;
|
|
21
|
+
/** Bulk backup export (pull/list/metadata). Candid opt: [] = none. */
|
|
22
|
+
canReadBackup: [] | [boolean];
|
|
23
|
+
}
|
|
24
|
+
export interface OperatorRecord {
|
|
25
|
+
principal: Principal;
|
|
26
|
+
name: string;
|
|
27
|
+
registeredAt: bigint;
|
|
28
|
+
lastSeen: bigint;
|
|
29
|
+
permissions: OperatorPermissions;
|
|
30
|
+
status: OperatorStatus;
|
|
31
|
+
publicKeyHash: string | null;
|
|
32
|
+
keyRotatedAt: bigint;
|
|
33
|
+
keyRotationCount: bigint;
|
|
34
|
+
}
|
|
35
|
+
/** Internal wire type — raw bytes as stored on-canister (plaintext; see encryption.ts) */
|
|
36
|
+
export interface RawMemoryFile {
|
|
37
|
+
path: string;
|
|
38
|
+
content: Uint8Array;
|
|
39
|
+
version: bigint;
|
|
40
|
+
lastModifiedBy: Principal;
|
|
41
|
+
lastModifiedAt: bigint;
|
|
42
|
+
}
|
|
43
|
+
/** Public type — content decoded to a UTF-8 string (no decryption; see encryption.ts) */
|
|
44
|
+
export interface MemoryFile {
|
|
45
|
+
path: string;
|
|
46
|
+
content: string;
|
|
47
|
+
version: bigint;
|
|
48
|
+
lastModifiedBy: Principal;
|
|
49
|
+
lastModifiedAt: bigint;
|
|
50
|
+
}
|
|
51
|
+
export interface MemoryFileInfo {
|
|
52
|
+
path: string;
|
|
53
|
+
version: bigint;
|
|
54
|
+
lastModifiedAt: bigint;
|
|
55
|
+
}
|
|
56
|
+
/** Internal wire type — raw snapshot bytes from canister (plaintext; see encryption.ts) */
|
|
57
|
+
export interface RawMemoryVersion {
|
|
58
|
+
version: bigint;
|
|
59
|
+
modifiedBy: Principal;
|
|
60
|
+
modifiedAt: bigint;
|
|
61
|
+
operation: {
|
|
62
|
+
Set: null;
|
|
63
|
+
} | {
|
|
64
|
+
Append: null;
|
|
65
|
+
} | {
|
|
66
|
+
Rollback: null;
|
|
67
|
+
};
|
|
68
|
+
contentSnapshot: Uint8Array;
|
|
69
|
+
}
|
|
70
|
+
/** Public type — snapshot decoded to a UTF-8 string (no decryption; see encryption.ts) */
|
|
71
|
+
export interface MemoryVersion {
|
|
72
|
+
version: bigint;
|
|
73
|
+
modifiedBy: Principal;
|
|
74
|
+
modifiedAt: bigint;
|
|
75
|
+
operation: {
|
|
76
|
+
Set: null;
|
|
77
|
+
} | {
|
|
78
|
+
Append: null;
|
|
79
|
+
} | {
|
|
80
|
+
Rollback: null;
|
|
81
|
+
};
|
|
82
|
+
contentSnapshot: string;
|
|
83
|
+
}
|
|
84
|
+
export interface Account {
|
|
85
|
+
owner: Principal;
|
|
86
|
+
subaccount: Uint8Array | null;
|
|
87
|
+
}
|
|
88
|
+
export interface AuditEntry {
|
|
89
|
+
id: bigint;
|
|
90
|
+
timestamp: bigint;
|
|
91
|
+
caller: Principal;
|
|
92
|
+
callerRole: Role;
|
|
93
|
+
operation: string;
|
|
94
|
+
details: string;
|
|
95
|
+
success: boolean;
|
|
96
|
+
}
|
|
97
|
+
export interface EngramStatus {
|
|
98
|
+
owner: Principal | null;
|
|
99
|
+
memoryFileCount: bigint;
|
|
100
|
+
auditLogSize: bigint;
|
|
101
|
+
operatorCount: bigint;
|
|
102
|
+
cyclesBalance: bigint;
|
|
103
|
+
version: string;
|
|
104
|
+
guardianCount: bigint;
|
|
105
|
+
paymentsFrozen: boolean;
|
|
106
|
+
writesPaused: boolean;
|
|
107
|
+
backupCount: bigint;
|
|
108
|
+
totalBackupSize: bigint;
|
|
109
|
+
}
|
|
110
|
+
/** @deprecated Use EngramStatus instead */
|
|
111
|
+
export type VaultStatus = EngramStatus;
|
|
112
|
+
export type EngramRecordStatus = {
|
|
113
|
+
Active: null;
|
|
114
|
+
} | {
|
|
115
|
+
Frozen: null;
|
|
116
|
+
} | {
|
|
117
|
+
Deleted: null;
|
|
118
|
+
};
|
|
119
|
+
/** @deprecated Use EngramRecordStatus instead */
|
|
120
|
+
export type VaultRecordStatus = EngramRecordStatus;
|
|
121
|
+
export interface EngramRecord {
|
|
122
|
+
owner: Principal;
|
|
123
|
+
canisterId: Principal;
|
|
124
|
+
createdAt: bigint;
|
|
125
|
+
lastTopUp: bigint;
|
|
126
|
+
status: EngramRecordStatus;
|
|
127
|
+
}
|
|
128
|
+
/** @deprecated Use EngramRecord instead */
|
|
129
|
+
export type VaultRecord = EngramRecord;
|
|
130
|
+
export interface RegistryStatus {
|
|
131
|
+
totalEngrams: bigint;
|
|
132
|
+
activeEngrams: bigint;
|
|
133
|
+
registryVersion: string;
|
|
134
|
+
engramWasmHash: string;
|
|
135
|
+
}
|
|
136
|
+
export interface GuardianPermissions {
|
|
137
|
+
canRevokeOperators: boolean;
|
|
138
|
+
canFreezePayments: boolean;
|
|
139
|
+
canPauseWrites: boolean;
|
|
140
|
+
}
|
|
141
|
+
export interface GuardianRecord {
|
|
142
|
+
principal: Principal;
|
|
143
|
+
name: string;
|
|
144
|
+
addedAt: bigint;
|
|
145
|
+
permissions: GuardianPermissions;
|
|
146
|
+
}
|
|
147
|
+
export type SessionStatus = {
|
|
148
|
+
open: null;
|
|
149
|
+
} | {
|
|
150
|
+
closing: null;
|
|
151
|
+
} | {
|
|
152
|
+
closed: null;
|
|
153
|
+
} | {
|
|
154
|
+
expired: null;
|
|
155
|
+
};
|
|
156
|
+
export interface Eip3009Authorization {
|
|
157
|
+
from: string;
|
|
158
|
+
to: string;
|
|
159
|
+
value: bigint;
|
|
160
|
+
validAfter: bigint;
|
|
161
|
+
validBefore: bigint;
|
|
162
|
+
nonce: Uint8Array;
|
|
163
|
+
v: number;
|
|
164
|
+
r: Uint8Array;
|
|
165
|
+
s: Uint8Array;
|
|
166
|
+
}
|
|
167
|
+
export interface PaymentRequirement {
|
|
168
|
+
scheme: string;
|
|
169
|
+
network: string;
|
|
170
|
+
token: string;
|
|
171
|
+
amount: bigint;
|
|
172
|
+
recipient: string;
|
|
173
|
+
nonce: Uint8Array;
|
|
174
|
+
expiry: bigint;
|
|
175
|
+
tokenName: string | null;
|
|
176
|
+
tokenVersion: string | null;
|
|
177
|
+
}
|
|
178
|
+
export interface PaymentSignature {
|
|
179
|
+
scheme: string;
|
|
180
|
+
network: string;
|
|
181
|
+
signature: Uint8Array;
|
|
182
|
+
asset: string | null;
|
|
183
|
+
publicKey: Uint8Array | null;
|
|
184
|
+
sender: string;
|
|
185
|
+
nonce: Uint8Array;
|
|
186
|
+
authorization: Eip3009Authorization | null;
|
|
187
|
+
}
|
|
188
|
+
export interface SessionIntent {
|
|
189
|
+
network: string;
|
|
190
|
+
token: string;
|
|
191
|
+
recipient: string;
|
|
192
|
+
suggestedDeposit: bigint;
|
|
193
|
+
minDeposit: bigint | null;
|
|
194
|
+
expiry: bigint;
|
|
195
|
+
costPerCall: bigint | null;
|
|
196
|
+
description: string | null;
|
|
197
|
+
}
|
|
198
|
+
export interface SessionConfig {
|
|
199
|
+
maxDeposit: bigint;
|
|
200
|
+
autoClose: boolean;
|
|
201
|
+
idleTimeout: bigint | null;
|
|
202
|
+
}
|
|
203
|
+
export interface SessionState {
|
|
204
|
+
id: string;
|
|
205
|
+
payer: Principal;
|
|
206
|
+
deposited: bigint;
|
|
207
|
+
consumed: bigint;
|
|
208
|
+
remaining: bigint;
|
|
209
|
+
voucherCount: bigint;
|
|
210
|
+
status: SessionStatus;
|
|
211
|
+
openedAt: bigint;
|
|
212
|
+
lastActivityAt: bigint;
|
|
213
|
+
}
|
|
214
|
+
export interface Voucher {
|
|
215
|
+
sessionId: string;
|
|
216
|
+
cumulativeAmount: bigint;
|
|
217
|
+
sequence: bigint;
|
|
218
|
+
signature: Uint8Array;
|
|
219
|
+
}
|
|
220
|
+
export interface SpendingPolicy {
|
|
221
|
+
maxPerTransaction: bigint | null;
|
|
222
|
+
maxPerDay: bigint | null;
|
|
223
|
+
rateLimitPerMinute: bigint | null;
|
|
224
|
+
maxSessionDeposit: bigint | null;
|
|
225
|
+
maxConcurrentSessions: bigint | null;
|
|
226
|
+
maxSessionDuration: bigint | null;
|
|
227
|
+
sessionIdleTimeout: bigint | null;
|
|
228
|
+
allowedCallers: Principal[] | null;
|
|
229
|
+
blockedCallers: Principal[] | null;
|
|
230
|
+
}
|
|
231
|
+
export interface ContentEntry {
|
|
232
|
+
id: string;
|
|
233
|
+
mimeType: string;
|
|
234
|
+
totalSize: bigint;
|
|
235
|
+
chunkCount: bigint;
|
|
236
|
+
createdAt: bigint;
|
|
237
|
+
}
|
|
238
|
+
export interface ContentRef {
|
|
239
|
+
id: string;
|
|
240
|
+
mimeType: string | null;
|
|
241
|
+
sizeBytes: bigint | null;
|
|
242
|
+
metadata: Array<[string, string]> | null;
|
|
243
|
+
}
|
|
244
|
+
export interface AccessGrant {
|
|
245
|
+
grantId: string;
|
|
246
|
+
contentRef: ContentRef;
|
|
247
|
+
grantee: Principal;
|
|
248
|
+
receiptId: string;
|
|
249
|
+
issuedAt: bigint;
|
|
250
|
+
expiresAt: bigint;
|
|
251
|
+
hmac: Uint8Array;
|
|
252
|
+
}
|
|
253
|
+
export type AccessGrantResult = {
|
|
254
|
+
ok: null;
|
|
255
|
+
} | {
|
|
256
|
+
expired: string;
|
|
257
|
+
} | {
|
|
258
|
+
revoked: string;
|
|
259
|
+
} | {
|
|
260
|
+
invalidGrant: string;
|
|
261
|
+
};
|
|
262
|
+
export interface ContentDelivery {
|
|
263
|
+
grant: AccessGrant;
|
|
264
|
+
delivery: {
|
|
265
|
+
inline: Uint8Array;
|
|
266
|
+
} | {
|
|
267
|
+
canisterQuery: {
|
|
268
|
+
method: string;
|
|
269
|
+
chunkCount: bigint;
|
|
270
|
+
};
|
|
271
|
+
} | {
|
|
272
|
+
httpUrl: string;
|
|
273
|
+
} | {
|
|
274
|
+
assetCanister: {
|
|
275
|
+
canisterId: Principal;
|
|
276
|
+
path: string;
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
export type PaymentResult = {
|
|
281
|
+
ok: PaymentReceipt;
|
|
282
|
+
} | {
|
|
283
|
+
insufficientFunds: string;
|
|
284
|
+
} | {
|
|
285
|
+
invalidSignature: string;
|
|
286
|
+
} | {
|
|
287
|
+
expired: string;
|
|
288
|
+
} | {
|
|
289
|
+
policyDenied: string;
|
|
290
|
+
} | {
|
|
291
|
+
tokenNotAccepted: string;
|
|
292
|
+
} | {
|
|
293
|
+
networkNotSupported: string;
|
|
294
|
+
} | {
|
|
295
|
+
settlementFailed: string;
|
|
296
|
+
} | {
|
|
297
|
+
reputationTooLow: bigint;
|
|
298
|
+
} | {
|
|
299
|
+
depositBelowMinimum: bigint;
|
|
300
|
+
};
|
|
301
|
+
export interface PaymentReceipt {
|
|
302
|
+
id: string;
|
|
303
|
+
amount: bigint;
|
|
304
|
+
token: string;
|
|
305
|
+
sender: string;
|
|
306
|
+
recipient: string;
|
|
307
|
+
network: string;
|
|
308
|
+
timestamp: bigint;
|
|
309
|
+
txHash: string | null;
|
|
310
|
+
sessionId: string | null;
|
|
311
|
+
refunded: bigint | null;
|
|
312
|
+
}
|
|
313
|
+
export interface AgentCard {
|
|
314
|
+
name: string;
|
|
315
|
+
description: string;
|
|
316
|
+
services: ServiceEntry[];
|
|
317
|
+
x402Support: boolean;
|
|
318
|
+
}
|
|
319
|
+
export interface ServiceEntry {
|
|
320
|
+
name: string;
|
|
321
|
+
endpoint: string;
|
|
322
|
+
version: string;
|
|
323
|
+
skills: string[];
|
|
324
|
+
domains: string[];
|
|
325
|
+
}
|
|
326
|
+
export type VerificationLevel = {
|
|
327
|
+
Orb: null;
|
|
328
|
+
} | {
|
|
329
|
+
Device: null;
|
|
330
|
+
} | {
|
|
331
|
+
Document: null;
|
|
332
|
+
};
|
|
333
|
+
export interface WorldIdProof {
|
|
334
|
+
nullifierHash: string;
|
|
335
|
+
merkleRoot: string;
|
|
336
|
+
proof: string;
|
|
337
|
+
verificationLevel: VerificationLevel;
|
|
338
|
+
verifiedAt: bigint;
|
|
339
|
+
}
|
|
340
|
+
export type BackupType = {
|
|
341
|
+
FullSnapshot: null;
|
|
342
|
+
} | {
|
|
343
|
+
PartialSnapshot: null;
|
|
344
|
+
} | {
|
|
345
|
+
IncrementalDiff: null;
|
|
346
|
+
};
|
|
347
|
+
export type BackupStatus = {
|
|
348
|
+
Uploading: null;
|
|
349
|
+
} | {
|
|
350
|
+
Finalized: null;
|
|
351
|
+
} | {
|
|
352
|
+
Failed: null;
|
|
353
|
+
};
|
|
354
|
+
export type ApprovalStatus = {
|
|
355
|
+
Pending: null;
|
|
356
|
+
} | {
|
|
357
|
+
Approved: null;
|
|
358
|
+
} | {
|
|
359
|
+
Denied: null;
|
|
360
|
+
} | {
|
|
361
|
+
Used: null;
|
|
362
|
+
} | {
|
|
363
|
+
Expired: null;
|
|
364
|
+
};
|
|
365
|
+
export interface ApprovalRequest {
|
|
366
|
+
id: string;
|
|
367
|
+
caller: Principal;
|
|
368
|
+
operation: string;
|
|
369
|
+
amount: bigint;
|
|
370
|
+
policyLimit: bigint;
|
|
371
|
+
policyField: string;
|
|
372
|
+
rationale: string;
|
|
373
|
+
createdAt: bigint;
|
|
374
|
+
expiresAt: bigint;
|
|
375
|
+
status: ApprovalStatus;
|
|
376
|
+
approvedBy: Principal | null;
|
|
377
|
+
approvedAt: bigint | null;
|
|
378
|
+
denialReason: string | null;
|
|
379
|
+
}
|
|
380
|
+
export type EndpointType = {
|
|
381
|
+
Content: null;
|
|
382
|
+
};
|
|
383
|
+
export type EndpointStatus = {
|
|
384
|
+
Disabled: null;
|
|
385
|
+
} | {
|
|
386
|
+
Enabled: null;
|
|
387
|
+
} | {
|
|
388
|
+
Deleted: null;
|
|
389
|
+
};
|
|
390
|
+
export interface X402Endpoint {
|
|
391
|
+
id: string;
|
|
392
|
+
name: string;
|
|
393
|
+
description: string;
|
|
394
|
+
endpointType: EndpointType;
|
|
395
|
+
contentId: string | null;
|
|
396
|
+
suggestedPrice: bigint;
|
|
397
|
+
price: bigint;
|
|
398
|
+
createdBy: Principal;
|
|
399
|
+
createdAt: bigint;
|
|
400
|
+
status: EndpointStatus;
|
|
401
|
+
enabledBy: Principal | null;
|
|
402
|
+
enabledAt: bigint | null;
|
|
403
|
+
totalRevenue: bigint;
|
|
404
|
+
totalPurchases: bigint;
|
|
405
|
+
}
|
|
406
|
+
export interface PurchaseRecord {
|
|
407
|
+
id: string;
|
|
408
|
+
endpointId: string;
|
|
409
|
+
buyer: string;
|
|
410
|
+
amount: bigint;
|
|
411
|
+
network: string;
|
|
412
|
+
timestamp: bigint;
|
|
413
|
+
receiptId: string;
|
|
414
|
+
txHash: string | null;
|
|
415
|
+
}
|
|
416
|
+
export interface RevenueSummary {
|
|
417
|
+
totalRevenue: bigint;
|
|
418
|
+
totalPurchases: bigint;
|
|
419
|
+
endpointBreakdown: Array<{
|
|
420
|
+
endpointId: string;
|
|
421
|
+
name: string;
|
|
422
|
+
revenue: bigint;
|
|
423
|
+
purchases: bigint;
|
|
424
|
+
}>;
|
|
425
|
+
}
|
|
426
|
+
export interface StorageStats {
|
|
427
|
+
totalFiles: bigint;
|
|
428
|
+
totalContentSize: bigint;
|
|
429
|
+
memoryFilesSize: bigint;
|
|
430
|
+
memoryFilesCount: bigint;
|
|
431
|
+
sessionFilesSize: bigint;
|
|
432
|
+
sessionFilesCount: bigint;
|
|
433
|
+
versionHistorySize: bigint;
|
|
434
|
+
versionHistoryCount: bigint;
|
|
435
|
+
backupSize: bigint;
|
|
436
|
+
backupCount: bigint;
|
|
437
|
+
fileLimit: bigint;
|
|
438
|
+
auditLogSize: bigint;
|
|
439
|
+
}
|
|
440
|
+
export interface BackupMetadata {
|
|
441
|
+
backupId: string;
|
|
442
|
+
dbType: string;
|
|
443
|
+
backupType: BackupType;
|
|
444
|
+
parentBackupId: string | null;
|
|
445
|
+
totalSize: bigint;
|
|
446
|
+
chunkCount: bigint;
|
|
447
|
+
sha256: string;
|
|
448
|
+
createdAt: bigint;
|
|
449
|
+
createdBy: Principal;
|
|
450
|
+
backupLabel: string | null;
|
|
451
|
+
status: BackupStatus;
|
|
452
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@engramx/client",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Client SDK for EngramX — persistent, decentralized memory for AI agents on ICP",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "EngramX <developer@engramx.ai>",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/vhew/engramx",
|
|
10
|
+
"directory": "packages/client"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/vhew/engramx#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/vhew/engramx/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"icp",
|
|
18
|
+
"internet-computer",
|
|
19
|
+
"ai-agent",
|
|
20
|
+
"engram",
|
|
21
|
+
"memory",
|
|
22
|
+
"decentralized",
|
|
23
|
+
"openclaw",
|
|
24
|
+
"engram"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=22.12.0"
|
|
29
|
+
},
|
|
30
|
+
"main": "dist/index.js",
|
|
31
|
+
"types": "dist/index.d.ts",
|
|
32
|
+
"bin": {
|
|
33
|
+
"engramx": "./dist/cli.js"
|
|
34
|
+
},
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist/",
|
|
43
|
+
"README.md",
|
|
44
|
+
"LICENSE"
|
|
45
|
+
],
|
|
46
|
+
"publishConfig": {
|
|
47
|
+
"access": "public"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@icp-sdk/core": "^5.4.0"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@ic402/client": "^2.5.4",
|
|
54
|
+
"@icp-sdk/core": "^5.4.0",
|
|
55
|
+
"@icp-sdk/vetkeys": "0.5.0-beta.0",
|
|
56
|
+
"cborg": "^5.1.1"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^25.9.2",
|
|
60
|
+
"typescript": "^6.0.3",
|
|
61
|
+
"vitest": "^4.1.8"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "tsc",
|
|
65
|
+
"test": "vitest run"
|
|
66
|
+
}
|
|
67
|
+
}
|