agent-sin 0.1.12 → 0.1.16
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/CHANGELOG.md +79 -0
- package/README.md +2 -1
- package/builtin-skills/_shared/_todo_lib.py +290 -0
- package/builtin-skills/even-g2-setup/main.ts +896 -0
- package/builtin-skills/even-g2-setup/skill.yaml +133 -0
- package/builtin-skills/memo-delete/main.py +28 -107
- package/builtin-skills/memo-delete/skill.yaml +10 -21
- package/builtin-skills/memo-index/main.py +96 -64
- package/builtin-skills/memo-index/skill.yaml +4 -10
- package/builtin-skills/memo-list/main.py +126 -72
- package/builtin-skills/memo-list/skill.yaml +8 -14
- package/builtin-skills/memo-save/main.py +191 -25
- package/builtin-skills/memo-save/skill.yaml +29 -5
- package/builtin-skills/memo-search/main.py +38 -18
- package/builtin-skills/memo-vector-search/main.py +11 -6
- package/builtin-skills/nightly-topic-knowledge/_feedback_lib.py +391 -0
- package/builtin-skills/nightly-topic-knowledge/_topics_lib.py +415 -0
- package/builtin-skills/nightly-topic-knowledge/main.py +403 -0
- package/builtin-skills/nightly-topic-knowledge/skill.yaml +88 -0
- package/builtin-skills/schedule-add/main.py +26 -0
- package/builtin-skills/service-restart/main.ts +249 -0
- package/builtin-skills/service-restart/skill.yaml +49 -0
- package/builtin-skills/todo-add/main.py +3 -1
- package/builtin-skills/todo-delete/main.py +3 -1
- package/builtin-skills/todo-done/main.py +3 -1
- package/builtin-skills/todo-list/main.py +4 -1
- package/builtin-skills/todo-tick/main.py +3 -1
- package/builtin-skills/topic-knowledge-read/main.py +118 -0
- package/builtin-skills/topic-knowledge-read/skill.yaml +49 -0
- package/dist/builder/build-action-classifier.d.ts +18 -0
- package/dist/builder/build-action-classifier.js +82 -1
- package/dist/builder/build-flow.d.ts +33 -4
- package/dist/builder/build-flow.js +251 -89
- package/dist/builder/builder-session.d.ts +1 -1
- package/dist/builder/builder-session.js +112 -7
- package/dist/builder/conversation-router.d.ts +4 -2
- package/dist/builder/conversation-router.js +19 -2
- package/dist/cli/index.js +323 -20
- package/dist/core/ai-provider.d.ts +1 -0
- package/dist/core/ai-provider.js +8 -3
- package/dist/core/chat-engine.d.ts +9 -3
- package/dist/core/chat-engine.js +1263 -146
- package/dist/core/config.d.ts +4 -0
- package/dist/core/config.js +82 -0
- package/dist/core/daily-memory-promotion.d.ts +7 -0
- package/dist/core/daily-memory-promotion.js +596 -18
- package/dist/core/image-attachments.d.ts +31 -0
- package/dist/core/image-attachments.js +237 -0
- package/dist/core/logger.d.ts +2 -1
- package/dist/core/logger.js +77 -1
- package/dist/core/memo-migration.d.ts +3 -0
- package/dist/core/memo-migration.js +422 -0
- package/dist/core/native-modules.d.ts +24 -0
- package/dist/core/native-modules.js +99 -0
- package/dist/core/notifier.d.ts +8 -3
- package/dist/core/notifier.js +191 -17
- package/dist/core/obsidian-vault.d.ts +19 -0
- package/dist/core/obsidian-vault.js +477 -0
- package/dist/core/operating-model.d.ts +2 -0
- package/dist/core/operating-model.js +15 -0
- package/dist/core/output-writer.d.ts +3 -2
- package/dist/core/output-writer.js +108 -7
- package/dist/core/profile-memory.js +22 -1
- package/dist/core/runtime.d.ts +2 -0
- package/dist/core/runtime.js +9 -1
- package/dist/core/secrets.d.ts +4 -0
- package/dist/core/secrets.js +34 -0
- package/dist/core/skill-history.d.ts +44 -0
- package/dist/core/skill-history.js +329 -0
- package/dist/core/skill-registry.d.ts +5 -0
- package/dist/core/skill-registry.js +11 -0
- package/dist/discord/bot.d.ts +1 -0
- package/dist/discord/bot.js +181 -10
- package/dist/even-g2/gateway.d.ts +15 -0
- package/dist/even-g2/gateway.js +868 -0
- package/dist/runtimes/codex-app-server.d.ts +5 -1
- package/dist/runtimes/codex-app-server.js +147 -8
- package/dist/runtimes/python-runner.js +82 -0
- package/dist/runtimes/typescript-runner.js +13 -1
- package/dist/skills-sdk/types.d.ts +19 -4
- package/dist/telegram/bot.d.ts +1 -0
- package/dist/telegram/bot.js +115 -7
- package/package.json +3 -1
- package/templates/even-g2-agent/README.md +83 -0
- package/templates/even-g2-agent/app.json +20 -0
- package/templates/even-g2-agent/index.html +31 -0
- package/templates/even-g2-agent/package-lock.json +1836 -0
- package/templates/even-g2-agent/package.json +22 -0
- package/templates/even-g2-agent/scripts/qr-auto.mjs +182 -0
- package/templates/even-g2-agent/src/embedded-config.ts +4 -0
- package/templates/even-g2-agent/src/main.ts +539 -0
- package/templates/even-g2-agent/src/style.css +70 -0
- package/templates/even-g2-agent/tsconfig.json +11 -0
- package/templates/skill-python/main.py +20 -2
- package/templates/skill-python/skill.yaml +9 -0
- package/templates/skill-typescript/main.ts +40 -5
- package/templates/skill-typescript/skill.yaml +9 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agent-sin-even-g2-agent",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite --host 0.0.0.0",
|
|
8
|
+
"qr": "evenhub qr",
|
|
9
|
+
"qr:auto": "node scripts/qr-auto.mjs",
|
|
10
|
+
"qr:ip": "node scripts/qr-auto.mjs",
|
|
11
|
+
"build": "vite build",
|
|
12
|
+
"pack": "npm run build && evenhub pack app.json dist -o agent-sin-g2.ehpk"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@evenrealities/even_hub_sdk": "^0.0.10",
|
|
16
|
+
"vite": "^7.0.0",
|
|
17
|
+
"typescript": "^5.9.3"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@evenrealities/evenhub-cli": "^0.1.13"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const projectRoot = path.resolve(__dirname, "..");
|
|
10
|
+
|
|
11
|
+
const args = parseArgs(process.argv.slice(2));
|
|
12
|
+
|
|
13
|
+
if (args.help) {
|
|
14
|
+
printHelp();
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const host = args.host || hostFromUrl(args.server) || hostFromUrl(args.app) || detectHost();
|
|
19
|
+
if (!host) {
|
|
20
|
+
fail("Could not detect an IP address. Pass --host, --app, or --server.");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const appUrl = normalizeUrl(args.app || `http://${host}:${args.appPort || "5173"}`);
|
|
24
|
+
const serverUrl = normalizeUrl(args.server || `http://${host}:${args.serverPort || "8765"}`);
|
|
25
|
+
const token = args.token || process.env.AGENT_SIN_G2_TOKEN || readTokenFromAgentEnv() || readTokenFromProcess();
|
|
26
|
+
|
|
27
|
+
if (!token) {
|
|
28
|
+
fail("Could not find AGENT_SIN_G2_TOKEN. Run agent-sin g2 setup, or pass --token.");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const qrUrl = buildQrUrl(appUrl, serverUrl, token);
|
|
32
|
+
|
|
33
|
+
if (args.print) {
|
|
34
|
+
console.log(qrUrl);
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log(`App URL: ${redactHash(qrUrl)}`);
|
|
39
|
+
console.log(`Server URL: ${serverUrl}`);
|
|
40
|
+
console.log("The token is embedded in the QR hash and will be saved by the phone app.");
|
|
41
|
+
|
|
42
|
+
const evenhub = findEvenhub();
|
|
43
|
+
const result = spawnSync(evenhub, ["qr", "--url", qrUrl], { stdio: "inherit" });
|
|
44
|
+
if (result.error) {
|
|
45
|
+
fail(`Could not run evenhub. Try npm install first. ${result.error.message}`);
|
|
46
|
+
}
|
|
47
|
+
process.exit(result.status ?? 1);
|
|
48
|
+
|
|
49
|
+
function parseArgs(argv) {
|
|
50
|
+
const output = {
|
|
51
|
+
appPort: "5173",
|
|
52
|
+
serverPort: "8765",
|
|
53
|
+
};
|
|
54
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
55
|
+
const arg = argv[index];
|
|
56
|
+
const [name, inlineValue] = arg.includes("=") ? arg.split(/=(.*)/s, 2) : [arg, undefined];
|
|
57
|
+
const nextValue = () => inlineValue ?? argv[++index];
|
|
58
|
+
if (name === "--help" || name === "-h") output.help = true;
|
|
59
|
+
else if (name === "--app") output.app = nextValue();
|
|
60
|
+
else if (name === "--server") output.server = nextValue();
|
|
61
|
+
else if (name === "--token") output.token = nextValue();
|
|
62
|
+
else if (name === "--host") output.host = nextValue();
|
|
63
|
+
else if (name === "--app-port") output.appPort = nextValue();
|
|
64
|
+
else if (name === "--server-port") output.serverPort = nextValue();
|
|
65
|
+
else if (name === "--print") output.print = true;
|
|
66
|
+
else fail(`Unknown option: ${arg}`);
|
|
67
|
+
}
|
|
68
|
+
return output;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function printHelp() {
|
|
72
|
+
console.log(`Usage: npm run qr:auto -- [options]
|
|
73
|
+
|
|
74
|
+
Options:
|
|
75
|
+
--host <host> Host used for both app and gateway URLs
|
|
76
|
+
--app <url> Full EvenHub app URL, default http://<host>:5173
|
|
77
|
+
--server <url> Full Agent-Sin G2 gateway URL, default http://<host>:8765
|
|
78
|
+
--token <token> Gateway token. Defaults to AGENT_SIN_G2_TOKEN or ~/.agent-sin/.env
|
|
79
|
+
--app-port <port> App dev server port, default 5173
|
|
80
|
+
--server-port <port> Gateway port, default 8765
|
|
81
|
+
--print Print the generated QR URL without opening EvenHub QR
|
|
82
|
+
`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function normalizeUrl(value) {
|
|
86
|
+
if (!value) return "";
|
|
87
|
+
const withProtocol = /^[a-z][a-z\d+.-]*:\/\//i.test(value) ? value : `http://${value}`;
|
|
88
|
+
return new URL(withProtocol).toString().replace(/\/$/, "");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function buildQrUrl(appUrl, serverUrl, token) {
|
|
92
|
+
const url = new URL(appUrl);
|
|
93
|
+
const hash = new URLSearchParams(url.hash.startsWith("#") ? url.hash.slice(1) : "");
|
|
94
|
+
hash.set("server", serverUrl);
|
|
95
|
+
hash.set("token", token);
|
|
96
|
+
url.hash = hash.toString();
|
|
97
|
+
return url.toString();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function hostFromUrl(value) {
|
|
101
|
+
if (!value) return "";
|
|
102
|
+
try {
|
|
103
|
+
return new URL(normalizeUrl(value)).hostname;
|
|
104
|
+
} catch {
|
|
105
|
+
return "";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function detectHost() {
|
|
110
|
+
return detectTailscaleIp() || detectLanIp();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function detectTailscaleIp() {
|
|
114
|
+
try {
|
|
115
|
+
const output = execFileSync("tailscale", ["ip", "-4"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
116
|
+
return output.split(/\s+/).find((item) => /^\d+\.\d+\.\d+\.\d+$/.test(item)) || "";
|
|
117
|
+
} catch {
|
|
118
|
+
return "";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function detectLanIp() {
|
|
123
|
+
const interfaces = os.networkInterfaces();
|
|
124
|
+
for (const name of ["en0", "en1"]) {
|
|
125
|
+
const address = findInterfaceAddress(interfaces[name]);
|
|
126
|
+
if (address) return address;
|
|
127
|
+
}
|
|
128
|
+
for (const values of Object.values(interfaces)) {
|
|
129
|
+
const address = findInterfaceAddress(values);
|
|
130
|
+
if (address) return address;
|
|
131
|
+
}
|
|
132
|
+
return "";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function findInterfaceAddress(values = []) {
|
|
136
|
+
return values.find((item) => item.family === "IPv4" && !item.internal && !item.address.startsWith("169.254."))?.address || "";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function readTokenFromAgentEnv() {
|
|
140
|
+
const envPath = path.join(os.homedir(), ".agent-sin", ".env");
|
|
141
|
+
if (!existsSync(envPath)) return "";
|
|
142
|
+
const contents = readFileSync(envPath, "utf8");
|
|
143
|
+
const match = contents.match(/^AGENT_SIN_G2_TOKEN=(.*)$/m);
|
|
144
|
+
if (!match) return "";
|
|
145
|
+
return unquoteEnv(match[1].trim());
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function unquoteEnv(value) {
|
|
149
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
150
|
+
return value.slice(1, -1);
|
|
151
|
+
}
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function readTokenFromProcess() {
|
|
156
|
+
try {
|
|
157
|
+
const output = execFileSync("ps", ["-axo", "command"], { encoding: "utf8" });
|
|
158
|
+
const line = output
|
|
159
|
+
.split("\n")
|
|
160
|
+
.find((item) => /\b(?:agent-sin|dist\/cli\/index\.js)\s+g2\b/.test(item) && item.includes("--token"));
|
|
161
|
+
if (!line) return "";
|
|
162
|
+
return line.match(/--token(?:=|\s+)([^\s]+)/)?.[1] || "";
|
|
163
|
+
} catch {
|
|
164
|
+
return "";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function findEvenhub() {
|
|
169
|
+
const local = path.join(projectRoot, "node_modules", ".bin", "evenhub");
|
|
170
|
+
return existsSync(local) ? local : "evenhub";
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function redactHash(value) {
|
|
174
|
+
const url = new URL(value);
|
|
175
|
+
url.hash = "#server=...&token=...";
|
|
176
|
+
return url.toString();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function fail(message) {
|
|
180
|
+
console.error(`qr:auto: ${message}`);
|
|
181
|
+
process.exit(1);
|
|
182
|
+
}
|