@kortexya/reasoninglayer 1.1.0 → 1.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.cjs CHANGED
@@ -7,7 +7,7 @@ var __export = (target, all) => {
7
7
  };
8
8
 
9
9
  // src/config.ts
10
- var SDK_VERSION = "1.1.0";
10
+ var SDK_VERSION = "1.2.0";
11
11
  function resolveConfig(config) {
12
12
  if (!config.baseUrl) {
13
13
  throw new Error("ClientConfig.baseUrl is required");
@@ -7653,6 +7653,100 @@ var Scheduling = class {
7653
7653
  });
7654
7654
  };
7655
7655
 
7656
+ // src/api-spec/generated/FlowNetworks.ts
7657
+ var FlowNetworks = class {
7658
+ http;
7659
+ constructor(http) {
7660
+ this.http = http;
7661
+ }
7662
+ /**
7663
+ * No description
7664
+ *
7665
+ * @tags flow-networks
7666
+ * @name CloneFlowNetwork
7667
+ * @summary Clone a flow network for what-if analysis.
7668
+ * @request POST:/api/v1/flow-networks/{network_id}/clone
7669
+ * @secure
7670
+ */
7671
+ cloneFlowNetwork = (networkId, params = {}) => this.http.request({
7672
+ path: `/api/v1/flow-networks/${networkId}/clone`,
7673
+ method: "POST",
7674
+ secure: true,
7675
+ format: "json",
7676
+ ...params
7677
+ });
7678
+ /**
7679
+ * No description
7680
+ *
7681
+ * @tags flow-networks
7682
+ * @name CommitFlowNetwork
7683
+ * @summary Commit structural mutations (capacity updates and/or new edges).
7684
+ * @request POST:/api/v1/flow-networks/{network_id}/commit
7685
+ * @secure
7686
+ */
7687
+ commitFlowNetwork = (networkId, data, params = {}) => this.http.request({
7688
+ path: `/api/v1/flow-networks/${networkId}/commit`,
7689
+ method: "POST",
7690
+ body: data,
7691
+ secure: true,
7692
+ type: "application/json" /* Json */,
7693
+ format: "json",
7694
+ ...params
7695
+ });
7696
+ /**
7697
+ * No description
7698
+ *
7699
+ * @tags flow-networks
7700
+ * @name CreateFlowNetwork
7701
+ * @summary Create a new flow network.
7702
+ * @request POST:/api/v1/flow-networks
7703
+ * @secure
7704
+ */
7705
+ createFlowNetwork = (data, params = {}) => this.http.request({
7706
+ path: `/api/v1/flow-networks`,
7707
+ method: "POST",
7708
+ body: data,
7709
+ secure: true,
7710
+ type: "application/json" /* Json */,
7711
+ format: "json",
7712
+ ...params
7713
+ });
7714
+ /**
7715
+ * No description
7716
+ *
7717
+ * @tags flow-networks
7718
+ * @name GetFlowNetwork
7719
+ * @summary Get a flow network's status.
7720
+ * @request GET:/api/v1/flow-networks/{network_id}
7721
+ * @secure
7722
+ */
7723
+ getFlowNetwork = (networkId, params = {}) => this.http.request({
7724
+ path: `/api/v1/flow-networks/${networkId}`,
7725
+ method: "GET",
7726
+ secure: true,
7727
+ format: "json",
7728
+ ...params
7729
+ });
7730
+ /**
7731
+ * No description
7732
+ *
7733
+ * @tags flow-networks
7734
+ * @name SolveFlowNetwork
7735
+ * @summary Solve a flow network with the chosen algorithm.
7736
+ * @request POST:/api/v1/flow-networks/{network_id}/solve
7737
+ * @secure
7738
+ */
7739
+ solveFlowNetwork = (networkId, data, params = {}) => this.http.request({
7740
+ path: `/api/v1/flow-networks/${networkId}/solve`,
7741
+ method: "POST",
7742
+ body: data,
7743
+ secure: true,
7744
+ type: "application/json" /* Json */,
7745
+ format: "json",
7746
+ ...params
7747
+ });
7748
+ };
7749
+
7656
7750
  // src/api-spec/generated/Admin.ts
7657
7751
  var Admin = class {
7658
7752
  http;
@@ -9514,19 +9608,10 @@ function ConstraintInputDtoFromFrontToApi(model) {
9514
9608
  }
9515
9609
  }
