@softprobe/opencode-plugin 0.1.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.
- package/README.md +70 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +70 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +235 -0
- package/dist/softprobe.d.ts +119 -0
- package/dist/softprobe.js +707 -0
- package/dist/tool-kind.d.ts +3 -0
- package/dist/tool-kind.js +27 -0
- package/dist/types.d.ts +132 -0
- package/dist/types.js +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const SHELL_TOOLS = new Set(["bash", "shell", "exec"]);
|
|
2
|
+
const FILE_TOOLS = new Set([
|
|
3
|
+
"read",
|
|
4
|
+
"write",
|
|
5
|
+
"edit",
|
|
6
|
+
"apply_patch",
|
|
7
|
+
"multiedit",
|
|
8
|
+
"list",
|
|
9
|
+
"glob",
|
|
10
|
+
"grep",
|
|
11
|
+
]);
|
|
12
|
+
/** Map OpenCode tool names to Part A `sp.tool.kind` values. */
|
|
13
|
+
export function inferToolKind(toolName) {
|
|
14
|
+
const name = toolName.trim().toLowerCase();
|
|
15
|
+
if (!name)
|
|
16
|
+
return "other";
|
|
17
|
+
if (SHELL_TOOLS.has(name) || name.includes("shell") || name.includes("bash")) {
|
|
18
|
+
return "shell";
|
|
19
|
+
}
|
|
20
|
+
if (FILE_TOOLS.has(name) || name.startsWith("file.")) {
|
|
21
|
+
return "file";
|
|
22
|
+
}
|
|
23
|
+
if (name.includes("mcp") || name.startsWith("mcp_")) {
|
|
24
|
+
return "mcp";
|
|
25
|
+
}
|
|
26
|
+
return "function";
|
|
27
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { JsonValue } from "@softprobe/tracing";
|
|
2
|
+
/** OpenCode session.next.* events omitted from some published Hooks unions. */
|
|
3
|
+
export type SessionNextEvent = {
|
|
4
|
+
id: string;
|
|
5
|
+
type: "session.next.step.started";
|
|
6
|
+
properties: {
|
|
7
|
+
sessionID: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
agent: string;
|
|
10
|
+
model: {
|
|
11
|
+
providerID: string;
|
|
12
|
+
id: string;
|
|
13
|
+
variant?: string;
|
|
14
|
+
};
|
|
15
|
+
snapshot?: string;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
id: string;
|
|
19
|
+
type: "session.next.step.ended";
|
|
20
|
+
properties: {
|
|
21
|
+
sessionID: string;
|
|
22
|
+
timestamp: number;
|
|
23
|
+
};
|
|
24
|
+
} | {
|
|
25
|
+
id: string;
|
|
26
|
+
type: "session.next.step.failed";
|
|
27
|
+
properties: {
|
|
28
|
+
sessionID: string;
|
|
29
|
+
timestamp: number;
|
|
30
|
+
error: {
|
|
31
|
+
message: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
} | {
|
|
35
|
+
id: string;
|
|
36
|
+
type: "session.next.retried";
|
|
37
|
+
properties: {
|
|
38
|
+
sessionID: string;
|
|
39
|
+
timestamp: number;
|
|
40
|
+
attempt: number;
|
|
41
|
+
error: unknown;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
id: string;
|
|
45
|
+
type: "session.next.reasoning.ended";
|
|
46
|
+
properties: {
|
|
47
|
+
sessionID: string;
|
|
48
|
+
timestamp: number;
|
|
49
|
+
assistantMessageID: string;
|
|
50
|
+
reasoningID: string;
|
|
51
|
+
text: string;
|
|
52
|
+
};
|
|
53
|
+
} | {
|
|
54
|
+
id: string;
|
|
55
|
+
type: "session.next.compaction.ended";
|
|
56
|
+
properties: {
|
|
57
|
+
sessionID: string;
|
|
58
|
+
timestamp: number;
|
|
59
|
+
text: string;
|
|
60
|
+
include?: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export type MessagePart = {
|
|
64
|
+
id?: string;
|
|
65
|
+
type: string;
|
|
66
|
+
sessionID?: string;
|
|
67
|
+
messageID?: string;
|
|
68
|
+
callID?: string;
|
|
69
|
+
text?: string;
|
|
70
|
+
filename?: string;
|
|
71
|
+
url?: string;
|
|
72
|
+
name?: string;
|
|
73
|
+
prompt?: string;
|
|
74
|
+
agent?: string;
|
|
75
|
+
tool?: string;
|
|
76
|
+
state?: {
|
|
77
|
+
title?: string;
|
|
78
|
+
status?: string;
|
|
79
|
+
error?: string;
|
|
80
|
+
input?: unknown;
|
|
81
|
+
output?: string;
|
|
82
|
+
time?: {
|
|
83
|
+
start?: number;
|
|
84
|
+
end?: number;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
time?: {
|
|
88
|
+
completed?: number;
|
|
89
|
+
end?: number;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export type SessionErrorInfo = {
|
|
93
|
+
name: string;
|
|
94
|
+
message?: string;
|
|
95
|
+
data?: {
|
|
96
|
+
message?: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
export type UserMessageInput = {
|
|
100
|
+
sessionID: string;
|
|
101
|
+
messageID?: string;
|
|
102
|
+
agent?: string;
|
|
103
|
+
model?: {
|
|
104
|
+
providerID: string;
|
|
105
|
+
modelID: string;
|
|
106
|
+
};
|
|
107
|
+
parts: MessagePart[];
|
|
108
|
+
};
|
|
109
|
+
export type AssistantGenerationInput = {
|
|
110
|
+
sessionID: string;
|
|
111
|
+
messageID: string;
|
|
112
|
+
parentID: string;
|
|
113
|
+
modelID: string;
|
|
114
|
+
providerID: string;
|
|
115
|
+
agent?: string;
|
|
116
|
+
mode: string;
|
|
117
|
+
created: number;
|
|
118
|
+
completed: number;
|
|
119
|
+
finish?: string;
|
|
120
|
+
cost: number;
|
|
121
|
+
tokens: {
|
|
122
|
+
total?: number;
|
|
123
|
+
input: number;
|
|
124
|
+
output: number;
|
|
125
|
+
reasoning: number;
|
|
126
|
+
cache: {
|
|
127
|
+
read: number;
|
|
128
|
+
write: number;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export type Jsonish = JsonValue;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@softprobe/opencode-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "OpenCode plugin that sends session telemetry to Softprobe",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=20"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p tsconfig.json",
|
|
23
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"lint": "tsc -p tsconfig.json --noEmit"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@softprobe/tracing": "workspace:*"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@opencode-ai/plugin": ">=1.15.0",
|
|
32
|
+
"@opentelemetry/api": "^1.9.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"@opencode-ai/plugin": {
|
|
36
|
+
"optional": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@opencode-ai/plugin": "^1.15.13",
|
|
41
|
+
"@opentelemetry/api": "^1.9.0",
|
|
42
|
+
"@opentelemetry/sdk-trace-base": "^1.30.1",
|
|
43
|
+
"@types/node": "^22.13.10",
|
|
44
|
+
"typescript": "^5.8.2",
|
|
45
|
+
"vitest": "^3.0.8"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"keywords": [
|
|
51
|
+
"softprobe",
|
|
52
|
+
"opencode",
|
|
53
|
+
"plugin",
|
|
54
|
+
"observability",
|
|
55
|
+
"opentelemetry"
|
|
56
|
+
],
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/softprobe/softprobe-js.git",
|
|
60
|
+
"directory": "packages/opencode-plugin"
|
|
61
|
+
},
|
|
62
|
+
"license": "MIT"
|
|
63
|
+
}
|