@kortexya/reasoninglayer 0.21.0 → 0.22.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.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.21.0";
112
+ declare const SDK_VERSION = "0.22.1";
113
113
  /**
114
114
  * Configuration for the Reasoning Layer client.
115
115
  *
@@ -571,6 +571,55 @@ interface AddPendingReviewResponse {
571
571
  /** @format uuid */
572
572
  review_id: string;
573
573
  }
574
+ /**
575
+ * Request body for `POST /api/v1/scheduling/problems/{id}/pins`.
576
+ *
577
+ * Same shape as the `PinInput` used inside a problem-creation
578
+ * request, but carried alone — the URL identifies the target
579
+ * problem.
580
+ */
581
+ interface AddPinRequest$1 {
582
+ agent_id: string;
583
+ /** @min 0 */
584
+ day: number;
585
+ role?: string | null;
586
+ /** @min 0 */
587
+ shift: number;
588
+ }
589
+ /**
590
+ * Response from `POST /api/v1/scheduling/problems/{id}/pins`.
591
+ *
592
+ * `pin_id` is the [`TermId`] of the newly-created pin Ψ-term —
593
+ * the stable handle for subsequent removal via
594
+ * `DELETE /api/v1/scheduling/problems/{id}/pins/{pin_id}`.
595
+ */
596
+ interface AddPinResponse$1 {
597
+ pin_id: string;
598
+ /**
599
+ * Problem version after the mutation.
600
+ * @format int64
601
+ */
602
+ version: number;
603
+ }
604
+ /** Request body for `POST /api/v1/scheduling/problems/{id}/preferences`. */
605
+ interface AddPreferenceRequest$1 {
606
+ agent_id: string;
607
+ /** @min 0 */
608
+ day: number;
609
+ /** @format int64 */
610
+ score: number;
611
+ /** @min 0 */
612
+ shift: number;
613
+ }
614
+ /** Response from `POST /api/v1/scheduling/problems/{id}/preferences`. */
615
+ interface AddPreferenceResponse$1 {
616
+ preference_id: string;
617
+ /**
618
+ * Problem version after the mutation.
619
+ * @format int64
620
+ */
621
+ version: number;
622
+ }
574
623
  /** Request to add a rule (a term with antecedents). */
575
624
  interface AddRuleRequest$1 {
576
625
  /**
@@ -3417,6 +3466,58 @@ type CreateScenarioResponse$1 = {
3417
3466
  /** @min 0 */
3418
3467
  total_time_ms: number;
3419
3468
  };
3469
+ /**
3470
+ * Request body for `POST /api/v1/scheduling/problems`.
3471
+ *
3472
+ * Two mutually exclusive ways to identify the problem's agents:
3473
+ *
3474
+ * * **Inline** — set `agents` to a list of [`AgentInput`]s.
3475
+ * The problem term embeds frozen copies of the agent specs.
3476
+ * Convenient for ad-hoc demos but doesn't compose with other
3477
+ * KB-stored entities.
3478
+ *
3479
+ * * **Reference** — set `agent_ids` to a list of `TermId`
3480
+ * UUIDs pointing at agent Ψ-terms (sort `nurse` or any
3481
+ * tenant-defined agent sort) created via the regular
3482
+ * `POST /api/v1/terms` endpoint. The problem term carries
3483
+ * refs only; re-solving fetches the agent terms from the KB
3484
+ * at solve time, so updating an agent (e.g. adding a
3485
+ * certification, adding a personal_constraint sub-term)
3486
+ * immediately affects the next solve. This is the
3487
+ * OSF/LIFE-native flow and what multi-user collaboration
3488
+ * uses.
3489
+ *
3490
+ * Exactly one of `agents` / `agent_ids` must be supplied;
3491
+ * supplying both, or neither, returns HTTP 400.
3492
+ */
3493
+ interface CreateSchedulingProblemRequest$1 {
3494
+ /**
3495
+ * References to agent Ψ-terms in the KB (UUID strings).
3496
+ * Optional; mutually exclusive with `agents`.
3497
+ */
3498
+ agent_ids?: any[] | null;
3499
+ /**
3500
+ * Inline agent specs (legacy / demo-friendly path). Optional;
3501
+ * see `agent_ids` for the reference-based alternative.
3502
+ */
3503
+ agents?: any[] | null;
3504
+ /** @min 0 */
3505
+ days: number;
3506
+ demands: ShiftDemandInput[];
3507
+ pins?: PinInput[];
3508
+ preferences?: PreferenceInput[];
3509
+ /** @min 0 */
3510
+ shifts_per_day: number;
3511
+ }
3512
+ /** Response to `POST /api/v1/scheduling/problems`. */
3513
+ interface CreateSchedulingProblemResponse$1 {
3514
+ /**
3515
+ * UUID-formatted ID of the stored `scheduling.problem` snapshot
3516
+ * term. Use this in subsequent `/scheduling/problems/{id}/...`
3517
+ * calls.
3518
+ */
3519
+ problem_id: string;
3520
+ }
3420
3521
  /** Request to create a live oversight session. */
