@hanzo/build 0.2.123 → 0.2.125
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/coding.d.ts +7 -1
- package/lib/api/coding.js +33 -6
- package/lib/api/sandbox.d.ts +32 -0
- package/lib/api/sandbox.js +76 -0
- package/lib/api/sessions.d.ts +13 -4
- package/lib/api/sessions.js +58 -20
- package/lib/api/talk.d.ts +4 -0
- package/lib/api/talk.js +11 -1
- package/lib/data.js +18 -3
- package/lib/desk.js +70 -18
- package/lib/landing.js +10 -14
- package/lib/run.js +2 -2
- package/package.json +1 -1
package/lib/api/coding.d.ts
CHANGED
|
@@ -26,6 +26,12 @@ export interface Ask {
|
|
|
26
26
|
effort?: string;
|
|
27
27
|
/** The number of the issue on `repo` this run resolves: its pull request says `Closes #<n>`. */
|
|
28
28
|
issue?: number;
|
|
29
|
+
/** Client-generated idempotency key so retries never duplicate a run. */
|
|
30
|
+
requestId?: string;
|
|
31
|
+
/** Out-of-band instructions (skills, memories) kept separate from `prompt`. */
|
|
32
|
+
instructions?: string;
|
|
33
|
+
/** Explicit alias for `instructions` passed via `-c developer_instructions=...`. */
|
|
34
|
+
developerInstructions?: string;
|
|
29
35
|
}
|
|
30
36
|
export interface Run {
|
|
31
37
|
session: string;
|
|
@@ -48,7 +54,7 @@ export declare function start(t: Target, ask: Ask): Promise<Run>;
|
|
|
48
54
|
* with the words; the follow-up's session arrives on this run's own stream as
|
|
49
55
|
* its `followed` status (turn.ts `followed`).
|
|
50
56
|
*/
|
|
51
|
-
export declare function steer(t: Target, session: string, text: string): Promise<void>;
|
|
57
|
+
export declare function steer(t: Target, session: string, text: string, requestId?: string): Promise<void>;
|
|
52
58
|
/** A run a follow-up continues, as its record states it. */
|
|
53
59
|
export interface Earlier {
|
|
54
60
|
id: string;
|
package/lib/api/coding.js
CHANGED
|
@@ -40,6 +40,14 @@ export const unhonoured = (mode, target, t = english) => !target?.trim()
|
|
|
40
40
|
: mode === 'setup'
|
|
41
41
|
? t('A setup runs in the Hanzo sandbox: a machine clones and pushes with its own credential. Choose Cloud, or switch to Build.')
|
|
42
42
|
: '';
|
|
43
|
+
let reqSeq = 0;
|
|
44
|
+
function newRequestId() {
|
|
45
|
+
const uuid = globalThis.crypto?.randomUUID?.();
|
|
46
|
+
if (uuid)
|
|
47
|
+
return uuid;
|
|
48
|
+
reqSeq += 1;
|
|
49
|
+
return `req_${Date.now().toString(36)}_${reqSeq.toString(36)}`;
|
|
50
|
+
}
|
|
43
51
|
/**
|
|
44
52
|
* The request body: only what was asked, with no empty strings sent as values.
|
|
45
53
|
* A run in the sandbox asks for one with a desktop, so its Desktop tab has a
|
|
@@ -47,7 +55,19 @@ export const unhonoured = (mode, target, t = english) => !target?.trim()
|
|
|
47
55
|
*/
|
|
48
56
|
export function body(ask) {
|
|
49
57
|
const out = { prompt: ask.prompt.trim() };
|
|
50
|
-
for (const k of [
|
|
58
|
+
for (const k of [
|
|
59
|
+
'repo',
|
|
60
|
+
'base',
|
|
61
|
+
'targetId',
|
|
62
|
+
'project',
|
|
63
|
+
'after',
|
|
64
|
+
'mode',
|
|
65
|
+
'model',
|
|
66
|
+
'effort',
|
|
67
|
+
'requestId',
|
|
68
|
+
'instructions',
|
|
69
|
+
'developerInstructions',
|
|
70
|
+
]) {
|
|
51
71
|
const v = ask[k]?.trim();
|
|
52
72
|
if (v)
|
|
53
73
|
out[k] = v;
|
|
@@ -64,7 +84,7 @@ export async function start(t, ask) {
|
|
|
64
84
|
const why = unhonoured(ask.mode, ask.targetId);
|
|
65
85
|
if (why)
|
|
66
86
|
throw new Refusal(400, why);
|
|
67
|
-
const r = await call(t, 'POST', '/v1/agent/coding', body(ask));
|
|
87
|
+
const r = await call(t, 'POST', '/v1/agent/coding', body({ ...ask, requestId: ask.requestId?.trim() || newRequestId() }));
|
|
68
88
|
const s = (k) => (typeof r?.[k] === 'string' ? r[k] : '');
|
|
69
89
|
if (!s('sessionId'))
|
|
70
90
|
throw new Refusal(502, phrase('The run was admitted but named no session'));
|
|
@@ -83,11 +103,14 @@ export async function start(t, ask) {
|
|
|
83
103
|
* with the words; the follow-up's session arrives on this run's own stream as
|
|
84
104
|
* its `followed` status (turn.ts `followed`).
|
|
85
105
|
*/
|
|
86
|
-
export async function steer(t, session, text) {
|
|
106
|
+
export async function steer(t, session, text, requestId) {
|
|
87
107
|
const words = text.trim();
|
|
88
108
|
if (!words)
|
|
89
109
|
throw new Refusal(400, phrase('Say something to the run'));
|
|
90
|
-
await call(t, 'POST', `/v1/agent/coding/${seg(session)}/steer`, {
|
|
110
|
+
await call(t, 'POST', `/v1/agent/coding/${seg(session)}/steer`, {
|
|
111
|
+
text: words,
|
|
112
|
+
requestId: requestId?.trim() || newRequestId(),
|
|
113
|
+
});
|
|
91
114
|
}
|
|
92
115
|
/**
|
|
93
116
|
* The earlier run's ask, without the codebase its title leads with (`universe:
|
|
@@ -127,10 +150,14 @@ const modeOf = (m) => (m === 'plan' || m === 'setup' ? m : 'build');
|
|
|
127
150
|
* when it carries a paused run on (apps/coding steer.go followUp).
|
|
128
151
|
*/
|
|
129
152
|
export function followUp(e, said) {
|
|
153
|
+
const next = from(e);
|
|
130
154
|
const head = headline(e.title, e.repo);
|
|
131
155
|
const words = said.trim();
|
|
132
156
|
let prompt;
|
|
133
|
-
if (
|
|
157
|
+
if (next.after) {
|
|
158
|
+
prompt = words || 'Continue where the earlier run left off.';
|
|
159
|
+
}
|
|
160
|
+
else if (words) {
|
|
134
161
|
const was = head ? `This follows an earlier run on this codebase: “${head}”.` : 'This follows an earlier run on this codebase.';
|
|
135
162
|
prompt = `${words}\n\n${was}${e.pushed ? ' Its work so far is on this branch; build on it.' : ''}`;
|
|
136
163
|
}
|
|
@@ -138,7 +165,7 @@ export function followUp(e, said) {
|
|
|
138
165
|
const kept = e.pushed ? 'An earlier run already worked on this; its work so far is on this branch. Build on it. ' : '';
|
|
139
166
|
prompt = `${head}\n\n${kept}Continue where the earlier run left off.`.trim();
|
|
140
167
|
}
|
|
141
|
-
return { ...
|
|
168
|
+
return { ...next, prompt, mode: modeOf(e.mode) };
|
|
142
169
|
}
|
|
143
170
|
/** A build of what a plan run answered: its ask as the title, and the plan to carry out. */
|
|
144
171
|
export function approve(e, plan) {
|
package/lib/api/sandbox.d.ts
CHANGED
|
@@ -31,6 +31,38 @@ export declare function ports(t: Target, id: string): Promise<Port[]>;
|
|
|
31
31
|
* ticket that sets the preview's cookie and lands on its root.
|
|
32
32
|
*/
|
|
33
33
|
export declare function preview(t: Target, id: string, port: number): Promise<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Where a server started from the Preview keeps its process group and its output:
|
|
36
|
+
* under /tmp, as a run keeps its own files out of the checkout it commits.
|
|
37
|
+
*/
|
|
38
|
+
export declare const SERVE_DIR = "/tmp/hanzo-preview";
|
|
39
|
+
/**
|
|
40
|
+
* The shell that starts the app's server for the Preview, detached in a session of
|
|
41
|
+
* its own so it outlives the one command that started it. A server a run starts
|
|
42
|
+
* ends with the run (the agent's harness takes it down), so the Preview starts one
|
|
43
|
+
* again. It runs the codebase's start command when its environment names one ($1),
|
|
44
|
+
* else the package's `dev` script, or `start`, by the package manager its lockfile
|
|
45
|
+
* names, with the environment's secrets sourced as a run sources them (cloud
|
|
46
|
+
* apps/coding envPath). A server this started before is stopped first, its whole
|
|
47
|
+
* group. It prints what it started, or exits 3 saying why nothing could be.
|
|
48
|
+
*/
|
|
49
|
+
export declare const SERVE: string;
|
|
50
|
+
/** Whether the server the Preview started still runs (`up` or `down`), then its output's last lines. */
|
|
51
|
+
export declare const SERVED: string;
|
|
52
|
+
/**
|
|
53
|
+
* Start the app's server in the sandbox, detached, and answer the command it runs:
|
|
54
|
+
* `start` when the codebase's environment names one, else its package's dev script.
|
|
55
|
+
* A parked sandbox is resumed first.
|
|
56
|
+
*/
|
|
57
|
+
export declare function serve(t: Target, id: string, start?: string): Promise<string>;
|
|
58
|
+
export interface Served {
|
|
59
|
+
/** Whether the server the Preview started still runs. */
|
|
60
|
+
up: boolean;
|
|
61
|
+
/** The last lines it wrote. */
|
|
62
|
+
log: string;
|
|
63
|
+
}
|
|
64
|
+
/** Whether the server the Preview started still runs, and what it last wrote. */
|
|
65
|
+
export declare function served(t: Target, id: string): Promise<Served>;
|
|
34
66
|
export interface Node {
|
|
35
67
|
/** The resolved path inside the sandbox. */
|
|
36
68
|
path: string;
|
package/lib/api/sandbox.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* POST /v1/sandbox/{id}/{screen|terminal}/ticket one ticket, spent when the page's socket opens (30 s)
|
|
11
11
|
* GET /v1/sandbox/{id}/ports what listens in it, each with its preview host
|
|
12
12
|
* POST /v1/sandbox/{id}/preview {port} an address that opens that port in a browser
|
|
13
|
+
* POST /v1/sandbox/{id}/exec {argv, timeoutSec} one command in /work: {exitCode, stdout, stderr}
|
|
13
14
|
* POST /v1/sandbox/read {id, path} a directory's names, or a file's bytes
|
|
14
15
|
*
|
|
15
16
|
* A door or a preview asked of a sandbox that stopped as it was asked is 409: it
|
|
@@ -111,6 +112,81 @@ export async function preview(t, id, port) {
|
|
|
111
112
|
throw new Refusal(502, phrase('The sandbox answered with no address to open'));
|
|
112
113
|
return url.href;
|
|
113
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Where a server started from the Preview keeps its process group and its output:
|
|
117
|
+
* under /tmp, as a run keeps its own files out of the checkout it commits.
|
|
118
|
+
*/
|
|
119
|
+
export const SERVE_DIR = '/tmp/hanzo-preview';
|
|
120
|
+
/**
|
|
121
|
+
* The shell that starts the app's server for the Preview, detached in a session of
|
|
122
|
+
* its own so it outlives the one command that started it. A server a run starts
|
|
123
|
+
* ends with the run (the agent's harness takes it down), so the Preview starts one
|
|
124
|
+
* again. It runs the codebase's start command when its environment names one ($1),
|
|
125
|
+
* else the package's `dev` script, or `start`, by the package manager its lockfile
|
|
126
|
+
* names, with the environment's secrets sourced as a run sources them (cloud
|
|
127
|
+
* apps/coding envPath). A server this started before is stopped first, its whole
|
|
128
|
+
* group. It prints what it started, or exits 3 saying why nothing could be.
|
|
129
|
+
*/
|
|
130
|
+
export const SERVE = [
|
|
131
|
+
`d=${SERVE_DIR}`,
|
|
132
|
+
'mkdir -p "$d"',
|
|
133
|
+
'if [ -f /tmp/hanzo-run/env ]; then . /tmp/hanzo-run/env; fi',
|
|
134
|
+
'cmd=$1',
|
|
135
|
+
'if [ -z "$cmd" ]; then',
|
|
136
|
+
' [ -f package.json ] || { echo no-package; exit 3; }',
|
|
137
|
+
' if [ -f pnpm-lock.yaml ]; then pm=pnpm; elif [ -f yarn.lock ]; then pm=yarn; elif [ -f bun.lock ] || [ -f bun.lockb ]; then pm=bun; else pm=npm; fi',
|
|
138
|
+
` run=$(node -e 'const s=require("./package.json").scripts||{};process.stdout.write(s.dev?"dev":s.start?"start":"")' 2>/dev/null)`,
|
|
139
|
+
' [ -n "$run" ] || { echo no-script; exit 3; }',
|
|
140
|
+
' cmd="$pm run $run"',
|
|
141
|
+
'fi',
|
|
142
|
+
'old=$(cat "$d/pid" 2>/dev/null)',
|
|
143
|
+
'if [ -n "$old" ] && kill -0 "$old" 2>/dev/null; then kill -TERM "-$old" 2>/dev/null || kill -TERM "$old" 2>/dev/null; sleep 1; fi',
|
|
144
|
+
'if command -v setsid >/dev/null 2>&1; then setsid nohup sh -c "$cmd" </dev/null >"$d/log" 2>&1 & else nohup sh -c "$cmd" </dev/null >"$d/log" 2>&1 & fi',
|
|
145
|
+
'echo $! >"$d/pid"',
|
|
146
|
+
'printf %s "$cmd"',
|
|
147
|
+
].join('\n');
|
|
148
|
+
/** Whether the server the Preview started still runs (`up` or `down`), then its output's last lines. */
|
|
149
|
+
export const SERVED = [
|
|
150
|
+
`d=${SERVE_DIR}`,
|
|
151
|
+
'p=$(cat "$d/pid" 2>/dev/null)',
|
|
152
|
+
'if [ -n "$p" ] && kill -0 "$p" 2>/dev/null; then echo up; else echo down; fi',
|
|
153
|
+
'tail -n 40 "$d/log" 2>/dev/null',
|
|
154
|
+
].join('\n');
|
|
155
|
+
/** Why there was nothing to start, as SERVE says it. */
|
|
156
|
+
const UNSTARTED = {
|
|
157
|
+
'no-package': phrase('This checkout has no package.json to start. Set a start command in its Environment.'),
|
|
158
|
+
'no-script': phrase('Its package.json has no dev or start script. Set a start command in its Environment.'),
|
|
159
|
+
};
|
|
160
|
+
/** One command in the sandbox, as an argument vector: its exit code and output. A failed command is an answer, not a refusal. */
|
|
161
|
+
async function exec(t, id, argv, timeoutSec) {
|
|
162
|
+
const r = (await call(t, 'POST', `/v1/sandbox/${seg(id)}/exec`, { argv, timeoutSec })) ?? {};
|
|
163
|
+
return {
|
|
164
|
+
code: typeof r.exitCode === 'number' ? r.exitCode : -1,
|
|
165
|
+
out: typeof r.stdout === 'string' ? r.stdout : '',
|
|
166
|
+
err: typeof r.stderr === 'string' ? r.stderr : '',
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Start the app's server in the sandbox, detached, and answer the command it runs:
|
|
171
|
+
* `start` when the codebase's environment names one, else its package's dev script.
|
|
172
|
+
* A parked sandbox is resumed first.
|
|
173
|
+
*/
|
|
174
|
+
export async function serve(t, id, start = '') {
|
|
175
|
+
const r = await running(t, id, () => exec(t, id, ['sh', '-c', SERVE, 'sh', start.trim()], 30));
|
|
176
|
+
const said = r.out.trim();
|
|
177
|
+
if (r.code === 0 && said)
|
|
178
|
+
return said;
|
|
179
|
+
const why = UNSTARTED[said];
|
|
180
|
+
if (r.code === 3 && why)
|
|
181
|
+
throw new Refusal(422, why);
|
|
182
|
+
throw new Refusal(502, r.err.trim().split('\n').pop() || phrase('The dev server could not be started.'));
|
|
183
|
+
}
|
|
184
|
+
/** Whether the server the Preview started still runs, and what it last wrote. */
|
|
185
|
+
export async function served(t, id) {
|
|
186
|
+
const r = await exec(t, id, ['sh', '-c', SERVED], 10);
|
|
187
|
+
const [first = '', ...rest] = r.out.split('\n');
|
|
188
|
+
return { up: first.trim() === 'up', log: rest.join('\n').trimEnd() };
|
|
189
|
+
}
|
|
114
190
|
/** What a file shows at most. */
|
|
115
191
|
const CAP = 1 << 20;
|
|
116
192
|
/** One path in the sandbox, relative to its working directory. */
|
package/lib/api/sessions.d.ts
CHANGED
|
@@ -75,7 +75,11 @@ export interface Page {
|
|
|
75
75
|
}
|
|
76
76
|
export declare function page(t: Target, q?: ListQuery): Promise<Page>;
|
|
77
77
|
export declare function list(t: Target, q?: ListQuery): Promise<Session[]>;
|
|
78
|
-
export
|
|
78
|
+
export interface GetOptions {
|
|
79
|
+
limit?: number;
|
|
80
|
+
after?: number;
|
|
81
|
+
}
|
|
82
|
+
export declare function get(t: Target, id: string, opts?: GetOptions): Promise<Detail>;
|
|
79
83
|
/**
|
|
80
84
|
* A session's whole log, oldest first, read a page at a time — what a conversation
|
|
81
85
|
* draws from its first word, where the detail carries only the latest fifty.
|
|
@@ -101,8 +105,13 @@ export interface Watch {
|
|
|
101
105
|
/** Each (re)connect. The first is 0; a later one means frames may have been missed. */
|
|
102
106
|
open?: (attempt: number) => void;
|
|
103
107
|
}
|
|
108
|
+
export interface WatchOptions {
|
|
109
|
+
/** Resume replaying missed events strictly after this sequence number. */
|
|
110
|
+
after?: number;
|
|
111
|
+
}
|
|
104
112
|
/**
|
|
105
|
-
* Follow one run's tree until `signal` aborts. Reconnects with a capped backoff
|
|
106
|
-
*
|
|
113
|
+
* Follow one run's tree until `signal` aborts. Reconnects with a capped backoff
|
|
114
|
+
* and replays missed frames via `?after=<lastSeq>` + `Last-Event-ID`; a refusal
|
|
115
|
+
* (401/403) ends it, because retrying a no is not recovery.
|
|
107
116
|
*/
|
|
108
|
-
export declare function watch(t: Target, root: string, on: Watch, signal: AbortSignal): Promise<void>;
|
|
117
|
+
export declare function watch(t: Target, root: string, on: Watch, signal: AbortSignal, opts?: WatchOptions): Promise<void>;
|
package/lib/api/sessions.js
CHANGED
|
@@ -89,21 +89,45 @@ export async function page(t, q = {}) {
|
|
|
89
89
|
export async function list(t, q = {}) {
|
|
90
90
|
return (await page(t, q)).sessions;
|
|
91
91
|
}
|
|
92
|
-
export async function get(t, id) {
|
|
93
|
-
const raw = obj(await call(t, 'GET', `/v1/agent/sessions/${seg(id)}`));
|
|
92
|
+
export async function get(t, id, opts) {
|
|
93
|
+
const raw = obj(await call(t, 'GET', `/v1/agent/sessions/${seg(id)}${query({ limit: opts?.limit, after: opts?.after })}`));
|
|
94
94
|
let recent = (Array.isArray(raw.recentEvents) ? raw.recentEvents : []).map(event);
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
95
|
+
// When `limit` is explicitly requested (e.g. Run's initial 500-event load) and a
|
|
96
|
+
// long coding run still exceeds one page (`recent[0].seq > 1`), page forward from
|
|
97
|
+
// seq 0 so middle history is never dropped. Without `opts`, keep the lightweight
|
|
98
|
+
// 2-event head fetch so short summary callers stay single-hop.
|
|
99
|
+
if (recent.length > 0 && recent[0].seq > 1 && opts?.after === undefined) {
|
|
100
|
+
const tailFloor = recent[0].seq;
|
|
101
|
+
if (opts?.limit && opts.limit > 50) {
|
|
102
|
+
try {
|
|
103
|
+
const earlier = [];
|
|
104
|
+
let cursor = 0;
|
|
105
|
+
for (let page = 0; page < 6 && cursor < tailFloor - 1; page++) {
|
|
106
|
+
const chunk = obj(await call(t, 'GET', `/v1/agent/sessions/${seg(id)}/events${query({ after: cursor || undefined, limit: Math.min(1000, opts.limit) })}`));
|
|
107
|
+
const rows = (Array.isArray(chunk.events) ? chunk.events : []).map(event);
|
|
108
|
+
earlier.push(...rows.filter((e) => e.seq > 0 && e.seq < tailFloor));
|
|
109
|
+
const next = num(chunk.next);
|
|
110
|
+
if (next <= cursor || next >= tailFloor - 1)
|
|
111
|
+
break;
|
|
112
|
+
cursor = next;
|
|
113
|
+
}
|
|
114
|
+
const have = new Set(recent.map((e) => e.seq));
|
|
115
|
+
recent = [...earlier.filter((e) => !have.has(e.seq)), ...recent].sort((a, b) => a.seq - b.seq);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
/* keep the tail */
|
|
119
|
+
}
|
|
104
120
|
}
|
|
105
|
-
|
|
106
|
-
|
|
121
|
+
else {
|
|
122
|
+
try {
|
|
123
|
+
const head = obj(await call(t, 'GET', `/v1/agent/sessions/${seg(id)}/events?limit=2`));
|
|
124
|
+
const first = (Array.isArray(head.events) ? head.events : []).map(event);
|
|
125
|
+
const have = new Set(recent.map((e) => e.seq));
|
|
126
|
+
recent = [...first.filter((e) => e.seq > 0 && !have.has(e.seq)), ...recent].sort((a, b) => a.seq - b.seq);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
/* keep the tail */
|
|
130
|
+
}
|
|
107
131
|
}
|
|
108
132
|
}
|
|
109
133
|
return {
|
|
@@ -162,16 +186,21 @@ export async function publish(t, id, on) {
|
|
|
162
186
|
/** Where anyone can read a published run's story: the public build route, by org and project. '' without both. */
|
|
163
187
|
export const story = (t, org, project) => org && project ? `${t.api}/v1/agent/builds/${seg(org)}/${seg(project)}` : '';
|
|
164
188
|
/**
|
|
165
|
-
* Follow one run's tree until `signal` aborts. Reconnects with a capped backoff
|
|
166
|
-
*
|
|
189
|
+
* Follow one run's tree until `signal` aborts. Reconnects with a capped backoff
|
|
190
|
+
* and replays missed frames via `?after=<lastSeq>` + `Last-Event-ID`; a refusal
|
|
191
|
+
* (401/403) ends it, because retrying a no is not recovery.
|
|
167
192
|
*/
|
|
168
|
-
export async function watch(t, root, on, signal) {
|
|
193
|
+
export async function watch(t, root, on, signal, opts) {
|
|
169
194
|
let opened = 0;
|
|
170
195
|
let fails = 0;
|
|
196
|
+
let lastSeq = opts?.after && Number.isFinite(opts.after) && opts.after > 0 ? Math.floor(opts.after) : 0;
|
|
171
197
|
while (!signal.aborted) {
|
|
172
198
|
try {
|
|
173
|
-
const
|
|
174
|
-
|
|
199
|
+
const extra = { Accept: 'text/event-stream' };
|
|
200
|
+
if (lastSeq > 0)
|
|
201
|
+
extra['Last-Event-ID'] = String(lastSeq);
|
|
202
|
+
const res = await fetch(`${t.api}/v1/agent/sessions/stream${query({ root, after: lastSeq > 0 ? lastSeq : undefined })}`, {
|
|
203
|
+
headers: headers(t, extra),
|
|
175
204
|
cache: 'no-store',
|
|
176
205
|
signal,
|
|
177
206
|
});
|
|
@@ -191,8 +220,17 @@ export async function watch(t, root, on, signal) {
|
|
|
191
220
|
}
|
|
192
221
|
if (f.event === 'session')
|
|
193
222
|
on.session?.(session(obj(data).session));
|
|
194
|
-
else if (f.event === 'event')
|
|
195
|
-
|
|
223
|
+
else if (f.event === 'event') {
|
|
224
|
+
const ev = event(obj(data).event);
|
|
225
|
+
if (!root || !ev.sessionId || ev.sessionId === root) {
|
|
226
|
+
const fid = Number(f.id);
|
|
227
|
+
if (Number.isInteger(fid) && fid > lastSeq)
|
|
228
|
+
lastSeq = fid;
|
|
229
|
+
if (ev.seq > lastSeq)
|
|
230
|
+
lastSeq = ev.seq;
|
|
231
|
+
}
|
|
232
|
+
on.event?.(ev);
|
|
233
|
+
}
|
|
196
234
|
}, signal);
|
|
197
235
|
}
|
|
198
236
|
catch (e) {
|
package/lib/api/talk.d.ts
CHANGED
|
@@ -27,6 +27,10 @@ export interface Say {
|
|
|
27
27
|
effort?: string;
|
|
28
28
|
/** The issue on `repo` a coding run resolves. */
|
|
29
29
|
issue?: number;
|
|
30
|
+
/** Out-of-band instructions (skills, memories) kept separate from `input`. */
|
|
31
|
+
instructions?: string;
|
|
32
|
+
/** Explicit alias for `instructions` forwarded to turns and coding runs. */
|
|
33
|
+
developerInstructions?: string;
|
|
30
34
|
}
|
|
31
35
|
export interface Said {
|
|
32
36
|
/** The conversation: the same id on every turn. */
|
package/lib/api/talk.js
CHANGED
|
@@ -34,7 +34,17 @@ export const talks = (s) => s?.channel === TALK && !s.parent;
|
|
|
34
34
|
/** The request body: only what was said, with no empty values sent. */
|
|
35
35
|
export function body(s) {
|
|
36
36
|
const out = { input: s.input.trim() };
|
|
37
|
-
for (const k of [
|
|
37
|
+
for (const k of [
|
|
38
|
+
'session',
|
|
39
|
+
'model',
|
|
40
|
+
'effort',
|
|
41
|
+
'repo',
|
|
42
|
+
'base',
|
|
43
|
+
'target',
|
|
44
|
+
'mode',
|
|
45
|
+
'instructions',
|
|
46
|
+
'developerInstructions',
|
|
47
|
+
]) {
|
|
38
48
|
const v = s[k]?.trim();
|
|
39
49
|
if (v)
|
|
40
50
|
out[k] = v;
|
package/lib/data.js
CHANGED
|
@@ -223,12 +223,24 @@ export function useKept(key, initial) {
|
|
|
223
223
|
* the record. `id` null reads nothing.
|
|
224
224
|
*/
|
|
225
225
|
export function useRun(t, id) {
|
|
226
|
-
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]);
|
|
227
227
|
const [live, setLive] = useState([]);
|
|
228
228
|
const [pushed, setPushed] = useState(null);
|
|
229
229
|
const [refused, setRefused] = useState('');
|
|
230
230
|
const reload = useRef(detail.reload);
|
|
231
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
|
+
}
|
|
232
244
|
// The stream is followed by the run's tree: a conversation's coding run is in the
|
|
233
245
|
// conversation's (talk.ts), and its frames carry that root.
|
|
234
246
|
const root = (detail.value?.id === id && detail.value.root) || id;
|
|
@@ -242,8 +254,11 @@ export function useRun(t, id) {
|
|
|
242
254
|
void watch(t, root, {
|
|
243
255
|
// A frame from a stream this run has already left is not this run's.
|
|
244
256
|
event: (e) => {
|
|
245
|
-
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;
|
|
246
260
|
setLive((prev) => [...prev, e]);
|
|
261
|
+
}
|
|
247
262
|
},
|
|
248
263
|
session: (s) => {
|
|
249
264
|
if (!ctl.signal.aborted && s.id === id)
|
|
@@ -255,7 +270,7 @@ export function useRun(t, id) {
|
|
|
255
270
|
if (n > 0 || root !== id)
|
|
256
271
|
reload.current();
|
|
257
272
|
},
|
|
258
|
-
}, ctl.signal).catch((e) => setRefused(e.message));
|
|
273
|
+
}, ctl.signal, { after: root === id ? highestSeq.current : 0 }).catch((e) => setRefused(e.message));
|
|
259
274
|
return () => ctl.abort();
|
|
260
275
|
}, [t, id, root]);
|
|
261
276
|
// The read and the frames describe THIS run or nothing: a read kept from the
|
package/lib/desk.js
CHANGED
|
@@ -15,11 +15,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
15
15
|
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
16
16
|
import { useI18n } from '@hanzo/i18n/react';
|
|
17
17
|
import { ChevronRight, ExternalLink, Folder, GitBranch, GitPullRequest, Globe, Info, Laptop, Maximize2, MoreHorizontal, RefreshCcw, Square, SquareTerminal, X } from '@hanzogui/lucide-icons-2';
|
|
18
|
-
import { Button, DropdownMenu,
|
|
18
|
+
import { Button, DropdownMenu, Switch } from '@hanzo/ui';
|
|
19
19
|
import { PreviewFrame } from '@hanzo/ui/agents';
|
|
20
20
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
21
21
|
import { read as readChanges } from './api/changes.js';
|
|
22
|
-
import {
|
|
22
|
+
import { read as readEnvironment } from './api/environment.js';
|
|
23
|
+
import { park, ports as listening, preview, sandbox as look, serve, served, wake } from './api/sandbox.js';
|
|
23
24
|
import { cards, failure, shell, steps } from './api/turn.js';
|
|
24
25
|
import { useKept, useRead } from './data.js';
|
|
25
26
|
import { Door } from './door.js';
|
|
@@ -53,7 +54,12 @@ export function Desk({ id, repo, branch, base, environment, mode, pr, title, pro
|
|
|
53
54
|
const held = box.value?.state ?? '';
|
|
54
55
|
const environ = () => side.open({ kind: 'environment', title: say('Environment') });
|
|
55
56
|
const kinds = [
|
|
56
|
-
{
|
|
57
|
+
{
|
|
58
|
+
id: 'preview',
|
|
59
|
+
label: say('Preview'),
|
|
60
|
+
bleed: true,
|
|
61
|
+
render: () => _jsx(Browser, { sandbox: sandbox, held: held, site: site, live: live, repo: repo, onEnvironment: environ }, published),
|
|
62
|
+
},
|
|
57
63
|
{
|
|
58
64
|
id: 'artifacts',
|
|
59
65
|
label: say('Artifacts'),
|
|
@@ -176,7 +182,7 @@ const SAYS = {
|
|
|
176
182
|
* looking. A preview that lost its sandbox (409) is opened again, at most twice
|
|
177
183
|
* in a while; any other status is said, and Retry is the person's.
|
|
178
184
|
*/
|
|
179
|
-
function Browser({ sandbox, held, site, live }) {
|
|
185
|
+
function Browser({ sandbox, held, site, live, repo, onEnvironment, }) {
|
|
180
186
|
const { t: say } = useI18n();
|
|
181
187
|
const t = useTarget();
|
|
182
188
|
const [open, setOpen] = useState([]);
|
|
@@ -184,9 +190,14 @@ function Browser({ sandbox, held, site, live }) {
|
|
|
184
190
|
const [src, setSrc] = useState('');
|
|
185
191
|
const [why, setWhy] = useState('');
|
|
186
192
|
const [attempt, setAttempt] = useState(0);
|
|
193
|
+
const [serving, setServing] = useState(null);
|
|
187
194
|
const reopened = useRef([]);
|
|
188
195
|
const frame = useRef(null);
|
|
189
196
|
const running = Boolean(sandbox) && held === 'running';
|
|
197
|
+
// A server the run started ended with the run, so once it has, the person can
|
|
198
|
+
// start one again here, in the sandbox kept for its previews — a suspended one
|
|
199
|
+
// is resumed for it. While the run works, its server is the agent's to start.
|
|
200
|
+
const startable = Boolean(sandbox) && !live && (held === 'running' || held === 'parked');
|
|
190
201
|
// What listens, read again while the sandbox runs: a dev server appears once it listens.
|
|
191
202
|
useEffect(() => {
|
|
192
203
|
if (!running) {
|
|
@@ -246,34 +257,75 @@ function Browser({ sandbox, held, site, live }) {
|
|
|
246
257
|
return () => window.removeEventListener('message', hear);
|
|
247
258
|
}, [src, port, say]);
|
|
248
259
|
const tab = () => away(preview(t, sandbox, port)).catch((e) => setWhy(e.message));
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
260
|
+
/**
|
|
261
|
+
* Start the app's server: the codebase's start command when its environment
|
|
262
|
+
* names one, else its package's dev script. The page opens once it listens,
|
|
263
|
+
* because what listens is read every few seconds anyway.
|
|
264
|
+
*/
|
|
265
|
+
const start = async () => {
|
|
266
|
+
setServing({ command: '', up: true, log: '', why: '' });
|
|
267
|
+
try {
|
|
268
|
+
const named = repo ? await readEnvironment(t, repo).then((e) => e.start, () => '') : '';
|
|
269
|
+
setServing({ command: await serve(t, sandbox, named), up: true, log: '', why: '' });
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
setServing({ command: '', up: false, log: '', why: e.message });
|
|
273
|
+
}
|
|
256
274
|
};
|
|
275
|
+
// While a server started here comes up, whether it is still running and what it
|
|
276
|
+
// says; one that exits says why. Read for a while, never for as long as the page is open.
|
|
277
|
+
const coming = Boolean(serving?.command && serving.up && !port);
|
|
278
|
+
useEffect(() => {
|
|
279
|
+
if (!coming)
|
|
280
|
+
return;
|
|
281
|
+
let gone = false;
|
|
282
|
+
const until = Date.now() + WATCH;
|
|
283
|
+
const check = () => {
|
|
284
|
+
if (Date.now() > until) {
|
|
285
|
+
clearInterval(every);
|
|
286
|
+
setServing((v) => v && { ...v, why: say('It is running, and nothing listens on a port yet.') });
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
served(t, sandbox).then((s) => {
|
|
290
|
+
if (gone)
|
|
291
|
+
return;
|
|
292
|
+
setServing((v) => v && { ...v, up: s.up, log: s.log, why: s.up ? '' : say('The dev server stopped.') });
|
|
293
|
+
}, () => undefined);
|
|
294
|
+
};
|
|
295
|
+
const every = setInterval(check, WATCHING);
|
|
296
|
+
return () => {
|
|
297
|
+
gone = true;
|
|
298
|
+
clearInterval(every);
|
|
299
|
+
};
|
|
300
|
+
}, [t, sandbox, coming, say]);
|
|
301
|
+
const nothing = _jsx(Site, { site: site, live: live, held: held, serving: serving, onStart: startable ? () => void start() : undefined, onEnvironment: repo ? onEnvironment : undefined });
|
|
257
302
|
if (!running)
|
|
258
|
-
return
|
|
303
|
+
return nothing;
|
|
259
304
|
if (!port)
|
|
260
|
-
return
|
|
305
|
+
return nothing;
|
|
261
306
|
const host = open.find((p) => p.port === port)?.host ?? '';
|
|
262
307
|
return (_jsxs(YStack, { flex: 1, minH: 0, children: [_jsxs(XStack, { px: "$2", py: "$1.5", gap: "$1.5", items: "center", borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(XStack, { render: "button", "aria-label": say('Reload the page'), onPress: () => setAttempt((a) => a + 1), p: "$1.5", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(RefreshCcw, { size: 14 }) }), open.length > 1 ? (_jsx(XStack, { gap: "$1", children: open.map((p) => (_jsx(XStack, { render: "button", "aria-label": say('Port {port}', { port: p.port }), onPress: () => setPort(p.port), px: "$2", py: "$1", rounded: "$2", bg: p.port === port ? '$hover' : 'transparent', children: _jsx(SizableText, { size: "$1", color: p.port === port ? '$ink' : '$soft', children: String(p.port) }) }, p.port))) })) : null, _jsx(SizableText, { flex: 1, minW: 0, size: "$1", color: "$soft", numberOfLines: 1, style: mono, children: host || say('port {port}', { port }) }), _jsx(XStack, { render: "button", "aria-label": say('Open in a new tab'), onPress: () => void tab(), p: "$1.5", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(ExternalLink, { size: 14 }) })] }), why ? (_jsxs(YStack, { flex: 1, items: "center", justify: "center", gap: "$2", p: "$6", children: [_jsx(SizableText, { size: "$2", color: "$soft", style: { textAlign: 'center' }, children: why }), _jsxs(XStack, { gap: "$2", children: [_jsx(Button, { size: "sm", variant: "outline", onPress: () => setAttempt((a) => a + 1), children: say('Retry') }), _jsx(Button, { size: "sm", variant: "outline", onPress: () => void tab(), children: say('Open in a new tab') })] })] })) : src ? (_jsx("iframe", { ref: frame, src: src, title: say('What the run serves on port {port}', { port }), sandbox: "allow-scripts allow-same-origin allow-forms allow-popups", style: { border: 0, width: '100%', height: '100%', display: 'block', background: '#fff' } })) : (_jsx(YStack, { flex: 1, items: "center", justify: "center", children: _jsx(SizableText, { size: "$2", color: "$soft", children: say('Opening port {port}…', { port }) }) }))] }));
|
|
263
308
|
}
|
|
309
|
+
/** How long, and how often, a server started here is watched while it comes up. */
|
|
310
|
+
const WATCH = 120_000;
|
|
311
|
+
const WATCHING = 3_000;
|
|
264
312
|
/**
|
|
265
313
|
* Where the run published its work, framed, with its address, a reload and the
|
|
266
|
-
* page in a tab of its own; or what keeps its sandbox from serving
|
|
314
|
+
* page in a tab of its own; or what keeps its sandbox from serving, and the
|
|
315
|
+
* server the person can start in it.
|
|
267
316
|
*/
|
|
268
|
-
function Site({ site, live, held,
|
|
317
|
+
function Site({ site, live, held, serving, onStart, onEnvironment, }) {
|
|
269
318
|
const { t } = useI18n();
|
|
270
319
|
const frame = useRef(null);
|
|
271
|
-
|
|
272
|
-
return (_jsxs(YStack, { flex: 1, minH: 0, children: [_jsxs(XStack, { px: "$2", py: "$1.5", gap: "$1.5", items: "center", borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(XStack, { render: "button", "aria-label": t('Reload the page'), onPress: () => frame.current?.reload(), p: "$1.5", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(RefreshCcw, { size: 14 }) }), _jsx(SizableText, { flex: 1, minW: 0, size: "$1", color: "$soft", numberOfLines: 1, style: mono, children: site || t('Nothing is serving yet') }), _jsx(Input, { unstyled: true, value: urlInput, onChangeText: setUrlInput, placeholder: t('Type a URL'), "aria-label": t('Type a URL'), style: { width: 120, fontSize: 12, outlineStyle: 'none', background: 'transparent' } }), site ? (_jsx(Out, { href: site, label: t('Open in a new tab'), children: _jsx(XStack, { p: "$1.5", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(ExternalLink, { size: 14 }) }) })) : null] }), _jsx(PreviewFrame, { ref: frame, src: site, title: t('Where this run is published'), device: "desktop", empty: _jsxs(YStack, { items: "center", gap: "$2.5", p: "$6", children: [_jsx(Globe, { size: 28, opacity: 0.45 }), _jsx(SizableText, { size: "$3", color: "$ink", children: t('Nothing is serving yet') }), _jsx(SizableText, { size: "$2", color: "$soft", style: { textAlign: 'center', maxWidth: 280 }, children: held === 'parked'
|
|
320
|
+
return (_jsxs(YStack, { flex: 1, minH: 0, children: [_jsxs(XStack, { px: "$2", py: "$1.5", gap: "$1.5", items: "center", borderBottomWidth: 1, borderColor: "$borderColor", children: [_jsx(XStack, { render: "button", "aria-label": t('Reload the page'), onPress: () => frame.current?.reload(), p: "$1.5", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(RefreshCcw, { size: 14 }) }), _jsx(SizableText, { flex: 1, minW: 0, size: "$1", color: "$soft", numberOfLines: 1, style: mono, children: site || t('Nothing is serving yet') }), site ? (_jsx(Out, { href: site, label: t('Open in a new tab'), children: _jsx(XStack, { p: "$1.5", rounded: "$2", hoverStyle: { bg: '$hover' }, children: _jsx(ExternalLink, { size: 14 }) }) })) : null] }), _jsx(PreviewFrame, { ref: frame, src: site, title: t('Where this run is published'), device: "desktop", empty: _jsxs(YStack, { items: "center", gap: "$2.5", p: "$6", children: [_jsx(Globe, { size: 28, opacity: 0.45 }), _jsx(SizableText, { size: "$3", color: "$ink", children: t('Nothing is serving yet') }), _jsx(SizableText, { size: "$2", color: "$soft", style: { textAlign: 'center', maxWidth: 280 }, children: held === 'parked'
|
|
273
321
|
? `${t('The run’s sandbox is suspended.')} ${t('Resume it to see what it serves.')}`
|
|
274
322
|
: live
|
|
275
323
|
? t('When the run starts a server in its sandbox, the page opens here.')
|
|
276
|
-
: `${t('Nothing listens in this run’s sandbox, and it published no site.')} ${t('
|
|
324
|
+
: `${t('Nothing listens in this run’s sandbox, and it published no site.')} ${t('A server the run started stopped when the run ended.')}` }), serving ? (_jsxs(YStack, { items: "center", gap: "$2", width: "100%", children: [_jsx(SizableText, { size: "$2", color: "$ink", role: "status", style: { textAlign: 'center', maxWidth: 320 }, children: serving.why || (serving.command ? t('Starting {command}…', { command: serving.command }) : t('Starting the dev server…')) }), serving.log ? _jsx(Tail, { log: serving.log }) : null, serving.why ? (_jsxs(XStack, { gap: "$2", flexWrap: "wrap", justify: "center", children: [onStart ? (_jsx(Button, { size: "sm", variant: "outline", onPress: onStart, children: t('Try again') })) : null, onEnvironment ? (_jsx(Button, { size: "sm", variant: "outline", onPress: onEnvironment, children: t('Set a start command') })) : null] })) : null] })) : onStart ? (_jsx(Button, { size: "sm", onPress: onStart, children: t('Start dev server') })) : null] }) })] }));
|
|
325
|
+
}
|
|
326
|
+
/** The last lines a server wrote, as it wrote them. */
|
|
327
|
+
function Tail({ log }) {
|
|
328
|
+
return (_jsx(YStack, { width: "100%", maxW: 460, maxH: 200, overflow: "scroll", rounded: "$2", borderWidth: 1, borderColor: "$borderColor", p: "$2", children: _jsx(SizableText, { size: "$1", color: "$soft", style: { ...mono, whiteSpace: 'pre-wrap', wordBreak: 'break-word' }, children: log.split('\n').slice(-12).join('\n') }) }));
|
|
277
329
|
}
|
|
278
330
|
function EnvironmentInspection({ id, repo, name, branch, environment, pr, title, events, live, onOpenEnvironment, onOpenDiff, }) {
|
|
279
331
|
const { t } = useI18n();
|
package/lib/landing.js
CHANGED
|
@@ -22,7 +22,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
22
22
|
import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
|
|
23
23
|
import { phrase } from '@hanzo/i18n';
|
|
24
24
|
import { useI18n } from '@hanzo/i18n/react';
|
|
25
|
-
import { CircleDot, Cloud, Code,
|
|
25
|
+
import { CircleDot, Cloud, Code, GitBranch, LayoutTemplate, Link2, Monitor, Play } from '@hanzogui/lucide-icons-2';
|
|
26
26
|
import { Button } from '@hanzo/ui';
|
|
27
27
|
import { Composer, MEASURE } from '@hanzo/ui/chat';
|
|
28
28
|
import { BranchSelect, ChipSelect, FooterLink, RepoSelect } from '@hanzo/ui/product';
|
|
@@ -112,13 +112,9 @@ export function Landing({ onStarted }) {
|
|
|
112
112
|
const [note, setNote] = useState('');
|
|
113
113
|
const [adding, setAdding] = useState(null);
|
|
114
114
|
const [offering, setOffering] = useState(false);
|
|
115
|
-
const [forgetful, setForgetful] = useState(false);
|
|
116
115
|
const [desk, setDesk] = useState(false);
|
|
117
116
|
const deck = useDeck('dev-new', { tabs: [{ id: 'tab-1', kind: PAGE, title: '' }], at: 'tab-1' });
|
|
118
117
|
useKey(() => setDesk((d) => !d));
|
|
119
|
-
const [browserTabs, setBrowserTabs] = useState(false);
|
|
120
|
-
const [webSearch, setWebSearch] = useState(false);
|
|
121
|
-
const [research, setResearch] = useState(false);
|
|
122
118
|
// Asking for a repository's address, for one the lists do not show.
|
|
123
119
|
const [giving, setGiving] = useState(false);
|
|
124
120
|
// The repository and branch lists are read again each time they open.
|
|
@@ -277,8 +273,12 @@ export function Landing({ onStarted }) {
|
|
|
277
273
|
// The first thing said opens a conversation (api/talk.ts) and starts nothing:
|
|
278
274
|
// the agent answers, and leases a sandbox or starts a coding run only when the
|
|
279
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');
|
|
280
279
|
const sent = await say(target, {
|
|
281
|
-
input: compose(
|
|
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,
|
|
@@ -431,24 +431,20 @@ export function Landing({ onStarted }) {
|
|
|
431
431
|
loading: places.loading,
|
|
432
432
|
error: places.error?.message ?? null,
|
|
433
433
|
};
|
|
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 }),
|
|
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",
|
|
435
435
|
// One track, its question set at the track's foot, just above the composer: a
|
|
436
436
|
// second `auto` track left the question alone in the first, at the pane's top.
|
|
437
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'
|
|
438
438
|
? t('A proposed environment for {repo} is waiting for review.', { repo: codebase })
|
|
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,
|
|
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: {
|
|
440
440
|
upload: () => pick(files, setFiles, setNote, t),
|
|
441
|
-
|
|
442
|
-
browserTabs: { on: browserTabs, set: setBrowserTabs },
|
|
443
|
-
webSearch: { on: webSearch, set: setWebSearch },
|
|
444
|
-
},
|
|
445
|
-
research: { on: research, set: setResearch },
|
|
441
|
+
research: { on: carry.gear.gear.research, set: (on) => carry.gear.set({ research: on }) },
|
|
446
442
|
skills: carry.skills,
|
|
447
443
|
design: carry.design,
|
|
448
444
|
plugins: carry.plugins,
|
|
449
445
|
devices,
|
|
450
446
|
memory: { on: carry.gear.gear.memory, set: (on) => carry.gear.set({ memory: on }) },
|
|
451
|
-
}, 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: () => {
|
|
452
448
|
setOffering(false);
|
|
453
449
|
env.reload();
|
|
454
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/run.js
CHANGED
|
@@ -180,8 +180,8 @@ function Job({ id, state: read }) {
|
|
|
180
180
|
const failed = finished && state === 'error';
|
|
181
181
|
const asked = shown.find((c) => c.kind === 'said' && c.who === 'person');
|
|
182
182
|
const again = asked && asked.kind === 'said' ? asked.text : '';
|
|
183
|
-
// What the recorded read left out
|
|
184
|
-
const hidden = Math.max(0, (detail.value?.events ?? 0) -
|
|
183
|
+
// What the recorded read left out once initial pagination and live replay are merged.
|
|
184
|
+
const hidden = Math.max(0, (detail.value?.events ?? 0) - events.length);
|
|
185
185
|
// Only a run still working is on a step.
|
|
186
186
|
const current = running ? plan.find((x) => !x.done) : undefined;
|
|
187
187
|
// Asked for while it ran, said once when it stops. `notify` is only ever set
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/build",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.125",
|
|
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.",
|