@kortexya/reasoninglayer 1.1.0 → 1.2.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/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // src/config.ts
8
- var SDK_VERSION = "1.1.0";
8
+ var SDK_VERSION = "1.2.1";
9
9
  function resolveConfig(config) {
10
10
  if (!config.baseUrl) {
11
11
  throw new Error("ClientConfig.baseUrl is required");
@@ -7651,6 +7651,100 @@ var Scheduling = class {
7651
7651
  });
7652
7652
  };
7653
7653
 
7654
+ // src/api-spec/generated/FlowNetworks.ts
7655
+ var FlowNetworks = class {
7656
+ http;
7657
+ constructor(http) {
7658
+ this.http = http;
7659
+ }
7660
+ /**
7661
+ * No description
7662
+ *
7663
+ * @tags flow-networks
7664
+ * @name CloneFlowNetwork
7665
+ * @summary Clone a flow network for what-if analysis.
7666
+ * @request POST:/api/v1/flow-networks/{network_id}/clone
7667
+ * @secure
7668
+ */
7669
+ cloneFlowNetwork = (networkId, params = {}) => this.http.request({
7670
+ path: `/api/v1/flow-networks/${networkId}/clone`,
7671
+ method: "POST",
7672
+ secure: true,
7673
+ format: "json",
7674
+ ...params
7675
+ });
7676
+ /**
7677
+ * No description
7678
+ *
7679
+ * @tags flow-networks
7680
+ * @name CommitFlowNetwork
7681
+ * @summary Commit structural mutations (capacity updates and/or new edges).
7682
+ * @request POST:/api/v1/flow-networks/{network_id}/commit
7683
+ * @secure
7684
+ */
7685
+ commitFlowNetwork = (networkId, data, params = {}) => this.http.request({
7686
+ path: `/api/v1/flow-networks/${networkId}/commit`,
7687
+ method: "POST",
7688
+ body: data,
7689
+ secure: true,
7690
+ type: "application/json" /* Json */,
7691
+ format: "json",
7692
+ ...params
7693
+ });
7694
+ /**
7695
+ * No description
7696
+ *
7697
+ * @tags flow-networks
7698
+ * @name CreateFlowNetwork
7699
+ * @summary Create a new flow network.
7700
+ * @request POST:/api/v1/flow-networks
7701
+ * @secure
7702
+ */
7703
+ createFlowNetwork = (data, params = {}) => this.http.request({
7704
+ path: `/api/v1/flow-networks`,
7705
+ method: "POST",
7706
+ body: data,
7707
+ secure: true,
7708
+ type: "application/json" /* Json */,
7709
+ format: "json",
7710
+ ...params
7711
+ });
7712
+ /**
7713
+ * No description
7714
+ *
7715
+ * @tags flow-networks
7716
+ * @name GetFlowNetwork
7717
+ * @summary Get a flow network's status.
7718
+ * @request GET:/api/v1/flow-networks/{network_id}
7719
+ * @secure
7720
+ */
7721
+ getFlowNetwork = (networkId, params = {}) => this.http.request({
7722
+ path: `/api/v1/flow-networks/${networkId}`,
7723
+ method: "GET",
7724
+ secure: true,
7725
+ format: "json",
7726
+ ...params
7727
+ });
7728
+ /**
7729
+ * No description
7730
+ *
7731
+ * @tags flow-networks
7732
+ * @name SolveFlowNetwork
7733
+ * @summary Solve a flow network with the chosen algorithm.
7734
+ * @request POST:/api/v1/flow-networks/{network_id}/solve
7735
+ * @secure
7736
+ */
7737
+ solveFlowNetwork = (networkId, data, params = {}) => this.http.request({
7738
+ path: `/api/v1/flow-networks/${networkId}/solve`,
7739
+ method: "POST",
7740
+ body: data,
7741
+ secure: true,
7742
+ type: "application/json" /* Json */,
7743
+ format: "json",
7744
+ ...params
7745
+ });
7746
+ };
7747
+
7654
7748
  // src/api-spec/generated/Admin.ts
7655
7749
  var Admin = class {
7656
7750
  http;
@@ -9512,19 +9606,10 @@ function ConstraintInputDtoFromFrontToApi(model) {
9512
9606
  }
9513
9607
  }
