@agentunion/fastaun 0.4.4 → 0.4.6

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 (64) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/_packed_docs/CHANGELOG.md +41 -0
  3. package/_packed_docs/INDEX.md +2 -2
  4. package/_packed_docs/KITE_DOCS_GUIDE.md +1 -1
  5. package/_packed_docs/agent.md//350/277/234/347/250/213agent.md/347/274/223/345/255/230/344/270/216etag/351/200/217/344/274/240/346/226/271/346/241/210.md +73 -84
  6. package/_packed_docs/sdk/01-/345/277/253/351/200/237/345/274/200/345/247/213.md +16 -15
  7. package/_packed_docs/sdk/02-WebSocket/345/215/217/350/256/256.md +2 -2
  8. package/_packed_docs/sdk/03-/346/240/270/345/277/203/346/246/202/345/277/265.md +22 -5
  9. package/_packed_docs/sdk/04-/350/277/236/346/216/245/344/270/216/350/256/244/350/257/201.md +42 -26
  10. package/_packed_docs/sdk/05-E2EE/345/212/240/345/257/206/351/200/232/344/277/241.md +2 -2
  11. package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +61 -35
  12. package/_packed_docs/sdk/08-/346/234/200/344/275/263/345/256/236/350/267/265.md +3 -3
  13. package/_packed_docs/sdk/09-message-rpc-manual.md +6 -6
  14. package/_packed_docs/sdk/AUN_DOCS_GUIDE.md +6 -4
  15. package/_packed_docs/sdk/INDEX.md +2 -2
  16. package/_packed_docs/sdk/README.md +3 -3
  17. package/dist/agent-md.d.ts +101 -0
  18. package/dist/agent-md.js +778 -0
  19. package/dist/agent-md.js.map +1 -0
  20. package/dist/aid-store.d.ts +7 -39
  21. package/dist/aid-store.js +74 -141
  22. package/dist/aid-store.js.map +1 -1
  23. package/dist/auth.d.ts +17 -32
  24. package/dist/auth.js +42 -295
  25. package/dist/auth.js.map +1 -1
  26. package/dist/client.d.ts +6 -65
  27. package/dist/client.js +213 -913
  28. package/dist/client.js.map +1 -1
  29. package/dist/crypto.d.ts +1 -1
  30. package/dist/crypto.js +1 -1
  31. package/dist/index.d.ts +4 -2
  32. package/dist/index.js +3 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/keystore/aid-db.d.ts +0 -4
  35. package/dist/keystore/aid-db.js +4 -95
  36. package/dist/keystore/aid-db.js.map +1 -1
  37. package/dist/keystore/file.d.ts +8 -3
  38. package/dist/keystore/file.js +103 -24
  39. package/dist/keystore/file.js.map +1 -1
  40. package/dist/keystore/index.d.ts +43 -36
  41. package/dist/keystore/index.js +3 -2
  42. package/dist/keystore/index.js.map +1 -1
  43. package/dist/keystore/local-identity-store.d.ts +70 -0
  44. package/dist/keystore/local-identity-store.js +525 -0
  45. package/dist/keystore/local-identity-store.js.map +1 -0
  46. package/dist/keystore/local-token-store.d.ts +68 -0
  47. package/dist/keystore/local-token-store.js +368 -0
  48. package/dist/keystore/local-token-store.js.map +1 -0
  49. package/dist/register-flow.d.ts +57 -0
  50. package/dist/register-flow.js +433 -0
  51. package/dist/register-flow.js.map +1 -0
  52. package/dist/secret-store/file-store.js +6 -1
  53. package/dist/secret-store/file-store.js.map +1 -1
  54. package/dist/v2/session/keystore.d.ts +5 -0
  55. package/dist/v2/session/keystore.js +21 -3
  56. package/dist/v2/session/keystore.js.map +1 -1
  57. package/dist/version.d.ts +1 -1
  58. package/dist/version.js +1 -1
  59. package/package.json +1 -1
  60. package/_packed_docs/0.4.0_/345/267/256/345/274/202/346/240/270/345/256/236/345/206/263/347/255/226/350/256/260/345/275/225.md +0 -302
  61. package/_packed_docs/AUN_SDK_0.4.0_/350/256/276/350/256/241/345/257/271/346/257/224/345/210/206/346/236/220.md +0 -194
  62. package/_packed_docs/AUN_SDK_/351/207/215/346/236/204/345/256/236/346/226/275/350/256/241/345/210/222.md +0 -596
  63. package/_packed_docs/AUN_SDK_/351/207/215/346/236/204/350/256/276/350/256/241/346/226/271/346/241/210_v3.md +0 -1698
  64. package/_packed_docs/python-sdk-v2-only-changelog.md +0 -189