3421
3522
  interface CreateSessionRequest {
3422
3523
  /** Optional pipeline configuration overrides */
@@ -11487,6 +11588,17 @@ interface PendingReviewEntityDto {
11487
11588
  /** Original text span that was extracted */
11488
11589
  source_text?: string | null;
11489
11590
  }
11591
+ /** Pin entry in [`SchedulingProblemDto`]. */
11592
+ interface PinEntryDto {
11593
+ agent_id: string;
11594
+ /** @min 0 */
11595
+ day: number;
11596
+ /** Stable ID for `DELETE /api/v1/scheduling/problems/{id}/pins/{pin_id}`. */
11597
+ pin_id: string;
11598
+ role?: string | null;
11599
+ /** @min 0 */
11600
+ shift: number;
11601
+ }
11490
11602
  /**
11491
11603
  * A pre-assigned `(agent, day, shift)` triple, optionally naming
11492
11604
  * which role the pin covers.
@@ -11812,17 +11924,34 @@ interface PreferenceDto$1 {
11812
11924
  /** Preference value. */
11813
11925
  value: string;
11814
11926
  }
11927
+ /** Preference entry in [`SchedulingProblemDto`]. */
11928
+ interface PreferenceEntryDto {
11929
+ agent_id: string;
11930
+ /** @min 0 */
11931
+ day: number;
11932
+ /** Stable ID for `DELETE /api/v1/scheduling/problems/{id}/preferences/{preference_id}`. */
11933
+ preference_id: string;
11934
+ /** @format int64 */
11935
+ score: number;
11936
+ /** @min 0 */
11937
+ shift: number;
11938
+ }
11815
11939
  /**
11816
11940
  * A soft preference: bias the optimizer toward (or against) assigning
11817
11941
  * `agent_id` to cell `(day, shift)`.
11818
11942
  *
11819
11943
  * `score` contributes to the objective when the cell is assigned in
11820
11944
  * 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.
11945
+ * the cell; negative values push it away.
11946
+ *
11947
+ * Preferences targeting a structurally infeasible cell (the agent
11948
+ * has a day-off on `day`, is restricted to a different shift, or
11949
+ * otherwise cannot occupy the slot) are silently ignored — the
11950
+ * agent cannot fill the cell, so the preference cannot fire.
11951
+ *
11952
+ * Preferences targeting a **pinned** cell *do* contribute to
11953
+ * `total_score`: pins force the agent into the cell, so the
11954
+ * preference is realised in the chosen schedule.
11826
11955
  */
11827
11956
  interface PreferenceInput {
11828
11957
  agent_id: string;
@@ -13725,6 +13854,22 @@ interface ScenarioSummaryDto$1 {
13725
13854
  */
13726
13855
  sorts_created: number;
13727
13856
  }
13857
+ /**
13858
+ * Response to `GET /api/v1/scheduling/problems/{id}/assignments`.
13859
+ *
13860
+ * One entry per `(agent, day, shift)` cell that was lifted from
13861
+ * the optimum's per-cell envelope, including `free` cells (per
13862
+ * the materialise decision so downstream rules can residuate).
13863
+ */
13864
+ interface SchedulingAssignmentsResponse$1 {
13865
+ assignments: AssignmentDto[];
13866
+ /**
13867
+ * `total_score` of the most recent solve, or `0` when the
13868
+ * problem has never been solved.
13869
+ * @format int64
13870
+ */
13871
+ total_score: number;
13872
+ }
13728
13873
  /**
13729
13874
  * A scheduling feasibility request.
13730
13875
  *
@@ -13816,6 +13961,38 @@ interface SchedulingOptimizeResponse$1 {
13816
13961
  */
13817
13962
  total_score: number;
13818
13963
  }
