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