@@ -1,40 +1,18 @@
1
1
  /**
2
- * KeyStore 接口定义
2
+ * KeyStore / TokenStore 接口定义
3
3
  *
4
- * Python SDK KeyStore Protocol 完全对齐。
4
+ * TokenStore 不含私钥操作,AuthFlow / AUNClient 持有此类型。
5
+ * KeyStore — 仅包含私钥/完整身份操作,AIDStore / RegisterFlow 持有。
5
6
  */
6
7
  import type { IdentityRecord, KeyPairRecord, MetadataRecord } from '../types.js';
7
- export interface AgentMdCacheRecord {
8
- aid: string;
9
- content: string;
10
- local_etag: string;
11
- remote_etag: string;
12
- last_modified: string;
13
- fetched_at: number;
14
- observed_at: number;
15
- checked_at: number;
16
- remote_status: string;
17
- verify_status: string;
18
- verify_error: string;
19
- last_error: string;
20
- updated_at: number;
21
- }
22
- export type AgentMdCacheUpsert = Partial<Omit<AgentMdCacheRecord, 'aid' | 'updated_at'>>;
23
- export interface KeyStore {
24
- /** 加载密钥对 */
25
- loadKeyPair(aid: string): KeyPairRecord | null;
26
- /** 保存密钥对 */
27
- saveKeyPair(aid: string, keyPair: KeyPairRecord): void;
8
+ /** 不含私钥操作的存储接口,AuthFlow / AUNClient 持有此类型。 */
9
+ export interface TokenStore {
28
10
  /** 加载证书 */
29
11
  loadCert(aid: string, certFingerprint?: string): string | null;
30
12
  /** 保存证书 */
31
13
  saveCert(aid: string, certPem: string, certFingerprint?: string, opts?: {
32
14
  makeActive?: boolean;
33
15
  }): void;
34
- /** 加载完整身份信息 */
35
- loadIdentity(aid: string): IdentityRecord | null;
36
- /** 保存完整身份信息 */
37
- saveIdentity(aid: string, identity: IdentityRecord): void;
38
16
  /** 加载实例级状态 */
39
17
  loadInstanceState?(aid: string, deviceId: string, slotId?: string): MetadataRecord | null;
40
18
  /** 保存实例级状态 */
@@ -49,20 +27,14 @@ export interface KeyStore {
49
27
  loadAllSeqs?(aid: string, deviceId: string, slotId: string): Record<string, number>;
50
28
  /** 删除单个 namespace 的 contiguous_seq 行 */
51
29
  deleteSeq?(aid: string, deviceId: string, slotId: string, namespace: string): void;
52
- /** 读取最近 ack seq,供 SeqTracker 作 baseline 使用 */
30
+ /** 读取最近 ack seq */
53
31
  getLastAckSeq?(aid: string, deviceId: string, slotId: string, namespace: string): number;
54
32
  /** 写入最近 ack seq */
55
33
  setLastAckSeq?(aid: string, deviceId: string, slotId: string, namespace: string, seq: number): void;
56
- /** 列出所有已存储的 AID(对齐 Python list_identities) */
57
- listIdentities?(): string[];
58
- /** 加载指定 AID 的元数据(对齐 Python load_metadata) */
34
+ /** 加载指定 AID 的元数据 */
59
35
  loadMetadata?(aid: string): Record<string, unknown> | null;
60
- /** 保存指定 AID 的元数据(对齐 Python save_metadata,增量覆盖字段) */
36
+ /** 保存指定 AID 的元数据 */
61
37
  saveMetadata?(aid: string, metadata: Record<string, unknown>): void;
62
- /** 加载本地持久化的某个远端/自身 agent.md 缓存记录 */
63
- loadAgentMdCache?(ownerAid: string, targetAid: string): AgentMdCacheRecord | null;
64
- /** 更新本地持久化的某个远端/自身 agent.md 缓存记录 */
65
- upsertAgentMdCache?(ownerAid: string, targetAid: string, fields: AgentMdCacheUpsert): AgentMdCacheRecord;
66
38
  /** 保存群组状态(state_hash 链) */
67
39
  saveGroupState?(groupId: string, stateVersion: number, stateHash: string, keyEpoch: number, membershipJson: string, policyJson: string): void;
68
40
  /** 加载群组状态 */
@@ -88,3 +60,38 @@ export interface KeyStore {
88
60
  /** 保存 issuer 根证书并合并到 bundle,返回 [证书路径, bundle 路径] */
89
61
  saveIssuerRootCert?(issuer: string, certPem: string, fingerprintSha256?: string): [string, string];
90
62
  }
63
+ /** 私钥/完整身份存储接口,仅 AIDStore / RegisterFlow 持有。 */
64
+ export interface KeyStore {
65
+ /** 加载证书 */
66
+ loadCert(aid: string, certFingerprint?: string): string | null;
67
+ /** 保存证书 */
68
+ saveCert(aid: string, certPem: string, certFingerprint?: string, opts?: {
69
+ makeActive?: boolean;
70
+ }): void;
71
+ /** 加载密钥对 */
72
+ loadKeyPair(aid: string): KeyPairRecord | null;
73
+ /** 保存密钥对 */
74
+ saveKeyPair(aid: string, keyPair: KeyPairRecord): void;
75
+ /** 创建注册 pending 身份记录 */
76
+ pendingIdentityDir?(aid: string): string;
77
+ /** 列出指定 AID 的 pending 身份记录 */
78
+ listPendingIdentityDirs?(aid: string): string[];
79
+ /** 保存 pending 密钥对 */
80
+ savePendingKeyPair?(handle: string, aid: string, keyPair: KeyPairRecord): void;
81
+ /** 加载 pending 密钥对 */
82
+ loadPendingKeyPair?(handle: string, aid: string): KeyPairRecord | null;
83
+ /** 保存 pending 证书 */
84
+ savePendingCert?(handle: string, certPem: string): void;
85
+ /** 将 pending 身份转正 */
86
+ promotePendingIdentity?(handle: string, aid: string): string;
87
+ /** 删除指定 pending 身份 */
88
+ discardPendingIdentity?(handle: string): void;
89
+ /** 清理超龄 pending 身份 */
90
+ cleanupPendingDirs?(maxAgeMs?: number): number;
91
+ /** 加载完整身份信息(含私钥) */
92
+ loadIdentity(aid: string): IdentityRecord | null;
93
+ /** 保存完整身份信息(允许写入私钥字段) */
94
+ saveIdentity(aid: string, identity: IdentityRecord): void;
95
+ /** 列出所有已存储的 AID */
96
+ listIdentities?(): string[];
97
+ }
@@ -1,7 +1,8 @@
1
1
  /**
2
- * KeyStore 接口定义
2
+ * KeyStore / TokenStore 接口定义
3
3
  *
4
- * Python SDK KeyStore Protocol 完全对齐。
4
+ * TokenStore 不含私钥操作,AuthFlow / AUNClient 持有此类型。
5
+ * KeyStore — 仅包含私钥/完整身份操作,AIDStore / RegisterFlow 持有。
5
6
  */
6
7
  export {};
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/keystore/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/keystore/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * LocalIdentityStore — 基于文件系统 + SQLite 的 KeyStore 实现(含私钥操作)。
3
+ * AIDStore / RegisterFlow 持有此类型。
4
+ */
5
+ import type { KeyStore } from './index.js';
6
+ import type { SecretStore } from '../secret-store/index.js';
7
+ import type { ModuleLogger } from '../logger.js';
8
+ import { type SeedChangeResult } from '../secret-store/file-store.js';
9
+ import { type IdentityRecord, type KeyPairRecord, type MetadataRecord } from '../types.js';
10
+ export declare class LocalIdentityStore implements KeyStore {
11
+ private _root;
12
+ private _aidsRoot;
13
+ private _secretStore;
14
+ private _aidDBs;
15
+ readonly deviceId: string;
16
+ private _logger;
17
+ constructor(root?: string, opts?: {
18
+ secretStore?: SecretStore;
19
+ encryptionSeed?: string;
20
+ logger?: ModuleLogger;
21
+ secretStoreLogger?: ModuleLogger;
22
+ });
23
+ close(): void;
24
+ static ChangeSeed(root: string, oldSeed: string, newSeed: string): SeedChangeResult;
25
+ changeSeed(oldSeed: string, newSeed: string): SeedChangeResult;
26
+ private _prepareRoot;
27
+ private _getDB;
28
+ loadKeyPair(aid: string): KeyPairRecord | null;
29
+ saveKeyPair(aid: string, keyPair: KeyPairRecord): void;
30
+ private _saveKeyPairAtPath;
31
+ private _restoreKeyPair;
32
+ loadCert(aid: string, certFingerprint?: string): string | null;
33
+ saveCert(aid: string, certPem: string, certFingerprint?: string, opts?: {
34
+ makeActive?: boolean;
35
+ }): void;
36
+ private _normalizeCertFingerprint;
37
+ loadIdentity(aid: string): IdentityRecord | null;
38
+ saveIdentity(aid: string, identity: IdentityRecord): void;
39
+ loadAnyIdentity(): IdentityRecord | null;
40
+ listIdentities(): string[];
41
+ loadMetadata(aid: string): Record<string, unknown> | null;
42
+ saveMetadata(aid: string, metadata: Record<string, unknown>): void;
43
+ loadInstanceState(aid: string, deviceId: string, slotId?: string): MetadataRecord | null;
44
+ saveInstanceState(aid: string, deviceId: string, slotId: string, state: MetadataRecord): void;
45
+ saveSeq(aid: string, deviceId: string, slotId: string, namespace: string, contiguousSeq: number): void;
46
+ loadSeq(aid: string, deviceId: string, slotId: string, namespace: string): number;
47
+ loadAllSeqs(aid: string, deviceId: string, slotId: string): Record<string, number>;
48
+ trustRootDir(): string;
49
+ trustRootBundlePath(): string;
50
+ saveTrustRoots(trustList: Record<string, unknown>, rootCerts: Array<{
51
+ id?: string;
52
+ cert_pem: string;
53
+ fingerprint_sha256?: string;
54
+ }>): string;
55
+ saveIssuerRootCert(issuer: string, certPem: string, fingerprintSha256?: string): [string, string];
56
+ private _pemFingerprint;
57
+ pendingIdentityDir(aid: string): string;
58
+ listPendingIdentityDirs(aid: string): string[];
59
+ savePendingKeyPair(pendingDir: string, aid: string, keyPair: KeyPairRecord): void;
60
+ loadPendingKeyPair(pendingDir: string, aid: string): KeyPairRecord | null;
61
+ savePendingCert(pendingDir: string, certPem: string): void;
62
+ promotePendingIdentity(pendingDir: string, aid: string): string;
63
+ discardPendingIdentity(pendingDir: string): void;
64
+ cleanupPendingDirs(maxAgeMs?: number): number;
65
+ private _ensurePendingKeyPairProtected;
66
+ private _pendingRoot;
67
+ private _keyPairPath;
68
+ private _certPath;
69
+ private _certVersionPath;
70
+ }