@hanzo/build 0.2.116 → 0.2.117
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/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/mind.d.ts +7 -9
- package/lib/mind.js +13 -19
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export { href, parse, path, PLACES, route, SESSION, SLUG, type Route, type Scree
|
|
|
49
49
|
* (`Reply`), and the side panel (`Panel` over a `Deck` of tabs). The composer is
|
|
50
50
|
* @hanzo/ui/chat's, for Chat and Dev alike.
|
|
51
51
|
*/
|
|
52
|
-
export { catalog, EFFORTS, FIRST,
|
|
52
|
+
export { catalog, EFFORTS, FIRST, grants, isFree, keep, kept, level, nameOf, pacing, useCatalog, useChoice, useMind, type Choice, type Effort, type Mind } from './mind.ts';
|
|
53
53
|
export { useEar } from './voice.ts';
|
|
54
54
|
export { BARE, CHAT_MODES, DEV_MODES, gearOf, MODES, useGear, useLanguage, type Gear, type GearState, type Mode as GearMode } from './gear.ts';
|
|
55
55
|
export { useCarry, type Carry } from './carry.tsx';
|
package/lib/index.js
CHANGED
|
@@ -44,7 +44,7 @@ export { href, parse, path, PLACES, route, SESSION, SLUG } from './route.js';
|
|
|
44
44
|
* (`Reply`), and the side panel (`Panel` over a `Deck` of tabs). The composer is
|
|
45
45
|
* @hanzo/ui/chat's, for Chat and Dev alike.
|
|
46
46
|
*/
|
|
47
|
-
export { catalog, EFFORTS, FIRST,
|
|
47
|
+
export { catalog, EFFORTS, FIRST, grants, isFree, keep, kept, level, nameOf, pacing, useCatalog, useChoice, useMind } from './mind.js';
|
|
48
48
|
export { useEar } from './voice.js';
|
|
49
49
|
export { BARE, CHAT_MODES, DEV_MODES, gearOf, MODES, useGear, useLanguage } from './gear.js';
|
|
50
50
|
export { useCarry } from './carry.js';
|
package/lib/mind.d.ts
CHANGED
|
@@ -36,9 +36,7 @@ export interface Choice {
|
|
|
36
36
|
effort: Effort;
|
|
37
37
|
}
|
|
38
38
|
export declare const FIRST: Choice;
|
|
39
|
-
/**
|
|
40
|
-
export declare const FREE = "enso-free";
|
|
41
|
-
/** Whether a plan grants only the free lane. An unknown plan is not taken for Free. */
|
|
39
|
+
/** Whether a plan grants only Enso Auto. An unknown plan is not taken for Free. */
|
|
42
40
|
export declare const isFree: (plan: string | null | undefined) => boolean;
|
|
43
41
|
/** The kept choice, Enso and Auto where nothing is kept. Stable while the stored text is. Low and Medium, offered once, read as Auto. */
|
|
44
42
|
export declare function kept(): Choice;
|
|
@@ -46,7 +44,7 @@ export declare function kept(): Choice;
|
|
|
46
44
|
export declare function keep(patch: Partial<Choice>): void;
|
|
47
45
|
/** The kept choice and the way to change it. The server and the first render read the default. */
|
|
48
46
|
export declare function useChoice(): readonly [Choice, (patch: Partial<Choice>) => void];
|
|
49
|
-
/** A model's name as the catalog spells it; Enso for the router. */
|
|
47
|
+
/** A model's name as the catalog spells it; Enso Auto for the router. */
|
|
50
48
|
export declare function nameOf(model: string, catalog: readonly Model[]): string;
|
|
51
49
|
/** An id said as a name: its last path part, each word capitalised (`enso-flash` → Enso Flash). */
|
|
52
50
|
export declare function spelled(id: string): string;
|
|
@@ -74,8 +72,8 @@ export interface Catalog {
|
|
|
74
72
|
* the reason in the chooser — never the platform's own words.
|
|
75
73
|
*/
|
|
76
74
|
export declare function useCatalog(t: Target): Catalog;
|
|
77
|
-
/** Whether `model` is one this plan may send: on Free,
|
|
78
|
-
export declare function grants(free: boolean, model: string
|
|
75
|
+
/** Whether `model` is one this plan may send: on Free, Enso Auto alone (commerce's `allowedModels`). */
|
|
76
|
+
export declare function grants(free: boolean, model: string): boolean;
|
|
79
77
|
/** The effort as the composer reads it: the one in force, its list, and the way to change it. */
|
|
80
78
|
export declare const pacing: (m: Pick<Mind, 'effort' | 'pace'>) => Modes<Effort>;
|
|
81
79
|
/** The chip's whole state: the catalog, what answers next, and how to change either. */
|
|
@@ -87,7 +85,7 @@ export interface Mind {
|
|
|
87
85
|
error: string | null;
|
|
88
86
|
/** A list shown from before, because this read failed. */
|
|
89
87
|
note: string;
|
|
90
|
-
/** The plan grants only
|
|
88
|
+
/** The plan grants only Enso Auto: anything else is an upgrade, never a pick. */
|
|
91
89
|
free: boolean;
|
|
92
90
|
/** A premium pick holds for this screen; any other is kept. */
|
|
93
91
|
pick: (id: string) => void;
|
|
@@ -95,7 +93,7 @@ export interface Mind {
|
|
|
95
93
|
}
|
|
96
94
|
/**
|
|
97
95
|
* The model and effort for the plan `plan` names (`GET /v1/ai/limits` `plan`).
|
|
98
|
-
* On Free the
|
|
99
|
-
*
|
|
96
|
+
* On Free the model is Enso Auto, and a kept pick of any other is set aside
|
|
97
|
+
* rather than sent — it comes back once the plan grants it.
|
|
100
98
|
*/
|
|
101
99
|
export declare function useMind(t: Target, plan?: string | null): Mind;
|
package/lib/mind.js
CHANGED
|
@@ -9,9 +9,7 @@ export const EFFORTS = EVERY.filter((e) => ['auto', 'high', 'xhigh', 'max'].incl
|
|
|
9
9
|
/** The effort a coding run names (apps/coding takes low, medium or high): medium for Auto, high for the rest. */
|
|
10
10
|
export const level = (effort) => (effort === 'auto' ? 'medium' : 'high');
|
|
11
11
|
export const FIRST = { model: ENSO, effort: 'auto' };
|
|
12
|
-
/**
|
|
13
|
-
export const FREE = 'enso-free';
|
|
14
|
-
/** Whether a plan grants only the free lane. An unknown plan is not taken for Free. */
|
|
12
|
+
/** Whether a plan grants only Enso Auto. An unknown plan is not taken for Free. */
|
|
15
13
|
export const isFree = (plan) => plan === 'free';
|
|
16
14
|
const KEY = 'hanzo.mind';
|
|
17
15
|
const CHANGE = 'hanzo:mind';
|
|
@@ -79,12 +77,10 @@ function subscribe(change) {
|
|
|
79
77
|
export function useChoice() {
|
|
80
78
|
return [useSyncExternalStore(subscribe, kept, () => FIRST), keep];
|
|
81
79
|
}
|
|
82
|
-
/** A model's name as the catalog spells it; Enso for the router. */
|
|
80
|
+
/** A model's name as the catalog spells it; Enso Auto for the router. */
|
|
83
81
|
export function nameOf(model, catalog) {
|
|
84
82
|
if (model === ENSO)
|
|
85
|
-
return 'Enso';
|
|
86
|
-
if (model === 'free')
|
|
87
|
-
return nameOf(FREE, catalog);
|
|
83
|
+
return 'Enso Auto';
|
|
88
84
|
const row = catalog.find((m) => m.id === model);
|
|
89
85
|
return row?.name ?? spelled(model);
|
|
90
86
|
}
|
|
@@ -98,14 +94,14 @@ export function spelled(id) {
|
|
|
98
94
|
.join(' ');
|
|
99
95
|
}
|
|
100
96
|
/** The ids that are the router under another name: the picker's Enso row stands for all of them. */
|
|
101
|
-
export const ROUTER_IDS = new Set([ENSO, 'enso', 'hanzo/enso'
|
|
97
|
+
export const ROUTER_IDS = new Set([ENSO, 'enso', 'hanzo/enso']);
|
|
102
98
|
// The catalog, once per platform for the page: Chat and Dev read the same list.
|
|
103
99
|
const catalogs = new Map();
|
|
104
100
|
const settled = new Map();
|
|
105
101
|
/** Where this browser keeps the last list it read. */
|
|
106
102
|
const LAST = 'hanzo.build.models';
|
|
107
|
-
/** The router alone: what a chooser offers before any list was ever read, so it reads "Enso" and not an id. */
|
|
108
|
-
const ROUTER = parseModels([{ id: ENSO, name: 'Enso', family: 'enso', class: 'ours' }]);
|
|
103
|
+
/** The router alone: what a chooser offers before any list was ever read, so it reads "Enso Auto" and not an id. */
|
|
104
|
+
const ROUTER = parseModels([{ id: ENSO, name: 'Enso Auto', family: 'enso', class: 'ours' }]);
|
|
109
105
|
/** The last list this browser read, or none. */
|
|
110
106
|
function last() {
|
|
111
107
|
try {
|
|
@@ -172,25 +168,23 @@ export function useCatalog(t) {
|
|
|
172
168
|
note: '',
|
|
173
169
|
};
|
|
174
170
|
}
|
|
175
|
-
/** Whether `model` is one this plan may send: on Free,
|
|
176
|
-
export function grants(free, model
|
|
177
|
-
|
|
178
|
-
return true;
|
|
179
|
-
return catalog.find((m) => m.id === model)?.class === 'free';
|
|
171
|
+
/** Whether `model` is one this plan may send: on Free, Enso Auto alone (commerce's `allowedModels`). */
|
|
172
|
+
export function grants(free, model) {
|
|
173
|
+
return !free || model === ENSO;
|
|
180
174
|
}
|
|
181
175
|
/** The effort as the composer reads it: the one in force, its list, and the way to change it. */
|
|
182
176
|
export const pacing = (m) => ({ value: m.effort, set: m.pace, items: EFFORTS });
|
|
183
177
|
/**
|
|
184
178
|
* The model and effort for the plan `plan` names (`GET /v1/ai/limits` `plan`).
|
|
185
|
-
* On Free the
|
|
186
|
-
*
|
|
179
|
+
* On Free the model is Enso Auto, and a kept pick of any other is set aside
|
|
180
|
+
* rather than sent — it comes back once the plan grants it.
|
|
187
181
|
*/
|
|
188
182
|
export function useMind(t, plan) {
|
|
189
183
|
const [choice, change] = useChoice();
|
|
190
184
|
const { models, list, loading, error, note } = useCatalog(t);
|
|
191
185
|
const free = isFree(plan);
|
|
192
186
|
const [picked, pick] = usePick(choice.model, (id) => change({ model: id }), list);
|
|
193
|
-
const model =
|
|
187
|
+
const model = grants(free, picked) ? picked : ENSO;
|
|
194
188
|
return {
|
|
195
189
|
model,
|
|
196
190
|
effort: choice.effort,
|
|
@@ -200,7 +194,7 @@ export function useMind(t, plan) {
|
|
|
200
194
|
note,
|
|
201
195
|
free,
|
|
202
196
|
pick: (id) => {
|
|
203
|
-
if (grants(free, id
|
|
197
|
+
if (grants(free, id))
|
|
204
198
|
pick(id);
|
|
205
199
|
},
|
|
206
200
|
pace: (effort) => change({ effort }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/build",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.117",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"description": "Hanzo Build — say what you want, watch it built, deployed and running. The builder as a component, mounted by the Hanzo app at hanzo.ai.",
|