clinch-core 0.5.0 → 0.6.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/README.md +16 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ npm install node-llama-cpp
|
|
|
40
40
|
|
|
41
41
|
### Core Statuses (`CoreStatus`)
|
|
42
42
|
* `OFFLINE`: Client is disconnected.
|
|
43
|
-
* `CONNECTING`: Resolving registry
|
|
43
|
+
* `CONNECTING`: Resolving registry configuration and performing Proof-of-Work auth.
|
|
44
44
|
* `IDLE`: Connected and authenticated. Waiting for handshakes or callbacks.
|
|
45
45
|
* `RECONNECTING`: Socket connection lost; executing exponential backoff.
|
|
46
46
|
* `NEGOTIATING`: Active turn-based negotiation sequence in progress.
|
|
@@ -86,6 +86,7 @@ async function startLocalAgent() {
|
|
|
86
86
|
await core.sandbox({ downloadLLM: true });
|
|
87
87
|
|
|
88
88
|
// 2. Initiate Negotiation: Session automatically transitions to 'NEGOTIATING'
|
|
89
|
+
// Format: PROTOCOL_MODE.domain.anp (e.g., ANP/C.amazon.anp)
|
|
89
90
|
const sessionId = await core.negotiate('ANP/C.amazon.anp', {
|
|
90
91
|
intent: 'purchase',
|
|
91
92
|
category: 'electronics',
|
|
@@ -147,6 +148,7 @@ webhookCore.on('callback_received', async (event) => {
|
|
|
147
148
|
console.log("Deal reached!");
|
|
148
149
|
} else {
|
|
149
150
|
await webhookCore.sendCounter(event.sessionId, aiDecision.price, aiDecision.message);
|
|
151
|
+
// Reserialize and update DB after turn to maintain state sync
|
|
150
152
|
await db.update(event.sessionId, webhookCore.exportSessionState(event.sessionId));
|
|
151
153
|
}
|
|
152
154
|
});
|
|
@@ -168,7 +170,10 @@ const app = express();
|
|
|
168
170
|
app.use(express.json());
|
|
169
171
|
|
|
170
172
|
// Initialize with your permanent Dashboard-generated Private Key
|
|
171
|
-
const seller = new ClinchSeller({
|
|
173
|
+
const seller = new ClinchSeller({
|
|
174
|
+
privateKeyHex: process.env.SELLER_PRIVATE_KEY
|
|
175
|
+
// registryUrl: 'http://localhost:7860' // Optional: Override for local dev
|
|
176
|
+
});
|
|
172
177
|
|
|
173
178
|
// Publish your routing endpoint to the network on boot
|
|
174
179
|
await seller.registerEndpoint({
|
|
@@ -206,19 +211,20 @@ app.listen(8080);
|
|
|
206
211
|
### Buyer Client (`ClinchCore`)
|
|
207
212
|
|
|
208
213
|
#### `new ClinchCore(config)`
|
|
209
|
-
* `config.registryUrl` *(string)*: Override
|
|
214
|
+
* `config.registryUrl` *(string)*: Override default dynamic configuration resolution for local testing.
|
|
210
215
|
* `config.timeoutMs` *(number)*: Connection timeout limit (Default: `5000`ms).
|
|
211
216
|
|
|
212
217
|
#### `async initialize(cachedToken?)`
|
|
213
|
-
Authenticates the node, completes Identity-Bound PoW, and connects the WebSocket.
|
|
218
|
+
Authenticates the node on the network, completes Identity-Bound PoW, and connects the WebSocket.
|
|
219
|
+
* `cachedToken` *(string)*: Optional. Re-use an existing network token to bypass PoW calculations on restart.
|
|
214
220
|
|
|
215
221
|
#### `async negotiate(address, constraints)`
|
|
216
222
|
Launches a cryptographic session handshake. Returns `sessionId`.
|
|
217
|
-
* `address` *(string)*: e.g
|
|
218
|
-
* `constraints` *(ConstraintVector)*: Must include `max_budget` (number).
|
|
223
|
+
* `address` *(string)*: Target seller address. Must include the protocol mode prefix (e.g., `ANP/C.amazon.anp`).
|
|
224
|
+
* `constraints` *(ConstraintVector)*: Must include `max_budget` (number) and `item` (string).
|
|
219
225
|
|
|
220
226
|
#### `exportSessionState(sessionId)` / `importSessionState(serializedData)`
|
|
221
|
-
Serializes the active session—including the ephemeral cryptographic keys, current turn, and LLM context parameters—to a JSON string. Used to scale instances horizontally
|
|
227
|
+
Serializes the active session—including the ephemeral cryptographic keys, current turn, and LLM context parameters—to a JSON string. Used to scale instances horizontally, survive pod restarts, or pick up negotiations across async callback windows.
|
|
222
228
|
|
|
223
229
|
#### `buildAgentPrompt(sessionId, incomingMessage)`
|
|
224
230
|
Returns a highly-optimized, state-aware string to pass to an external LLM as a System Prompt. Ensures the LLM outputs strict JSON matching the protocol rules.
|
|
@@ -232,10 +238,13 @@ Closes the active connection and generates a single-use re-engagement Callback t
|
|
|
232
238
|
#### `async sandbox(config)`
|
|
233
239
|
Initializes the edge-AI execution context, downloads the GGUF, and auto-listens.
|
|
234
240
|
|
|
241
|
+
---
|
|
242
|
+
|
|
235
243
|
### Seller Client (`ClinchSeller`)
|
|
236
244
|
|
|
237
245
|
#### `new ClinchSeller(config)`
|
|
238
246
|
* `config.privateKeyHex` *(string)*: The Ed25519 private key generated from the Clinch Dashboard. Used to cryptographically authenticate endpoint updates.
|
|
247
|
+
* `config.registryUrl` *(string)*: Optional. Overrides Registry configuration resolution for local testing.
|
|
239
248
|
|
|
240
249
|
#### `async registerEndpoint(record)`
|
|
241
250
|
Publishes the seller's DNS-style record to the Registry so buyers can discover and route to it. Signed locally via the Ed25519 identity key.
|