@synapsor/client 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,8 @@
1
- # Synapsor Node.js Adapter
1
+ # Synapsor Node.js SDK
2
2
 
3
- The Node.js adapter is a thin ESM client over `synapsor_server` HTTP/JSON APIs.
4
- It keeps Synapsor semantics in C++ and exposes a compact JavaScript API.
3
+ The Synapsor Node.js SDK connects applications to hosted or local Synapsor
4
+ databases. Use it for SQL, branch workflows, agent contexts, capabilities,
5
+ evidence, memory, and safe write proposals from Node.js applications.
5
6
 
6
7
  ## Local Usage
7
8
 
@@ -35,7 +36,7 @@ await db.close();
35
36
 
36
37
  ## Hosted Usage
37
38
 
38
- Install from npm after the package is published:
39
+ Install from npm:
39
40
 
40
41
  ```bash
41
42
  npm install @synapsor/client
@@ -59,14 +60,12 @@ const ctx = await db.invokeAgentCapability("chat.prepare_llm_context", { questio
59
60
  ```
60
61
 
61
62
  Use database-scoped API keys from the Synapsor control panel for hosted projects.
62
- The cloud gateway pins those keys to the database runtime branch before forwarding
63
- requests to the single-node runtime.
64
63
 
65
64
  ## API Surface
66
65
 
67
66
  - `execute(sql)` and `query(sql)`
68
67
  - `setSession({...})`
69
- - `invokeAgentCapability(name, args)`
68
+ - `invokeAgentCapability(name, args, options)`
70
69
  - `listCapabilities(query)`
71
70
  - `rememberFact({...})`
72
71
  - `proposeMemoryFact({...})`
@@ -77,7 +76,7 @@ requests to the single-node runtime.
77
76
  - `retireFact(id, {...})` and `forgetFact(id, reason)`
78
77
  - `checkFactForAction({...})`
79
78
  - branch helpers: `createBranch`, `useBranch`, `diffBranch`, `mergeBranch`, `dropBranch`
80
- - write lifecycle helpers: `previewWrite`, `approveWrite`, `commitWrite`, `rejectWrite`
79
+ - write lifecycle helpers: `previewWrite`, `approveWrite`, `commitWrite`, `rejectWrite`, `settleWrite`
81
80
  - `readResource(uri)`
82
81
 
83
82
  Errors from Synapsor become `SynapsorError` with `status` and `payload`.
@@ -1,6 +1,6 @@
1
1
  // Generated by tools/generate_openapi_sdk_contract.py. Do not edit by hand.
2
2
  export const PROTOCOL_VERSION = "v1";
