opencode-pushnot 0.0.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 +16 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# opencode-pushnot
|
|
2
|
+
|
|
3
|
+
```jsonc
|
|
4
|
+
// ~/.config/opencode/opencode.jsonc
|
|
5
|
+
{
|
|
6
|
+
"plugin": [
|
|
7
|
+
[
|
|
8
|
+
"opencode-pushnot@latest",
|
|
9
|
+
{
|
|
10
|
+
"baseURL": "<base-url>", // Optional, default: https://pushnot.cabbagelettuce.com/
|
|
11
|
+
"session": "<session-id>",
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
],
|
|
15
|
+
}
|
|
16
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAoBjD,eAAO,MAAM,aAAa,EAAE,MAgE3B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { tool } from "@opencode-ai/plugin";
|
|
2
|
+
async function sendNotification({ baseURL, sessionId, ...payload }) {
|
|
3
|
+
const url = new URL(`/api/push/${sessionId}`, baseURL);
|
|
4
|
+
return await fetch(url, {
|
|
5
|
+
method: "POST",
|
|
6
|
+
headers: {
|
|
7
|
+
"Content-Type": "application/json",
|
|
8
|
+
},
|
|
9
|
+
body: JSON.stringify(payload),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export const PushnotPlugin = async (_, options) => {
|
|
13
|
+
const { session, baseURL = "https://pushnot.cabbagelettuce.com/" } = options ?? {};
|
|
14
|
+
if (typeof session !== "string" || typeof baseURL !== "string") {
|
|
15
|
+
console.error("Invalid option provided.");
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
async event({ event }) {
|
|
20
|
+
switch (event.type) {
|
|
21
|
+
case "session.idle":
|
|
22
|
+
await sendNotification({
|
|
23
|
+
baseURL,
|
|
24
|
+
sessionId: session,
|
|
25
|
+
title: `OpenCode: Session Idle`,
|
|
26
|
+
body: `Session ${event.properties.sessionID} is now idle.`,
|
|
27
|
+
});
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
async "permission.ask"({ title }) {
|
|
32
|
+
// Send notification
|
|
33
|
+
await sendNotification({
|
|
34
|
+
baseURL,
|
|
35
|
+
sessionId: session,
|
|
36
|
+
title: `OpenCode: Ask permissions`,
|
|
37
|
+
body: `${title}`,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
async "tool.execute.after"({ tool, args }) {
|
|
41
|
+
if (tool === "question") {
|
|
42
|
+
await sendNotification({
|
|
43
|
+
baseURL,
|
|
44
|
+
sessionId: session,
|
|
45
|
+
title: `OpenCode: Ask question`,
|
|
46
|
+
body: `${JSON.stringify(args)}`,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
tool: {
|
|
51
|
+
notify: tool({
|
|
52
|
+
description: `
|
|
53
|
+
Sends notifications to users.
|
|
54
|
+
This can be used for purposes such as reporting work progress.
|
|
55
|
+
`.trim(),
|
|
56
|
+
args: {
|
|
57
|
+
payload: tool.schema.string(),
|
|
58
|
+
},
|
|
59
|
+
async execute({ payload }) {
|
|
60
|
+
try {
|
|
61
|
+
await sendNotification({
|
|
62
|
+
baseURL,
|
|
63
|
+
sessionId: session,
|
|
64
|
+
title: `OpenCode: Agent sent notification`,
|
|
65
|
+
body: payload,
|
|
66
|
+
});
|
|
67
|
+
return "Notification sent successfully.";
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return `Failed to send notification`;
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAQ1C,KAAK,UAAU,gBAAgB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,OAAO,EAA2B;IACzF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,SAAS,EAAE,EAAE,OAAO,CAAC,CAAA;IACtD,OAAO,MAAM,KAAK,CAAC,GAAG,EAAE;QACtB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KAC9B,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAW,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE;IACxD,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,qCAAqC,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAClF,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC/D,OAAO,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;QACzC,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO;QACL,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE;YACnB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;gBACnB,KAAK,cAAc;oBACjB,MAAM,gBAAgB,CAAC;wBACrB,OAAO;wBACP,SAAS,EAAE,OAAO;wBAClB,KAAK,EAAE,wBAAwB;wBAC/B,IAAI,EAAE,WA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encode-pushnot",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Opencode plugin for pushnot",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "pycabbage",
|
|
8
|
+
"url": "https://github.com/pycabbage/"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pycabbage/pushnot/",
|
|
13
|
+
"directory": "packages/opencode-pushnot"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@opencode-ai/plugin": "^1.18.30"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^26.5.1",
|
|
26
|
+
"typescript": "^7.0.2"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc -b",
|
|
30
|
+
"typecheck": "tsc --noEmit"
|
|
31
|
+
}
|
|
32
|
+
}
|