13964
+ /**
13965
+ * Response from `GET /api/v1/scheduling/problems/{id}`.
13966
+ *
13967
+ * Snapshot of the live problem state — agents and demands as
13968
+ * supplied at creation time, plus the *current* set of pins and
13969
+ * preferences (including their stable child IDs). Use the IDs
13970
+ * here when building DELETE calls.
13971
+ */
13972
+ interface SchedulingProblemDto {
13973
+ /** @min 0 */
13974
+ days: number;
13975
+ /** Status of the most recent solve, or `None` if never solved. */
13976
+ latest_solve_status?: null | SchedulingStatusDto;
13977
+ /** Pins currently on the problem. */
13978
+ pins: PinEntryDto[];
13979
+ /** Preferences currently on the problem. */
13980
+ preferences: PreferenceEntryDto[];
13981
+ problem_id: string;
13982
+ /** @min 0 */
13983
+ shifts_per_day: number;
13984
+ /**
13985
+ * Score of the most recent solve, or `0` if never solved.
13986
+ * @format int64
13987
+ */
13988
+ total_score: number;
13989
+ /**
13990
+ * Bumped on every input mutation (add/remove pin or preference).
13991
+ * Solving does not bump it.
13992
+ * @format int64
13993
+ */
13994
+ version: number;
13995
+ }
13819
13996
  /** Top-level request status. */
13820
13997
  type SchedulingStatusDto = "feasible" | "infeasible";
13821
13998
  /** Request to search communities */
@@ -14246,6 +14423,26 @@ interface SolveConstraintResponse$1 {
14246
14423
  success: boolean;
14247
14424
  suspended_constraints: string[];
14248
14425
  }
14426
+ /**
14427
+ * Response to `POST /api/v1/scheduling/problems/{id}/solve`.
14428
+ *
14429
+ * Re-solving an already-solved problem replaces the previously
14430
+ * derived `scheduling.assignment` Ψ-terms. Per-cell trichotomy
14431
+ * must be fetched separately via
14432
+ * `GET /scheduling/problems/{id}/assignments` (so a successful
14433
+ * re-solve carries minimal payload).
14434
+ */
14435
+ interface SolveSchedulingProblemResponse$1 {
14436
+ /** Top-level request status. */
14437
+ status: SchedulingStatusDto;
14438
+ /**
14439
+ * Sum of [`PreferenceInput::score`] over assigned cells in the
14440
+ * optimum. `0` when no preferences were supplied or the
14441
+ * problem is infeasible.
14442
+ * @format int64
14443
+ */
14444
+ total_score: number;
14445
+ }
14249
14446
  /** Response with ancestor sorts */
