longtable 0.1.1 → 0.1.2
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/package.json +1 -1
- package/src/claude.mjs +2 -1
- package/src/codex.mjs +1 -1
- package/src/run.mjs +21 -2
package/package.json
CHANGED
package/src/claude.mjs
CHANGED
|
@@ -110,7 +110,8 @@ export function claudeLimits(rate) {
|
|
|
110
110
|
if (!rate) return null;
|
|
111
111
|
const names = { five_hour: "5-hour", seven_day: "weekly" };
|
|
112
112
|
const windows = Object.entries(rate.unifiedWindows || {}).map(([k, w]) => ({
|
|
113
|
-
|
|
113
|
+
// A week counted for one model alone arrives as seven_day_<model>.
|
|
114
|
+
name: names[k] || (k.startsWith("seven_day_") ? `weekly ${k.slice(10).replace(/_/g, " ")}` : k.replace(/_/g, " ")),
|
|
114
115
|
used: Math.round((w.utilization ?? 0) * 100),
|
|
115
116
|
resets: w.resetsAt ? new Date(w.resetsAt * 1000).toISOString() : null,
|
|
116
117
|
}));
|
package/src/codex.mjs
CHANGED
|
@@ -141,7 +141,7 @@ export function codexLimits(codex) {
|
|
|
141
141
|
// The model Codex uses when none is asked for: the one it marks as its default, else the first it lists.
|
|
142
142
|
const list = m.result?.data || [];
|
|
143
143
|
const pick = list.find((x) => x.isDefault) || list[0];
|
|
144
|
-
done(limits ? { ...limits, model: pick?.
|
|
144
|
+
done(limits ? { ...limits, model: pick?.id || null, models: list.filter((x) => !x.hidden).map((x) => x.id).filter(Boolean).slice(0, 12) } : null);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
});
|
package/src/run.mjs
CHANGED
|
@@ -157,7 +157,7 @@ async function workClient(rpc, seat, engines, job) {
|
|
|
157
157
|
model: seat.model || process.env.LONGTABLE_MODEL });
|
|
158
158
|
if (result.is_error) throw new Error(result.result || "Claude Code reported an error");
|
|
159
159
|
s = result.structured_output;
|
|
160
|
-
limits = result.limits;
|
|
160
|
+
limits = result.limits && { ...result.limits, models: ["opus", "sonnet", "haiku"] };
|
|
161
161
|
info = { model: Object.keys(result.modelUsage || {})[0] || seat.model || process.env.LONGTABLE_MODEL || "default",
|
|
162
162
|
usage: { input: result.usage?.input_tokens, output: result.usage?.output_tokens, wall_ms: result.wall_ms,
|
|
163
163
|
cost_usd_equivalent: result.total_cost_usd } };
|
|
@@ -208,8 +208,27 @@ async function workPacked(rpc, seat, engines, job, copy) {
|
|
|
208
208
|
await report(rpc, seat, limits, model);
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
// The model for this job. The table's own answer (a direct answer, or the one combined from views) runs on the
|
|
212
|
+
// model picked for the table; a view or an introduction runs on the one the person picked for their own AI. Neither
|
|
213
|
+
// pick stands in for the other. With no pick, Claude runs Sonnet 5.5 for the table and Opus 5.5 for the person;
|
|
214
|
+
// ChatGPT keeps Codex's own default. A pick made for the other maker's AI is ignored.
|
|
215
|
+
const fits = (kind, model) => !!model && (/^(claude|opus|sonnet|haiku|fable)/i.test(model) === (kind === "claude"));
|
|
216
|
+
const AUTOMATIC = { table: "claude-sonnet-5-5", mine: "claude-opus-5-5" };
|
|
217
|
+
async function chosenModel(rpc, seat, job) {
|
|
218
|
+
const forTable = job.kind === "answer" || job.kind === "combine";
|
|
219
|
+
let pick = null;
|
|
220
|
+
try {
|
|
221
|
+
const picks = (await rpc("runner_models", { token: seat.token })) || {};
|
|
222
|
+
pick = forTable ? picks.table : picks.mine;
|
|
223
|
+
} catch {}
|
|
224
|
+
if (fits(seat.kind, pick)) return pick;
|
|
225
|
+
// A model named when connecting, or by the tests, comes before the automatic one.
|
|
226
|
+
return seat.model || process.env.LONGTABLE_MODEL || (seat.kind === "claude" ? AUTOMATIC[forTable ? "table" : "mine"] : null);
|
|
227
|
+
}
|
|
228
|
+
|
|
211
229
|
async function work(rpc, seat, engines, job) {
|
|
212
230
|
log(`${job.kind} job ${job.job_id} for ${job.me}`);
|
|
231
|
+
seat = { ...seat, model: await chosenModel(rpc, seat, job) };
|
|
213
232
|
if (job.kind === "client") {
|
|
214
233
|
try {
|
|
215
234
|
await workClient(rpc, seat, engines, job);
|
|
@@ -262,7 +281,7 @@ async function work(rpc, seat, engines, job) {
|
|
|
262
281
|
},
|
|
263
282
|
});
|
|
264
283
|
log(`${job.kind} job ${job.job_id} done in ${result.wall_ms} ms`);
|
|
265
|
-
await report(rpc, seat, result.limits, Object.keys(result.modelUsage || {})[0] || seat.model || process.env.LONGTABLE_MODEL);
|
|
284
|
+
await report(rpc, seat, { ai: "claude", ...(result.limits || {}), models: ["opus", "sonnet", "haiku"] }, Object.keys(result.modelUsage || {})[0] || seat.model || process.env.LONGTABLE_MODEL);
|
|
266
285
|
} catch (e) {
|
|
267
286
|
log(`${job.kind} job ${job.job_id} failed: ${e.message}`);
|
|
268
287
|
try { await rpc("runner_fail", { token: seat.token, job: job.job_id, reason: e.message }); } catch {}
|