3
- export const CONTRACT_SHA256 = "f738189b0873fe48c5900cbffafb7d4eed90acbe9fc8c7cfcd4db89ad78f106a";
3
+ export const CONTRACT_SHA256 = "af3ae249f90c9d7dd7d424890c8a9d37e1c6c8c024cd83341f882c5bac8c389d";
4
4
  export const OPENAPI_OPERATIONS = Object.freeze({
5
5
  "approveAgentProposal": {
6
6
  "method": "POST",
@@ -209,6 +209,14 @@ export const OPENAPI_OPERATIONS = Object.freeze({
209
209
  "public": false,
210
210
  "python_method": "run_hybrid_reembed_jobs",
211
211
  "request_schema": "#/components/schemas/HybridReembedRunRequest"
212
+ },
213
+ "settleAgentProposal": {
214
+ "method": "POST",
215
+ "node_method": "settleWrite",
216
+ "path": "/v1/agent/proposals/settle",
217
+ "public": false,
218
+ "python_method": "settle_write",
219
+ "request_schema": "#/components/schemas/ProposalLifecycleRequest"
212
220
  }
213
221
  });
214
222
  export const PYTHON_OPERATION_METHODS = Object.freeze({
@@ -237,7 +245,8 @@ export const PYTHON_OPERATION_METHODS = Object.freeze({
237
245
  "previewAgentProposal": "preview_write",
238
246
  "rejectAgentProposal": "reject_write",
239
247
  "resumeHybridReembedJob": "resume_hybrid_reembed_job",
240
- "runHybridReembedJobs": "run_hybrid_reembed_jobs"
248
+ "runHybridReembedJobs": "run_hybrid_reembed_jobs",
249
+ "settleAgentProposal": "settle_write"
241
250
  });
242
251
  export const NODE_OPERATION_METHODS = Object.freeze({
243
252
  "approveAgentProposal": "approveWrite",
@@ -265,7 +274,8 @@ export const NODE_OPERATION_METHODS = Object.freeze({
265
274
  "previewAgentProposal": "previewWrite",
266
275
  "rejectAgentProposal": "rejectWrite",
267
276
  "resumeHybridReembedJob": "resumeHybridReembedJob",
268
- "runHybridReembedJobs": "runHybridReembedJobs"
277
+ "runHybridReembedJobs": "runHybridReembedJobs",
278
+ "settleAgentProposal": "settleWrite"
269
279
  });
270
280
  export const PUBLIC_OPERATIONS = Object.freeze([
271
281
  "getHealth",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@synapsor/client",
3
- "version": "0.1.0",
4
- "description": "Node.js client for Synapsor HTTP/JSON APIs",
3
+ "version": "0.1.1",
4
+ "description": "Node.js SDK for Synapsor, the agent-native database for auditable AI applications",
5
5
  "type": "module",
6
6
  "main": "./synapsor.mjs",
7
7
  "exports": {
package/synapsor.mjs CHANGED
@@ -236,14 +236,47 @@ export class Synapsor {
236
236
  return results.at(-1).result?.rows ?? [];
237
237
  }
238
238
 
239
- async invokeAgentCapability(capability, args = {}, { session = undefined, traceId = undefined } = {}) {
239
+ async invokeAgentCapability(capability, args = {}, {
240
+ session = undefined,
241
+ traceId = undefined,
242
+ trace_id = undefined,
243
+ mode = undefined,
244
+ autoBranch = undefined,
245
+ auto_branch = undefined,
246
+ responseEnvelope = undefined,
247
+ response_envelope = undefined,
248
+ includeAuditTrail = undefined,
249
+ include_audit_trail = undefined,
250
+ settlementPolicy = undefined,
251
+ settlement_policy = undefined,
252
+ } = {}) {
240
253
  const payload = {
241
254
  capability,
242
255
  arguments: args,
243
256
  session: this.requireSession(session),
244
257
  };
245
- if (traceId !== undefined) {
246
- payload.trace_id = traceId;
258
+ const trace = traceId ?? trace_id;
259
+ const branch = autoBranch ?? auto_branch;
260
+ const envelope = responseEnvelope ?? response_envelope;
261
+ const audit = includeAuditTrail ?? include_audit_trail;
262
+ const policy = settlementPolicy ?? settlement_policy;
263
+ if (trace !== undefined) {
264
+ payload.trace_id = trace;
265
+ }
266
+ if (mode !== undefined) {
267
+ payload.mode = mode;
268
+ }
269
+ if (branch !== undefined) {
270
+ payload.auto_branch = Boolean(branch);
271
+ }
272
+ if (envelope !== undefined) {
273
+ payload.response_envelope = Boolean(envelope);
274
+ }
275
+ if (audit !== undefined) {
276
+ payload.include_audit_trail = Boolean(audit);
277
+ }
278
+ if (policy !== undefined) {
279
+ payload.settlement_policy = policy;
247
280
  }
248
281
  return this.request("POST", "/v1/agent/invoke", payload);
249
282
  }
@@ -414,6 +447,13 @@ export class Synapsor {
414
447
  return this.proposalLifecycle("cancel", proposal, options);
415
448
  }
416
449
 
450
+ async settleWrite(proposal, settlementPolicy, options = {}) {
451
+ return this.proposalLifecycle("settle", proposal, {
452
+ ...options,
453
+ settlementPolicy,
454
+ });
455
+ }
456
+
417
457
  async replayAgentRun(runId, options = {}) {
418
458
  return this.request("POST", "/v1/agent/runs/replay", {
419
459
  run_id: Number(runId),
@@ -422,19 +462,23 @@ export class Synapsor {
422
462
  });
423
463
  }
424
464
 
425
- async proposalLifecycle(action, proposal, { session = undefined, promoteBranch = undefined, promote_branch = undefined, targetBranch = undefined, target_branch = undefined } = {}) {
465
+ async proposalLifecycle(action, proposal, { session = undefined, promoteBranch = undefined, promote_branch = undefined, targetBranch = undefined, target_branch = undefined, settlementPolicy = undefined, settlement_policy = undefined } = {}) {
426
466
  const payload = {
427
467
  proposal,
428
468
  session: this.requireSession(session),
429
469
  };
430
470
  const shouldPromote = promoteBranch ?? promote_branch;
431
471
  const target = targetBranch ?? target_branch;
472
+ const policy = settlementPolicy ?? settlement_policy;
432
473
  if (shouldPromote !== undefined) {
433
474
  payload.promote_branch = Boolean(shouldPromote);
434
475
  }
435
476
  if (target !== undefined) {
436
477
  payload.target_branch = target;
437
478
  }
479
+ if (policy !== undefined) {
480
+ payload.settlement_policy = policy;
481
+ }
438
482
  return this.request("POST", `/v1/agent/proposals/${action}`, payload);
439
483
  }
440
484