@kortexya/reasoninglayer 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +131 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +314 -7
- package/dist/index.d.ts +314 -7
- package/dist/index.js +131 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __export = (target, all) => {
|
|
5
|
+
for (var name in all)
|
|
6
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
+
};
|
|
8
|
+
|
|
3
9
|
// src/config.ts
|
|
4
|
-
var SDK_VERSION = "0.
|
|
10
|
+
var SDK_VERSION = "0.21.0";
|
|
5
11
|
function resolveConfig(config) {
|
|
6
12
|
if (!config.baseUrl) {
|
|
7
13
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -951,11 +957,10 @@ var Sorts = class {
|
|
|
951
957
|
...params
|
|
952
958
|
});
|
|
953
959
|
/**
|
|
954
|
-
*
|
|
960
|
+
* No description
|
|
955
961
|
*
|
|
956
962
|
* @tags sorts
|
|
957
963
|
* @name IndexSorts
|
|
958
|
-
* @summary Index all sorts for a tenant into the vector store (Qdrant).
|
|
959
964
|
* @request POST:/api/v1/sorts/index
|
|
960
965
|
* @secure
|
|
961
966
|
*/
|
|
@@ -7386,7 +7391,7 @@ var Scheduling = class {
|
|
|
7386
7391
|
this.http = http;
|
|
7387
7392
|
}
|
|
7388
7393
|
/**
|
|
7389
|
-
* @description Classify every `(agent, day, shift)` cell in the input grid as confirmed-true, confirmed-false, or free. Input validation errors (duplicate agent IDs, out-of-range pins, role minima exceeding total demand, 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.
|
|
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.
|
|
7390
7395
|
*
|
|
7391
7396
|
* @tags scheduling
|
|
7392
7397
|
* @name Feasibility
|
|
@@ -7401,6 +7406,22 @@ var Scheduling = class {
|
|
|
7401
7406
|
format: "json",
|
|
7402
7407
|
...params
|
|
7403
7408
|
});
|
|
7409
|
+
/**
|
|
7410
|
+
* @description Same hard constraints as `/scheduling/feasibility` plus a list of soft `preferences` (each a per-cell score added to the optimizer's objective). Returns the per-cell trichotomy across the space of **optimal** schedules, plus `total_score` (sum of preference scores at chosen cells in the optimum). `confirmed_true` / `confirmed_false` here are stronger than in `/feasibility`: they hold across every optimum, not every feasible schedule. Cells with status `free` indicate ties — multiple optima exist and the cell varies between them. Preferences targeting cells that are already pinned, blocked by a day-off, restricted-to-shift, or otherwise structurally fixed are silently ignored — those cells are not the optimizer's choice to make.
|
|
7411
|
+
*
|
|
7412
|
+
* @tags scheduling
|
|
7413
|
+
* @name Optimize
|
|
7414
|
+
* @summary `POST /api/v1/scheduling/optimize`
|
|
7415
|
+
* @request POST:/api/v1/scheduling/optimize
|
|
7416
|
+
*/
|
|
7417
|
+
optimize = (data, params = {}) => this.http.request({
|
|
7418
|
+
path: `/api/v1/scheduling/optimize`,
|
|
7419
|
+
method: "POST",
|
|
7420
|
+
body: data,
|
|
7421
|
+
type: "application/json" /* Json */,
|
|
7422
|
+
format: "json",
|
|
7423
|
+
...params
|
|
7424
|
+
});
|
|
7404
7425
|
};
|
|
7405
7426
|
|
|
7406
7427
|
// src/api-spec/generated/Admin.ts
|
|
@@ -20493,11 +20514,15 @@ function ShiftDemandFromFrontToApi(demand) {
|
|
|
20493
20514
|
return dto;
|
|
20494
20515
|
}
|
|
20495
20516
|
function PinFromFrontToApi(pin) {
|
|
20496
|
-
|
|
20517
|
+
const dto = {
|
|
20497
20518
|
agent_id: pin.agentId,
|
|
20498
20519
|
day: pin.day,
|
|
20499
20520
|
shift: pin.shift
|
|
20500
20521
|
};
|
|
20522
|
+
if (pin.role !== void 0) {
|
|
20523
|
+
dto.role = pin.role;
|
|
20524
|
+
}
|
|
20525
|
+
return dto;
|
|
20501
20526
|
}
|
|
20502
20527
|
function SchedulingFeasibilityRequestFromFrontToApi(request) {
|
|
20503
20528
|
const dto = {
|
|
@@ -20516,7 +20541,8 @@ function AssignmentFromApiToFront(dto) {
|
|
|
20516
20541
|
agentId: dto.agent_id,
|
|
20517
20542
|
day: dto.day,
|
|
20518
20543
|
shift: dto.shift,
|
|
20519
|
-
status: dto.status
|
|
20544
|
+
status: dto.status,
|
|
20545
|
+
roles: dto.roles ?? []
|
|
20520
20546
|
};
|
|
20521
20547
|
}
|
|
20522
20548
|
function SchedulingFeasibilityResponseFromApiToFront(dto) {
|
|
@@ -20525,6 +20551,36 @@ function SchedulingFeasibilityResponseFromApiToFront(dto) {
|
|
|
20525
20551
|
assignments: dto.assignments.map(AssignmentFromApiToFront)
|
|
20526
20552
|
};
|
|
20527
20553
|
}
|
|
20554
|
+
function PreferenceFromFrontToApi(pref) {
|
|
20555
|
+
return {
|
|
20556
|
+
agent_id: pref.agentId,
|
|
20557
|
+
day: pref.day,
|
|
20558
|
+
shift: pref.shift,
|
|
20559
|
+
score: pref.score
|
|
20560
|
+
};
|
|
20561
|
+
}
|
|
20562
|
+
function SchedulingOptimizeRequestFromFrontToApi(request) {
|
|
20563
|
+
const dto = {
|
|
20564
|
+
agents: request.agents.map(AgentSpecFromFrontToApi),
|
|
20565
|
+
days: request.days,
|
|
20566
|
+
shifts_per_day: request.shiftsPerDay,
|
|
20567
|
+
demands: request.demands.map(ShiftDemandFromFrontToApi)
|
|
20568
|
+
};
|
|
20569
|
+
if (request.pins !== void 0) {
|
|
20570
|
+
dto.pins = request.pins.map(PinFromFrontToApi);
|
|
20571
|
+
}
|
|
20572
|
+
if (request.preferences !== void 0) {
|
|
20573
|
+
dto.preferences = request.preferences.map(PreferenceFromFrontToApi);
|
|
20574
|
+
}
|
|
20575
|
+
return dto;
|
|
20576
|
+
}
|
|
20577
|
+
function SchedulingOptimizeResponseFromApiToFront(dto) {
|
|
20578
|
+
return {
|
|
20579
|
+
status: dto.status,
|
|
20580
|
+
totalScore: dto.total_score,
|
|
20581
|
+
assignments: dto.assignments.map(AssignmentFromApiToFront)
|
|
20582
|
+
};
|
|
20583
|
+
}
|
|
20528
20584
|
|
|
20529
20585
|
// src/resources/scheduling.ts
|
|
20530
20586
|
var SchedulingClient = class {
|
|
@@ -20555,6 +20611,70 @@ var SchedulingClient = class {
|
|
|
20555
20611
|
);
|
|
20556
20612
|
return SchedulingFeasibilityResponseFromApiToFront(response.data);
|
|
20557
20613
|
}
|
|
20614
|
+
/**
|
|
20615
|
+
* Solve the scheduling problem with **soft preferences** and
|
|
20616
|
+
* return the per-cell envelope across the space of *optimal*
|
|
20617
|
+
* schedules.
|
|
20618
|
+
*
|
|
20619
|
+
* @param request - the scheduling problem plus optional
|
|
20620
|
+
* `preferences` (per-cell scores added to the optimizer's
|
|
20621
|
+
* objective). Same hard-constraint shape as
|
|
20622
|
+
* {@link SchedulingClient.feasibility}.
|
|
20623
|
+
* @returns a {@link SchedulingOptimizeResponse} with `totalScore`
|
|
20624
|
+
* and per-cell trichotomy across optimal schedules.
|
|
20625
|
+
*
|
|
20626
|
+
* @throws HTTP 400 errors are surfaced when the input is malformed
|
|
20627
|
+
* (duplicate agent IDs, pins or preferences referencing unknown
|
|
20628
|
+
* agents, ambiguous pin role on multi-role agents, role minima
|
|
20629
|
+
* exceeding total demand, etc.).
|
|
20630
|
+
*
|
|
20631
|
+
* @remarks
|
|
20632
|
+
* The trichotomy returned here is **strictly stronger** than the
|
|
20633
|
+
* one from {@link SchedulingClient.feasibility}:
|
|
20634
|
+
*
|
|
20635
|
+
* - `"confirmed_true"` — assigned in *every* optimum.
|
|
20636
|
+
* - `"confirmed_false"` — assigned in *no* optimum.
|
|
20637
|
+
* - `"free"` — varies across the optima; the optimizer is indifferent
|
|
20638
|
+
* between equally-good choices.
|
|
20639
|
+
*
|
|
20640
|
+
* `totalScore` is the sum of {@link Preference.score} over assigned
|
|
20641
|
+
* cells in the optimum (`0` when no preferences are supplied or
|
|
20642
|
+
* the problem is infeasible).
|
|
20643
|
+
*
|
|
20644
|
+
* Preferences targeting structurally-fixed cells (pinned cells,
|
|
20645
|
+
* day-off / shift-only restricted cells, agents not in the grid)
|
|
20646
|
+
* are silently ignored — the optimizer has no choice to make there.
|
|
20647
|
+
*
|
|
20648
|
+
* Empty `preferences` is equivalent to calling
|
|
20649
|
+
* {@link SchedulingClient.feasibility} (every feasible schedule
|
|
20650
|
+
* is optimal under a zero objective), but slower; prefer
|
|
20651
|
+
* `feasibility()` when you only need the feasibility envelope.
|
|
20652
|
+
*
|
|
20653
|
+
* @example Score Aisha as a strong preference for emergency cover
|
|
20654
|
+
* ```typescript
|
|
20655
|
+
* const report = await client.scheduling.optimize({
|
|
20656
|
+
* agents: [
|
|
20657
|
+
* { id: 'aisha', roles: ['icu', 'emergency'], maxAssignments: 5 },
|
|
20658
|
+
* { id: 'bob', roles: ['general'], maxAssignments: 5 },
|
|
20659
|
+
* ],
|
|
20660
|
+
* days: 7,
|
|
20661
|
+
* shiftsPerDay: 3,
|
|
20662
|
+
* demands: [{ day: 0, shift: 0, total: 2, roleMinimums: { icu: 1 } }],
|
|
20663
|
+
* preferences: [
|
|
20664
|
+
* { agentId: 'aisha', day: 0, shift: 0, score: 10 },
|
|
20665
|
+
* ],
|
|
20666
|
+
* });
|
|
20667
|
+
*
|
|
20668
|
+
* console.log(report.totalScore); // 10 if Aisha is in the optimum
|
|
20669
|
+
* console.log(report.status); // 'feasible' | 'infeasible'
|
|
20670
|
+
* ```
|
|
20671
|
+
*/
|
|
20672
|
+
async optimize(request) {
|
|
20673
|
+
const response = await this.api.optimize(
|
|
20674
|
+
SchedulingOptimizeRequestFromFrontToApi(request)
|
|
20675
|
+
);
|
|
20676
|
+
return SchedulingOptimizeResponseFromApiToFront(response.data);
|
|
20677
|
+
}
|
|
20558
20678
|
};
|
|
20559
20679
|
|
|
20560
20680
|
// src/normalizers/osfql.ts
|
|
@@ -22090,6 +22210,10 @@ var optimize_exports = {};
|
|
|
22090
22210
|
|
|
22091
22211
|
// src/types/scheduling.ts
|
|
22092
22212
|
var scheduling_exports = {};
|
|
22213
|
+
__export(scheduling_exports, {
|
|
22214
|
+
ANY_ROLE: () => ANY_ROLE
|
|
22215
|
+
});
|
|
22216
|
+
var ANY_ROLE = "any";
|
|
22093
22217
|
|
|
22094
22218
|
// src/types/ilp.ts
|
|
22095
22219
|
var ilp_exports = {};
|
|
@@ -22780,6 +22904,7 @@ function discriminateFeatureValue(value) {
|
|
|
22780
22904
|
);
|
|
22781
22905
|
}
|
|
22782
22906
|
|
|
22907
|
+
exports.ANY_ROLE = ANY_ROLE;
|
|
22783
22908
|
exports.ActionReviews = action_reviews_exports;
|
|
22784
22909
|
exports.Admin = admin_exports;
|
|
22785
22910
|
exports.Analysis = analysis_exports;
|