9514
9608
  function BackwardChainResponseFromApiToFront(dto) {
9515
- const wireRefs = dto.referenced_terms;
9516
- let referencedTerms;
9517
- if (wireRefs) {
9518
- referencedTerms = {};
9519
- for (const [uuid, term] of Object.entries(wireRefs)) {
9520
- referencedTerms[uuid] = TermDtoFromApiToFront(term);
9521
- }
9522
- }
9523
9609
  return {
9524
9610
  solutions: dto.solutions.map(SolutionDtoFromApiToFront),
9525
9611
  queryTimeMs: dto.query_time_ms,
9526
- goalId: dto.goal_id ?? void 0,
9527
- referencedTerms
9612
+ goalId: dto.goal_id ?? void 0
9528
9613
  };
9529
9614
  }
9530
9615
  function ForwardChainResponseFromApiToFront(dto) {
@@ -9896,8 +9981,7 @@ function BackwardChainRequestFromFrontToApi(model) {
9896
9981
  max_solutions: model.maxSolutions,
9897
9982
  min_certainty: model.minCertainty,
9898
9983
  timeout_ms: model.timeoutMs ?? void 0,
9899
- constraints: model.constraints?.map(ConstraintInputDtoFromFrontToApi),
9900
- expand_bindings: model.expandBindings
9984
+ constraints: model.constraints?.map(ConstraintInputDtoFromFrontToApi)
9901
9985
  };
9902
9986
  }