14250
14447
  interface SortAncestorsResponse {
14251
14448
  ancestors: SortInfoDto$1[];
@@ -39369,6 +39566,33 @@ declare class OptimizeClient {
39369
39566
  declare class Scheduling<SecurityDataType = unknown> {
39370
39567
  http: HttpClient<SecurityDataType>;
39371
39568
  constructor(http: HttpClient<SecurityDataType>);
39569
+ /**
39570
+ * No description
39571
+ *
39572
+ * @tags scheduling
39573
+ * @name AddPin
39574
+ * @summary `POST /api/v1/scheduling/problems/{id}/pins`
39575
+ * @request POST:/api/v1/scheduling/problems/{problem_id}/pins
39576
+ */
39577
+ addPin: (problemId: string, data: AddPinRequest$1, params?: RequestParams) => Promise<HttpResponse<AddPinResponse$1, void>>;
39578
+ /**
39579
+ * No description
39580
+ *
39581
+ * @tags scheduling
39582
+ * @name AddPreference
39583
+ * @summary `POST /api/v1/scheduling/problems/{id}/preferences`
39584
+ * @request POST:/api/v1/scheduling/problems/{problem_id}/preferences
39585
+ */
39586
+ addPreference: (problemId: string, data: AddPreferenceRequest$1, params?: RequestParams) => Promise<HttpResponse<AddPreferenceResponse$1, void>>;
39587
+ /**
39588
+ * @description Freeze the inline scheduling inputs into a `scheduling.problem` Ψ-term snapshot stored in the application-layer scheduling store, and return its ID. The endpoint does NOT solve — call `POST /api/v1/scheduling/problems/{id}/solve` to compute the optimum, then `GET /api/v1/scheduling/problems/{id}/assignments` to retrieve the per-cell trichotomy. Snapshot mode: subsequent re-solves read only the snapshot, not any source terms in the KB. This keeps the optimum reproducible and auditable from the moment the problem is created.
39589
+ *
39590
+ * @tags scheduling
39591
+ * @name CreateProblem
39592
+ * @summary `POST /api/v1/scheduling/problems`
39593
+ * @request POST:/api/v1/scheduling/problems
39594
+ */
39595
+ createProblem: (data: CreateSchedulingProblemRequest$1, params?: RequestParams) => Promise<HttpResponse<CreateSchedulingProblemResponse$1, void>>;
39372
39596
  /**
39373
39597
  * @description Classify every `(agent, day, shift)` cell in the input grid as confirmed-true, confirmed-false, or free, and list the role(s) each cell could cover. Input validation errors (duplicate agent IDs, out-of-range pins, role minima exceeding total demand, pin role the agent doesn't have, pin on a multi-role agent where the role is ambiguous, etc.) return HTTP 400. Infeasibility of a well-formed problem is a valid answer and returns HTTP 200 with `status = "infeasible"` and an empty `assignments` list.
39374
39598
  *
@@ -39379,7 +39603,25 @@ declare class Scheduling<SecurityDataType = unknown> {
39379
39603
  */
39380
39604
  feasibility: (data: SchedulingFeasibilityRequest$1, params?: RequestParams) => Promise<HttpResponse<SchedulingFeasibilityResponse$1, void>>;
39381
39605
  /**
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.
39606
+ * No description
39607
+ *
39608
+ * @tags scheduling
39609
+ * @name GetProblem
39610
+ * @summary `GET /api/v1/scheduling/problems/{id}` — read the current state.
39611
+ * @request GET:/api/v1/scheduling/problems/{problem_id}
39612
+ */
39613
+ getProblem: (problemId: string, params?: RequestParams) => Promise<HttpResponse<SchedulingProblemDto, void>>;
39614
+ /**
39615
+ * @description Retrieve the derived `scheduling.assignment` Ψ-terms produced by the most recent solve. Returns an empty list when the problem has never been solved, or when the problem ID isn't known for this tenant. Includes `free` cells (per the materialise decision) so consumers can residuate on them.
39616
+ *
39617
+ * @tags scheduling
39618
+ * @name ListAssignments
39619
+ * @summary `GET /api/v1/scheduling/problems/{id}/assignments`
39620
+ * @request GET:/api/v1/scheduling/problems/{problem_id}/assignments
39621
+ */
39622
+ listAssignments: (problemId: string, params?: RequestParams) => Promise<HttpResponse<SchedulingAssignmentsResponse$1, void>>;
39623
+ /**
39624
+ * @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 structurally infeasible cells (agent has a day-off on the day, is restricted to a different shift, or otherwise cannot occupy the slot) are silently ignored — the preference cannot fire when the agent cannot be there. Preferences targeting **pinned** cells DO contribute to `total_score`: pins force the agent into the cell, so the preference is realised by the chosen schedule.
39383
39625
  *
39384
39626
  * @tags scheduling
39385
39627
  * @name Optimize
@@ -39387,6 +39629,33 @@ declare class Scheduling<SecurityDataType = unknown> {
39387
39629
  * @request POST:/api/v1/scheduling/optimize
39388
39630
  */
39389
39631
  optimize: (data: SchedulingOptimizeRequest$1, params?: RequestParams) => Promise<HttpResponse<SchedulingOptimizeResponse$1, void>>;
39632
+ /**
39633
+ * No description
39634
+ *
39635
+ * @tags scheduling
39636
+ * @name RemovePin
39637
+ * @summary `DELETE /api/v1/scheduling/problems/{id}/pins/{pin_id}`
39638
+ * @request DELETE:/api/v1/scheduling/problems/{problem_id}/pins/{pin_id}
39639
+ */
39640
+ removePin: (problemId: string, pinId: string, params?: RequestParams) => Promise<HttpResponse<void, void>>;
39641
+ /**
39642
+ * No description
39643
+ *
39644
+ * @tags scheduling
39645
+ * @name RemovePreference
39646
+ * @summary `DELETE /api/v1/scheduling/problems/{id}/preferences/{preference_id}`
39647
+ * @request DELETE:/api/v1/scheduling/problems/{problem_id}/preferences/{preference_id}
39648
+ */
39649
+ removePreference: (problemId: string, preferenceId: string, params?: RequestParams) => Promise<HttpResponse<void, void>>;
39650
+ /**
39651
+ * @description Re-solve the stored snapshot: project it back into a domain `SchedulingProblem`, run the optimizer, and lift the per-cell trichotomy into `scheduling.assignment` Ψ-terms (idempotent — previous derived assignments for this problem are replaced). Returns only `status` and `total_score`; fetch the per-cell trichotomy via `/assignments`.
39652
+ *
39653
+ * @tags scheduling
39654
+ * @name SolveProblem
39655
+ * @summary `POST /api/v1/scheduling/problems/{id}/solve`
39656
+ * @request POST:/api/v1/scheduling/problems/{problem_id}/solve
39657
+ */
39658
+ solveProblem: (problemId: string, params?: RequestParams) => Promise<HttpResponse<SolveSchedulingProblemResponse$1, void>>;
39390
39659
  }
39391
39660
 
39392
39661
  /**
@@ -39630,21 +39899,216 @@ interface SchedulingOptimizeResponse {
39630
39899
  */
39631
39900
  assignments: Assignment[];
39632
39901
  }
39902
+ /**
39903
+ * Input to {@link SchedulingClient.createProblem}.
39904
+ *
39905
+ * @remarks
39906
+ * Two mutually-exclusive ways to identify the problem's agents:
39907
+ *
39908
+ * - **Inline** — set `agents` to a list of {@link AgentSpec}s.
39909
+ * The server embeds frozen agent-spec copies on the problem
39910
+ * term. Convenient for ad-hoc demos.
39911
+ *
39912
+ * - **Reference** — set `agentIds` to a list of `TermId` UUIDs
39913
+ * pointing at agent Ψ-terms (sort `nurse` or any other
39914
+ * tenant-defined sort) created via the regular
39915
+ * `POST /api/v1/terms` endpoint. The problem term carries
39916
+ * refs only; re-solving fetches the agent terms from the KB
39917
+ * at solve time, so mutating an agent (adding a
39918
+ * `personal_constraints` sub-term, for instance) immediately
39919
+ * affects the next solve. This is the OSF/LIFE-native flow
39920
+ * and what multi-user collaboration uses.
39921
+ *
39922
+ * **Exactly one** of `agents` / `agentIds` must be supplied.
39923
+ * Sending both — or neither — returns HTTP 400.
39924
+ *
39925
+ * `pins` / `preferences` on the create payload are only honoured
39926
+ * for the inline path. In the reference path, create the problem
39927
+ * first and add pins / preferences via the mutation endpoints
39928
+ * (where `agentId` is then a TermId UUID).
39929
+ */
39930
+ interface CreateSchedulingProblemRequest {
39931
+ /** Inline agent specs. Mutually exclusive with `agentIds`. */
39932
+ agents?: AgentSpec[];
39933
+ /**
39934
+ * References to agent Ψ-terms in the KB (UUID strings).
39935
+ * Mutually exclusive with `agents`.
39936
+ */
39937
+ agentIds?: string[];
39938
+ days: number;
39939
+ shiftsPerDay: number;
39940
+ demands: ShiftDemand[];
39941
+ /** Pre-assigned `(agent, day, shift)` triples. Inline path only. */
39942
+ pins?: Pin[];
39943
+ /** Soft preferences applied to the optimum's objective. Inline path only. */
39944
+ preferences?: Preference[];
39945
+ }
39946
+ /**
39947
+ * Response from {@link SchedulingClient.createProblem}.
39948
+ */
39949
+ interface CreateSchedulingProblemResponse {
39950
+ /**
39951
+ * UUID of the stored `scheduling.problem` snapshot term. Use it
39952
+ * in subsequent `solveProblem` / `listAssignments` calls.
39953
+ */
39954
+ problemId: string;
39955
+ }
39956
+ /**
39957
+ * Response from {@link SchedulingClient.solveProblem}.
39958
+ *
39959
+ * @remarks
39960
+ * Re-solving an already-solved problem replaces the previously
39961
+ * lifted `scheduling.assignment` Ψ-terms (idempotent). Per-cell
39962
+ * trichotomy must be fetched separately via
39963
+ * {@link SchedulingClient.listAssignments} so a successful
39964
+ * re-solve carries minimal payload.
39965
+ */
39966
+ interface SolveSchedulingProblemResponse {
39967
+ status: SchedulingStatus;
39968
+ /**
39969
+ * Sum of {@link Preference.score} over chosen cells in the
39970
+ * optimum. `0` when no preferences were supplied or the problem
39971
+ * is infeasible.
39972
+ */
39973
+ totalScore: number;
39974
+ }
39975
+ /**
39976
+ * Response from {@link SchedulingClient.listAssignments}.
39977
+ *
39978
+ * @remarks
39979
+ * One entry per `(agent, day, shift)` cell that was lifted from
39980
+ * the optimum — including `free` cells, so consumers can residuate
39981
+ * on cells the optimizer is indifferent about. Empty when the
39982
+ * problem has never been solved.
39983
+ *
39984
+ * `totalScore` mirrors the most recent solve's optimum value, or
39985
+ * `0` when the problem hasn't been solved yet.
39986
+ */
39987
+ interface SchedulingAssignmentsResponse {
39988
+ totalScore: number;
39989
+ assignments: Assignment[];
39990
+ }
39991
+ /**
39992
+ * Input to {@link SchedulingClient.addPin}.
39993
+ *
39994
+ * @remarks
39995
+ * Same field set as {@link Pin}; the URL identifies the target
39996
+ * problem. Returns a `pinId` that callers retain for subsequent
39997
+ * removal.
39998
+ */
39999
+ interface AddPinRequest {
40000
+ agentId: string;
40001
+ day: number;
40002
+ shift: number;
40003
+ role?: string;
40004
+ }
40005
+ interface AddPinResponse {
40006
+ /**
40007
+ * Stable handle for `removePin(problemId, pinId)`. UUID-formatted.
40008
+ */
40009
+ pinId: string;
40010
+ /** Problem version after this mutation. */
40011
+ version: number;
40012
+ }
40013
+ /**
40014
+ * Input to {@link SchedulingClient.addPreference}.
40015
+ */
40016
+ interface AddPreferenceRequest {
40017
+ agentId: string;
40018
+ day: number;
40019
+ shift: number;
40020
+ score: number;
40021
+ }
40022
+ interface AddPreferenceResponse {
40023
+ /**
40024
+ * Stable handle for
40025
+ * `removePreference(problemId, preferenceId)`. UUID-formatted.
40026
+ */
40027
+ preferenceId: string;
40028
+ /** Problem version after this mutation. */
40029
+ version: number;
40030
+ }
40031
+ /**
40032
+ * One pin currently on the problem, as returned by
40033
+ * {@link SchedulingClient.getProblem}. Carries the stable
40034
+ * `pinId` to use when calling
40035
+ * {@link SchedulingClient.removePin}.
40036
+ */
40037
+ interface PinEntry {
40038
+ pinId: string;
40039
+ agentId: string;
40040
+ day: number;
40041
+ shift: number;
40042
+ role?: string;
40043
+ }
40044
+ /**
40045
+ * One preference currently on the problem, as returned by
40046
+ * {@link SchedulingClient.getProblem}. Carries the stable
40047
+ * `preferenceId` to use when calling
40048
+ * {@link SchedulingClient.removePreference}.
40049
+ */
40050
+ interface PreferenceEntry {
40051
+ preferenceId: string;
40052
+ agentId: string;
40053
+ day: number;
40054
+ shift: number;
40055
+ score: number;
40056
+ }
40057
+ /**
40058
+ * Current state of a stored problem returned by
40059
+ * {@link SchedulingClient.getProblem}.
40060
+ *
40061
+ * @remarks
40062
+ * `pins` and `preferences` carry the stable IDs needed for
40063
+ * subsequent removal. `version` is bumped on every input edit
40064
+ * (add/remove pin or preference); solving does NOT bump it —
40065
+ * solves are derivations, not edits. `latestSolveStatus` is
40066
+ * `undefined` until the first successful solve.
40067
+ */
40068
+ interface SchedulingProblem {
40069
+ problemId: string;
40070
+ days: number;
40071
+ shiftsPerDay: number;
40072
+ version: number;
40073
+ pins: PinEntry[];
40074
+ preferences: PreferenceEntry[];
40075
+ /**
40076
+ * Score of the most recent solve, or `0` if the problem has
40077
+ * never been solved.
40078
+ */
40079
+ totalScore: number;
40080
+ /**
40081
+ * Status of the most recent solve, or `undefined` if the
40082
+ * problem has never been solved.
40083
+ */
40084
+ latestSolveStatus?: SchedulingStatus;
40085
+ }
39633
40086
 
39634
40087
  declare const scheduling_ANY_ROLE: typeof ANY_ROLE;
40088
+ type scheduling_AddPinRequest = AddPinRequest;
40089
+ type scheduling_AddPinResponse = AddPinResponse;
40090
+ type scheduling_AddPreferenceRequest = AddPreferenceRequest;
40091
+ type scheduling_AddPreferenceResponse = AddPreferenceResponse;
39635
40092
  type scheduling_AgentSpec = AgentSpec;
39636
40093
  type scheduling_Assignment = Assignment;
39637
40094
  type scheduling_AssignmentStatus = AssignmentStatus;
40095
+ type scheduling_CreateSchedulingProblemRequest = CreateSchedulingProblemRequest;
40096
+ type scheduling_CreateSchedulingProblemResponse = CreateSchedulingProblemResponse;
39638
40097
  type scheduling_Pin = Pin;
40098
+ type scheduling_PinEntry = PinEntry;
39639
40099
  type scheduling_Preference = Preference;
40100
+ type scheduling_PreferenceEntry = PreferenceEntry;
40101
+ type scheduling_SchedulingAssignmentsResponse = SchedulingAssignmentsResponse;
39640
40102
  type scheduling_SchedulingFeasibilityRequest = SchedulingFeasibilityRequest;
39641
40103
  type scheduling_SchedulingFeasibilityResponse = SchedulingFeasibilityResponse;
39642
40104
  type scheduling_SchedulingOptimizeRequest = SchedulingOptimizeRequest;
39643
40105
  type scheduling_SchedulingOptimizeResponse = SchedulingOptimizeResponse;
40106
+ type scheduling_SchedulingProblem = SchedulingProblem;
39644
40107
  type scheduling_SchedulingStatus = SchedulingStatus;
39645
40108
  type scheduling_ShiftDemand = ShiftDemand;
40109
+ type scheduling_SolveSchedulingProblemResponse = SolveSchedulingProblemResponse;
39646
40110
  declare namespace scheduling {
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 };
40111
+ export { scheduling_ANY_ROLE as ANY_ROLE, type scheduling_AddPinRequest as AddPinRequest, type scheduling_AddPinResponse as AddPinResponse, type scheduling_AddPreferenceRequest as AddPreferenceRequest, type scheduling_AddPreferenceResponse as AddPreferenceResponse, type scheduling_AgentSpec as AgentSpec, type scheduling_Assignment as Assignment, type scheduling_AssignmentStatus as AssignmentStatus, type scheduling_CreateSchedulingProblemRequest as CreateSchedulingProblemRequest, type scheduling_CreateSchedulingProblemResponse as CreateSchedulingProblemResponse, type scheduling_Pin as Pin, type scheduling_PinEntry as PinEntry, type scheduling_Preference as Preference, type scheduling_PreferenceEntry as PreferenceEntry, type scheduling_SchedulingAssignmentsResponse as SchedulingAssignmentsResponse, type scheduling_SchedulingFeasibilityRequest as SchedulingFeasibilityRequest, type scheduling_SchedulingFeasibilityResponse as SchedulingFeasibilityResponse, type scheduling_SchedulingOptimizeRequest as SchedulingOptimizeRequest, type scheduling_SchedulingOptimizeResponse as SchedulingOptimizeResponse, type scheduling_SchedulingProblem as SchedulingProblem, type scheduling_SchedulingStatus as SchedulingStatus, type scheduling_ShiftDemand as ShiftDemand, type scheduling_SolveSchedulingProblemResponse as SolveSchedulingProblemResponse };
39648
40112
  }
