@hanzo/build 0.2.130 → 0.2.132

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/README.md CHANGED
@@ -287,6 +287,14 @@ light round chips as tall as the composer's controls, on one centreline a gap ap
287
287
  (the composer stands every `ChipSelect` in its pills so, on a phone and a laptop alike),
288
288
  and Repos, Branches, Issues and Templates under it, each a press to its list. A codebase can be added to a project. Opening a codebase or an
289
289
  issue from its own screen lands here with that choice already made.
290
+ A repository is optional everywhere: with none, a run works in a new folder (in
291
+ the sandbox, or on a machine), and GitHub can be connected later. On a host that
292
+ has the computer (Hanzo Desktop hands `local`, local.ts), This computer comes
293
+ first: the run works in a folder there and needs no repository, the Folder pill
294
+ reads Auto (the folder used most recently) until another is chosen, Choose
295
+ folder… opens the computer's own dialog, and a computer that opened no folder
296
+ asks for one on the first send. The agent reads, edits and runs in that folder
297
+ only, and what it printed shows under the composer when it ends.
290
298
 
291
299
  **A run.** The transcript as it streams, drawn by what each part is: what the
292
300
  agent says as markdown, each command it runs as a card that opens onto its
@@ -56,3 +56,25 @@ export declare function remove(t: Target, id: string): Promise<void>;
56
56
  export declare function brand(t: Target): Promise<Catalogue>;
57
57
  /** One catalogue skill's SKILL.md. */
58
58
  export declare function document(t: Target, name: string): Promise<string>;
59
+ /** One thing Kai picked for a message: a skill (`skill_<name>`) or a tool, how likely it applies, and what it does. */
60
+ export interface Detected {
61
+ /** The skill's own name for a skill (`code-review`), else the tool's. */
62
+ name: string;
63
+ skill: boolean;
64
+ /** Where it comes from: skill, mcp, connector, function, agent. */
65
+ source: string;
66
+ description: string;
67
+ /** 0 to 1. */
68
+ probability: number;
69
+ }
70
+ /**
71
+ * Which skills and tools apply to `prompt`, as Kai decides it (cloud apps/tools
72
+ * detect.go; a lexical fallback answers when Kai does not). Only asks: nothing
73
+ * is switched on (`autoActivate` is left out), so a message carries what was
74
+ * picked for it and nothing more.
75
+ */
76
+ export declare function detect(t: Target, prompt: string, opts?: {
77
+ maxSkills?: number;
78
+ maxTools?: number;
79
+ signal?: AbortSignal;
80
+ }): Promise<Detected[]>;
package/lib/api/skills.js CHANGED
@@ -7,6 +7,7 @@
7
7
  * DELETE /v1/tool/skills/{id} {deleted}
8
8
  * GET /.well-known/agent-skills/index.json the brand's catalogue, public
9
9
  * GET /.well-known/agent-skills/{name}/SKILL.md one of its documents, public
10
+ * POST /v1/tool/detect {prompt, maxSkills, maxTools} → {skills, tools} Kai's pick for one message
10
11
  *
11
12
  * A skill is on when its tool name, `skill_<name>`, is activated (tools.ts):
12
13
  * that is how a catalogue skill is added to an org and how an org's own skill is
