@plumbus/ai-decision-typesafe 0.2.1 → 0.3.0-beta.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/CHANGELOG.md +10 -1
- package/README.md +9 -3
- package/dist/.tsbuildinfo +1 -1
- package/instructions/README.md +8 -3
- package/instructions/framework.md +15 -3
- package/instructions/testing.md +6 -1
- package/package.json +4 -4
package/instructions/README.md
CHANGED
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
| [framework.md](framework.md) | Installation, public exports, adapter boundary, usage rules |
|
|
6
6
|
| [testing.md](testing.md) | Offline validation and live environment setup |
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
**Classification, categorization, provider/model selection, TypeSafe/Jev or Laya:**
|
|
9
|
+
read `node_modules/@plumbus/core/instructions/ai-classification.md` first (core
|
|
10
|
+
**0.8.0-beta.6+**), then [framework.md](framework.md) for this package.
|
|
11
|
+
|
|
12
|
+
Core 0.8.0-beta.6+ provides `ctx.ai.decide()` and also routes `ctx.ai.classify()`
|
|
13
|
+
to explicitly registered decision adapters. Keep app business logic in Plumbus
|
|
14
|
+
primitives and `ctx.*`. Never route predictions around capability access checks
|
|
15
|
+
or confirmation policy. Provider registration is explicit in `app/server.ts`.
|
|
11
16
|
|
|
12
17
|
[Package README](../README.md) · [Monorepo guide](https://github.com/plumbus-framework/plumbus/blob/main/docs/ai/decision-providers.md)
|
|
@@ -4,7 +4,7 @@ TypeSafe/Jev provider for typed choices, scores, and probabilities.
|
|
|
4
4
|
|
|
5
5
|
## Install and ownership
|
|
6
6
|
|
|
7
|
-
Install `@plumbus/ai-decision-typesafe` explicitly. Its core peer is exactly `"0.
|
|
7
|
+
Install `@plumbus/ai-decision-typesafe` explicitly. Its core peer is exactly `">=0.8.0-beta.0 <0.9.0"` (core 0.8 beta family).
|
|
8
8
|
Consumers reuse Zod/testing utilities from core; do not install them separately.
|
|
9
9
|
Use this package for bounded typed decisions. Use core generation and embeddings
|
|
10
10
|
for text responses and vector inference.
|
|
@@ -14,7 +14,19 @@ Public exports: `createTypeSafeDecisionAdapter` — construct an explicitly conf
|
|
|
14
14
|
File map: `src/index.ts` is the public barrel, `src/__tests__/` exercises the public
|
|
15
15
|
API, `instructions/` contains these recipes. Laya alone also ships `service/`.
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Classification and model selection (core 0.8.0-beta.6+)
|
|
18
|
+
|
|
19
|
+
Read `node_modules/@plumbus/core/instructions/ai-classification.md` for the complete
|
|
20
|
+
registration and usage recipe. Call `ctx.ai.classify({ text, labels, provider, model,
|
|
21
|
+
threshold })` inside capabilities/flows. `provider` is your registered decision map
|
|
22
|
+
key; `model` is an optional endpoint-supported ID. Native `threshold` defaults to
|
|
23
|
+
0.5 and returns all matching labels. Use `decide()` for richer questions.
|
|
24
|
+
|
|
25
|
+
Core records one `classify` cost row, including dispatched failures, with actual
|
|
26
|
+
model/usage and identity. Omitted `provider` still uses the text default. Keep
|
|
27
|
+
decision adapters under `decisions.providers`, separate from text providers.
|
|
28
|
+
|
|
29
|
+
## Minimal usage (infrastructure / smoke testing)
|
|
18
30
|
|
|
19
31
|
```ts
|
|
20
32
|
import { createTypeSafeDecisionAdapter } from '@plumbus/ai-decision-typesafe';
|
|
@@ -33,7 +45,7 @@ console.log(result.answers.refund.probability);
|
|
|
33
45
|
1. Keep capabilities, flows, access policy and `ctx.*` as the application implementation path.
|
|
34
46
|
2. Construct adapters at a server-owned infrastructure boundary and inject them. Keep keys on the server.
|
|
35
47
|
3. Treat direct adapter usage as protocol integration, not a replacement for core's security/budget/audit lifecycle.
|
|
36
|
-
4. With core 0.
|
|
48
|
+
4. With core 0.8.0-beta.6+, use `ctx.ai.decide()` in capabilities/flows. Export `decisions = { providers, defaultProvider }` from `app/server.ts`; API and workers share it. Do not register decision adapters as completion providers.
|
|
37
49
|
5. Preserve distributions and provider confidence separately. A high confidence value is not authorization or proof of correctness.
|
|
38
50
|
6. Validate thresholds on the actual task/model/language. Unknown cost is `null`, not free.
|
|
39
51
|
7. Pass `signal: ctx.signal` and `timeoutMs` where needed. Flow steps supply their signal by default.
|
package/instructions/testing.md
CHANGED
|
@@ -18,7 +18,12 @@ Validate choices, scores, probabilities, actual model/routing, usage and unknown
|
|
|
18
18
|
cost handling. Measure live accuracy and calibration separately from connection
|
|
19
19
|
success. Do not assert a universal confidence cutoff or guaranteed live label.
|
|
20
20
|
|
|
21
|
-
For core 0.
|
|
21
|
+
For core 0.8.0-beta.6+ classification, use `mockAI({ classify: ['billing'] })` and test
|
|
22
|
+
through `runCapability()` / `simulateFlow()`. Integration tests should assert
|
|
23
|
+
provider/model forwarding, zero/multiple matches, inclusive thresholds, and one
|
|
24
|
+
`classify` cost row. Use injected fetch; routine tests do not require live Laya.
|
|
25
|
+
|
|
26
|
+
For core 0.8.0-beta.6+ integration tests, configure `mockAI({ decide: result })` or a real
|
|
22
27
|
`createAIService({ decisions, costTracker, onAICostRecorded })` with injected
|
|
23
28
|
provider fetch. Assert exactly one cost row, identity, actual model/usage, unknown
|
|
24
29
|
cost handling, billed validation failures, and budget rejection before dispatch.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plumbus/ai-decision-typesafe",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-beta.0",
|
|
4
4
|
"description": "TypeSafe/Jev typed decision provider adapter for Plumbus.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -35,17 +35,17 @@
|
|
|
35
35
|
"node": ">=20.6.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@plumbus/core": "0.
|
|
38
|
+
"@plumbus/core": ">=0.8.0-beta.0 <0.9.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@biomejs/biome": "^2.4.6",
|
|
42
42
|
"@types/node": "^25.4.0",
|
|
43
43
|
"typescript": "^5.7.0",
|
|
44
44
|
"vitest": "^3.2.4",
|
|
45
|
-
"@plumbus/core": "0.
|
|
45
|
+
"@plumbus/core": "0.8.0-beta.6"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@plumbus/ai-decision": "~0.
|
|
48
|
+
"@plumbus/ai-decision": "~0.3.0-beta.0"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"build": "tsc -b",
|