9516
9610
  function BackwardChainResponseFromApiToFront(dto) {
9517
- const wireRefs = dto.referenced_terms;
9518
- let referencedTerms;
9519
- if (wireRefs) {
9520
- referencedTerms = {};
9521
- for (const [uuid, term] of Object.entries(wireRefs)) {
9522
- referencedTerms[uuid] = TermDtoFromApiToFront(term);
9523
- }
9524
- }
9525
9611
  return {
9526
9612
  solutions: dto.solutions.map(SolutionDtoFromApiToFront),
9527
9613
  queryTimeMs: dto.query_time_ms,
9528
- goalId: dto.goal_id ?? void 0,
9529
- referencedTerms
9614
+ goalId: dto.goal_id ?? void 0
9530
9615
  };
9531
9616
  }
9532
9617
  function ForwardChainResponseFromApiToFront(dto) {
@@ -9898,8 +9983,7 @@ function BackwardChainRequestFromFrontToApi(model) {
9898
9983
  max_solutions: model.maxSolutions,
9899
9984
  min_certainty: model.minCertainty,
9900
9985
  timeout_ms: model.timeoutMs ?? void 0,
9901
- constraints: model.constraints?.map(ConstraintInputDtoFromFrontToApi),
9902
- expand_bindings: model.expandBindings
9986
+ constraints: model.constraints?.map(ConstraintInputDtoFromFrontToApi)
9903
9987
  };
9904
9988
  }
