notioncode 0.1.1 → 0.1.3
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 +10 -4
- package/agent-runtime-server/package-lock.json +4381 -0
- package/agent-runtime-server/package.json +36 -0
- package/agent-runtime-server/scripts/fix-node-pty.js +67 -0
- package/agent-runtime-server/server/agent-session-service.js +816 -0
- package/agent-runtime-server/server/claude-sdk.js +836 -0
- package/agent-runtime-server/server/cli.js +330 -0
- package/agent-runtime-server/server/constants/config.js +5 -0
- package/agent-runtime-server/server/cursor-cli.js +335 -0
- package/agent-runtime-server/server/database/db.js +653 -0
- package/agent-runtime-server/server/database/init.sql +99 -0
- package/agent-runtime-server/server/gemini-cli.js +460 -0
- package/agent-runtime-server/server/gemini-response-handler.js +79 -0
- package/agent-runtime-server/server/index.js +2569 -0
- package/agent-runtime-server/server/load-env.js +32 -0
- package/agent-runtime-server/server/middleware/auth.js +132 -0
- package/agent-runtime-server/server/openai-codex.js +512 -0
- package/agent-runtime-server/server/projects.js +2594 -0
- package/agent-runtime-server/server/providers/claude/adapter.js +278 -0
- package/agent-runtime-server/server/providers/codex/adapter.js +248 -0
- package/agent-runtime-server/server/providers/cursor/adapter.js +353 -0
- package/agent-runtime-server/server/providers/gemini/adapter.js +186 -0
- package/agent-runtime-server/server/providers/registry.js +44 -0
- package/agent-runtime-server/server/providers/types.js +119 -0
- package/agent-runtime-server/server/providers/utils.js +29 -0
- package/agent-runtime-server/server/routes/agent-sessions.js +238 -0
- package/agent-runtime-server/server/routes/agent.js +1244 -0
- package/agent-runtime-server/server/routes/auth.js +144 -0
- package/agent-runtime-server/server/routes/cli-auth.js +478 -0
- package/agent-runtime-server/server/routes/codex.js +329 -0
- package/agent-runtime-server/server/routes/commands.js +596 -0
- package/agent-runtime-server/server/routes/cursor.js +798 -0
- package/agent-runtime-server/server/routes/gemini.js +24 -0
- package/agent-runtime-server/server/routes/git.js +1508 -0
- package/agent-runtime-server/server/routes/mcp-utils.js +48 -0
- package/agent-runtime-server/server/routes/mcp.js +552 -0
- package/agent-runtime-server/server/routes/messages.js +61 -0
- package/agent-runtime-server/server/routes/plugins.js +307 -0
- package/agent-runtime-server/server/routes/projects.js +548 -0
- package/agent-runtime-server/server/routes/settings.js +276 -0
- package/agent-runtime-server/server/routes/taskmaster.js +1963 -0
- package/agent-runtime-server/server/routes/user.js +123 -0
- package/agent-runtime-server/server/services/notification-orchestrator.js +227 -0
- package/agent-runtime-server/server/services/vapid-keys.js +35 -0
- package/agent-runtime-server/server/sessionManager.js +226 -0
- package/agent-runtime-server/server/utils/commandParser.js +303 -0
- package/agent-runtime-server/server/utils/frontmatter.js +18 -0
- package/agent-runtime-server/server/utils/gitConfig.js +34 -0
- package/agent-runtime-server/server/utils/mcp-detector.js +198 -0
- package/agent-runtime-server/server/utils/plugin-loader.js +457 -0
- package/agent-runtime-server/server/utils/plugin-process-manager.js +184 -0
- package/agent-runtime-server/server/utils/taskmaster-websocket.js +129 -0
- package/agent-runtime-server/shared/modelConstants.js +12 -0
- package/agent-runtime-server/shared/modelConstants.test.js +34 -0
- package/agent-runtime-server/shared/networkHosts.js +22 -0
- package/agent-runtime-server/test_sdk.mjs +16 -0
- package/bin/bridges/darwin-x64/nocode-bridge +0 -0
- package/bin/{nocode-local.js → notioncode.js} +0 -0
- package/dist/assets/icon-CQtd7WEB.png +0 -0
- package/dist/assets/index-Ctr1ES45.js +1 -0
- package/dist/assets/index-DhCWie1Z.css +1 -0
- package/dist/assets/index-DzqxG7Z8.js +689 -0
- package/dist/index.html +46 -0
- package/dist/onboarding/step1_create.png +0 -0
- package/dist/onboarding/step2_capabilities.png +0 -0
- package/dist/onboarding/step2b_content_access.png +0 -0
- package/dist/onboarding/step2c_page_access.png +0 -0
- package/dist/onboarding/step3_token.png +0 -0
- package/dist/onboarding/step4_webhook.png +0 -0
- package/dist/onboarding/step6a_verify.png +0 -0
- package/dist/onboarding/step6b_copy_verify_token.png +0 -0
- package/dist/tinyfish-fish-only.png +0 -0
- package/lib/install.js +33 -2
- package/lib/start.js +157 -25
- package/package.json +7 -4
- package/src/shared/modelRegistry.d.ts +24 -0
- package/src/shared/modelRegistry.js +163 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared provider utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module providers/utils
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Prefixes that indicate internal/system content which should be hidden from the UI.
|
|
9
|
+
* @type {readonly string[]}
|
|
10
|
+
*/
|
|
11
|
+
export const INTERNAL_CONTENT_PREFIXES = Object.freeze([
|
|
12
|
+
'<command-name>',
|
|
13
|
+
'<command-message>',
|
|
14
|
+
'<command-args>',
|
|
15
|
+
'<local-command-stdout>',
|
|
16
|
+
'<system-reminder>',
|
|
17
|
+
'Caveat:',
|
|
18
|
+
'This session is being continued from a previous',
|
|
19
|
+
'[Request interrupted',
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Check if user text content is internal/system that should be skipped.
|
|
24
|
+
* @param {string} content
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
export function isInternalContent(content) {
|
|
28
|
+
return INTERNAL_CONTENT_PREFIXES.some(prefix => content.startsWith(prefix));
|
|
29
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ProviderSelectionError,
|
|
5
|
+
abortLocalAgentSession,
|
|
6
|
+
getLocalAgentSession,
|
|
7
|
+
getLocalAgentSessionEvents,
|
|
8
|
+
listAvailableProviders,
|
|
9
|
+
sendLocalAgentSessionMessage,
|
|
10
|
+
startLocalAgentSession,
|
|
11
|
+
subscribeToLocalAgentSession,
|
|
12
|
+
} from '../agent-session-service.js';
|
|
13
|
+
|
|
14
|
+
const router = Router();
|
|
15
|
+
|
|
16
|
+
function readString(value) {
|
|
17
|
+
return typeof value === 'string' && value.trim() ? value.trim() : '';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function formatRichList(items) {
|
|
21
|
+
if (!Array.isArray(items) || items.length === 0) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const lines = items
|
|
26
|
+
.map((item) => {
|
|
27
|
+
if (typeof item === 'string') {
|
|
28
|
+
return item.trim();
|
|
29
|
+
}
|
|
30
|
+
if (item && typeof item === 'object') {
|
|
31
|
+
return readString(item.text || item.title || item.name || item.label || item.content);
|
|
32
|
+
}
|
|
33
|
+
return '';
|
|
34
|
+
})
|
|
35
|
+
.filter(Boolean);
|
|
36
|
+
|
|
37
|
+
return lines.length > 0 ? lines.map((line) => `- ${line}`).join('\n') : '';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function buildPromptFromRequest(body = {}) {
|
|
41
|
+
const directPrompt = readString(body.prompt);
|
|
42
|
+
const metadata = body.metadata && typeof body.metadata === 'object' ? body.metadata : {};
|
|
43
|
+
const notion = metadata.notion && typeof metadata.notion === 'object' ? metadata.notion : {};
|
|
44
|
+
const source = { ...metadata, ...notion, ...body };
|
|
45
|
+
|
|
46
|
+
const sections = [];
|
|
47
|
+
const title = readString(source.title || source.taskTitle || source.pageTitle);
|
|
48
|
+
const description = readString(source.description || source.taskDescription || source.pageDescription);
|
|
49
|
+
const pageContent = readString(source.pageContent || source.content || source.body || source.markdown || source.richText);
|
|
50
|
+
const findings = formatRichList(source.findings);
|
|
51
|
+
const subtasks = formatRichList(source.subtasks);
|
|
52
|
+
const checklist = formatRichList(source.checklist || source.checklistMap);
|
|
53
|
+
|
|
54
|
+
if (directPrompt) {
|
|
55
|
+
sections.push(directPrompt);
|
|
56
|
+
} else if (title) {
|
|
57
|
+
sections.push(`Task: ${title}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (description) {
|
|
61
|
+
sections.push(`Description:\n${description}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (pageContent) {
|
|
65
|
+
sections.push(`Notion page content:\n${pageContent}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (subtasks) {
|
|
69
|
+
sections.push(`Subtasks:\n${subtasks}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (findings) {
|
|
73
|
+
sections.push(`Findings:\n${findings}`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (checklist) {
|
|
77
|
+
sections.push(`Checklist:\n${checklist}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return sections.filter(Boolean).join('\n\n').trim();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function sendSse(res, payload) {
|
|
84
|
+
res.write(`data: ${JSON.stringify(payload)}\n\n`);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function parseAfterSequence(value) {
|
|
88
|
+
const parsed = Number.parseInt(typeof value === 'string' ? value : '0', 10);
|
|
89
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
router.get('/providers', async (req, res) => {
|
|
93
|
+
try {
|
|
94
|
+
const providers = await listAvailableProviders();
|
|
95
|
+
res.json(providers);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
res.status(500).json({
|
|
98
|
+
error: error instanceof Error ? error.message : String(error),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
router.post('/sessions', async (req, res) => {
|
|
104
|
+
const prompt = buildPromptFromRequest(req.body);
|
|
105
|
+
const cwd = typeof req.body?.cwd === 'string' ? req.body.cwd.trim() : '';
|
|
106
|
+
|
|
107
|
+
if (!prompt) {
|
|
108
|
+
return res.status(400).json({ error: 'prompt is required' });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!cwd) {
|
|
112
|
+
return res.status(400).json({ error: 'cwd is required' });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const session = await startLocalAgentSession(
|
|
117
|
+
{
|
|
118
|
+
prompt,
|
|
119
|
+
cwd,
|
|
120
|
+
workerRole: req.body?.workerRole,
|
|
121
|
+
preferredProvider: req.body?.preferredProvider,
|
|
122
|
+
workflowDefaultProvider: req.body?.workflowDefaultProvider,
|
|
123
|
+
allowFallback: req.body?.allowFallback,
|
|
124
|
+
metadata: req.body?.metadata,
|
|
125
|
+
model: req.body?.model,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
userId: req.user?.id ?? req.user?.userId ?? null,
|
|
129
|
+
}
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
return res.status(201).json(session);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
if (error instanceof ProviderSelectionError) {
|
|
135
|
+
return res.status(error.code === 'session_not_found' ? 404 : 409).json({
|
|
136
|
+
error: error.message,
|
|
137
|
+
code: error.code,
|
|
138
|
+
...error.details,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return res.status(500).json({
|
|
143
|
+
error: error instanceof Error ? error.message : String(error),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
router.get('/sessions/:id/events', (req, res) => {
|
|
149
|
+
let unsubscribe = null;
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
const afterSequence = parseAfterSequence(req.query.after);
|
|
153
|
+
const sessionId = req.params.id;
|
|
154
|
+
getLocalAgentSession(sessionId);
|
|
155
|
+
|
|
156
|
+
res.setHeader('Content-Type', 'text/event-stream');
|
|
157
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
158
|
+
res.setHeader('Connection', 'keep-alive');
|
|
159
|
+
res.setHeader('X-Accel-Buffering', 'no');
|
|
160
|
+
|
|
161
|
+
for (const event of getLocalAgentSessionEvents(sessionId, afterSequence)) {
|
|
162
|
+
sendSse(res, event);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
unsubscribe = subscribeToLocalAgentSession(sessionId, (event) => {
|
|
166
|
+
sendSse(res, event);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const heartbeat = setInterval(() => {
|
|
170
|
+
sendSse(res, { type: 'status', heartbeat: true, timestamp: new Date().toISOString() });
|
|
171
|
+
}, 15000);
|
|
172
|
+
|
|
173
|
+
req.on('close', () => {
|
|
174
|
+
clearInterval(heartbeat);
|
|
175
|
+
unsubscribe?.();
|
|
176
|
+
if (!res.writableEnded) {
|
|
177
|
+
res.end();
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return undefined;
|
|
182
|
+
} catch (error) {
|
|
183
|
+
unsubscribe?.();
|
|
184
|
+
return res.status(error instanceof ProviderSelectionError && error.code === 'session_not_found' ? 404 : 500).json({
|
|
185
|
+
error: error instanceof Error ? error.message : String(error),
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
router.post('/sessions/:id/messages', async (req, res) => {
|
|
191
|
+
const prompt = buildPromptFromRequest(req.body);
|
|
192
|
+
|
|
193
|
+
if (!prompt) {
|
|
194
|
+
return res.status(400).json({ error: 'prompt is required' });
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
try {
|
|
198
|
+
const session = await sendLocalAgentSessionMessage(req.params.id, {
|
|
199
|
+
prompt,
|
|
200
|
+
model: req.body?.model,
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
return res.json(session);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
if (error instanceof ProviderSelectionError) {
|
|
206
|
+
return res.status(error.code === 'session_not_found' ? 404 : 409).json({
|
|
207
|
+
error: error.message,
|
|
208
|
+
code: error.code,
|
|
209
|
+
...error.details,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return res.status(500).json({
|
|
214
|
+
error: error instanceof Error ? error.message : String(error),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
router.post('/sessions/:id/abort', async (req, res) => {
|
|
220
|
+
try {
|
|
221
|
+
const result = await abortLocalAgentSession(req.params.id);
|
|
222
|
+
return res.json(result);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
if (error instanceof ProviderSelectionError) {
|
|
225
|
+
return res.status(error.code === 'session_not_found' ? 404 : 409).json({
|
|
226
|
+
error: error.message,
|
|
227
|
+
code: error.code,
|
|
228
|
+
...error.details,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return res.status(500).json({
|
|
233
|
+
error: error instanceof Error ? error.message : String(error),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
export default router;
|