39649
40113
 
39650
40114
  /**
@@ -39775,6 +40239,127 @@ declare class SchedulingClient {
39775
40239
  * ```
39776
40240
  */
39777
40241
  optimize(request: SchedulingOptimizeRequest): Promise<SchedulingOptimizeResponse>;
40242
+ /**
40243
+ * Freeze the inline scheduling inputs into a `scheduling.problem`
40244
+ * Ψ-term snapshot stored under the caller's tenant, and return the
40245
+ * snapshot's `problemId`. The endpoint does NOT solve — call
40246
+ * {@link SchedulingClient.solveProblem} afterwards to compute the
40247
+ * optimum, then {@link SchedulingClient.listAssignments} to fetch
40248
+ * the per-cell trichotomy.
40249
+ *
40250
+ * @param request - same inline shape as
40251
+ * {@link SchedulingClient.optimize}.
40252
+ * @returns the snapshot ID, useful for subsequent re-solves and
40253
+ * provenance lookups.
40254
+ * @throws HTTP 400 on malformed input (duplicate agent IDs,
40255
+ * ambiguous pin role, unknown pin or preference agent ID,
40256
+ * role minima exceeding total demand, etc.).
40257
+ *
40258
+ * @remarks
40259
+ * Re-solves read only the snapshot, so the optimum is reproducible
40260
+ * and auditable from the moment the problem is created. The
40261
+ * snapshot persists across solves — pin a problem once, re-solve
40262
+ * many times.
40263
+ *
40264
+ * @example
40265
+ * ```typescript
40266
+ * const { problemId } = await client.scheduling.createProblem({
40267
+ * agents: [{ id: 'alice', roles: ['icu'], maxAssignments: 3 }],
40268
+ * days: 7,
40269
+ * shiftsPerDay: 3,
40270
+ * demands: [{ day: 0, shift: 0, total: 1, roleMinimums: { icu: 1 } }],
40271
+ * preferences: [{ agentId: 'alice', day: 0, shift: 0, score: 5 }],
40272
+ * });
40273
+ * await client.scheduling.solveProblem(problemId);
40274
+ * const { totalScore, assignments } =
40275
+ * await client.scheduling.listAssignments(problemId);
40276
+ * ```
40277
+ */
40278
+ createProblem(request: CreateSchedulingProblemRequest): Promise<CreateSchedulingProblemResponse>;
40279
+ /**
40280
+ * Re-solve a previously-stored snapshot, lift the per-cell
40281
+ * trichotomy into `scheduling.assignment` Ψ-terms (idempotent —
40282
+ * previously lifted assignments are replaced), and return the
40283
+ * optimum's `totalScore`.
40284
+ *
40285
+ * @param problemId - the ID returned by
40286
+ * {@link SchedulingClient.createProblem}.
40287
+ * @throws HTTP 404 when the problem doesn't exist for the caller's
40288
+ * tenant. HTTP 400 for malformed problem IDs.
40289
+ *
40290
+ * @remarks
40291
+ * Returns only `status` and `totalScore`; fetch the per-cell
40292
+ * trichotomy with {@link SchedulingClient.listAssignments}.
40293
+ * Re-running this method on the same `problemId` is safe — the
40294
+ * lifted assignment terms are replaced atomically.
40295
+ */
40296
+ solveProblem(problemId: string): Promise<SolveSchedulingProblemResponse>;
40297
+ /**
40298
+ * Retrieve the lifted `scheduling.assignment` Ψ-terms produced by
40299
+ * the most recent solve.
40300
+ *
40301
+ * @param problemId - the ID returned by
40302
+ * {@link SchedulingClient.createProblem}.
40303
+ * @throws HTTP 404 when the problem doesn't exist for the caller's
40304
+ * tenant. HTTP 400 for malformed problem IDs.
40305
+ *
40306
+ * @remarks
40307
+ * Returns one entry per `(agent, day, shift)` cell — including
40308
+ * `free` cells, so consumers can residuate on cells the optimizer
40309
+ * is indifferent about. `assignments` is empty when the problem
40310
+ * exists but hasn't been solved yet.
40311
+ *
40312
+ * `totalScore` mirrors the most recent solve's optimum value, or
40313
+ * `0` when the problem hasn't been solved.
40314
+ */
40315
+ listAssignments(problemId: string): Promise<SchedulingAssignmentsResponse>;
40316
+ /**
40317
+ * Read the current state of a stored problem — its pins,
40318
+ * preferences, version counter, and latest-solve metadata.
40319
+ *
40320
+ * @remarks
40321
+ * Pin and preference entries carry stable IDs (`pinId`,
40322
+ * `preferenceId`) — pass those to {@link SchedulingClient.removePin}
40323
+ * / {@link SchedulingClient.removePreference} to delete them.
40324
+ *
40325
+ * @throws HTTP 404 when the problem doesn't exist for the
40326
+ * caller's tenant.
40327
+ */
40328
+ getProblem(problemId: string): Promise<SchedulingProblem>;
40329
+ /**
40330
+ * Append a pin to a stored problem. Returns the pin's stable
40331
+ * ID and the problem's new version. Multiple pins on the same
40332
+ * `(agent, day, shift)` are not deduplicated server-side; if you
40333
+ * want at-most-one-pin-per-cell semantics, enforce it on the
40334
+ * client by checking the pin entries from
40335
+ * {@link SchedulingClient.getProblem} first.
40336
+ *
40337
+ * @throws HTTP 400 when the agent isn't on the problem's roster
40338
+ * or the (day, shift) is outside the grid. HTTP 404 when the
40339
+ * problem doesn't exist for the caller's tenant.
40340
+ */
40341
+ addPin(problemId: string, request: AddPinRequest): Promise<AddPinResponse>;
40342
+ /**
40343
+ * Remove a pin previously added via
40344
+ * {@link SchedulingClient.addPin}.
40345
+ *
40346
+ * @throws HTTP 404 when the problem doesn't exist for the
40347
+ * tenant or the `pinId` doesn't match any current pin
40348
+ * (already removed, stale ID).
40349
+ */
40350
+ removePin(problemId: string, pinId: string): Promise<void>;
40351
+ /**
40352
+ * Append a preference to a stored problem. Same return shape as
40353
+ * {@link SchedulingClient.addPin} — `preferenceId` is the stable
40354
+ * handle for removal. Multiple preferences targeting the same
40355
+ * cell sum on the next solve.
40356
+ */
40357
+ addPreference(problemId: string, request: AddPreferenceRequest): Promise<AddPreferenceResponse>;
40358
+ /**
40359
+ * Remove a preference previously added via
40360
+ * {@link SchedulingClient.addPreference}.
40361
+ */
40362
+ removePreference(problemId: string, preferenceId: string): Promise<void>;
39778
40363
  }
39779
40364
 
39780
40365
  declare class Osfql<SecurityDataType = unknown> {