@raindrop-ai/opencode-plugin 0.0.3 → 0.0.4
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/index.cjs +73 -8
- package/dist/index.js +73 -8
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -49,12 +49,72 @@ function loadConfig(projectDirectory) {
|
|
|
49
49
|
writeKey: (_b = (_a = process.env["RAINDROP_WRITE_KEY"]) != null ? _a : merged.write_key) != null ? _b : "",
|
|
50
50
|
endpoint: (_d = (_c = process.env["RAINDROP_API_URL"]) != null ? _c : merged.api_url) != null ? _d : "https://api.raindrop.ai/v1",
|
|
51
51
|
eventName: (_e = merged.event_name) != null ? _e : "opencode_session",
|
|
52
|
-
userId: merged.user_id,
|
|
53
52
|
debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (_f = merged.debug) != null ? _f : false
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
|
|
56
|
+
// package.json
|
|
57
|
+
var package_default = {
|
|
58
|
+
name: "@raindrop-ai/opencode-plugin",
|
|
59
|
+
version: "0.0.4",
|
|
60
|
+
description: "Raindrop observability plugin for OpenCode \u2014 automatic session/event/span tracing",
|
|
61
|
+
type: "module",
|
|
62
|
+
main: "dist/index.cjs",
|
|
63
|
+
module: "dist/index.js",
|
|
64
|
+
types: "dist/index.d.ts",
|
|
65
|
+
exports: {
|
|
66
|
+
".": {
|
|
67
|
+
types: "./dist/index.d.ts",
|
|
68
|
+
import: "./dist/index.js",
|
|
69
|
+
require: "./dist/index.cjs"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
sideEffects: false,
|
|
73
|
+
files: [
|
|
74
|
+
"dist/**"
|
|
75
|
+
],
|
|
76
|
+
scripts: {
|
|
77
|
+
build: "tsup",
|
|
78
|
+
dev: "tsup --watch",
|
|
79
|
+
clean: "rm -rf dist",
|
|
80
|
+
test: "cd tests && yarn test"
|
|
81
|
+
},
|
|
82
|
+
peerDependencies: {
|
|
83
|
+
"@opencode-ai/plugin": ">=1.2.0",
|
|
84
|
+
"@opencode-ai/sdk": ">=1.2.0"
|
|
85
|
+
},
|
|
86
|
+
peerDependenciesMeta: {
|
|
87
|
+
"@opencode-ai/sdk": {
|
|
88
|
+
optional: true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
devDependencies: {
|
|
92
|
+
"@opencode-ai/plugin": "^1.2.0",
|
|
93
|
+
"@opencode-ai/sdk": "^1.2.0",
|
|
94
|
+
"@types/node": "^20.11.17",
|
|
95
|
+
tsup: "^8.4.0",
|
|
96
|
+
typescript: "^5.3.3"
|
|
97
|
+
},
|
|
98
|
+
tsup: {
|
|
99
|
+
entry: [
|
|
100
|
+
"src/index.ts"
|
|
101
|
+
],
|
|
102
|
+
format: [
|
|
103
|
+
"cjs",
|
|
104
|
+
"esm"
|
|
105
|
+
],
|
|
106
|
+
dts: {
|
|
107
|
+
resolve: true
|
|
108
|
+
},
|
|
109
|
+
clean: true
|
|
110
|
+
},
|
|
111
|
+
publishConfig: {
|
|
112
|
+
access: "public"
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
57
116
|
// src/shipper.ts
|
|
117
|
+
var PLUGIN_VERSION = package_default.version;
|
|
58
118
|
function getCryptoObj() {
|
|
59
119
|
return globalThis.crypto;
|
|
60
120
|
}
|
|
@@ -94,7 +154,6 @@ function base64Encode(bytes) {
|
|
|
94
154
|
return out;
|
|
95
155
|
}
|
|
96
156
|
var SERVICE_NAME = "raindrop.opencode-plugin";
|
|
97
|
-
var PLUGIN_VERSION = "0.1.0";
|
|
98
157
|
var SpanStatusCode = {
|
|
99
158
|
ERROR: 2
|
|
100
159
|
};
|
|
@@ -111,7 +170,7 @@ function createSpanIds(parent) {
|
|
|
111
170
|
};
|
|
112
171
|
}
|
|
113
172
|
function nowUnixNanoString() {
|
|
114
|
-
return
|
|
173
|
+
return Date.now().toString() + "000000";
|
|
115
174
|
}
|
|
116
175
|
function attrString(key, value) {
|
|
117
176
|
if (value === void 0) return void 0;
|
|
@@ -633,8 +692,8 @@ function getHostname() {
|
|
|
633
692
|
}
|
|
634
693
|
function createHooks(config, worktree, directory, eventShipper, traceShipper) {
|
|
635
694
|
function log(msg, data) {
|
|
636
|
-
|
|
637
|
-
const prefix = `[raindrop-ai/opencode-plugin] [
|
|
695
|
+
if (!config.debug) return;
|
|
696
|
+
const prefix = `[raindrop-ai/opencode-plugin] [info] ${msg}`;
|
|
638
697
|
if (data !== void 0) {
|
|
639
698
|
console.log(prefix, data);
|
|
640
699
|
return;
|
|
@@ -805,7 +864,7 @@ type: ${name != null ? name : "UnknownError"}`;
|
|
|
805
864
|
attributes: llmAttrs
|
|
806
865
|
});
|
|
807
866
|
if (typeof timeObj["created"] === "number") {
|
|
808
|
-
llmSpan.startTimeUnixNano = String(timeObj["created"]
|
|
867
|
+
llmSpan.startTimeUnixNano = String(Math.floor(timeObj["created"])) + "000000";
|
|
809
868
|
}
|
|
810
869
|
traceShipper.endSpan(llmSpan, { error: errorForSpan });
|
|
811
870
|
await traceShipper.flush();
|
|
@@ -842,7 +901,7 @@ type: ${name != null ? name : "UnknownError"}`;
|
|
|
842
901
|
attributes: llmAttrs
|
|
843
902
|
});
|
|
844
903
|
if (typeof timeObj["created"] === "number") {
|
|
845
|
-
finalLlmSpan.startTimeUnixNano = String(timeObj["created"]
|
|
904
|
+
finalLlmSpan.startTimeUnixNano = String(Math.floor(timeObj["created"])) + "000000";
|
|
846
905
|
}
|
|
847
906
|
traceShipper.endSpan(finalLlmSpan, { error: errorForSpan });
|
|
848
907
|
traceShipper.endSpan(rootSpan, {
|
|
@@ -902,7 +961,7 @@ type: ${name != null ? name : "UnknownError"}`;
|
|
|
902
961
|
if (state.currentEventId) {
|
|
903
962
|
state.currentEventId = void 0;
|
|
904
963
|
}
|
|
905
|
-
await traceShipper.flush();
|
|
964
|
+
await Promise.all([eventShipper.flush(), traceShipper.flush()]);
|
|
906
965
|
if (state.parentId) {
|
|
907
966
|
cleanupSessionParentMap(String(sessionID));
|
|
908
967
|
sessions.delete(String(sessionID));
|
|
@@ -1099,6 +1158,9 @@ type: ${errorName != null ? errorName : "UnknownError"}`;
|
|
|
1099
1158
|
});
|
|
1100
1159
|
}
|
|
1101
1160
|
} catch (err) {
|
|
1161
|
+
console.log(
|
|
1162
|
+
`[raindrop-ai/opencode-plugin] [error] Error in tool.execute.before hook: ${err instanceof Error ? err.message : String(err)}`
|
|
1163
|
+
);
|
|
1102
1164
|
}
|
|
1103
1165
|
},
|
|
1104
1166
|
// ------------------------------------------------------------------
|
|
@@ -1170,6 +1232,9 @@ type: ${errorName != null ? errorName : "UnknownError"}`;
|
|
|
1170
1232
|
});
|
|
1171
1233
|
}
|
|
1172
1234
|
} catch (err) {
|
|
1235
|
+
console.log(
|
|
1236
|
+
`[raindrop-ai/opencode-plugin] [error] Error in tool.execute.after hook: ${err instanceof Error ? err.message : String(err)}`
|
|
1237
|
+
);
|
|
1173
1238
|
}
|
|
1174
1239
|
}
|
|
1175
1240
|
};
|
package/dist/index.js
CHANGED
|
@@ -30,12 +30,72 @@ function loadConfig(projectDirectory) {
|
|
|
30
30
|
writeKey: (_b = (_a = process.env["RAINDROP_WRITE_KEY"]) != null ? _a : merged.write_key) != null ? _b : "",
|
|
31
31
|
endpoint: (_d = (_c = process.env["RAINDROP_API_URL"]) != null ? _c : merged.api_url) != null ? _d : "https://api.raindrop.ai/v1",
|
|
32
32
|
eventName: (_e = merged.event_name) != null ? _e : "opencode_session",
|
|
33
|
-
userId: merged.user_id,
|
|
34
33
|
debug: process.env["RAINDROP_DEBUG"] === "true" ? true : (_f = merged.debug) != null ? _f : false
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
36
|
|
|
37
|
+
// package.json
|
|
38
|
+
var package_default = {
|
|
39
|
+
name: "@raindrop-ai/opencode-plugin",
|
|
40
|
+
version: "0.0.4",
|
|
41
|
+
description: "Raindrop observability plugin for OpenCode \u2014 automatic session/event/span tracing",
|
|
42
|
+
type: "module",
|
|
43
|
+
main: "dist/index.cjs",
|
|
44
|
+
module: "dist/index.js",
|
|
45
|
+
types: "dist/index.d.ts",
|
|
46
|
+
exports: {
|
|
47
|
+
".": {
|
|
48
|
+
types: "./dist/index.d.ts",
|
|
49
|
+
import: "./dist/index.js",
|
|
50
|
+
require: "./dist/index.cjs"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
sideEffects: false,
|
|
54
|
+
files: [
|
|
55
|
+
"dist/**"
|
|
56
|
+
],
|
|
57
|
+
scripts: {
|
|
58
|
+
build: "tsup",
|
|
59
|
+
dev: "tsup --watch",
|
|
60
|
+
clean: "rm -rf dist",
|
|
61
|
+
test: "cd tests && yarn test"
|
|
62
|
+
},
|
|
63
|
+
peerDependencies: {
|
|
64
|
+
"@opencode-ai/plugin": ">=1.2.0",
|
|
65
|
+
"@opencode-ai/sdk": ">=1.2.0"
|
|
66
|
+
},
|
|
67
|
+
peerDependenciesMeta: {
|
|
68
|
+
"@opencode-ai/sdk": {
|
|
69
|
+
optional: true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
devDependencies: {
|
|
73
|
+
"@opencode-ai/plugin": "^1.2.0",
|
|
74
|
+
"@opencode-ai/sdk": "^1.2.0",
|
|
75
|
+
"@types/node": "^20.11.17",
|
|
76
|
+
tsup: "^8.4.0",
|
|
77
|
+
typescript: "^5.3.3"
|
|
78
|
+
},
|
|
79
|
+
tsup: {
|
|
80
|
+
entry: [
|
|
81
|
+
"src/index.ts"
|
|
82
|
+
],
|
|
83
|
+
format: [
|
|
84
|
+
"cjs",
|
|
85
|
+
"esm"
|
|
86
|
+
],
|
|
87
|
+
dts: {
|
|
88
|
+
resolve: true
|
|
89
|
+
},
|
|
90
|
+
clean: true
|
|
91
|
+
},
|
|
92
|
+
publishConfig: {
|
|
93
|
+
access: "public"
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
38
97
|
// src/shipper.ts
|
|
98
|
+
var PLUGIN_VERSION = package_default.version;
|
|
39
99
|
function getCryptoObj() {
|
|
40
100
|
return globalThis.crypto;
|
|
41
101
|
}
|
|
@@ -75,7 +135,6 @@ function base64Encode(bytes) {
|
|
|
75
135
|
return out;
|
|
76
136
|
}
|
|
77
137
|
var SERVICE_NAME = "raindrop.opencode-plugin";
|
|
78
|
-
var PLUGIN_VERSION = "0.1.0";
|
|
79
138
|
var SpanStatusCode = {
|
|
80
139
|
ERROR: 2
|
|
81
140
|
};
|
|
@@ -92,7 +151,7 @@ function createSpanIds(parent) {
|
|
|
92
151
|
};
|
|
93
152
|
}
|
|
94
153
|
function nowUnixNanoString() {
|
|
95
|
-
return
|
|
154
|
+
return Date.now().toString() + "000000";
|
|
96
155
|
}
|
|
97
156
|
function attrString(key, value) {
|
|
98
157
|
if (value === void 0) return void 0;
|
|
@@ -614,8 +673,8 @@ function getHostname() {
|
|
|
614
673
|
}
|
|
615
674
|
function createHooks(config, worktree, directory, eventShipper, traceShipper) {
|
|
616
675
|
function log(msg, data) {
|
|
617
|
-
|
|
618
|
-
const prefix = `[raindrop-ai/opencode-plugin] [
|
|
676
|
+
if (!config.debug) return;
|
|
677
|
+
const prefix = `[raindrop-ai/opencode-plugin] [info] ${msg}`;
|
|
619
678
|
if (data !== void 0) {
|
|
620
679
|
console.log(prefix, data);
|
|
621
680
|
return;
|
|
@@ -786,7 +845,7 @@ type: ${name != null ? name : "UnknownError"}`;
|
|
|
786
845
|
attributes: llmAttrs
|
|
787
846
|
});
|
|
788
847
|
if (typeof timeObj["created"] === "number") {
|
|
789
|
-
llmSpan.startTimeUnixNano = String(timeObj["created"]
|
|
848
|
+
llmSpan.startTimeUnixNano = String(Math.floor(timeObj["created"])) + "000000";
|
|
790
849
|
}
|
|
791
850
|
traceShipper.endSpan(llmSpan, { error: errorForSpan });
|
|
792
851
|
await traceShipper.flush();
|
|
@@ -823,7 +882,7 @@ type: ${name != null ? name : "UnknownError"}`;
|
|
|
823
882
|
attributes: llmAttrs
|
|
824
883
|
});
|
|
825
884
|
if (typeof timeObj["created"] === "number") {
|
|
826
|
-
finalLlmSpan.startTimeUnixNano = String(timeObj["created"]
|
|
885
|
+
finalLlmSpan.startTimeUnixNano = String(Math.floor(timeObj["created"])) + "000000";
|
|
827
886
|
}
|
|
828
887
|
traceShipper.endSpan(finalLlmSpan, { error: errorForSpan });
|
|
829
888
|
traceShipper.endSpan(rootSpan, {
|
|
@@ -883,7 +942,7 @@ type: ${name != null ? name : "UnknownError"}`;
|
|
|
883
942
|
if (state.currentEventId) {
|
|
884
943
|
state.currentEventId = void 0;
|
|
885
944
|
}
|
|
886
|
-
await traceShipper.flush();
|
|
945
|
+
await Promise.all([eventShipper.flush(), traceShipper.flush()]);
|
|
887
946
|
if (state.parentId) {
|
|
888
947
|
cleanupSessionParentMap(String(sessionID));
|
|
889
948
|
sessions.delete(String(sessionID));
|
|
@@ -1080,6 +1139,9 @@ type: ${errorName != null ? errorName : "UnknownError"}`;
|
|
|
1080
1139
|
});
|
|
1081
1140
|
}
|
|
1082
1141
|
} catch (err) {
|
|
1142
|
+
console.log(
|
|
1143
|
+
`[raindrop-ai/opencode-plugin] [error] Error in tool.execute.before hook: ${err instanceof Error ? err.message : String(err)}`
|
|
1144
|
+
);
|
|
1083
1145
|
}
|
|
1084
1146
|
},
|
|
1085
1147
|
// ------------------------------------------------------------------
|
|
@@ -1151,6 +1213,9 @@ type: ${errorName != null ? errorName : "UnknownError"}`;
|
|
|
1151
1213
|
});
|
|
1152
1214
|
}
|
|
1153
1215
|
} catch (err) {
|
|
1216
|
+
console.log(
|
|
1217
|
+
`[raindrop-ai/opencode-plugin] [error] Error in tool.execute.after hook: ${err instanceof Error ? err.message : String(err)}`
|
|
1218
|
+
);
|
|
1154
1219
|
}
|
|
1155
1220
|
}
|
|
1156
1221
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raindrop-ai/opencode-plugin",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Raindrop observability plugin for OpenCode — automatic session/event/span tracing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "tsup",
|
|
22
22
|
"dev": "tsup --watch",
|
|
23
|
-
"clean": "rm -rf dist"
|
|
23
|
+
"clean": "rm -rf dist",
|
|
24
|
+
"test": "cd tests && yarn test"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
27
|
"@opencode-ai/plugin": ">=1.2.0",
|