@synapsor/client 0.1.1 → 0.1.3
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 +107 -2
- package/bin/synapsor.mjs +442 -0
- package/external-db-writeback.mjs +266 -0
- package/generated-contract.mjs +251 -1
- package/package.json +11 -4
- package/synapsor.mjs +815 -5
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
function quoteIdentifier(kind, identifier) {
|
|
2
|
+
const text = String(identifier || "");
|
|
3
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(text)) {
|
|
4
|
+
throw new Error(`UNSAFE_IDENTIFIER: ${text}`);
|
|
5
|
+
}
|
|
6
|
+
return kind === "mysql" ? `\`${text}\`` : `"${text}"`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function placeholder(kind, index) {
|
|
10
|
+
return kind === "mysql" ? "?" : `$${index}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function assertAllowedColumns(proposal, columns, label) {
|
|
14
|
+
const allowed = new Set((proposal.allowed_columns || []).map(String));
|
|
15
|
+
const blocked = columns.filter((column) => !allowed.has(String(column)));
|
|
16
|
+
if (blocked.length) {
|
|
17
|
+
throw new Error(`WRITEBACK_COLUMN_NOT_ALLOWED: ${label} ${blocked.join(",")}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function buildExternalWritebackSql(proposal, { kind = undefined } = {}) {
|
|
22
|
+
const sourceKind = kind || proposal.source_kind || "postgres";
|
|
23
|
+
if (!["postgres", "mysql"].includes(sourceKind)) {
|
|
24
|
+
throw new Error(`UNSUPPORTED_WRITEBACK_KIND: ${sourceKind}`);
|
|
25
|
+
}
|
|
26
|
+
const operation = String(proposal.operation || "update").toLowerCase();
|
|
27
|
+
if (!["update", "insert", "delete"].includes(operation)) {
|
|
28
|
+
throw new Error(`UNSUPPORTED_WRITEBACK_OPERATION: ${operation}`);
|
|
29
|
+
}
|
|
30
|
+
const schema = String(proposal.external_schema || proposal.external_catalog || "");
|
|
31
|
+
const table = String(proposal.external_table || "");
|
|
32
|
+
if (!schema || !table) {
|
|
33
|
+
throw new Error("WRITEBACK_TABLE_REQUIRED: proposal must include external_schema and external_table");
|
|
34
|
+
}
|
|
35
|
+
const tableRef = `${quoteIdentifier(sourceKind, schema)}.${quoteIdentifier(sourceKind, table)}`;
|
|
36
|
+
const changes = proposal.changes && typeof proposal.changes === "object" ? proposal.changes : {};
|
|
37
|
+
const primaryKey = proposal.primary_key && typeof proposal.primary_key === "object" ? proposal.primary_key : {};
|
|
38
|
+
const conflict = proposal.conflict && typeof proposal.conflict === "object" ? proposal.conflict : {};
|
|
39
|
+
const tenantColumn = proposal.tenant_column ? String(proposal.tenant_column) : "";
|
|
40
|
+
const tenantId = proposal.tenant_id;
|
|
41
|
+
const conflictColumn = proposal.conflict_column ? String(proposal.conflict_column) : "";
|
|
42
|
+
const params = [];
|
|
43
|
+
const where = [];
|
|
44
|
+
|
|
45
|
+
function pushParam(value) {
|
|
46
|
+
params.push(value);
|
|
47
|
+
return placeholder(sourceKind, params.length);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function appendWhereClauses() {
|
|
51
|
+
for (const column of pkColumns) {
|
|
52
|
+
where.push(`${quoteIdentifier(sourceKind, column)} = ${pushParam(primaryKey[column])}`);
|
|
53
|
+
}
|
|
54
|
+
if (tenantColumn) {
|
|
55
|
+
assertAllowedColumns(proposal, [tenantColumn], "tenant");
|
|
56
|
+
where.push(`${quoteIdentifier(sourceKind, tenantColumn)} = ${pushParam(tenantId)}`);
|
|
57
|
+
}
|
|
58
|
+
if (conflictColumn && Object.prototype.hasOwnProperty.call(conflict, conflictColumn)) {
|
|
59
|
+
assertAllowedColumns(proposal, [conflictColumn], "conflict");
|
|
60
|
+
where.push(`${quoteIdentifier(sourceKind, conflictColumn)} = ${pushParam(conflict[conflictColumn])}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (operation === "insert") {
|
|
65
|
+
const insertColumns = Object.keys(changes);
|
|
66
|
+
if (tenantColumn && !insertColumns.includes(tenantColumn)) {
|
|
67
|
+
insertColumns.push(tenantColumn);
|
|
68
|
+
changes[tenantColumn] = tenantId;
|
|
69
|
+
}
|
|
70
|
+
if (!insertColumns.length) {
|
|
71
|
+
throw new Error("WRITEBACK_INSERT_VALUES_REQUIRED");
|
|
72
|
+
}
|
|
73
|
+
assertAllowedColumns(proposal, insertColumns, "insert");
|
|
74
|
+
const columnSql = insertColumns.map((column) => quoteIdentifier(sourceKind, column)).join(", ");
|
|
75
|
+
const valueSql = insertColumns.map((column) => pushParam(changes[column])).join(", ");
|
|
76
|
+
return {
|
|
77
|
+
sql: `INSERT INTO ${tableRef} (${columnSql}) VALUES (${valueSql})`,
|
|
78
|
+
params,
|
|
79
|
+
operation,
|
|
80
|
+
expectedRowCount: 1,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const pkColumns = Object.keys(primaryKey);
|
|
85
|
+
if (!pkColumns.length) {
|
|
86
|
+
throw new Error("WRITEBACK_PRIMARY_KEY_REQUIRED");
|
|
87
|
+
}
|
|
88
|
+
assertAllowedColumns(proposal, pkColumns, "primary_key");
|
|
89
|
+
|
|
90
|
+
if (operation === "delete") {
|
|
91
|
+
appendWhereClauses();
|
|
92
|
+
return {
|
|
93
|
+
sql: `DELETE FROM ${tableRef} WHERE ${where.join(" AND ")}`,
|
|
94
|
+
params,
|
|
95
|
+
operation,
|
|
96
|
+
expectedRowCount: 1,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const changeColumns = Object.keys(changes);
|
|
101
|
+
if (!changeColumns.length) {
|
|
102
|
+
throw new Error("WRITEBACK_UPDATE_VALUES_REQUIRED");
|
|
103
|
+
}
|
|
104
|
+
assertAllowedColumns(proposal, changeColumns, "update");
|
|
105
|
+
const protectedColumns = new Set([...pkColumns, tenantColumn, conflictColumn].filter(Boolean));
|
|
106
|
+
const protectedChanges = changeColumns.filter((column) => protectedColumns.has(column));
|
|
107
|
+
if (protectedChanges.length) {
|
|
108
|
+
throw new Error(`WRITEBACK_PROTECTED_COLUMN_CHANGE: ${protectedChanges.join(",")}`);
|
|
109
|
+
}
|
|
110
|
+
const setSql = changeColumns
|
|
111
|
+
.map((column) => `${quoteIdentifier(sourceKind, column)} = ${pushParam(changes[column])}`)
|
|
112
|
+
.join(", ");
|
|
113
|
+
appendWhereClauses();
|
|
114
|
+
return {
|
|
115
|
+
sql: `UPDATE ${tableRef} SET ${setSql} WHERE ${where.join(" AND ")}`,
|
|
116
|
+
params,
|
|
117
|
+
operation,
|
|
118
|
+
expectedRowCount: 1,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async function request({ baseUrl, apiKey, fetchImpl }, method, path, body) {
|
|
123
|
+
const response = await fetchImpl(`${baseUrl.replace(/\/+$/, "")}${path}`, {
|
|
124
|
+
method,
|
|
125
|
+
headers: {
|
|
126
|
+
accept: "application/json",
|
|
127
|
+
authorization: `Bearer ${apiKey}`,
|
|
128
|
+
...(body === undefined ? {} : { "content-type": "application/json" }),
|
|
129
|
+
},
|
|
130
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
131
|
+
});
|
|
132
|
+
const text = await response.text();
|
|
133
|
+
let payload = {};
|
|
134
|
+
if (text.trim()) {
|
|
135
|
+
payload = JSON.parse(text);
|
|
136
|
+
}
|
|
137
|
+
if (!response.ok || payload.ok === false) {
|
|
138
|
+
const error = new Error(payload.message || payload.error || `HTTP ${response.status}`);
|
|
139
|
+
error.payload = payload;
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
return payload;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function rowCountFromResult(result) {
|
|
146
|
+
if (typeof result === "number") return result;
|
|
147
|
+
if (!result || typeof result !== "object") return 0;
|
|
148
|
+
return Number(result.rowCount ?? result.affectedRows ?? result.rowsAffected ?? 0);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function executeWithDb(db, built, proposal, kind) {
|
|
152
|
+
if (!db) {
|
|
153
|
+
throw new Error("WRITEBACK_EXECUTOR_REQUIRED: pass execute({sql, params}) or db client");
|
|
154
|
+
}
|
|
155
|
+
if (typeof db === "function") {
|
|
156
|
+
return db({ ...built, proposal, kind });
|
|
157
|
+
}
|
|
158
|
+
if (typeof db.execute === "function") {
|
|
159
|
+
return db.execute(built.sql, built.params);
|
|
160
|
+
}
|
|
161
|
+
if (typeof db.query === "function") {
|
|
162
|
+
return db.query(built.sql, built.params);
|
|
163
|
+
}
|
|
164
|
+
throw new Error("WRITEBACK_EXECUTOR_REQUIRED: db must expose execute() or query()");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function createExternalDbWritebackWorker(options = {}) {
|
|
168
|
+
const {
|
|
169
|
+
baseUrl = "https://synapsor.ai",
|
|
170
|
+
synapsorApiKey = process.env.SYNAPSOR_API_KEY,
|
|
171
|
+
sourceId = "",
|
|
172
|
+
sourceName = "",
|
|
173
|
+
projectId = "",
|
|
174
|
+
kind = undefined,
|
|
175
|
+
db = undefined,
|
|
176
|
+
execute = undefined,
|
|
177
|
+
fetchImpl = globalThis.fetch,
|
|
178
|
+
pollIntervalMs = 5000,
|
|
179
|
+
dryRun = false,
|
|
180
|
+
} = options;
|
|
181
|
+
if (!synapsorApiKey) {
|
|
182
|
+
throw new Error("SYNAPSOR_API_KEY_REQUIRED");
|
|
183
|
+
}
|
|
184
|
+
if (!fetchImpl) {
|
|
185
|
+
throw new Error("FETCH_REQUIRED");
|
|
186
|
+
}
|
|
187
|
+
let stopped = false;
|
|
188
|
+
let timer = null;
|
|
189
|
+
const client = { baseUrl, apiKey: synapsorApiKey, fetchImpl };
|
|
190
|
+
|
|
191
|
+
async function resolveSourceId() {
|
|
192
|
+
if (sourceId) return sourceId;
|
|
193
|
+
if (!sourceName) return "";
|
|
194
|
+
const query = projectId ? `?project_id=${encodeURIComponent(projectId)}` : "";
|
|
195
|
+
const listed = await request(client, "GET", `/v1/control/external-sources${query}`);
|
|
196
|
+
const match = (listed.sources || []).find((source) => source.name === sourceName || source.source_id === sourceName);
|
|
197
|
+
if (!match) throw new Error(`SOURCE_NOT_FOUND: ${sourceName}`);
|
|
198
|
+
return match.source_id;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
async function pollOnce() {
|
|
202
|
+
const resolvedSourceId = await resolveSourceId();
|
|
203
|
+
const params = new URLSearchParams();
|
|
204
|
+
if (resolvedSourceId) params.set("source_id", resolvedSourceId);
|
|
205
|
+
if (projectId) params.set("project_id", projectId);
|
|
206
|
+
params.set("status", "approved");
|
|
207
|
+
const listed = await request(client, "GET", `/v1/control/external-writebacks/proposals?${params.toString()}`);
|
|
208
|
+
const results = [];
|
|
209
|
+
for (const proposal of listed.proposals || []) {
|
|
210
|
+
const built = buildExternalWritebackSql(proposal, { kind: kind || proposal.source_kind });
|
|
211
|
+
if (dryRun) {
|
|
212
|
+
results.push({ proposal_id: proposal.proposal_id, dryRun: true, ...built });
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
const rawResult = await executeWithDb(execute || db, built, proposal, kind || proposal.source_kind);
|
|
217
|
+
const affectedRows = rowCountFromResult(rawResult);
|
|
218
|
+
const status = affectedRows === built.expectedRowCount ? "applied" : "conflict";
|
|
219
|
+
const reported = await request(
|
|
220
|
+
client,
|
|
221
|
+
"POST",
|
|
222
|
+
`/v1/control/external-writebacks/proposals/${encodeURIComponent(proposal.proposal_id)}/apply-result`,
|
|
223
|
+
{
|
|
224
|
+
status,
|
|
225
|
+
idempotency_key: proposal.idempotency_key,
|
|
226
|
+
external_commit_metadata: {
|
|
227
|
+
affected_rows: String(affectedRows),
|
|
228
|
+
operation: built.operation,
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
);
|
|
232
|
+
results.push({ proposal_id: proposal.proposal_id, status, affectedRows, reported });
|
|
233
|
+
} catch (error) {
|
|
234
|
+
await request(
|
|
235
|
+
client,
|
|
236
|
+
"POST",
|
|
237
|
+
`/v1/control/external-writebacks/proposals/${encodeURIComponent(proposal.proposal_id)}/apply-result`,
|
|
238
|
+
{
|
|
239
|
+
status: "failed",
|
|
240
|
+
idempotency_key: proposal.idempotency_key,
|
|
241
|
+
error: error.message || String(error),
|
|
242
|
+
},
|
|
243
|
+
);
|
|
244
|
+
results.push({ proposal_id: proposal.proposal_id, status: "failed", error: error.message || String(error) });
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return { ok: true, count: results.length, results };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async function start() {
|
|
251
|
+
stopped = false;
|
|
252
|
+
while (!stopped) {
|
|
253
|
+
await pollOnce();
|
|
254
|
+
await new Promise((resolve) => {
|
|
255
|
+
timer = setTimeout(resolve, pollIntervalMs);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function stop() {
|
|
261
|
+
stopped = true;
|
|
262
|
+
if (timer) clearTimeout(timer);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return { pollOnce, start, stop };
|
|
266
|
+
}
|
package/generated-contract.mjs
CHANGED
|
@@ -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 = "
|
|
3
|
+
export const CONTRACT_SHA256 = "482f2e07b65471b6709045fd3be3c14d678671c22a2f9cefa8e9d5b7e2551cbb";
|
|
4
4
|
export const OPENAPI_OPERATIONS = Object.freeze({
|
|
5
5
|
"approveAgentProposal": {
|
|
6
6
|
"method": "POST",
|
|
@@ -26,6 +26,14 @@ export const OPENAPI_OPERATIONS = Object.freeze({
|
|
|
26
26
|
"python_method": "cancel_hybrid_reembed_job",
|
|
27
27
|
"request_schema": "#/components/schemas/HybridReembedJobActionRequest"
|
|
28
28
|
},
|
|
29
|
+
"clearAdminTenantBudget": {
|
|
30
|
+
"method": "POST",
|
|
31
|
+
"node_method": "clearAdminTenantBudget",
|
|
32
|
+
"path": "/v1/admin/tenant-budgets/clear",
|
|
33
|
+
"public": false,
|
|
34
|
+
"python_method": "clear_admin_tenant_budget",
|
|
35
|
+
"request_schema": null
|
|
36
|
+
},
|
|
29
37
|
"commitAgentProposal": {
|
|
30
38
|
"method": "POST",
|
|
31
39
|
"node_method": "commitWrite",
|
|
@@ -122,6 +130,30 @@ export const OPENAPI_OPERATIONS = Object.freeze({
|
|
|
122
130
|
"python_method": "shutdown",
|
|
123
131
|
"request_schema": null
|
|
124
132
|
},
|
|
133
|
+
"postAgentAdapter": {
|
|
134
|
+
"method": "POST",
|
|
135
|
+
"node_method": "createAgentAdapter",
|
|
136
|
+
"path": "/v1/agent/adapters",
|
|
137
|
+
"public": false,
|
|
138
|
+
"python_method": "create_agent_adapter",
|
|
139
|
+
"request_schema": null
|
|
140
|
+
},
|
|
141
|
+
"postAgentAdapterToolCall": {
|
|
142
|
+
"method": "POST",
|
|
143
|
+
"node_method": "callAdapterTool",
|
|
144
|
+
"path": "/v1/agent/adapters/call-tool",
|
|
145
|
+
"public": false,
|
|
146
|
+
"python_method": "call_adapter_tool",
|
|
147
|
+
"request_schema": null
|
|
148
|
+
},
|
|
149
|
+
"postAgentAdapterTools": {
|
|
150
|
+
"method": "POST",
|
|
151
|
+
"node_method": "adapterTools",
|
|
152
|
+
"path": "/v1/agent/adapters/tools",
|
|
153
|
+
"public": false,
|
|
154
|
+
"python_method": "adapter_tools",
|
|
155
|
+
"request_schema": null
|
|
156
|
+
},
|
|
125
157
|
"postAgentCapabilities": {
|
|
126
158
|
"method": "POST",
|
|
127
159
|
"node_method": "listCapabilities",
|
|
@@ -130,6 +162,38 @@ export const OPENAPI_OPERATIONS = Object.freeze({
|
|
|
130
162
|
"python_method": "list_capabilities",
|
|
131
163
|
"request_schema": "#/components/schemas/CapabilityDiscoveryRequest"
|
|
132
164
|
},
|
|
165
|
+
"postAgentEval": {
|
|
166
|
+
"method": "POST",
|
|
167
|
+
"node_method": "createAgentEval",
|
|
168
|
+
"path": "/v1/agent/evals",
|
|
169
|
+
"public": false,
|
|
170
|
+
"python_method": "create_agent_eval",
|
|
171
|
+
"request_schema": null
|
|
172
|
+
},
|
|
173
|
+
"postAgentEvalDiff": {
|
|
174
|
+
"method": "POST",
|
|
175
|
+
"node_method": "diffAgentEval",
|
|
176
|
+
"path": "/v1/agent/evals/diff",
|
|
177
|
+
"public": false,
|
|
178
|
+
"python_method": "diff_agent_eval",
|
|
179
|
+
"request_schema": null
|
|
180
|
+
},
|
|
181
|
+
"postAgentEvalFailures": {
|
|
182
|
+
"method": "POST",
|
|
183
|
+
"node_method": "agentEvalFailures",
|
|
184
|
+
"path": "/v1/agent/evals/failures",
|
|
185
|
+
"public": false,
|
|
186
|
+
"python_method": "agent_eval_failures",
|
|
187
|
+
"request_schema": null
|
|
188
|
+
},
|
|
189
|
+
"postAgentEvalRun": {
|
|
190
|
+
"method": "POST",
|
|
191
|
+
"node_method": "runAgentEval",
|
|
192
|
+
"path": "/v1/agent/evals/run",
|
|
193
|
+
"public": false,
|
|
194
|
+
"python_method": "run_agent_eval",
|
|
195
|
+
"request_schema": null
|
|
196
|
+
},
|
|
133
197
|
"postAgentInvoke": {
|
|
134
198
|
"method": "POST",
|
|
135
199
|
"node_method": "invokeAgentCapability",
|
|
@@ -146,6 +210,62 @@ export const OPENAPI_OPERATIONS = Object.freeze({
|
|
|
146
210
|
"python_method": "memory_command",
|
|
147
211
|
"request_schema": "#/components/schemas/AgentMemoryRequest"
|
|
148
212
|
},
|
|
213
|
+
"postAgentRun": {
|
|
214
|
+
"method": "POST",
|
|
215
|
+
"node_method": "beginAgentRun",
|
|
216
|
+
"path": "/v1/agent/runs",
|
|
217
|
+
"public": false,
|
|
218
|
+
"python_method": "begin_agent_run",
|
|
219
|
+
"request_schema": null
|
|
220
|
+
},
|
|
221
|
+
"postAgentRunCheckpoint": {
|
|
222
|
+
"method": "POST",
|
|
223
|
+
"node_method": "checkpointAgentRun",
|
|
224
|
+
"path": "/v1/agent/runs/checkpoints",
|
|
225
|
+
"public": false,
|
|
226
|
+
"python_method": "checkpoint_agent_run",
|
|
227
|
+
"request_schema": null
|
|
228
|
+
},
|
|
229
|
+
"postAgentRunComplete": {
|
|
230
|
+
"method": "POST",
|
|
231
|
+
"node_method": "endAgentRun",
|
|
232
|
+
"path": "/v1/agent/runs/complete",
|
|
233
|
+
"public": false,
|
|
234
|
+
"python_method": "end_agent_run",
|
|
235
|
+
"request_schema": null
|
|
236
|
+
},
|
|
237
|
+
"postAgentRunExplain": {
|
|
238
|
+
"method": "POST",
|
|
239
|
+
"node_method": "explainAgentRun",
|
|
240
|
+
"path": "/v1/agent/runs/explain",
|
|
241
|
+
"public": false,
|
|
242
|
+
"python_method": "explain_agent_run",
|
|
243
|
+
"request_schema": null
|
|
244
|
+
},
|
|
245
|
+
"postAgentRunGuardrailEvent": {
|
|
246
|
+
"method": "POST",
|
|
247
|
+
"node_method": "recordGuardrailEvent",
|
|
248
|
+
"path": "/v1/agent/runs/guardrail-events",
|
|
249
|
+
"public": false,
|
|
250
|
+
"python_method": "record_guardrail_event",
|
|
251
|
+
"request_schema": null
|
|
252
|
+
},
|
|
253
|
+
"postAgentRunHandoff": {
|
|
254
|
+
"method": "POST",
|
|
255
|
+
"node_method": "handoffAgentRun",
|
|
256
|
+
"path": "/v1/agent/runs/handoffs",
|
|
257
|
+
"public": false,
|
|
258
|
+
"python_method": "handoff_agent_run",
|
|
259
|
+
"request_schema": null
|
|
260
|
+
},
|
|
261
|
+
"postAgentRunInterrupt": {
|
|
262
|
+
"method": "POST",
|
|
263
|
+
"node_method": "interruptAgentRun",
|
|
264
|
+
"path": "/v1/agent/runs/interrupts",
|
|
265
|
+
"public": false,
|
|
266
|
+
"python_method": "interrupt_agent_run",
|
|
267
|
+
"request_schema": null
|
|
268
|
+
},
|
|
149
269
|
"postAgentRunReplay": {
|
|
150
270
|
"method": "POST",
|
|
151
271
|
"node_method": "replayAgentRun",
|
|
@@ -154,6 +274,78 @@ export const OPENAPI_OPERATIONS = Object.freeze({
|
|
|
154
274
|
"python_method": "replay_agent_run",
|
|
155
275
|
"request_schema": "#/components/schemas/AgentRunReplayRequest"
|
|
156
276
|
},
|
|
277
|
+
"postAgentRunSettle": {
|
|
278
|
+
"method": "POST",
|
|
279
|
+
"node_method": "settleAgentRun",
|
|
280
|
+
"path": "/v1/agent/runs/settle",
|
|
281
|
+
"public": false,
|
|
282
|
+
"python_method": "settle_agent_run",
|
|
283
|
+
"request_schema": null
|
|
284
|
+
},
|
|
285
|
+
"postAgentRunStep": {
|
|
286
|
+
"method": "POST",
|
|
287
|
+
"node_method": "recordAgentStep",
|
|
288
|
+
"path": "/v1/agent/runs/steps",
|
|
289
|
+
"public": false,
|
|
290
|
+
"python_method": "record_agent_step",
|
|
291
|
+
"request_schema": null
|
|
292
|
+
},
|
|
293
|
+
"postAgentRunTrace": {
|
|
294
|
+
"method": "POST",
|
|
295
|
+
"node_method": "traceAgentRun",
|
|
296
|
+
"path": "/v1/agent/runs/trace",
|
|
297
|
+
"public": false,
|
|
298
|
+
"python_method": "trace_agent_run",
|
|
299
|
+
"request_schema": null
|
|
300
|
+
},
|
|
301
|
+
"postAgentWorkflow": {
|
|
302
|
+
"method": "POST",
|
|
303
|
+
"node_method": "createAgentWorkflow",
|
|
304
|
+
"path": "/v1/agent/workflows",
|
|
305
|
+
"public": false,
|
|
306
|
+
"python_method": "create_agent_workflow",
|
|
307
|
+
"request_schema": null
|
|
308
|
+
},
|
|
309
|
+
"postExternalActionApprove": {
|
|
310
|
+
"method": "POST",
|
|
311
|
+
"node_method": "approveExternalAction",
|
|
312
|
+
"path": "/v1/agent/external-actions/{action_instance_id}/approve",
|
|
313
|
+
"public": false,
|
|
314
|
+
"python_method": "approve_external_action",
|
|
315
|
+
"request_schema": null
|
|
316
|
+
},
|
|
317
|
+
"postExternalActionClaim": {
|
|
318
|
+
"method": "POST",
|
|
319
|
+
"node_method": "claimExternalAction",
|
|
320
|
+
"path": "/v1/agent/external-actions/claim",
|
|
321
|
+
"public": false,
|
|
322
|
+
"python_method": "claim_external_action",
|
|
323
|
+
"request_schema": null
|
|
324
|
+
},
|
|
325
|
+
"postExternalActionConfirm": {
|
|
326
|
+
"method": "POST",
|
|
327
|
+
"node_method": "confirmExternalAction",
|
|
328
|
+
"path": "/v1/agent/external-actions/{action_instance_id}/confirm",
|
|
329
|
+
"public": false,
|
|
330
|
+
"python_method": "confirm_external_action",
|
|
331
|
+
"request_schema": null
|
|
332
|
+
},
|
|
333
|
+
"postExternalActionPropose": {
|
|
334
|
+
"method": "POST",
|
|
335
|
+
"node_method": "proposeExternalAction",
|
|
336
|
+
"path": "/v1/agent/external-actions/propose",
|
|
337
|
+
"public": false,
|
|
338
|
+
"python_method": "propose_external_action",
|
|
339
|
+
"request_schema": null
|
|
340
|
+
},
|
|
341
|
+
"postObservabilitySink": {
|
|
342
|
+
"method": "POST",
|
|
343
|
+
"node_method": "createObservabilitySink",
|
|
344
|
+
"path": "/v1/observability/sinks",
|
|
345
|
+
"public": false,
|
|
346
|
+
"python_method": "create_observability_sink",
|
|
347
|
+
"request_schema": null
|
|
348
|
+
},
|
|
157
349
|
"postQuery": {
|
|
158
350
|
"method": "POST",
|
|
159
351
|
"node_method": "query",
|
|
@@ -210,6 +402,14 @@ export const OPENAPI_OPERATIONS = Object.freeze({
|
|
|
210
402
|
"python_method": "run_hybrid_reembed_jobs",
|
|
211
403
|
"request_schema": "#/components/schemas/HybridReembedRunRequest"
|
|
212
404
|
},
|
|
405
|
+
"setAdminTenantBudget": {
|
|
406
|
+
"method": "POST",
|
|
407
|
+
"node_method": "setAdminTenantBudget",
|
|
408
|
+
"path": "/v1/admin/tenant-budgets",
|
|
409
|
+
"public": false,
|
|
410
|
+
"python_method": "set_admin_tenant_budget",
|
|
411
|
+
"request_schema": null
|
|
412
|
+
},
|
|
213
413
|
"settleAgentProposal": {
|
|
214
414
|
"method": "POST",
|
|
215
415
|
"node_method": "settleWrite",
|
|
@@ -223,6 +423,7 @@ export const PYTHON_OPERATION_METHODS = Object.freeze({
|
|
|
223
423
|
"approveAgentProposal": "approve_write",
|
|
224
424
|
"cancelAgentProposal": "cancel_write",
|
|
225
425
|
"cancelHybridReembedJob": "cancel_hybrid_reembed_job",
|
|
426
|
+
"clearAdminTenantBudget": "clear_admin_tenant_budget",
|
|
226
427
|
"commitAgentProposal": "commit_write",
|
|
227
428
|
"createAdminBackup": "create_admin_backup",
|
|
228
429
|
"getAdminCheck": "admin_check",
|
|
@@ -235,10 +436,33 @@ export const PYTHON_OPERATION_METHODS = Object.freeze({
|
|
|
235
436
|
"getOpenApi": "openapi",
|
|
236
437
|
"pauseHybridReembedJob": "pause_hybrid_reembed_job",
|
|
237
438
|
"postAdminShutdown": "shutdown",
|
|
439
|
+
"postAgentAdapter": "create_agent_adapter",
|
|
440
|
+
"postAgentAdapterToolCall": "call_adapter_tool",
|
|
441
|
+
"postAgentAdapterTools": "adapter_tools",
|
|
238
442
|
"postAgentCapabilities": "list_capabilities",
|
|
443
|
+
"postAgentEval": "create_agent_eval",
|
|
444
|
+
"postAgentEvalDiff": "diff_agent_eval",
|
|
445
|
+
"postAgentEvalFailures": "agent_eval_failures",
|
|
446
|
+
"postAgentEvalRun": "run_agent_eval",
|
|
239
447
|
"postAgentInvoke": "invoke_agent_capability",
|
|
240
448
|
"postAgentMemory": "memory_command",
|
|
449
|
+
"postAgentRun": "begin_agent_run",
|
|
450
|
+
"postAgentRunCheckpoint": "checkpoint_agent_run",
|
|
451
|
+
"postAgentRunComplete": "end_agent_run",
|
|
452
|
+
"postAgentRunExplain": "explain_agent_run",
|
|
453
|
+
"postAgentRunGuardrailEvent": "record_guardrail_event",
|
|
454
|
+
"postAgentRunHandoff": "handoff_agent_run",
|
|
455
|
+
"postAgentRunInterrupt": "interrupt_agent_run",
|
|
241
456
|
"postAgentRunReplay": "replay_agent_run",
|
|
457
|
+
"postAgentRunSettle": "settle_agent_run",
|
|
458
|
+
"postAgentRunStep": "record_agent_step",
|
|
459
|
+
"postAgentRunTrace": "trace_agent_run",
|
|
460
|
+
"postAgentWorkflow": "create_agent_workflow",
|
|
461
|
+
"postExternalActionApprove": "approve_external_action",
|
|
462
|
+
"postExternalActionClaim": "claim_external_action",
|
|
463
|
+
"postExternalActionConfirm": "confirm_external_action",
|
|
464
|
+
"postExternalActionPropose": "propose_external_action",
|
|
465
|
+
"postObservabilitySink": "create_observability_sink",
|
|
242
466
|
"postQuery": "query",
|
|
243
467
|
"postResourceRead": "read_resource",
|
|
244
468
|
"postSql": "execute",
|
|
@@ -246,12 +470,14 @@ export const PYTHON_OPERATION_METHODS = Object.freeze({
|
|
|
246
470
|
"rejectAgentProposal": "reject_write",
|
|
247
471
|
"resumeHybridReembedJob": "resume_hybrid_reembed_job",
|
|
248
472
|
"runHybridReembedJobs": "run_hybrid_reembed_jobs",
|
|
473
|
+
"setAdminTenantBudget": "set_admin_tenant_budget",
|
|
249
474
|
"settleAgentProposal": "settle_write"
|
|
250
475
|
});
|
|
251
476
|
export const NODE_OPERATION_METHODS = Object.freeze({
|
|
252
477
|
"approveAgentProposal": "approveWrite",
|
|
253
478
|
"cancelAgentProposal": "cancelWrite",
|
|
254
479
|
"cancelHybridReembedJob": "cancelHybridReembedJob",
|
|
480
|
+
"clearAdminTenantBudget": "clearAdminTenantBudget",
|
|
255
481
|
"commitAgentProposal": "commitWrite",
|
|
256
482
|
"createAdminBackup": "createAdminBackup",
|
|
257
483
|
"getAdminCheck": "adminCheck",
|
|
@@ -264,10 +490,33 @@ export const NODE_OPERATION_METHODS = Object.freeze({
|
|
|
264
490
|
"getOpenApi": "openapi",
|
|
265
491
|
"pauseHybridReembedJob": "pauseHybridReembedJob",
|
|
266
492
|
"postAdminShutdown": "shutdown",
|
|
493
|
+
"postAgentAdapter": "createAgentAdapter",
|
|
494
|
+
"postAgentAdapterToolCall": "callAdapterTool",
|
|
495
|
+
"postAgentAdapterTools": "adapterTools",
|
|
267
496
|
"postAgentCapabilities": "listCapabilities",
|
|
497
|
+
"postAgentEval": "createAgentEval",
|
|
498
|
+
"postAgentEvalDiff": "diffAgentEval",
|
|
499
|
+
"postAgentEvalFailures": "agentEvalFailures",
|
|
500
|
+
"postAgentEvalRun": "runAgentEval",
|
|
268
501
|
"postAgentInvoke": "invokeAgentCapability",
|
|
269
502
|
"postAgentMemory": "memoryCommand",
|
|
503
|
+
"postAgentRun": "beginAgentRun",
|
|
504
|
+
"postAgentRunCheckpoint": "checkpointAgentRun",
|
|
505
|
+
"postAgentRunComplete": "endAgentRun",
|
|
506
|
+
"postAgentRunExplain": "explainAgentRun",
|
|
507
|
+
"postAgentRunGuardrailEvent": "recordGuardrailEvent",
|
|
508
|
+
"postAgentRunHandoff": "handoffAgentRun",
|
|
509
|
+
"postAgentRunInterrupt": "interruptAgentRun",
|
|
270
510
|
"postAgentRunReplay": "replayAgentRun",
|
|
511
|
+
"postAgentRunSettle": "settleAgentRun",
|
|
512
|
+
"postAgentRunStep": "recordAgentStep",
|
|
513
|
+
"postAgentRunTrace": "traceAgentRun",
|
|
514
|
+
"postAgentWorkflow": "createAgentWorkflow",
|
|
515
|
+
"postExternalActionApprove": "approveExternalAction",
|
|
516
|
+
"postExternalActionClaim": "claimExternalAction",
|
|
517
|
+
"postExternalActionConfirm": "confirmExternalAction",
|
|
518
|
+
"postExternalActionPropose": "proposeExternalAction",
|
|
519
|
+
"postObservabilitySink": "createObservabilitySink",
|
|
271
520
|
"postQuery": "query",
|
|
272
521
|
"postResourceRead": "readResource",
|
|
273
522
|
"postSql": "execute",
|
|
@@ -275,6 +524,7 @@ export const NODE_OPERATION_METHODS = Object.freeze({
|
|
|
275
524
|
"rejectAgentProposal": "rejectWrite",
|
|
276
525
|
"resumeHybridReembedJob": "resumeHybridReembedJob",
|
|
277
526
|
"runHybridReembedJobs": "runHybridReembedJobs",
|
|
527
|
+
"setAdminTenantBudget": "setAdminTenantBudget",
|
|
278
528
|
"settleAgentProposal": "settleWrite"
|
|
279
529
|
});
|
|
280
530
|
export const PUBLIC_OPERATIONS = Object.freeze([
|
package/package.json
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synapsor/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
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
|
+
"bin": {
|
|
8
|
+
"synapsor": "bin/synapsor.mjs"
|
|
9
|
+
},
|
|
7
10
|
"exports": {
|
|
8
|
-
".": "./synapsor.mjs"
|
|
11
|
+
".": "./synapsor.mjs",
|
|
12
|
+
"./bin/synapsor": "./bin/synapsor.mjs",
|
|
13
|
+
"./external-db-writeback": "./external-db-writeback.mjs"
|
|
9
14
|
},
|
|
10
15
|
"files": [
|
|
16
|
+
"bin/synapsor.mjs",
|
|
17
|
+
"external-db-writeback.mjs",
|
|
11
18
|
"synapsor.mjs",
|
|
12
19
|
"generated-contract.mjs",
|
|
13
20
|
"README.md",
|
|
14
21
|
"package.json"
|
|
15
22
|
],
|
|
16
23
|
"scripts": {
|
|
17
|
-
"build": "node --check synapsor.mjs && node --check generated-contract.mjs",
|
|
24
|
+
"build": "node --check synapsor.mjs && node --check generated-contract.mjs && node --check external-db-writeback.mjs && node --check bin/synapsor.mjs",
|
|
18
25
|
"test": "node --test test/*.test.mjs"
|
|
19
26
|
},
|
|
20
27
|
"keywords": [
|
|
@@ -28,7 +35,7 @@
|
|
|
28
35
|
"homepage": "https://synapsor.ai",
|
|
29
36
|
"repository": {
|
|
30
37
|
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/
|
|
38
|
+
"url": "git+https://github.com/synapsor/synapsor.git"
|
|
32
39
|
},
|
|
33
40
|
"bugs": {
|
|
34
41
|
"url": "https://synapsor.ai/contact"
|