9903
9987
  function ForwardChainRequestFromFrontToApi(model) {
@@ -10050,12 +10134,6 @@ var InferenceClient = class {
10050
10134
  *
10051
10135
  * The `timeout_ms` field on the request is a wall-clock timeout for the search.
10052
10136
  * When it fires, the backend returns whatever solutions have been found so far.
10053
- *
10054
- * Pass `expandBindings: true` to receive the full {@link TermDto} of every
10055
- * Ψ-term transitively referenced by a solution's bindings in the
10056
- * `referencedTerms` sidecar map of the response. Lets the caller read complex
10057
- * bound values (lists of nested Ψ-terms etc.) without follow-up
10058
- * `terms.get(uuid)` calls.
10059
10137
  */
10060
10138
  async backwardChain(request) {
10061
10139
  const wireRequest = {
@@ -21073,6 +21151,181 @@ var SchedulingClient = class {
21073
21151
  }
21074
21152
  };
21075
21153
 
21154
+ // src/normalizers/flow-networks.ts
21155
+ function EdgeSpecFromFrontToApi(edge) {
21156
+ const dto = {
21157
+ from: edge.from,
21158
+ to: edge.to,
21159
+ capacity: edge.capacity
21160
+ };
21161
+ if (edge.cost !== void 0 && edge.cost !== null) {
21162
+ dto.cost = edge.cost;
21163
+ }
21164
+ if (edge.label !== void 0 && edge.label !== null) {
21165
+ dto.label = edge.label;
21166
+ }
21167
+ return dto;
21168
+ }
21169
+ function EdgeCapacityUpdateFromFrontToApi(update) {
21170
+ return { label: update.label, capacity: update.capacity };
21171
+ }
21172
+ function CreateFlowNetworkRequestFromFrontToApi(request) {
21173
+ const dto = {
21174
+ nodes: request.nodes,
21175
+ source: request.source,
21176
+ sink: request.sink,
21177
+ edges: request.edges.map(EdgeSpecFromFrontToApi)
21178
+ };
21179
+ if (request.description !== void 0 && request.description !== null) {
21180
+ dto.description = request.description;
21181
+ }
21182
+ return dto;
21183
+ }
21184
+ function CommitFlowNetworkRequestFromFrontToApi(request) {
21185
+ const dto = {};
21186
+ if (request.updateCapacities !== void 0) {
21187
+ dto.update_capacities = request.updateCapacities.map(
21188
+ EdgeCapacityUpdateFromFrontToApi
21189
+ );
21190
+ }
21191
+ if (request.addEdges !== void 0) {
21192
+ dto.add_edges = request.addEdges.map(EdgeSpecFromFrontToApi);
21193
+ }
21194
+ return dto;
21195
+ }
21196
+ function SolveFlowNetworkRequestFromFrontToApi(request) {
21197
+ return { algorithm: request.algorithm };
21198
+ }
21199
+ function FlowNetworkResponseFromApiToFront(dto) {
21200
+ return {
21201
+ id: dto.id,
21202
+ source: dto.source,
21203
+ sink: dto.sink,
21204
+ nodeCount: dto.node_count,
21205
+ edgeCount: dto.edge_count,
21206
+ description: dto.description ?? void 0
21207
+ };
21208
+ }
21209
+ function EdgeFlowFromApiToFront(dto) {
21210
+ return {
21211
+ from: dto.from,
21212
+ to: dto.to,
21213
+ label: dto.label ?? void 0,
21214
+ capacity: dto.capacity,
21215
+ flow: dto.flow
21216
+ };
21217
+ }
21218
+ function EdgeClassificationFromApiToFront(dto) {
21219
+ return {
21220
+ from: dto.from,
21221
+ to: dto.to,
21222
+ label: dto.label ?? void 0,
21223
+ class: dto.class
21224
+ };
21225
+ }
21226
+ function MinCutFromApiToFront(dto) {
21227
+ return {
21228
+ sourceSide: dto.source_side,
21229
+ sinkSide: dto.sink_side,
21230
+ cutEdges: dto.cut_edges.map(EdgeFlowFromApiToFront)
21231
+ };
21232
+ }
21233
+ function SolveFlowNetworkResponseFromApiToFront(dto) {
21234
+ const wireClassifications = dto.classifications;
21235
+ return {
21236
+ algorithm: dto.algorithm,
21237
+ edgeFlows: dto.edge_flows.map(EdgeFlowFromApiToFront),
21238
+ totalFlow: dto.total_flow ?? void 0,
21239
+ totalCost: dto.total_cost ?? void 0,
21240
+ classifications: wireClassifications ? wireClassifications.map(EdgeClassificationFromApiToFront) : void 0,
21241
+ minCut: dto.min_cut ? MinCutFromApiToFront(dto.min_cut) : void 0
21242
+ };
21243
+ }
21244
+
21245
+ // src/resources/flow-networks.ts
21246
+ var FlowNetworksClient = class {
21247
+ /** @internal */
21248
+ api;
21249
+ /** @internal */
21250
+ constructor(api) {
21251
+ this.api = api;
21252
+ }
21253
+ /**
21254
+ * Create and persist a new flow network.
21255
+ *
21256
+ * @param request - graph shape, source/sink, and initial edges.
21257
+ * @returns metadata for the new network (including its id).
21258
+ * @throws HTTP 400 if the input is malformed (duplicate node names,
21259
+ * source/sink not in `nodes`, edges referencing unknown nodes,
21260
+ * negative capacities, duplicate edge labels).
21261
+ */
21262
+ async create(request) {
21263
+ const response = await this.api.createFlowNetwork(
21264
+ CreateFlowNetworkRequestFromFrontToApi(request)
21265
+ );
21266
+ return FlowNetworkResponseFromApiToFront(response.data);
21267
+ }
21268
+ /**
21269
+ * Fetch the current status snapshot of a flow network.
21270
+ *
21271
+ * @throws HTTP 404 if the id is unknown.
21272
+ */
21273
+ async get(networkId) {
21274
+ const response = await this.api.getFlowNetwork(networkId);
21275
+ return FlowNetworkResponseFromApiToFront(response.data);
21276
+ }
21277
+ /**
21278
+ * Clone an existing flow network for what-if analysis. The clone
21279
+ * receives a new id and its own mutable graph; the original is
21280
+ * unaffected.
21281
+ *
21282
+ * @throws HTTP 404 if the id is unknown.
21283
+ */
21284
+ async clone(networkId) {
21285
+ const response = await this.api.cloneFlowNetwork(networkId);
21286
+ return FlowNetworkResponseFromApiToFront(response.data);
21287
+ }
21288
+ /**
21289
+ * Apply structural mutations to an existing network: replace
21290
+ * capacities of labelled edges and/or append new edges. Both
21291
+ * fields on the request are optional; capacity updates apply
21292
+ * before new edges are added.
21293
+ *
21294
+ * @throws HTTP 400 if a referenced label is unknown, an appended
21295
+ * edge references undeclared nodes, or capacities are negative.
21296
+ * @throws HTTP 404 if the id is unknown.
21297
+ */
21298
+ async commit(networkId, request) {
21299
+ const response = await this.api.commitFlowNetwork(
21300
+ networkId,
21301
+ CommitFlowNetworkRequestFromFrontToApi(request)
21302
+ );
21303
+ return FlowNetworkResponseFromApiToFront(response.data);
21304
+ }
21305
+ /**
21306
+ * Run the chosen algorithm against the persisted network.
21307
+ *
21308
+ * @remarks
21309
+ * The response shape narrows per algorithm:
21310
+ *
21311
+ * - `max_flow` — `totalFlow` + `edgeFlows`.
21312
+ * - `min_cost_max_flow` — `totalFlow`, `totalCost`, `edgeFlows`.
21313
+ * - `classify_edges` / `classify_edges_optimal` — `classifications`.
21314
+ * - `min_cut` — `totalFlow`, `edgeFlows`, `minCut`.
21315
+ *
21316
+ * Fields irrelevant to the chosen algorithm are `undefined`.
21317
+ *
21318
+ * @throws HTTP 404 if the id is unknown.
21319
+ */
21320
+ async solve(networkId, request) {
21321
+ const response = await this.api.solveFlowNetwork(
21322
+ networkId,
21323
+ SolveFlowNetworkRequestFromFrontToApi(request)
21324
+ );
21325
+ return SolveFlowNetworkResponseFromApiToFront(response.data);
21326
+ }
21327
+ };
21328
+
21076
21329
  // src/normalizers/osfql.ts
21077
21330
  function OsfqlResponseFromApiToFront(dto) {
21078
21331
  return {
@@ -22462,6 +22715,8 @@ var ReasoningLayerClient = class {
22462
22715
  optimize;
22463
22716
  /** Scheduling feasibility via capacitated bipartite b-matching (staff rostering, assignment problems). */
22464
22717
  scheduling;
22718
+ /** Generic flow-network resource: max-flow, min-cost max-flow, edge classification, min-cut over a persisted graph. */
22719
+ flowNetworks;
22465
22720
  /** OSFQL execution operations. */
22466
22721
  osfql;
22467
22722
  /** Conversational AI operations (NL → OSFQL with self-correction). */
@@ -22541,11 +22796,12 @@ var ReasoningLayerClient = class {
22541
22796
  rlTraining: this.rlTraining
22542
22797
  };
22543
22798
  }
22544
- /** Advanced reasoning operations — optimization, ILP, CDL, execution, preferences, discovery, scheduling. */
22799
+ /** Advanced reasoning operations — optimization, ILP, CDL, execution, preferences, discovery, scheduling, flow networks. */
22545
22800
  get reasoningOps() {
22546
22801
  return this._reasoning ??= {
22547
22802
  optimize: this.optimize,
22548
22803
  scheduling: this.scheduling,
22804
+ flowNetworks: this.flowNetworks,
22549
22805
  ilp: this.ilp,
22550
22806
  cdl: this.cdl,
22551
22807
  execution: this.execution,
@@ -22701,6 +22957,7 @@ var ReasoningLayerClient = class {
22701
22957
  this.rag = new RagClient(generatedRag);
22702
22958
  this.optimize = new OptimizeClient(generatedInference, generatedSorts, generatedQuery, generatedTerms, resolved.tenantId);
22703
22959
  this.scheduling = new SchedulingClient(new Scheduling(generatedHttp));
22960
+ this.flowNetworks = new FlowNetworksClient(new FlowNetworks(generatedHttp));
22704
22961
  this.osfql = new OsfqlClient(generatedOsfql);
22705
22962
  this.conversation = new ConversationClient(generatedHttp);
22706
22963
  this.research = new ResearchClient(generatedHttp);
@@ -22854,6 +23111,9 @@ __export(scheduling_exports, {
22854
23111
  });
22855
23112
  var ANY_ROLE = "any";
22856
23113
 
23114
+ // src/types/flow-networks.ts
23115
+ var flow_networks_exports = {};
23116
+
22857
23117
  // src/types/ilp.ts
22858
23118
  var ilp_exports = {};
22859
23119
 
@@ -23549,6 +23809,6 @@ function discriminateFeatureValue(value) {
23549
23809
  );
23550
23810
  }
23551
23811
 
23552
- export { ANY_ROLE, action_reviews_exports as ActionReviews, admin_exports as Admin, analysis_exports as Analysis, ApiError, AuthenticationError, BadRequestError, cdl_exports as CDL, causal_exports as Causal, cognitive_exports as Cognitive, collections_exports as Collections, communities_exports as Communities, compliance_exports as Compliance, ConstraintViolationError, constraints_exports as Constraints, control_exports as Control, conversation_exports as Conversation, discovery_exports as Discovery, execution_exports as Execution, extract_exports as Extract, ForbiddenError, functions_exports as Functions, fuzzy_exports as Fuzzy, FuzzyShape, generation_exports as Generation, health_exports as Health, homoiconic_exports as Homoiconic, ilp_exports as ILP, image_extraction_exports as ImageExtraction, inference_exports as Inference, ingestion_exports as Ingestion, IngestionFailedError, IngestionSession, InternalServerError, LP, namespaces_exports as Namespaces, NetworkError, neuro_symbolic_exports as NeuroSymbolic, NotFoundError, ontology_exports as Ontology, operations_exports as Operations, optimize_exports as Optimize, osfql_exports as Osfql, oversight_exports as Oversight, plain_values_exports as PlainValues, preferences_exports as Preferences, proof_engine_exports as ProofEngine, query_exports as Query, rag_exports as RAG, RateLimitError, reasoning_exports as Reasoning, ReasoningLayerClient, ReasoningLayerError, research_exports as Research, reviews_exports as Reviews, row_exports as Row, SDK_VERSION, scenarios_exports as Scenarios, scheduling_exports as Scheduling, SortBuilder, sorts_exports as Sorts, sources_exports as Sources, spaces_exports as Spaces, statistical_exports as Statistical, synthetic_exports as Synthetic, terms_exports as Terms, TimeoutError, utilities_exports as Utilities, ValidationError, Value, values_exports as Values, visualization_exports as Visualization, WebSocketClient, WebSocketConnection, webhook_actions_exports as WebhookActions, allen, constrained, discriminateFeatureValue, guard, isConstrainedPlainVar, isPsiTermInput, isTaggedValueDto, isUuid, psi, toTaggedFeatures, toTaggedValue, toTermInputDto, toUntaggedFeatures, toUntaggedValue };
23812
+ export { ANY_ROLE, action_reviews_exports as ActionReviews, admin_exports as Admin, analysis_exports as Analysis, ApiError, AuthenticationError, BadRequestError, cdl_exports as CDL, causal_exports as Causal, cognitive_exports as Cognitive, collections_exports as Collections, communities_exports as Communities, compliance_exports as Compliance, ConstraintViolationError, constraints_exports as Constraints, control_exports as Control, conversation_exports as Conversation, discovery_exports as Discovery, execution_exports as Execution, extract_exports as Extract, flow_networks_exports as FlowNetworks, ForbiddenError, functions_exports as Functions, fuzzy_exports as Fuzzy, FuzzyShape, generation_exports as Generation, health_exports as Health, homoiconic_exports as Homoiconic, ilp_exports as ILP, image_extraction_exports as ImageExtraction, inference_exports as Inference, ingestion_exports as Ingestion, IngestionFailedError, IngestionSession, InternalServerError, LP, namespaces_exports as Namespaces, NetworkError, neuro_symbolic_exports as NeuroSymbolic, NotFoundError, ontology_exports as Ontology, operations_exports as Operations, optimize_exports as Optimize, osfql_exports as Osfql, oversight_exports as Oversight, plain_values_exports as PlainValues, preferences_exports as Preferences, proof_engine_exports as ProofEngine, query_exports as Query, rag_exports as RAG, RateLimitError, reasoning_exports as Reasoning, ReasoningLayerClient, ReasoningLayerError, research_exports as Research, reviews_exports as Reviews, row_exports as Row, SDK_VERSION, scenarios_exports as Scenarios, scheduling_exports as Scheduling, SortBuilder, sorts_exports as Sorts, sources_exports as Sources, spaces_exports as Spaces, statistical_exports as Statistical, synthetic_exports as Synthetic, terms_exports as Terms, TimeoutError, utilities_exports as Utilities, ValidationError, Value, values_exports as Values, visualization_exports as Visualization, WebSocketClient, WebSocketConnection, webhook_actions_exports as WebhookActions, allen, constrained, discriminateFeatureValue, guard, isConstrainedPlainVar, isPsiTermInput, isTaggedValueDto, isUuid, psi, toTaggedFeatures, toTaggedValue, toTermInputDto, toUntaggedFeatures, toUntaggedValue };
23553
23813
  //# sourceMappingURL=index.js.map
23554
23814
  //# sourceMappingURL=index.js.map