@neta-art/cohub-cli 9.1.1 → 10.0.0
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/board-export.d.ts +20 -6
- package/dist/board-export.js +143 -87
- package/dist/board-kernel/lexer.js +84 -0
- package/dist/board-kernel.d.ts +4 -2
- package/dist/board-kernel.js +2943 -823
- package/dist/board-time.js +6 -0
- package/dist/commands/boards/authoring.d.ts +2 -0
- package/dist/commands/boards/authoring.js +90 -0
- package/dist/commands/boards/examples.js +12 -7
- package/dist/commands/boards.js +46 -11
- package/dist/commands/me.js +2 -0
- package/dist/commands/rooms.d.ts +3 -0
- package/dist/commands/rooms.js +232 -0
- package/dist/commands/spaces.js +3 -0
- package/dist/index.js +3 -0
- package/dist/runtime/harness.js +3 -6
- package/dist/runtime/model-catalog.d.ts +9 -1
- package/dist/runtime/model-catalog.js +52 -6
- package/dist/runtime/native/execution.js +1 -1
- package/dist/safe-remote-image.d.ts +4 -0
- package/dist/safe-remote-image.js +30 -15
- package/dist/session-status.d.ts +6 -0
- package/dist/session-status.js +14 -0
- package/package.json +3 -3
|
@@ -1,19 +1,65 @@
|
|
|
1
1
|
import { record } from "./json-rpc.js";
|
|
2
|
-
|
|
2
|
+
const thinkingLevels = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
3
|
+
const thinkingLevel = (value) => thinkingLevels.includes(value) ? value : undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Publish only picker metadata, never provider credentials or request configuration.
|
|
6
|
+
* `state` is a fresh Pi's `get_state`: its model is what Pi runs when Cohub requests
|
|
7
|
+
* nothing, and its level is resolved and clamped for that model only. Pi's levels for
|
|
8
|
+
* other models live in its settings, which RPC does not expose; those models fall back
|
|
9
|
+
* to the picker's rule, and Cohub always sends the chosen level explicitly.
|
|
10
|
+
*/
|
|
11
|
+
export function piModelCatalog(entries, state) {
|
|
12
|
+
const current = record(state.model);
|
|
13
|
+
const currentLevel = thinkingLevel(state.thinkingLevel);
|
|
14
|
+
return entries.flatMap((value) => {
|
|
15
|
+
const model = record(value);
|
|
16
|
+
if (typeof model.id !== "string" || !model.id || typeof model.provider !== "string" || !model.provider)
|
|
17
|
+
return [];
|
|
18
|
+
const map = record(model.thinkingLevelMap);
|
|
19
|
+
const thinkingLevelMap = Object.fromEntries(thinkingLevels.flatMap((level) => map[level] === null || typeof map[level] === "string" ? [[level, map[level]]] : []));
|
|
20
|
+
const isDefault = current.provider === model.provider && current.id === model.id;
|
|
21
|
+
return [{
|
|
22
|
+
harness: "pi", id: model.id, provider: model.provider, name: typeof model.name === "string" ? model.name : model.id,
|
|
23
|
+
...(isDefault ? { isDefault } : {}),
|
|
24
|
+
...(typeof model.reasoning === "boolean" ? { reasoning: model.reasoning } : {}),
|
|
25
|
+
...(isDefault && currentLevel ? { defaultThinkingLevel: currentLevel } : {}),
|
|
26
|
+
...(Object.keys(thinkingLevelMap).length ? { thinkingLevelMap } : {}),
|
|
27
|
+
}];
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function codexThinking(model, configuredEffort) {
|
|
31
|
+
if (!Array.isArray(model.supportedReasoningEfforts))
|
|
32
|
+
return {};
|
|
33
|
+
const efforts = new Set(model.supportedReasoningEfforts.map((entry) => record(entry).reasoningEffort));
|
|
34
|
+
const thinkingLevelMap = Object.fromEntries(thinkingLevels.map((level) => {
|
|
35
|
+
const effort = level === "off" ? "none" : level;
|
|
36
|
+
return [level, efforts.has(effort) ? effort : null];
|
|
37
|
+
}));
|
|
38
|
+
const normalize = (value) => thinkingLevel(value === "none" ? "off" : value);
|
|
39
|
+
const configured = normalize(configuredEffort);
|
|
40
|
+
const fallback = normalize(model.defaultReasoningEffort);
|
|
41
|
+
const defaultThinkingLevel = [configured, fallback].find((level) => level && thinkingLevelMap[level] != null);
|
|
42
|
+
return {
|
|
43
|
+
reasoning: thinkingLevels.some((level) => level !== "off" && thinkingLevelMap[level] != null),
|
|
44
|
+
thinkingLevelMap,
|
|
45
|
+
...(defaultThinkingLevel ? { defaultThinkingLevel } : {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Use Codex's picker-visible model/list for every provider, including custom providers. */
|
|
3
49
|
export function codexModelCatalog(configResponse, entries) {
|
|
4
50
|
const config = record(configResponse.config);
|
|
5
51
|
const provider = typeof config.model_provider === "string" ? config.model_provider : "openai";
|
|
6
52
|
const configuredModel = typeof config.model === "string" ? config.model : null;
|
|
7
|
-
const
|
|
8
|
-
const catalog = provider !== "openai" && !customCatalog ? [] : entries;
|
|
9
|
-
const models = catalog.flatMap((value) => {
|
|
53
|
+
const models = entries.flatMap((value) => {
|
|
10
54
|
const model = record(value);
|
|
11
55
|
const id = typeof model.model === "string" ? model.model : typeof model.id === "string" ? model.id : null;
|
|
12
56
|
if (!id || model.hidden)
|
|
13
57
|
return [];
|
|
14
|
-
|
|
58
|
+
// A configured model replaces the catalog's own default.
|
|
59
|
+
const isDefault = configuredModel ? id === configuredModel : model.isDefault === true;
|
|
60
|
+
return [{ harness: "codex", provider, id, name: typeof model.displayName === "string" ? model.displayName : id, ...(isDefault ? { isDefault } : {}), ...codexThinking(model, config.model_reasoning_effort) }];
|
|
15
61
|
});
|
|
16
62
|
if (configuredModel && !models.some((model) => model.id === configuredModel))
|
|
17
|
-
models.unshift({ harness: "codex", provider, id: configuredModel, name: configuredModel });
|
|
63
|
+
models.unshift({ harness: "codex", provider, id: configuredModel, name: configuredModel, isDefault: true });
|
|
18
64
|
return models;
|
|
19
65
|
}
|
|
@@ -294,7 +294,7 @@ async function runCodex(executor, turn, context) {
|
|
|
294
294
|
escalation = setTimeout(() => void host?.close().catch(() => undefined), ABORT_ESCALATION_MS);
|
|
295
295
|
};
|
|
296
296
|
signal.addEventListener("abort", abort, { once: true });
|
|
297
|
-
codex.request("turn/start", { threadId, clientUserMessageId: input.turnId, input: content, ...(input.thinkingLevel ? { effort: input.thinkingLevel } : {}) })
|
|
297
|
+
codex.request("turn/start", { threadId, clientUserMessageId: input.turnId, input: content, ...(input.thinkingLevel ? { effort: input.thinkingLevel === "off" ? "none" : input.thinkingLevel } : {}) })
|
|
298
298
|
.then((result) => { nativeTurnId ??= text(record(result.turn).id) || null; if (signal.aborted)
|
|
299
299
|
interrupt(); })
|
|
300
300
|
.catch(finish);
|
|
@@ -25,4 +25,8 @@ export declare function downloadPublicImage(input: string, options?: RemoteImage
|
|
|
25
25
|
bytes: Uint8Array;
|
|
26
26
|
mimeType: string;
|
|
27
27
|
}>;
|
|
28
|
+
export declare function downloadPublicAudio(input: string, options?: RemoteImageDownloadOptions): Promise<{
|
|
29
|
+
bytes: Uint8Array;
|
|
30
|
+
mimeType: string;
|
|
31
|
+
}>;
|
|
28
32
|
export {};
|
|
@@ -13,6 +13,11 @@ const IMAGE_MIME_TYPES = new Set([
|
|
|
13
13
|
"image/png",
|
|
14
14
|
"image/webp",
|
|
15
15
|
]);
|
|
16
|
+
const AUDIO_MIME_TYPES = new Set([
|
|
17
|
+
"audio/mpeg", "audio/mp3", "audio/mp4", "audio/aac", "audio/ogg",
|
|
18
|
+
"audio/wav", "audio/x-wav", "audio/wave", "audio/flac", "audio/x-flac",
|
|
19
|
+
"audio/webm", "audio/opus", "application/ogg",
|
|
20
|
+
]);
|
|
16
21
|
const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
17
22
|
async function defaultLookup(hostname) {
|
|
18
23
|
const records = await dns.lookup(hostname, { all: true, verbatim: true });
|
|
@@ -48,7 +53,7 @@ function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
|
48
53
|
const client = url.protocol === "https:" ? https : http;
|
|
49
54
|
const request = client.request(url, {
|
|
50
55
|
agent: false,
|
|
51
|
-
headers: { Accept: "image/
|
|
56
|
+
headers: { Accept: "image/*,audio/*,application/ogg" },
|
|
52
57
|
lookup: pinnedLookup(addresses),
|
|
53
58
|
}, (response) => {
|
|
54
59
|
const status = response.statusCode ?? 0;
|
|
@@ -61,7 +66,7 @@ function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
|
61
66
|
const declaredLength = Number(headers.get("content-length") ?? 0);
|
|
62
67
|
if (Number.isFinite(declaredLength) && declaredLength > maxBytes) {
|
|
63
68
|
response.destroy();
|
|
64
|
-
reject(new Error(`
|
|
69
|
+
reject(new Error(`Media exceeds the ${maxBytes} byte download limit`));
|
|
65
70
|
return;
|
|
66
71
|
}
|
|
67
72
|
const chunks = [];
|
|
@@ -69,7 +74,7 @@ function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
|
69
74
|
response.on("data", (chunk) => {
|
|
70
75
|
total += chunk.byteLength;
|
|
71
76
|
if (total > maxBytes) {
|
|
72
|
-
response.destroy(new Error(`
|
|
77
|
+
response.destroy(new Error(`Media exceeds the ${maxBytes} byte download limit`));
|
|
73
78
|
return;
|
|
74
79
|
}
|
|
75
80
|
chunks.push(chunk);
|
|
@@ -86,7 +91,7 @@ function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
|
86
91
|
});
|
|
87
92
|
});
|
|
88
93
|
request.setTimeout(timeoutMs, () => {
|
|
89
|
-
request.destroy(new Error(`
|
|
94
|
+
request.destroy(new Error(`Media download timed out after ${timeoutMs}ms`));
|
|
90
95
|
});
|
|
91
96
|
request.once("error", reject);
|
|
92
97
|
request.end();
|
|
@@ -95,7 +100,7 @@ function requestPinned(url, addresses, timeoutMs, maxBytes) {
|
|
|
95
100
|
function remainingMs(deadline) {
|
|
96
101
|
const remaining = deadline - Date.now();
|
|
97
102
|
if (remaining <= 0)
|
|
98
|
-
throw new Error("
|
|
103
|
+
throw new Error("Media download timed out");
|
|
99
104
|
return remaining;
|
|
100
105
|
}
|
|
101
106
|
async function withDeadline(promise, deadline) {
|
|
@@ -105,7 +110,7 @@ async function withDeadline(promise, deadline) {
|
|
|
105
110
|
return await Promise.race([
|
|
106
111
|
promise,
|
|
107
112
|
new Promise((_, reject) => {
|
|
108
|
-
timer = setTimeout(() => reject(new Error(`
|
|
113
|
+
timer = setTimeout(() => reject(new Error(`Media download timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
109
114
|
}),
|
|
110
115
|
]);
|
|
111
116
|
}
|
|
@@ -117,7 +122,7 @@ async function withDeadline(promise, deadline) {
|
|
|
117
122
|
async function resolvePublicUrl(value, lookup, deadline) {
|
|
118
123
|
const normalized = normalizeBoardRemoteUrl(value);
|
|
119
124
|
if (!normalized)
|
|
120
|
-
throw new Error("
|
|
125
|
+
throw new Error("Media URL must be a public HTTP(S) URL");
|
|
121
126
|
const url = new URL(normalized);
|
|
122
127
|
const hostname = url.hostname.replace(/^\[|\]$/g, "");
|
|
123
128
|
const addresses = isIP(hostname)
|
|
@@ -126,11 +131,21 @@ async function resolvePublicUrl(value, lookup, deadline) {
|
|
|
126
131
|
const [first, ...rest] = addresses;
|
|
127
132
|
if (!first ||
|
|
128
133
|
addresses.some((entry) => !isPublicBoardRemoteAddress(entry.address))) {
|
|
129
|
-
throw new Error("
|
|
134
|
+
throw new Error("Media URL resolves to a private address");
|
|
130
135
|
}
|
|
131
136
|
return { url, addresses: [first, ...rest] };
|
|
132
137
|
}
|
|
133
|
-
export
|
|
138
|
+
export function downloadPublicImage(input, options = {}) {
|
|
139
|
+
return downloadPublicMedia(input, IMAGE_MIME_TYPES, options);
|
|
140
|
+
}
|
|
141
|
+
export function downloadPublicAudio(input, options = {}) {
|
|
142
|
+
return downloadPublicMedia(input, AUDIO_MIME_TYPES, {
|
|
143
|
+
maxBytes: 64 * 1024 * 1024,
|
|
144
|
+
timeoutMs: 30_000,
|
|
145
|
+
...options,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async function downloadPublicMedia(input, mimeTypes, options) {
|
|
134
149
|
const lookup = options.lookup ?? defaultLookup;
|
|
135
150
|
const requester = options.requester ?? requestPinned;
|
|
136
151
|
const maxBytes = options.maxBytes ?? REMOTE_IMAGE_MAX_BYTES;
|
|
@@ -142,9 +157,9 @@ export async function downloadPublicImage(input, options = {}) {
|
|
|
142
157
|
if (REDIRECT_STATUSES.has(response.status)) {
|
|
143
158
|
const location = response.headers.get("location");
|
|
144
159
|
if (!location)
|
|
145
|
-
throw new Error("
|
|
160
|
+
throw new Error("Media redirect is missing a location");
|
|
146
161
|
if (redirect === MAX_REDIRECTS)
|
|
147
|
-
throw new Error("Too many
|
|
162
|
+
throw new Error("Too many media redirects");
|
|
148
163
|
current = new URL(location, url).toString();
|
|
149
164
|
continue;
|
|
150
165
|
}
|
|
@@ -152,17 +167,17 @@ export async function downloadPublicImage(input, options = {}) {
|
|
|
152
167
|
throw new Error(`HTTP ${response.status}`);
|
|
153
168
|
}
|
|
154
169
|
if (response.bytes.byteLength > maxBytes) {
|
|
155
|
-
throw new Error(`
|
|
170
|
+
throw new Error(`Media exceeds the ${maxBytes} byte download limit`);
|
|
156
171
|
}
|
|
157
172
|
const mimeType = response.headers
|
|
158
173
|
.get("content-type")
|
|
159
174
|
?.split(";", 1)[0]
|
|
160
175
|
?.trim()
|
|
161
176
|
.toLowerCase();
|
|
162
|
-
if (!mimeType || !
|
|
163
|
-
throw new Error("Remote
|
|
177
|
+
if (!mimeType || !mimeTypes.has(mimeType)) {
|
|
178
|
+
throw new Error("Remote resource has an unsupported media type");
|
|
164
179
|
}
|
|
165
180
|
return { bytes: response.bytes, mimeType };
|
|
166
181
|
}
|
|
167
|
-
throw new Error("Too many
|
|
182
|
+
throw new Error("Too many media redirects");
|
|
168
183
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SessionRecord } from "@neta-art/cohub";
|
|
2
|
+
import type { Column } from "./output.js";
|
|
3
|
+
type SessionStatusFields = Pick<SessionRecord, "activeTurn" | "lastTurnIssue">;
|
|
4
|
+
export declare function sessionStatusText(session: Partial<SessionStatusFields>): string;
|
|
5
|
+
export declare const SESSION_STATUS_COLUMN: Column;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function sessionStatusText(session) {
|
|
2
|
+
const turn = session.activeTurn;
|
|
3
|
+
if (turn)
|
|
4
|
+
return turn.status === "abort_requested" ? "stopping" : turn.status;
|
|
5
|
+
const issue = session.lastTurnIssue;
|
|
6
|
+
if (issue?.status === "failed")
|
|
7
|
+
return "failed";
|
|
8
|
+
return issue?.reason === "stale_active_recovered" ? "interrupted" : "";
|
|
9
|
+
}
|
|
10
|
+
export const SESSION_STATUS_COLUMN = {
|
|
11
|
+
key: "activeTurn",
|
|
12
|
+
label: "Status",
|
|
13
|
+
format: (_value, row) => sessionStatusText(row),
|
|
14
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/cohub-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"NOTICE"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@neta-art/cohub": "
|
|
22
|
-
"@neta-art/generation": "^0.1.
|
|
21
|
+
"@neta-art/cohub": "11.0.0",
|
|
22
|
+
"@neta-art/generation": "^0.1.33",
|
|
23
23
|
"commander": "^15.0.0",
|
|
24
24
|
"sharp": "^0.35.4",
|
|
25
25
|
"ws": "^8.21.3"
|