@engramx/client 0.16.0-rc.2 → 0.16.0-rc.21
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/README.md +69 -8
- package/dist/EngramClient.d.ts +60 -16
- package/dist/EngramClient.js +139 -70
- package/dist/EngramClient.js.map +1 -1
- package/dist/MarketClient.js.map +1 -1
- package/dist/ProfileManager.d.ts +3 -19
- package/dist/ProfileManager.js +1 -58
- package/dist/ProfileManager.js.map +1 -1
- package/dist/SessionManager.d.ts +1 -1
- package/dist/SessionManager.js.map +1 -1
- package/dist/actionReceipt.d.ts +8 -0
- package/dist/actionReceipt.js +8 -0
- package/dist/actionReceipt.js.map +1 -1
- package/dist/birthChain.d.ts +87 -0
- package/dist/birthChain.js +233 -0
- package/dist/birthChain.js.map +1 -0
- package/dist/cache.js.map +1 -1
- package/dist/certifiedAudit.d.ts +31 -0
- package/dist/certifiedAudit.js +124 -0
- package/dist/certifiedAudit.js.map +1 -1
- package/dist/claude-setup.d.ts +15 -6
- package/dist/claude-setup.js +30 -17
- package/dist/claude-setup.js.map +1 -1
- package/dist/cli.d.ts +7 -1
- package/dist/cli.js +212 -187
- package/dist/cli.js.map +1 -1
- package/dist/connect-config.d.ts +109 -0
- package/dist/connect-config.js +251 -0
- package/dist/connect-config.js.map +1 -0
- package/dist/encryption.d.ts +4 -0
- package/dist/encryption.js +7 -1
- package/dist/encryption.js.map +1 -1
- package/dist/evidence.d.ts +94 -0
- package/dist/evidence.js +352 -0
- package/dist/evidence.js.map +1 -0
- package/dist/idl.d.ts +21 -3
- package/dist/idl.js +34 -4
- package/dist/idl.js.map +1 -1
- package/dist/index.d.ts +13 -6
- package/dist/index.js +22 -5
- package/dist/index.js.map +1 -1
- package/dist/ledgerfsHash.d.ts +0 -2
- package/dist/ledgerfsHash.js +0 -2
- package/dist/ledgerfsHash.js.map +1 -1
- package/dist/lineage.d.ts +7 -1
- package/dist/lineage.js +7 -1
- package/dist/lineage.js.map +1 -1
- package/dist/memoryArchive.d.ts +77 -98
- package/dist/memoryArchive.js +58 -31
- package/dist/memoryArchive.js.map +1 -1
- package/dist/migrate.d.ts +18 -30
- package/dist/migrate.js +42 -136
- package/dist/migrate.js.map +1 -1
- package/dist/openEngram.d.ts +7 -0
- package/dist/openEngram.js +27 -3
- package/dist/openEngram.js.map +1 -1
- package/dist/openclaw-local.d.ts +86 -0
- package/dist/openclaw-local.js +332 -0
- package/dist/openclaw-local.js.map +1 -0
- package/dist/openclaw-setup.d.ts +82 -3
- package/dist/openclaw-setup.js +162 -50
- package/dist/openclaw-setup.js.map +1 -1
- package/dist/pair.js.map +1 -1
- package/dist/path-utils.d.ts +0 -16
- package/dist/path-utils.js +4 -27
- package/dist/path-utils.js.map +1 -1
- package/dist/publicRecord.d.ts +5 -0
- package/dist/publicRecord.js +52 -0
- package/dist/publicRecord.js.map +1 -0
- package/dist/recordChain.d.ts +69 -0
- package/dist/recordChain.js +145 -0
- package/dist/recordChain.js.map +1 -0
- package/dist/schema.d.ts +11 -22
- package/dist/schema.js +6 -28
- package/dist/schema.js.map +1 -1
- package/dist/types.d.ts +67 -451
- package/dist/verify.d.ts +8 -0
- package/dist/verify.js +19 -0
- package/dist/verify.js.map +1 -0
- package/dist/version.d.ts +22 -0
- package/dist/version.js +22 -0
- package/dist/version.js.map +1 -1
- package/package.json +27 -12
- package/dist/generated/engram.idl.d.ts +0 -6
- package/dist/generated/engram.idl.js +0 -1366
- package/dist/generated/engram.idl.js.map +0 -1
- package/dist/generated/market.idl.d.ts +0 -6
- package/dist/generated/market.idl.js +0 -557
- package/dist/generated/market.idl.js.map +0 -1
- package/dist/generated/registry.idl.d.ts +0 -6
- package/dist/generated/registry.idl.js +0 -510
- package/dist/generated/registry.idl.js.map +0 -1
- package/dist/offline.d.ts +0 -21
- package/dist/offline.js +0 -104
- package/dist/offline.js.map +0 -1
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// The chained record's hash contract, and the walk from one entry to a certified head.
|
|
2
|
+
//
|
|
3
|
+
// ⟨ADDED 2026-10-15, the owner's ruling 6B of 2026-10-14⟩ WHY THIS IS PUBLIC. Every engram, the
|
|
4
|
+
// registry and the market keep a chained record: each entry's hash commits to the head before it,
|
|
5
|
+
// and the canister certifies only the newest head. A stranger who wants to check ONE entry against
|
|
6
|
+
// the subnet's signature has to walk from that entry to a certified head. Under the rule this file
|
|
7
|
+
// mirrors, each entry is HASHED FIRST, THEN CHAINED:
|
|
8
|
+
//
|
|
9
|
+
// body = id|timestampNs|caller|role|operation|details|success (success = "1" | "0")
|
|
10
|
+
// digest = SHA-256(body)
|
|
11
|
+
// entryHash = SHA-256(previous head ‖ digest) (genesis head = empty)
|
|
12
|
+
//
|
|
13
|
+
// so the walk passes through every other entry knowing only its 32-byte digest — which the record
|
|
14
|
+
// read (`listAuditEntries`) serves to anyone as a hash-only row — and never its body. Entries a
|
|
15
|
+
// chain recorded before its upgrade to this rule were hashed SHA-256(previous head ‖ body); the read
|
|
16
|
+
// says where each chain switched (`hashFirstFrom`), and a walk through an older entry needs its body.
|
|
17
|
+
//
|
|
18
|
+
// The Motoko half is src/shared/AuditLog.mo (`bodyOf`, `digestOf`, `link`, `legacyLink`). The two
|
|
19
|
+
// are locked by the same known-answer vector, computed outside both (Python's hashlib): this
|
|
20
|
+
// package's test/record-chain.test.ts and the repo's test/audit-log-hash-first.test.mo assert the
|
|
21
|
+
// same constants. A diff in either is a contract change, never a routine test update.
|
|
22
|
+
//
|
|
23
|
+
// BROWSER-SAFE: hashing is WebCrypto (`crypto.subtle`), present in every browser and in Node ≥ 19;
|
|
24
|
+
// nothing here imports a Node module (test/browser-safe-subpaths.test.ts walks `./verify`'s graph).
|
|
25
|
+
const utf8 = new TextEncoder();
|
|
26
|
+
const principalText = (p) => typeof p === 'string' ? p : p.toText();
|
|
27
|
+
const roleText = (r) => typeof r === 'string' ? r : (Object.keys(r)[0] ?? '');
|
|
28
|
+
/** The bytes an entry's hash covers — byte-for-byte `AuditLog.bodyOf`. */
|
|
29
|
+
export function recordEntryBody(e) {
|
|
30
|
+
return utf8.encode([
|
|
31
|
+
BigInt(e.id).toString(),
|
|
32
|
+
BigInt(e.timestampNs).toString(),
|
|
33
|
+
principalText(e.caller),
|
|
34
|
+
roleText(e.callerRole),
|
|
35
|
+
e.operation,
|
|
36
|
+
e.details,
|
|
37
|
+
e.success ? '1' : '0',
|
|
38
|
+
].join('|'));
|
|
39
|
+
}
|
|
40
|
+
function concat(a, b) {
|
|
41
|
+
const out = new Uint8Array(a.length + b.length);
|
|
42
|
+
out.set(a, 0);
|
|
43
|
+
out.set(b, a.length);
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
export async function sha256(bytes) {
|
|
47
|
+
return new Uint8Array(await globalThis.crypto.subtle.digest('SHA-256', bytes));
|
|
48
|
+
}
|
|
49
|
+
/** SHA-256 of an entry's body — the digest a hash-only row carries. */
|
|
50
|
+
export const recordDigest = (body) => sha256(body);
|
|
51
|
+
/** The hash-first rule: SHA-256(prev ‖ digest). */
|
|
52
|
+
export const recordLink = (prev, digest) => sha256(concat(prev, digest));
|
|
53
|
+
/** The rule before a chain's switch point: SHA-256(prev ‖ body). */
|
|
54
|
+
export const legacyRecordLink = (prev, body) => sha256(concat(prev, body));
|
|
55
|
+
/**
|
|
56
|
+
* One entry's hash from its fields and the head before it, under the rule its id falls on.
|
|
57
|
+
* `hashFirstFrom` is the chain's switch point as its record read serves it.
|
|
58
|
+
*/
|
|
59
|
+
export async function recordEntryHash(e, prev, hashFirstFrom) {
|
|
60
|
+
const body = recordEntryBody(e);
|
|
61
|
+
return BigInt(e.id) >= hashFirstFrom
|
|
62
|
+
? recordLink(prev, await recordDigest(body))
|
|
63
|
+
: legacyRecordLink(prev, body);
|
|
64
|
+
}
|
|
65
|
+
/** A full entry turned into the row a stranger would be served — for walking a page that mixes the two. */
|
|
66
|
+
export async function sealedRowOf(e) {
|
|
67
|
+
return {
|
|
68
|
+
id: BigInt(e.id),
|
|
69
|
+
digest: await recordDigest(recordEntryBody(e)),
|
|
70
|
+
entryHash: Uint8Array.from(e.entryHash),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export const sameBytes = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
|
|
74
|
+
export const toHexString = (b) => Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');
|
|
75
|
+
/**
|
|
76
|
+
* Walk from one entry's hash, through hash-only rows, to a certified head.
|
|
77
|
+
*
|
|
78
|
+
* `rows` are taken in the order given and must continue the chain from `fromId + 1` with no gap and
|
|
79
|
+
* no reordering — the walk does NOT sort them, so a removed or a swapped row is named rather than
|
|
80
|
+
* silently repaired. Leading rows at or below `fromId` are skipped (a fetched page may start earlier).
|
|
81
|
+
* Each row's digest is chained onto the running head; when the row carries an entry hash it must
|
|
82
|
+
* agree. The walk succeeds the moment the running head equals `certifiedHead`.
|
|
83
|
+
*/
|
|
84
|
+
export async function walkToCertifiedHead(args) {
|
|
85
|
+
const { fromId, fromHash, certifiedHead, hashFirstFrom } = args;
|
|
86
|
+
if (sameBytes(fromHash, certifiedHead))
|
|
87
|
+
return { ok: true, distance: 0n, headId: fromId };
|
|
88
|
+
const rows = args.rows;
|
|
89
|
+
let i = 0;
|
|
90
|
+
while (i < rows.length && rows[i].id <= fromId)
|
|
91
|
+
i++;
|
|
92
|
+
let h = fromHash;
|
|
93
|
+
let expected = fromId + 1n;
|
|
94
|
+
for (; i < rows.length; i++, expected++) {
|
|
95
|
+
const row = rows[i];
|
|
96
|
+
if (row.id !== expected) {
|
|
97
|
+
const next = rows[i + 1];
|
|
98
|
+
if (next && next.id === expected && row.id === expected + 1n) {
|
|
99
|
+
return {
|
|
100
|
+
ok: false,
|
|
101
|
+
at: expected,
|
|
102
|
+
why: `rows ${expected} and ${row.id} are swapped: the chain is walked in id order, and a reordered row breaks it`,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
if (row.id > expected) {
|
|
106
|
+
return {
|
|
107
|
+
ok: false,
|
|
108
|
+
at: expected,
|
|
109
|
+
why: `row ${expected} is missing: the rows jump from ${expected - 1n} to ${row.id}, and every entry between the one checked and the certified head is needed`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
ok: false,
|
|
114
|
+
at: row.id,
|
|
115
|
+
why: `row ${row.id} is out of order: it comes after row ${expected - 1n}`,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (row.id < hashFirstFrom) {
|
|
119
|
+
return {
|
|
120
|
+
ok: false,
|
|
121
|
+
at: row.id,
|
|
122
|
+
why: `row ${row.id} was hashed under the record's older rule (below its switch point ${hashFirstFrom}): a walk through it needs its body, not its digest`,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const next = await recordLink(h, row.digest);
|
|
126
|
+
if (row.entryHash.length > 0 && !sameBytes(next, row.entryHash)) {
|
|
127
|
+
return {
|
|
128
|
+
ok: false,
|
|
129
|
+
at: row.id,
|
|
130
|
+
why: `row ${row.id} does not chain: SHA-256(previous head ‖ its digest) is ${toHexString(next)}, its entry hash is ${toHexString(row.entryHash)} — the row was altered, or a row before it was`,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
h = next;
|
|
134
|
+
if (sameBytes(h, certifiedHead))
|
|
135
|
+
return { ok: true, distance: expected - fromId, headId: expected };
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
ok: false,
|
|
139
|
+
at: expected,
|
|
140
|
+
why: `the certified head was not reached: walking ${expected - 1n - fromId} row(s) from entry ${fromId} ` +
|
|
141
|
+
`(to id ${expected - 1n}) never produced it. Either the rows stop short of the certified head, or the ` +
|
|
142
|
+
`certificate certifies a head from BEFORE this entry`,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=recordChain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recordChain.js","sourceRoot":"","sources":["../src/recordChain.ts"],"names":[],"mappings":"AAAA,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GAAG,CAAC,EAAE;gBACV,GAAG,EAAE,OAAO,GAAG,CAAC,EAAE,qEAAqE,aAAa,qDAAqD;aAC1J,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAChE,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,EAAE,EAAE,GAAG,CAAC,EAAE;gBACV,GAAG,EAAE,OAAO,GAAG,CAAC,EAAE,2DAA2D,WAAW,CAAC,IAAI,CAAC,uBAAuB,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,gDAAgD;aAChM,CAAC;QACJ,CAAC;QACD,CAAC,GAAG,IAAI,CAAC;QACT,IAAI,SAAS,CAAC,CAAC,EAAE,aAAa,CAAC;YAC7B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACvE,CAAC;IACD,OAAO;QACL,EAAE,EAAE,KAAK;QACT,EAAE,EAAE,QAAQ;QACZ,GAAG,EACD,+CAA+C,QAAQ,GAAG,EAAE,GAAG,MAAM,sBAAsB,MAAM,GAAG;YACpG,UAAU,QAAQ,GAAG,EAAE,gFAAgF;YACvG,qDAAqD;KACxD,CAAC;AACJ,CAAC"}
|
package/dist/schema.d.ts
CHANGED
|
@@ -4,20 +4,26 @@
|
|
|
4
4
|
* Formalises the memory layout so that Claude, OpenClaw, and any future
|
|
5
5
|
* MCP-compatible platform share the same vocabulary for what files mean
|
|
6
6
|
* and where they live inside an engram canister.
|
|
7
|
+
*
|
|
8
|
+
* ⟨2026-10-13⟩ CONFIG, DEFAULT_PROTECTED_PATHS, KNOWLEDGE_PATHS, PLATFORMS (and its Platform type)
|
|
9
|
+
* and the isIdentityPath / isKnowledgePath / isSessionPath / isConfigPath helpers were removed in
|
|
10
|
+
* the bloat audit: nothing in this repo or the platform referenced them, and nothing tested them.
|
|
11
|
+
* DEFAULT_PROTECTED_PATHS also described a default protected list the engram does not have (an
|
|
12
|
+
* engram's protected-path list starts empty).
|
|
7
13
|
*/
|
|
8
14
|
export declare const IDENTITY: {
|
|
9
15
|
/** Agent personality & principles (owner-write-only) */
|
|
10
|
-
readonly SOUL:
|
|
16
|
+
readonly SOUL: 'identity/soul.md';
|
|
11
17
|
/** Human profile — name, role, preferences (owner-write-only) */
|
|
12
|
-
readonly USER:
|
|
18
|
+
readonly USER: 'identity/user.md';
|
|
13
19
|
/** Communication style, formatting, tool preferences */
|
|
14
|
-
readonly PREFERENCES:
|
|
20
|
+
readonly PREFERENCES: 'identity/preferences.md';
|
|
15
21
|
};
|
|
16
22
|
export declare const KNOWLEDGE: {
|
|
17
23
|
/** Cross-platform accumulated lessons and insights */
|
|
18
|
-
readonly LESSONS:
|
|
24
|
+
readonly LESSONS: 'knowledge/lessons.md';
|
|
19
25
|
/** Decision log with rationale */
|
|
20
|
-
readonly DECISIONS:
|
|
26
|
+
readonly DECISIONS: 'knowledge/decisions.md';
|
|
21
27
|
/** Domain-specific knowledge file */
|
|
22
28
|
readonly domain: (topic: string) => string;
|
|
23
29
|
};
|
|
@@ -27,27 +33,10 @@ export declare const SESSIONS: {
|
|
|
27
33
|
/** Session directory prefix for a platform */
|
|
28
34
|
readonly platformDir: (platform: string) => string;
|
|
29
35
|
};
|
|
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
36
|
/** All well-known identity paths for batch reads. */
|
|
39
37
|
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
38
|
/** All well-known profile paths (identity + lessons). */
|
|
43
39
|
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
40
|
/** Extract the platform name from a session path, or null. */
|
|
52
41
|
export declare function sessionPlatform(path: string): string | null;
|
|
53
42
|
/** Today's date as YYYY-MM-DD. */
|
package/dist/schema.js
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
* Formalises the memory layout so that Claude, OpenClaw, and any future
|
|
5
5
|
* MCP-compatible platform share the same vocabulary for what files mean
|
|
6
6
|
* and where they live inside an engram canister.
|
|
7
|
+
*
|
|
8
|
+
* ⟨2026-10-13⟩ CONFIG, DEFAULT_PROTECTED_PATHS, KNOWLEDGE_PATHS, PLATFORMS (and its Platform type)
|
|
9
|
+
* and the isIdentityPath / isKnowledgePath / isSessionPath / isConfigPath helpers were removed in
|
|
10
|
+
* the bloat audit: nothing in this repo or the platform referenced them, and nothing tested them.
|
|
11
|
+
* DEFAULT_PROTECTED_PATHS also described a default protected list the engram does not have (an
|
|
12
|
+
* engram's protected-path list starts empty).
|
|
7
13
|
*/
|
|
8
14
|
// ── Path constants ─────────────────────────────────────────────
|
|
9
15
|
export const IDENTITY = {
|
|
@@ -38,25 +44,10 @@ export const SESSIONS = {
|
|
|
38
44
|
return `sessions/${platform}/`;
|
|
39
45
|
},
|
|
40
46
|
};
|
|
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
47
|
/** All well-known identity paths for batch reads. */
|
|
53
48
|
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
49
|
/** All well-known profile paths (identity + lessons). */
|
|
57
50
|
export const PROFILE_PATHS = [...IDENTITY_PATHS, KNOWLEDGE.LESSONS];
|
|
58
|
-
// ── Known platforms ────────────────────────────────────────────
|
|
59
|
-
export const PLATFORMS = ['claude', 'openclaw', 'cursor', 'windsurf'];
|
|
60
51
|
// ── Validators ─────────────────────────────────────────────────
|
|
61
52
|
const SAFE_NAME_RE = /^[a-z0-9][a-z0-9_-]{0,62}$/;
|
|
62
53
|
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
@@ -76,19 +67,6 @@ function validateDate(date) {
|
|
|
76
67
|
}
|
|
77
68
|
}
|
|
78
69
|
// ── 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
70
|
/** Extract the platform name from a session path, or null. */
|
|
93
71
|
export function sessionPlatform(path) {
|
|
94
72
|
const match = path.match(/^sessions\/([a-z0-9_-]+)\//);
|
package/dist/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;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,KAA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