clavarium 0.2.516-next.1 → 0.2.517-next.1
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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/signinhelp.mjs +7 -4
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.517-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.517-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/signinhelp.mjs
CHANGED
|
@@ -200,10 +200,11 @@ export class SigninHelp {
|
|
|
200
200
|
/* STILL AT ITS PROMPT (22-11, a wrong code on a real machine): the ask stays, so that the field can be used
|
|
201
201
|
again and nothing else is typed into that prompt meanwhile. */
|
|
202
202
|
const end = Date.now() + this.codeSettleMs;
|
|
203
|
-
|
|
203
|
+
const still = () => this.atCodePrompt(name, exec, { last: 3 }).catch(() => false);
|
|
204
|
+
let waiting = await still();
|
|
204
205
|
while (waiting && Date.now() < end) {
|
|
205
206
|
await new Promise((r) => { setTimeout(r, 1000).unref?.(); });
|
|
206
|
-
waiting = await
|
|
207
|
+
waiting = await still();
|
|
207
208
|
}
|
|
208
209
|
if (waiting) throw new Refusal(422, 'The tool did not accept this code.');
|
|
209
210
|
/* Accepted: the ask is over, whatever comes next is not this code. */
|
|
@@ -227,7 +228,7 @@ export class SigninHelp {
|
|
|
227
228
|
}
|
|
228
229
|
/* ITS TOOL IS AT ITS « PASTE THE CODE » PROMPT (22-11, seen on a real machine): a line typed now goes into that field
|
|
229
230
|
and the sign-in fails. Asked of its screen, only while a sign-in is open and its tool has such a prompt. */
|
|
230
|
-
async atCodePrompt(name, exec) {
|
|
231
|
+
async atCodePrompt(name, exec, { last = 0 } = {}) {
|
|
231
232
|
const ask = this.#readAsk(name); if (!ask) return false;
|
|
232
233
|
const at = Date.parse(ask.at); if (!Number.isFinite(at) || this.#now() - at > CODE_WAIT_MS) return false;
|
|
233
234
|
const rules = (this.#tool(name)?.signin?.screen ?? []).filter((r) => String(r).startsWith('code:')).map((r) => String(r).slice(5));
|
|
@@ -236,7 +237,9 @@ export class SigninHelp {
|
|
|
236
237
|
if (r.code !== 0) return false;
|
|
237
238
|
/* As screen-watch reads it: the bottom of the screen, whatever the case. A prompt left higher up is over, and a
|
|
238
239
|
code typed then would go to the AI as a message. */
|
|
239
|
-
const
|
|
240
|
+
const lines = String(r.stdout).replace(/\s+$/u, '').split('\n');
|
|
241
|
+
/* `last`: only its last written lines: a prompt the tool has answered and moved on from stays higher up. */
|
|
242
|
+
const bottom = (last ? lines.filter((l) => l.trim()).slice(-last) : lines.slice(-SCREEN_LINES)).join('\n');
|
|
240
243
|
return rules.some((p) => { try { return new RegExp(p, 'i').test(bottom); } catch { return false; } });
|
|
241
244
|
}
|
|
242
245
|
#readRoute(name) { try { return JSON.parse(readFileSync(join(this.#chat(name), ROUTE), 'utf8')); } catch { return null; } }
|