@nekzus/liop 1.2.0-alpha.10

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 (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +413 -0
  3. package/dist/bin/agent.d.ts +2 -0
  4. package/dist/bin/agent.js +307 -0
  5. package/dist/bridge/index.d.ts +37 -0
  6. package/dist/bridge/index.js +249 -0
  7. package/dist/bridge/stream.d.ts +62 -0
  8. package/dist/bridge/stream.js +202 -0
  9. package/dist/client/index.d.ts +60 -0
  10. package/dist/client/index.js +275 -0
  11. package/dist/crypto/logic-image-id.d.ts +3 -0
  12. package/dist/crypto/logic-image-id.js +27 -0
  13. package/dist/crypto/verifier.d.ts +29 -0
  14. package/dist/crypto/verifier.js +96 -0
  15. package/dist/economy/estimator.d.ts +53 -0
  16. package/dist/economy/estimator.js +69 -0
  17. package/dist/economy/index.d.ts +5 -0
  18. package/dist/economy/index.js +3 -0
  19. package/dist/economy/otel.d.ts +38 -0
  20. package/dist/economy/otel.js +100 -0
  21. package/dist/economy/telemetry.d.ts +77 -0
  22. package/dist/economy/telemetry.js +224 -0
  23. package/dist/gateway/hybrid.d.ts +23 -0
  24. package/dist/gateway/hybrid.js +199 -0
  25. package/dist/gateway/router.d.ts +69 -0
  26. package/dist/gateway/router.js +1036 -0
  27. package/dist/index.d.ts +11 -0
  28. package/dist/index.js +11 -0
  29. package/dist/mesh/index.d.ts +1 -0
  30. package/dist/mesh/index.js +1 -0
  31. package/dist/mesh/node.d.ts +129 -0
  32. package/dist/mesh/node.js +853 -0
  33. package/dist/prompts/adapters.d.ts +16 -0
  34. package/dist/prompts/adapters.js +55 -0
  35. package/dist/protocol/liop_core.proto +44 -0
  36. package/dist/rpc/client.d.ts +22 -0
  37. package/dist/rpc/client.js +40 -0
  38. package/dist/rpc/codec/lpm.d.ts +20 -0
  39. package/dist/rpc/codec/lpm.js +36 -0
  40. package/dist/rpc/crypto/aes.d.ts +22 -0
  41. package/dist/rpc/crypto/aes.js +47 -0
  42. package/dist/rpc/crypto/kyber.d.ts +27 -0
  43. package/dist/rpc/crypto/kyber.js +70 -0
  44. package/dist/rpc/proto.d.ts +2 -0
  45. package/dist/rpc/proto.js +33 -0
  46. package/dist/rpc/server.d.ts +13 -0
  47. package/dist/rpc/server.js +50 -0
  48. package/dist/rpc/tls.d.ts +26 -0
  49. package/dist/rpc/tls.js +54 -0
  50. package/dist/rpc/types.d.ts +28 -0
  51. package/dist/rpc/types.js +5 -0
  52. package/dist/sandbox/guardian.d.ts +18 -0
  53. package/dist/sandbox/guardian.js +35 -0
  54. package/dist/sandbox/wasi.d.ts +36 -0
  55. package/dist/sandbox/wasi.js +179 -0
  56. package/dist/security/guardian.d.ts +22 -0
  57. package/dist/security/guardian.js +52 -0
  58. package/dist/security/zk.d.ts +37 -0
  59. package/dist/security/zk.js +66 -0
  60. package/dist/server/index.d.ts +184 -0
  61. package/dist/server/index.js +933 -0
  62. package/dist/server/pii.d.ts +40 -0
  63. package/dist/server/pii.js +266 -0
  64. package/dist/types.d.ts +145 -0
  65. package/dist/types.js +26 -0
  66. package/dist/utils/logger.d.ts +21 -0
  67. package/dist/utils/logger.js +70 -0
  68. package/dist/utils/mcpCompact.d.ts +11 -0
  69. package/dist/utils/mcpCompact.js +29 -0
  70. package/dist/workers/logic-execution.d.ts +17 -0
  71. package/dist/workers/logic-execution.js +121 -0
  72. package/dist/workers/zk-verifier.d.ts +20 -0
  73. package/dist/workers/zk-verifier.js +84 -0
  74. package/package.json +147 -0
@@ -0,0 +1,11 @@
1
+ export * from "./bridge/index.js";
2
+ export * from "./client/index.js";
3
+ export * from "./economy/index.js";
4
+ export * from "./gateway/hybrid.js";
5
+ export * from "./mesh/node.js";
6
+ export * from "./prompts/adapters.js";
7
+ export * from "./rpc/client.js";
8
+ export * from "./rpc/server.js";
9
+ export * from "./sandbox/wasi.js";
10
+ export * from "./server/index.js";
11
+ export * from "./types.js";
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ export * from "./bridge/index.js";
2
+ export * from "./client/index.js";
3
+ export * from "./economy/index.js";
4
+ export * from "./gateway/hybrid.js";
5
+ export * from "./mesh/node.js";
6
+ export * from "./prompts/adapters.js";
7
+ export * from "./rpc/client.js";
8
+ export * from "./rpc/server.js";
9
+ export * from "./sandbox/wasi.js";
10
+ export * from "./server/index.js";
11
+ export * from "./types.js";
@@ -0,0 +1 @@
1
+ export * from "./node.js";
@@ -0,0 +1 @@
1
+ export * from "./node.js";
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Manifest describing a node's capabilities in the LIOP Mesh.
3
+ * Exchanged via the /liop/manifest/1.0.0 protocol stream.
4
+ */
5
+ export interface LiopManifest {
6
+ peerId: string;
7
+ grpcPort: number;
8
+ tools: Array<{
9
+ name: string;
10
+ description?: string;
11
+ inputSchema?: Record<string, unknown>;
12
+ }>;
13
+ resources: Array<{
14
+ name: string;
15
+ uri: string;
16
+ description?: string;
17
+ mimeType?: string;
18
+ text?: string;
19
+ }>;
20
+ serverInfo: {
21
+ name: string;
22
+ version: string;
23
+ };
24
+ taxonomy?: {
25
+ domain: string;
26
+ clearanceTier: number;
27
+ executionTypes: string[];
28
+ };
29
+ }
30
+ export interface MeshNodeConfig {
31
+ listenAddresses?: string[];
32
+ bootstrapNodes?: string[];
33
+ identityPath?: string;
34
+ enableWAN?: boolean;
35
+ dhtStoragePath?: string;
36
+ /** Optional function to translate multiaddrs (e.g. for Docker NAT traversal). Return null to drop an address. */
37
+ addressMapper?: (addr: string) => string | null;
38
+ }
39
+ /**
40
+ * P2P Mesh Node backed by libp2p + Kademlia DHT.
41
+ *
42
+ * Provides capability advertisement via CID-based content routing
43
+ * and decentralized peer discovery.
44
+ */
45
+ export declare class MeshNode {
46
+ private node;
47
+ private config;
48
+ private manifestDialFailureState;
49
+ private static readonly MANIFEST_DIAL_BASE_COOLDOWN_MS;
50
+ private static readonly MANIFEST_DIAL_MAX_COOLDOWN_MS;
51
+ private static readonly MANIFEST_DIAL_SKIP_LOG_THROTTLE_MS;
52
+ /**
53
+ * Buffer of capability hashes that have been announced.
54
+ * Used to re-announce capabilities when new peers connect
55
+ * (critical for small / isolated clusters where the initial
56
+ * provide() finds zero peers in the routing table).
57
+ */
58
+ private announcedCapabilities;
59
+ /** Guards against concurrent re-announcement storms. */
60
+ private reannouncing;
61
+ /** Callback that returns the local node's manifest on request. */
62
+ private manifestProvider;
63
+ /** Flag to ensure the manifest protocol is only registered once. */
64
+ private manifestProtocolRegistered;
65
+ /** Local Ed25519 Private Key for protocol signatures */
66
+ private localPrivateKey;
67
+ constructor(config?: MeshNodeConfig);
68
+ private shouldSkipManifestDial;
69
+ private recordManifestDialFailure;
70
+ private clearManifestDialFailure;
71
+ /**
72
+ * Loads a persistent identity from disk or generates a new Ed25519 keypair.
73
+ * Uses privateKeyToProtobuf/privateKeyFromProtobuf (libp2p v3.x official API).
74
+ */
75
+ private loadOrCreateIdentity;
76
+ /**
77
+ * Persists the private key to disk using protobuf serialization (libp2p v3.x).
78
+ */
79
+ private saveIdentity;
80
+ /**
81
+ * Creates a CID v1 (raw codec 0x55) from a SHA-256 hash of the capability string.
82
+ * Required by @libp2p/kad-dht v16+ for provide/findProviders.
83
+ */
84
+ private capabilityToCID;
85
+ /**
86
+ * Re-announces all buffered capabilities after a new peer connects.
87
+ * Uses a small delay to allow the DHT protocol handshake to complete.
88
+ */
89
+ private reannounceAll;
90
+ start(): Promise<void>;
91
+ stop(): Promise<void>;
92
+ private loadRoutingTable;
93
+ private saveRoutingTable;
94
+ /**
95
+ * Internal logic to register protocol handlers against the libp2p node.
96
+ * Can be called multiple times; handles idempotent registration.
97
+ */
98
+ private applyHandlers;
99
+ /**
100
+ * Registers a callback as the manifest provider.
101
+ * Will be applied immediately if the node is already initialized.
102
+ */
103
+ registerManifestHandler(provider: () => LiopManifest): void;
104
+ /**
105
+ * Queries a remote peer's manifest by opening a /liop/manifest/1.0.0 stream.
106
+ * Returns null if the peer doesn't support the protocol or is unreachable.
107
+ */
108
+ queryManifest(peerIdStr: string): Promise<LiopManifest | null>;
109
+ /**
110
+ * Discovers all peers in the DHT that have announced "liop:manifest".
111
+ * Returns their PeerIDs for subsequent manifest queries.
112
+ */
113
+ discoverManifestProviders(): Promise<string[]>;
114
+ /**
115
+ * Announces this node as a manifest provider in the DHT.
116
+ * Should be called after tools/resources have been registered.
117
+ */
118
+ announceManifest(): Promise<void>;
119
+ /**
120
+ * Returns the current size of the routing table for diagnostic purposes.
121
+ */
122
+ getRoutingTableSize(): number;
123
+ getPeerId(): string;
124
+ sign(data: Uint8Array): Promise<Uint8Array>;
125
+ getMultiaddrs(): string[];
126
+ announceCapability(hash: string): Promise<void>;
127
+ findProviders(hash: string): Promise<string[]>;
128
+ resolvePeer(peerIdStr: string): Promise<string[]>;
129
+ }