assistme 0.8.2 → 0.8.4
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/dist/{chunk-A2NR7LCQ.js → chunk-3UNXN3BX.js} +60 -35
- package/dist/chunk-HY3FFXSQ.js +113 -0
- package/dist/{chunk-IKYXC4RJ.js → chunk-R7A3MKYO.js} +645 -329
- package/dist/config-2HH7PO34.js +20 -0
- package/dist/index.js +658 -788
- package/dist/job-runner-P4DIXXCV.js +7 -0
- package/dist/workers/entry.js +535 -316
- package/package.json +1 -1
- package/src/NAMING.md +34 -0
- package/src/agent/heartbeat-checks.ts +158 -0
- package/src/agent/heartbeat-compiler.ts +122 -0
- package/src/agent/heartbeat-types.ts +62 -0
- package/src/agent/job-analysis-poller.ts +96 -0
- package/src/agent/job-runner.ts +31 -0
- package/src/agent/proactive-monitor.ts +88 -410
- package/src/agent/processor.ts +147 -252
- package/src/agent/prompt-builder.ts +83 -0
- package/src/agent/scheduler.ts +1 -1
- package/src/agent/sdk-stream.ts +105 -0
- package/src/agent/self-analyzer.ts +21 -22
- package/src/agent/session-heartbeat.ts +34 -0
- package/src/agent/skill-db.ts +170 -0
- package/src/agent/skill-evaluator.ts +4 -13
- package/src/agent/skill-format.ts +96 -0
- package/src/agent/skill-marketplace.ts +98 -0
- package/src/agent/skill-search.ts +315 -0
- package/src/agent/skill-types.ts +68 -0
- package/src/agent/skill-utils.ts +66 -0
- package/src/agent/skills.ts +270 -568
- package/src/agent/system-prompt.ts +11 -8
- package/src/agent/task-poller.ts +101 -0
- package/src/agent/task-timeout.ts +50 -0
- package/src/browser/chrome-launcher.ts +6 -6
- package/src/browser/controller.ts +1 -2
- package/src/commands/auth.ts +4 -11
- package/src/commands/browser.ts +12 -47
- package/src/commands/credential.ts +2 -2
- package/src/commands/job.ts +3 -3
- package/src/credentials/encryption.ts +4 -10
- package/src/credentials/local-store.ts +4 -7
- package/src/credentials/program-store.ts +8 -10
- package/src/db/auth-store.ts +15 -13
- package/src/db/session-log.ts +12 -5
- package/src/mcp/agent-tools-server.ts +132 -103
- package/src/mcp/ask-user.ts +102 -0
- package/src/mcp/skill-confirmation.ts +109 -0
- package/src/orchestrator.ts +100 -350
- package/src/tools/filesystem.ts +48 -2
- package/src/tools/index.ts +1 -2
- package/src/tools/shell.ts +58 -2
- package/src/types/edsger-feedback.d.ts +18 -0
- package/src/utils/config.ts +79 -1
- package/src/utils/logger.ts +52 -12
- package/src/utils/lru-cache.ts +57 -0
- package/src/utils/schemas.ts +2 -0
- package/src/workers/base-handler.ts +7 -1
- package/src/workers/index.ts +2 -0
- package/src/workers/log-forwarder.ts +55 -0
- package/src/workers/manager.ts +82 -220
- package/src/workers/types.ts +9 -1
- package/src/workers/worker-lifecycle.ts +113 -0
- package/tests/agent/heartbeat-checks.test.ts +160 -0
- package/tests/agent/mcp-servers.test.ts +1 -1
- package/tests/agent/proactive-monitor.test.ts +42 -26
- package/tests/agent/processor.test.ts +2 -1
- package/tests/agent/sdk-stream.test.ts +181 -0
- package/tests/agent/self-analyzer.test.ts +106 -49
- package/tests/agent/session.test.ts +114 -132
- package/tests/agent/skill-format.test.ts +93 -0
- package/tests/agent/skill-search.test.ts +175 -0
- package/tests/agent/skill-utils.test.ts +86 -0
- package/tests/agent/skills.test.ts +4 -24
- package/tests/db/supabase.test.ts +3 -2
- package/tests/mcp/ask-user.test.ts +117 -0
- package/tests/mcp/skill-confirmation.integration.test.ts +216 -0
- package/tests/mcp/skill-confirmation.test.ts +66 -0
- package/tests/tools/filesystem.test.ts +38 -1
- package/tests/tools/shell.test.ts +43 -0
- package/tests/utils/config.test.ts +2 -2
- package/dist/chunk-YYSJHZSO.js +0 -47
- package/dist/config-3RWSAUAZ.js +0 -12
- package/dist/job-runner-PECVS424.js +0 -7
- package/src/agent/session.ts +0 -348
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
errorMessage,
|
|
3
|
+
getConfig,
|
|
4
|
+
getDataDir
|
|
5
|
+
} from "./chunk-HY3FFXSQ.js";
|
|
4
6
|
|
|
5
7
|
// src/db/auth-store.ts
|
|
6
|
-
import { existsSync,
|
|
8
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
7
9
|
import { join } from "path";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var AUTH_FILE = join(AUTH_DIR, "auth.json");
|
|
11
|
-
function ensureAuthDir() {
|
|
12
|
-
if (!existsSync(AUTH_DIR)) {
|
|
13
|
-
mkdirSync(AUTH_DIR, { recursive: true, mode: 448 });
|
|
14
|
-
}
|
|
10
|
+
function getAuthFile() {
|
|
11
|
+
return join(getDataDir(), "auth.json");
|
|
15
12
|
}
|
|
16
13
|
function readAuthStore() {
|
|
17
14
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const authFile = getAuthFile();
|
|
16
|
+
if (existsSync(authFile)) {
|
|
17
|
+
return JSON.parse(readFileSync(authFile, "utf-8"));
|
|
20
18
|
}
|
|
21
19
|
} catch {
|
|
22
20
|
}
|
|
23
21
|
return {};
|
|
24
22
|
}
|
|
25
23
|
function writeAuthStore(data) {
|
|
26
|
-
|
|
27
|
-
writeFileSync(AUTH_FILE, JSON.stringify(data, null, 2), { mode: 384 });
|
|
24
|
+
writeFileSync(getAuthFile(), JSON.stringify(data, null, 2), { mode: 384 });
|
|
28
25
|
}
|
|
29
26
|
function getRawToken() {
|
|
27
|
+
const envToken = process.env.ASSISTME_TOKEN;
|
|
28
|
+
if (envToken && envToken.startsWith("am_")) {
|
|
29
|
+
return envToken;
|
|
30
|
+
}
|
|
30
31
|
const store = readAuthStore();
|
|
31
32
|
const token = store["mcp_token"];
|
|
32
33
|
if (!token || !token.startsWith("am_")) {
|
|
@@ -352,25 +353,6 @@ var HEARTBEAT_MAX_BUDGET_USD = 0.25;
|
|
|
352
353
|
var HEARTBEAT_LOG_MAX_ENTRIES = 100;
|
|
353
354
|
var MAX_COMPLETE_TASK_RETRIES = 2;
|
|
354
355
|
|
|
355
|
-
// src/utils/errors.ts
|
|
356
|
-
var AppError = class _AppError extends Error {
|
|
357
|
-
constructor(message, code, cause) {
|
|
358
|
-
super(message);
|
|
359
|
-
this.code = code;
|
|
360
|
-
this.cause = cause;
|
|
361
|
-
this.name = "AppError";
|
|
362
|
-
}
|
|
363
|
-
static fromUnknown(err, code = "INTERNAL") {
|
|
364
|
-
if (err instanceof _AppError) return err;
|
|
365
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
366
|
-
return new _AppError(message, code, err);
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
function errorMessage(err) {
|
|
370
|
-
if (err instanceof Error) return err.message;
|
|
371
|
-
return String(err);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
356
|
// src/agent/job-runner.ts
|
|
375
357
|
var JobRunner = class {
|
|
376
358
|
/**
|
|
@@ -475,6 +457,51 @@ var JobRunner = class {
|
|
|
475
457
|
return [];
|
|
476
458
|
}
|
|
477
459
|
}
|
|
460
|
+
/**
|
|
461
|
+
* Build a prompt for analyzing a job's skill requirements.
|
|
462
|
+
* Used by the orchestrator to dispatch analysis tasks for newly created jobs.
|
|
463
|
+
*/
|
|
464
|
+
buildJobAnalysisPrompt(job) {
|
|
465
|
+
let prompt = `Analyze this job definition and determine what skills are needed to execute it effectively.
|
|
466
|
+
|
|
467
|
+
`;
|
|
468
|
+
prompt += `## Job Definition
|
|
469
|
+
`;
|
|
470
|
+
prompt += `**Name:** ${job.jobName}
|
|
471
|
+
`;
|
|
472
|
+
prompt += `**Description:** ${job.jobDescription}
|
|
473
|
+
|
|
474
|
+
`;
|
|
475
|
+
if (job.skills.length > 0) {
|
|
476
|
+
prompt += `**Current Skills:**
|
|
477
|
+
`;
|
|
478
|
+
for (const skill of job.skills) {
|
|
479
|
+
const emoji = skill.skillEmoji ? `${skill.skillEmoji} ` : "";
|
|
480
|
+
prompt += `- ${emoji}${skill.skillName}: ${skill.skillDescription}
|
|
481
|
+
`;
|
|
482
|
+
}
|
|
483
|
+
prompt += `
|
|
484
|
+
`;
|
|
485
|
+
}
|
|
486
|
+
prompt += `## Instructions
|
|
487
|
+
`;
|
|
488
|
+
prompt += `For each capability the job needs:
|
|
489
|
+
`;
|
|
490
|
+
prompt += `1. Check if an existing skill covers it (use \`skill_search\` to check)
|
|
491
|
+
`;
|
|
492
|
+
prompt += `2. If no existing skill covers it, create a new one using \`skill_create\`
|
|
493
|
+
`;
|
|
494
|
+
prompt += `3. If an existing skill needs improvement, update it using \`skill_improve\`
|
|
495
|
+
`;
|
|
496
|
+
prompt += `4. Link all relevant skills to the job using \`skill_link_job\`
|
|
497
|
+
|
|
498
|
+
`;
|
|
499
|
+
prompt += `Be practical \u2014 only create skills that would genuinely help automate this job.
|
|
500
|
+
`;
|
|
501
|
+
prompt += `When done, summarize what skills were created, updated, or already existed.
|
|
502
|
+
`;
|
|
503
|
+
return prompt;
|
|
504
|
+
}
|
|
478
505
|
/**
|
|
479
506
|
* Build the agentic prompt for the agent to execute a job.
|
|
480
507
|
*
|
|
@@ -574,8 +601,6 @@ export {
|
|
|
574
601
|
HEARTBEAT_MAX_BUDGET_USD,
|
|
575
602
|
HEARTBEAT_LOG_MAX_ENTRIES,
|
|
576
603
|
MAX_COMPLETE_TASK_RETRIES,
|
|
577
|
-
AppError,
|
|
578
|
-
errorMessage,
|
|
579
604
|
safeParse,
|
|
580
605
|
SkillRowSchema,
|
|
581
606
|
SkillCreateResultSchema,
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// src/utils/config.ts
|
|
2
|
+
import Conf from "conf";
|
|
3
|
+
import { resolve, basename, join, relative, sep } from "path";
|
|
4
|
+
import { existsSync, mkdirSync } from "fs";
|
|
5
|
+
|
|
6
|
+
// src/utils/errors.ts
|
|
7
|
+
var AppError = class _AppError extends Error {
|
|
8
|
+
constructor(message, code, cause) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.cause = cause;
|
|
12
|
+
this.name = "AppError";
|
|
13
|
+
}
|
|
14
|
+
static fromUnknown(err, code = "INTERNAL") {
|
|
15
|
+
if (err instanceof _AppError) return err;
|
|
16
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
17
|
+
return new _AppError(message, code, err);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function errorMessage(err) {
|
|
21
|
+
if (err instanceof Error) return err.message;
|
|
22
|
+
return String(err);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/utils/config.ts
|
|
26
|
+
var SUPABASE_URL_DEFAULT = process.env.ASSISTME_SUPABASE_URL || "https://msgplwbgohpokajtibew.supabase.co";
|
|
27
|
+
var SUPABASE_ANON_KEY_DEFAULT = process.env.ASSISTME_SUPABASE_ANON_KEY || "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1zZ3Bsd2Jnb2hwb2thanRpYmV3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE3MTMzNTEsImV4cCI6MjA3NzI4OTM1MX0.YqiluL_mIBWKv5dteIcPAPQ_jRp9rzZlvAXvkQttDjs";
|
|
28
|
+
var CONFIG_DEFAULTS = {
|
|
29
|
+
supabaseUrl: SUPABASE_URL_DEFAULT,
|
|
30
|
+
supabaseAnonKey: SUPABASE_ANON_KEY_DEFAULT,
|
|
31
|
+
sessionName: "Default",
|
|
32
|
+
model: "claude-sonnet-4-20250514",
|
|
33
|
+
taskTimeoutMinutes: 10
|
|
34
|
+
};
|
|
35
|
+
var config = new Conf({
|
|
36
|
+
projectName: "assistme",
|
|
37
|
+
defaults: CONFIG_DEFAULTS
|
|
38
|
+
});
|
|
39
|
+
function getConfig() {
|
|
40
|
+
const supabaseUrl = process.env.SUPABASE_URL || config.get("supabaseUrl") || SUPABASE_URL_DEFAULT;
|
|
41
|
+
const supabaseAnonKey = process.env.SUPABASE_ANON_KEY || config.get("supabaseAnonKey") || SUPABASE_ANON_KEY_DEFAULT;
|
|
42
|
+
const anthropicApiKey = process.env.ANTHROPIC_API_KEY || config.get("anthropicApiKey") || "";
|
|
43
|
+
const workspacePath = config.get("workspacePath") || process.cwd();
|
|
44
|
+
return {
|
|
45
|
+
supabaseUrl,
|
|
46
|
+
supabaseAnonKey,
|
|
47
|
+
anthropicApiKey,
|
|
48
|
+
workspacePath: resolve(workspacePath),
|
|
49
|
+
sessionName: config.get("sessionName") || "Default",
|
|
50
|
+
model: config.get("model") || "claude-sonnet-4-20250514",
|
|
51
|
+
taskTimeoutMinutes: config.get("taskTimeoutMinutes") || 10
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function setConfig(key, value) {
|
|
55
|
+
config.set(key, value);
|
|
56
|
+
}
|
|
57
|
+
function clearConfig() {
|
|
58
|
+
config.clear();
|
|
59
|
+
}
|
|
60
|
+
function getConfigPath() {
|
|
61
|
+
return config.path;
|
|
62
|
+
}
|
|
63
|
+
var DATA_DIR_NAME = ".assistme-data";
|
|
64
|
+
var _rootCache = null;
|
|
65
|
+
var _dataDirCache = null;
|
|
66
|
+
function getAssistMeRoot() {
|
|
67
|
+
if (_rootCache) return _rootCache;
|
|
68
|
+
const { workspacePath } = getConfig();
|
|
69
|
+
const base = basename(workspacePath);
|
|
70
|
+
_rootCache = base === "assistme" ? workspacePath : join(workspacePath, "assistme");
|
|
71
|
+
if (!existsSync(_rootCache)) {
|
|
72
|
+
mkdirSync(_rootCache, { recursive: true });
|
|
73
|
+
}
|
|
74
|
+
return _rootCache;
|
|
75
|
+
}
|
|
76
|
+
function getDataDir() {
|
|
77
|
+
if (_dataDirCache) return _dataDirCache;
|
|
78
|
+
const dataDir = join(getAssistMeRoot(), DATA_DIR_NAME);
|
|
79
|
+
if (!existsSync(dataDir)) {
|
|
80
|
+
mkdirSync(dataDir, { recursive: true, mode: 448 });
|
|
81
|
+
}
|
|
82
|
+
_dataDirCache = dataDir;
|
|
83
|
+
return dataDir;
|
|
84
|
+
}
|
|
85
|
+
function assertWithinAssistMeRoot(filePath) {
|
|
86
|
+
const root = getAssistMeRoot();
|
|
87
|
+
const resolved = resolve(root, filePath);
|
|
88
|
+
const rel = relative(root, resolved);
|
|
89
|
+
if (rel.startsWith("..") || rel.startsWith(sep + sep)) {
|
|
90
|
+
throw new AppError(
|
|
91
|
+
`Access denied: path "${filePath}" is outside assistme workspace "${root}"`,
|
|
92
|
+
"PATH_TRAVERSAL"
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return resolved;
|
|
96
|
+
}
|
|
97
|
+
function resetDirCaches() {
|
|
98
|
+
_rootCache = null;
|
|
99
|
+
_dataDirCache = null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
AppError,
|
|
104
|
+
errorMessage,
|
|
105
|
+
getConfig,
|
|
106
|
+
setConfig,
|
|
107
|
+
clearConfig,
|
|
108
|
+
getConfigPath,
|
|
109
|
+
getAssistMeRoot,
|
|
110
|
+
getDataDir,
|
|
111
|
+
assertWithinAssistMeRoot,
|
|
112
|
+
resetDirCaches
|
|
113
|
+
};
|