@rethinkingstudio/clawpilot 1.1.16 → 1.1.17-beta.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.
|
@@ -4,9 +4,43 @@ function isDirectMainSession(session) {
|
|
|
4
4
|
session.kind === "direct" &&
|
|
5
5
|
!session.key.includes(":cron:"));
|
|
6
6
|
}
|
|
7
|
+
function extractJsonPayload(raw) {
|
|
8
|
+
const trimmed = raw.trim();
|
|
9
|
+
if (!trimmed) {
|
|
10
|
+
throw new Error("openclaw status returned empty output");
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
JSON.parse(trimmed);
|
|
14
|
+
return trimmed;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Fall through and try to extract the trailing JSON payload from noisy output.
|
|
18
|
+
}
|
|
19
|
+
const firstObjectIndex = trimmed.indexOf("{");
|
|
20
|
+
const firstArrayIndex = trimmed.indexOf("[");
|
|
21
|
+
const startCandidates = [firstObjectIndex, firstArrayIndex].filter(index => index >= 0);
|
|
22
|
+
const startIndex = startCandidates.length > 0 ? Math.min(...startCandidates) : -1;
|
|
23
|
+
if (startIndex < 0) {
|
|
24
|
+
throw new Error(`openclaw status did not return JSON: ${trimmed}`);
|
|
25
|
+
}
|
|
26
|
+
for (let index = startIndex; index < trimmed.length; index += 1) {
|
|
27
|
+
const ch = trimmed[index];
|
|
28
|
+
if (ch !== "{" && ch !== "[")
|
|
29
|
+
continue;
|
|
30
|
+
const candidate = trimmed.slice(index);
|
|
31
|
+
try {
|
|
32
|
+
JSON.parse(candidate);
|
|
33
|
+
return candidate;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Keep scanning for the real JSON start.
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`openclaw status returned invalid JSON: ${trimmed}`);
|
|
40
|
+
}
|
|
7
41
|
function parseStatus() {
|
|
8
42
|
const raw = execOpenclaw("status --json").toString("utf8").trim();
|
|
9
|
-
return JSON.parse(raw);
|
|
43
|
+
return JSON.parse(extractJsonPayload(raw));
|
|
10
44
|
}
|
|
11
45
|
export function resolveSessionKeyFromStatus() {
|
|
12
46
|
const status = parseStatus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-key.js","sourceRoot":"","sources":["../../src/commands/session-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAcjD,SAAS,mBAAmB,CAAC,OAAkC;IAC7D,OAAO,OAAO,CACZ,OAAO,EAAE,GAAG;QACZ,OAAO,CAAC,IAAI,KAAK,QAAQ;QACzB,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAChC,CAAC;AACJ,CAAC;AAED,SAAS,WAAW;IAClB,MAAM,GAAG,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAClE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"session-key.js","sourceRoot":"","sources":["../../src/commands/session-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAcjD,SAAS,mBAAmB,CAAC,OAAkC;IAC7D,OAAO,OAAO,CACZ,OAAO,EAAE,GAAG;QACZ,OAAO,CAAC,IAAI,KAAK,QAAQ;QACzB,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAChC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACrC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,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CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAClE,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAkB,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACjC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC5D,IAAI,QAAQ,EAAE,GAAG,EAAE,CAAC;QAClB,OAAO,QAAQ,CAAC,GAAG,CAAC;IACtB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;AACxF,CAAC"}
|
package/package.json
CHANGED
|
@@ -20,9 +20,45 @@ function isDirectMainSession(session: StatusSession | undefined): session is Sta
|
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
function extractJsonPayload(raw: string): string {
|
|
24
|
+
const trimmed = raw.trim();
|
|
25
|
+
if (!trimmed) {
|
|
26
|
+
throw new Error("openclaw status returned empty output");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
JSON.parse(trimmed);
|
|
31
|
+
return trimmed;
|
|
32
|
+
} catch {
|
|
33
|
+
// Fall through and try to extract the trailing JSON payload from noisy output.
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const firstObjectIndex = trimmed.indexOf("{");
|
|
37
|
+
const firstArrayIndex = trimmed.indexOf("[");
|
|
38
|
+
const startCandidates = [firstObjectIndex, firstArrayIndex].filter(index => index >= 0);
|
|
39
|
+
const startIndex = startCandidates.length > 0 ? Math.min(...startCandidates) : -1;
|
|
40
|
+
if (startIndex < 0) {
|
|
41
|
+
throw new Error(`openclaw status did not return JSON: ${trimmed}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
for (let index = startIndex; index < trimmed.length; index += 1) {
|
|
45
|
+
const ch = trimmed[index];
|
|
46
|
+
if (ch !== "{" && ch !== "[") continue;
|
|
47
|
+
const candidate = trimmed.slice(index);
|
|
48
|
+
try {
|
|
49
|
+
JSON.parse(candidate);
|
|
50
|
+
return candidate;
|
|
51
|
+
} catch {
|
|
52
|
+
// Keep scanning for the real JSON start.
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
throw new Error(`openclaw status returned invalid JSON: ${trimmed}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
23
59
|
function parseStatus(): StatusPayload {
|
|
24
60
|
const raw = execOpenclaw("status --json").toString("utf8").trim();
|
|
25
|
-
return JSON.parse(raw) as StatusPayload;
|
|
61
|
+
return JSON.parse(extractJsonPayload(raw)) as StatusPayload;
|
|
26
62
|
}
|
|
27
63
|
|
|
28
64
|
export function resolveSessionKeyFromStatus(): string {
|