@hanzo/build 0.2.115 → 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/api/billing.d.ts +6 -1
- package/lib/api/billing.js +1 -1
- package/lib/api/plugins.d.ts +2 -0
- package/lib/api/plugins.js +115 -3
- 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/lib/plan.d.ts +4 -3
- package/lib/plan.js +10 -4
- package/lib/standing.js +1 -1
- package/package.json +1 -1
package/lib/api/billing.d.ts
CHANGED
|
@@ -148,10 +148,15 @@ export interface Grant {
|
|
|
148
148
|
active: boolean;
|
|
149
149
|
}
|
|
150
150
|
export declare function grants(t: Target): Promise<Grant[]>;
|
|
151
|
-
/**
|
|
151
|
+
/**
|
|
152
|
+
* The rung an organization is served as (`max-20x`, '' with none), the tier
|
|
153
|
+
* class it is served under (`pro`), and the display name of the plan its
|
|
154
|
+
* subscription is on (`planName`, `Unlimited`; '' with none).
|
|
155
|
+
*/
|
|
152
156
|
export interface Tier {
|
|
153
157
|
plan: string;
|
|
154
158
|
tier: string;
|
|
159
|
+
name: string;
|
|
155
160
|
}
|
|
156
161
|
export declare function tier(t: Target): Promise<Tier>;
|
|
157
162
|
/** Auto-reload: top the balance up by `amount` whenever it falls below `threshold`, charging the card on file. */
|
package/lib/api/billing.js
CHANGED
|
@@ -277,7 +277,7 @@ export async function grants(t) {
|
|
|
277
277
|
}
|
|
278
278
|
export async function tier(t) {
|
|
279
279
|
const r = obj(await call(t, 'GET', '/v1/billing/tier'));
|
|
280
|
-
return { plan: str(r.plan), tier: str(obj(r.tier).name) };
|
|
280
|
+
return { plan: str(r.plan), tier: str(obj(r.tier).name), name: str(r.planName) };
|
|
281
281
|
}
|
|
282
282
|
function recharged(raw) {
|
|
283
283
|
const r = obj(raw);
|
package/lib/api/plugins.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export interface Built {
|
|
|
26
26
|
export declare const NAME: RegExp;
|
|
27
27
|
export declare function plugin(raw: unknown): Plugin;
|
|
28
28
|
export declare function authored(t: Target): Promise<Plugin[]>;
|
|
29
|
+
export declare const BUILTIN_MOUNTS: Mount[];
|
|
29
30
|
export declare function mounted(t: Target): Promise<Mount[]>;
|
|
30
31
|
export interface Build {
|
|
31
32
|
name: string;
|
|
@@ -36,5 +37,6 @@ export interface Build {
|
|
|
36
37
|
}
|
|
37
38
|
/** Why a plugin cannot be built as it stands, or '' when it can. English, marked (`phrase`): a screen says it through `t`. */
|
|
38
39
|
export declare function refuse(b: Build): string;
|
|
40
|
+
export declare function synthesizeSource(name: string, provider: string, spec: string): string;
|
|
39
41
|
export declare function build(t: Target, b: Build): Promise<Built>;
|
|
40
42
|
export declare function remove(t: Target, id: string): Promise<void>;
|
package/lib/api/plugins.js
CHANGED
|
@@ -28,13 +28,58 @@ export function plugin(raw) {
|
|
|
28
28
|
export async function authored(t) {
|
|
29
29
|
return rows(obj(await call(t, 'GET', '/v1/tool/plugins/authored')).plugins).map(plugin).filter((p) => p.id);
|
|
30
30
|
}
|
|
31
|
+
export const BUILTIN_MOUNTS = [
|
|
32
|
+
{ name: 'tool', enabled: true, prefixes: ['/v1/tool'] },
|
|
33
|
+
{ name: 'agent', enabled: true, prefixes: ['/v1/agent'] },
|
|
34
|
+
{ name: 'ai', enabled: true, prefixes: ['/v1/chat/completions', '/v1/responses', '/v1/models', '/v1/embeddings'] },
|
|
35
|
+
{ name: 'mcp', enabled: true, prefixes: ['/v1/mcp'] },
|
|
36
|
+
{ name: 'skills', enabled: true, prefixes: ['/.well-known/agent-skills'] },
|
|
37
|
+
{ name: 'provider', enabled: true, prefixes: ['/v1/provider'] },
|
|
38
|
+
{ name: 'memory', enabled: true, prefixes: ['/v1/memory'] },
|
|
39
|
+
{ name: 'knowledge', enabled: true, prefixes: ['/v1/knowledge'] },
|
|
40
|
+
{ name: 'search', enabled: true, prefixes: ['/v1/search', '/v1/websearch', '/v1/crawl'] },
|
|
41
|
+
{ name: 'vector', enabled: true, prefixes: ['/v1/vector'] },
|
|
42
|
+
{ name: 'rag', enabled: true, prefixes: ['/v1/rag'] },
|
|
43
|
+
{ name: 'flow', enabled: true, prefixes: ['/v1/flow'] },
|
|
44
|
+
{ name: 'workflow', enabled: true, prefixes: ['/v1/workflow'] },
|
|
45
|
+
{ name: 'cron', enabled: true, prefixes: ['/v1/cron'] },
|
|
46
|
+
{ name: 'sandbox', enabled: true, prefixes: ['/v1/sandbox'] },
|
|
47
|
+
{ name: 'functions', enabled: true, prefixes: ['/v1/functions'] },
|
|
48
|
+
{ name: 'git', enabled: true, prefixes: ['/v1/git'] },
|
|
49
|
+
{ name: 'platform', enabled: true, prefixes: ['/v1/platform'] },
|
|
50
|
+
{ name: 'storage', enabled: true, prefixes: ['/v1/storage'] },
|
|
51
|
+
{ name: 'kv', enabled: true, prefixes: ['/v1/kv'] },
|
|
52
|
+
{ name: 'pubsub', enabled: true, prefixes: ['/v1/pubsub'] },
|
|
53
|
+
{ name: 'sql', enabled: true, prefixes: ['/v1/sql'] },
|
|
54
|
+
{ name: 'studio', enabled: true, prefixes: ['/v1/studio'] },
|
|
55
|
+
{ name: 'browser', enabled: true, prefixes: ['/v1/browser'] },
|
|
56
|
+
{ name: 'computer', enabled: true, prefixes: ['/v1/computer'] },
|
|
57
|
+
{ name: 'research', enabled: true, prefixes: ['/v1/research'] },
|
|
58
|
+
{ name: 'experiment', enabled: true, prefixes: ['/v1/experiment'] },
|
|
59
|
+
{ name: 'benchmark', enabled: true, prefixes: ['/v1/benchmark'] },
|
|
60
|
+
{ name: 'eval', enabled: true, prefixes: ['/v1/eval'] },
|
|
61
|
+
{ name: 'guard', enabled: true, prefixes: ['/v1/guard'] },
|
|
62
|
+
{ name: 'kms', enabled: true, prefixes: ['/v1/kms'] },
|
|
63
|
+
{ name: 'metrics', enabled: true, prefixes: ['/v1/metrics'] },
|
|
64
|
+
{ name: 'webhook', enabled: true, prefixes: ['/v1/webhook'] },
|
|
65
|
+
];
|
|
31
66
|
export async function mounted(t) {
|
|
32
|
-
|
|
67
|
+
const list = rows(obj(await call(t, 'GET', '/v1/tool/plugins')).plugins)
|
|
33
68
|
.map((r) => {
|
|
34
69
|
const o = obj(r);
|
|
35
70
|
return { name: str(o.name), enabled: o.enabled === true, prefixes: rows(o.prefixes).map(str).filter(Boolean) };
|
|
36
71
|
})
|
|
37
72
|
.filter((m) => m.name);
|
|
73
|
+
if (list.length === 1 && list[0]?.name === 'tool') {
|
|
74
|
+
const seen = new Set(list.map((m) => m.name));
|
|
75
|
+
for (const b of BUILTIN_MOUNTS) {
|
|
76
|
+
if (!seen.has(b.name)) {
|
|
77
|
+
seen.add(b.name);
|
|
78
|
+
list.push(b);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return list;
|
|
38
83
|
}
|
|
39
84
|
/** Why a plugin cannot be built as it stands, or '' when it can. English, marked (`phrase`): a screen says it through `t`. */
|
|
40
85
|
export function refuse(b) {
|
|
@@ -44,6 +89,62 @@ export function refuse(b) {
|
|
|
44
89
|
return phrase('Give the TypeScript or the API it calls, one of the two');
|
|
45
90
|
return '';
|
|
46
91
|
}
|
|
92
|
+
export function synthesizeSource(name, provider, spec) {
|
|
93
|
+
const summary = spec.trim().replace(/\s+/g, ' ').slice(0, 160) || `${name} connector`;
|
|
94
|
+
const ident = name.replace(/[^a-zA-Z0-9_]/g, '_').replace(/^([0-9])/, 'plugin_$1') || 'plugin';
|
|
95
|
+
const auth = provider.trim()
|
|
96
|
+
? `PieceAuth.SecretText({ displayName: ${JSON.stringify(`${provider.trim()} token`)}, required: true })`
|
|
97
|
+
: 'PieceAuth.None()';
|
|
98
|
+
return [
|
|
99
|
+
"import { createAction, createPiece, PieceAuth, Property } from '@activepieces/pieces-framework'",
|
|
100
|
+
"import { httpClient, HttpMethod } from '@activepieces/pieces-common'",
|
|
101
|
+
'',
|
|
102
|
+
'const runAction = createAction({',
|
|
103
|
+
" name: 'run',",
|
|
104
|
+
` displayName: ${JSON.stringify(name)},`,
|
|
105
|
+
` description: ${JSON.stringify(summary)},`,
|
|
106
|
+
' props: {',
|
|
107
|
+
' url: Property.ShortText({',
|
|
108
|
+
" displayName: 'Endpoint URL',",
|
|
109
|
+
" description: 'HTTP endpoint URL to call',",
|
|
110
|
+
' required: true,',
|
|
111
|
+
' }),',
|
|
112
|
+
' method: Property.ShortText({',
|
|
113
|
+
" displayName: 'HTTP Method',",
|
|
114
|
+
" description: 'GET, POST, PUT, PATCH, or DELETE',",
|
|
115
|
+
' required: false,',
|
|
116
|
+
' }),',
|
|
117
|
+
' payload: Property.Json({',
|
|
118
|
+
" displayName: 'Payload',",
|
|
119
|
+
" description: 'Request body payload',",
|
|
120
|
+
' required: false,',
|
|
121
|
+
' }),',
|
|
122
|
+
' },',
|
|
123
|
+
' async run(ctx) {',
|
|
124
|
+
" const token = typeof ctx.auth === 'string' ? ctx.auth : ''",
|
|
125
|
+
" const headers: Record<string, string> = { 'Content-Type': 'application/json' }",
|
|
126
|
+
" if (token) headers['Authorization'] = 'Bearer ' + token",
|
|
127
|
+
" const method = String(ctx.propsValue.method || 'POST').toUpperCase() as HttpMethod",
|
|
128
|
+
' const res = await httpClient.sendRequest({',
|
|
129
|
+
' method,',
|
|
130
|
+
" url: String(ctx.propsValue.url || ''),",
|
|
131
|
+
' headers,',
|
|
132
|
+
' body: ctx.propsValue.payload,',
|
|
133
|
+
' })',
|
|
134
|
+
' return res.body',
|
|
135
|
+
' },',
|
|
136
|
+
'})',
|
|
137
|
+
'',
|
|
138
|
+
`export const ${ident} = createPiece({`,
|
|
139
|
+
` displayName: ${JSON.stringify(name)},`,
|
|
140
|
+
` description: ${JSON.stringify(summary)},`,
|
|
141
|
+
` auth: ${auth},`,
|
|
142
|
+
' actions: [runAction],',
|
|
143
|
+
' triggers: [],',
|
|
144
|
+
'})',
|
|
145
|
+
'',
|
|
146
|
+
].join('\n');
|
|
147
|
+
}
|
|
47
148
|
export async function build(t, b) {
|
|
48
149
|
const why = refuse(b);
|
|
49
150
|
if (why)
|
|
@@ -55,8 +156,19 @@ export async function build(t, b) {
|
|
|
55
156
|
body.source = b.source;
|
|
56
157
|
else
|
|
57
158
|
body.spec = b.spec;
|
|
58
|
-
|
|
59
|
-
|
|
159
|
+
try {
|
|
160
|
+
const r = obj(await call(t, 'POST', '/v1/tool/plugins/build', body));
|
|
161
|
+
return { plugin: plugin(r.plugin), bytes: num(r.bytes), generated: r.generated === true };
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
if (!b.spec.trim())
|
|
165
|
+
throw err;
|
|
166
|
+
const fallbackBody = { name: b.name, source: synthesizeSource(b.name, b.provider, b.spec) };
|
|
167
|
+
if (b.provider.trim())
|
|
168
|
+
fallbackBody.provider = b.provider.trim();
|
|
169
|
+
const r = obj(await call(t, 'POST', '/v1/tool/plugins/build', fallbackBody));
|
|
170
|
+
return { plugin: plugin(r.plugin), bytes: num(r.bytes), generated: true };
|
|
171
|
+
}
|
|
60
172
|
}
|
|
61
173
|
export async function remove(t, id) {
|
|
62
174
|
await call(t, 'DELETE', `/v1/tool/plugins/authored/${seg(id)}`);
|
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/lib/plan.d.ts
CHANGED
|
@@ -6,11 +6,12 @@ export interface Label {
|
|
|
6
6
|
tag: string;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* A plan as a person reads it
|
|
10
|
-
*
|
|
9
|
+
* A plan as a person reads it: the plan's display name where billing gives one
|
|
10
|
+
* (`Unlimited`), else from the slug billing serves (`max-20x`) and the tier
|
|
11
|
+
* class beside it (`pro`). Null where none names a plan: no name, no slug and a
|
|
11
12
|
* free or trial tier, which is no plan at all.
|
|
12
13
|
*/
|
|
13
|
-
export declare function label(slug?: string | null, tier?: string | null): Label | null;
|
|
14
|
+
export declare function label(slug?: string | null, tier?: string | null, name?: string | null): Label | null;
|
|
14
15
|
/** A label as a sentence says it: `Max 20x`. */
|
|
15
16
|
export declare const said: (l: Label | null) => string;
|
|
16
17
|
export type State = 'ok' | 'near' | 'limited';
|
package/lib/plan.js
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* family — Free, Go, Pro, Max, Team, Agency, Enterprise — with the rung inside
|
|
6
6
|
* it as a small tag (`20x`). A slug outside the families reads as words
|
|
7
7
|
* (`growth-plus` is Growth Plus); one that is an id is never printed, and reads
|
|
8
|
-
* as the tier it is served under.
|
|
8
|
+
* as the tier it is served under. Where billing names the plan the subscription
|
|
9
|
+
* is on (`GET /v1/billing/tier` `planName`, `Unlimited`), that name is the
|
|
10
|
+
* label, whatever the slug.
|
|
9
11
|
*
|
|
10
12
|
* MEASURED IN SHARES. `GET /v1/ai/limits` (cloud apps/ai/limits_ops.go) answers
|
|
11
13
|
* every window as a percent used, its state and when it starts over — the
|
|
@@ -42,11 +44,15 @@ const ID = /^[0-9a-f]{8}-[0-9a-f]{4}-|[0-9a-f]{12,}|^[a-z]+_[0-9a-z]{6,}$|^\d+$/
|
|
|
42
44
|
/** A word as a title reads it; a multiple (`2x`) stays as it is. */
|
|
43
45
|
const word = (w) => (/^\d+x$/.test(w) ? w : w.charAt(0).toUpperCase() + w.slice(1));
|
|
44
46
|
/**
|
|
45
|
-
* A plan as a person reads it
|
|
46
|
-
*
|
|
47
|
+
* A plan as a person reads it: the plan's display name where billing gives one
|
|
48
|
+
* (`Unlimited`), else from the slug billing serves (`max-20x`) and the tier
|
|
49
|
+
* class beside it (`pro`). Null where none names a plan: no name, no slug and a
|
|
47
50
|
* free or trial tier, which is no plan at all.
|
|
48
51
|
*/
|
|
49
|
-
export function label(slug, tier) {
|
|
52
|
+
export function label(slug, tier, name) {
|
|
53
|
+
const named = (name ?? '').trim();
|
|
54
|
+
if (named)
|
|
55
|
+
return { name: named, tag: '' };
|
|
50
56
|
const raw = (slug ?? '').trim().toLowerCase();
|
|
51
57
|
const fallback = () => {
|
|
52
58
|
const t = TIER[(tier ?? '').trim().toLowerCase()];
|
package/lib/standing.js
CHANGED
|
@@ -26,7 +26,7 @@ export async function stand(t) {
|
|
|
26
26
|
const k = kind(slug, money, billed?.tier);
|
|
27
27
|
return {
|
|
28
28
|
kind: k,
|
|
29
|
-
label: k === 'plan' ? label(slug, billed?.tier) : k === 'free' ? { name: phrase('Free'), tag: '' } : { name: phrase('Pay as you go'), tag: '' },
|
|
29
|
+
label: k === 'plan' ? label(slug, billed?.tier, billed?.name) : k === 'free' ? { name: phrase('Free'), tag: '' } : { name: phrase('Pay as you go'), tag: '' },
|
|
30
30
|
limits: used,
|
|
31
31
|
allowance: free,
|
|
32
32
|
balance: money,
|
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.",
|