@@ -97,3 +98,20 @@ export async function brand(t) {
97
98
  export async function document(t, name) {
98
99
  return (await open(t, `${seg(name)}/SKILL.md`)).text();
99
100
  }
101
+ /**
102
+ * Which skills and tools apply to `prompt`, as Kai decides it (cloud apps/tools
103
+ * detect.go; a lexical fallback answers when Kai does not). Only asks: nothing
104
+ * is switched on (`autoActivate` is left out), so a message carries what was
105
+ * picked for it and nothing more.
106
+ */
107
+ export async function detect(t, prompt, opts = {}) {
108
+ const raw = await call(t, 'POST', '/v1/tool/detect', { prompt, maxSkills: opts.maxSkills ?? 3, maxTools: opts.maxTools ?? 3 }, { signal: opts.signal });
109
+ const r = (raw && typeof raw === 'object' ? raw : {});
110
+ const read = (list, skill) => (Array.isArray(list) ? list : []).flatMap((x) => {
111
+ const o = (x && typeof x === 'object' ? x : {});
112
+ const tool = str(o.name);
113
+ const name = skill ? nameOf(tool) || tool : tool;
114
+ return name ? [{ name, skill, source: str(o.source), description: str(o.description), probability: num(o.probability) }] : [];
115
+ });
116
+ return [...read(r.skills, true), ...read(r.tools, false)];
117
+ }
package/lib/api/turn.d.ts CHANGED
@@ -141,10 +141,13 @@ export type Card = {
141
141
  text: string;
142
142
  done: boolean;
143
143
  }[];
144
- } | {
144
+ }
145
+ /** `step`: a line about the run getting going (started, sent to a machine), the process rather than its end. */
146
+ | {
145
147
  kind: 'note';
146
148
  key: string;
147
149
  text: string;
150
+ step?: true;
148
151
  } | {
149
152
  kind: 'plan';
150
153
  key: string;
package/lib/api/turn.js CHANGED
@@ -518,8 +518,9 @@ export function cards(events, mode = '', t = english) {
518
518
  break;
519
519
  }
520
520
  const line = status(b, mode, t);
521
+ const going = str(b.status) === 'started' || str(b.status) === 'routed';
521
522
  if (line)
522
- out.push({ kind: 'note', key: mint(), text: line });
523
+ out.push(going ? { kind: 'note', key: mint(), text: line, step: true } : { kind: 'note', key: mint(), text: line });
523
524
  break;
524
525
  }
