@uselemma/opencode 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/README.md +3 -1
- package/package.json +12 -2
- package/runtime/lemma.mjs +48 -22
package/README.md
CHANGED
|
@@ -47,9 +47,11 @@ Sensitive keys, authorization values, common provider tokens, credential-bearing
|
|
|
47
47
|
|
|
48
48
|
## Verification
|
|
49
49
|
|
|
50
|
+
`runtime/` and `scripts/` are generated by `pnpm --filter @uselemma/opencode build`. They are not committed. CI, `verify:local`, and publish build them before test, pack, and npm publish.
|
|
51
|
+
|
|
50
52
|
```bash
|
|
51
53
|
pnpm --filter @uselemma/opencode type-check
|
|
52
|
-
pnpm --filter @uselemma/opencode test
|
|
53
54
|
pnpm --filter @uselemma/opencode build
|
|
55
|
+
pnpm --filter @uselemma/opencode test
|
|
54
56
|
pnpm --filter @uselemma/opencode verify:local
|
|
55
57
|
```
|
package/package.json
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uselemma/opencode",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Lemma SDK tracing for OpenCode coding-agent sessions",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"author": "Lemma",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/uselemma/lemma",
|
|
10
|
+
"directory": "plugins/lemma-opencode"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/uselemma/lemma/tree/main/plugins/lemma-opencode#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/uselemma/lemma/issues"
|
|
15
|
+
},
|
|
6
16
|
"type": "module",
|
|
7
17
|
"main": "./runtime/lemma.mjs",
|
|
8
18
|
"types": "./runtime/lemma.d.ts",
|
|
@@ -29,7 +39,7 @@
|
|
|
29
39
|
],
|
|
30
40
|
"dependencies": {
|
|
31
41
|
"@opencode-ai/plugin": "1.18.19",
|
|
32
|
-
"@uselemma/tracing": "^7.11.
|
|
42
|
+
"@uselemma/tracing": "^7.11.1"
|
|
33
43
|
},
|
|
34
44
|
"devDependencies": {
|
|
35
45
|
"@opencode-ai/sdk": "1.18.19",
|
package/runtime/lemma.mjs
CHANGED
|
@@ -1620,31 +1620,57 @@ var require_tool_result = __commonJS({
|
|
|
1620
1620
|
const record = asResultRecord(output);
|
|
1621
1621
|
if (!record)
|
|
1622
1622
|
return null;
|
|
1623
|
-
if (record
|
|
1624
|
-
|
|
1625
|
-
}
|
|
1626
|
-
const content = record.content;
|
|
1627
|
-
if (Array.isArray(content)) {
|
|
1628
|
-
const text = content.map((part) => {
|
|
1629
|
-
if (!part || typeof part !== "object")
|
|
1630
|
-
return "";
|
|
1631
|
-
const textValue = part.text;
|
|
1632
|
-
return typeof textValue === "string" ? textValue : "";
|
|
1633
|
-
}).filter(Boolean).join("\n").trim();
|
|
1623
|
+
if (isFlaggedFailure(record)) {
|
|
1624
|
+
const text = contentText(record.content);
|
|
1634
1625
|
if (text)
|
|
1635
1626
|
return text;
|
|
1627
|
+
const flaggedError = nonEmptyString(record.error);
|
|
1628
|
+
if (flaggedError)
|
|
1629
|
+
return flaggedError;
|
|
1630
|
+
const message = nonEmptyString(record.message);
|
|
1631
|
+
if (message)
|
|
1632
|
+
return message;
|
|
1633
|
+
try {
|
|
1634
|
+
return JSON.stringify(record);
|
|
1635
|
+
} catch {
|
|
1636
|
+
return "Tool returned an error result";
|
|
1637
|
+
}
|
|
1636
1638
|
}
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1639
|
+
return encodedPayloadError(record);
|
|
1640
|
+
}
|
|
1641
|
+
function isFlaggedFailure(record) {
|
|
1642
|
+
return record.isError === true || record.is_error === true || record.error === true;
|
|
1643
|
+
}
|
|
1644
|
+
function encodedPayloadError(record) {
|
|
1645
|
+
const direct = nonEmptyString(record.error);
|
|
1646
|
+
if (direct)
|
|
1647
|
+
return direct;
|
|
1648
|
+
const structured = asResultRecord(record.structuredContent);
|
|
1649
|
+
const nested = structured ? nonEmptyString(structured.error) : null;
|
|
1650
|
+
if (nested)
|
|
1651
|
+
return nested;
|
|
1652
|
+
const text = contentText(record.content);
|
|
1653
|
+
if (!text)
|
|
1654
|
+
return null;
|
|
1655
|
+
const parsed = asResultRecord(text);
|
|
1656
|
+
return parsed ? nonEmptyString(parsed.error) : null;
|
|
1657
|
+
}
|
|
1658
|
+
function contentText(content) {
|
|
1659
|
+
if (!Array.isArray(content))
|
|
1660
|
+
return null;
|
|
1661
|
+
const text = content.map((part) => {
|
|
1662
|
+
if (!part || typeof part !== "object")
|
|
1663
|
+
return "";
|
|
1664
|
+
const textValue = part.text;
|
|
1665
|
+
return typeof textValue === "string" ? textValue : "";
|
|
1666
|
+
}).filter(Boolean).join("\n").trim();
|
|
1667
|
+
return text || null;
|
|
1668
|
+
}
|
|
1669
|
+
function nonEmptyString(value) {
|
|
1670
|
+
if (typeof value !== "string")
|
|
1671
|
+
return null;
|
|
1672
|
+
const trimmed = value.trim();
|
|
1673
|
+
return trimmed ? trimmed : null;
|
|
1648
1674
|
}
|
|
1649
1675
|
function asResultRecord(output) {
|
|
1650
1676
|
if (output == null)
|