@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.d.cts CHANGED
@@ -109,7 +109,7 @@ type JsonValue$1 = string | number | boolean | null | JsonValue$1[] | object;
109
109
  * This is the single source of truth for the version constant.
110
110
  * The `scripts/release.sh` script updates this value alongside `package.json`.
111
111
  */
112
- declare const SDK_VERSION = "0.20.0";
112
+ declare const SDK_VERSION = "0.21.0";
113
113
  /**
114
114
  * Configuration for the Reasoning Layer client.
115
115
  *
@@ -11812,6 +11812,31 @@ interface PreferenceDto$1 {
11812
11812
  /** Preference value. */
11813
11813
  value: string;
11814
11814
  }
11815
+ /**
11816
+ * A soft preference: bias the optimizer toward (or against) assigning
11817
+ * `agent_id` to cell `(day, shift)`.
11818
+ *
11819
+ * `score` contributes to the objective when the cell is assigned in
11820
+ * the chosen schedule. Positive values pull the optimizer toward
11821
+ * the cell; negative values push it away. Preferences targeting a
11822
+ * pinned cell, an agent with a day-off on `day`, or an agent
11823
+ * otherwise blocked from the slot are silently ignored — the
11824
+ * corresponding decision edge does not exist in the reduced flow
11825
+ * graph.
11826
+ */
11827
+ interface PreferenceInput {
11828
+ agent_id: string;
11829
+ /** @min 0 */
11830
+ day: number;
11831
+ /**
11832
+ * Score contributed by this assignment to the optimizer's
11833
+ * objective. Positive = preferred, negative = avoided.
11834
+ * @format int64
11835
+ */
11836
+ score: number;
11837
+ /** @min 0 */
11838
+ shift: number;
11839
+ }
11815
11840
  /** Prediction result for a single term */
