@hanzo/build 0.2.99 → 0.2.111

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.
@@ -1,6 +1,14 @@
1
1
  import { type Target } from './call.ts';
2
2
  export type Period = 'day' | 'week' | 'month';
3
3
  export declare const PERIODS: readonly Period[];
4
+ export type Mode = 'one-shot' | 'long-running';
5
+ export declare const MODES: readonly Mode[];
6
+ export type Trigger = 'webhook' | 'git' | 'channel' | 'watch';
7
+ export declare const TRIGGERS: readonly Trigger[];
8
+ export declare const SCHEDULES: readonly {
9
+ cron: string;
10
+ label: string;
11
+ }[];
4
12
  export interface Agent {
5
13
  id: string;
6
14
  name: string;
@@ -19,11 +27,12 @@ export interface Agent {
19
27
  /** Its picture: an https link or a data URL; '' draws its emoji or initial. */
20
28
  avatar: string;
21
29
  emoji: string;
22
- }
23
- export interface Preset {
24
- id: string;
25
- title: string;
26
- prompt: string;
30
+ /** How the agent runs: 'long-running' runs autonomously 24/7 on its schedule and triggers. */
31
+ executionMode?: Mode;
32
+ /** 5-field cron schedule for proactive execution (required when executionMode is 'long-running'). */
33
+ schedule?: string;
34
+ /** Event-driven triggers that wake the agent proactively. */
35
+ triggers?: Trigger[];
27
36
  }
28
37
  /** The fields a person edits. Money is in dollars here and micro-USD on the wire. */
29
38
  export interface Draft {
@@ -37,6 +46,9 @@ export interface Draft {
37
46
  period: Period;
38
47
  /** Sent on create only: an https link or a data URL. */
39
48
  avatar: string;
49
+ executionMode?: Mode;
50
+ schedule?: string;
51
+ triggers?: Trigger[];
40
52
  }
41
53
  /** An agent's name, as the handler takes it. */
42
54
  export declare const NAME: RegExp;
@@ -71,7 +83,7 @@ export declare function profile(t: Target, ref: string): Promise<{
71
83
  agent: Agent;
72
84
  runs: Run[];
73
85
  }>;
74
- /** An agent to start from: a default agent, a persona or a preset. */
86
+ /** An agent to start from: a default agent or a persona. */
75
87
  export interface Cast {
76
88
  /** The name it is made under. */
77
89
  name: string;
@@ -87,6 +99,12 @@ export interface Cast {
87
99
  /** Its face, an address of the host. */
88
100
  avatar?: string;
89
101
  tools?: string[];
102
+ /** How the preset runs when elected (e.g. 'long-running' for 24/7 autonomous bots). */
103
+ executionMode?: Mode;
104
+ /** Default 5-field cron schedule for proactive execution. */
105
+ schedule?: string;
106
+ /** Default event-driven triggers. */
107
+ triggers?: Trigger[];
90
108
  }
91
109
  /** What an agent made from a template may spend until its owner says otherwise, in dollars: each month, and one run. */
92
110
  export declare const CAST_CAP = "10";
@@ -107,7 +125,7 @@ export declare const link: (at: string | undefined, base: string) => string;
107
125
  * free (read now, so it is never one that exists), with its instructions read
108
126
  * and its face linked. The template is not touched.
109
127
  */
110
- export declare function use(t: Target, c: Cast, base: string): Promise<Agent>;
128
+ export declare function use(t: Target, c: Cast, base: string, overrides?: Partial<Pick<Draft, 'executionMode' | 'schedule' | 'triggers' | 'model' | 'tools' | 'cap' | 'task' | 'period'>>): Promise<Agent>;
111
129
  /** Anyone as a template: their name, who they are, and writing of theirs to take the voice from. */
112
130
  export declare function person(name: string, about: string, writing: string, avatar?: string): Cast;
113
131
  export declare function create(t: Target, d: Draft): Promise<Agent>;
@@ -115,7 +133,3 @@ export declare function create(t: Target, d: Draft): Promise<Agent>;
115
133
  export declare function changes(was: Agent, d: Draft): Record<string, unknown>;
116
134
  export declare function update(t: Target, was: Agent, d: Draft): Promise<Agent>;
117
135
  export declare function remove(t: Target, ref: string): Promise<void>;
118
- /** The presets that make a working agent. */
119
- export declare function presets(t: Target): Promise<Preset[]>;
120
- /** A preset as a template. */
121
- export declare function fromPreset(p: Preset): Cast;
package/lib/api/agents.js CHANGED
@@ -1,25 +1,32 @@
1
1
  /**
2
2
  * Agents: the org's own — a model, instructions, the tools it may call, a
3
- * budget and a face — and the templates one is made from.
3
+ * budget and a face — and how one is made from a template.
4
4
  *
5
5
  * GET /v1/agent {agents: [agent]}, without instructions
6
6
  * POST /v1/agent create → 201 agent
7
7
  * GET /v1/agent/{ref} one, with its instructions
8
8
  * PATCH /v1/agent/{ref} the fields sent change, the rest stay → agent
9
9
  * DELETE /v1/agent/{ref} removes it and every run recorded against it → 204
10
- * GET /v1/agent/chat/presets {presets: [{id, title, systemPrompt, serverExecuted}]}
11
10
  *
12
11
  * A ref is the agent's id or its name. A budget is required: the most it may
13
12
  * spend in a period and in one run, in micro-USD, and the period — day, week or
14
13
  * month. Tools are names from the tool plane; none grants none, and `*` is
15
14
  * whatever the fleet's MCP server serves when it runs. An omitted model is the
16
- * deployment's default. A preset whose tool calls run on the platform
17
- * (`serverExecuted`) makes a working agent; the others hand their calls back to
18
- * the client that asked, so they are not offered here.
15
+ * deployment's default.
19
16
  */
20
17
  import { phrase } from '@hanzo/i18n';
21
18
  import { call, seg } from './call.js';
22
19
  export const PERIODS = ['day', 'week', 'month'];
20
+ export const MODES = ['one-shot', 'long-running'];
21
+ export const TRIGGERS = ['webhook', 'git', 'channel', 'watch'];
22
+ export const SCHEDULES = [
23
+ { cron: '*/5 * * * *', label: phrase('Every 5 min') },
24
+ { cron: '*/15 * * * *', label: phrase('Every 15 min') },
25
+ { cron: '0 * * * *', label: phrase('Hourly') },
26
+ { cron: '0 9 * * *', label: phrase('Daily 9am') },
27
+ { cron: '0 9 * * 1-5', label: phrase('Weekdays 9am') },
28
+ { cron: '0 9 * * 1', label: phrase('Weekly Mon 9am') },
29
+ ];
23
30
  /** An agent's name, as the handler takes it. */
24
31
  export const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
25
32
  /** The most instructions the handler keeps. */
@@ -35,6 +42,9 @@ export const dollars = (m) => (m ? String(m / 1_000_000) : '');
35
42
  export function agent(raw) {
36
43
  const o = obj(raw);
37
44
  const period = str(o.period);
45
+ const mode = str(o.executionMode || o.execution_mode);
46
+ const schedule = str(o.schedule);
47
+ const triggers = rows(o.triggers).map(str).filter((x) => TRIGGERS.includes(x));
38
48
  return {
39
49
  id: str(o.id),
40
50
  name: str(o.name),
@@ -50,6 +60,9 @@ export function agent(raw) {
50
60
  period: PERIODS.includes(period) ? period : '',
51
61
  avatar: str(o.avatar),
52
62
  emoji: str(o.emoji),
63
+ ...(MODES.includes(mode) ? { executionMode: mode } : {}),
64
+ ...(schedule ? { schedule } : {}),
65
+ ...(triggers.length ? { triggers } : {}),
53
66
  };
54
67
  }
55
68
  /** A draft of an agent as it stands, to edit. */
@@ -64,6 +77,9 @@ export function draft(a) {
64
77
  task: dollars(a.task),
65
78
  period: a.period || 'month',
66
79
  avatar: a.avatar,
80
+ ...(a.executionMode ? { executionMode: a.executionMode } : {}),
81
+ ...(a.schedule ? { schedule: a.schedule } : {}),
82
+ ...(a.triggers?.length ? { triggers: a.triggers } : {}),
67
83
  };
68
84
  }
69
85
  export const EMPTY = { name: '', description: '', model: '', instructions: '', tools: [], cap: '', task: '', period: 'month', avatar: '' };
@@ -80,6 +96,8 @@ export function refuse(d) {
80
96
  return phrase('A name is letters, digits, . _ or -, starting with a letter or digit');
81
97
  if (new TextEncoder().encode(d.instructions).length > MAX)
82
98
  return phrase('Instructions are at most 32 KB');
99
+ if (d.executionMode === 'long-running' && !d.schedule?.trim())
100
+ return phrase('A 24/7 autonomous agent requires a schedule (5-field cron)');
83
101
  const cap = micros(d.cap);
84
102
  const task = micros(d.task);
85
103
  if (!(cap > 0))
@@ -142,9 +160,26 @@ export const link = (at, base) => {
142
160
  * free (read now, so it is never one that exists), with its instructions read
143
161
  * and its face linked. The template is not touched.
144
162
  */
145
- export async function use(t, c, base) {
163
+ export async function use(t, c, base, overrides) {
146
164
  const [have, instructions] = await Promise.all([agents(t), c.read ? c.read() : c.instructions]);
147
- return create(t, { ...EMPTY, name: free(handle(c.name), have), description: c.description, model: c.model, instructions, tools: c.tools ?? [], cap: CAST_CAP, task: CAST_TASK, avatar: link(c.avatar, base) });
165
+ const executionMode = overrides?.executionMode ?? c.executionMode;
166
+ const schedule = overrides?.schedule ?? c.schedule;
167
+ const triggers = overrides?.triggers ?? c.triggers;
168
+ return create(t, {
169
+ ...EMPTY,
170
+ name: free(handle(c.name), have),
171
+ description: c.description,
172
+ model: overrides?.model ?? c.model,
173
+ instructions,
174
+ tools: overrides?.tools ?? c.tools ?? [],
175
+ cap: overrides?.cap ?? CAST_CAP,
176
+ task: overrides?.task ?? CAST_TASK,
177
+ period: overrides?.period ?? 'month',
178
+ avatar: link(c.avatar, base),
179
+ ...(executionMode ? { executionMode } : {}),
180
+ ...(schedule ? { schedule } : {}),
181
+ ...(triggers?.length ? { triggers } : {}),
182
+ });
148
183
  }
149
184
  /** Anyone as a template: their name, who they are, and writing of theirs to take the voice from. */
150
185
  export function person(name, about, writing, avatar = '') {
@@ -169,6 +204,12 @@ export async function create(t, d) {
169
204
  body.model = d.model;
170
205
  if (d.avatar)
171
206
  body.avatar = d.avatar;
207
+ if (d.executionMode)
208
+ body.executionMode = d.executionMode;
209
+ if (d.schedule?.trim())
210
+ body.schedule = d.schedule.trim();
211
+ if (d.triggers?.length)
212
+ body.triggers = d.triggers;
172
213
  return agent(await call(t, 'POST', '/v1/agent', body));
173
214
  }
174
215
  /** The fields that differ from `was`, and nothing else: an omitted field keeps its value. */
@@ -188,6 +229,12 @@ export function changes(was, d) {
188
229
  out.max_task_micro_usd = micros(d.task);
189
230
  if (d.period !== was.period)
190
231
  out.period = d.period;
232
+ if ((d.executionMode ?? '') !== (was.executionMode ?? '') && d.executionMode)
233
+ out.executionMode = d.executionMode;
234
+ if ((d.schedule ?? '').trim() !== (was.schedule ?? ''))
235
+ out.schedule = (d.schedule ?? '').trim();
236
+ if ((d.triggers ?? []).join('\n') !== (was.triggers ?? []).join('\n'))
237
+ out.triggers = d.triggers ?? [];
191
238
  return out;
192
239
  }
193
240
  export async function update(t, was, d) {
@@ -202,15 +249,3 @@ export async function update(t, was, d) {
202
249
  export async function remove(t, ref) {
203
250
  await call(t, 'DELETE', `/v1/agent/${seg(ref)}`);
204
251
  }
205
- /** The presets that make a working agent. */
206
- export async function presets(t) {
207
- return rows(obj(await call(t, 'GET', '/v1/agent/chat/presets')).presets)
208
- .map(obj)
209
- .filter((p) => p.serverExecuted === true)
210
- .map((p) => ({ id: str(p.id), title: str(p.title), prompt: str(p.systemPrompt) }))
211
- .filter((p) => p.id);
212
- }
213
- /** A preset as a template. */
214
- export function fromPreset(p) {
215
- return { name: p.id, title: p.title || p.id, description: p.title, category: phrase('Preset'), model: '', instructions: p.prompt };
216
- }
@@ -41,6 +41,14 @@ export interface Run {
41
41
  */
42
42
  export declare function body(ask: Ask): Record<string, string | number | boolean>;
43
43
  export declare function start(t: Target, ask: Ask): Promise<Run>;
44
+ /**
45
+ * New words for a sandbox run that is working. The run takes its task on its
46
+ * command line and reads nothing after (apps/coding steer.go), so the platform
47
+ * stops it with its work kept on its branch and starts a follow-up from there
48
+ * with the words; the follow-up's session arrives on this run's own stream as
49
+ * its `followed` status (turn.ts `followed`).
50
+ */
51
+ export declare function steer(t: Target, session: string, text: string): Promise<void>;
44
52
  /** A run a follow-up continues, as its record states it. */
45
53
  export interface Earlier {
46
54
  id: string;
package/lib/api/coding.js CHANGED
@@ -2,6 +2,7 @@
2
2
  * Starting a coding run, and what it left.
3
3
  *
4
4
  * POST /v1/agent/coding → 202 {sessionId, repo, branch, routed, targetId}
5
+ * POST /v1/agent/coding/{session}/steer {text} 202 {ok}
5
6
  * GET /v1/agent/coding/{session}/artifacts {session, saved, artifacts}
6
7
  * GET /v1/agent/coding/{session}/artifacts/{name} one stored artifact's bytes
7
8
  *
@@ -75,6 +76,19 @@ export async function start(t, ask) {
75
76
  target: s('targetId'),
76
77
  };
77
78
  }
79
+ /**
80
+ * New words for a sandbox run that is working. The run takes its task on its
81
+ * command line and reads nothing after (apps/coding steer.go), so the platform
82
+ * stops it with its work kept on its branch and starts a follow-up from there
83
+ * with the words; the follow-up's session arrives on this run's own stream as
84
+ * its `followed` status (turn.ts `followed`).
85
+ */
86
+ export async function steer(t, session, text) {
87
+ const words = text.trim();
88
+ if (!words)
89
+ throw new Refusal(400, phrase('Say something to the run'));
90
+ await call(t, 'POST', `/v1/agent/coding/${seg(session)}/steer`, { text: words });
91
+ }
78
92
  /**
79
93
  * The earlier run's ask, without the codebase its title leads with (`universe:
80
94
  * add the widget`), or the `new project:` the platform titles a run that made its
@@ -83,7 +97,7 @@ export async function start(t, ask) {
83
97
  export function headline(title, repo) {
84
98
  const name = repo.split('/').filter(Boolean).pop() ?? '';
85
99
  const t = title.trim();
86
- for (const lead of [name, 'new project'])
100
+ for (const lead of [name, 'new project', 'workspace'])
87
101
  if (lead && t.startsWith(`${lead}: `))
88
102
  return t.slice(lead.length + 2).trim();
89
103
  return t;
@@ -97,11 +111,12 @@ export function headline(title, repo) {
97
111
  */
98
112
  function from(e) {
99
113
  const place = e.environment && e.environment !== 'sandbox' ? e.environment : undefined;
114
+ const base = e.base && !e.base.startsWith('agent/') ? e.base : undefined;
100
115
  return {
101
116
  repo: e.repo || undefined,
102
117
  project: e.project || undefined,
103
118
  targetId: place,
104
- ...(!place || e.pushed ? { after: e.id } : { base: e.base || undefined }),
119
+ ...(!place || e.pushed ? { after: e.id } : { base }),
105
120
  };
106
121
  }
107
122
  const modeOf = (m) => (m === 'plan' || m === 'setup' ? m : 'build');
@@ -137,7 +152,16 @@ export function approve(e, plan) {
137
152
  * with none recorded, its title's.
138
153
  */
139
154
  export function retry(e, ask) {
140
- return { ...from(e), prompt: ask.trim() || headline(e.title, e.repo), mode: modeOf(e.mode) };
155
+ const place = e.environment && e.environment !== 'sandbox' ? e.environment : undefined;
156
+ const base = e.base && !e.base.startsWith('agent/') ? e.base : undefined;
157
+ return {
158
+ repo: e.repo || undefined,
159
+ project: e.project || undefined,
160
+ targetId: place,
161
+ ...(e.pushed ? { after: e.id } : { base }),
162
+ prompt: ask.trim() || headline(e.title, e.repo),
163
+ mode: modeOf(e.mode),
164
+ };
141
165
  }
142
166
  const KINDS = ['file', 'patch', 'preview', 'pull', 'deploy'];
143
167
  /** What a run left, kept after its sandbox is gone. */
@@ -84,20 +84,24 @@ export interface Made {
84
84
  seconds?: number;
85
85
  pages?: number;
86
86
  }
87
- /** The largest thing one upload carries. */
87
+ /** The largest thing an inline upload carries; larger files up to `MAX` reserve a signed PUT. */
88
88
  export declare const INLINE: number;
89
+ /** The largest thing one upload carries (2 GiB). */
90
+ export declare const MAX: number;
89
91
  /** Bytes as base64, in chunks a call stack holds. */
90
92
  export declare function base64(bytes: Uint8Array): string;
91
93
  /** Keep a file in the Library. */
92
94
  export declare function upload(t: Target, file: {
93
95
  name: string;
94
96
  type: string;
95
- bytes: Uint8Array;
97
+ bytes?: Uint8Array;
98
+ blob?: Blob;
96
99
  }, made: Made): Promise<Item>;
97
100
  export interface Change {
98
101
  name?: string;
99
102
  shared?: boolean;
100
103
  project?: string;
104
+ commit?: boolean;
101
105
  }
102
106
  export declare function change(t: Target, id: string, c: Change): Promise<Item>;
103
107
  export declare function remove(t: Target, id: string): Promise<void>;
@@ -95,8 +95,10 @@ export async function get(t, id) {
95
95
  throw new Error(phrase('The item came back without an id'));
96
96
  return x;
97
97
  }
98
- /** The largest thing one upload carries. */
98
+ /** The largest thing an inline upload carries; larger files up to `MAX` reserve a signed PUT. */
99
99
  export const INLINE = 10 << 20;
100
+ /** The largest thing one upload carries (2 GiB). */
101
+ export const MAX = 2 * 1024 * 1024 * 1024;
100
102
  /** Bytes as base64, in chunks a call stack holds. */
101
103
  export function base64(bytes) {
102
104
  let s = '';
@@ -106,14 +108,56 @@ export function base64(bytes) {
106
108
  }
107
109
  /** Keep a file in the Library. */
108
110
  export async function upload(t, file, made) {
109
- if (!file.bytes.length)
111
+ const len = file.blob ? file.blob.size : (file.bytes?.length ?? 0);
112
+ if (!len)
110
113
  throw new Sentence(phrase('{name} is empty'), { name: file.name });
111
- if (file.bytes.length > INLINE)
112
- throw new Sentence(phrase('{name} is larger than 10 MB'), { name: file.name });
114
+ if (len > MAX)
115
+ throw new Sentence(phrase('{name} is larger than 2 GB'), { name: file.name });
116
+ const mime = file.type || 'application/octet-stream';
117
+ if (len > INLINE) {
118
+ const reserved = obj(await call(t, 'POST', '/v1/library', {
119
+ name: file.name,
120
+ mime,
121
+ bytes: len,
122
+ ...made,
123
+ }));
124
+ const id = str(reserved.id);
125
+ const up = obj(reserved.upload);
126
+ const putUrl = signed(up.url);
127
+ if (!id)
128
+ throw new Error(phrase('The item was kept and came back without an id'));
129
+ if (!putUrl) {
130
+ const x = item(reserved);
131
+ if (!x)
132
+ throw new Error(phrase('The item was kept and came back without an id'));
133
+ return x;
134
+ }
135
+ const headers = {};
136
+ if (Array.isArray(up.headers)) {
137
+ for (const h of up.headers) {
138
+ const ho = obj(h);
139
+ const hn = str(ho.name);
140
+ if (hn)
141
+ headers[hn] = str(ho.value);
142
+ }
143
+ }
144
+ const res = await fetch(putUrl, {
145
+ method: 'PUT',
146
+ headers,
147
+ body: (file.blob ?? file.bytes),
148
+ });
149
+ if (!res.ok)
150
+ throw new Sentence(phrase('{name} was not kept'), { name: file.name });
151
+ const done = item(await call(t, 'PATCH', `/v1/library/${seg(id)}`, { commit: true }));
152
+ if (!done)
153
+ throw new Error(phrase('The item was kept and came back without an id'));
154
+ return done;
155
+ }
156
+ const bytes = file.bytes ?? new Uint8Array(await file.blob.arrayBuffer());
113
157
  const x = item(await call(t, 'POST', '/v1/library', {
114
158
  name: file.name,
115
- mime: file.type || 'application/octet-stream',
116
- data: base64(file.bytes),
159
+ mime,
160
+ data: base64(bytes),
117
161
  ...made,
118
162
  }));
119
163
  if (!x)
@@ -86,9 +86,24 @@ export async function list(t, q = {}) {
86
86
  }
87
87
  export async function get(t, id) {
88
88
  const raw = obj(await call(t, 'GET', `/v1/agent/sessions/${seg(id)}`));
89
+ let recent = (Array.isArray(raw.recentEvents) ? raw.recentEvents : []).map(event);
90
+ // The detail carries the 50 most recent events; when a long run has scrolled
91
+ // past seq 1, read the opening turns so the person's full multi-line ask stays
92
+ // at the head of the transcript and in Try again.
93
+ if (recent.length > 0 && recent[0].seq > 1) {
94
+ try {
95
+ const head = obj(await call(t, 'GET', `/v1/agent/sessions/${seg(id)}/events?limit=2`));
96
+ const first = (Array.isArray(head.events) ? head.events : []).map(event);
97
+ const have = new Set(recent.map((e) => e.seq));
98
+ recent = [...first.filter((e) => e.seq > 0 && !have.has(e.seq)), ...recent].sort((a, b) => a.seq - b.seq);
99
+ }
100
+ catch {
101
+ /* keep the tail */
102
+ }
103
+ }
89
104
  return {
90
105
  ...session(raw),
91
- recent: (Array.isArray(raw.recentEvents) ? raw.recentEvents : []).map(event),
106
+ recent,
92
107
  };
93
108
  }
94
109
  export async function message(t, id, text) {
package/lib/api/turn.d.ts CHANGED
@@ -170,3 +170,5 @@ export interface Settled {
170
170
  * would clone a branch the push has not reached.
171
171
  */
172
172
  export declare function settled(events: Pick<Event, 'kind' | 'payload' | 'seq'>[]): Settled;
173
+ /** The session of the run that carried this one on (its `followed` status), or ''. */
174
+ export declare function followed(events: Pick<Event, 'kind' | 'payload' | 'seq'>[]): string;
package/lib/api/turn.js CHANGED
@@ -559,3 +559,15 @@ export function settled(events) {
559
559
  }
560
560
  return out;
561
561
  }
562
+ /** The session of the run that carried this one on (its `followed` status), or ''. */
563
+ export function followed(events) {
564
+ let next = '';
565
+ for (const e of [...events].sort((a, b) => a.seq - b.seq)) {
566
+ if (e.kind !== 'status')
567
+ continue;
568
+ const b = decode(e.payload);
569
+ if (b && typeof b !== 'string' && str(b.status) === 'followed')
570
+ next = str(b.next);
571
+ }
572
+ return next;
573
+ }
package/lib/carry.js CHANGED
@@ -22,7 +22,7 @@ import { BookOpen, ListChecks, Palette, ScrollText } from '@hanzogui/lucide-icon
22
22
  import { Button, Dialog, DialogContent, DialogDescription, DialogTitle } from '@hanzo/ui';
23
23
  import { useEffect, useMemo, useRef, useState } from 'react';
24
24
  import { call, query, unwrap } from './api/call.js';
25
- import { active, authored, document, nameOf as skillOf } from './api/skills.js';
25
+ import { active, authored, brand as brandSkills, document, nameOf as skillOf } from './api/skills.js';
26
26
  import { brand, brands } from './api/studio.js';
27
27
  import { useRead } from './data.js';
28
28
  import { said as designSaid } from './design.js';
@@ -48,11 +48,13 @@ async function said(t, skills, memory, mode, design) {
48
48
  parts.push(designSaid(b));
49
49
  }
50
50
  if (skills.length) {
51
- const own = await authored(t).catch(() => []);
51
+ const own = t.token() ? await authored(t).catch(() => []) : [];
52
52
  for (const n of skills) {
53
53
  const body = own.find((s) => s.name === n)?.content || (await document(t, n).catch(() => ''));
54
54
  if (body)
55
55
  parts.push(`Use the skill "${n}" where it applies:\n\n${body.slice(0, SKILL_MAX)}`);
56
+ else
57
+ parts.push(`Use the "${n}" skill where it applies.`);
56
58
  }
57
59
  }
58
60
  if (memory) {
@@ -93,8 +95,76 @@ export function useCarry(t, key, customize, lent, modes = DEV_MODES) {
93
95
  }), [t]);
94
96
  const found = usePlugins(t);
95
97
  const signed = Boolean(t.token());
96
- const list = useRead(signed ? () => active(t) : null, [], [t, signed]);
97
- const names = useMemo(() => list.value.map((s) => skillOf(s.name)).filter(Boolean), [list.value]);
98
+ const list = useRead(async () => {
99
+ const [act, own, cat] = await Promise.all([
100
+ signed ? active(t).catch(() => []) : Promise.resolve([]),
101
+ signed ? authored(t).catch(() => []) : Promise.resolve([]),
102
+ brandSkills(t).catch(() => ({ skills: [], products: [] })),
103
+ ]);
104
+ const localSkills = [];
105
+ try {
106
+ const raw = typeof localStorage !== 'undefined' ? localStorage.getItem('hanzo_enterprise_settings_v1:plugins') : null;
107
+ if (raw) {
108
+ const parsed = JSON.parse(raw);
109
+ if (Array.isArray(parsed?.skillsAndPlugins)) {
110
+ for (const item of parsed.skillsAndPlugins) {
111
+ if (item?.status === 'enabled' && typeof item?.name === 'string') {
112
+ localSkills.push(item.name);
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ catch {
119
+ // ignore
120
+ }
121
+ const standard = [
122
+ 'code-review',
123
+ 'simplify',
124
+ 'security-review',
125
+ 'bug-finder',
126
+ 'test-writer',
127
+ 'refactor',
128
+ 'frontend-design',
129
+ 'api-design',
130
+ 'sql-optimizer',
131
+ 'ui-port',
132
+ 'app-port',
133
+ 'hanzo-cloud',
134
+ 'hanzo-base',
135
+ 'hanzo-code',
136
+ 'hanzo-dev',
137
+ 'hanzo-cli',
138
+ 'hanzo-commerce',
139
+ 'hanzo-bot',
140
+ 'hanzo-agent',
141
+ 'hanzo-security-review',
142
+ 'pdf-analysis',
143
+ 'xlsx-modeling',
144
+ 'pptx-deck-builder',
145
+ 'docx-redline',
146
+ 'scientific-research',
147
+ 'mcp-builder',
148
+ 'webapp-testing',
149
+ ];
150
+ const seen = new Set();
151
+ const out = [];
152
+ for (const n of [
153
+ ...act.map((s) => skillOf(s.name)),
154
+ ...own.map((s) => s.name),
155
+ ...localSkills,
156
+ ...standard,
157
+ ...(Array.isArray(cat?.skills) ? cat.skills.map((s) => s.name) : []),
158
+ ]) {
159
+ const clean = typeof n === 'string' ? n.trim() : '';
160
+ if (clean && !seen.has(clean)) {
161
+ seen.add(clean);
162
+ out.push(clean);
163
+ }
164
+ }
165
+ return out;
166
+ }, [], [t, signed]);
167
+ const names = list.value;
98
168
  const { skills, research, memory, design } = gear.gear;
99
169
  const mode = modes.includes(gear.gear.mode) ? gear.gear.mode : 'auto';
100
170
  const shelf = {
@@ -143,10 +213,12 @@ export function useCarry(t, key, customize, lent, modes = DEV_MODES) {
143
213
  const [text, setText] = useState('');
144
214
  const asked = skills.join('\n');
145
215
  useEffect(() => {
146
- if (!signedIn)
147
- return setText(mode === 'plan' ? 'Plan mode: lay out the plan and stop until the person says go.' : '');
216
+ if (!signedIn && !skills.length) {
217
+ setText(mode === 'plan' ? 'Plan mode: lay out the plan and stop until the person says go.' : '');
218
+ return;
219
+ }
148
220
  let live = true;
149
- void said(t, skills, memory, mode, design).then((x) => live && setText(x));
221
+ void said(t, skills, signedIn ? memory : false, mode, signedIn ? design : '').then((x) => live && setText(x));
150
222
  return () => {
151
223
  live = false;
152
224
  };
@@ -1,6 +1,6 @@
1
1
  import { type Cast } from '../api/agents.ts';
2
2
  import { type Pane } from './ui.tsx';
3
- /** Categories as Browse offers them: the default agents' and presets' first, as listed, then the rest by how many each holds. */
3
+ /** Categories as Browse offers them: the default agents' first, as listed, then the rest by how many each holds. */
4
4
  export declare function kinds(first: readonly Cast[], rest: readonly Cast[]): string[];
5
5
  export declare function Agents({ view, q, adding, onAdding, onView, onCount }: Pane): import("react").JSX.Element;
6
6
  /** One agent's page: who it is, what it runs on and reads, what it may call and spend, and what it has done. */