@hanzo/app 0.3.85 → 0.3.87
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/dist/App.js +2 -2
- package/dist/Recents.js +1 -1
- package/dist/bots/Bots.d.ts +0 -4
- package/dist/bots/Bots.js +99 -67
- package/dist/bots/ComputerDialog.d.ts +9 -0
- package/dist/bots/ComputerDialog.js +175 -0
- package/dist/bots/ConnectorsDialog.d.ts +2 -0
- package/dist/bots/ConnectorsDialog.js +188 -82
- package/dist/bots/Groups.d.ts +26 -0
- package/dist/bots/Groups.js +284 -0
- package/dist/bots/Make.d.ts +3 -1
- package/dist/bots/Make.js +28 -13
- package/dist/bots/Panel.d.ts +5 -1
- package/dist/bots/Panel.js +172 -43
- package/dist/bots/Roster.d.ts +4 -1
- package/dist/bots/Roster.js +30 -13
- package/dist/bots/api.d.ts +169 -8
- package/dist/bots/api.js +157 -7
- package/dist/bots/grid.d.ts +8 -1
- package/dist/bots/grid.js +58 -8
- package/package.json +1 -1
package/dist/bots/api.d.ts
CHANGED
|
@@ -4,12 +4,89 @@ export type Client = NonNullable<ReturnType<typeof useAi>['client']>;
|
|
|
4
4
|
/** The platform's word for a bot that runs on its own schedule. */
|
|
5
5
|
export declare const ALWAYS = "long-running";
|
|
6
6
|
export declare const ONCE = "one-shot";
|
|
7
|
+
/** Default Primary Bot name for every workspace on hanzo.bot. */
|
|
8
|
+
export declare const PRIMARY_BOT = "hanzo";
|
|
9
|
+
/** Prefix used in `?bot=group:<name>` to address a Bot Group in the roster. */
|
|
10
|
+
export declare const GROUP_PREFIX = "group:";
|
|
11
|
+
export declare const isGroupRef: (ref: string | null | undefined) => boolean;
|
|
12
|
+
export declare const groupNameOf: (ref: string) => string;
|
|
13
|
+
export declare const toGroupRef: (name: string) => string;
|
|
7
14
|
/** A bot's name, as the agents route accepts one in a path. */
|
|
8
15
|
export declare const NAME: RegExp;
|
|
9
16
|
/** The address names the open bot (`?bot=`), so a reload, a link and Share all reopen it. */
|
|
10
17
|
export declare const PARAM = "bot";
|
|
11
18
|
/** One US dollar in the platform's unit of money. */
|
|
12
19
|
export declare const DOLLAR = 1000000;
|
|
20
|
+
/** Agent record extended with hierarchy and desktop computer fields returned by `/v1/agent`. */
|
|
21
|
+
export interface BotAgent extends Agent {
|
|
22
|
+
isPrimary?: boolean;
|
|
23
|
+
groupId?: string;
|
|
24
|
+
layer?: number;
|
|
25
|
+
computeRef?: string;
|
|
26
|
+
tools?: string[];
|
|
27
|
+
period?: string;
|
|
28
|
+
}
|
|
29
|
+
export type PolicyKind = 'leader' | 'quasar' | 'majority' | 'weighted' | 'unanimous' | 'kai' | 'custom';
|
|
30
|
+
export type QuasarProfile = 'polaris' | 'aurora' | 'pulsar';
|
|
31
|
+
export interface GroupPolicy {
|
|
32
|
+
kind: PolicyKind;
|
|
33
|
+
leader?: string;
|
|
34
|
+
quasarProfile?: QuasarProfile;
|
|
35
|
+
sampleK?: number;
|
|
36
|
+
alpha?: number;
|
|
37
|
+
beta?: number;
|
|
38
|
+
weights?: Record<string, number>;
|
|
39
|
+
minConfidence?: number;
|
|
40
|
+
customPrompt?: string;
|
|
41
|
+
adjudicatorModel?: string;
|
|
42
|
+
escalateToPrimary?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface BotGroup {
|
|
45
|
+
id: string;
|
|
46
|
+
org?: string;
|
|
47
|
+
name: string;
|
|
48
|
+
description?: string;
|
|
49
|
+
layer: number;
|
|
50
|
+
parentGroupId?: string;
|
|
51
|
+
members: string[];
|
|
52
|
+
policy: GroupPolicy;
|
|
53
|
+
createdAt?: string;
|
|
54
|
+
updatedAt?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface GroupProposal {
|
|
57
|
+
agent: string;
|
|
58
|
+
layer: number;
|
|
59
|
+
output: string;
|
|
60
|
+
verdict: string;
|
|
61
|
+
confidence: number;
|
|
62
|
+
error?: string;
|
|
63
|
+
durationMs?: number;
|
|
64
|
+
runId?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface QuasarCert {
|
|
67
|
+
profile: string;
|
|
68
|
+
sampleK: number;
|
|
69
|
+
alpha: number;
|
|
70
|
+
beta: number;
|
|
71
|
+
rounds: number;
|
|
72
|
+
finalized: boolean;
|
|
73
|
+
support: number;
|
|
74
|
+
winnerDigest: string;
|
|
75
|
+
thresholdCommitment: string;
|
|
76
|
+
checkpointDigest: string;
|
|
77
|
+
escalated?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export interface GroupRunResult {
|
|
80
|
+
group: string;
|
|
81
|
+
layer: number;
|
|
82
|
+
policy: PolicyKind;
|
|
83
|
+
leader?: string;
|
|
84
|
+
output: string;
|
|
85
|
+
proposals: GroupProposal[];
|
|
86
|
+
quasar?: QuasarCert;
|
|
87
|
+
escalatedTo?: string;
|
|
88
|
+
durationMs: number;
|
|
89
|
+
}
|
|
13
90
|
/** What a person states to make a bot: who it is, what it does, what it may spend a week. */
|
|
14
91
|
export interface Draft {
|
|
15
92
|
name: string;
|
|
@@ -17,17 +94,51 @@ export interface Draft {
|
|
|
17
94
|
model: string;
|
|
18
95
|
/** Whole US dollars a week. */
|
|
19
96
|
weekly: number;
|
|
97
|
+
isPrimary?: boolean;
|
|
98
|
+
groupId?: string;
|
|
99
|
+
layer?: number;
|
|
100
|
+
computeRef?: string;
|
|
20
101
|
}
|
|
21
102
|
/**
|
|
22
|
-
* Makes a bot
|
|
23
|
-
*
|
|
24
|
-
* The platform refuses an agent without a budget — `cap_micro_usd`,
|
|
25
|
-
* `max_task_micro_usd` and `period`, every field required — and the SDK's create
|
|
26
|
-
* names none of them, so the call is made here. The week's budget is also the
|
|
27
|
-
* ceiling for one run: a single message may use what the week allows, and the
|
|
28
|
-
* cap is what stops it.
|
|
103
|
+
* Makes a bot with full tool access (`tools: ['*']`) — including Desktop Sandbox
|
|
104
|
+
* Computer Use (`computer_in_sandbox`), bash/files, Connectors, and Bot Coordination.
|
|
29
105
|
*/
|
|
30
|
-
export declare const make: (c: Client, d: Draft) => Promise<
|
|
106
|
+
export declare const make: (c: Client, d: Draft) => Promise<BotAgent>;
|
|
107
|
+
/**
|
|
108
|
+
* Idempotently ensures the org's Primary Bot (default `"hanzo"`, Layer 0, max 1 primary)
|
|
109
|
+
* exists and is ready to direct subordinate bots and groups. Falls back gracefully if
|
|
110
|
+
* `/v1/agent/bootstrap` has not rolled out to an edge node yet.
|
|
111
|
+
*/
|
|
112
|
+
export declare function bootstrapPrimary(c: Client, name?: string, model?: string): Promise<{
|
|
113
|
+
agent: BotAgent;
|
|
114
|
+
created: boolean;
|
|
115
|
+
}>;
|
|
116
|
+
/** Atomically promotes `ref` to be the org's sole Primary Bot (Layer 0). */
|
|
117
|
+
export declare const setPrimaryBot: (c: Client, ref: string) => Promise<BotAgent>;
|
|
118
|
+
/** Updates hierarchy metadata (`groupId`, `layer`, `computeRef`, `tools`) on an existing bot. */
|
|
119
|
+
export declare const updateBotMeta: (c: Client, ref: string, patch: {
|
|
120
|
+
isPrimary?: boolean;
|
|
121
|
+
groupId?: string;
|
|
122
|
+
layer?: number;
|
|
123
|
+
computeRef?: string;
|
|
124
|
+
tools?: string[];
|
|
125
|
+
}) => Promise<BotAgent>;
|
|
126
|
+
/** Lists all Bot Groups in the caller's org, ordered by layer. */
|
|
127
|
+
export declare function listGroups(c: Client, signal?: AbortSignal): Promise<BotGroup[]>;
|
|
128
|
+
export interface GroupDraft {
|
|
129
|
+
name: string;
|
|
130
|
+
description?: string;
|
|
131
|
+
layer: number;
|
|
132
|
+
parentGroupId?: string;
|
|
133
|
+
members: string[];
|
|
134
|
+
policy: GroupPolicy;
|
|
135
|
+
}
|
|
136
|
+
export declare const createGroup: (c: Client, body: GroupDraft) => Promise<BotGroup>;
|
|
137
|
+
export declare const updateGroup: (c: Client, ref: string, body: Partial<GroupDraft>) => Promise<BotGroup>;
|
|
138
|
+
export declare const deleteGroup: (c: Client, ref: string) => Promise<{
|
|
139
|
+
deleted: boolean;
|
|
140
|
+
}>;
|
|
141
|
+
export declare const runGroup: (c: Client, ref: string, input: string, model?: string) => Promise<GroupRunResult>;
|
|
31
142
|
/** The sandbox project that is a bot's own disk: the same name finds the same disk. */
|
|
32
143
|
export declare const disk: (name: string) => string;
|
|
33
144
|
/** Which bot answers on a transport: the org default and any channel bound past it. */
|
|
@@ -37,6 +148,29 @@ export interface Answering {
|
|
|
37
148
|
channels?: Record<string, string>;
|
|
38
149
|
}
|
|
39
150
|
export declare const answering: (c: Client, transport: string, signal?: AbortSignal) => Promise<Answering>;
|
|
151
|
+
export declare const setAnswering: (c: Client, body: {
|
|
152
|
+
transport: string;
|
|
153
|
+
default?: string;
|
|
154
|
+
channels?: Record<string, string>;
|
|
155
|
+
unbind?: string[];
|
|
156
|
+
}) => Promise<Answering>;
|
|
157
|
+
export interface SlackChannel {
|
|
158
|
+
id: string;
|
|
159
|
+
name: string;
|
|
160
|
+
isMember?: boolean;
|
|
161
|
+
isPrivate?: boolean;
|
|
162
|
+
}
|
|
163
|
+
export declare function slackStatus(signal?: AbortSignal): Promise<{
|
|
164
|
+
connected: boolean;
|
|
165
|
+
account?: string;
|
|
166
|
+
available?: boolean;
|
|
167
|
+
}>;
|
|
168
|
+
export declare function slackAuthorizeUrl(): Promise<string | null>;
|
|
169
|
+
export declare function slackSyncChannels(): Promise<{
|
|
170
|
+
joined?: number;
|
|
171
|
+
ok: boolean;
|
|
172
|
+
}>;
|
|
173
|
+
export declare function slackChannels(signal?: AbortSignal): Promise<SlackChannel[]>;
|
|
40
174
|
/** A short-lived grant to open a bot computer's screen or terminal. */
|
|
41
175
|
export interface Grant {
|
|
42
176
|
url?: string;
|
|
@@ -44,3 +178,30 @@ export interface Grant {
|
|
|
44
178
|
expiresIn?: number;
|
|
45
179
|
}
|
|
46
180
|
export declare const grant: (c: Client, id: string, kind: 'terminal' | 'screen') => Promise<Grant>;
|
|
181
|
+
export declare const parkComputer: (c: Client, id: string) => Promise<unknown>;
|
|
182
|
+
export interface ComputerActionIn {
|
|
183
|
+
id: string;
|
|
184
|
+
action: 'screenshot' | 'click' | 'double_click' | 'right_click' | 'middle_click' | 'move' | 'drag' | 'scroll' | 'type' | 'key' | 'navigate' | 'wait' | 'shell';
|
|
185
|
+
x?: number;
|
|
186
|
+
y?: number;
|
|
187
|
+
toX?: number;
|
|
188
|
+
toY?: number;
|
|
189
|
+
dx?: number;
|
|
190
|
+
dy?: number;
|
|
191
|
+
text?: string;
|
|
192
|
+
key?: string;
|
|
193
|
+
url?: string;
|
|
194
|
+
command?: string;
|
|
195
|
+
ms?: number;
|
|
196
|
+
}
|
|
197
|
+
export interface ComputerActionOut {
|
|
198
|
+
action: string;
|
|
199
|
+
stdout?: string;
|
|
200
|
+
stderr?: string;
|
|
201
|
+
exitCode?: number;
|
|
202
|
+
image?: string;
|
|
203
|
+
mimeType?: string;
|
|
204
|
+
width?: number;
|
|
205
|
+
height?: number;
|
|
206
|
+
}
|
|
207
|
+
export declare const actComputer: (c: Client, body: ComputerActionIn) => Promise<ComputerActionOut>;
|
package/dist/bots/api.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { api } from '../lib/api.js';
|
|
3
|
+
import { scope } from '../lib/session.js';
|
|
2
4
|
/** The platform's word for a bot that runs on its own schedule. */
|
|
3
5
|
export const ALWAYS = 'long-running';
|
|
4
6
|
export const ONCE = 'one-shot';
|
|
7
|
+
/** Default Primary Bot name for every workspace on hanzo.bot. */
|
|
8
|
+
export const PRIMARY_BOT = 'hanzo';
|
|
9
|
+
/** Prefix used in `?bot=group:<name>` to address a Bot Group in the roster. */
|
|
10
|
+
export const GROUP_PREFIX = 'group:';
|
|
11
|
+
export const isGroupRef = (ref) => Boolean(ref && ref.startsWith(GROUP_PREFIX) && ref.length > GROUP_PREFIX.length);
|
|
12
|
+
export const groupNameOf = (ref) => ref.startsWith(GROUP_PREFIX) ? ref.slice(GROUP_PREFIX.length) : ref;
|
|
13
|
+
export const toGroupRef = (name) => name.startsWith(GROUP_PREFIX) ? name : `${GROUP_PREFIX}${name}`;
|
|
5
14
|
/** A bot's name, as the agents route accepts one in a path. */
|
|
6
15
|
export const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
7
16
|
/** The address names the open bot (`?bot=`), so a reload, a link and Share all reopen it. */
|
|
@@ -9,13 +18,8 @@ export const PARAM = 'bot';
|
|
|
9
18
|
/** One US dollar in the platform's unit of money. */
|
|
10
19
|
export const DOLLAR = 1_000_000;
|
|
11
20
|
/**
|
|
12
|
-
* Makes a bot
|
|
13
|
-
*
|
|
14
|
-
* The platform refuses an agent without a budget — `cap_micro_usd`,
|
|
15
|
-
* `max_task_micro_usd` and `period`, every field required — and the SDK's create
|
|
16
|
-
* names none of them, so the call is made here. The week's budget is also the
|
|
17
|
-
* ceiling for one run: a single message may use what the week allows, and the
|
|
18
|
-
* cap is what stops it.
|
|
21
|
+
* Makes a bot with full tool access (`tools: ['*']`) — including Desktop Sandbox
|
|
22
|
+
* Computer Use (`computer_in_sandbox`), bash/files, Connectors, and Bot Coordination.
|
|
19
23
|
*/
|
|
20
24
|
export const make = (c, d) => c.http.json({
|
|
21
25
|
method: 'POST',
|
|
@@ -25,12 +29,158 @@ export const make = (c, d) => c.http.json({
|
|
|
25
29
|
model: d.model,
|
|
26
30
|
instructions: d.instructions,
|
|
27
31
|
description: d.instructions.split('\n')[0].slice(0, 200),
|
|
32
|
+
tools: ['*'],
|
|
33
|
+
isPrimary: Boolean(d.isPrimary),
|
|
34
|
+
groupId: d.groupId || undefined,
|
|
35
|
+
layer: d.layer ?? (d.isPrimary ? 0 : 1),
|
|
36
|
+
computeRef: d.computeRef || undefined,
|
|
28
37
|
cap_micro_usd: d.weekly * DOLLAR,
|
|
29
38
|
max_task_micro_usd: d.weekly * DOLLAR,
|
|
30
39
|
period: 'week',
|
|
31
40
|
},
|
|
32
41
|
});
|
|
42
|
+
/**
|
|
43
|
+
* Idempotently ensures the org's Primary Bot (default `"hanzo"`, Layer 0, max 1 primary)
|
|
44
|
+
* exists and is ready to direct subordinate bots and groups. Falls back gracefully if
|
|
45
|
+
* `/v1/agent/bootstrap` has not rolled out to an edge node yet.
|
|
46
|
+
*/
|
|
47
|
+
export async function bootstrapPrimary(c, name = PRIMARY_BOT, model = 'enso') {
|
|
48
|
+
try {
|
|
49
|
+
return await c.http.json({
|
|
50
|
+
method: 'POST',
|
|
51
|
+
path: '/v1/agent/bootstrap',
|
|
52
|
+
body: { name, model },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
const existing = (await c.agents.list());
|
|
57
|
+
const primary = existing.find((b) => b.isPrimary) ?? existing.find((b) => b.name.toLowerCase() === name.toLowerCase());
|
|
58
|
+
if (primary)
|
|
59
|
+
return { agent: primary, created: false };
|
|
60
|
+
const created = await make(c, {
|
|
61
|
+
name,
|
|
62
|
+
model,
|
|
63
|
+
weekly: 25,
|
|
64
|
+
isPrimary: true,
|
|
65
|
+
layer: 0,
|
|
66
|
+
instructions: 'You are hanzo, the Primary Bot (Layer 0) for this workspace. Direct worker bots and Bot Groups across layers, operate your Desktop Sandbox Computer, and answer across Slack and connected tools.',
|
|
67
|
+
});
|
|
68
|
+
return { agent: created, created: true };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Atomically promotes `ref` to be the org's sole Primary Bot (Layer 0). */
|
|
72
|
+
export const setPrimaryBot = (c, ref) => c.http.json({
|
|
73
|
+
method: 'PUT',
|
|
74
|
+
path: `/v1/agents/${encodeURIComponent(ref)}`,
|
|
75
|
+
body: { isPrimary: true, layer: 0 },
|
|
76
|
+
});
|
|
77
|
+
/** Updates hierarchy metadata (`groupId`, `layer`, `computeRef`, `tools`) on an existing bot. */
|
|
78
|
+
export const updateBotMeta = (c, ref, patch) => c.http.json({
|
|
79
|
+
method: 'PUT',
|
|
80
|
+
path: `/v1/agents/${encodeURIComponent(ref)}`,
|
|
81
|
+
body: patch,
|
|
82
|
+
});
|
|
83
|
+
/** Lists all Bot Groups in the caller's org, ordered by layer. */
|
|
84
|
+
export async function listGroups(c, signal) {
|
|
85
|
+
try {
|
|
86
|
+
const res = await c.http.json({ path: '/v1/agent/groups', signal });
|
|
87
|
+
return res.groups ?? [];
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export const createGroup = (c, body) => c.http.json({
|
|
94
|
+
method: 'POST',
|
|
95
|
+
path: '/v1/agent/groups',
|
|
96
|
+
body,
|
|
97
|
+
});
|
|
98
|
+
export const updateGroup = (c, ref, body) => c.http.json({
|
|
99
|
+
method: 'PUT',
|
|
100
|
+
path: `/v1/agent/groups/${encodeURIComponent(groupNameOf(ref))}`,
|
|
101
|
+
body,
|
|
102
|
+
});
|
|
103
|
+
export const deleteGroup = (c, ref) => c.http.json({
|
|
104
|
+
method: 'DELETE',
|
|
105
|
+
path: `/v1/agent/groups/${encodeURIComponent(groupNameOf(ref))}`,
|
|
106
|
+
});
|
|
107
|
+
export const runGroup = (c, ref, input, model) => c.http.json({
|
|
108
|
+
method: 'POST',
|
|
109
|
+
path: `/v1/agent/groups/${encodeURIComponent(groupNameOf(ref))}/run`,
|
|
110
|
+
body: { input, model: model || undefined },
|
|
111
|
+
});
|
|
33
112
|
/** The sandbox project that is a bot's own disk: the same name finds the same disk. */
|
|
34
113
|
export const disk = (name) => `bot-${name}`;
|
|
35
114
|
export const answering = (c, transport, signal) => c.http.json({ path: '/v1/transport/agent', query: { transport }, signal });
|
|
115
|
+
export const setAnswering = (c, body) => c.http.json({
|
|
116
|
+
method: 'PUT',
|
|
117
|
+
path: '/v1/transport/agent',
|
|
118
|
+
body,
|
|
119
|
+
});
|
|
120
|
+
export async function slackStatus(signal) {
|
|
121
|
+
try {
|
|
122
|
+
const r = await fetch(`${api()}/v1/provider`, { headers: scope(), signal });
|
|
123
|
+
if (!r.ok)
|
|
124
|
+
return { connected: false };
|
|
125
|
+
const j = (await r.json());
|
|
126
|
+
const slack = j.providers?.find((p) => String(p.id ?? '').toLowerCase() === 'slack');
|
|
127
|
+
if (!slack)
|
|
128
|
+
return { connected: false };
|
|
129
|
+
const conn = (slack.connection ?? {});
|
|
130
|
+
return {
|
|
131
|
+
connected: Boolean(slack.connected),
|
|
132
|
+
available: Boolean(slack.available),
|
|
133
|
+
account: String(conn.account ?? conn.label ?? ''),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return { connected: false };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export async function slackAuthorizeUrl() {
|
|
141
|
+
const r = await fetch(`${api()}/v1/provider/slack/connect`, {
|
|
142
|
+
method: 'POST',
|
|
143
|
+
headers: { ...scope(), 'Content-Type': 'application/json' },
|
|
144
|
+
body: '{}',
|
|
145
|
+
});
|
|
146
|
+
if (!r.ok)
|
|
147
|
+
return null;
|
|
148
|
+
const j = (await r.json());
|
|
149
|
+
return j.authorizeUrl ?? null;
|
|
150
|
+
}
|
|
151
|
+
export async function slackSyncChannels() {
|
|
152
|
+
const r = await fetch(`${api()}/v1/provider/slack/join`, {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
headers: { ...scope(), 'Content-Type': 'application/json' },
|
|
155
|
+
body: '{}',
|
|
156
|
+
});
|
|
157
|
+
if (!r.ok)
|
|
158
|
+
return { ok: false };
|
|
159
|
+
const j = (await r.json().catch(() => ({})));
|
|
160
|
+
const count = Array.isArray(j.joined) ? j.joined.length : typeof j.count === 'number' ? j.count : undefined;
|
|
161
|
+
return { ok: true, joined: count };
|
|
162
|
+
}
|
|
163
|
+
export async function slackChannels(signal) {
|
|
164
|
+
try {
|
|
165
|
+
const r = await fetch(`${api()}/v1/provider/slack/channels?types=public_channel`, { headers: scope(), signal });
|
|
166
|
+
if (!r.ok)
|
|
167
|
+
return [];
|
|
168
|
+
const j = (await r.json());
|
|
169
|
+
return (j.channels ?? []).map((ch) => ({
|
|
170
|
+
id: String(ch.id ?? ''),
|
|
171
|
+
name: String(ch.name ?? ''),
|
|
172
|
+
isMember: Boolean(ch.is_member ?? ch.isMember),
|
|
173
|
+
isPrivate: Boolean(ch.is_private ?? ch.isPrivate),
|
|
174
|
+
})).filter((ch) => Boolean(ch.id && ch.name));
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
36
180
|
export const grant = (c, id, kind) => c.http.json({ method: 'POST', path: `/v1/sandbox/${encodeURIComponent(id)}/${kind}/ticket` });
|
|
181
|
+
export const parkComputer = (c, id) => c.http.json({ method: 'POST', path: `/v1/sandbox/${encodeURIComponent(id)}/park`, body: {} });
|
|
182
|
+
export const actComputer = (c, body) => c.http.json({
|
|
183
|
+
method: 'POST',
|
|
184
|
+
path: '/v1/sandbox/computer',
|
|
185
|
+
body,
|
|
186
|
+
});
|
package/dist/bots/grid.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { Agent, AgentRun } from '@hanzo/ai';
|
|
2
|
+
import type { BotGroup, GroupPolicy } from './api.js';
|
|
2
3
|
/** How many bots the grid holds before the rest become rows. */
|
|
3
4
|
export declare const GRID = 12;
|
|
5
|
+
/** Whether a bot wears the Primary / Lead star badge in the roster grid. */
|
|
6
|
+
export declare function isStarredBot(bot: Agent): boolean;
|
|
4
7
|
/** What a row says under a bot's name: its newest run's last word. */
|
|
5
8
|
export declare function lastWord(run: AgentRun | undefined): string;
|
|
6
|
-
/** The bots in the grid (lead seat order
|
|
9
|
+
/** The bots in the grid (Primary Bot first, lead seat order next, then creation order) and the rest in rows. */
|
|
7
10
|
export declare function split(bots: readonly Agent[], last: ReadonlyMap<string, AgentRun>): {
|
|
8
11
|
grid: Agent[];
|
|
9
12
|
rows: Agent[];
|
|
10
13
|
};
|
|
14
|
+
/** Orders Bot Groups by layer ascending (`Layer 1`, `Layer 2`, ...), then alphabetically. */
|
|
15
|
+
export declare function sortGroupsByLayer(groups: readonly BotGroup[]): BotGroup[];
|
|
16
|
+
/** Compact human-readable badge for a group's consensus or leadership policy. */
|
|
17
|
+
export declare function policyBadge(policy: GroupPolicy | undefined): string;
|
package/dist/bots/grid.js
CHANGED
|
@@ -1,28 +1,43 @@
|
|
|
1
|
-
// Which bots are faces in the grid and which are rows,
|
|
2
|
-
// Pure, so the roster's
|
|
1
|
+
// Which bots are faces in the grid and which are rows, how Bot Groups sort across
|
|
2
|
+
// layers, and how coordination policies describe themselves. Pure, so the roster's
|
|
3
|
+
// order is tested as data.
|
|
3
4
|
import { member } from '../team.js';
|
|
5
|
+
import { PRIMARY_BOT } from './api.js';
|
|
4
6
|
import { instant } from './time.js';
|
|
5
7
|
/** How many bots the grid holds before the rest become rows. */
|
|
6
8
|
export const GRID = 12;
|
|
7
9
|
const LEAD_ORDER = new Map(['vi', 'opera', 'mana', 'dev', 'des', 'fin', 'huma', 'mark', 'sal', 'sci', 'su', 'cyber'].map((id, i) => [id, i]));
|
|
8
|
-
function rankOf(
|
|
9
|
-
const
|
|
10
|
+
function rankOf(bot) {
|
|
11
|
+
const ext = bot;
|
|
12
|
+
if (ext.isPrimary)
|
|
13
|
+
return -2;
|
|
14
|
+
const lower = bot.name.toLowerCase();
|
|
15
|
+
if (lower === PRIMARY_BOT)
|
|
16
|
+
return -1;
|
|
17
|
+
const lead = LEAD_ORDER.get(lower);
|
|
10
18
|
if (lead !== undefined)
|
|
11
19
|
return lead;
|
|
12
|
-
const seat = member(name)?.seat;
|
|
20
|
+
const seat = member(bot.name)?.seat;
|
|
13
21
|
return seat !== undefined ? 100 + seat : Number.MAX_SAFE_INTEGER;
|
|
14
22
|
}
|
|
23
|
+
/** Whether a bot wears the Primary / Lead star badge in the roster grid. */
|
|
24
|
+
export function isStarredBot(bot) {
|
|
25
|
+
const ext = bot;
|
|
26
|
+
if (ext.isPrimary || bot.name.toLowerCase() === PRIMARY_BOT)
|
|
27
|
+
return true;
|
|
28
|
+
return member(bot.name)?.seat === 1;
|
|
29
|
+
}
|
|
15
30
|
/** What a row says under a bot's name: its newest run's last word. */
|
|
16
31
|
export function lastWord(run) {
|
|
17
32
|
if (!run)
|
|
18
33
|
return '';
|
|
19
34
|
return (run.output || run.error || run.input || '').replace(/\s+/g, ' ').trim();
|
|
20
35
|
}
|
|
21
|
-
/** The bots in the grid (lead seat order
|
|
36
|
+
/** The bots in the grid (Primary Bot first, lead seat order next, then creation order) and the rest in rows. */
|
|
22
37
|
export function split(bots, last) {
|
|
23
38
|
const made = [...bots].sort((a, b) => {
|
|
24
|
-
const sa = rankOf(a
|
|
25
|
-
const sb = rankOf(b
|
|
39
|
+
const sa = rankOf(a);
|
|
40
|
+
const sb = rankOf(b);
|
|
26
41
|
if (sa !== sb)
|
|
27
42
|
return sa - sb;
|
|
28
43
|
return (instant(a.createdAt) ?? 0) - (instant(b.createdAt) ?? 0);
|
|
@@ -33,3 +48,38 @@ export function split(bots, last) {
|
|
|
33
48
|
.sort((a, b) => (instant(last.get(b.name)?.createdAt) ?? 0) - (instant(last.get(a.name)?.createdAt) ?? 0));
|
|
34
49
|
return { grid, rows };
|
|
35
50
|
}
|
|
51
|
+
/** Orders Bot Groups by layer ascending (`Layer 1`, `Layer 2`, ...), then alphabetically. */
|
|
52
|
+
export function sortGroupsByLayer(groups) {
|
|
53
|
+
return [...groups].sort((a, b) => {
|
|
54
|
+
const la = a.layer || 1;
|
|
55
|
+
const lb = b.layer || 1;
|
|
56
|
+
if (la !== lb)
|
|
57
|
+
return la - lb;
|
|
58
|
+
return a.name.localeCompare(b.name);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** Compact human-readable badge for a group's consensus or leadership policy. */
|
|
62
|
+
export function policyBadge(policy) {
|
|
63
|
+
if (!policy)
|
|
64
|
+
return 'Leader';
|
|
65
|
+
switch (policy.kind) {
|
|
66
|
+
case 'quasar': {
|
|
67
|
+
const prof = policy.quasarProfile ? policy.quasarProfile.charAt(0).toUpperCase() + policy.quasarProfile.slice(1) : 'Aurora';
|
|
68
|
+
return `Lux Quasar · ${prof}`;
|
|
69
|
+
}
|
|
70
|
+
case 'leader':
|
|
71
|
+
return policy.leader ? `Leader · ${policy.leader}` : 'Leader';
|
|
72
|
+
case 'majority':
|
|
73
|
+
return 'Majority';
|
|
74
|
+
case 'weighted':
|
|
75
|
+
return 'Weighted';
|
|
76
|
+
case 'unanimous':
|
|
77
|
+
return 'Unanimous';
|
|
78
|
+
case 'kai':
|
|
79
|
+
return 'Kai Consensus';
|
|
80
|
+
case 'custom':
|
|
81
|
+
return 'Custom Policy';
|
|
82
|
+
default:
|
|
83
|
+
return 'Leader';
|
|
84
|
+
}
|
|
85
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/app",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.87",
|
|
4
4
|
"description": "Hanzo's app: the shell and its apps (Home, Chat, Inbox, Contacts, Meet, Calendar, Drive, Board, Work, Bots), once, for every Hanzo surface.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|