@oisin-ee/oisinpi 0.9.0 → 0.9.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/CHANGELOG.md +10 -0
- package/node_modules/@oisin-ee/pi-guardrails/package.json +1 -1
- package/node_modules/@oisin-ee/pi-prewalk/package.json +1 -1
- package/node_modules/@oisin-ee/pi-tiers/package.json +1 -1
- package/node_modules/@oisin-ee/pi-tiers/src/recovery.ts +3 -1
- package/node_modules/@oisin-ee/pi-tiers/src/router.ts +25 -6
- package/node_modules/@oisin-ee/pi-todo/package.json +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @oisin-ee/oisinpi
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`bcba2d4`](https://github.com/oisin-ee/oisinpi/commit/bcba2d42673c2cf12c23b62079c2a96c0b098e30)]:
|
|
8
|
+
- @oisin-ee/pi-tiers@0.9.1
|
|
9
|
+
- @oisin-ee/pi-guardrails@0.9.1
|
|
10
|
+
- @oisin-ee/pi-prewalk@0.9.1
|
|
11
|
+
- @oisin-ee/pi-todo@0.9.1
|
|
12
|
+
|
|
3
13
|
## 0.9.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -9,6 +9,7 @@ import type { Context } from "./ports.ts";
|
|
|
9
9
|
import type { Router } from "./router.ts";
|
|
10
10
|
import type { Tiers } from "./config.ts";
|
|
11
11
|
import { classify } from "./policy.ts";
|
|
12
|
+
import { listed } from "./router.ts";
|
|
12
13
|
|
|
13
14
|
const ZERO = 0,
|
|
14
15
|
ONE = 1;
|
|
@@ -76,7 +77,8 @@ class Recovery {
|
|
|
76
77
|
}
|
|
77
78
|
const tier = ctx.model.id,
|
|
78
79
|
state = branchState(ctx.sessionManager.getBranch(), tier),
|
|
79
|
-
|
|
80
|
+
tierTargets = this.#tiers.get(tier),
|
|
81
|
+
targets = tierTargets === undefined ? undefined : listed(tierTargets, ctx),
|
|
80
82
|
message = event.context.contextMessages.findLast((item) => item.role === "assistant"),
|
|
81
83
|
entry = event.context.contextEntries.findLast(
|
|
82
84
|
(item: Readonly<{ sourceEntry: SessionEntry; messages: readonly unknown[] }>) =>
|
|
@@ -10,7 +10,23 @@ import type { Window } from "./quota.ts";
|
|
|
10
10
|
|
|
11
11
|
const ZERO = 0,
|
|
12
12
|
ONE = 1,
|
|
13
|
-
CACHE_MS = 60_000
|
|
13
|
+
CACHE_MS = 60_000,
|
|
14
|
+
/**
|
|
15
|
+
* Keeps only targets the model registry lists, so a provider model that is not
|
|
16
|
+
* configured yet behaves like an unavailable target instead of a terminal error.
|
|
17
|
+
* @param {readonly string[]} targets Ordered tier.
|
|
18
|
+
* @param {Context} ctx Pi authority.
|
|
19
|
+
* @returns {readonly string[]} Listed targets, in tier order.
|
|
20
|
+
*/
|
|
21
|
+
listed = (targets: readonly string[], ctx: Context): readonly string[] => {
|
|
22
|
+
const available = new Set(
|
|
23
|
+
ctx.modelRegistry.getAvailable().map((candidate) => `${candidate.provider}/${candidate.id}`),
|
|
24
|
+
);
|
|
25
|
+
return targets.filter((reference) => {
|
|
26
|
+
const parsed = target(reference);
|
|
27
|
+
return available.has(`${parsed.provider}/${parsed.id}`);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
14
30
|
|
|
15
31
|
/** Sticky routing with host-wide quota and gateway health. */
|
|
16
32
|
class Router {
|
|
@@ -139,19 +155,20 @@ class Router {
|
|
|
139
155
|
|
|
140
156
|
/**
|
|
141
157
|
* Routes a tier without fabricating conversation messages.
|
|
142
|
-
* @param {readonly string[]}
|
|
158
|
+
* @param {readonly string[]} tier Ordered physical models, listed or not.
|
|
143
159
|
* @param {Request} request Pi request.
|
|
144
160
|
* @param {Context} ctx Pi authority.
|
|
145
161
|
* @returns {Promise<ModelRoute<State>>} Physical dispatch.
|
|
146
162
|
*/
|
|
147
163
|
public async route(
|
|
148
|
-
|
|
164
|
+
tier: readonly string[],
|
|
149
165
|
request: Request,
|
|
150
166
|
ctx: Context,
|
|
151
167
|
): Promise<ModelRoute<State>> {
|
|
152
168
|
request.signal?.throwIfAborted();
|
|
153
169
|
await this.#refresh();
|
|
154
|
-
const
|
|
170
|
+
const targets = listed(tier, ctx),
|
|
171
|
+
previous =
|
|
155
172
|
request.reason === "direct"
|
|
156
173
|
? undefined
|
|
157
174
|
: (branchState(ctx.sessionManager.getBranch(), request.model.id) ?? request.state),
|
|
@@ -163,7 +180,9 @@ class Router {
|
|
|
163
180
|
state = await this.#retry(request, current),
|
|
164
181
|
health = await this.#effects.read(),
|
|
165
182
|
chosen =
|
|
166
|
-
|
|
183
|
+
targets.includes(state.chosen) &&
|
|
184
|
+
!state.attempted.includes(state.chosen) &&
|
|
185
|
+
this.#available(state.chosen, health)
|
|
167
186
|
? state.chosen
|
|
168
187
|
: await this.next(targets, state);
|
|
169
188
|
if (chosen === undefined) {
|
|
@@ -173,4 +192,4 @@ class Router {
|
|
|
173
192
|
}
|
|
174
193
|
}
|
|
175
194
|
|
|
176
|
-
export { Router };
|
|
195
|
+
export { Router, listed };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oisin-ee/oisinpi",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Oisin's pi packages in one install: prewalk, todo, tiers, and guardrails.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"guardrails",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@oisin-ee/pi-guardrails": "0.9.
|
|
21
|
-
"@oisin-ee/pi-prewalk": "0.9.
|
|
22
|
-
"@oisin-ee/pi-tiers": "0.9.
|
|
23
|
-
"@oisin-ee/pi-todo": "0.9.
|
|
20
|
+
"@oisin-ee/pi-guardrails": "0.9.1",
|
|
21
|
+
"@oisin-ee/pi-prewalk": "0.9.1",
|
|
22
|
+
"@oisin-ee/pi-tiers": "0.9.1",
|
|
23
|
+
"@oisin-ee/pi-todo": "0.9.1"
|
|
24
24
|
},
|
|
25
25
|
"bundleDependencies": [
|
|
26
26
|
"@oisin-ee/pi-guardrails",
|