525
526
  case 'control': {
package/lib/carry.d.ts CHANGED
@@ -27,6 +27,13 @@ export interface Carry {
27
27
  /** The words the gear adds to every message, '' when none. */
28
28
  text: string;
29
29
  }
30
+ /**
31
+ * The words skills add to a message: each one's SKILL.md (the org's own before
32
+ * the brand's), at most `max` of each, or its name when no document answers.
33
+ * Chat carries the ones Hanzo chose for a single message the same way
34
+ * (hanzo-inc/app issue 314).
35
+ */
36
+ export declare function skillsSaid(t: Target, skills: readonly string[], max?: number): Promise<string>;
30
37
  /** What Manual asks about: a plugin, or a Dev run. `id` is what "always" remembers. */
31
38
  export interface Asked {
32
39
  id: string;
package/lib/carry.js CHANGED
@@ -39,6 +39,23 @@ async function remembered(t) {
39
39
  .map((r) => (r && typeof r === 'object' ? String(r.content ?? '') : ''))
40
40
  .filter(Boolean);
41
41
  }
42
+ /**
43
+ * The words skills add to a message: each one's SKILL.md (the org's own before
44
+ * the brand's), at most `max` of each, or its name when no document answers.
45
+ * Chat carries the ones Hanzo chose for a single message the same way
46
+ * (hanzo-inc/app issue 314).
47
+ */
48
+ export async function skillsSaid(t, skills, max = SKILL_MAX) {
49
+ if (!skills.length)
50
+ return '';
51
+ const own = t.token() ? await authored(t).catch(() => []) : [];
52
+ const parts = [];
53
+ for (const n of skills) {
54
+ const body = own.find((s) => s.name === n)?.content || (await document(t, n).catch(() => ''));
55
+ parts.push(body ? `Use the skill "${n}" where it applies:\n\n${body.slice(0, max)}` : `Use the "${n}" skill where it applies.`);
56
+ }
57
+ return parts.join('\n\n');
58
+ }
42
59
  /** The words `skills`, `memory` and `mode` add to a message. */
43
60
  async function said(t, skills, memory, mode, design) {
44
61
  const parts = [];
@@ -47,16 +64,9 @@ async function said(t, skills, memory, mode, design) {
47
64
  if (b?.name)
48
65
  parts.push(designSaid(b));
49
66
  }
50
- if (skills.length) {
51
- const own = t.token() ? await authored(t).catch(() => []) : [];
52
- for (const n of skills) {
53
- const body = own.find((s) => s.name === n)?.content || (await document(t, n).catch(() => ''));
54
- if (body)
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.`);
58
- }
59
- }
67
+ const taught = await skillsSaid(t, skills);
68
+ if (taught)
69
+ parts.push(taught);
60
70
  if (memory) {
61
71
  const lines = await remembered(t).catch(() => []);
62
72
  if (lines.length)
package/lib/dev-mode.d.ts CHANGED
@@ -1,6 +1,23 @@
1
1
  import type { Say } from '@hanzo/i18n/react';
2
2
  export declare const DEV_MODE_KEY = "hanzo.dev_mode";
3
3
  export declare const DEV_MODE_EVENT = "hanzo:dev-mode";
4
+ /** What Developer mode does, in one line, wherever its switch is drawn (English, marked; drawn through `t`). */
5
+ export declare const DEV_MODE_NOTE: string;
6
+ /**
7
+ * DEVELOPER MODE IS OFF FOR A NEW PERSON, and the result is what they see
8
+ * (hanzo-inc/app issues 317 and 321). Someone who has worked with the process
9
+ * on this device keeps seeing it: the first time the choice is read where it
10
+ * was never made, it is made once from what this device shows of them, and kept.
11
+ *
12
+ * - Tabs listed a machine or a cloud workspace of theirs (`hanzo.tabs.fleet`):
13
+ * they opened a terminal, or linked a computer with the CLI.
14
+ * - Dev's transcript view is Thinking or Verbose: they asked to see more of it.
15
+ *
16
+ * Anyone else, including someone who has only built with Dev, starts with the
17
+ * result. The switch (Settings › General, the account menu, a run's menu, ⌘⇧D)
18
+ * changes it either way.
19
+ */
20
+ export declare function adopt(store: Pick<Storage, 'getItem'>): boolean;
4
21
  export declare function getDevMode(): boolean;
5
22
  export declare function setDevMode(next: boolean): void;
6
23
  export declare function useDevMode(): [boolean, (next: boolean) => void];
package/lib/dev-mode.js CHANGED
@@ -1,13 +1,47 @@
1
+ import { phrase } from '@hanzo/i18n';
1
2
  import { useCallback, useSyncExternalStore } from 'react';
2
3
  import { friendly } from './names.js';
3
4
  import { english } from './say.js';
4
5
  export const DEV_MODE_KEY = 'hanzo.dev_mode';
5
6
  export const DEV_MODE_EVENT = 'hanzo:dev-mode';
7
+ /** What Developer mode does, in one line, wherever its switch is drawn (English, marked; drawn through `t`). */
8
+ export const DEV_MODE_NOTE = phrase('Shows the process: the terminal, the commands Hanzo runs and each step. Off, Hanzo shows the result.');
9
+ /**
10
+ * DEVELOPER MODE IS OFF FOR A NEW PERSON, and the result is what they see
11
+ * (hanzo-inc/app issues 317 and 321). Someone who has worked with the process
12
+ * on this device keeps seeing it: the first time the choice is read where it
13
+ * was never made, it is made once from what this device shows of them, and kept.
14
+ *
15
+ * - Tabs listed a machine or a cloud workspace of theirs (`hanzo.tabs.fleet`):
16
+ * they opened a terminal, or linked a computer with the CLI.
17
+ * - Dev's transcript view is Thinking or Verbose: they asked to see more of it.
18
+ *
19
+ * Anyone else, including someone who has only built with Dev, starts with the
20
+ * result. The switch (Settings › General, the account menu, a run's menu, ⌘⇧D)
21
+ * changes it either way.
22
+ */
23
+ export function adopt(store) {
24
+ try {
25
+ const view = store.getItem('hanzo.build.transcript.view');
26
+ if (view === '"thinking"' || view === '"verbose"')
27
+ return true;
28
+ const fleet = JSON.parse(store.getItem('hanzo.tabs.fleet') || '[]');
29
+ return Array.isArray(fleet) && fleet.length > 0;
30
+ }
31
+ catch {
32
+ return false;
33
+ }
34
+ }
6
35
  export function getDevMode() {
7
36
  if (typeof window === 'undefined')
8
37
  return false;
9
38
  try {
10
- return window.localStorage.getItem(DEV_MODE_KEY) === 'true';
39
+ const kept = window.localStorage.getItem(DEV_MODE_KEY);
40
+ if (kept !== null)
41
+ return kept === 'true';
42
+ const chosen = adopt(window.localStorage);
43
+ window.localStorage.setItem(DEV_MODE_KEY, chosen ? 'true' : 'false');
44
+ return chosen;
11
45
  }
12
46
  catch {
13
47
  return false;
package/lib/host.d.ts CHANGED
@@ -11,6 +11,7 @@ import { type ComponentType, type ReactNode } from 'react';
11
11
  import type { Cast } from './api/agents.ts';
12
12
  import type { Target } from './api/call.ts';
13
13
  import type { Theme } from './api/pref.ts';
14
+ import type { Local } from './local.ts';
14
15
  export interface Person {
15
16
  name: string;
16
17
  email: string;
@@ -118,6 +119,11 @@ export interface Host {
118
119
  cast?: readonly Cast[];
119
120
  /** Every persona Customize › Agents offers to start from, read when Browse opens. Absent, none. */
120
121
  personas?: () => Promise<readonly Cast[]>;
122
+ /**
123
+ * The folders of the computer the host runs on, and a run in one of them (local.ts): Hanzo Desktop has them, so New
124
+ * offers This computer with Auto picking the folder used last. A browser page has no folder of its own: absent.
125
+ */
126
+ local?: Local;
121
127
  }
122
128
  export declare function HostProvider({ host, children }: {
123
129
  host: Host;
@@ -126,6 +132,8 @@ export declare function HostProvider({ host, children }: {
126
132
  export declare function useHost(): Host;
127
133
  /** The host's way of showing a page, where one is mounted and has one. The side panel is drawn without a host too (hanzo.team's rooms). */
128
134
  export declare function useBrowse(): Browse | null;
135
+ /** The host's computer and its folders, where the host runs on one (Hanzo Desktop). */
136
+ export declare function useLocal(): Local | null;
129
137
  /** The host's browser, where one is mounted and has one. */
130
138
  export declare function useBrowser(): Browser | null;
131
139
  /** The call target for this host — stable while the host's api, token reader and org are. */
package/lib/host.js CHANGED
@@ -23,6 +23,10 @@ export function useHost() {
23
23
  export function useBrowse() {
24
24
  return useContext(Context)?.browse ?? null;
25
25
  }
26
+ /** The host's computer and its folders, where the host runs on one (Hanzo Desktop). */
27
+ export function useLocal() {
28
+ return useContext(Context)?.local ?? null;
29
+ }
26
30
  /** The host's browser, where one is mounted and has one. */
27
31
  export function useBrowser() {
28
32
  return useContext(Context)?.browser ?? null;
package/lib/index.d.ts CHANGED
@@ -42,8 +42,10 @@ export { kind, label, said, share, spent, ways, when, type Label, type Share, ty
42
42
  export type { Limits } from './api/limits.ts';
43
43
  export type { Target } from './api/call.ts';
44
44
  export type { Browse, Browser, Host, Person, Shown } from './host.tsx';
45
+ export type { Done, Folder, Local } from './local.ts';
45
46
  export type { Session, Status } from './api/sessions.ts';
46
47
  export { talks } from './api/talk.ts';
48
+ export { detect, type Detected } from './api/skills.ts';
47
49
  export type { Read } from './data.ts';
48
50
  export { href, parse, path, PLACES, route, SESSION, SLUG, type Route, type Screen } from './route.ts';
49
51
  /**
@@ -56,13 +58,14 @@ export { catalog, EFFORTS, FIRST, grants, isFree, keep, kept, level, nameOf, pac
56
58
  export { DEV_HANDOFF, takeHandoff } from './handoff.ts';
57
59
  export { useEar } from './voice.ts';
58
60
  export { BARE, CHAT_MODES, DEV_MODES, gearOf, MODES, useGear, useLanguage, type Gear, type GearState, type Mode as GearMode } from './gear.ts';
59
- export { useCarry, type Carry } from './carry.tsx';
61
+ export { skillsSaid, useCarry, type Carry } from './carry.tsx';
60
62
  export { artifacts, blob, lead, renders, Reply, Served, speakable, speaker, type Artifact, type Listen } from './reply.tsx';
61
63
  export { frames, Page, Panel, PanelToggle, type Kind, type PageProps, type PanelProps, type Suggestion } from './panel.tsx';
62
64
  export { SideProvider, useSplit, type Split } from './side.tsx';
63
65
  export { PrefsProvider } from './prefs.tsx';
64
66
  export { deviceKey, friendly, heldNames, NAMES_KEY, rename, shellKey, useDeviceNames, type Names } from './names.ts';
65
- export { formatDeviceLabel, type DeviceLabelOptions } from './dev-mode.ts';
67
+ export { DEV_MODE_NOTE, formatDeviceLabel, type DeviceLabelOptions } from './dev-mode.ts';
68
+ export { plainPath } from './plain.ts';
66
69
  export { Rename } from './ask.tsx';
67
70
  export { kinds, Summary, useKinds, type Entry, type Section } from './summary.tsx';
68
71
  /**
package/lib/index.js CHANGED
@@ -40,6 +40,7 @@ export { Credits, SEPARATE } from './settings/credits.js';
40
40
  export { useStanding, rows, left } from './standing.js';
41
41
  export { kind, label, said, share, spent, ways, when } from './plan.js';
42
42
  export { talks } from './api/talk.js';
43
+ export { detect } from './api/skills.js';
43
44
  export { href, parse, path, PLACES, route, SESSION, SLUG } from './route.js';
44
45
  /**
45
46
  * What Chat draws the same way (@hanzo/rooms imports these): the model and
@@ -51,13 +52,14 @@ export { catalog, EFFORTS, FIRST, grants, isFree, keep, kept, level, nameOf, pac
51
52
  export { DEV_HANDOFF, takeHandoff } from './handoff.js';
52
53
  export { useEar } from './voice.js';
53
54
  export { BARE, CHAT_MODES, DEV_MODES, gearOf, MODES, useGear, useLanguage } from './gear.js';
54
- export { useCarry } from './carry.js';
55
+ export { skillsSaid, useCarry } from './carry.js';
55
56
  export { artifacts, blob, lead, renders, Reply, Served, speakable, speaker } from './reply.js';
56
57
  export { frames, Page, Panel, PanelToggle } from './panel.js';
57
58
  export { SideProvider, useSplit } from './side.js';
58
59
  export { PrefsProvider } from './prefs.js';
59
60
  export { deviceKey, friendly, heldNames, NAMES_KEY, rename, shellKey, useDeviceNames } from './names.js';
60
- export { formatDeviceLabel } from './dev-mode.js';
61
+ export { DEV_MODE_NOTE, formatDeviceLabel } from './dev-mode.js';
62
+ export { plainPath } from './plain.js';
61
63
  export { Rename } from './ask.js';
62
64
  export { kinds, Summary, useKinds } from './summary.js';
63
65
  /**