@datagrout/conduit 0.1.0 → 0.2.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/dist/index.d.mts +210 -224
- package/dist/index.d.ts +210 -224
- package/dist/index.js +362 -289
- package/dist/index.mjs +362 -289
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -873,6 +873,304 @@ function saveIdentity(identity, directory = DEFAULT_IDENTITY_DIR) {
|
|
|
873
873
|
return result;
|
|
874
874
|
}
|
|
875
875
|
|
|
876
|
+
// src/namespaces/prism.ts
|
|
877
|
+
var PrismNamespace = class {
|
|
878
|
+
/** @internal */
|
|
879
|
+
constructor(callDg, warn) {
|
|
880
|
+
this.callDg = callDg;
|
|
881
|
+
this.warn = warn;
|
|
882
|
+
}
|
|
883
|
+
/** AI-driven data transformation (`data-grout/prism.refract`). */
|
|
884
|
+
async refract(options) {
|
|
885
|
+
this.warn("prism.refract");
|
|
886
|
+
const params = {
|
|
887
|
+
goal: options.goal,
|
|
888
|
+
payload: options.payload
|
|
889
|
+
};
|
|
890
|
+
if (options.verbose !== void 0) params.verbose = options.verbose;
|
|
891
|
+
if (options.chart !== void 0) params.chart = options.chart;
|
|
892
|
+
return this.callDg("prism.refract", params);
|
|
893
|
+
}
|
|
894
|
+
/** AI-driven charting (`data-grout/prism.chart`). */
|
|
895
|
+
async chart(options) {
|
|
896
|
+
this.warn("prism.chart");
|
|
897
|
+
const params = {
|
|
898
|
+
goal: options.goal,
|
|
899
|
+
payload: options.payload
|
|
900
|
+
};
|
|
901
|
+
if (options.format) params.format = options.format;
|
|
902
|
+
if (options.chartType) params.chart_type = options.chartType;
|
|
903
|
+
if (options.title) params.title = options.title;
|
|
904
|
+
if (options.xLabel) params.x_label = options.xLabel;
|
|
905
|
+
if (options.yLabel) params.y_label = options.yLabel;
|
|
906
|
+
if (options.width !== void 0) params.width = options.width;
|
|
907
|
+
if (options.height !== void 0) params.height = options.height;
|
|
908
|
+
return this.callDg("prism.chart", params);
|
|
909
|
+
}
|
|
910
|
+
/** Generate a document toward a natural-language goal (`data-grout/prism.render`). */
|
|
911
|
+
async render(options) {
|
|
912
|
+
this.warn("prism.render");
|
|
913
|
+
const { goal, format = "markdown", payload, sections, ...rest } = options;
|
|
914
|
+
const params = { goal, format, ...rest };
|
|
915
|
+
if (payload !== void 0) params.payload = payload;
|
|
916
|
+
if (sections !== void 0) params.sections = sections;
|
|
917
|
+
return this.callDg("prism.render", params);
|
|
918
|
+
}
|
|
919
|
+
/** Convert content to another format without LLM (`data-grout/prism.export`). */
|
|
920
|
+
async export(options) {
|
|
921
|
+
this.warn("prism.export");
|
|
922
|
+
const { content, format, ...rest } = options;
|
|
923
|
+
const params = { content, format, ...rest };
|
|
924
|
+
return this.callDg("prism.export", params);
|
|
925
|
+
}
|
|
926
|
+
/** Semantic type transformation (`data-grout/prism.focus`). */
|
|
927
|
+
async focus(options) {
|
|
928
|
+
this.warn("prism.focus");
|
|
929
|
+
const params = {
|
|
930
|
+
data: options.data,
|
|
931
|
+
source_type: options.sourceType,
|
|
932
|
+
target_type: options.targetType,
|
|
933
|
+
...options.sourceAnnotations && { source_annotations: options.sourceAnnotations },
|
|
934
|
+
...options.targetAnnotations && { target_annotations: options.targetAnnotations },
|
|
935
|
+
...options.context && { context: options.context }
|
|
936
|
+
};
|
|
937
|
+
return this.callDg("prism.focus", params);
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
// src/namespaces/logic.ts
|
|
942
|
+
var LogicNamespace = class {
|
|
943
|
+
/** @internal */
|
|
944
|
+
constructor(callDg, warn) {
|
|
945
|
+
this.callDg = callDg;
|
|
946
|
+
this.warn = warn;
|
|
947
|
+
}
|
|
948
|
+
async remember(statementOrOptions, optionsArg) {
|
|
949
|
+
let statement;
|
|
950
|
+
let opts;
|
|
951
|
+
if (typeof statementOrOptions === "string") {
|
|
952
|
+
statement = statementOrOptions;
|
|
953
|
+
opts = optionsArg;
|
|
954
|
+
} else {
|
|
955
|
+
opts = statementOrOptions;
|
|
956
|
+
statement = opts.statement;
|
|
957
|
+
}
|
|
958
|
+
if (!statement && !opts?.facts?.length) {
|
|
959
|
+
throw new InvalidConfigError("remember() requires either a statement or facts");
|
|
960
|
+
}
|
|
961
|
+
const params = { tag: opts?.tag ?? "default" };
|
|
962
|
+
if (opts?.facts) {
|
|
963
|
+
params.facts = opts.facts;
|
|
964
|
+
} else {
|
|
965
|
+
params.statement = statement;
|
|
966
|
+
}
|
|
967
|
+
return this.callDg("logic.remember", params);
|
|
968
|
+
}
|
|
969
|
+
async query(questionOrOptions, optionsArg) {
|
|
970
|
+
let question;
|
|
971
|
+
let opts;
|
|
972
|
+
if (typeof questionOrOptions === "string") {
|
|
973
|
+
question = questionOrOptions;
|
|
974
|
+
opts = optionsArg;
|
|
975
|
+
} else {
|
|
976
|
+
opts = questionOrOptions;
|
|
977
|
+
question = opts.question;
|
|
978
|
+
}
|
|
979
|
+
if (!question && !opts?.patterns?.length) {
|
|
980
|
+
throw new InvalidConfigError("query() requires either a question or patterns");
|
|
981
|
+
}
|
|
982
|
+
const params = { limit: opts?.limit ?? 50 };
|
|
983
|
+
if (opts?.patterns) {
|
|
984
|
+
params.patterns = opts.patterns;
|
|
985
|
+
} else {
|
|
986
|
+
params.question = question;
|
|
987
|
+
}
|
|
988
|
+
return this.callDg("logic.query", params);
|
|
989
|
+
}
|
|
990
|
+
/** Retract facts from the logic cell (`data-grout/logic.forget`). */
|
|
991
|
+
async forget(options) {
|
|
992
|
+
if (!options.handles?.length && !options.pattern) {
|
|
993
|
+
throw new InvalidConfigError("forget() requires either handles or pattern");
|
|
994
|
+
}
|
|
995
|
+
const params = {};
|
|
996
|
+
if (options.handles) params.handles = options.handles;
|
|
997
|
+
if (options.pattern) params.pattern = options.pattern;
|
|
998
|
+
return this.callDg("logic.forget", params);
|
|
999
|
+
}
|
|
1000
|
+
/** Reflect on the logic cell (`data-grout/logic.reflect`). */
|
|
1001
|
+
async reflect(options) {
|
|
1002
|
+
const params = { summary_only: options?.summaryOnly ?? false };
|
|
1003
|
+
if (options?.entity) params.entity = options.entity;
|
|
1004
|
+
return this.callDg("logic.reflect", params);
|
|
1005
|
+
}
|
|
1006
|
+
/** Add a constraint rule (`data-grout/logic.constrain`). */
|
|
1007
|
+
async constrain(rule, options) {
|
|
1008
|
+
const params = { rule, tag: options?.tag ?? "constraint" };
|
|
1009
|
+
return this.callDg("logic.constrain", params);
|
|
1010
|
+
}
|
|
1011
|
+
/** Hydrate the logic cell from external data (`data-grout/logic.hydrate`). */
|
|
1012
|
+
async hydrate(params) {
|
|
1013
|
+
this.warn("logic.hydrate");
|
|
1014
|
+
return this.callDg("logic.hydrate", params);
|
|
1015
|
+
}
|
|
1016
|
+
/** Export the logic cell contents (`data-grout/logic.export`). */
|
|
1017
|
+
async exportCell(params = {}) {
|
|
1018
|
+
this.warn("logic.export");
|
|
1019
|
+
return this.callDg("logic.export", params);
|
|
1020
|
+
}
|
|
1021
|
+
/** Import facts into the logic cell (`data-grout/logic.import`). */
|
|
1022
|
+
async importCell(params) {
|
|
1023
|
+
this.warn("logic.import");
|
|
1024
|
+
return this.callDg("logic.import", params);
|
|
1025
|
+
}
|
|
1026
|
+
/** Tabulate logic cell contents (`data-grout/logic.tabulate`). */
|
|
1027
|
+
async tabulate(params = {}) {
|
|
1028
|
+
this.warn("logic.tabulate");
|
|
1029
|
+
return this.callDg("logic.tabulate", params);
|
|
1030
|
+
}
|
|
1031
|
+
/** Manage hypothetical worlds (`data-grout/logic.worlds`). */
|
|
1032
|
+
async worlds(params) {
|
|
1033
|
+
this.warn("logic.worlds");
|
|
1034
|
+
return this.callDg("logic.worlds", params);
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
// src/namespaces/warden.ts
|
|
1039
|
+
var WardenNamespace = class {
|
|
1040
|
+
/** @internal */
|
|
1041
|
+
constructor(callDg, warn) {
|
|
1042
|
+
this.callDg = callDg;
|
|
1043
|
+
this.warn = warn;
|
|
1044
|
+
}
|
|
1045
|
+
/** Run a canary safety check (`data-grout/warden.canary`). */
|
|
1046
|
+
async canary(params) {
|
|
1047
|
+
this.warn("warden.canary");
|
|
1048
|
+
return this.callDg("warden.canary", params);
|
|
1049
|
+
}
|
|
1050
|
+
/** Verify intent before executing an action (`data-grout/warden.intent`). */
|
|
1051
|
+
async verifyIntent(params) {
|
|
1052
|
+
this.warn("warden.intent");
|
|
1053
|
+
return this.callDg("warden.intent", params);
|
|
1054
|
+
}
|
|
1055
|
+
/** Adjudicate a dispute or ambiguity (`data-grout/warden.adjudicate`). */
|
|
1056
|
+
async adjudicate(params) {
|
|
1057
|
+
this.warn("warden.adjudicate");
|
|
1058
|
+
return this.callDg("warden.adjudicate", params);
|
|
1059
|
+
}
|
|
1060
|
+
/** Multi-model ensemble consensus check (`data-grout/warden.ensemble`). */
|
|
1061
|
+
async ensemble(params) {
|
|
1062
|
+
this.warn("warden.ensemble");
|
|
1063
|
+
return this.callDg("warden.ensemble", params);
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
// src/namespaces/deliverables.ts
|
|
1068
|
+
var DeliverablesNamespace = class {
|
|
1069
|
+
/** @internal */
|
|
1070
|
+
constructor(callDg, warn) {
|
|
1071
|
+
this.callDg = callDg;
|
|
1072
|
+
this.warn = warn;
|
|
1073
|
+
}
|
|
1074
|
+
/** Register a work product (`data-grout/deliverables.register`). */
|
|
1075
|
+
async register(params) {
|
|
1076
|
+
this.warn("deliverables.register");
|
|
1077
|
+
return this.callDg("deliverables.register", params);
|
|
1078
|
+
}
|
|
1079
|
+
/** List deliverables with optional semantic search (`data-grout/deliverables.list`). */
|
|
1080
|
+
async list(params = {}) {
|
|
1081
|
+
this.warn("deliverables.list");
|
|
1082
|
+
return this.callDg("deliverables.list", params);
|
|
1083
|
+
}
|
|
1084
|
+
/** Get a specific deliverable by reference (`data-grout/deliverables.get`). */
|
|
1085
|
+
async get(refId) {
|
|
1086
|
+
this.warn("deliverables.get");
|
|
1087
|
+
return this.callDg("deliverables.get", { ref: refId });
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
|
|
1091
|
+
// src/namespaces/ephemerals.ts
|
|
1092
|
+
var EphemeralsNamespace = class {
|
|
1093
|
+
/** @internal */
|
|
1094
|
+
constructor(callDg, warn) {
|
|
1095
|
+
this.callDg = callDg;
|
|
1096
|
+
this.warn = warn;
|
|
1097
|
+
}
|
|
1098
|
+
/** List cached results (`data-grout/ephemerals.list`). */
|
|
1099
|
+
async list(params = {}) {
|
|
1100
|
+
this.warn("ephemerals.list");
|
|
1101
|
+
return this.callDg("ephemerals.list", params);
|
|
1102
|
+
}
|
|
1103
|
+
/** Inspect a specific cache entry (`data-grout/ephemerals.inspect`). */
|
|
1104
|
+
async inspect(cacheRef) {
|
|
1105
|
+
this.warn("ephemerals.inspect");
|
|
1106
|
+
return this.callDg("ephemerals.inspect", { cache_ref: cacheRef });
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
// src/namespaces/flow.ts
|
|
1111
|
+
var FlowNamespace = class {
|
|
1112
|
+
/** @internal */
|
|
1113
|
+
constructor(callDg, warn) {
|
|
1114
|
+
this.callDg = callDg;
|
|
1115
|
+
this.warn = warn;
|
|
1116
|
+
}
|
|
1117
|
+
/** Execute a multi-step workflow plan (`data-grout/flow.into`). */
|
|
1118
|
+
async run(options) {
|
|
1119
|
+
this.warn("flow.into");
|
|
1120
|
+
const params = {
|
|
1121
|
+
plan: options.plan,
|
|
1122
|
+
validate_ctc: options.validateCtc ?? true,
|
|
1123
|
+
save_as_skill: options.saveAsSkill ?? false
|
|
1124
|
+
};
|
|
1125
|
+
if (options.inputData) params.input_data = options.inputData;
|
|
1126
|
+
return this.callDg("flow.into", params);
|
|
1127
|
+
}
|
|
1128
|
+
/** Conditional dispatch with predicate-based branching (`data-grout/flow.route`). */
|
|
1129
|
+
async route(options) {
|
|
1130
|
+
this.warn("flow.route");
|
|
1131
|
+
const { branches, payload, cacheRef, else: elseTarget, ...rest } = options;
|
|
1132
|
+
const params = { branches, ...rest };
|
|
1133
|
+
if (payload !== void 0) params.payload = payload;
|
|
1134
|
+
if (cacheRef !== void 0) params.cache_ref = cacheRef;
|
|
1135
|
+
if (elseTarget !== void 0) params.else = elseTarget;
|
|
1136
|
+
return this.callDg("flow.route", params);
|
|
1137
|
+
}
|
|
1138
|
+
/** Pause workflow for human approval (`data-grout/flow.request-approval`). */
|
|
1139
|
+
async requestApproval(options) {
|
|
1140
|
+
this.warn("flow.request-approval");
|
|
1141
|
+
const { action, details, reason, context, ...rest } = options;
|
|
1142
|
+
const params = { action, ...rest };
|
|
1143
|
+
if (details !== void 0) params.details = details;
|
|
1144
|
+
if (reason !== void 0) params.reason = reason;
|
|
1145
|
+
if (context !== void 0) params.context = context;
|
|
1146
|
+
return this.callDg("flow.request-approval", params);
|
|
1147
|
+
}
|
|
1148
|
+
/** Request user clarification for missing fields (`data-grout/flow.request-feedback`). */
|
|
1149
|
+
async requestFeedback(options) {
|
|
1150
|
+
this.warn("flow.request-feedback");
|
|
1151
|
+
const { missing_fields, reason, ...rest } = options;
|
|
1152
|
+
const params = { missing_fields, reason, ...rest };
|
|
1153
|
+
return this.callDg("flow.request-feedback", params);
|
|
1154
|
+
}
|
|
1155
|
+
/** List recent tool executions (`data-grout/inspect.execution-history`). */
|
|
1156
|
+
async history(options = {}) {
|
|
1157
|
+
this.warn("inspect.execution-history");
|
|
1158
|
+
const params = {
|
|
1159
|
+
limit: options.limit ?? 50,
|
|
1160
|
+
offset: options.offset ?? 0,
|
|
1161
|
+
refractions_only: options.refractions_only ?? false,
|
|
1162
|
+
...options
|
|
1163
|
+
};
|
|
1164
|
+
if (options.status !== void 0) params.status = options.status;
|
|
1165
|
+
return this.callDg("inspect.execution-history", params);
|
|
1166
|
+
}
|
|
1167
|
+
/** Get details for a specific execution (`data-grout/inspect.execution-details`). */
|
|
1168
|
+
async details(executionId) {
|
|
1169
|
+
this.warn("inspect.execution-details");
|
|
1170
|
+
return this.callDg("inspect.execution-details", { execution_id: executionId });
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
|
|
876
1174
|
// src/client.ts
|
|
877
1175
|
var GuidedSession = class {
|
|
878
1176
|
client;
|
|
@@ -1080,6 +1378,35 @@ var Client2 = class _Client {
|
|
|
1080
1378
|
}
|
|
1081
1379
|
}
|
|
1082
1380
|
}
|
|
1381
|
+
// ===== Namespace Accessors =====
|
|
1382
|
+
callDgTool = async (tool, params) => {
|
|
1383
|
+
this.ensureInitialized();
|
|
1384
|
+
return this.sendWithRetry(() => this.transport.callTool(`data-grout/${tool}`, params));
|
|
1385
|
+
};
|
|
1386
|
+
/** Data transformation, charting, rendering, and type bridging. */
|
|
1387
|
+
get prism() {
|
|
1388
|
+
return new PrismNamespace(this.callDgTool, (m) => this.warnIfNotDg(m));
|
|
1389
|
+
}
|
|
1390
|
+
/** Persistent agent memory backed by a Prolog logic cell. */
|
|
1391
|
+
get logic() {
|
|
1392
|
+
return new LogicNamespace(this.callDgTool, (m) => this.warnIfNotDg(m));
|
|
1393
|
+
}
|
|
1394
|
+
/** Safety gates, intent verification, and multi-model consensus. */
|
|
1395
|
+
get warden() {
|
|
1396
|
+
return new WardenNamespace(this.callDgTool, (m) => this.warnIfNotDg(m));
|
|
1397
|
+
}
|
|
1398
|
+
/** Work product registration, listing, and retrieval. */
|
|
1399
|
+
get deliverables() {
|
|
1400
|
+
return new DeliverablesNamespace(this.callDgTool, (m) => this.warnIfNotDg(m));
|
|
1401
|
+
}
|
|
1402
|
+
/** Cache listing and inspection. */
|
|
1403
|
+
get ephemerals() {
|
|
1404
|
+
return new EphemeralsNamespace(this.callDgTool, (m) => this.warnIfNotDg(m));
|
|
1405
|
+
}
|
|
1406
|
+
/** Multi-step orchestration, routing, approvals, and execution history. */
|
|
1407
|
+
get flow() {
|
|
1408
|
+
return new FlowNamespace(this.callDgTool, (m) => this.warnIfNotDg(m));
|
|
1409
|
+
}
|
|
1083
1410
|
// ===== Standard MCP API (Drop-in Compatible) =====
|
|
1084
1411
|
/**
|
|
1085
1412
|
* List all tools exposed by the connected MCP server.
|
|
@@ -1300,60 +1627,6 @@ var Client2 = class _Client {
|
|
|
1300
1627
|
};
|
|
1301
1628
|
return new GuidedSession(this, state);
|
|
1302
1629
|
}
|
|
1303
|
-
/**
|
|
1304
|
-
* Execute a pre-planned sequence of tool calls (a "flow") through the
|
|
1305
|
-
* DataGrout gateway.
|
|
1306
|
-
*
|
|
1307
|
-
* JSON-RPC method: `tools/call` → `data-grout/flow.into`
|
|
1308
|
-
*
|
|
1309
|
-
* @param options.plan - Ordered list of tool call descriptors.
|
|
1310
|
-
* @param options.validateCtc - Validate each call against its CTC schema (default: `true`).
|
|
1311
|
-
* @param options.saveAsSkill - Persist the flow as a reusable skill (default: `false`).
|
|
1312
|
-
* @param options.inputData - Runtime input data for the flow.
|
|
1313
|
-
*/
|
|
1314
|
-
async flowInto(options) {
|
|
1315
|
-
this.ensureInitialized();
|
|
1316
|
-
this.warnIfNotDg("flowInto");
|
|
1317
|
-
const params = {
|
|
1318
|
-
plan: options.plan,
|
|
1319
|
-
validate_ctc: options.validateCtc ?? true,
|
|
1320
|
-
save_as_skill: options.saveAsSkill ?? false
|
|
1321
|
-
};
|
|
1322
|
-
if (options.inputData) {
|
|
1323
|
-
params.input_data = options.inputData;
|
|
1324
|
-
}
|
|
1325
|
-
return this.sendWithRetry(
|
|
1326
|
-
() => this.transport.callTool("data-grout/flow.into", params)
|
|
1327
|
-
);
|
|
1328
|
-
}
|
|
1329
|
-
/**
|
|
1330
|
-
* Transform data from one annotated type to another using the DataGrout
|
|
1331
|
-
* Prism semantic mapping engine.
|
|
1332
|
-
*
|
|
1333
|
-
* JSON-RPC method: `tools/call` → `data-grout/prism.focus`
|
|
1334
|
-
*
|
|
1335
|
-
* @param options.data - Source payload to transform.
|
|
1336
|
-
* @param options.sourceType - Semantic type of the source data.
|
|
1337
|
-
* @param options.targetType - Desired semantic type for the output.
|
|
1338
|
-
* @param options.sourceAnnotations - Additional schema hints for the source.
|
|
1339
|
-
* @param options.targetAnnotations - Additional schema hints for the target.
|
|
1340
|
-
* @param options.context - Free-text context to guide the mapping.
|
|
1341
|
-
*/
|
|
1342
|
-
async prismFocus(options) {
|
|
1343
|
-
this.ensureInitialized();
|
|
1344
|
-
this.warnIfNotDg("prismFocus");
|
|
1345
|
-
const params = {
|
|
1346
|
-
data: options.data,
|
|
1347
|
-
source_type: options.sourceType,
|
|
1348
|
-
target_type: options.targetType,
|
|
1349
|
-
...options.sourceAnnotations && { source_annotations: options.sourceAnnotations },
|
|
1350
|
-
...options.targetAnnotations && { target_annotations: options.targetAnnotations },
|
|
1351
|
-
...options.context && { context: options.context }
|
|
1352
|
-
};
|
|
1353
|
-
return this.sendWithRetry(
|
|
1354
|
-
() => this.transport.callTool("data-grout/prism.focus", params)
|
|
1355
|
-
);
|
|
1356
|
-
}
|
|
1357
1630
|
/**
|
|
1358
1631
|
* Generate an execution plan for a goal using DataGrout's planning engine.
|
|
1359
1632
|
*
|
|
@@ -1393,126 +1666,6 @@ var Client2 = class _Client {
|
|
|
1393
1666
|
() => this.transport.callTool("data-grout/discovery.plan", params)
|
|
1394
1667
|
);
|
|
1395
1668
|
}
|
|
1396
|
-
/**
|
|
1397
|
-
* Analyse and summarise a payload using the DataGrout Prism refraction engine.
|
|
1398
|
-
*
|
|
1399
|
-
* JSON-RPC method: `tools/call` → `data-grout/prism.refract`
|
|
1400
|
-
*
|
|
1401
|
-
* @param options.goal - Description of what to extract or summarise.
|
|
1402
|
-
* @param options.payload - Input data to analyse (any JSON-serializable value).
|
|
1403
|
-
* @param options.verbose - Include detailed processing trace in the response.
|
|
1404
|
-
* @param options.chart - Also generate a chart representation.
|
|
1405
|
-
*/
|
|
1406
|
-
async refract(options) {
|
|
1407
|
-
this.ensureInitialized();
|
|
1408
|
-
this.warnIfNotDg("refract");
|
|
1409
|
-
const params = {
|
|
1410
|
-
goal: options.goal,
|
|
1411
|
-
payload: options.payload
|
|
1412
|
-
};
|
|
1413
|
-
if (options.verbose !== void 0) params.verbose = options.verbose;
|
|
1414
|
-
if (options.chart !== void 0) params.chart = options.chart;
|
|
1415
|
-
return this.sendWithRetry(
|
|
1416
|
-
() => this.transport.callTool("data-grout/prism.refract", params)
|
|
1417
|
-
);
|
|
1418
|
-
}
|
|
1419
|
-
/**
|
|
1420
|
-
* Generate a chart from a data payload using the DataGrout Prism engine.
|
|
1421
|
-
*
|
|
1422
|
-
* JSON-RPC method: `tools/call` → `data-grout/prism.chart`
|
|
1423
|
-
*
|
|
1424
|
-
* @param options.goal - What the chart should visualise.
|
|
1425
|
-
* @param options.payload - Input data (any JSON-serializable value).
|
|
1426
|
-
* @param options.format - Output format (e.g. `"png"`, `"svg"`).
|
|
1427
|
-
* @param options.chartType - Chart type (e.g. `"bar"`, `"line"`, `"pie"`).
|
|
1428
|
-
* @param options.title - Chart title.
|
|
1429
|
-
* @param options.xLabel - X-axis label.
|
|
1430
|
-
* @param options.yLabel - Y-axis label.
|
|
1431
|
-
* @param options.width - Chart width in pixels.
|
|
1432
|
-
* @param options.height - Chart height in pixels.
|
|
1433
|
-
*/
|
|
1434
|
-
async chart(options) {
|
|
1435
|
-
this.ensureInitialized();
|
|
1436
|
-
this.warnIfNotDg("chart");
|
|
1437
|
-
const params = {
|
|
1438
|
-
goal: options.goal,
|
|
1439
|
-
payload: options.payload
|
|
1440
|
-
};
|
|
1441
|
-
if (options.format) params.format = options.format;
|
|
1442
|
-
if (options.chartType) params.chart_type = options.chartType;
|
|
1443
|
-
if (options.title) params.title = options.title;
|
|
1444
|
-
if (options.xLabel) params.x_label = options.xLabel;
|
|
1445
|
-
if (options.yLabel) params.y_label = options.yLabel;
|
|
1446
|
-
if (options.width !== void 0) params.width = options.width;
|
|
1447
|
-
if (options.height !== void 0) params.height = options.height;
|
|
1448
|
-
return this.sendWithRetry(
|
|
1449
|
-
() => this.transport.callTool("data-grout/prism.chart", params)
|
|
1450
|
-
);
|
|
1451
|
-
}
|
|
1452
|
-
/**
|
|
1453
|
-
* Generate a document toward a natural-language goal.
|
|
1454
|
-
* Supported formats: markdown, html, pdf, json.
|
|
1455
|
-
*/
|
|
1456
|
-
async render(options) {
|
|
1457
|
-
this.ensureInitialized();
|
|
1458
|
-
this.warnIfNotDg("render");
|
|
1459
|
-
const { goal, format = "markdown", payload, sections, ...rest } = options;
|
|
1460
|
-
const params = { goal, format, ...rest };
|
|
1461
|
-
if (payload !== void 0) params.payload = payload;
|
|
1462
|
-
if (sections !== void 0) params.sections = sections;
|
|
1463
|
-
return this.sendWithRetry(() => this.transport.callTool("data-grout/prism.render", params));
|
|
1464
|
-
}
|
|
1465
|
-
/**
|
|
1466
|
-
* Convert content to another format (no LLM). Supports csv, xlsx, pdf, json, html, markdown, etc.
|
|
1467
|
-
*/
|
|
1468
|
-
async export(options) {
|
|
1469
|
-
this.ensureInitialized();
|
|
1470
|
-
this.warnIfNotDg("export");
|
|
1471
|
-
const { content, format, ...rest } = options;
|
|
1472
|
-
const params = { content, format, ...rest };
|
|
1473
|
-
return this.sendWithRetry(() => this.transport.callTool("data-grout/prism.export", params));
|
|
1474
|
-
}
|
|
1475
|
-
/**
|
|
1476
|
-
* Pause workflow for human approval. Use for destructive or policy-gated actions.
|
|
1477
|
-
*/
|
|
1478
|
-
async requestApproval(options) {
|
|
1479
|
-
this.ensureInitialized();
|
|
1480
|
-
this.warnIfNotDg("requestApproval");
|
|
1481
|
-
const { action, details, reason, context, ...rest } = options;
|
|
1482
|
-
const params = { action, ...rest };
|
|
1483
|
-
if (details !== void 0) params.details = details;
|
|
1484
|
-
if (reason !== void 0) params.reason = reason;
|
|
1485
|
-
if (context !== void 0) params.context = context;
|
|
1486
|
-
return this.sendWithRetry(() => this.transport.callTool("data-grout/flow.request-approval", params));
|
|
1487
|
-
}
|
|
1488
|
-
/**
|
|
1489
|
-
* Request user clarification for missing fields. Pauses until user provides values.
|
|
1490
|
-
*/
|
|
1491
|
-
async requestFeedback(options) {
|
|
1492
|
-
this.ensureInitialized();
|
|
1493
|
-
this.warnIfNotDg("requestFeedback");
|
|
1494
|
-
const { missing_fields, reason, ...rest } = options;
|
|
1495
|
-
const params = { missing_fields, reason, ...rest };
|
|
1496
|
-
return this.sendWithRetry(() => this.transport.callTool("data-grout/flow.request-feedback", params));
|
|
1497
|
-
}
|
|
1498
|
-
/**
|
|
1499
|
-
* List recent tool executions for the current server.
|
|
1500
|
-
*/
|
|
1501
|
-
async executionHistory(options = {}) {
|
|
1502
|
-
this.ensureInitialized();
|
|
1503
|
-
this.warnIfNotDg("executionHistory");
|
|
1504
|
-
const params = { limit: options.limit ?? 50, offset: options.offset ?? 0, refractions_only: options.refractions_only ?? false, ...options };
|
|
1505
|
-
if (options.status !== void 0) params.status = options.status;
|
|
1506
|
-
return this.sendWithRetry(() => this.transport.callTool("data-grout/inspect.execution-history", params));
|
|
1507
|
-
}
|
|
1508
|
-
/**
|
|
1509
|
-
* Get details and transcript for a specific execution.
|
|
1510
|
-
*/
|
|
1511
|
-
async executionDetails(executionId) {
|
|
1512
|
-
this.ensureInitialized();
|
|
1513
|
-
this.warnIfNotDg("executionDetails");
|
|
1514
|
-
return this.sendWithRetry(() => this.transport.callTool("data-grout/inspect.execution-details", { execution_id: executionId }));
|
|
1515
|
-
}
|
|
1516
1669
|
/**
|
|
1517
1670
|
* Call any DataGrout first-party tool by its short name.
|
|
1518
1671
|
*
|
|
@@ -1529,119 +1682,6 @@ var Client2 = class _Client {
|
|
|
1529
1682
|
const method = `data-grout/${toolShortName}`;
|
|
1530
1683
|
return this.sendWithRetry(() => this.transport.callTool(method, params));
|
|
1531
1684
|
}
|
|
1532
|
-
async remember(statementOrOptions, optionsArg) {
|
|
1533
|
-
this.ensureInitialized();
|
|
1534
|
-
let statement;
|
|
1535
|
-
let opts;
|
|
1536
|
-
if (typeof statementOrOptions === "string") {
|
|
1537
|
-
statement = statementOrOptions;
|
|
1538
|
-
opts = optionsArg;
|
|
1539
|
-
} else {
|
|
1540
|
-
opts = statementOrOptions;
|
|
1541
|
-
statement = opts.statement;
|
|
1542
|
-
}
|
|
1543
|
-
if (!statement && !opts?.facts?.length) {
|
|
1544
|
-
throw new InvalidConfigError("remember() requires either a statement or facts");
|
|
1545
|
-
}
|
|
1546
|
-
const params = {
|
|
1547
|
-
tag: opts?.tag ?? "default"
|
|
1548
|
-
};
|
|
1549
|
-
if (opts?.facts) {
|
|
1550
|
-
params.facts = opts.facts;
|
|
1551
|
-
} else {
|
|
1552
|
-
params.statement = statement;
|
|
1553
|
-
}
|
|
1554
|
-
return this.sendWithRetry(
|
|
1555
|
-
() => this.transport.callTool("data-grout/logic.remember", params)
|
|
1556
|
-
);
|
|
1557
|
-
}
|
|
1558
|
-
async queryCell(questionOrOptions, optionsArg) {
|
|
1559
|
-
this.ensureInitialized();
|
|
1560
|
-
let question;
|
|
1561
|
-
let opts;
|
|
1562
|
-
if (typeof questionOrOptions === "string") {
|
|
1563
|
-
question = questionOrOptions;
|
|
1564
|
-
opts = optionsArg;
|
|
1565
|
-
} else {
|
|
1566
|
-
opts = questionOrOptions;
|
|
1567
|
-
question = opts.question;
|
|
1568
|
-
}
|
|
1569
|
-
if (!question && !opts?.patterns?.length) {
|
|
1570
|
-
throw new InvalidConfigError("queryCell() requires either a question or patterns");
|
|
1571
|
-
}
|
|
1572
|
-
const params = {
|
|
1573
|
-
limit: opts?.limit ?? 50
|
|
1574
|
-
};
|
|
1575
|
-
if (opts?.patterns) {
|
|
1576
|
-
params.patterns = opts.patterns;
|
|
1577
|
-
} else {
|
|
1578
|
-
params.question = question;
|
|
1579
|
-
}
|
|
1580
|
-
return this.sendWithRetry(
|
|
1581
|
-
() => this.transport.callTool("data-grout/logic.query", params)
|
|
1582
|
-
);
|
|
1583
|
-
}
|
|
1584
|
-
/**
|
|
1585
|
-
* Retract facts from the agent's logic cell.
|
|
1586
|
-
*
|
|
1587
|
-
* Throws `InvalidConfigError` if neither `handles` nor `pattern` is provided.
|
|
1588
|
-
*
|
|
1589
|
-
* JSON-RPC method: `tools/call` → `data-grout/logic.forget`
|
|
1590
|
-
*
|
|
1591
|
-
* @param options.handles - Specific fact handles to retract.
|
|
1592
|
-
* @param options.pattern - Natural language pattern — retract all matching facts.
|
|
1593
|
-
*/
|
|
1594
|
-
async forget(options) {
|
|
1595
|
-
this.ensureInitialized();
|
|
1596
|
-
if (!options.handles?.length && !options.pattern) {
|
|
1597
|
-
throw new InvalidConfigError("forget() requires either handles or pattern");
|
|
1598
|
-
}
|
|
1599
|
-
const params = {};
|
|
1600
|
-
if (options.handles) params.handles = options.handles;
|
|
1601
|
-
if (options.pattern) params.pattern = options.pattern;
|
|
1602
|
-
return this.sendWithRetry(
|
|
1603
|
-
() => this.transport.callTool("data-grout/logic.forget", params)
|
|
1604
|
-
);
|
|
1605
|
-
}
|
|
1606
|
-
/**
|
|
1607
|
-
* Reflect on the agent's logic cell — returns a full snapshot or a
|
|
1608
|
-
* per-entity view of all stored facts.
|
|
1609
|
-
*
|
|
1610
|
-
* JSON-RPC method: `tools/call` → `data-grout/logic.reflect`
|
|
1611
|
-
*
|
|
1612
|
-
* @param options.entity - Optional entity name to scope reflection.
|
|
1613
|
-
* @param options.summaryOnly - When `true`, return only counts (default: `false`).
|
|
1614
|
-
*/
|
|
1615
|
-
async reflect(options) {
|
|
1616
|
-
this.ensureInitialized();
|
|
1617
|
-
const params = {
|
|
1618
|
-
summary_only: options?.summaryOnly ?? false
|
|
1619
|
-
};
|
|
1620
|
-
if (options?.entity) params.entity = options.entity;
|
|
1621
|
-
return this.sendWithRetry(
|
|
1622
|
-
() => this.transport.callTool("data-grout/logic.reflect", params)
|
|
1623
|
-
);
|
|
1624
|
-
}
|
|
1625
|
-
/**
|
|
1626
|
-
* Store a logical rule or policy in the agent's logic cell.
|
|
1627
|
-
*
|
|
1628
|
-
* Rules are permanent constraints evaluated during `queryCell()` calls.
|
|
1629
|
-
*
|
|
1630
|
-
* JSON-RPC method: `tools/call` → `data-grout/logic.constrain`
|
|
1631
|
-
*
|
|
1632
|
-
* @param rule - Natural language rule (e.g. `"VIP customers have ARR > $500K"`).
|
|
1633
|
-
* @param options.tag - Tag/namespace for this constraint (default: `"constraint"`).
|
|
1634
|
-
*/
|
|
1635
|
-
async constrain(rule, options) {
|
|
1636
|
-
this.ensureInitialized();
|
|
1637
|
-
const params = {
|
|
1638
|
-
rule,
|
|
1639
|
-
tag: options?.tag ?? "constraint"
|
|
1640
|
-
};
|
|
1641
|
-
return this.sendWithRetry(
|
|
1642
|
-
() => this.transport.callTool("data-grout/logic.constrain", params)
|
|
1643
|
-
);
|
|
1644
|
-
}
|
|
1645
1685
|
/**
|
|
1646
1686
|
* Estimate the credit cost of a tool call without executing it.
|
|
1647
1687
|
*
|
|
@@ -1673,8 +1713,41 @@ init_oauth();
|
|
|
1673
1713
|
|
|
1674
1714
|
// src/types.ts
|
|
1675
1715
|
function extractMeta(result) {
|
|
1676
|
-
const
|
|
1677
|
-
if (
|
|
1716
|
+
const rich = result?._meta?.datagrout;
|
|
1717
|
+
if (rich?.receipt) {
|
|
1718
|
+
return buildToolMeta(rich);
|
|
1719
|
+
}
|
|
1720
|
+
const legacy = result?._datagrout ?? result?._meta;
|
|
1721
|
+
if (legacy?.receipt) {
|
|
1722
|
+
return buildToolMeta(legacy);
|
|
1723
|
+
}
|
|
1724
|
+
const dg = result?._dg;
|
|
1725
|
+
if (dg) {
|
|
1726
|
+
const credits = dg.credits ?? {};
|
|
1727
|
+
const breakdown = {};
|
|
1728
|
+
if (credits.premium !== void 0) breakdown.premium = credits.premium;
|
|
1729
|
+
if (credits.llm !== void 0) breakdown.llm = credits.llm;
|
|
1730
|
+
return {
|
|
1731
|
+
receipt: {
|
|
1732
|
+
receiptId: "",
|
|
1733
|
+
timestamp: "",
|
|
1734
|
+
estimatedCredits: credits.estimated ?? 0,
|
|
1735
|
+
actualCredits: credits.charged ?? 0,
|
|
1736
|
+
netCredits: credits.charged ?? 0,
|
|
1737
|
+
savings: 0,
|
|
1738
|
+
savingsBonus: 0,
|
|
1739
|
+
balanceAfter: credits.remaining,
|
|
1740
|
+
breakdown,
|
|
1741
|
+
byok: { enabled: false, discountApplied: 0, discountRate: 0 }
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
console.warn(
|
|
1746
|
+
'[conduit] No DataGrout metadata found in tool result. Cost tracking data is unavailable. Enable "Include DG Inline" or "Include DataGrout Metadata" in your server settings.'
|
|
1747
|
+
);
|
|
1748
|
+
return null;
|
|
1749
|
+
}
|
|
1750
|
+
function buildToolMeta(raw) {
|
|
1678
1751
|
const r = raw.receipt;
|
|
1679
1752
|
const receipt = {
|
|
1680
1753
|
receiptId: r.receipt_id ?? "",
|