freeturtle 0.1.14 → 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/README.md +79 -59
- package/dist/bin/freeturtle.js +10 -2
- package/dist/bin/freeturtle.js.map +1 -1
- package/dist/src/cli/connect-gmail.d.ts +6 -0
- package/dist/src/cli/connect-gmail.js +128 -0
- package/dist/src/cli/connect-gmail.js.map +1 -0
- package/dist/src/cli/connection-tests.d.ts +4 -0
- package/dist/src/cli/connection-tests.js +10 -0
- package/dist/src/cli/connection-tests.js.map +1 -1
- package/dist/src/cli/init.js +51 -2
- package/dist/src/cli/init.js.map +1 -1
- package/dist/src/cli/webhooks.js +3 -0
- package/dist/src/cli/webhooks.js.map +1 -1
- package/dist/src/daemon.js +37 -4
- package/dist/src/daemon.js.map +1 -1
- package/dist/src/heartbeat.js +3 -1
- package/dist/src/heartbeat.js.map +1 -1
- package/dist/src/modules/gmail/client.d.ts +62 -0
- package/dist/src/modules/gmail/client.js +144 -0
- package/dist/src/modules/gmail/client.js.map +1 -0
- package/dist/src/modules/gmail/index.d.ts +9 -0
- package/dist/src/modules/gmail/index.js +45 -0
- package/dist/src/modules/gmail/index.js.map +1 -0
- package/dist/src/modules/gmail/tools.d.ts +2 -0
- package/dist/src/modules/gmail/tools.js +70 -0
- package/dist/src/modules/gmail/tools.js.map +1 -0
- package/dist/src/modules/loader.js +6 -1
- package/dist/src/modules/loader.js.map +1 -1
- package/dist/src/modules/onchain/chains.d.ts +12 -0
- package/dist/src/modules/onchain/chains.js +83 -0
- package/dist/src/modules/onchain/chains.js.map +1 -0
- package/dist/src/modules/onchain/client.js +1 -1
- package/dist/src/modules/onchain/client.js.map +1 -1
- package/dist/src/modules/onchain/index.d.ts +4 -0
- package/dist/src/modules/onchain/index.js +32 -4
- package/dist/src/modules/onchain/index.js.map +1 -1
- package/dist/src/modules/onchain/portfolio.d.ts +3 -0
- package/dist/src/modules/onchain/portfolio.js +180 -0
- package/dist/src/modules/onchain/portfolio.js.map +1 -0
- package/dist/src/modules/onchain/taskboard.d.ts +3 -0
- package/dist/src/modules/onchain/taskboard.js +532 -0
- package/dist/src/modules/onchain/taskboard.js.map +1 -0
- package/dist/src/modules/onchain/tools.js +1 -1
- package/dist/src/modules/onchain/tools.js.map +1 -1
- package/dist/src/oauth/google.d.ts +23 -0
- package/dist/src/oauth/google.js +110 -0
- package/dist/src/oauth/google.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { keccak256, toBytes, parseEther, formatEther } from "viem";
|
|
5
|
+
import { getClients, explorerTxUrl } from "./chains.js";
|
|
6
|
+
function tasksFilePath(workspaceDir) {
|
|
7
|
+
return join(workspaceDir, "memory", "tasks.json");
|
|
8
|
+
}
|
|
9
|
+
function loadTasks(workspaceDir) {
|
|
10
|
+
if (!workspaceDir)
|
|
11
|
+
return [];
|
|
12
|
+
try {
|
|
13
|
+
const raw = readFileSync(tasksFilePath(workspaceDir), "utf-8");
|
|
14
|
+
return JSON.parse(raw);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function saveTask(task, workspaceDir) {
|
|
21
|
+
if (!workspaceDir)
|
|
22
|
+
return;
|
|
23
|
+
const tasks = loadTasks(workspaceDir);
|
|
24
|
+
tasks.push(task);
|
|
25
|
+
const dir = join(workspaceDir, "memory");
|
|
26
|
+
mkdirSync(dir, { recursive: true });
|
|
27
|
+
writeFileSync(tasksFilePath(workspaceDir), JSON.stringify(tasks, null, 2));
|
|
28
|
+
}
|
|
29
|
+
const TASK_BOARD_ABI = [
|
|
30
|
+
{
|
|
31
|
+
name: "createTask",
|
|
32
|
+
type: "function",
|
|
33
|
+
stateMutability: "payable",
|
|
34
|
+
inputs: [
|
|
35
|
+
{ name: "descriptionHash", type: "bytes32" },
|
|
36
|
+
{ name: "deadline", type: "uint256" },
|
|
37
|
+
{ name: "approvalMode", type: "uint8" },
|
|
38
|
+
],
|
|
39
|
+
outputs: [{ name: "taskId", type: "uint256" }],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "approveSubmission",
|
|
43
|
+
type: "function",
|
|
44
|
+
stateMutability: "nonpayable",
|
|
45
|
+
inputs: [
|
|
46
|
+
{ name: "taskId", type: "uint256" },
|
|
47
|
+
{ name: "submissionIndex", type: "uint256" },
|
|
48
|
+
],
|
|
49
|
+
outputs: [],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "cancelTask",
|
|
53
|
+
type: "function",
|
|
54
|
+
stateMutability: "nonpayable",
|
|
55
|
+
inputs: [{ name: "taskId", type: "uint256" }],
|
|
56
|
+
outputs: [],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "withdraw",
|
|
60
|
+
type: "function",
|
|
61
|
+
stateMutability: "nonpayable",
|
|
62
|
+
inputs: [],
|
|
63
|
+
outputs: [],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "getTask",
|
|
67
|
+
type: "function",
|
|
68
|
+
stateMutability: "view",
|
|
69
|
+
inputs: [{ name: "taskId", type: "uint256" }],
|
|
70
|
+
outputs: [
|
|
71
|
+
{ name: "descriptionHash", type: "bytes32" },
|
|
72
|
+
{ name: "reward", type: "uint256" },
|
|
73
|
+
{ name: "deadline", type: "uint256" },
|
|
74
|
+
{ name: "approvalMode", type: "uint8" },
|
|
75
|
+
{ name: "status", type: "uint8" },
|
|
76
|
+
{ name: "createdAt", type: "uint256" },
|
|
77
|
+
{ name: "winner", type: "address" },
|
|
78
|
+
{ name: "submissionCount", type: "uint256" },
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "getSubmission",
|
|
83
|
+
type: "function",
|
|
84
|
+
stateMutability: "view",
|
|
85
|
+
inputs: [
|
|
86
|
+
{ name: "taskId", type: "uint256" },
|
|
87
|
+
{ name: "submissionIndex", type: "uint256" },
|
|
88
|
+
],
|
|
89
|
+
outputs: [
|
|
90
|
+
{ name: "contributor", type: "address" },
|
|
91
|
+
{ name: "contentHash", type: "bytes32" },
|
|
92
|
+
{ name: "submittedAt", type: "uint256" },
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "getTaskIdsInRange",
|
|
97
|
+
type: "function",
|
|
98
|
+
stateMutability: "view",
|
|
99
|
+
inputs: [
|
|
100
|
+
{ name: "start", type: "uint256" },
|
|
101
|
+
{ name: "end", type: "uint256" },
|
|
102
|
+
],
|
|
103
|
+
outputs: [{ name: "ids", type: "uint256[]" }],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "taskCount",
|
|
107
|
+
type: "function",
|
|
108
|
+
stateMutability: "view",
|
|
109
|
+
inputs: [],
|
|
110
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "pendingWithdrawals",
|
|
114
|
+
type: "function",
|
|
115
|
+
stateMutability: "view",
|
|
116
|
+
inputs: [{ name: "", type: "address" }],
|
|
117
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
const TASK_STATUS = ["Open", "Completed", "Cancelled"];
|
|
121
|
+
export const taskboardTools = [
|
|
122
|
+
{
|
|
123
|
+
name: "create_task",
|
|
124
|
+
description: "Create a new task on the TaskBoard contract, funded with ETH from the CEO wallet. A unique email keyword is auto-generated — contributors must include it in their email subject line when submitting deliverables. When approval_mode is 'ceo', search Gmail for the keyword to find and evaluate submissions autonomously.",
|
|
125
|
+
input_schema: {
|
|
126
|
+
type: "object",
|
|
127
|
+
properties: {
|
|
128
|
+
description: {
|
|
129
|
+
type: "string",
|
|
130
|
+
description: "Clear description of the work to be done",
|
|
131
|
+
},
|
|
132
|
+
reward_eth: {
|
|
133
|
+
type: "string",
|
|
134
|
+
description: 'ETH amount to fund (e.g. "0.005")',
|
|
135
|
+
},
|
|
136
|
+
approval_mode: {
|
|
137
|
+
type: "string",
|
|
138
|
+
description: 'Who approves submissions — "ceo" or "founder"',
|
|
139
|
+
},
|
|
140
|
+
judging_criteria: {
|
|
141
|
+
type: "string",
|
|
142
|
+
description: 'When approval_mode is "ceo", the founder\'s natural-language description of what makes a good submission. The CEO uses this to autonomously evaluate and pick a winner. E.g. "Looking for thorough analysis with cited sources, clear actionable recommendations, and at least 3 alternative strategies compared."',
|
|
143
|
+
},
|
|
144
|
+
deadline_hours: {
|
|
145
|
+
type: "number",
|
|
146
|
+
description: "Hours until deadline. 0 or omitted = no deadline.",
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
required: ["description", "reward_eth", "approval_mode"],
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: "approve_task_submission",
|
|
154
|
+
description: "Approve a submission for a task. This allocates the escrowed ETH to the contributor's pending balance — they call withdraw() to claim. Only works for tasks where approval_mode is 'ceo'.",
|
|
155
|
+
input_schema: {
|
|
156
|
+
type: "object",
|
|
157
|
+
properties: {
|
|
158
|
+
task_id: { type: "number", description: "The task ID" },
|
|
159
|
+
submission_index: {
|
|
160
|
+
type: "number",
|
|
161
|
+
description: "Which submission to approve (0-indexed)",
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
required: ["task_id", "submission_index"],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "cancel_task",
|
|
169
|
+
description: "Cancel an open task and refund escrowed ETH to the CEO wallet.",
|
|
170
|
+
input_schema: {
|
|
171
|
+
type: "object",
|
|
172
|
+
properties: {
|
|
173
|
+
task_id: { type: "number", description: "The task ID to cancel" },
|
|
174
|
+
},
|
|
175
|
+
required: ["task_id"],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: "get_open_tasks",
|
|
180
|
+
description: "List all currently open tasks from the TaskBoard contract.",
|
|
181
|
+
input_schema: {
|
|
182
|
+
type: "object",
|
|
183
|
+
properties: {},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "get_task_submissions",
|
|
188
|
+
description: "Get all submissions for a specific task. Use this to review deliverables before approving a winner.",
|
|
189
|
+
input_schema: {
|
|
190
|
+
type: "object",
|
|
191
|
+
properties: {
|
|
192
|
+
task_id: { type: "number", description: "The task ID" },
|
|
193
|
+
},
|
|
194
|
+
required: ["task_id"],
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "review_task_submissions",
|
|
199
|
+
description: "Review all submissions for a CEO-approved task. Fetches the stored task description, judging criteria, onchain submissions, and corresponding email deliverables from Gmail. Returns everything needed for the CEO to evaluate submissions and pick a winner. After reviewing, call approve_task_submission to approve the best one.",
|
|
200
|
+
input_schema: {
|
|
201
|
+
type: "object",
|
|
202
|
+
properties: {
|
|
203
|
+
task_id: { type: "number", description: "The task ID to review" },
|
|
204
|
+
},
|
|
205
|
+
required: ["task_id"],
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: "check_pending_withdrawal",
|
|
210
|
+
description: "Check how much ETH a contributor has available to withdraw from the TaskBoard contract.",
|
|
211
|
+
input_schema: {
|
|
212
|
+
type: "object",
|
|
213
|
+
properties: {
|
|
214
|
+
address: {
|
|
215
|
+
type: "string",
|
|
216
|
+
description: "The contributor's Ethereum address",
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
required: ["address"],
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
];
|
|
223
|
+
export async function executeTaskboardTool(name, input, env, workspaceDir) {
|
|
224
|
+
const contractAddress = env.TASK_CONTRACT_ADDRESS;
|
|
225
|
+
if (!contractAddress) {
|
|
226
|
+
return JSON.stringify({
|
|
227
|
+
error: true,
|
|
228
|
+
message: "TASK_CONTRACT_ADDRESS not set",
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
switch (name) {
|
|
233
|
+
case "create_task":
|
|
234
|
+
return await createTask(contractAddress, input.description, input.reward_eth, input.approval_mode, input.judging_criteria, input.deadline_hours, env, workspaceDir);
|
|
235
|
+
case "approve_task_submission":
|
|
236
|
+
return await approveTaskSubmission(contractAddress, input.task_id, input.submission_index, env);
|
|
237
|
+
case "cancel_task":
|
|
238
|
+
return await cancelTask(contractAddress, input.task_id, env);
|
|
239
|
+
case "get_open_tasks":
|
|
240
|
+
return await getOpenTasks(contractAddress, env, workspaceDir);
|
|
241
|
+
case "get_task_submissions":
|
|
242
|
+
return await getTaskSubmissions(contractAddress, input.task_id, env);
|
|
243
|
+
case "review_task_submissions":
|
|
244
|
+
return await reviewTaskSubmissions(contractAddress, input.task_id, env, workspaceDir);
|
|
245
|
+
case "check_pending_withdrawal":
|
|
246
|
+
return await checkPendingWithdrawal(contractAddress, input.address, env);
|
|
247
|
+
default:
|
|
248
|
+
throw new Error(`Unknown taskboard tool: ${name}`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
const msg = error instanceof Error
|
|
253
|
+
? error.shortMessage || error.message
|
|
254
|
+
: "Unknown error";
|
|
255
|
+
return JSON.stringify({ error: true, message: `Failed: ${msg}` });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
async function createTask(contractAddress, description, rewardEth, approvalMode, judgingCriteria, deadlineHours, env, workspaceDir) {
|
|
259
|
+
const { chain, account, walletClient, publicClient } = getClients(env);
|
|
260
|
+
// Generate a unique email keyword for submission delivery
|
|
261
|
+
const keyword = `TASK-${randomBytes(4).toString("hex").toUpperCase()}`;
|
|
262
|
+
const fullDescription = `${description}\n\nSubmit deliverables by email with subject keyword: ${keyword}`;
|
|
263
|
+
const descriptionHash = keccak256(toBytes(fullDescription));
|
|
264
|
+
const deadline = deadlineHours
|
|
265
|
+
? BigInt(Math.floor(Date.now() / 1000) + deadlineHours * 3600)
|
|
266
|
+
: 0n;
|
|
267
|
+
const mode = approvalMode.toLowerCase() === "founder" ? 1 : 0;
|
|
268
|
+
const hash = await walletClient.writeContract({
|
|
269
|
+
chain,
|
|
270
|
+
account,
|
|
271
|
+
address: contractAddress,
|
|
272
|
+
abi: TASK_BOARD_ABI,
|
|
273
|
+
functionName: "createTask",
|
|
274
|
+
args: [descriptionHash, deadline, mode],
|
|
275
|
+
value: parseEther(rewardEth),
|
|
276
|
+
});
|
|
277
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
278
|
+
const count = await publicClient.readContract({
|
|
279
|
+
address: contractAddress,
|
|
280
|
+
abi: TASK_BOARD_ABI,
|
|
281
|
+
functionName: "taskCount",
|
|
282
|
+
});
|
|
283
|
+
const taskId = Number(count) - 1;
|
|
284
|
+
saveTask({
|
|
285
|
+
taskId,
|
|
286
|
+
description: fullDescription,
|
|
287
|
+
emailKeyword: keyword,
|
|
288
|
+
rewardEth,
|
|
289
|
+
approvalMode,
|
|
290
|
+
...(judgingCriteria ? { judgingCriteria } : {}),
|
|
291
|
+
deadlineHours: deadlineHours || "none",
|
|
292
|
+
chain: chain.name,
|
|
293
|
+
createdAt: new Date().toISOString(),
|
|
294
|
+
}, workspaceDir);
|
|
295
|
+
return JSON.stringify({
|
|
296
|
+
taskId,
|
|
297
|
+
description: fullDescription,
|
|
298
|
+
emailKeyword: keyword,
|
|
299
|
+
emailSearchHint: `Search Gmail for subject:${keyword} to find submissions`,
|
|
300
|
+
rewardEth,
|
|
301
|
+
approvalMode,
|
|
302
|
+
deadlineHours: deadlineHours || "none",
|
|
303
|
+
txHash: hash,
|
|
304
|
+
explorerUrl: explorerTxUrl(chain, hash),
|
|
305
|
+
chain: chain.name,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
async function approveTaskSubmission(contractAddress, taskId, submissionIndex, env) {
|
|
309
|
+
const { chain, account, walletClient, publicClient } = getClients(env);
|
|
310
|
+
const [contributor, ,] = await publicClient.readContract({
|
|
311
|
+
address: contractAddress,
|
|
312
|
+
abi: TASK_BOARD_ABI,
|
|
313
|
+
functionName: "getSubmission",
|
|
314
|
+
args: [BigInt(taskId), BigInt(submissionIndex)],
|
|
315
|
+
});
|
|
316
|
+
const taskData = await publicClient.readContract({
|
|
317
|
+
address: contractAddress,
|
|
318
|
+
abi: TASK_BOARD_ABI,
|
|
319
|
+
functionName: "getTask",
|
|
320
|
+
args: [BigInt(taskId)],
|
|
321
|
+
});
|
|
322
|
+
const reward = taskData[1];
|
|
323
|
+
const hash = await walletClient.writeContract({
|
|
324
|
+
chain,
|
|
325
|
+
account,
|
|
326
|
+
address: contractAddress,
|
|
327
|
+
abi: TASK_BOARD_ABI,
|
|
328
|
+
functionName: "approveSubmission",
|
|
329
|
+
args: [BigInt(taskId), BigInt(submissionIndex)],
|
|
330
|
+
});
|
|
331
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
332
|
+
return JSON.stringify({
|
|
333
|
+
taskId,
|
|
334
|
+
submissionIndex,
|
|
335
|
+
winner: contributor,
|
|
336
|
+
rewardEth: formatEther(reward),
|
|
337
|
+
status: "approved — contributor can now withdraw funds by calling withdraw() on the contract",
|
|
338
|
+
txHash: hash,
|
|
339
|
+
explorerUrl: explorerTxUrl(chain, hash),
|
|
340
|
+
chain: chain.name,
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
async function cancelTask(contractAddress, taskId, env) {
|
|
344
|
+
const { chain, account, walletClient, publicClient } = getClients(env);
|
|
345
|
+
const hash = await walletClient.writeContract({
|
|
346
|
+
chain,
|
|
347
|
+
account,
|
|
348
|
+
address: contractAddress,
|
|
349
|
+
abi: TASK_BOARD_ABI,
|
|
350
|
+
functionName: "cancelTask",
|
|
351
|
+
args: [BigInt(taskId)],
|
|
352
|
+
});
|
|
353
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
354
|
+
return JSON.stringify({
|
|
355
|
+
taskId,
|
|
356
|
+
status: "cancelled — escrowed ETH refunded",
|
|
357
|
+
txHash: hash,
|
|
358
|
+
explorerUrl: explorerTxUrl(chain, hash),
|
|
359
|
+
chain: chain.name,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
async function getOpenTasks(contractAddress, env, workspaceDir) {
|
|
363
|
+
const { chain, publicClient } = getClients(env);
|
|
364
|
+
const count = await publicClient.readContract({
|
|
365
|
+
address: contractAddress,
|
|
366
|
+
abi: TASK_BOARD_ABI,
|
|
367
|
+
functionName: "taskCount",
|
|
368
|
+
});
|
|
369
|
+
const total = Number(count);
|
|
370
|
+
if (total === 0)
|
|
371
|
+
return JSON.stringify({ tasks: [], chain: chain.name });
|
|
372
|
+
const ids = await publicClient.readContract({
|
|
373
|
+
address: contractAddress,
|
|
374
|
+
abi: TASK_BOARD_ABI,
|
|
375
|
+
functionName: "getTaskIdsInRange",
|
|
376
|
+
args: [0n, BigInt(total)],
|
|
377
|
+
});
|
|
378
|
+
const storedTasks = loadTasks(workspaceDir);
|
|
379
|
+
const storedByIdMap = new Map(storedTasks.map((t) => [t.taskId, t]));
|
|
380
|
+
const openTasks = [];
|
|
381
|
+
for (const id of ids) {
|
|
382
|
+
const taskData = await publicClient.readContract({
|
|
383
|
+
address: contractAddress,
|
|
384
|
+
abi: TASK_BOARD_ABI,
|
|
385
|
+
functionName: "getTask",
|
|
386
|
+
args: [id],
|
|
387
|
+
});
|
|
388
|
+
if (Number(taskData[4]) === 0) {
|
|
389
|
+
const taskId = Number(id);
|
|
390
|
+
const stored = storedByIdMap.get(taskId);
|
|
391
|
+
openTasks.push({
|
|
392
|
+
taskId,
|
|
393
|
+
descriptionHash: taskData[0],
|
|
394
|
+
...(stored
|
|
395
|
+
? {
|
|
396
|
+
description: stored.description,
|
|
397
|
+
emailKeyword: stored.emailKeyword,
|
|
398
|
+
}
|
|
399
|
+
: {}),
|
|
400
|
+
rewardEth: formatEther(taskData[1]),
|
|
401
|
+
deadline: Number(taskData[2]) === 0
|
|
402
|
+
? "none"
|
|
403
|
+
: new Date(Number(taskData[2]) * 1000).toISOString(),
|
|
404
|
+
approvalMode: Number(taskData[3]) === 0 ? "CEO" : "Founder",
|
|
405
|
+
submissionCount: Number(taskData[7]),
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return JSON.stringify({ tasks: openTasks, chain: chain.name });
|
|
410
|
+
}
|
|
411
|
+
async function getTaskSubmissions(contractAddress, taskId, env) {
|
|
412
|
+
const { chain, publicClient } = getClients(env);
|
|
413
|
+
const taskData = await publicClient.readContract({
|
|
414
|
+
address: contractAddress,
|
|
415
|
+
abi: TASK_BOARD_ABI,
|
|
416
|
+
functionName: "getTask",
|
|
417
|
+
args: [BigInt(taskId)],
|
|
418
|
+
});
|
|
419
|
+
const submissionCount = Number(taskData[7]);
|
|
420
|
+
const subs = [];
|
|
421
|
+
for (let i = 0; i < submissionCount; i++) {
|
|
422
|
+
const [contributor, contentHash, submittedAt] = await publicClient.readContract({
|
|
423
|
+
address: contractAddress,
|
|
424
|
+
abi: TASK_BOARD_ABI,
|
|
425
|
+
functionName: "getSubmission",
|
|
426
|
+
args: [BigInt(taskId), BigInt(i)],
|
|
427
|
+
});
|
|
428
|
+
subs.push({
|
|
429
|
+
submissionIndex: i,
|
|
430
|
+
contributor,
|
|
431
|
+
contentHash,
|
|
432
|
+
submittedAt: new Date(Number(submittedAt) * 1000).toISOString(),
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
return JSON.stringify({
|
|
436
|
+
taskId,
|
|
437
|
+
rewardEth: formatEther(taskData[1]),
|
|
438
|
+
status: TASK_STATUS[Number(taskData[4])],
|
|
439
|
+
approvalMode: Number(taskData[3]) === 0 ? "CEO" : "Founder",
|
|
440
|
+
submissions: subs,
|
|
441
|
+
chain: chain.name,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
async function reviewTaskSubmissions(contractAddress, taskId, env, workspaceDir) {
|
|
445
|
+
const { chain, publicClient } = getClients(env);
|
|
446
|
+
// Get onchain task data
|
|
447
|
+
const taskData = await publicClient.readContract({
|
|
448
|
+
address: contractAddress,
|
|
449
|
+
abi: TASK_BOARD_ABI,
|
|
450
|
+
functionName: "getTask",
|
|
451
|
+
args: [BigInt(taskId)],
|
|
452
|
+
});
|
|
453
|
+
const status = Number(taskData[4]);
|
|
454
|
+
if (status !== 0) {
|
|
455
|
+
return JSON.stringify({
|
|
456
|
+
error: true,
|
|
457
|
+
message: `Task ${taskId} is ${TASK_STATUS[status]}, not Open`,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
const approvalMode = Number(taskData[3]) === 0 ? "CEO" : "Founder";
|
|
461
|
+
if (approvalMode !== "CEO") {
|
|
462
|
+
return JSON.stringify({
|
|
463
|
+
error: true,
|
|
464
|
+
message: `Task ${taskId} uses Founder approval — only the founder can approve via the contract directly`,
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
// Get onchain submissions
|
|
468
|
+
const submissionCount = Number(taskData[7]);
|
|
469
|
+
const submissions = [];
|
|
470
|
+
for (let i = 0; i < submissionCount; i++) {
|
|
471
|
+
const [contributor, contentHash, submittedAt] = await publicClient.readContract({
|
|
472
|
+
address: contractAddress,
|
|
473
|
+
abi: TASK_BOARD_ABI,
|
|
474
|
+
functionName: "getSubmission",
|
|
475
|
+
args: [BigInt(taskId), BigInt(i)],
|
|
476
|
+
});
|
|
477
|
+
submissions.push({
|
|
478
|
+
submissionIndex: i,
|
|
479
|
+
contributor,
|
|
480
|
+
contentHash,
|
|
481
|
+
submittedAt: new Date(Number(submittedAt) * 1000).toISOString(),
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
// Get stored task data (description, keyword, judging criteria)
|
|
485
|
+
const storedTasks = loadTasks(workspaceDir);
|
|
486
|
+
const stored = storedTasks.find((t) => t.taskId === taskId);
|
|
487
|
+
const result = {
|
|
488
|
+
taskId,
|
|
489
|
+
rewardEth: formatEther(taskData[1]),
|
|
490
|
+
deadline: Number(taskData[2]) === 0
|
|
491
|
+
? "none"
|
|
492
|
+
: new Date(Number(taskData[2]) * 1000).toISOString(),
|
|
493
|
+
approvalMode,
|
|
494
|
+
submissionCount,
|
|
495
|
+
submissions,
|
|
496
|
+
chain: chain.name,
|
|
497
|
+
};
|
|
498
|
+
if (stored) {
|
|
499
|
+
result.description = stored.description;
|
|
500
|
+
result.emailKeyword = stored.emailKeyword;
|
|
501
|
+
result.judgingCriteria = stored.judgingCriteria || "No specific criteria set — use your best judgment.";
|
|
502
|
+
result.nextSteps = [
|
|
503
|
+
`1. Search Gmail for emails matching: subject:${stored.emailKeyword}`,
|
|
504
|
+
"2. Read each email to review the deliverable content",
|
|
505
|
+
"3. Evaluate each submission against the judging criteria",
|
|
506
|
+
"4. Call approve_task_submission with the task_id and winning submission_index",
|
|
507
|
+
];
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
result.description = "(not available — task was created in a previous session without local persistence)";
|
|
511
|
+
result.nextSteps = [
|
|
512
|
+
"1. Review the onchain submissions above",
|
|
513
|
+
"2. Call approve_task_submission with the task_id and winning submission_index",
|
|
514
|
+
];
|
|
515
|
+
}
|
|
516
|
+
return JSON.stringify(result);
|
|
517
|
+
}
|
|
518
|
+
async function checkPendingWithdrawal(contractAddress, address, env) {
|
|
519
|
+
const { chain, publicClient } = getClients(env);
|
|
520
|
+
const pending = await publicClient.readContract({
|
|
521
|
+
address: contractAddress,
|
|
522
|
+
abi: TASK_BOARD_ABI,
|
|
523
|
+
functionName: "pendingWithdrawals",
|
|
524
|
+
args: [address],
|
|
525
|
+
});
|
|
526
|
+
return JSON.stringify({
|
|
527
|
+
address,
|
|
528
|
+
pendingEth: formatEther(pending),
|
|
529
|
+
chain: chain.name,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
//# sourceMappingURL=taskboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskboard.js","source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C,CAAC;IAEhD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC;QAC9C,OAAO,EAAE,eAAe;QACxB,GAAG,EAAE,cAAc;QACnB,YAAY,EAAE,oBAAoB;QAClC,IAAI,EAAE,CAAC,OAAwB,CAAC;KACjC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,OAAO;QACP,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC;QAChC,KAAK,EAAE,KAAK,CAAC,IAAI;KAClB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -41,7 +41,7 @@ export const onchainTools = [
|
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
name: "get_transactions",
|
|
44
|
-
description: "Get recent transactions for an address on Base (requires
|
|
44
|
+
description: "Get recent transactions for an address on Base (requires BLOCK_EXPLORER_API_KEY).",
|
|
45
45
|
input_schema: {
|
|
46
46
|
type: "object",
|
|
47
47
|
properties: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../../src/modules/onchain/tools.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EACT,mGAAmG;QACrG,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0BAA0B;iBACxC;gBACD,GAAG,EAAE;oBACH,IAAI,EAAE,OAAO;oBACb,WAAW,EAAE,uDAAuD;iBACrE;gBACD,aAAa,EAAE;oBACb,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,8BAA8B;iBAC5C;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,WAAW,EAAE,+BAA+B;iBAC7C;aACF;YACD,QAAQ,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,eAAe,CAAC;SAC9C;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,4CAA4C;QACzD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,wBAAwB;iBACtC;aACF;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;KACF;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../../src/modules/onchain/tools.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EACT,mGAAmG;QACrG,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0BAA0B;iBACxC;gBACD,GAAG,EAAE;oBACH,IAAI,EAAE,OAAO;oBACb,WAAW,EAAE,uDAAuD;iBACrE;gBACD,aAAa,EAAE;oBACb,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,8BAA8B;iBAC5C;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO;oBACb,WAAW,EAAE,+BAA+B;iBAC7C;aACF;YACD,QAAQ,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,eAAe,CAAC;SAC9C;KACF;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,4CAA4C;QACzD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,wBAAwB;iBACtC;aACF;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;KACF;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,WAAW,EACT,mFAAmF;QACrF,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,wBAAwB;iBACtC;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,+CAA+C;iBAC7D;aACF;YACD,QAAQ,EAAE,CAAC,SAAS,CAAC;SACtB;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OAuth2Client } from "google-auth-library";
|
|
2
|
+
export interface GoogleOAuthCredentials {
|
|
3
|
+
clientId: string;
|
|
4
|
+
clientSecret: string;
|
|
5
|
+
refreshToken: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Create an authenticated OAuth2Client with auto-refresh.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createGoogleOAuth2Client(creds: GoogleOAuthCredentials): OAuth2Client;
|
|
11
|
+
/**
|
|
12
|
+
* Run the browser-based OAuth2 consent flow.
|
|
13
|
+
*
|
|
14
|
+
* Matches OpenClaw's approach:
|
|
15
|
+
* 1. Starts a local HTTP server on 127.0.0.1
|
|
16
|
+
* 2. Opens the consent URL in the user's browser
|
|
17
|
+
* 3. Waits for the redirect callback with the auth code
|
|
18
|
+
* 4. Exchanges the code for tokens
|
|
19
|
+
* 5. Returns the refresh_token
|
|
20
|
+
*/
|
|
21
|
+
export declare function runGoogleOAuthFlow(clientId: string, clientSecret: string, opts?: {
|
|
22
|
+
port?: number;
|
|
23
|
+
}): Promise<string>;
|