@1agents/dsh-plugin-todo 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +48 -2
- package/bin/ios-agenda.mjs +11 -0
- package/cordis.patch.yml +3 -0
- package/dist/IosAgenda.app/Contents/Info.plist +30 -0
- package/dist/IosAgenda.app/Contents/MacOS/ios-agenda +0 -0
- package/dist/IosAgenda.app/Contents/_CodeSignature/CodeResources +115 -0
- package/dist/client.js +894 -0
- package/dist/host.js +172 -0
- package/package.json +60 -4
- package/skills/ios-agenda/SKILL.md +20 -0
package/dist/host.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// src/contract.js
|
|
2
|
+
var SERVICE = "iosAgenda";
|
|
3
|
+
var PACKAGE = "@1agents/dsh-plugin-todo";
|
|
4
|
+
var METHODS = ["snapshot", "createReminder", "completeReminder", "deleteReminder", "createEvent", "deleteEvent"];
|
|
5
|
+
function objectOf(value) {
|
|
6
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
function resultOf(value) {
|
|
10
|
+
if (value && typeof value === "object" && (value.ok === true || value.ok === false)) return value;
|
|
11
|
+
throw new Error("\u539F\u751F\u7A0B\u5E8F\u8FD4\u56DE\u4E86\u65E0\u6CD5\u8BC6\u522B\u7684\u7ED3\u679C");
|
|
12
|
+
}
|
|
13
|
+
var codec = (name2, parse) => ({
|
|
14
|
+
mode: "strict",
|
|
15
|
+
typeSymbol: `${PACKAGE}#${name2}`,
|
|
16
|
+
create: () => ({ parse })
|
|
17
|
+
});
|
|
18
|
+
var contribution = {
|
|
19
|
+
package: PACKAGE,
|
|
20
|
+
descriptors: METHODS.map((method) => ({
|
|
21
|
+
id: `${PACKAGE}#${method}`,
|
|
22
|
+
service: SERVICE,
|
|
23
|
+
namespace: SERVICE,
|
|
24
|
+
method,
|
|
25
|
+
invocation: { kind: "direct" },
|
|
26
|
+
cancellation: { parameter: "signal" },
|
|
27
|
+
parameters: [
|
|
28
|
+
{ name: "input", wire: "input", source: "json", codec: codec("Input", objectOf) }
|
|
29
|
+
],
|
|
30
|
+
result: codec("Result", resultOf)
|
|
31
|
+
}))
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/native.js
|
|
35
|
+
import { spawn } from "node:child_process";
|
|
36
|
+
import { constants } from "node:fs";
|
|
37
|
+
import { access } from "node:fs/promises";
|
|
38
|
+
import { fileURLToPath } from "node:url";
|
|
39
|
+
function binaryPath(from = import.meta.url) {
|
|
40
|
+
return fileURLToPath(new URL("./IosAgenda.app/Contents/MacOS/ios-agenda", from));
|
|
41
|
+
}
|
|
42
|
+
async function callNative(binary2, method, input = {}, signal) {
|
|
43
|
+
await access(binary2, constants.X_OK).catch(() => {
|
|
44
|
+
throw Object.assign(new Error("\u8FD8\u6CA1\u6709\u6784\u5EFA IosAgenda.app\u3002\u5148\u8FD0\u884C npm run build\u3002"), { code: "NOT_BUILT" });
|
|
45
|
+
});
|
|
46
|
+
return await new Promise((resolve) => {
|
|
47
|
+
const child = spawn(binary2, ["call", method], { stdio: ["pipe", "pipe", "pipe"] });
|
|
48
|
+
let stdout = "";
|
|
49
|
+
let stderr = "";
|
|
50
|
+
let settled = false;
|
|
51
|
+
const finish = (result) => {
|
|
52
|
+
if (settled) return;
|
|
53
|
+
settled = true;
|
|
54
|
+
clearTimeout(timer);
|
|
55
|
+
resolve(result);
|
|
56
|
+
};
|
|
57
|
+
const timer = setTimeout(() => {
|
|
58
|
+
child.kill("SIGTERM");
|
|
59
|
+
finish({ ok: false, error: { code: "TIMEOUT", message: "\u8BFB\u53D6\u65E5\u5386\u6216\u63D0\u9192\u4E8B\u9879\u8D85\u65F6\u3002\u5982\u679C\u7CFB\u7EDF\u6B63\u5728\u8BE2\u95EE\u6743\u9650\uFF0C\u5141\u8BB8\u540E\u518D\u8BD5\u3002" } });
|
|
60
|
+
}, 2e4);
|
|
61
|
+
child.stdout.setEncoding("utf8");
|
|
62
|
+
child.stderr.setEncoding("utf8");
|
|
63
|
+
child.stdout.on("data", (chunk) => {
|
|
64
|
+
stdout += chunk;
|
|
65
|
+
});
|
|
66
|
+
child.stderr.on("data", (chunk) => {
|
|
67
|
+
stderr += chunk;
|
|
68
|
+
});
|
|
69
|
+
child.on("error", (error) => finish({ ok: false, error: { code: "SPAWN", message: error.message } }));
|
|
70
|
+
child.on("close", () => {
|
|
71
|
+
const line = stdout.trim().split("\n").findLast((item) => item.trim());
|
|
72
|
+
try {
|
|
73
|
+
finish(line ? JSON.parse(line) : { ok: false, error: { code: "BAD_RESPONSE", message: stderr.trim() || "\u539F\u751F\u7A0B\u5E8F\u6CA1\u6709\u8FD4\u56DE JSON" } });
|
|
74
|
+
} catch {
|
|
75
|
+
finish({ ok: false, error: { code: "BAD_RESPONSE", message: stderr.trim() || stdout.trim() || "\u539F\u751F\u7A0B\u5E8F\u8FD4\u56DE\u7684\u4E0D\u662F JSON" } });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
signal?.addEventListener("abort", () => child.kill("SIGTERM"), { once: true });
|
|
79
|
+
child.stdin.end(JSON.stringify(input ?? {}));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// src/register-mcp.js
|
|
84
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
85
|
+
import { readFile } from "node:fs/promises";
|
|
86
|
+
import { homedir } from "node:os";
|
|
87
|
+
import { join } from "node:path";
|
|
88
|
+
var SOURCE = "ios-agenda";
|
|
89
|
+
function run(args, input) {
|
|
90
|
+
return new Promise((resolve) => {
|
|
91
|
+
const child = spawn2("dreammate-node", args, { stdio: ["pipe", "pipe", "pipe"] });
|
|
92
|
+
let stdout = "";
|
|
93
|
+
let stderr = "";
|
|
94
|
+
child.stdout.setEncoding("utf8");
|
|
95
|
+
child.stderr.setEncoding("utf8");
|
|
96
|
+
child.stdout.on("data", (chunk) => {
|
|
97
|
+
stdout += chunk;
|
|
98
|
+
});
|
|
99
|
+
child.stderr.on("data", (chunk) => {
|
|
100
|
+
stderr += chunk;
|
|
101
|
+
});
|
|
102
|
+
child.on("error", (error) => resolve({ code: 127, stdout, stderr: error.message }));
|
|
103
|
+
child.on("close", (code) => resolve({ code: code ?? 1, stdout, stderr }));
|
|
104
|
+
if (input) child.stdin.end(input);
|
|
105
|
+
else child.stdin.end();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async function currentCommand() {
|
|
109
|
+
try {
|
|
110
|
+
const raw = await readFile(join(homedir(), ".1agents", "mcp-sources.json"), "utf8");
|
|
111
|
+
return JSON.parse(raw)?.mcpServers?.[SOURCE]?.command;
|
|
112
|
+
} catch {
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function registerMcp(binary2) {
|
|
117
|
+
const current = await currentCommand();
|
|
118
|
+
if (current === binary2) return { ok: true, changed: false };
|
|
119
|
+
if (current) {
|
|
120
|
+
const removed = await run(["mcp", "remove", `mcp-${SOURCE}`]);
|
|
121
|
+
if (removed.code !== 0 && !/not found|不存在|unknown/i.test(`${removed.stdout}
|
|
122
|
+
${removed.stderr}`)) {
|
|
123
|
+
return { ok: false, error: removed.stderr || removed.stdout || "\u65E0\u6CD5\u66F4\u65B0\u5DF2\u6709 MCP \u6765\u6E90" };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const config = JSON.stringify({
|
|
127
|
+
mcpServers: {
|
|
128
|
+
[SOURCE]: { command: binary2, args: ["mcp"], sharing: "local" }
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const added = await run(["mcp", "add", "--config", config]);
|
|
132
|
+
if (added.code !== 0) return { ok: false, error: added.stderr || added.stdout || "dreammate-node mcp add \u5931\u8D25" };
|
|
133
|
+
return { ok: true, changed: true };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/host.js
|
|
137
|
+
var name = "ios-agenda";
|
|
138
|
+
var inject = ["typert"];
|
|
139
|
+
var binary = binaryPath();
|
|
140
|
+
function failure(code, message) {
|
|
141
|
+
return { ok: false, error: { code, message } };
|
|
142
|
+
}
|
|
143
|
+
async function invoke(method, input, signal) {
|
|
144
|
+
try {
|
|
145
|
+
return await callNative(binary, method, input, signal);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return failure(error?.code ?? "FAILED", error instanceof Error ? error.message : String(error));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function apply(ctx) {
|
|
151
|
+
const service = {};
|
|
152
|
+
for (const method of METHODS) {
|
|
153
|
+
service[method] = (input, signal) => invoke(method, input, signal);
|
|
154
|
+
}
|
|
155
|
+
service.typertRemote = Object.freeze({ service, serviceKey: SERVICE, namespace: SERVICE });
|
|
156
|
+
ctx.effect(() => ctx.reflect.provide(SERVICE, service));
|
|
157
|
+
ctx.effect(() => ctx.typert.register({
|
|
158
|
+
...contribution,
|
|
159
|
+
face: "host",
|
|
160
|
+
schemas: [],
|
|
161
|
+
model: { services: [], events: [], objects: [] },
|
|
162
|
+
invocations: contribution.descriptors
|
|
163
|
+
}));
|
|
164
|
+
registerMcp(binary).then((result) => {
|
|
165
|
+
if (!result.ok) console.error(`[ios-agenda] \u672A\u80FD\u767B\u8BB0 dreammate MCP\uFF1A${result.error}`);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
apply,
|
|
170
|
+
inject,
|
|
171
|
+
name
|
|
172
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1agents/dsh-plugin-todo",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "管理本机已同步的系统提醒事项和日历。页面在 DSH,工具在 dreammate-node MCP。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"os": ["darwin"],
|
|
8
|
+
"cpu": ["arm64"],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/scottzx/DSH-Plugin-Todo.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/scottzx/DSH-Plugin-Todo#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/scottzx/DSH-Plugin-Todo/issues"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"registry": "https://registry.npmjs.org/"
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"ios-agenda": "./bin/ios-agenda.mjs"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./dist/host.js",
|
|
26
|
+
"./client": "./dist/client.js",
|
|
27
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist/host.js",
|
|
32
|
+
"dist/client.js",
|
|
33
|
+
"dist/IosAgenda.app",
|
|
34
|
+
"bin",
|
|
35
|
+
"skills/ios-agenda",
|
|
36
|
+
"cordis.patch.yml",
|
|
37
|
+
"LICENSE",
|
|
38
|
+
"README.md"
|
|
39
|
+
],
|
|
40
|
+
"dsh": {
|
|
41
|
+
"bundle": {
|
|
42
|
+
"patch": "./cordis.patch.yml"
|
|
43
|
+
},
|
|
44
|
+
"client": {
|
|
45
|
+
"platform": "web",
|
|
46
|
+
"inject": [
|
|
47
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
48
|
+
"@deepseek-ai/dsh-client-locale"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=20"
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "node scripts/build.mjs",
|
|
57
|
+
"test": "node --test tests/protocol.test.mjs"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"esbuild": "^0.25.0"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ios-agenda
|
|
3
|
+
description: 通过 dreammate-node 管理这台 Mac 上已同步的系统提醒事项和日历。用户要查看、新建、完成或删除待办和日程时使用。不要把这些工具注册到 DSH。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 本机提醒事项与日历
|
|
7
|
+
|
|
8
|
+
数据在这台 Mac 的系统「提醒事项」和「日历」里,经 iCloud 同步到 iPhone。工具不在 DSH 里,在 dreammate-node 的 `mcp-ios-agenda`。
|
|
9
|
+
|
|
10
|
+
先搜索再读契约再调用:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
dreammate-node cli search --agent http://127.0.0.1:36908 --query '提醒事项 日历'
|
|
14
|
+
dreammate-node cli inspect --agent http://127.0.0.1:36908 --service mcp-ios-agenda --method agenda_snapshot
|
|
15
|
+
dreammate-node cli invoke --agent http://127.0.0.1:36908 --service mcp-ios-agenda --method agenda_snapshot --params '{}'
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
方法以 inspect 返回的 Schema 为准。常用的是 `agenda_snapshot`、`agenda_create_reminder`、`agenda_complete_reminder`、`agenda_create_event`。写入后不会立刻出现在手机上,要等 iCloud 同步。
|
|
19
|
+
|
|
20
|
+
没有来源时,先在插件仓库执行 `npm run build`,再由 DSH 启用插件,或手动 `dreammate-node mcp add`。来源范围是 `local`。
|