@kortexya/reasoninglayer 0.20.0 → 0.21.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.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // src/config.ts
8
- var SDK_VERSION = "0.20.0";
8
+ var SDK_VERSION = "0.21.0";
9
9
  function resolveConfig(config) {
10
10
  if (!config.baseUrl) {
11
11
  throw new Error("ClientConfig.baseUrl is required");
@@ -955,11 +955,10 @@ var Sorts = class {
955
955
  ...params
956
956
  });
957
957
  /**
958
- * @description This enables semantic search over sort names for NER label pre-filtering. Must be called after bulk sort creation (e.g., after ontology hydration) to make sorts searchable via embedding similarity. Returns the number of sorts indexed.
958
+ * No description
959
959
  *
960
960
  * @tags sorts
961
961
  * @name IndexSorts
962
- * @summary Index all sorts for a tenant into the vector store (Qdrant).
963
962
  * @request POST:/api/v1/sorts/index
964
963
  * @secure
965
964
  */
@@ -7405,6 +7404,22 @@ var Scheduling = class {
7405
7404
  format: "json",
7406
7405
  ...params
7407
7406
  });
7407
+ /**
7408
+ * @description Same hard constraints as `/scheduling/feasibility` plus a list of soft `preferences` (each a per-cell score added to the optimizer's objective). Returns the per-cell trichotomy across the space of **optimal** schedules, plus `total_score` (sum of preference scores at chosen cells in the optimum). `confirmed_true` / `confirmed_false` here are stronger than in `/feasibility`: they hold across every optimum, not every feasible schedule. Cells with status `free` indicate ties — multiple optima exist and the cell varies between them. Preferences targeting cells that are already pinned, blocked by a day-off, restricted-to-shift, or otherwise structurally fixed are silently ignored — those cells are not the optimizer's choice to make.
7409
+ *
7410
+ * @tags scheduling
7411
+ * @name Optimize
7412
+ * @summary `POST /api/v1/scheduling/optimize`
7413
+ * @request POST:/api/v1/scheduling/optimize
7414
+ */
7415
+ optimize = (data, params = {}) => this.http.request({
7416
+ path: `/api/v1/scheduling/optimize`,
7417
+ method: "POST",
7418
+ body: data,
7419
+ type: "application/json" /* Json */,
7420
+ format: "json",
7421
+ ...params
7422
+ });
7408
7423
  };
7409
7424
 
7410
7425
  // src/api-spec/generated/Admin.ts
@@ -20534,6 +20549,36 @@ function SchedulingFeasibilityResponseFromApiToFront(dto) {
20534
20549
  assignments: dto.assignments.map(AssignmentFromApiToFront)
20535
20550
  };
20536
20551
  }
20552
+ function PreferenceFromFrontToApi(pref) {
20553
+ return {
20554
+ agent_id: pref.agentId,
20555
+ day: pref.day,
20556
+ shift: pref.shift,
20557
+ score: pref.score
20558
+ };
20559
+ }
20560
+ function SchedulingOptimizeRequestFromFrontToApi(request) {
20561
+ const dto = {
20562
+ agents: request.agents.map(AgentSpecFromFrontToApi),
20563
+ days: request.days,
20564
+ shifts_per_day: request.shiftsPerDay,
20565
+ demands: request.demands.map(ShiftDemandFromFrontToApi)
20566
+ };
20567
+ if (request.pins !== void 0) {
20568
+ dto.pins = request.pins.map(PinFromFrontToApi);
20569
+ }
20570
+ if (request.preferences !== void 0) {
20571
+ dto.preferences = request.preferences.map(PreferenceFromFrontToApi);
20572
+ }
20573
+ return dto;
20574
+ }
20575
+ function SchedulingOptimizeResponseFromApiToFront(dto) {
20576
+ return {
20577
+ status: dto.status,
20578
+ totalScore: dto.total_score,
20579
+ assignments: dto.assignments.map(AssignmentFromApiToFront)
20580
+ };
20581
+ }
20537
20582
 
20538
20583
  // src/resources/scheduling.ts
20539
20584
  var SchedulingClient = class {
@@ -20564,6 +20609,70 @@ var SchedulingClient = class {
20564
20609
  );
20565
20610
  return SchedulingFeasibilityResponseFromApiToFront(response.data);
20566
20611
  }
20612
+ /**
20613
+ * Solve the scheduling problem with **soft preferences** and
20614
+ * return the per-cell envelope across the space of *optimal*
20615
+ * schedules.
20616
+ *
20617
+ * @param request - the scheduling problem plus optional
20618
+ * `preferences` (per-cell scores added to the optimizer's
20619
+ * objective). Same hard-constraint shape as
20620
+ * {@link SchedulingClient.feasibility}.
20621
+ * @returns a {@link SchedulingOptimizeResponse} with `totalScore`
20622
+ * and per-cell trichotomy across optimal schedules.
20623
+ *
20624
+ * @throws HTTP 400 errors are surfaced when the input is malformed
20625
+ * (duplicate agent IDs, pins or preferences referencing unknown
20626
+ * agents, ambiguous pin role on multi-role agents, role minima
20627
+ * exceeding total demand, etc.).
20628
+ *
20629
+ * @remarks
20630
+ * The trichotomy returned here is **strictly stronger** than the
20631
+ * one from {@link SchedulingClient.feasibility}:
20632
+ *
20633
+ * - `"confirmed_true"` — assigned in *every* optimum.
20634
+ * - `"confirmed_false"` — assigned in *no* optimum.
20635
+ * - `"free"` — varies across the optima; the optimizer is indifferent
20636
+ * between equally-good choices.
20637
+ *
20638
+ * `totalScore` is the sum of {@link Preference.score} over assigned
20639
+ * cells in the optimum (`0` when no preferences are supplied or
20640
+ * the problem is infeasible).
20641
+ *
20642
+ * Preferences targeting structurally-fixed cells (pinned cells,
20643
+ * day-off / shift-only restricted cells, agents not in the grid)
20644
+ * are silently ignored — the optimizer has no choice to make there.
20645
+ *
20646
+ * Empty `preferences` is equivalent to calling
20647
+ * {@link SchedulingClient.feasibility} (every feasible schedule
20648
+ * is optimal under a zero objective), but slower; prefer
20649
+ * `feasibility()` when you only need the feasibility envelope.
20650
+ *
20651
+ * @example Score Aisha as a strong preference for emergency cover
20652
+ * ```typescript
20653
+ * const report = await client.scheduling.optimize({
20654
+ * agents: [
20655
+ * { id: 'aisha', roles: ['icu', 'emergency'], maxAssignments: 5 },
20656
+ * { id: 'bob', roles: ['general'], maxAssignments: 5 },
20657
+ * ],
20658
+ * days: 7,
20659
+ * shiftsPerDay: 3,
20660
+ * demands: [{ day: 0, shift: 0, total: 2, roleMinimums: { icu: 1 } }],
20661
+ * preferences: [
20662
+ * { agentId: 'aisha', day: 0, shift: 0, score: 10 },
20663
+ * ],
20664
+ * });
20665
+ *
20666
+ * console.log(report.totalScore); // 10 if Aisha is in the optimum
20667
+ * console.log(report.status); // 'feasible' | 'infeasible'
20668
+ * ```
20669
+ */
20670
+ async optimize(request) {
20671
+ const response = await this.api.optimize(
20672
+ SchedulingOptimizeRequestFromFrontToApi(request)
20673
+ );
20674
+ return SchedulingOptimizeResponseFromApiToFront(response.data);
20675
+ }
20567
20676
  };
20568
20677
 
20569
20678
  // src/normalizers/osfql.ts