@kortexya/reasoninglayer 0.22.0 → 0.23.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.22.0";
10
+ var SDK_VERSION = "0.23.0";
11
11
  function resolveConfig(config) {
12
12
  if (!config.baseUrl) {
13
13
  throw new Error("ClientConfig.baseUrl is required");
@@ -7390,54 +7390,6 @@ var Scheduling = class {
7390
7390
  constructor(http) {
7391
7391
  this.http = http;
7392
7392
  }
7393
- /**
7394
- * No description
7395
- *
7396
- * @tags scheduling
7397
- * @name AddPin
7398
- * @summary `POST /api/v1/scheduling/problems/{id}/pins`
7399
- * @request POST:/api/v1/scheduling/problems/{problem_id}/pins
7400
- */
7401
- addPin = (problemId, data, params = {}) => this.http.request({
7402
- path: `/api/v1/scheduling/problems/${problemId}/pins`,
7403
- method: "POST",
7404
- body: data,
7405
- type: "application/json" /* Json */,
7406
- format: "json",
7407
- ...params
7408
- });
7409
- /**
7410
- * No description
7411
- *
7412
- * @tags scheduling
7413
- * @name AddPreference
7414
- * @summary `POST /api/v1/scheduling/problems/{id}/preferences`
7415
- * @request POST:/api/v1/scheduling/problems/{problem_id}/preferences
7416
- */
7417
- addPreference = (problemId, data, params = {}) => this.http.request({
7418
- path: `/api/v1/scheduling/problems/${problemId}/preferences`,
7419
- method: "POST",
7420
- body: data,
7421
- type: "application/json" /* Json */,
7422
- format: "json",
7423
- ...params
7424
- });
7425
- /**
7426
- * @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.
7427
- *
7428
- * @tags scheduling
7429
- * @name CreateProblem
7430
- * @summary `POST /api/v1/scheduling/problems`
7431
- * @request POST:/api/v1/scheduling/problems
7432
- */
7433
- createProblem = (data, params = {}) => this.http.request({
7434
- path: `/api/v1/scheduling/problems`,
7435
- method: "POST",
7436
- body: data,
7437
- type: "application/json" /* Json */,
7438
- format: "json",
7439
- ...params
7440
- });
7441
7393
  /**
7442
7394
  * @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.
7443
7395
  *
@@ -7454,34 +7406,6 @@ var Scheduling = class {
7454
7406
  format: "json",
7455
7407
  ...params
7456
7408
  });
7457
- /**
7458
- * No description
7459
- *
7460
- * @tags scheduling
7461
- * @name GetProblem
7462
- * @summary `GET /api/v1/scheduling/problems/{id}` — read the current state.
7463
- * @request GET:/api/v1/scheduling/problems/{problem_id}
7464
- */
7465
- getProblem = (problemId, params = {}) => this.http.request({
7466
- path: `/api/v1/scheduling/problems/${problemId}`,
7467
- method: "GET",
7468
- format: "json",
7469
- ...params
7470
- });
7471
- /**
7472
- * @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.
7473
- *
7474
- * @tags scheduling
7475
- * @name ListAssignments
7476
- * @summary `GET /api/v1/scheduling/problems/{id}/assignments`
7477
- * @request GET:/api/v1/scheduling/problems/{problem_id}/assignments
7478
- */
7479
- listAssignments = (problemId, params = {}) => this.http.request({
7480
- path: `/api/v1/scheduling/problems/${problemId}/assignments`,
7481
- method: "GET",
7482
- format: "json",
7483
- ...params
7484
- });
7485
7409
  /**
7486
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 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.
7487
7411
  *
@@ -7498,46 +7422,6 @@ var Scheduling = class {
7498
7422
  format: "json",
7499
7423
  ...params
7500
7424
  });
7501
- /**
7502
- * No description
7503
- *
7504
- * @tags scheduling
7505
- * @name RemovePin
7506
- * @summary `DELETE /api/v1/scheduling/problems/{id}/pins/{pin_id}`
7507
- * @request DELETE:/api/v1/scheduling/problems/{problem_id}/pins/{pin_id}
7508
- */
7509
- removePin = (problemId, pinId, params = {}) => this.http.request({
7510
- path: `/api/v1/scheduling/problems/${problemId}/pins/${pinId}`,
7511
- method: "DELETE",
7512
- ...params
7513
- });
7514
- /**
7515
- * No description
7516
- *
7517
- * @tags scheduling
7518
- * @name RemovePreference
7519
- * @summary `DELETE /api/v1/scheduling/problems/{id}/preferences/{preference_id}`
7520
- * @request DELETE:/api/v1/scheduling/problems/{problem_id}/preferences/{preference_id}
7521
- */
7522
- removePreference = (problemId, preferenceId, params = {}) => this.http.request({
7523
- path: `/api/v1/scheduling/problems/${problemId}/preferences/${preferenceId}`,
7524
- method: "DELETE",
7525
- ...params
7526
- });
7527
- /**
7528
- * @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`.
7529
- *
7530
- * @tags scheduling
7531
- * @name SolveProblem
7532
- * @summary `POST /api/v1/scheduling/problems/{id}/solve`
7533
- * @request POST:/api/v1/scheduling/problems/{problem_id}/solve
7534
- */
7535
- solveProblem = (problemId, params = {}) => this.http.request({
7536
- path: `/api/v1/scheduling/problems/${problemId}/solve`,
7537
- method: "POST",
7538
- format: "json",
7539
- ...params
7540
- });
7541
7425
  };
7542
7426
 
7543
7427
  // src/api-spec/generated/Admin.ts
@@ -20697,105 +20581,6 @@ function SchedulingOptimizeResponseFromApiToFront(dto) {
20697
20581
  assignments: dto.assignments.map(AssignmentFromApiToFront)
20698
20582
  };
20699
20583
  }
20700
- function CreateSchedulingProblemRequestFromFrontToApi(request) {
20701
- const dto = {
20702
- agents: request.agents.map(AgentSpecFromFrontToApi),
20703
- days: request.days,
20704
- shifts_per_day: request.shiftsPerDay,
20705
- demands: request.demands.map(ShiftDemandFromFrontToApi)
20706
- };
20707
- if (request.pins !== void 0) {
20708
- dto.pins = request.pins.map(PinFromFrontToApi);
20709
- }
20710
- if (request.preferences !== void 0) {
20711
- dto.preferences = request.preferences.map(PreferenceFromFrontToApi);
20712
- }
20713
- return dto;
20714
- }
20715
- function CreateSchedulingProblemResponseFromApiToFront(dto) {
20716
- return {
20717
- problemId: dto.problem_id
20718
- };
20719
- }
20720
- function SolveSchedulingProblemResponseFromApiToFront(dto) {
20721
- return {
20722
- status: dto.status,
20723
- totalScore: dto.total_score
20724
- };
20725
- }
20726
- function SchedulingAssignmentsResponseFromApiToFront(dto) {
20727
- return {
20728
- totalScore: dto.total_score,
20729
- assignments: dto.assignments.map(AssignmentFromApiToFront)
20730
- };
20731
- }
20732
- function AddPinRequestFromFrontToApi(request) {
20733
- const dto = {
20734
- agent_id: request.agentId,
20735
- day: request.day,
20736
- shift: request.shift
20737
- };
20738
- if (request.role !== void 0) {
20739
- dto.role = request.role;
20740
- }
20741
- return dto;
20742
- }
20743
- function AddPinResponseFromApiToFront(dto) {
20744
- return {
20745
- pinId: dto.pin_id,
20746
- version: dto.version
20747
- };
20748
- }
20749
- function AddPreferenceRequestFromFrontToApi(request) {
20750
- return {
20751
- agent_id: request.agentId,
20752
- day: request.day,
20753
- shift: request.shift,
20754
- score: request.score
20755
- };
20756
- }
20757
- function AddPreferenceResponseFromApiToFront(dto) {
20758
- return {
20759
- preferenceId: dto.preference_id,
20760
- version: dto.version
20761
- };
20762
- }
20763
- function PinEntryFromApiToFront(dto) {
20764
- const entry = {
20765
- pinId: dto.pin_id,
20766
- agentId: dto.agent_id,
20767
- day: dto.day,
20768
- shift: dto.shift
20769
- };
20770
- if (dto.role !== void 0 && dto.role !== null) {
20771
- entry.role = dto.role;
20772
- }
20773
- return entry;
20774
- }
20775
- function PreferenceEntryFromApiToFront(dto) {
20776
- return {
20777
- preferenceId: dto.preference_id,
20778
- agentId: dto.agent_id,
20779
- day: dto.day,
20780
- shift: dto.shift,
20781
- score: dto.score
20782
- };
20783
- }
20784
- function SchedulingProblemFromApiToFront(dto) {
20785
- const problem = {
20786
- problemId: dto.problem_id,
20787
- days: dto.days,
20788
- shiftsPerDay: dto.shifts_per_day,
20789
- version: dto.version,
20790
- pins: dto.pins.map(PinEntryFromApiToFront),
20791
- preferences: dto.preferences.map(PreferenceEntryFromApiToFront),
20792
- totalScore: dto.total_score
20793
- };
20794
- if (dto.latest_solve_status !== void 0 && dto.latest_solve_status !== null) {
20795
- problem.latestSolveStatus = dto.latest_solve_status;
20796
- }
20797
- return problem;
20798
- }
20799
20584
 
20800
20585
  // src/resources/scheduling.ts
20801
20586
  var SchedulingClient = class {
@@ -20890,159 +20675,6 @@ var SchedulingClient = class {
20890
20675
  );
20891
20676
  return SchedulingOptimizeResponseFromApiToFront(response.data);
20892
20677
  }
20893
- // ── Snapshot-driven endpoints (POST /scheduling/problems/*) ───────
20894
- /**
20895
- * Freeze the inline scheduling inputs into a `scheduling.problem`
20896
- * Ψ-term snapshot stored under the caller's tenant, and return the
20897
- * snapshot's `problemId`. The endpoint does NOT solve — call
20898
- * {@link SchedulingClient.solveProblem} afterwards to compute the
20899
- * optimum, then {@link SchedulingClient.listAssignments} to fetch
20900
- * the per-cell trichotomy.
20901
- *
20902
- * @param request - same inline shape as
20903
- * {@link SchedulingClient.optimize}.
20904
- * @returns the snapshot ID, useful for subsequent re-solves and
20905
- * provenance lookups.
20906
- * @throws HTTP 400 on malformed input (duplicate agent IDs,
20907
- * ambiguous pin role, unknown pin or preference agent ID,
20908
- * role minima exceeding total demand, etc.).
20909
- *
20910
- * @remarks
20911
- * Re-solves read only the snapshot, so the optimum is reproducible
20912
- * and auditable from the moment the problem is created. The
20913
- * snapshot persists across solves — pin a problem once, re-solve
20914
- * many times.
20915
- *
20916
- * @example
20917
- * ```typescript
20918
- * const { problemId } = await client.scheduling.createProblem({
20919
- * agents: [{ id: 'alice', roles: ['icu'], maxAssignments: 3 }],
20920
- * days: 7,
20921
- * shiftsPerDay: 3,
20922
- * demands: [{ day: 0, shift: 0, total: 1, roleMinimums: { icu: 1 } }],
20923
- * preferences: [{ agentId: 'alice', day: 0, shift: 0, score: 5 }],
20924
- * });
20925
- * await client.scheduling.solveProblem(problemId);
20926
- * const { totalScore, assignments } =
20927
- * await client.scheduling.listAssignments(problemId);
20928
- * ```
20929
- */
20930
- async createProblem(request) {
20931
- const response = await this.api.createProblem(
20932
- CreateSchedulingProblemRequestFromFrontToApi(request)
20933
- );
20934
- return CreateSchedulingProblemResponseFromApiToFront(response.data);
20935
- }
20936
- /**
20937
- * Re-solve a previously-stored snapshot, lift the per-cell
20938
- * trichotomy into `scheduling.assignment` Ψ-terms (idempotent —
20939
- * previously lifted assignments are replaced), and return the
20940
- * optimum's `totalScore`.
20941
- *
20942
- * @param problemId - the ID returned by
20943
- * {@link SchedulingClient.createProblem}.
20944
- * @throws HTTP 404 when the problem doesn't exist for the caller's
20945
- * tenant. HTTP 400 for malformed problem IDs.
20946
- *
20947
- * @remarks
20948
- * Returns only `status` and `totalScore`; fetch the per-cell
20949
- * trichotomy with {@link SchedulingClient.listAssignments}.
20950
- * Re-running this method on the same `problemId` is safe — the
20951
- * lifted assignment terms are replaced atomically.
20952
- */
20953
- async solveProblem(problemId) {
20954
- const response = await this.api.solveProblem(problemId);
20955
- return SolveSchedulingProblemResponseFromApiToFront(response.data);
20956
- }
20957
- /**
20958
- * Retrieve the lifted `scheduling.assignment` Ψ-terms produced by
20959
- * the most recent solve.
20960
- *
20961
- * @param problemId - the ID returned by
20962
- * {@link SchedulingClient.createProblem}.
20963
- * @throws HTTP 404 when the problem doesn't exist for the caller's
20964
- * tenant. HTTP 400 for malformed problem IDs.
20965
- *
20966
- * @remarks
20967
- * Returns one entry per `(agent, day, shift)` cell — including
20968
- * `free` cells, so consumers can residuate on cells the optimizer
20969
- * is indifferent about. `assignments` is empty when the problem
20970
- * exists but hasn't been solved yet.
20971
- *
20972
- * `totalScore` mirrors the most recent solve's optimum value, or
20973
- * `0` when the problem hasn't been solved.
20974
- */
20975
- async listAssignments(problemId) {
20976
- const response = await this.api.listAssignments(problemId);
20977
- return SchedulingAssignmentsResponseFromApiToFront(response.data);
20978
- }
20979
- // ── Mutation methods on the live problem ──────────────────────────
20980
- /**
20981
- * Read the current state of a stored problem — its pins,
20982
- * preferences, version counter, and latest-solve metadata.
20983
- *
20984
- * @remarks
20985
- * Pin and preference entries carry stable IDs (`pinId`,
20986
- * `preferenceId`) — pass those to {@link SchedulingClient.removePin}
20987
- * / {@link SchedulingClient.removePreference} to delete them.
20988
- *
20989
- * @throws HTTP 404 when the problem doesn't exist for the
20990
- * caller's tenant.
20991
- */
20992
- async getProblem(problemId) {
20993
- const response = await this.api.getProblem(problemId);
20994
- return SchedulingProblemFromApiToFront(response.data);
20995
- }
20996
- /**
20997
- * Append a pin to a stored problem. Returns the pin's stable
20998
- * ID and the problem's new version. Multiple pins on the same
20999
- * `(agent, day, shift)` are not deduplicated server-side; if you
21000
- * want at-most-one-pin-per-cell semantics, enforce it on the
21001
- * client by checking the pin entries from
21002
- * {@link SchedulingClient.getProblem} first.
21003
- *
21004
- * @throws HTTP 400 when the agent isn't on the problem's roster
21005
- * or the (day, shift) is outside the grid. HTTP 404 when the
21006
- * problem doesn't exist for the caller's tenant.
21007
- */
21008
- async addPin(problemId, request) {
21009
- const response = await this.api.addPin(
21010
- problemId,
21011
- AddPinRequestFromFrontToApi(request)
21012
- );
21013
- return AddPinResponseFromApiToFront(response.data);
21014
- }
21015
- /**
21016
- * Remove a pin previously added via
21017
- * {@link SchedulingClient.addPin}.
21018
- *
21019
- * @throws HTTP 404 when the problem doesn't exist for the
21020
- * tenant or the `pinId` doesn't match any current pin
21021
- * (already removed, stale ID).
21022
- */
21023
- async removePin(problemId, pinId) {
21024
- await this.api.removePin(problemId, pinId);
21025
- }
21026
- /**
21027
- * Append a preference to a stored problem. Same return shape as
21028
- * {@link SchedulingClient.addPin} — `preferenceId` is the stable
21029
- * handle for removal. Multiple preferences targeting the same
21030
- * cell sum on the next solve.
21031
- */
21032
- async addPreference(problemId, request) {
21033
- const response = await this.api.addPreference(
21034
- problemId,
21035
- AddPreferenceRequestFromFrontToApi(request)
21036
- );
21037
- return AddPreferenceResponseFromApiToFront(response.data);
21038
- }
21039
- /**
21040
- * Remove a preference previously added via
21041
- * {@link SchedulingClient.addPreference}.
21042
- */
21043
- async removePreference(problemId, preferenceId) {
21044
- await this.api.removePreference(problemId, preferenceId);
21045
- }
21046
20678
  };
21047
20679
 
21048
20680
  // src/normalizers/osfql.ts