9905
9989
  function ForwardChainRequestFromFrontToApi(model) {
@@ -10052,12 +10136,6 @@ var InferenceClient = class {
10052
10136
  *
10053
10137
  * The `timeout_ms` field on the request is a wall-clock timeout for the search.
10054
10138
  * When it fires, the backend returns whatever solutions have been found so far.
10055
- *
10056
- * Pass `expandBindings: true` to receive the full {@link TermDto} of every
10057
- * Ψ-term transitively referenced by a solution's bindings in the
10058
- * `referencedTerms` sidecar map of the response. Lets the caller read complex
10059
- * bound values (lists of nested Ψ-terms etc.) without follow-up
10060
- * `terms.get(uuid)` calls.
10061
10139
  */
10062
10140
  async backwardChain(request) {
10063
10141
  const wireRequest = {
@@ -21075,6 +21153,181 @@ var SchedulingClient = class {
21075
21153
  }
21076
21154
  };
21077
21155
 
21156
+ // src/normalizers/flow-networks.ts
21157
+ function EdgeSpecFromFrontToApi(edge) {
21158
+ const dto = {
21159
+ from: edge.from,
21160
+ to: edge.to,
21161
+ capacity: edge.capacity
21162
+ };
21163
+ if (edge.cost !== void 0 && edge.cost !== null) {
21164
+ dto.cost = edge.cost;
21165
+ }
21166
+ if (edge.label !== void 0 && edge.label !== null) {
21167
+ dto.label = edge.label;
21168
+ }
21169
+ return dto;
21170
+ }
21171
+ function EdgeCapacityUpdateFromFrontToApi(update) {
21172
+ return { label: update.label, capacity: update.capacity };
21173
+ }
21174
+ function CreateFlowNetworkRequestFromFrontToApi(request) {
21175
+ const dto = {
21176
+ nodes: request.nodes,
21177
+ source: request.source,
21178
+ sink: request.sink,
21179
+ edges: request.edges.map(EdgeSpecFromFrontToApi)
21180
+ };
21181
+ if (request.description !== void 0 && request.description !== null) {
21182
+ dto.description = request.description;
21183
+ }
21184
+ return dto;
21185
+ }
21186
+ function CommitFlowNetworkRequestFromFrontToApi(request) {
21187
+ const dto = {};
21188
+ if (request.updateCapacities !== void 0) {
21189
+ dto.update_capacities = request.updateCapacities.map(
21190
+ EdgeCapacityUpdateFromFrontToApi
21191
+ );
21192
+ }
21193
+ if (request.addEdges !== void 0) {
21194
+ dto.add_edges = request.addEdges.map(EdgeSpecFromFrontToApi);
21195
+ }
21196
+ return dto;
21197
+ }
21198
+ function SolveFlowNetworkRequestFromFrontToApi(request) {
21199
+ return { algorithm: request.algorithm };
21200
+ }
21201
+ function FlowNetworkResponseFromApiToFront(dto) {
21202
+ return {
21203
+ id: dto.id,
21204
+ source: dto.source,
21205
+ sink: dto.sink,
21206
+ nodeCount: dto.node_count,
21207
+ edgeCount: dto.edge_count,
21208
+ description: dto.description ?? void 0
21209
+ };
21210
+ }
21211
+ function EdgeFlowFromApiToFront(dto) {
21212
+ return {
21213
+ from: dto.from,
21214
+ to: dto.to,
21215
+ label: dto.label ?? void 0,
21216
+ capacity: dto.capacity,
21217
+ flow: dto.flow
21218
+ };
21219
+ }
21220
+ function EdgeClassificationFromApiToFront(dto) {
21221
+ return {
21222
+ from: dto.from,
21223
+ to: dto.to,
21224
+ label: dto.label ?? void 0,
21225
+ class: dto.class
21226
+ };
21227
+ }
21228
+ function MinCutFromApiToFront(dto) {
21229
+ return {
21230
+ sourceSide: dto.source_side,
21231
+ sinkSide: dto.sink_side,
21232
+ cutEdges: dto.cut_edges.map(EdgeFlowFromApiToFront)
21233
+ };
21234
+ }
21235
+ function SolveFlowNetworkResponseFromApiToFront(dto) {
21236
+ const wireClassifications = dto.classifications;
21237
+ return {
21238
+ algorithm: dto.algorithm,
21239
+ edgeFlows: dto.edge_flows.map(EdgeFlowFromApiToFront),
21240
+ totalFlow: dto.total_flow ?? void 0,
21241
+ totalCost: dto.total_cost ?? void 0,
21242
+ classifications: wireClassifications ? wireClassifications.map(EdgeClassificationFromApiToFront) : void 0,
21243
+ minCut: dto.min_cut ? MinCutFromApiToFront(dto.min_cut) : void 0
21244
+ };
21245
+ }
21246
+
21247
+ // src/resources/flow-networks.ts
21248
+ var FlowNetworksClient = class {
21249
+ /** @internal */
21250
+ api;
21251
+ /** @internal */
21252
+ constructor(api) {
21253
+ this.api = api;
21254
+ }
21255
+ /**
21256
+ * Create and persist a new flow network.
21257
+ *
21258
+ * @param request - graph shape, source/sink, and initial edges.
21259
+ * @returns metadata for the new network (including its id).
21260
+ * @throws HTTP 400 if the input is malformed (duplicate node names,
21261
+ * source/sink not in `nodes`, edges referencing unknown nodes,
21262
+ * negative capacities, duplicate edge labels).
21263
+ */
21264
+ async create(request) {
21265
+ const response = await this.api.createFlowNetwork(
21266
+ CreateFlowNetworkRequestFromFrontToApi(request)
21267
+ );
21268
+ return FlowNetworkResponseFromApiToFront(response.data);
21269
+ }
21270
+ /**
21271
+ * Fetch the current status snapshot of a flow network.
21272
+ *
21273
+ * @throws HTTP 404 if the id is unknown.
21274
+ */
21275
+ async get(networkId) {
21276
+ const response = await this.api.getFlowNetwork(networkId);
21277
+ return FlowNetworkResponseFromApiToFront(response.data);
21278
+ }
21279
+ /**
21280
+ * Clone an existing flow network for what-if analysis. The clone
21281
+ * receives a new id and its own mutable graph; the original is
21282
+ * unaffected.
21283
+ *
21284
+ * @throws HTTP 404 if the id is unknown.
21285
+ */
21286
+ async clone(networkId) {
21287
+ const response = await this.api.cloneFlowNetwork(networkId);
21288
+ return FlowNetworkResponseFromApiToFront(response.data);
21289
+ }
21290
+ /**
21291
+ * Apply structural mutations to an existing network: replace
21292
+ * capacities of labelled edges and/or append new edges. Both
21293
+ * fields on the request are optional; capacity updates apply
21294
+ * before new edges are added.
21295
+ *
21296
+ * @throws HTTP 400 if a referenced label is unknown, an appended
21297
+ * edge references undeclared nodes, or capacities are negative.
21298
+ * @throws HTTP 404 if the id is unknown.
21299
+ */
21300
+ async commit(networkId, request) {
21301
+ const response = await this.api.commitFlowNetwork(
21302
+ networkId,
21303
+ CommitFlowNetworkRequestFromFrontToApi(request)
21304
+ );
21305
+ return FlowNetworkResponseFromApiToFront(response.data);
21306
+ }
21307
+ /**
21308
+ * Run the chosen algorithm against the persisted network.
21309
+ *
21310
+ * @remarks
21311
+ * The response shape narrows per algorithm:
21312
+ *
21313
+ * - `max_flow` — `totalFlow` + `edgeFlows`.
21314
+ * - `min_cost_max_flow` — `totalFlow`, `totalCost`, `edgeFlows`.
21315
+ * - `classify_edges` / `classify_edges_optimal` — `classifications`.
21316
+ * - `min_cut` — `totalFlow`, `edgeFlows`, `minCut`.
21317
+ *
21318
+ * Fields irrelevant to the chosen algorithm are `undefined`.
21319
+ *
21320
+ * @throws HTTP 404 if the id is unknown.
21321
+ */
21322
+ async solve(networkId, request) {
21323
+ const response = await this.api.solveFlowNetwork(
21324
+ networkId,
21325
+ SolveFlowNetworkRequestFromFrontToApi(request)
21326
+ );
21327
+ return SolveFlowNetworkResponseFromApiToFront(response.data);
21328
+ }
21329
+ };
21330
+
21078
21331
  // src/normalizers/osfql.ts
21079
21332
  function OsfqlResponseFromApiToFront(dto) {
21080
21333
  return {
@@ -22464,6 +22717,8 @@ var ReasoningLayerClient = class {
22464
22717
  optimize;
22465
22718
  /** Scheduling feasibility via capacitated bipartite b-matching (staff rostering, assignment problems). */
22466
22719
  scheduling;
22720
+ /** Generic flow-network resource: max-flow, min-cost max-flow, edge classification, min-cut over a persisted graph. */
22721
+ flowNetworks;
22467
22722
  /** OSFQL execution operations. */
22468
22723
  osfql;
22469
22724
  /** Conversational AI operations (NL → OSFQL with self-correction). */
@@ -22543,11 +22798,12 @@ var ReasoningLayerClient = class {
22543
22798
  rlTraining: this.rlTraining
22544
22799
  };
22545
22800
  }
22546
- /** Advanced reasoning operations — optimization, ILP, CDL, execution, preferences, discovery, scheduling. */
22801
+ /** Advanced reasoning operations — optimization, ILP, CDL, execution, preferences, discovery, scheduling, flow networks. */
22547
22802
  get reasoningOps() {
22548
22803
  return this._reasoning ??= {
22549
22804
  optimize: this.optimize,
22550
22805
  scheduling: this.scheduling,
22806
+ flowNetworks: this.flowNetworks,
22551
22807
  ilp: this.ilp,
22552
22808
  cdl: this.cdl,
22553
22809
  execution: this.execution,
@@ -22703,6 +22959,7 @@ var ReasoningLayerClient = class {
22703
22959
  this.rag = new RagClient(generatedRag);
22704
22960
  this.optimize = new OptimizeClient(generatedInference, generatedSorts, generatedQuery, generatedTerms, resolved.tenantId);
22705
22961
  this.scheduling = new SchedulingClient(new Scheduling(generatedHttp));
22962
+ this.flowNetworks = new FlowNetworksClient(new FlowNetworks(generatedHttp));
22706
22963
  this.osfql = new OsfqlClient(generatedOsfql);
22707
22964
  this.conversation = new ConversationClient(generatedHttp);
22708
22965
  this.research = new ResearchClient(generatedHttp);
@@ -22856,6 +23113,9 @@ __export(scheduling_exports, {
22856
23113
  });
22857
23114
  var ANY_ROLE = "any";
22858
23115
 
23116
+ // src/types/flow-networks.ts
23117
+ var flow_networks_exports = {};
23118
+
22859
23119
  // src/types/ilp.ts
22860
23120
  var ilp_exports = {};
22861
23121
 
@@ -23571,6 +23831,7 @@ exports.Conversation = conversation_exports;
23571
23831
  exports.Discovery = discovery_exports;
23572
23832
  exports.Execution = execution_exports;
23573
23833
  exports.Extract = extract_exports;
23834
+ exports.FlowNetworks = flow_networks_exports;
23574
23835
  exports.ForbiddenError = ForbiddenError;
23575
23836
  exports.Functions = functions_exports;
23576
23837
  exports.Fuzzy = fuzzy_exports;