@botlearn-course/daemon 0.0.29-beta.3 → 0.0.29-beta.5
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/README.md +29 -89
- package/dist/auth-store.d.ts +1 -11
- package/dist/auth-store.js +2 -83
- package/dist/cli.d.ts +0 -15
- package/dist/cli.js +12 -204
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/run-dispatcher.d.ts +1 -5
- package/dist/run-dispatcher.js +41 -116
- package/dist/runtime-capabilities.js +3 -11
- package/dist/runtimes/engine.js +15 -52
- package/dist/runtimes/index.d.ts +1 -7
- package/dist/runtimes/index.js +1 -45
- package/dist/runtimes/pi-agent.js +38 -7
- package/dist/runtimes/pi-managed-launch.d.ts +5 -0
- package/dist/runtimes/pi-managed-launch.js +41 -0
- package/dist/runtimes/pi-managed-subagent-extension.d.ts +127 -0
- package/dist/runtimes/pi-managed-subagent-extension.js +300 -0
- package/dist/runtimes/pi-managed.d.ts +16 -2
- package/dist/runtimes/pi-managed.js +38 -16
- package/dist/runtimes/probe.d.ts +0 -5
- package/dist/runtimes/probe.js +0 -16
- package/dist/types.d.ts +10 -73
- package/dist/workspace.d.ts +0 -2
- package/dist/workspace.js +0 -10
- package/package.json +2 -2
- package/dist/course-client.d.ts +0 -46
- package/dist/course-client.js +0 -158
- package/dist/doctor.d.ts +0 -15
- package/dist/doctor.js +0 -85
- package/dist/runtime-profile.d.ts +0 -8
- package/dist/runtime-profile.js +0 -236
- package/dist/runtimes/acp-stream.d.ts +0 -96
- package/dist/runtimes/acp-stream.js +0 -490
- package/dist/runtimes/claude-code.d.ts +0 -41
- package/dist/runtimes/claude-code.js +0 -364
- package/dist/runtimes/codex.d.ts +0 -44
- package/dist/runtimes/codex.js +0 -348
- package/dist/runtimes/gemini.d.ts +0 -39
- package/dist/runtimes/gemini.js +0 -264
- package/dist/runtimes/hermes-agent.d.ts +0 -61
- package/dist/runtimes/hermes-agent.js +0 -191
- package/dist/runtimes/kimi.d.ts +0 -35
- package/dist/runtimes/kimi.js +0 -343
- package/dist/runtimes/native-tool-blocks.d.ts +0 -3
- package/dist/runtimes/native-tool-blocks.js +0 -98
- package/dist/runtimes/ndjson-stream.d.ts +0 -48
- package/dist/runtimes/ndjson-stream.js +0 -210
- package/dist/runtimes/openclaw-acp.d.ts +0 -52
- package/dist/runtimes/openclaw-acp.js +0 -893
- package/dist/runtimes/runtime-errors.d.ts +0 -20
- package/dist/runtimes/runtime-errors.js +0 -95
- package/dist/runtimes/text-cap.d.ts +0 -7
- package/dist/runtimes/text-cap.js +0 -25
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime CLIs sometimes report authentication failures as ordinary final
|
|
3
|
-
* text. Keep this intentionally narrow so normal model replies about auth do
|
|
4
|
-
* not get reclassified unless they look like a top-level CLI/API failure.
|
|
5
|
-
*/
|
|
6
|
-
export declare function looksLikeRuntimeAuthFailure(text: string): boolean;
|
|
7
|
-
export declare function looksLikeUsageLimit(text: string): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Pull the reset hint straight out of the runtime's own words — never compute it
|
|
10
|
-
* locally, since the runtime already knows the user's plan window and timezone
|
|
11
|
-
* and we do not. Returns a ready-to-render fragment: an absolute clock time like
|
|
12
|
-
* "2pm (America/New_York)", a relative "in 3h 42m", or null when the runtime
|
|
13
|
-
* gave no hint.
|
|
14
|
-
*/
|
|
15
|
-
export declare function extractUsageLimitReset(text: string): string | null;
|
|
16
|
-
/**
|
|
17
|
-
* Compose the calm, user-facing line for a usage/rate-limit error. Callers
|
|
18
|
-
* should gate on {@link looksLikeUsageLimit} first.
|
|
19
|
-
*/
|
|
20
|
-
export declare function formatUsageLimitMessage(text: string, runtime?: string): string;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime CLIs sometimes report authentication failures as ordinary final
|
|
3
|
-
* text. Keep this intentionally narrow so normal model replies about auth do
|
|
4
|
-
* not get reclassified unless they look like a top-level CLI/API failure.
|
|
5
|
-
*/
|
|
6
|
-
export function looksLikeRuntimeAuthFailure(text) {
|
|
7
|
-
const s = text.trim();
|
|
8
|
-
if (!s)
|
|
9
|
-
return false;
|
|
10
|
-
return (/^(Failed to authenticate|Authentication failed|Invalid API key|Invalid Anthropic API key)\b/i.test(s) ||
|
|
11
|
-
/^API Error:\s*4\d\d\b/i.test(s) ||
|
|
12
|
-
/\b(API Error:\s*4\d\d|Request not allowed|invalid x-api-key)\b/i.test(s) ||
|
|
13
|
-
/^(Unauthorized|Forbidden)(?:\b|:)/i.test(s));
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Usage / rate-limit exhaustion is reported by runtimes as ordinary error text,
|
|
17
|
-
* not a distinct status. Claude Code emits "Claude usage limit reached. Your
|
|
18
|
-
* limit will reset at 2pm (America/New_York)"; Codex emits "You've reached your
|
|
19
|
-
* 5-hour message limit. Try again in 3h 42m." or a bare
|
|
20
|
-
* `{"type":"error","error":{"type":"usage_limit_reached",...}}` blob. Detect it
|
|
21
|
-
* so the dispatcher can surface a calm, reset-time-forward sentence instead of a
|
|
22
|
-
* red "Runtime error" wrapped in an exit code and an error_ref.
|
|
23
|
-
*/
|
|
24
|
-
const USAGE_LIMIT_PATTERNS = [
|
|
25
|
-
/usage[_\s-]?limit[_\s-]?reached/i,
|
|
26
|
-
/\b\d+-hour (?:message )?limit\b/i,
|
|
27
|
-
/you'?ve (?:hit|reached) your (?:usage |message |daily |weekly )*limit/i,
|
|
28
|
-
/\binsufficient_quota\b/i,
|
|
29
|
-
/\bquota (?:exceeded|exhausted|reached)\b/i,
|
|
30
|
-
/\brate[_\s-]?limit(?:_?(?:exceeded|error)|ed|\s+(?:reached|exceeded|hit))/i,
|
|
31
|
-
];
|
|
32
|
-
export function looksLikeUsageLimit(text) {
|
|
33
|
-
const s = text?.trim();
|
|
34
|
-
if (!s)
|
|
35
|
-
return false;
|
|
36
|
-
return USAGE_LIMIT_PATTERNS.some((re) => re.test(s));
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Pull the reset hint straight out of the runtime's own words — never compute it
|
|
40
|
-
* locally, since the runtime already knows the user's plan window and timezone
|
|
41
|
-
* and we do not. Returns a ready-to-render fragment: an absolute clock time like
|
|
42
|
-
* "2pm (America/New_York)", a relative "in 3h 42m", or null when the runtime
|
|
43
|
-
* gave no hint.
|
|
44
|
-
*/
|
|
45
|
-
export function extractUsageLimitReset(text) {
|
|
46
|
-
const s = (text ?? "").trim();
|
|
47
|
-
if (!s)
|
|
48
|
-
return null;
|
|
49
|
-
// Absolute: "...reset at 2pm (America/New_York)" /
|
|
50
|
-
// "reset at approximately 11:00 PM Europe/Berlin time"
|
|
51
|
-
const at = s.match(/reset(?:s|ting)?\s+at\s+(?:approximately\s+)?(.+?)(?:\s+time\b)?\s*(?:[.,\n]|$)/i);
|
|
52
|
-
if (at?.[1])
|
|
53
|
-
return collapseWs(at[1]);
|
|
54
|
-
// Relative: "Try again in 3h 42m" / "please try again after 5 minutes"
|
|
55
|
-
const rel = s.match(/try again (?:in|after)\s+(.+?)\s*(?:[.,\n]|$)/i);
|
|
56
|
-
if (rel?.[1])
|
|
57
|
-
return `in ${collapseWs(rel[1])}`;
|
|
58
|
-
// Legacy Claude headless pipe form: "...reached|1719345600"
|
|
59
|
-
const pipe = s.match(/reached\s*\|\s*(\d{10,13})/);
|
|
60
|
-
if (pipe?.[1]) {
|
|
61
|
-
const ms = pipe[1].length >= 13 ? Number(pipe[1]) : Number(pipe[1]) * 1000;
|
|
62
|
-
if (Number.isFinite(ms))
|
|
63
|
-
return `${new Date(ms).toISOString().replace("T", " ").slice(0, 16)} UTC`;
|
|
64
|
-
}
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Compose the calm, user-facing line for a usage/rate-limit error. Callers
|
|
69
|
-
* should gate on {@link looksLikeUsageLimit} first.
|
|
70
|
-
*/
|
|
71
|
-
export function formatUsageLimitMessage(text, runtime) {
|
|
72
|
-
const who = runtimeLabel(runtime);
|
|
73
|
-
const reset = extractUsageLimitReset(text);
|
|
74
|
-
if (reset) {
|
|
75
|
-
const when = /^in\s/i.test(reset) ? `resets ${reset}` : `resets at ${reset}`;
|
|
76
|
-
return `${who} usage limit reached — ${when}.`;
|
|
77
|
-
}
|
|
78
|
-
return `${who} usage limit reached — please try again later.`;
|
|
79
|
-
}
|
|
80
|
-
function runtimeLabel(runtime) {
|
|
81
|
-
switch ((runtime ?? "").toLowerCase()) {
|
|
82
|
-
case "claude-code":
|
|
83
|
-
case "claude":
|
|
84
|
-
return "Claude Code";
|
|
85
|
-
case "codex":
|
|
86
|
-
return "Codex";
|
|
87
|
-
case "gemini":
|
|
88
|
-
return "Gemini";
|
|
89
|
-
default:
|
|
90
|
-
return "Agent runtime";
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function collapseWs(s) {
|
|
94
|
-
return s.replace(/\s+/g, " ").trim();
|
|
95
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** Return the UTF-8 byte length of a string. */
|
|
2
|
-
export declare function utf8ByteLength(text: string): number;
|
|
3
|
-
/**
|
|
4
|
-
* Slice a string to at most `maxBytes` UTF-8 bytes without splitting a code
|
|
5
|
-
* point. Used by runtime adapters whose safety caps are byte-oriented.
|
|
6
|
-
*/
|
|
7
|
-
export declare function sliceUtf8Bytes(text: string, maxBytes: number): string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Buffer } from "node:buffer";
|
|
2
|
-
/** Return the UTF-8 byte length of a string. */
|
|
3
|
-
export function utf8ByteLength(text) {
|
|
4
|
-
return Buffer.byteLength(text, "utf8");
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Slice a string to at most `maxBytes` UTF-8 bytes without splitting a code
|
|
8
|
-
* point. Used by runtime adapters whose safety caps are byte-oriented.
|
|
9
|
-
*/
|
|
10
|
-
export function sliceUtf8Bytes(text, maxBytes) {
|
|
11
|
-
if (maxBytes <= 0)
|
|
12
|
-
return "";
|
|
13
|
-
if (utf8ByteLength(text) <= maxBytes)
|
|
14
|
-
return text;
|
|
15
|
-
let used = 0;
|
|
16
|
-
let out = "";
|
|
17
|
-
for (const ch of text) {
|
|
18
|
-
const n = utf8ByteLength(ch);
|
|
19
|
-
if (used + n > maxBytes)
|
|
20
|
-
break;
|
|
21
|
-
out += ch;
|
|
22
|
-
used += n;
|
|
23
|
-
}
|
|
24
|
-
return out;
|
|
25
|
-
}
|