@hanzo/build 0.2.122 → 0.2.124
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/cli.d.ts +59 -0
- package/lib/api/cli.js +133 -0
- package/lib/api/coding.d.ts +7 -1
- package/lib/api/coding.js +33 -6
- package/lib/api/sessions.d.ts +26 -4
- package/lib/api/sessions.js +81 -22
- package/lib/api/talk.d.ts +48 -0
- package/lib/api/talk.js +81 -0
- package/lib/api/turn.d.ts +29 -3
- package/lib/api/turn.js +121 -5
- package/lib/builder.js +2 -2
- package/lib/data.d.ts +4 -2
- package/lib/data.js +38 -10
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/landing.js +24 -27
- package/lib/mind.d.ts +2 -0
- package/lib/mind.js +28 -1
- package/lib/project.js +4 -1
- package/lib/run.d.ts +1 -0
- package/lib/run.js +32 -7
- package/lib/section.d.ts +5 -0
- package/lib/section.js +7 -1
- package/lib/talk.d.ts +5 -0
- package/lib/talk.js +104 -0
- package/lib/transcript.d.ts +5 -1
- package/lib/transcript.js +15 -4
- package/package.json +1 -1
package/lib/api/turn.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Say } from '@hanzo/i18n/react';
|
|
2
|
+
import { type Changed, type Explore } from './cli.ts';
|
|
2
3
|
import type { Event } from './sessions.ts';
|
|
3
4
|
/** The payload as an object. A live frame may carry it as a JSON string. */
|
|
4
5
|
export declare function decode(payload: unknown): Record<string, unknown> | string | null;
|
|
@@ -91,12 +92,15 @@ export type Ran = 'running' | 'done' | 'error' | 'cancelled';
|
|
|
91
92
|
*
|
|
92
93
|
* said prose: the agent's messages (markdown), or a person's steering words
|
|
93
94
|
* think the agent's reasoning, folded until opened
|
|
94
|
-
* shell a command the agent ran, and what it printed
|
|
95
|
-
*
|
|
95
|
+
* shell a command the agent ran, and what it printed: the CLI's "Ran"
|
|
96
|
+
* explore reads, listings and searches, consecutive ones together: the CLI's "Explored"
|
|
97
|
+
* edit files the agent changed, with the lines each adds and removes; the diff is the run's Git tab
|
|
96
98
|
* step a step of the run itself (lease, clone, install, push), or a tool the agent called
|
|
97
99
|
* todo the agent's plan, as a checklist it ticks
|
|
98
100
|
* note a lifecycle line: started, pushed, stopped
|
|
99
101
|
* plan a plan run's answer, which can be approved into a build
|
|
102
|
+
* run a coding run a conversation's turn started (talk.ts), opened on its own page
|
|
103
|
+
* ask a question the run asked its person, with its options, and the answer once given
|
|
100
104
|
*/
|
|
101
105
|
export type Card = {
|
|
102
106
|
kind: 'said';
|
|
@@ -113,10 +117,15 @@ export type Card = {
|
|
|
113
117
|
command: string;
|
|
114
118
|
output: string;
|
|
115
119
|
ran: Ran;
|
|
120
|
+
} | {
|
|
121
|
+
kind: 'explore';
|
|
122
|
+
key: string;
|
|
123
|
+
calls: Explore[];
|
|
124
|
+
ran: Ran;
|
|
116
125
|
} | {
|
|
117
126
|
kind: 'edit';
|
|
118
127
|
key: string;
|
|
119
|
-
files:
|
|
128
|
+
files: Changed[];
|
|
120
129
|
ran: Ran;
|
|
121
130
|
} | {
|
|
122
131
|
kind: 'step';
|
|
@@ -140,6 +149,17 @@ export type Card = {
|
|
|
140
149
|
kind: 'plan';
|
|
141
150
|
key: string;
|
|
142
151
|
text: string;
|
|
152
|
+
} | {
|
|
153
|
+
kind: 'run';
|
|
154
|
+
key: string;
|
|
155
|
+
session: string;
|
|
156
|
+
} | {
|
|
157
|
+
kind: 'ask';
|
|
158
|
+
key: string;
|
|
159
|
+
question: string;
|
|
160
|
+
text: string;
|
|
161
|
+
options: string[];
|
|
162
|
+
answer: string;
|
|
143
163
|
};
|
|
144
164
|
/**
|
|
145
165
|
* A run's events, as the cards its transcript draws. `mode` is the run's, from
|
|
@@ -155,6 +175,12 @@ export type Card = {
|
|
|
155
175
|
* answer, drawn once. `log` is never drawn here.
|
|
156
176
|
*/
|
|
157
177
|
export declare function cards(events: Pick<Event, 'kind' | 'payload' | 'seq'>[], mode?: string, t?: Say): Card[];
|
|
178
|
+
/**
|
|
179
|
+
* Cards as the CLI prints them, line for line: what a run's transcript reads as in
|
|
180
|
+
* `dev`'s terminal. The transcript draws the same words (transcript.tsx); this is
|
|
181
|
+
* them as text, which the parity tests hold to the CLI's own.
|
|
182
|
+
*/
|
|
183
|
+
export declare function printed(cards: Card[], live?: boolean): string;
|
|
158
184
|
/** The plan a plan run answered with, from its final status, or ''. */
|
|
159
185
|
export declare function answer(events: Pick<Event, 'kind' | 'payload' | 'seq'>[]): string;
|
|
160
186
|
export interface Settled {
|
package/lib/api/turn.js
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
*/
|
|
30
30
|
import { phrase } from '@hanzo/i18n';
|
|
31
31
|
import { english } from '../say.js';
|
|
32
|
+
import { actions, called, counted, edited, explored, explores, shown } from './cli.js';
|
|
32
33
|
const str = (v) => (typeof v === 'string' ? v : '');
|
|
33
34
|
const obj = (v) => (v && typeof v === 'object' ? v : {});
|
|
34
35
|
/** The payload as an object. A live frame may carry it as a JSON string. */
|
|
@@ -339,14 +340,37 @@ function item(it, key) {
|
|
|
339
340
|
return str(it.text) ? { kind: 'said', key, who: 'agent', text: str(it.text) } : null;
|
|
340
341
|
case 'reasoning':
|
|
341
342
|
return str(it.text) ? { kind: 'think', key, text: str(it.text) } : null;
|
|
342
|
-
case 'command_execution':
|
|
343
|
-
|
|
343
|
+
case 'command_execution': {
|
|
344
|
+
// What the command did is the agent's own parse of it (cli.ts): exploration, or a command it ran.
|
|
345
|
+
const did = actions(it.command_actions);
|
|
346
|
+
if (explores(did))
|
|
347
|
+
return { kind: 'explore', key, calls: [{ actions: did, exit: typeof it.exit_code === 'number' ? it.exit_code : null }], ran: itemRan(it) };
|
|
348
|
+
return { kind: 'shell', key, command: shown(str(it.command)), output: str(it.aggregated_output), ran: itemRan(it) };
|
|
349
|
+
}
|
|
344
350
|
case 'file_change': {
|
|
345
351
|
const changes = Array.isArray(it.changes) ? it.changes : [];
|
|
346
|
-
|
|
352
|
+
const files = changes
|
|
353
|
+
.map((c) => {
|
|
354
|
+
const o = obj(c);
|
|
355
|
+
const kind = o.kind === 'add' || o.kind === 'delete' ? o.kind : 'update';
|
|
356
|
+
const n = (v) => (typeof v === 'number' ? v : null);
|
|
357
|
+
return { path: rel(str(o.path)), kind, added: n(o.added), removed: n(o.removed) };
|
|
358
|
+
})
|
|
359
|
+
.filter((f) => f.path);
|
|
360
|
+
return { kind: 'edit', key, files, ran: itemRan(it) };
|
|
361
|
+
}
|
|
362
|
+
case 'mcp_tool_call': {
|
|
363
|
+
const ran = itemRan(it);
|
|
364
|
+
const said = Array.isArray(obj(it.result).content) ? obj(it.result).content.map((c) => str(obj(c).text)).filter(Boolean).join('\n') : '';
|
|
365
|
+
return {
|
|
366
|
+
kind: 'step',
|
|
367
|
+
key,
|
|
368
|
+
name: ran === 'running' ? phrase('Calling') : phrase('Called'),
|
|
369
|
+
detail: called(str(it.server), str(it.tool), it.arguments),
|
|
370
|
+
output: str(obj(it.error).message) || said,
|
|
371
|
+
ran,
|
|
372
|
+
};
|
|
347
373
|
}
|
|
348
|
-
case 'mcp_tool_call':
|
|
349
|
-
return { kind: 'step', key, name: str(it.tool) || phrase('Tool'), detail: str(it.server), output: '', ran: itemRan(it) };
|
|
350
374
|
case 'web_search':
|
|
351
375
|
return { kind: 'step', key, name: phrase('Search'), detail: str(it.query), output: '', ran: 'done' };
|
|
352
376
|
case 'todo_list': {
|
|
@@ -386,6 +410,8 @@ export function cards(events, mode = '', t = english) {
|
|
|
386
410
|
return c;
|
|
387
411
|
};
|
|
388
412
|
const failures = new Set();
|
|
413
|
+
const spawned = new Set();
|
|
414
|
+
const asked = new Map();
|
|
389
415
|
const failed = (message) => {
|
|
390
416
|
if (failures.has(message))
|
|
391
417
|
return;
|
|
@@ -461,6 +487,20 @@ export function cards(events, mode = '', t = english) {
|
|
|
461
487
|
phase = null;
|
|
462
488
|
if (!b)
|
|
463
489
|
break;
|
|
490
|
+
// A question the run asked its person (apps/agents ask.go), and its answer, drawn on the question.
|
|
491
|
+
if (str(b.status) === 'asked') {
|
|
492
|
+
const options = (Array.isArray(b.options) ? b.options : []).map((o) => str(obj(o).label)).filter(Boolean);
|
|
493
|
+
asked.set(str(b.question), out.length);
|
|
494
|
+
out.push({ kind: 'ask', key: mint(), question: str(b.question), text: str(b.text), options, answer: '' });
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
if (str(b.status) === 'answered') {
|
|
498
|
+
const at = asked.get(str(b.question));
|
|
499
|
+
const card = at === undefined ? undefined : out[at];
|
|
500
|
+
if (card?.kind === 'ask')
|
|
501
|
+
out[at] = { ...card, answer: str(b.answer) };
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
464
504
|
const done = str(b.status) === 'done';
|
|
465
505
|
const text = str(b.plan) || str(b.answer);
|
|
466
506
|
if (done && (mode === 'plan' || mode === 'setup') && text) {
|
|
@@ -507,6 +547,21 @@ export function cards(events, mode = '', t = english) {
|
|
|
507
547
|
out.push({ kind: 'said', key: mint(), who: 'agent', text });
|
|
508
548
|
break;
|
|
509
549
|
}
|
|
550
|
+
case 'spawn': {
|
|
551
|
+
// A conversation's turn started a coding run, or follows the one that carried it on.
|
|
552
|
+
const session = str(b?.session);
|
|
553
|
+
if (!session || spawned.has(session))
|
|
554
|
+
break;
|
|
555
|
+
spawned.add(session);
|
|
556
|
+
out.push({ kind: 'run', key: mint(), session });
|
|
557
|
+
break;
|
|
558
|
+
}
|
|
559
|
+
case 'log': {
|
|
560
|
+
// A conversation's turn that failed says why on its record of the run.
|
|
561
|
+
if (b && str(b.runId) && str(b.status) === 'error')
|
|
562
|
+
failed(str(b.error));
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
510
565
|
}
|
|
511
566
|
}
|
|
512
567
|
// The answer a status carries is also the agent's last message: each is drawn once, as the answer.
|
|
@@ -523,8 +578,69 @@ export function cards(events, mode = '', t = english) {
|
|
|
523
578
|
const ask = out.findIndex((c) => c.kind === 'said' && c.who === 'person' && !steered.has(c));
|
|
524
579
|
if (ask > 0)
|
|
525
580
|
out.unshift(...out.splice(ask, 1));
|
|
581
|
+
return gather(out);
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Consecutive exploration as the CLI keeps it: one Explored block, open across the
|
|
585
|
+
* reads, listings and searches that follow each other — the agent's reasoning
|
|
586
|
+
* between them included, which stays where it was said, after the block.
|
|
587
|
+
*/
|
|
588
|
+
function gather(cards) {
|
|
589
|
+
const out = [];
|
|
590
|
+
let open = null;
|
|
591
|
+
for (const c of cards) {
|
|
592
|
+
if (c.kind === 'explore') {
|
|
593
|
+
if (open) {
|
|
594
|
+
open.calls = [...open.calls, ...c.calls];
|
|
595
|
+
if (c.ran === 'running')
|
|
596
|
+
open.ran = 'running';
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
open = { ...c, calls: [...c.calls] };
|
|
600
|
+
out.push(open);
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
if (c.kind !== 'think')
|
|
604
|
+
open = null;
|
|
605
|
+
out.push(c);
|
|
606
|
+
}
|
|
526
607
|
return out;
|
|
527
608
|
}
|
|
609
|
+
/**
|
|
610
|
+
* Cards as the CLI prints them, line for line: what a run's transcript reads as in
|
|
611
|
+
* `dev`'s terminal. The transcript draws the same words (transcript.tsx); this is
|
|
612
|
+
* them as text, which the parity tests hold to the CLI's own.
|
|
613
|
+
*/
|
|
614
|
+
export function printed(cards, live = false) {
|
|
615
|
+
const lines = [];
|
|
616
|
+
const under = (first, rest = ' ') => first.map((l, i) => `${i === 0 ? ' └ ' : rest}${l}`);
|
|
617
|
+
for (const c of cards) {
|
|
618
|
+
switch (c.kind) {
|
|
619
|
+
case 'explore':
|
|
620
|
+
lines.push(`• ${c.ran === 'running' && live ? 'Exploring' : 'Explored'}`, ...under(explored(c.calls).map((l) => `${l.title} ${l.text}`)));
|
|
621
|
+
break;
|
|
622
|
+
case 'shell': {
|
|
623
|
+
const output = c.output.replace(/\n+$/, '');
|
|
624
|
+
lines.push(`• ${c.ran === 'running' && live ? 'Running' : 'Ran'} ${c.command}`, ...under(output ? output.split('\n') : ['(no output)']));
|
|
625
|
+
break;
|
|
626
|
+
}
|
|
627
|
+
case 'edit':
|
|
628
|
+
lines.push(`• ${edited(c.files)}`);
|
|
629
|
+
if (c.files.length > 1)
|
|
630
|
+
lines.push(...c.files.map((f) => ` └ ${f.path} ${counted(f)}`.trimEnd()));
|
|
631
|
+
break;
|
|
632
|
+
case 'step':
|
|
633
|
+
if (c.name === 'Called' || c.name === 'Calling')
|
|
634
|
+
lines.push(`• ${c.name} ${c.detail}`);
|
|
635
|
+
break;
|
|
636
|
+
case 'said':
|
|
637
|
+
if (c.who === 'agent')
|
|
638
|
+
lines.push(`• ${c.text}`);
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return lines.join('\n');
|
|
643
|
+
}
|
|
528
644
|
/** The plan a plan run answered with, from its final status, or ''. */
|
|
529
645
|
export function answer(events) {
|
|
530
646
|
let out = '';
|
package/lib/builder.js
CHANGED
|
@@ -48,7 +48,7 @@ import { Project } from './project.js';
|
|
|
48
48
|
import { Plans } from './plans.js';
|
|
49
49
|
import { path, route } from './route.js';
|
|
50
50
|
import { Run } from './run.js';
|
|
51
|
-
import {
|
|
51
|
+
import { dot } from './section.js';
|
|
52
52
|
import { Library } from './library.js';
|
|
53
53
|
import { Templates } from './shelf.js';
|
|
54
54
|
import { Find } from './find.js';
|
|
@@ -71,7 +71,7 @@ function Shell() {
|
|
|
71
71
|
host.go(p);
|
|
72
72
|
};
|
|
73
73
|
const rows = useMemo(() => {
|
|
74
|
-
const list = recents.value.map((s) => ({ id: s.id, title: s.title || say('Untitled run'), status:
|
|
74
|
+
const list = recents.value.map((s) => ({ id: s.id, title: s.title || say('Untitled run'), status: dot(s) }));
|
|
75
75
|
if (order === 'running')
|
|
76
76
|
list.sort((a, b) => Number(b.status === 'running') - Number(a.status === 'running'));
|
|
77
77
|
return list;
|
package/lib/data.d.ts
CHANGED
|
@@ -24,8 +24,10 @@ export declare class Slow extends Error {
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function useCached<T>(key: string | null, load: (signal: AbortSignal) => Promise<T>, initial: T, wait?: number): Read<T>;
|
|
26
26
|
/**
|
|
27
|
-
* The org's coding runs, newest first, kept current by the
|
|
28
|
-
* stream: a status that moves moves its dot, and
|
|
27
|
+
* The org's conversations and coding runs, newest first, kept current by the
|
|
28
|
+
* org's own session stream: a status that moves moves its dot, and one started
|
|
29
|
+
* anywhere appears. A conversation's own coding runs are in its tree, not here:
|
|
30
|
+
* the platform lists roots.
|
|
29
31
|
*/
|
|
30
32
|
export declare function useRecents(t: Target, signed: boolean): Read<Session[]>;
|
|
31
33
|
export declare function usePlaces(t: Target, signed: boolean): Read<Place[]>;
|
package/lib/data.js
CHANGED
|
@@ -11,6 +11,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
11
11
|
import { places } from './api/places.js';
|
|
12
12
|
import { projects } from './api/projects.js';
|
|
13
13
|
import { get, list, watch } from './api/sessions.js';
|
|
14
|
+
import { TALK } from './api/talk.js';
|
|
14
15
|
import { merge } from './api/turn.js';
|
|
15
16
|
/** Run `load` whenever `key` changes (and on `reload`), keeping the last good value. */
|
|
16
17
|
export function useRead(load, initial, key) {
|
|
@@ -117,15 +118,22 @@ export function useCached(key, load, initial, wait = WAIT) {
|
|
|
117
118
|
/** Last coding runs read per `api\norg`, so mounting another rail or switching tabs starts warm. */
|
|
118
119
|
const recentRuns = new Map();
|
|
119
120
|
/**
|
|
120
|
-
* The org's coding runs, newest first, kept current by the
|
|
121
|
-
* stream: a status that moves moves its dot, and
|
|
121
|
+
* The org's conversations and coding runs, newest first, kept current by the
|
|
122
|
+
* org's own session stream: a status that moves moves its dot, and one started
|
|
123
|
+
* anywhere appears. A conversation's own coding runs are in its tree, not here:
|
|
124
|
+
* the platform lists roots.
|
|
122
125
|
*/
|
|
123
126
|
export function useRecents(t, signed) {
|
|
124
127
|
const scope = signed ? `${t.api}\n${t.org ?? ''}` : null;
|
|
125
128
|
const warm = scope !== null ? recentRuns.get(scope) : undefined;
|
|
126
129
|
const read = useRead(signed
|
|
127
130
|
? async () => {
|
|
128
|
-
const
|
|
131
|
+
const [runs, talked] = await Promise.all([list(t, { kind: 'coding', limit: 50 }), list(t, { channel: TALK, limit: 50 })]);
|
|
132
|
+
const seen = new Set();
|
|
133
|
+
const next = [...runs, ...talked]
|
|
134
|
+
.filter((s) => !seen.has(s.id) && Boolean(seen.add(s.id)))
|
|
135
|
+
.sort((a, b) => b.createdAt.localeCompare(a.createdAt))
|
|
136
|
+
.slice(0, 50);
|
|
129
137
|
if (scope !== null)
|
|
130
138
|
recentRuns.set(scope, next);
|
|
131
139
|
return next;
|
|
@@ -215,36 +223,56 @@ export function useKept(key, initial) {
|
|
|
215
223
|
* the record. `id` null reads nothing.
|
|
216
224
|
*/
|
|
217
225
|
export function useRun(t, id) {
|
|
218
|
-
const detail = useRead(id ? () => get(t, id) : null, null, [t, id]);
|
|
226
|
+
const detail = useRead(id ? () => get(t, id, { limit: 500 }) : null, null, [t, id]);
|
|
219
227
|
const [live, setLive] = useState([]);
|
|
220
228
|
const [pushed, setPushed] = useState(null);
|
|
221
229
|
const [refused, setRefused] = useState('');
|
|
222
230
|
const reload = useRef(detail.reload);
|
|
223
231
|
reload.current = detail.reload;
|
|
232
|
+
const seenId = useRef(null);
|
|
233
|
+
const highestSeq = useRef(0);
|
|
234
|
+
if (seenId.current !== id) {
|
|
235
|
+
seenId.current = id;
|
|
236
|
+
highestSeq.current = 0;
|
|
237
|
+
}
|
|
238
|
+
if (detail.value && detail.value.id === id) {
|
|
239
|
+
for (const e of detail.value.recent) {
|
|
240
|
+
if (e.sessionId === id && e.seq > highestSeq.current)
|
|
241
|
+
highestSeq.current = e.seq;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// The stream is followed by the run's tree: a conversation's coding run is in the
|
|
245
|
+
// conversation's (talk.ts), and its frames carry that root.
|
|
246
|
+
const root = (detail.value?.id === id && detail.value.root) || id;
|
|
224
247
|
useEffect(() => {
|
|
225
248
|
setLive([]);
|
|
226
249
|
setPushed(null);
|
|
227
250
|
setRefused('');
|
|
228
|
-
if (!id)
|
|
251
|
+
if (!id || !root)
|
|
229
252
|
return;
|
|
230
253
|
const ctl = new AbortController();
|
|
231
|
-
void watch(t,
|
|
254
|
+
void watch(t, root, {
|
|
232
255
|
// A frame from a stream this run has already left is not this run's.
|
|
233
256
|
event: (e) => {
|
|
234
|
-
if (!ctl.signal.aborted && e.sessionId === id)
|
|
257
|
+
if (!ctl.signal.aborted && e.sessionId === id) {
|
|
258
|
+
if (e.seq > highestSeq.current)
|
|
259
|
+
highestSeq.current = e.seq;
|
|
235
260
|
setLive((prev) => [...prev, e]);
|
|
261
|
+
}
|
|
236
262
|
},
|
|
237
263
|
session: (s) => {
|
|
238
264
|
if (!ctl.signal.aborted && s.id === id)
|
|
239
265
|
setPushed(s);
|
|
240
266
|
},
|
|
267
|
+
// A reconnect may have missed frames, and so may the move to the run's
|
|
268
|
+
// own tree once its read named one: either is read again.
|
|
241
269
|
open: (n) => {
|
|
242
|
-
if (n > 0)
|
|
270
|
+
if (n > 0 || root !== id)
|
|
243
271
|
reload.current();
|
|
244
272
|
},
|
|
245
|
-
}, ctl.signal).catch((e) => setRefused(e.message));
|
|
273
|
+
}, ctl.signal, { after: root === id ? highestSeq.current : 0 }).catch((e) => setRefused(e.message));
|
|
246
274
|
return () => ctl.abort();
|
|
247
|
-
}, [t, id]);
|
|
275
|
+
}, [t, id, root]);
|
|
248
276
|
// The read and the frames describe THIS run or nothing: a read kept from the
|
|
249
277
|
// run before (it stays until the next one lands, or forever if it fails) must
|
|
250
278
|
// not lend this run its pull request.
|
package/lib/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export { Editor } from './automations.tsx';
|
|
|
28
28
|
export { library, nav, NEW, own, sections, tabs, useScheduled, type Group } from './nav.tsx';
|
|
29
29
|
export { MARKS, type Icon, type Mark } from './marks.tsx';
|
|
30
30
|
export { useFunds, type Funds } from './mind.ts';
|
|
31
|
-
export { DevSection, DOTS, useSessions } from './section.tsx';
|
|
31
|
+
export { DevSection, dot, DOTS, useSessions } from './section.tsx';
|
|
32
32
|
export { HostProvider } from './host.tsx';
|
|
33
33
|
export { Slack, useWho, Who } from './foot.tsx';
|
|
34
34
|
export { Grip, type GripProps } from '@hanzo/ui';
|
|
@@ -43,6 +43,7 @@ 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
45
|
export type { Session, Status } from './api/sessions.ts';
|
|
46
|
+
export { talks } from './api/talk.ts';
|
|
46
47
|
export type { Read } from './data.ts';
|
|
47
48
|
export { href, parse, path, PLACES, route, SESSION, SLUG, type Route, type Screen } from './route.ts';
|
|
48
49
|
/**
|
package/lib/index.js
CHANGED
|
@@ -28,7 +28,7 @@ export { Editor } from './automations.js';
|
|
|
28
28
|
export { library, nav, NEW, own, sections, tabs, useScheduled } from './nav.js';
|
|
29
29
|
export { MARKS } from './marks.js';
|
|
30
30
|
export { useFunds } from './mind.js';
|
|
31
|
-
export { DevSection, DOTS, useSessions } from './section.js';
|
|
31
|
+
export { DevSection, dot, DOTS, useSessions } from './section.js';
|
|
32
32
|
export { HostProvider } from './host.js';
|
|
33
33
|
export { Slack, useWho, Who } from './foot.js';
|
|
34
34
|
export { Grip } from '@hanzo/ui';
|
|
@@ -39,6 +39,7 @@ export { Plan } from './settings/plan.js';
|
|
|
39
39
|
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
|
+
export { talks } from './api/talk.js';
|
|
42
43
|
export { href, parse, path, PLACES, route, SESSION, SLUG } from './route.js';
|
|
43
44
|
/**
|
|
44
45
|
* What Chat draws the same way (@hanzo/rooms imports these): the model and
|
package/lib/landing.js
CHANGED
|
@@ -7,10 +7,11 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
7
7
|
* composer Chat draws too (@hanzo/ui/chat): Dev hands it the three pills, the
|
|
8
8
|
* chips that go to its repositories, issues and templates, and its commands.
|
|
9
9
|
*
|
|
10
|
-
* Sending
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Sending opens a conversation (api/talk.ts) and goes to it: the agent answers,
|
|
11
|
+
* and decides for itself when the ask needs a sandbox or a coding run — on the
|
|
12
|
+
* repository, branch and machine chosen here, and only planning when Plan is on.
|
|
13
|
+
* A run on one of the org's machines needs a repository, so an ask with none
|
|
14
|
+
* chosen there opens the picker rather than making a project up from its words. The choices a person made here are kept in this
|
|
14
15
|
* browser, per org, so the next New starts where the last one did — and a kept
|
|
15
16
|
* repository New can no longer offer is let go, so the next run is not sent
|
|
16
17
|
* back to it. A repository can also be given by its address (Use a git URL).
|
|
@@ -21,7 +22,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
21
22
|
import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
|
|
22
23
|
import { phrase } from '@hanzo/i18n';
|
|
23
24
|
import { useI18n } from '@hanzo/i18n/react';
|
|
24
|
-
import { CircleDot, Cloud, Code,
|
|
25
|
+
import { CircleDot, Cloud, Code, GitBranch, LayoutTemplate, Link2, Monitor, Play } from '@hanzogui/lucide-icons-2';
|
|
25
26
|
import { Button } from '@hanzo/ui';
|
|
26
27
|
import { Composer, MEASURE } from '@hanzo/ui/chat';
|
|
27
28
|
import { BranchSelect, ChipSelect, FooterLink, RepoSelect } from '@hanzo/ui/product';
|
|
@@ -29,6 +30,7 @@ import { useLimits } from '@hanzo/ui/product/useLimits';
|
|
|
29
30
|
import { useDictation, useTalk, useVoice } from '@hanzo/voice';
|
|
30
31
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
31
32
|
import { start, unhonoured } from './api/coding.js';
|
|
33
|
+
import { say } from './api/talk.js';
|
|
32
34
|
import { asRepo, chosen, codebases, one } from './api/codebases.js';
|
|
33
35
|
import { heard, repos as githubRepos } from './api/github.js';
|
|
34
36
|
import { plain, read, SETUP, unset } from './api/environment.js';
|
|
@@ -110,13 +112,9 @@ export function Landing({ onStarted }) {
|
|
|
110
112
|
const [note, setNote] = useState('');
|
|
111
113
|
const [adding, setAdding] = useState(null);
|
|
112
114
|
const [offering, setOffering] = useState(false);
|
|
113
|
-
const [forgetful, setForgetful] = useState(false);
|
|
114
115
|
const [desk, setDesk] = useState(false);
|
|
115
116
|
const deck = useDeck('dev-new', { tabs: [{ id: 'tab-1', kind: PAGE, title: '' }], at: 'tab-1' });
|
|
116
117
|
useKey(() => setDesk((d) => !d));
|
|
117
|
-
const [browserTabs, setBrowserTabs] = useState(false);
|
|
118
|
-
const [webSearch, setWebSearch] = useState(false);
|
|
119
|
-
const [research, setResearch] = useState(false);
|
|
120
118
|
// Asking for a repository's address, for one the lists do not show.
|
|
121
119
|
const [giving, setGiving] = useState(false);
|
|
122
120
|
// The repository and branch lists are read again each time they open.
|
|
@@ -272,19 +270,22 @@ export function Landing({ onStarted }) {
|
|
|
272
270
|
setNote(prepped.reply.split('```')[0].trim());
|
|
273
271
|
return;
|
|
274
272
|
}
|
|
275
|
-
//
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
273
|
+
// The first thing said opens a conversation (api/talk.ts) and starts nothing:
|
|
274
|
+
// the agent answers, and leases a sandbox or starts a coding run only when the
|
|
275
|
+
// ask needs one — on the repository, branch, machine and Plan chosen here.
|
|
276
|
+
// Skills, memories and plugin system prompts travel out-of-band as
|
|
277
|
+
// developerInstructions so the user prompt stays clean and cacheable.
|
|
278
|
+
const developerInstructions = [carry.text, prepped.system ?? ''].filter(Boolean).join('\n\n');
|
|
279
|
+
const sent = await say(target, {
|
|
280
|
+
input: compose(said.trim(), files),
|
|
281
|
+
...(developerInstructions ? { developerInstructions } : {}),
|
|
282
282
|
// The name alone. The org rides the request, and a slash is not a repo name.
|
|
283
283
|
// An empty base or place is not sent: the default branch, and the sandbox.
|
|
284
284
|
repo: repo?.name ?? hub?.full_name,
|
|
285
285
|
base: repo ? kept.branch : hub ? kept.branch || hub.default_branch : undefined,
|
|
286
|
-
|
|
287
|
-
mode,
|
|
286
|
+
target: place.id,
|
|
287
|
+
// The mode the composer shows: Auto starts a build, Manual asks first, Plan only plans.
|
|
288
|
+
mode: carry.mode.value === 'manual' ? 'manual' : mode === 'plan' ? 'plan' : 'auto',
|
|
288
289
|
model: mind.model,
|
|
289
290
|
effort: level(mind.effort),
|
|
290
291
|
issue,
|
|
@@ -292,7 +293,7 @@ export function Landing({ onStarted }) {
|
|
|
292
293
|
setDraft('');
|
|
293
294
|
setFiles([]);
|
|
294
295
|
setIssue(0);
|
|
295
|
-
onStarted(
|
|
296
|
+
onStarted(sent.session);
|
|
296
297
|
}
|
|
297
298
|
catch (e) {
|
|
298
299
|
setNote(plain(e, repo?.name ?? hub?.full_name ?? t('a new project'), 'run', t));
|
|
@@ -430,24 +431,20 @@ export function Landing({ onStarted }) {
|
|
|
430
431
|
loading: places.loading,
|
|
431
432
|
error: places.error?.message ?? null,
|
|
432
433
|
};
|
|
433
|
-
return (_jsxs(XStack, { flex: 1, width: "100%", height: "100%", minW: 0, minH: 0, overflow: "hidden", children: [_jsxs(YStack, { flex: 1, minW: 0, minH: 0, height: "100%", overflow: "hidden", children: [_jsxs(XStack, { "data-slot": "conversation-head", shrink: 0, items: "center", justify: "space-between", gap: "$2", px: "$3", height: 36, "$max-md": { display: 'none' }, children: [_jsx(XStack, { items: "center", gap: "$2", minW: 0, flex: 1 }),
|
|
434
|
+
return (_jsxs(XStack, { flex: 1, width: "100%", height: "100%", minW: 0, minH: 0, overflow: "hidden", children: [_jsxs(YStack, { flex: 1, minW: 0, minH: 0, height: "100%", overflow: "hidden", children: [_jsxs(XStack, { "data-slot": "conversation-head", shrink: 0, items: "center", justify: "space-between", gap: "$2", px: "$3", height: 36, "$max-md": { display: 'none' }, children: [_jsx(XStack, { items: "center", gap: "$2", minW: 0, flex: 1 }), _jsx(XStack, { "data-slot": "conversation-controls", items: "center", gap: "$1", shrink: 0, children: wide ? _jsx(PanelToggle, { open: desk, onToggle: () => setDesk((d) => !d) }) : null })] }), _jsxs(YStack, { display: "grid", gridTemplateRows: wide ? '1fr auto auto 1fr' : 'minmax(0, 1fr) auto', items: "center", "$platform-web": { justifyItems: 'center' }, width: "100%", flex: 1, minH: 0, overflowX: "hidden", "data-slot": "new", children: [wide ? _jsx(YStack, {}) : null, _jsx(YStack, { display: "grid",
|
|
434
435
|
// One track, its question set at the track's foot, just above the composer: a
|
|
435
436
|
// second `auto` track left the question alone in the first, at the pane's top.
|
|
436
437
|
gridTemplateRows: "minmax(0, 1fr)", items: "flex-end", width: "100%", maxW: MEASURE, height: wide ? undefined : '100%', pb: wide ? '$5' : '$3', overflowY: "auto", children: _jsx(SizableText, { render: "h1", fontSize: "$7", lineHeight: "$7", fontWeight: "700", color: "$ink", style: { textAlign: 'center' }, children: t('Build what’s next.') }) }), _jsx(YStack, { width: "100%", maxW: MEASURE, gap: "$2", pb: 12, children: _jsxs(YStack, { gap: "$2", children: [env.value && (env.value.state === 'proposed' || unset(env.value)) && !place.id ? (_jsxs(XStack, { items: "center", justify: "space-between", gap: "$3", px: "$3", py: "$2", rounded: "$10", borderWidth: 1, borderColor: "$borderColor", children: [_jsx(SizableText, { size: "$2", color: "$ink", flex: 1, minW: 0, children: env.value.state === 'proposed'
|
|
437
438
|
? t('A proposed environment for {repo} is waiting for review.', { repo: codebase })
|
|
438
|
-
: t('{repo} has no environment yet, so every run starts it bare.', { repo: codebase }) }), env.value.state === 'proposed' && env.value.session ? (_jsx(Button, { size: "sm", variant: "outline", onPress: () => host.go(env.value.session), children: t('Review') })) : (_jsx(Button, { size: "sm", onPress: () => setOffering(true), children: t('Set up environment') }))] })) : null, note || unhonoured(mode, place.id, t) || mind.note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note || unhonoured(mode, place.id, t) || mind.note })) : null, _jsx(Composer, { column: true, value: draft, onChange: setDraft, onSend: () => void send(), busy: busy,
|
|
439
|
+
: t('{repo} has no environment yet, so every run starts it bare.', { repo: codebase }) }), env.value.state === 'proposed' && env.value.session ? (_jsx(Button, { size: "sm", variant: "outline", onPress: () => host.go(env.value.session), children: t('Review') })) : (_jsx(Button, { size: "sm", onPress: () => setOffering(true), children: t('Set up environment') }))] })) : null, note || unhonoured(mode, place.id, t) || mind.note ? (_jsx(SizableText, { size: "$1", color: "$soft", role: "status", children: note || unhonoured(mode, place.id, t) || mind.note })) : null, _jsx(Composer, { column: true, value: draft, onChange: setDraft, onSend: () => void send(), busy: busy, placeholder: t('Ask, build, or run anything…'), label: t('Describe a task or ask a question'), plus: {
|
|
439
440
|
upload: () => pick(files, setFiles, setNote, t),
|
|
440
|
-
|
|
441
|
-
browserTabs: { on: browserTabs, set: setBrowserTabs },
|
|
442
|
-
webSearch: { on: webSearch, set: setWebSearch },
|
|
443
|
-
},
|
|
444
|
-
research: { on: research, set: setResearch },
|
|
441
|
+
research: { on: carry.gear.gear.research, set: (on) => carry.gear.set({ research: on }) },
|
|
445
442
|
skills: carry.skills,
|
|
446
443
|
design: carry.design,
|
|
447
444
|
plugins: carry.plugins,
|
|
448
445
|
devices,
|
|
449
446
|
memory: { on: carry.gear.gear.memory, set: (on) => carry.gear.set({ memory: on }) },
|
|
450
|
-
}, carried: [...carry.on, ...carrying(files, setFiles)], slash: carry.skills, at: carry.plugins, pills: pills, commands: commands, mind: mind, effort: pacing(mind), limits: limits, onUpgrade: () => host.go(path({ kind: 'screen', screen: 'plans' })), voice: voice, language: prefs.language ?? null, onLanguage: (id) => void savePrefs({ language: id }), talk: talk })] }) }), wide ? _jsx(YStack, {}) : null, _jsx(Publish, { source: adding, onClose: () => setAdding(null) }), _jsx(Address, { open: giving, onOpenChange: setGiving, title: t('Use a git URL'), says: t('Runs work on the GitHub repository at this address until you choose another. A private one needs GitHub connected.'), act: t('Use'), address: "", run: async (at) => give(at) }), carry.dialog, codebase ? (_jsx(SetupDialog, { repo: codebase, homes: homes, open: offering, onOpenChange: setOffering, onStart: setup, onRepo: choose, onSaved: () => {
|
|
447
|
+
}, carried: [...carry.on, ...carrying(files, setFiles)], slash: carry.skills, at: carry.plugins, pills: pills, commands: commands, mode: carry.mode, mind: mind, effort: pacing(mind), limits: limits, onUpgrade: () => host.go(path({ kind: 'screen', screen: 'plans' })), voice: voice, language: prefs.language ?? null, onLanguage: (id) => void savePrefs({ language: id }), talk: talk })] }) }), wide ? _jsx(YStack, {}) : null, _jsx(Publish, { source: adding, onClose: () => setAdding(null) }), _jsx(Address, { open: giving, onOpenChange: setGiving, title: t('Use a git URL'), says: t('Runs work on the GitHub repository at this address until you choose another. A private one needs GitHub connected.'), act: t('Use'), address: "", run: async (at) => give(at) }), carry.dialog, codebase ? (_jsx(SetupDialog, { repo: codebase, homes: homes, open: offering, onOpenChange: setOffering, onStart: setup, onRepo: choose, onSaved: () => {
|
|
451
448
|
setOffering(false);
|
|
452
449
|
env.reload();
|
|
453
450
|
} })) : null] })] }), desk && wide ? (_jsx(YStack, { width: 440, shrink: 0, height: "100%", borderLeftWidth: 1, borderColor: "$borderColor", bg: "$background", minW: 0, minH: 0, overflow: "hidden", children: _jsx(Panel, { side: deck, kinds: [], onHide: () => setDesk(false), label: t('Tabs') }) })) : null] }));
|
package/lib/mind.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export interface Choice {
|
|
|
38
38
|
export declare const FIRST: Choice;
|
|
39
39
|
/** Whether a plan grants only Enso Auto. An unknown plan is not taken for Free. */
|
|
40
40
|
export declare const isFree: (plan: string | null | undefined) => boolean;
|
|
41
|
+
/** Whether third-party cloud models are enabled in Settings → Preferences (off by default). */
|
|
42
|
+
export declare function allowThirdPartyModels(): boolean;
|
|
41
43
|
/** The kept choice, Enso and Auto where nothing is kept. Stable while the stored text is. Low and Medium, offered once, read as Auto. */
|
|
42
44
|
export declare function kept(): Choice;
|
|
43
45
|
/** Keep a change, in this browser, for every surface that reads it. */
|
package/lib/mind.js
CHANGED
|
@@ -14,6 +14,31 @@ export const FIRST = { model: ENSO, effort: 'auto' };
|
|
|
14
14
|
export const isFree = (plan) => plan === 'free';
|
|
15
15
|
const KEY = 'hanzo.mind';
|
|
16
16
|
const CHANGE = 'hanzo:mind';
|
|
17
|
+
const PREFS_KEY = 'hanzo.chat.preferences';
|
|
18
|
+
const PREFS_EVENT = 'hanzo:chat:preferences';
|
|
19
|
+
/** Whether third-party cloud models are enabled in Settings → Preferences (off by default). */
|
|
20
|
+
export function allowThirdPartyModels() {
|
|
21
|
+
try {
|
|
22
|
+
const v = JSON.parse(store()?.getItem(PREFS_KEY) ?? 'null');
|
|
23
|
+
return v?.thirdPartyChosen ? Boolean(v.allowThirdPartyModels) : v?.allowThirdPartyModels === true;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function useAllowThirdPartyModels() {
|
|
30
|
+
const [allowed, setAllowed] = useState(allowThirdPartyModels);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const sync = () => setAllowed(allowThirdPartyModels());
|
|
33
|
+
window.addEventListener(PREFS_EVENT, sync);
|
|
34
|
+
window.addEventListener('storage', sync);
|
|
35
|
+
return () => {
|
|
36
|
+
window.removeEventListener(PREFS_EVENT, sync);
|
|
37
|
+
window.removeEventListener('storage', sync);
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
return allowed;
|
|
41
|
+
}
|
|
17
42
|
/** An effort kept, read back: one the ladder still offers, XHigh (which Max replaced) as Max, else Auto. */
|
|
18
43
|
const effortOf = (v) => (v === 'xhigh' ? 'max' : EFFORTS.some((e) => e.id === v) ? v : FIRST.effort);
|
|
19
44
|
/** The store, or null where the browser gives none (a server render, blocked site data). */
|
|
@@ -233,6 +258,7 @@ function settleReturn() {
|
|
|
233
258
|
export function useMind(t, plan, topUp) {
|
|
234
259
|
const [choice, change] = useChoice();
|
|
235
260
|
const { models, list, loading, error, note } = useCatalog(t);
|
|
261
|
+
const allowThirdParty = useAllowThirdPartyModels();
|
|
236
262
|
const free = isFree(plan);
|
|
237
263
|
const [picked, pick] = usePick(choice.model, (id) => change({ model: id }), list);
|
|
238
264
|
// Another maker's model is paid from the balance on any plan; Hanzo's own follow the plan.
|
|
@@ -240,6 +266,7 @@ export function useMind(t, plan, topUp) {
|
|
|
240
266
|
const cents = funds.cents;
|
|
241
267
|
const may = (id) => sendable(free, models, cents, id);
|
|
242
268
|
const model = may(picked) ? picked : ENSO;
|
|
269
|
+
const listed = allowThirdParty ? models : models.filter((m) => !thirdParty(m) || m.id === model);
|
|
243
270
|
// A top-up returns to this address with the model it was for: pick it once the balance can pay.
|
|
244
271
|
const [back] = useState(returned);
|
|
245
272
|
useEffect(() => {
|
|
@@ -254,7 +281,7 @@ export function useMind(t, plan, topUp) {
|
|
|
254
281
|
return {
|
|
255
282
|
model,
|
|
256
283
|
effort: choice.effort,
|
|
257
|
-
models,
|
|
284
|
+
models: listed,
|
|
258
285
|
loading,
|
|
259
286
|
error,
|
|
260
287
|
note,
|
package/lib/project.js
CHANGED
|
@@ -49,12 +49,14 @@ import { Attachments, CHAT, Console, DEVICES, Feedback, FileTabs, FileTree, Page
|
|
|
49
49
|
import { Composer, Message } from '@hanzo/ui/chat';
|
|
50
50
|
import { Button, Dialog, DialogContent, DialogTitle } from '@hanzo/ui';
|
|
51
51
|
import { HanzoMark } from '@hanzo/ui/product';
|
|
52
|
+
import { useLimits } from '@hanzo/ui/product/useLimits';
|
|
52
53
|
import { useDictation, useVoice } from '@hanzo/voice';
|
|
53
54
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
54
55
|
import { read as pushed } from './api/changes.js';
|
|
55
56
|
import { codebases, one } from './api/codebases.js';
|
|
56
57
|
import { start } from './api/coding.js';
|
|
57
58
|
import { blob, tree } from './api/git.js';
|
|
59
|
+
import { limits as readLimits } from './api/models.js';
|
|
58
60
|
import { declare } from './api/platform.js';
|
|
59
61
|
import { address, deployments, name as repoName, ours, templates } from './api/projects.js';
|
|
60
62
|
import { list, message, stop } from './api/sessions.js';
|
|
@@ -206,7 +208,8 @@ export function Project({ at }) {
|
|
|
206
208
|
const [picked, setPicked] = useState([]);
|
|
207
209
|
const [attached, setAttached] = useState([]);
|
|
208
210
|
// The model and effort Chat and New share, and dictation into the ask.
|
|
209
|
-
const
|
|
211
|
+
const { limits } = useLimits(signed ? (signal) => readLimits(target, signal) : null, target);
|
|
212
|
+
const mind = useMind(target, limits?.plan, host.topUp);
|
|
210
213
|
const voice = useVoice({ speech: useEar(target), language: useSpoken(), ...useDictation(draft, setDraft) });
|
|
211
214
|
const [bridge, setBridge] = useState(false);
|
|
212
215
|
const [editing, setEditing] = useState(false);
|
package/lib/run.d.ts
CHANGED