11816
11841
  interface PreferencePrediction$1 {
11817
11842
  /** @format double */
@@ -13741,6 +13766,56 @@ interface SchedulingFeasibilityResponse$1 {
13741
13766
  /** Top-level request status. */
13742
13767
  status: SchedulingStatusDto;
13743
13768
  }
13769
+ /**
13770
+ * Request body for `POST /api/v1/scheduling/optimize`.
13771
+ *
13772
+ * Same hard-constraint shape as
13773
+ * [`SchedulingFeasibilityRequest`], plus a list of soft
13774
+ * `preferences`. The engine returns the per-cell envelope across
13775
+ * the space of **optimal** schedules under the supplied
13776
+ * preferences.
13777
+ */
13778
+ interface SchedulingOptimizeRequest$1 {
13779
+ agents: AgentInput[];
13780
+ /** @min 0 */
13781
+ days: number;
13782
+ demands: ShiftDemandInput[];
13783
+ pins?: PinInput[];
13784
+ /**
13785
+ * Soft preferences applied to the objective. Empty = unweighted
13786
+ * (every feasible schedule is "optimal").
13787
+ */
13788
+ preferences?: PreferenceInput[];
13789
+ /** @min 0 */
13790
+ shifts_per_day: number;
13791
+ }
13792
+ /**
13793
+ * Response to [`SchedulingOptimizeRequest`].
13794
+ *
13795
+ * The per-cell `assignments` trichotomy classifies each cell over
13796
+ * the space of **optimal** schedules — strictly stronger than the
13797
+ * feasibility-only trichotomy returned by
13798
+ * `/api/v1/scheduling/feasibility`. When the un-pinned reduced
13799
+ * problem is infeasible, `status = "infeasible"`, `assignments` is
13800
+ * empty, and `total_score` is `0`.
13801
+ */
13802
+ interface SchedulingOptimizeResponse$1 {
13803
+ /**
13804
+ * Empty when `status` is `infeasible`; otherwise one entry per
13805
+ * `(agent, day, shift)` triple in the input grid, with
13806
+ * trichotomy taken across the space of optimal schedules.
13807
+ */
13808
+ assignments: AssignmentDto[];
13809
+ /** Top-level request status. */
13810
+ status: SchedulingStatusDto;
13811
+ /**
13812
+ * Sum of [`PreferenceInput::score`] over assigned cells in the
13813
+ * optimum. `0` when no preferences were supplied or the
13814
+ * problem is infeasible.
13815
+ * @format int64
13816
+ */
13817
+ total_score: number;
13818
+ }
13744
13819
  /** Top-level request status. */
13745
13820
  type SchedulingStatusDto = "feasible" | "infeasible";
13746
13821
  /** Request to search communities */
@@ -16927,11 +17002,10 @@ declare class Sorts<SecurityDataType = unknown> {
16927
17002
  */
16928
17003
  getSortSimilarity: (data: GetSortSimilarityRequest$1, params?: RequestParams) => Promise<HttpResponse<GetSortSimilarityResponse$1, any>>;
16929
17004
  /**
16930
- * @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.
17005
+ * No description
16931
17006
  *
16932
17007
  * @tags sorts
16933
17008
  * @name IndexSorts
16934
- * @summary Index all sorts for a tenant into the vector store (Qdrant).
16935
17009
  * @request POST:/api/v1/sorts/index
16936
17010
  * @secure
16937
17011
  */
@@ -16988,6 +17062,12 @@ declare class Sorts<SecurityDataType = unknown> {
16988
17062
  limit?: number | null;
16989
17063
  /** Filter to only show LLM-extracted sorts */
16990
17064
  llm_extracted?: boolean | null;
17065
+ /**
17066
+ * Filter to sorts whose name starts with this prefix.
17067
+ * Supports comma-separated multiple prefixes (e.g. "drug_,target_,pathway_,disease_").
17068
+ * Server-side filtering avoids transferring millions of irrelevant sorts.
17069
+ */
17070
+ name_prefix?: string | null;
16991
17071
  /** Filter to only show sorts needing review */
16992
17072
  needs_review?: boolean | null;
16993
17073
  /**
@@ -39298,6 +39378,15 @@ declare class Scheduling<SecurityDataType = unknown> {
39298
39378
  * @request POST:/api/v1/scheduling/feasibility
39299
39379
  */
39300
39380
  feasibility: (data: SchedulingFeasibilityRequest$1, params?: RequestParams) => Promise<HttpResponse<SchedulingFeasibilityResponse$1, void>>;
39381
+ /**
39382
+ * @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.
39383
+ *
39384
+ * @tags scheduling
39385
+ * @name Optimize
39386
+ * @summary `POST /api/v1/scheduling/optimize`
39387
+ * @request POST:/api/v1/scheduling/optimize
39388
+ */
39389
+ optimize: (data: SchedulingOptimizeRequest$1, params?: RequestParams) => Promise<HttpResponse<SchedulingOptimizeResponse$1, void>>;
39301
39390
  }
39302
39391
 
39303
39392
  /**
@@ -39456,18 +39545,106 @@ interface SchedulingFeasibilityResponse {
39456
39545
  status: SchedulingStatus;
39457
39546
  assignments: Assignment[];
39458
39547
  }
39548
+ /**
39549
+ * A soft preference: bias the optimizer toward (or against) assigning
39550
+ * `agentId` to cell `(day, shift)`.
39551
+ *
39552
+ * @remarks
39553
+ * `score` contributes to the optimizer's objective when the cell is
39554
+ * assigned in the chosen schedule. Positive values pull the optimizer
39555
+ * toward the cell; negative values push it away.
39556
+ *
39557
+ * Preferences targeting a cell that is already pinned, blocked by a
39558
+ * day-off, restricted-to-shift, or otherwise structurally fixed are
39559
+ * silently ignored — those cells are not the optimizer's choice to
39560
+ * make.
39561
+ *
39562
+ * Common encodings:
39563
+ * - "Aisha prefers morning shifts" → `score = +5` on every
39564
+ * `(aisha, day, morning)` pair
39565
+ * - "Avoid weekend assignments" → `score = -3` on every
39566
+ * `(*, sat|sun, *)` pair
39567
+ * - "Honor day-off requests" → `score = -100` on
39568
+ * `(agent, requested_off_day, *)` (large negative penalty —
39569
+ * respects the request when feasible, lets the engine decide
39570
+ * when not)
39571
+ */
39572
+ interface Preference {
39573
+ agentId: string;
39574
+ day: number;
39575
+ shift: number;
39576
+ /**
39577
+ * Score added to the objective when this cell is assigned in the
39578
+ * chosen schedule. Positive = preferred, negative = avoided.
39579
+ */
39580
+ score: number;
39581
+ }
39582
+ /**
39583
+ * Input to {@link SchedulingClient.optimize}.
39584
+ *
39585
+ * @remarks
39586
+ * Same hard-constraint shape as {@link SchedulingFeasibilityRequest}
39587
+ * plus a list of soft `preferences`. The engine returns the per-cell
39588
+ * envelope across the space of **optimal** schedules under the
39589
+ * supplied preferences.
39590
+ */
39591
+ interface SchedulingOptimizeRequest {
39592
+ agents: AgentSpec[];
39593
+ days: number;
39594
+ shiftsPerDay: number;
39595
+ demands: ShiftDemand[];
39596
+ /** Pre-assigned `(agent, day, shift)` triples. Defaults to empty. */
39597
+ pins?: Pin[];
39598
+ /**
39599
+ * Soft preferences applied to the objective. Empty (or omitted) =
39600
+ * unweighted: every feasible schedule is "optimal" and the result
39601
+ * coincides with {@link SchedulingClient.feasibility}.
39602
+ */
39603
+ preferences?: Preference[];
39604
+ }
39605
+ /**
39606
+ * Response from {@link SchedulingClient.optimize}.
39607
+ *
39608
+ * @remarks
39609
+ * The per-cell `assignments` trichotomy classifies each cell over the
39610
+ * space of **optimal** schedules — strictly stronger than the
39611
+ * feasibility-only trichotomy from
39612
+ * {@link SchedulingClient.feasibility}:
39613
+ *
39614
+ * - `"confirmed_true"` — assigned in *every* optimal schedule.
39615
+ * - `"confirmed_false"` — assigned in *no* optimal schedule.
39616
+ * - `"free"` — varies across the (possibly multiple) optimal
39617
+ * schedules; the optimizer is indifferent.
39618
+ *
39619
+ * `totalScore` is the sum of {@link Preference.score} over assigned
39620
+ * cells in the optimum. It is `0` when no preferences were supplied
39621
+ * or the problem is infeasible.
39622
+ */
39623
+ interface SchedulingOptimizeResponse {
39624
+ status: SchedulingStatus;
39625
+ /** Sum of preference scores at chosen cells in the optimum. */
39626
+ totalScore: number;
39627
+ /**
39628
+ * Empty when `status === "infeasible"`; otherwise one entry per
39629
+ * `(agent, day, shift)` triple in the input grid.
39630
+ */
39631
+ assignments: Assignment[];
39632
+ }
39459
39633
 
39460
39634
  declare const scheduling_ANY_ROLE: typeof ANY_ROLE;
39461
39635
  type scheduling_AgentSpec = AgentSpec;
39462
39636
  type scheduling_Assignment = Assignment;
39463
39637
  type scheduling_AssignmentStatus = AssignmentStatus;
39464
39638
  type scheduling_Pin = Pin;
39639
+ type scheduling_Preference = Preference;
39465
39640
  type scheduling_SchedulingFeasibilityRequest = SchedulingFeasibilityRequest;
39466
39641
  type scheduling_SchedulingFeasibilityResponse = SchedulingFeasibilityResponse;
39642
+ type scheduling_SchedulingOptimizeRequest = SchedulingOptimizeRequest;
39643
+ type scheduling_SchedulingOptimizeResponse = SchedulingOptimizeResponse;
39467
39644
  type scheduling_SchedulingStatus = SchedulingStatus;
39468
39645
  type scheduling_ShiftDemand = ShiftDemand;
39469
39646
  declare namespace scheduling {
39470
- export { scheduling_ANY_ROLE as ANY_ROLE, type scheduling_AgentSpec as AgentSpec, type scheduling_Assignment as Assignment, type scheduling_AssignmentStatus as AssignmentStatus, type scheduling_Pin as Pin, type scheduling_SchedulingFeasibilityRequest as SchedulingFeasibilityRequest, type scheduling_SchedulingFeasibilityResponse as SchedulingFeasibilityResponse, type scheduling_SchedulingStatus as SchedulingStatus, type scheduling_ShiftDemand as ShiftDemand };
39647
+ export { scheduling_ANY_ROLE as ANY_ROLE, type scheduling_AgentSpec as AgentSpec, type scheduling_Assignment as Assignment, type scheduling_AssignmentStatus as AssignmentStatus, type scheduling_Pin as Pin, type scheduling_Preference as Preference, type scheduling_SchedulingFeasibilityRequest as SchedulingFeasibilityRequest, type scheduling_SchedulingFeasibilityResponse as SchedulingFeasibilityResponse, type scheduling_SchedulingOptimizeRequest as SchedulingOptimizeRequest, type scheduling_SchedulingOptimizeResponse as SchedulingOptimizeResponse, type scheduling_SchedulingStatus as SchedulingStatus, type scheduling_ShiftDemand as ShiftDemand };
39471
39648
  }
39472
39649
 
39473
39650
  /**
@@ -39539,6 +39716,65 @@ declare class SchedulingClient {
39539
39716
  * raises.
39540
39717
  */
39541
39718
  feasibility(request: SchedulingFeasibilityRequest): Promise<SchedulingFeasibilityResponse>;
39719
+ /**
39720
+ * Solve the scheduling problem with **soft preferences** and
39721
+ * return the per-cell envelope across the space of *optimal*
39722
+ * schedules.
39723
+ *
39724
+ * @param request - the scheduling problem plus optional
39725
+ * `preferences` (per-cell scores added to the optimizer's
39726
+ * objective). Same hard-constraint shape as
39727
+ * {@link SchedulingClient.feasibility}.
39728
+ * @returns a {@link SchedulingOptimizeResponse} with `totalScore`
39729
+ * and per-cell trichotomy across optimal schedules.
39730
+ *
39731
+ * @throws HTTP 400 errors are surfaced when the input is malformed
39732
+ * (duplicate agent IDs, pins or preferences referencing unknown
39733
+ * agents, ambiguous pin role on multi-role agents, role minima
39734
+ * exceeding total demand, etc.).
39735
+ *
39736
+ * @remarks
39737
+ * The trichotomy returned here is **strictly stronger** than the
39738
+ * one from {@link SchedulingClient.feasibility}:
39739
+ *
39740
+ * - `"confirmed_true"` — assigned in *every* optimum.
39741
+ * - `"confirmed_false"` — assigned in *no* optimum.
39742
+ * - `"free"` — varies across the optima; the optimizer is indifferent
39743
+ * between equally-good choices.
39744
+ *
39745
+ * `totalScore` is the sum of {@link Preference.score} over assigned
39746
+ * cells in the optimum (`0` when no preferences are supplied or
39747
+ * the problem is infeasible).
39748
+ *
39749
+ * Preferences targeting structurally-fixed cells (pinned cells,
39750
+ * day-off / shift-only restricted cells, agents not in the grid)
39751
+ * are silently ignored — the optimizer has no choice to make there.
39752
+ *
39753
+ * Empty `preferences` is equivalent to calling
39754
+ * {@link SchedulingClient.feasibility} (every feasible schedule
39755
+ * is optimal under a zero objective), but slower; prefer
39756
+ * `feasibility()` when you only need the feasibility envelope.
39757
+ *
39758
+ * @example Score Aisha as a strong preference for emergency cover
39759
+ * ```typescript
39760
+ * const report = await client.scheduling.optimize({
39761
+ * agents: [
39762
+ * { id: 'aisha', roles: ['icu', 'emergency'], maxAssignments: 5 },
39763
+ * { id: 'bob', roles: ['general'], maxAssignments: 5 },
39764
+ * ],
39765
+ * days: 7,
39766
+ * shiftsPerDay: 3,
39767
+ * demands: [{ day: 0, shift: 0, total: 2, roleMinimums: { icu: 1 } }],
39768
+ * preferences: [
39769
+ * { agentId: 'aisha', day: 0, shift: 0, score: 10 },
39770
+ * ],
39771
+ * });
39772
+ *
39773
+ * console.log(report.totalScore); // 10 if Aisha is in the optimum
39774
+ * console.log(report.status); // 'feasible' | 'infeasible'
39775
+ * ```
39776
+ */
39777
+ optimize(request: SchedulingOptimizeRequest): Promise<SchedulingOptimizeResponse>;
39542
39778
  }
39543
39779
 
39544
39780
  declare class Osfql<SecurityDataType = unknown> {
package/dist/index.d.ts CHANGED
@@ -109,7 +109,7 @@ type JsonValue$1 = string | number | boolean | null | JsonValue$1[] | object;
109
109
  * This is the single source of truth for the version constant.
110
110
  * The `scripts/release.sh` script updates this value alongside `package.json`.
111
111
  */
112
- declare const SDK_VERSION = "0.20.0";
112
+ declare const SDK_VERSION = "0.21.0";
113
113
  /**
114
114
  * Configuration for the Reasoning Layer client.
115
115
  *
@@ -11812,6 +11812,31 @@ interface PreferenceDto$1 {
11812
11812
  /** Preference value. */
11813
11813
  value: string;
11814
11814
  }
11815
+ /**
11816
+ * A soft preference: bias the optimizer toward (or against) assigning
11817
+ * `agent_id` to cell `(day, shift)`.
11818
+ *
11819
+ * `score` contributes to the objective when the cell is assigned in
11820
+ * the chosen schedule. Positive values pull the optimizer toward
11821
+ * the cell; negative values push it away. Preferences targeting a
11822
+ * pinned cell, an agent with a day-off on `day`, or an agent
11823
+ * otherwise blocked from the slot are silently ignored — the
11824
+ * corresponding decision edge does not exist in the reduced flow
11825
+ * graph.
11826
+ */
11827
+ interface PreferenceInput {
11828
+ agent_id: string;
11829
+ /** @min 0 */
11830
+ day: number;
11831
+ /**
11832
+ * Score contributed by this assignment to the optimizer's
11833
+ * objective. Positive = preferred, negative = avoided.
11834
+ * @format int64
11835
+ */
11836
+ score: number;
11837
+ /** @min 0 */
11838
+ shift: number;
11839
+ }
11815
11840
  /** Prediction result for a single term */
11816
11841
  interface PreferencePrediction$1 {
11817
11842
  /** @format double */
@@ -13741,6 +13766,56 @@ interface SchedulingFeasibilityResponse$1 {
13741
13766
  /** Top-level request status. */
13742
13767
  status: SchedulingStatusDto;
13743
13768
  }
13769
+ /**
13770
+ * Request body for `POST /api/v1/scheduling/optimize`.
13771
+ *
13772
+ * Same hard-constraint shape as
13773
+ * [`SchedulingFeasibilityRequest`], plus a list of soft
13774
+ * `preferences`. The engine returns the per-cell envelope across
13775
+ * the space of **optimal** schedules under the supplied
13776
+ * preferences.
13777
+ */
13778
+ interface SchedulingOptimizeRequest$1 {
13779
+ agents: AgentInput[];
13780
+ /** @min 0 */
13781
+ days: number;
13782
+ demands: ShiftDemandInput[];
13783
+ pins?: PinInput[];
13784
+ /**
13785
+ * Soft preferences applied to the objective. Empty = unweighted
13786
+ * (every feasible schedule is "optimal").
13787
+ */
13788
+ preferences?: PreferenceInput[];
13789
+ /** @min 0 */
13790
+ shifts_per_day: number;
13791
+ }
13792
+ /**
13793
+ * Response to [`SchedulingOptimizeRequest`].
13794
+ *
13795
+ * The per-cell `assignments` trichotomy classifies each cell over
13796
+ * the space of **optimal** schedules — strictly stronger than the
13797
+ * feasibility-only trichotomy returned by
13798
+ * `/api/v1/scheduling/feasibility`. When the un-pinned reduced
13799
+ * problem is infeasible, `status = "infeasible"`, `assignments` is
13800
+ * empty, and `total_score` is `0`.
13801
+ */
13802
+ interface SchedulingOptimizeResponse$1 {
13803
+ /**
13804
+ * Empty when `status` is `infeasible`; otherwise one entry per
13805
+ * `(agent, day, shift)` triple in the input grid, with
13806
+ * trichotomy taken across the space of optimal schedules.
13807
+ */
13808
+ assignments: AssignmentDto[];
13809
+ /** Top-level request status. */
13810
+ status: SchedulingStatusDto;
13811
+ /**
13812
+ * Sum of [`PreferenceInput::score`] over assigned cells in the
13813
+ * optimum. `0` when no preferences were supplied or the
13814
+ * problem is infeasible.
13815
+ * @format int64
13816
+ */
13817
+ total_score: number;
13818
+ }
13744
13819
  /** Top-level request status. */
13745
13820
  type SchedulingStatusDto = "feasible" | "infeasible";
13746
13821
  /** Request to search communities */
@@ -16927,11 +17002,10 @@ declare class Sorts<SecurityDataType = unknown> {
16927
17002
  */
16928
17003
  getSortSimilarity: (data: GetSortSimilarityRequest$1, params?: RequestParams) => Promise<HttpResponse<GetSortSimilarityResponse$1, any>>;
16929
17004
  /**
16930
- * @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.
17005
+ * No description
16931
17006
  *
16932
17007
  * @tags sorts
16933
17008
  * @name IndexSorts
16934
- * @summary Index all sorts for a tenant into the vector store (Qdrant).
16935
17009
  * @request POST:/api/v1/sorts/index
16936
17010
  * @secure
16937
17011
  */
@@ -16988,6 +17062,12 @@ declare class Sorts<SecurityDataType = unknown> {
16988
17062
  limit?: number | null;
16989
17063
  /** Filter to only show LLM-extracted sorts */
16990
17064
  llm_extracted?: boolean | null;
17065
+ /**
17066
+ * Filter to sorts whose name starts with this prefix.
17067
+ * Supports comma-separated multiple prefixes (e.g. "drug_,target_,pathway_,disease_").
17068
+ * Server-side filtering avoids transferring millions of irrelevant sorts.
17069
+ */
17070
+ name_prefix?: string | null;
16991
17071
  /** Filter to only show sorts needing review */
16992
17072
  needs_review?: boolean | null;
16993
17073
  /**
@@ -39298,6 +39378,15 @@ declare class Scheduling<SecurityDataType = unknown> {
39298
39378
  * @request POST:/api/v1/scheduling/feasibility
39299
39379
  */
39300
39380
  feasibility: (data: SchedulingFeasibilityRequest$1, params?: RequestParams) => Promise<HttpResponse<SchedulingFeasibilityResponse$1, void>>;
39381
+ /**
39382
+ * @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.
39383
+ *
39384
+ * @tags scheduling
39385
+ * @name Optimize
39386
+ * @summary `POST /api/v1/scheduling/optimize`
39387
+ * @request POST:/api/v1/scheduling/optimize
39388
+ */
39389
+ optimize: (data: SchedulingOptimizeRequest$1, params?: RequestParams) => Promise<HttpResponse<SchedulingOptimizeResponse$1, void>>;
39301
39390
  }
39302
39391
 
39303
39392
  /**
@@ -39456,18 +39545,106 @@ interface SchedulingFeasibilityResponse {
39456
39545
  status: SchedulingStatus;
39457
39546
  assignments: Assignment[];
39458
39547
  }
39548
+ /**
39549
+ * A soft preference: bias the optimizer toward (or against) assigning
39550
+ * `agentId` to cell `(day, shift)`.
39551
+ *
39552
+ * @remarks
39553
+ * `score` contributes to the optimizer's objective when the cell is
39554
+ * assigned in the chosen schedule. Positive values pull the optimizer
39555
+ * toward the cell; negative values push it away.
39556
+ *
39557
+ * Preferences targeting a cell that is already pinned, blocked by a
39558
+ * day-off, restricted-to-shift, or otherwise structurally fixed are
39559
+ * silently ignored — those cells are not the optimizer's choice to
39560
+ * make.
39561
+ *
39562
+ * Common encodings:
39563
+ * - "Aisha prefers morning shifts" → `score = +5` on every
39564
+ * `(aisha, day, morning)` pair
39565
+ * - "Avoid weekend assignments" → `score = -3` on every
39566
+ * `(*, sat|sun, *)` pair
39567
+ * - "Honor day-off requests" → `score = -100` on
39568
+ * `(agent, requested_off_day, *)` (large negative penalty —
39569
+ * respects the request when feasible, lets the engine decide
39570
+ * when not)
39571
+ */
39572
+ interface Preference {
39573
+ agentId: string;
39574
+ day: number;
39575
+ shift: number;
39576
+ /**
39577
+ * Score added to the objective when this cell is assigned in the
39578
+ * chosen schedule. Positive = preferred, negative = avoided.
39579
+ */
39580
+ score: number;
39581
+ }
39582
+ /**
39583
+ * Input to {@link SchedulingClient.optimize}.
39584
+ *
39585
+ * @remarks
39586
+ * Same hard-constraint shape as {@link SchedulingFeasibilityRequest}
39587
+ * plus a list of soft `preferences`. The engine returns the per-cell
39588
+ * envelope across the space of **optimal** schedules under the
39589
+ * supplied preferences.
39590
+ */
39591
+ interface SchedulingOptimizeRequest {
39592
+ agents: AgentSpec[];
39593
+ days: number;
39594
+ shiftsPerDay: number;
39595
+ demands: ShiftDemand[];
39596
+ /** Pre-assigned `(agent, day, shift)` triples. Defaults to empty. */
39597
+ pins?: Pin[];
39598
+ /**
39599
+ * Soft preferences applied to the objective. Empty (or omitted) =
39600
+ * unweighted: every feasible schedule is "optimal" and the result
39601
+ * coincides with {@link SchedulingClient.feasibility}.
39602
+ */
39603
+ preferences?: Preference[];
39604
+ }
39605
+ /**
39606
+ * Response from {@link SchedulingClient.optimize}.
39607
+ *
39608
+ * @remarks
39609
+ * The per-cell `assignments` trichotomy classifies each cell over the
39610
+ * space of **optimal** schedules — strictly stronger than the
39611
+ * feasibility-only trichotomy from
39612
+ * {@link SchedulingClient.feasibility}:
39613
+ *
39614
+ * - `"confirmed_true"` — assigned in *every* optimal schedule.
39615
+ * - `"confirmed_false"` — assigned in *no* optimal schedule.
39616
+ * - `"free"` — varies across the (possibly multiple) optimal
39617
+ * schedules; the optimizer is indifferent.
39618
+ *
39619
+ * `totalScore` is the sum of {@link Preference.score} over assigned
39620
+ * cells in the optimum. It is `0` when no preferences were supplied
39621
+ * or the problem is infeasible.
39622
+ */
39623
+ interface SchedulingOptimizeResponse {
39624
+ status: SchedulingStatus;
39625
+ /** Sum of preference scores at chosen cells in the optimum. */
39626
+ totalScore: number;
39627
+ /**
39628
+ * Empty when `status === "infeasible"`; otherwise one entry per
39629
+ * `(agent, day, shift)` triple in the input grid.
39630
+ */
39631
+ assignments: Assignment[];
39632
+ }
39459
39633
 
39460
39634
  declare const scheduling_ANY_ROLE: typeof ANY_ROLE;
39461
39635
  type scheduling_AgentSpec = AgentSpec;
39462
39636
  type scheduling_Assignment = Assignment;
39463
39637
  type scheduling_AssignmentStatus = AssignmentStatus;
39464
39638
  type scheduling_Pin = Pin;
39639
+ type scheduling_Preference = Preference;
39465
39640
  type scheduling_SchedulingFeasibilityRequest = SchedulingFeasibilityRequest;
39466
39641
  type scheduling_SchedulingFeasibilityResponse = SchedulingFeasibilityResponse;
39642
+ type scheduling_SchedulingOptimizeRequest = SchedulingOptimizeRequest;
39643
+ type scheduling_SchedulingOptimizeResponse = SchedulingOptimizeResponse;
39467
39644
  type scheduling_SchedulingStatus = SchedulingStatus;
39468
39645
  type scheduling_ShiftDemand = ShiftDemand;
39469
39646
  declare namespace scheduling {
39470
- export { scheduling_ANY_ROLE as ANY_ROLE, type scheduling_AgentSpec as AgentSpec, type scheduling_Assignment as Assignment, type scheduling_AssignmentStatus as AssignmentStatus, type scheduling_Pin as Pin, type scheduling_SchedulingFeasibilityRequest as SchedulingFeasibilityRequest, type scheduling_SchedulingFeasibilityResponse as SchedulingFeasibilityResponse, type scheduling_SchedulingStatus as SchedulingStatus, type scheduling_ShiftDemand as ShiftDemand };
39647
+ export { scheduling_ANY_ROLE as ANY_ROLE, type scheduling_AgentSpec as AgentSpec, type scheduling_Assignment as Assignment, type scheduling_AssignmentStatus as AssignmentStatus, type scheduling_Pin as Pin, type scheduling_Preference as Preference, type scheduling_SchedulingFeasibilityRequest as SchedulingFeasibilityRequest, type scheduling_SchedulingFeasibilityResponse as SchedulingFeasibilityResponse, type scheduling_SchedulingOptimizeRequest as SchedulingOptimizeRequest, type scheduling_SchedulingOptimizeResponse as SchedulingOptimizeResponse, type scheduling_SchedulingStatus as SchedulingStatus, type scheduling_ShiftDemand as ShiftDemand };
39471
39648
  }
39472
39649
 
39473
39650
  /**
@@ -39539,6 +39716,65 @@ declare class SchedulingClient {
39539
39716
  * raises.
39540
39717
  */
39541
39718
  feasibility(request: SchedulingFeasibilityRequest): Promise<SchedulingFeasibilityResponse>;
39719
+ /**
39720
+ * Solve the scheduling problem with **soft preferences** and
39721
+ * return the per-cell envelope across the space of *optimal*
39722
+ * schedules.
39723
+ *
39724
+ * @param request - the scheduling problem plus optional
39725
+ * `preferences` (per-cell scores added to the optimizer's
39726
+ * objective). Same hard-constraint shape as
39727
+ * {@link SchedulingClient.feasibility}.
39728
+ * @returns a {@link SchedulingOptimizeResponse} with `totalScore`
39729
+ * and per-cell trichotomy across optimal schedules.
39730
+ *
39731
+ * @throws HTTP 400 errors are surfaced when the input is malformed
39732
+ * (duplicate agent IDs, pins or preferences referencing unknown
39733
+ * agents, ambiguous pin role on multi-role agents, role minima
39734
+ * exceeding total demand, etc.).
39735
+ *
39736
+ * @remarks
39737
+ * The trichotomy returned here is **strictly stronger** than the
39738
+ * one from {@link SchedulingClient.feasibility}:
39739
+ *
39740
+ * - `"confirmed_true"` — assigned in *every* optimum.
39741
+ * - `"confirmed_false"` — assigned in *no* optimum.
39742
+ * - `"free"` — varies across the optima; the optimizer is indifferent
39743
+ * between equally-good choices.
39744
+ *
39745
+ * `totalScore` is the sum of {@link Preference.score} over assigned
39746
+ * cells in the optimum (`0` when no preferences are supplied or
39747
+ * the problem is infeasible).
39748
+ *
39749
+ * Preferences targeting structurally-fixed cells (pinned cells,
39750
+ * day-off / shift-only restricted cells, agents not in the grid)
39751
+ * are silently ignored — the optimizer has no choice to make there.
39752
+ *
39753
+ * Empty `preferences` is equivalent to calling
39754
+ * {@link SchedulingClient.feasibility} (every feasible schedule
39755
+ * is optimal under a zero objective), but slower; prefer
39756
+ * `feasibility()` when you only need the feasibility envelope.
39757
+ *
39758
+ * @example Score Aisha as a strong preference for emergency cover
39759
+ * ```typescript
39760
+ * const report = await client.scheduling.optimize({
39761
+ * agents: [
39762
+ * { id: 'aisha', roles: ['icu', 'emergency'], maxAssignments: 5 },
39763
+ * { id: 'bob', roles: ['general'], maxAssignments: 5 },
39764
+ * ],
39765
+ * days: 7,
39766
+ * shiftsPerDay: 3,
39767
+ * demands: [{ day: 0, shift: 0, total: 2, roleMinimums: { icu: 1 } }],
39768
+ * preferences: [
39769
+ * { agentId: 'aisha', day: 0, shift: 0, score: 10 },
39770
+ * ],
39771
+ * });
39772
+ *
39773
+ * console.log(report.totalScore); // 10 if Aisha is in the optimum
39774
+ * console.log(report.status); // 'feasible' | 'infeasible'
39775
+ * ```
39776
+ */
39777
+ optimize(request: SchedulingOptimizeRequest): Promise<SchedulingOptimizeResponse>;
39542
39778
  }
39543
39779
 
39544
39780
  declare class Osfql<SecurityDataType = unknown> {