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