humanish 0.53.0 → 0.55.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/actor-contract.d.ts +13 -0
- package/dist/actor-contract.js.map +1 -1
- package/dist/computer-use-actor.d.ts +1 -1
- package/dist/computer-use.d.ts +11 -1
- package/dist/computer-use.js +5 -2
- package/dist/computer-use.js.map +1 -1
- package/dist/cua-actor-lab.d.ts +12 -2
- package/dist/cua-actor-lab.js +31 -5
- package/dist/cua-actor-lab.js.map +1 -1
- package/dist/lab-config.d.ts +19 -0
- package/dist/lab-config.js +14 -1
- package/dist/lab-config.js.map +1 -1
- package/dist/lab-summary.d.ts +8 -0
- package/dist/lab-summary.js +17 -1
- package/dist/lab-summary.js.map +1 -1
- package/dist/openai-responses-cu.d.ts +15 -2
- package/dist/openai-responses-cu.js +10 -1
- package/dist/openai-responses-cu.js.map +1 -1
- package/dist/program.js +3 -2
- package/dist/program.js.map +1 -1
- package/dist/reasoning-effort.d.ts +6 -0
- package/dist/reasoning-effort.js +24 -0
- package/dist/reasoning-effort.js.map +1 -0
- package/dist/run-detail.js +27 -3
- package/dist/run-detail.js.map +1 -1
- package/dist/tui-actions.d.ts +18 -0
- package/dist/tui-actions.js +81 -1
- package/dist/tui-actions.js.map +1 -1
- package/dist/tui-app.js +103 -103
- package/dist/tui-contract.d.ts +2 -0
- package/dist/tui-contract.js.map +1 -1
- package/docs/contracts/schemas.md +12 -1
- package/docs/goals/current.md +3 -3
- package/docs/ramp/README.md +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** The documented vocabulary, ordered from least to most reasoning. */
|
|
2
|
+
export declare const REASONING_EFFORTS: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
3
|
+
export type ReasoningEffort = (typeof REASONING_EFFORTS)[number];
|
|
4
|
+
export declare function isReasoningEffort(value: unknown): value is ReasoningEffort;
|
|
5
|
+
/** For error messages: the vocabulary as an inline list. */
|
|
6
|
+
export declare function reasoningEffortNames(): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// The provider-declared reasoning-effort vocabulary, kept in its own module so the lab schema and
|
|
2
|
+
// the OpenAI provider can share it without the schema depending on a provider.
|
|
3
|
+
//
|
|
4
|
+
// WHY THIS EXISTS AT ALL: effort was reachable in the provider and unreachable from a lab. Every
|
|
5
|
+
// computer-use run humanish had ever done was therefore the provider default — not by decision but
|
|
6
|
+
// by omission, which is the kind of silent constant that turns a finding about a product into a
|
|
7
|
+
// finding about a default nobody chose (#497).
|
|
8
|
+
//
|
|
9
|
+
// SUPPORT IS MODEL-DEPENDENT. OpenAI documents the vocabulary below as the union across models and
|
|
10
|
+
// states plainly that "supported values are model-dependent"; there is no offline way to know which
|
|
11
|
+
// subset a given model id accepts. So this module refuses to pretend: it validates that a lab asked
|
|
12
|
+
// for a REAL effort level, and a model that does not support the one it was asked for fails on the
|
|
13
|
+
// first turn with the provider's own message rather than being silently downgraded. Silent
|
|
14
|
+
// downgrade is the worse failure — it would record an effort the run did not actually use.
|
|
15
|
+
/** The documented vocabulary, ordered from least to most reasoning. */
|
|
16
|
+
export const REASONING_EFFORTS = ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
17
|
+
export function isReasoningEffort(value) {
|
|
18
|
+
return typeof value === "string" && REASONING_EFFORTS.includes(value);
|
|
19
|
+
}
|
|
20
|
+
/** For error messages: the vocabulary as an inline list. */
|
|
21
|
+
export function reasoningEffortNames() {
|
|
22
|
+
return REASONING_EFFORTS.join(", ");
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=reasoning-effort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning-effort.js","sourceRoot":"","sources":["../src/reasoning-effort.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,+EAA+E;AAC/E,EAAE;AACF,iGAAiG;AACjG,mGAAmG;AACnG,gGAAgG;AAChG,+CAA+C;AAC/C,EAAE;AACF,mGAAmG;AACnG,oGAAoG;AACpG,oGAAoG;AACpG,mGAAmG;AACnG,2FAA2F;AAC3F,2FAA2F;AAE3F,uEAAuE;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AAIvG,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,iBAAuC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC/F,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,oBAAoB;IAClC,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC"}
|
package/dist/run-detail.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// at the moment it completes.
|
|
14
14
|
import { readFile } from "node:fs/promises";
|
|
15
15
|
import path from "node:path";
|
|
16
|
+
import { estimateActorCost } from "./pricing.js";
|
|
16
17
|
import { resolveRunPath } from "./run.js";
|
|
17
18
|
export const RUN_DETAIL_SCHEMA = "humanish.run-detail.v1";
|
|
18
19
|
/**
|
|
@@ -62,11 +63,34 @@ function participantFrom(stream, index) {
|
|
|
62
63
|
...(typeof trace.counts?.turns === "number" ? { turns: trace.counts.turns } : {}),
|
|
63
64
|
...(typeof trace.counts?.actions === "number" ? { actions: trace.counts.actions } : {}),
|
|
64
65
|
...(thoughts > 0 ? { thoughts } : {}),
|
|
65
|
-
...(trace
|
|
66
|
-
? {}
|
|
67
|
-
: { estimatedCostUsd: trace.estimatedCost.estimatedCostUsd })
|
|
66
|
+
...costOf(trace)
|
|
68
67
|
};
|
|
69
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* What a participant has spent, priced the same way whether the run is finished or in flight.
|
|
71
|
+
*
|
|
72
|
+
* A finished trace carries its own `estimatedCost`. A live one carries the RUNNING usage and the
|
|
73
|
+
* model it prices at, so the same estimator gives a figure mid-run instead of the screen reporting
|
|
74
|
+
* the cost as unknown until the moment the run ends — which is the half of a run where knowing what
|
|
75
|
+
* it is costing actually changes what you do.
|
|
76
|
+
*/
|
|
77
|
+
function costOf(trace) {
|
|
78
|
+
const recorded = trace.estimatedCost?.estimatedCostUsd;
|
|
79
|
+
if (recorded !== undefined)
|
|
80
|
+
return { estimatedCostUsd: recorded };
|
|
81
|
+
const usage = trace.tokenUsage;
|
|
82
|
+
const model = trace.ids?.model;
|
|
83
|
+
if (usage === undefined || typeof model !== "string")
|
|
84
|
+
return {};
|
|
85
|
+
try {
|
|
86
|
+
const estimated = estimateActorCost(usage, model);
|
|
87
|
+
// A model `src/pricing.ts` cannot price yields no figure rather than a wrong one.
|
|
88
|
+
return typeof estimated?.estimatedCostUsd === "number" ? { estimatedCostUsd: estimated.estimatedCostUsd } : {};
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return {};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
70
94
|
/**
|
|
71
95
|
* Read one run's participants. Returns null when the run has no readable bundle yet — an ordinary
|
|
72
96
|
* state for a run that has just started, not a failure.
|
package/dist/run-detail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-detail.js","sourceRoot":"","sources":["../src/run-detail.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,iGAAiG;AACjG,iGAAiG;AACjG,mGAAmG;AACnG,+FAA+F;AAC/F,qCAAqC;AACrC,EAAE;AACF,yFAAyF;AACzF,2EAA2E;AAC3E,2CAA2C;AAC3C,iGAAiG;AACjG,8BAA8B;AAE9B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,wBAAwB,CA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,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAEvF,OAAO;QACL,MAAM,EAAE,iBAAiB;QACzB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK;QAC5B,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QAC1C,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC;YAClC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC,EAAE;YACxD,CAAC,CAAC,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;KACxC,CAAC;AACJ,CAAC"}
|
package/dist/tui-actions.d.ts
CHANGED
|
@@ -14,3 +14,21 @@ export interface TuiActionResult {
|
|
|
14
14
|
* on the machine it lives on.
|
|
15
15
|
*/
|
|
16
16
|
export declare function openObserverArtifact(cwd: string, observerPath: string): Promise<TuiActionResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Stop a run that is still going.
|
|
19
|
+
*
|
|
20
|
+
* The counterpart to starting one: a study that is going nowhere costs money every turn, and until
|
|
21
|
+
* now the only way to end it was to find the pid yourself.
|
|
22
|
+
*
|
|
23
|
+
* It signals the PROCESS GROUP, not the process. A run is spawned detached — its own group — and it
|
|
24
|
+
* has children: the CLI, and whatever it spawned to reach the sandbox. Signalling only the parent
|
|
25
|
+
* leaves those orphaned and still working.
|
|
26
|
+
*
|
|
27
|
+
* SIGTERM, never SIGKILL: the run's own handlers get the chance to finalize its record and release
|
|
28
|
+
* what it holds. A killed run leaves a `running` record to go stale, which reads as interrupted —
|
|
29
|
+
* true, but strictly less informative than a run that was told to stop.
|
|
30
|
+
*
|
|
31
|
+
* This stops the PROCESS. Sandboxes it created are a separate resource with their own receipts, and
|
|
32
|
+
* `Reclaim` is what stops those — the run screen offers it as soon as this succeeds.
|
|
33
|
+
*/
|
|
34
|
+
export declare function stopRun(cwd: string, runId: string): Promise<TuiActionResult>;
|
package/dist/tui-actions.js
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
// and nothing else. `Share…` waits for the export contract (#471) rather than appearing as a
|
|
6
6
|
// control that fails.
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
8
|
-
import { access } from "node:fs/promises";
|
|
8
|
+
import { access, readFile } from "node:fs/promises";
|
|
9
9
|
import path from "node:path";
|
|
10
|
+
import { RUN_STATUS_FILE, isRunStatusRecord } from "./run-status.js";
|
|
11
|
+
import { resolveRunPath } from "./run.js";
|
|
10
12
|
export const TUI_ACTION_SCHEMA = "humanish.tui-action.v1";
|
|
11
13
|
/** The platform's "open this file" command. */
|
|
12
14
|
function opener() {
|
|
@@ -65,4 +67,82 @@ export async function openObserverArtifact(cwd, observerPath) {
|
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Stop a run that is still going.
|
|
72
|
+
*
|
|
73
|
+
* The counterpart to starting one: a study that is going nowhere costs money every turn, and until
|
|
74
|
+
* now the only way to end it was to find the pid yourself.
|
|
75
|
+
*
|
|
76
|
+
* It signals the PROCESS GROUP, not the process. A run is spawned detached — its own group — and it
|
|
77
|
+
* has children: the CLI, and whatever it spawned to reach the sandbox. Signalling only the parent
|
|
78
|
+
* leaves those orphaned and still working.
|
|
79
|
+
*
|
|
80
|
+
* SIGTERM, never SIGKILL: the run's own handlers get the chance to finalize its record and release
|
|
81
|
+
* what it holds. A killed run leaves a `running` record to go stale, which reads as interrupted —
|
|
82
|
+
* true, but strictly less informative than a run that was told to stop.
|
|
83
|
+
*
|
|
84
|
+
* This stops the PROCESS. Sandboxes it created are a separate resource with their own receipts, and
|
|
85
|
+
* `Reclaim` is what stops those — the run screen offers it as soon as this succeeds.
|
|
86
|
+
*/
|
|
87
|
+
export async function stopRun(cwd, runId) {
|
|
88
|
+
const runPaths = await resolveRunPath(path.resolve(cwd), runId).catch(() => null);
|
|
89
|
+
if (runPaths === null) {
|
|
90
|
+
return { schema: TUI_ACTION_SCHEMA, ok: false, message: `no run directory for ${runId}` };
|
|
91
|
+
}
|
|
92
|
+
let record;
|
|
93
|
+
try {
|
|
94
|
+
record = JSON.parse(await readFile(path.join(runPaths.absoluteRunRoot, RUN_STATUS_FILE), "utf8"));
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return {
|
|
98
|
+
schema: TUI_ACTION_SCHEMA,
|
|
99
|
+
ok: false,
|
|
100
|
+
message: "this run has no status record, so there is no pid to stop — it predates the contract or never started"
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (!isRunStatusRecord(record)) {
|
|
104
|
+
return { schema: TUI_ACTION_SCHEMA, ok: false, message: "this run's status record is unreadable" };
|
|
105
|
+
}
|
|
106
|
+
if (record.state === "finished") {
|
|
107
|
+
return { schema: TUI_ACTION_SCHEMA, ok: false, message: "this run already finished" };
|
|
108
|
+
}
|
|
109
|
+
const pid = record.pid;
|
|
110
|
+
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 1) {
|
|
111
|
+
// pid 1 and below are never a run of ours, and signalling them would be catastrophic.
|
|
112
|
+
return { schema: TUI_ACTION_SCHEMA, ok: false, message: "this run recorded no usable pid" };
|
|
113
|
+
}
|
|
114
|
+
// Is it actually still there? A pid whose process is already gone means the run died without
|
|
115
|
+
// finalizing — nothing to stop, and the record will read as interrupted on its own.
|
|
116
|
+
try {
|
|
117
|
+
process.kill(pid, 0);
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return {
|
|
121
|
+
schema: TUI_ACTION_SCHEMA,
|
|
122
|
+
ok: false,
|
|
123
|
+
message: `nothing is running under pid ${pid} — it has already stopped, and its record will read as interrupted`
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
try {
|
|
127
|
+
// Negative pid = the whole process group, which is why the run was spawned detached.
|
|
128
|
+
process.kill(-pid, "SIGTERM");
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
try {
|
|
132
|
+
process.kill(pid, "SIGTERM");
|
|
133
|
+
}
|
|
134
|
+
catch (cause) {
|
|
135
|
+
return {
|
|
136
|
+
schema: TUI_ACTION_SCHEMA,
|
|
137
|
+
ok: false,
|
|
138
|
+
message: `could not stop it: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
schema: TUI_ACTION_SCHEMA,
|
|
144
|
+
ok: true,
|
|
145
|
+
message: "asked the run to stop — its sandboxes are separate, so Reclaim them once it reports interrupted"
|
|
146
|
+
};
|
|
147
|
+
}
|
|
68
148
|
//# sourceMappingURL=tui-actions.js.map
|
package/dist/tui-actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui-actions.js","sourceRoot":"","sources":["../src/tui-actions.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,mGAAmG;AACnG,iGAAiG;AACjG,6FAA6F;AAC7F,sBAAsB;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"tui-actions.js","sourceRoot":"","sources":["../src/tui-actions.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,mGAAmG;AACnG,iGAAiG;AACjG,6FAA6F;AAC7F,sBAAsB;AAEtB,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC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