assistme 0.6.0 → 0.6.2

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.
@@ -288,6 +288,7 @@ var SELF_ANALYSIS_MAX_MESSAGE_EVENTS = 300;
288
288
  var SELF_ANALYSIS_MAX_CONVERSATION_MESSAGES = 10;
289
289
  var SELF_ANALYSIS_LOG_CONTEXT_CHARS = 2e4;
290
290
  var SELF_ANALYSIS_EVENT_CONTEXT_CHARS = 2e4;
291
+ var SELF_ANALYSIS_TIMEOUT_MS = 18e4;
291
292
  var EDSGER_PRODUCT_SLUG = "assistme";
292
293
  var MAX_COMPLETE_TASK_RETRIES = 2;
293
294
 
@@ -506,6 +507,7 @@ export {
506
507
  SELF_ANALYSIS_MAX_CONVERSATION_MESSAGES,
507
508
  SELF_ANALYSIS_LOG_CONTEXT_CHARS,
508
509
  SELF_ANALYSIS_EVENT_CONTEXT_CHARS,
510
+ SELF_ANALYSIS_TIMEOUT_MS,
509
511
  EDSGER_PRODUCT_SLUG,
510
512
  MAX_COMPLETE_TASK_RETRIES,
511
513
  AppError,
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ import {
26
26
  SELF_ANALYSIS_MAX_CONVERSATION_MESSAGES,
27
27
  SELF_ANALYSIS_MAX_MESSAGE_EVENTS,
28
28
  SELF_ANALYSIS_MAX_SESSION_LOGS,
29
+ SELF_ANALYSIS_TIMEOUT_MS,
29
30
  SHELL_MAX_OUTPUT,
30
31
  SHELL_TIMEOUT_MS,
31
32
  SKILL_DESCRIPTION_BUDGET_CHARS,
@@ -45,7 +46,7 @@ import {
45
46
  setLogHook,
46
47
  setLogLevel,
47
48
  writeAuthStore
48
- } from "./chunk-ECEOBNDM.js";
49
+ } from "./chunk-3V6TCGZG.js";
49
50
  import {
50
51
  clearConfig,
51
52
  getConfig,
@@ -4104,6 +4105,31 @@ ${dataQualityNotes}
4104
4105
  }
4105
4106
  }
4106
4107
  }
4108
+ async function runAnalysisQuery(model, prompt) {
4109
+ let structuredOutput;
4110
+ for await (const message of query2({
4111
+ prompt,
4112
+ options: {
4113
+ model,
4114
+ maxTurns: 1,
4115
+ allowedTools: [],
4116
+ effort: "low",
4117
+ outputFormat: SELF_ANALYSIS_OUTPUT_FORMAT
4118
+ }
4119
+ })) {
4120
+ if (message.type === "result") {
4121
+ const resultMsg = message;
4122
+ if (resultMsg.subtype === "success") {
4123
+ const successMsg = resultMsg;
4124
+ structuredOutput = successMsg.structured_output;
4125
+ log.debug(
4126
+ `Self-analysis cost: $${successMsg.total_cost_usd.toFixed(4)}`
4127
+ );
4128
+ }
4129
+ }
4130
+ }
4131
+ return structuredOutput;
4132
+ }
4107
4133
  async function analyzeSelfPostTask(opts) {
4108
4134
  const {
4109
4135
  model,
@@ -4117,6 +4143,7 @@ async function analyzeSelfPostTask(opts) {
4117
4143
  sessionId
4118
4144
  } = opts;
4119
4145
  try {
4146
+ log.info(`Self-analysis starting for task ${taskId}`);
4120
4147
  const analysisContext = await buildAnalysisContext({
4121
4148
  taskId,
4122
4149
  conversationId,
@@ -4131,31 +4158,14 @@ async function analyzeSelfPostTask(opts) {
4131
4158
  ${analysisContext}
4132
4159
 
4133
4160
  Respond with a JSON object now.`;
4134
- let structuredOutput;
4135
- for await (const message of query2({
4136
- prompt,
4137
- options: {
4138
- model,
4139
- maxTurns: 1,
4140
- allowedTools: [],
4141
- effort: "low",
4142
- outputFormat: SELF_ANALYSIS_OUTPUT_FORMAT
4143
- }
4144
- })) {
4145
- if (message.type === "result") {
4146
- const resultMsg = message;
4147
- if (resultMsg.subtype === "success") {
4148
- const successMsg = resultMsg;
4149
- structuredOutput = successMsg.structured_output;
4150
- log.debug(
4151
- `Self-analysis cost: $${successMsg.total_cost_usd.toFixed(4)}`
4152
- );
4153
- }
4154
- }
4155
- }
4161
+ const analysisPromise = runAnalysisQuery(model, prompt);
4162
+ const timeoutPromise = new Promise(
4163
+ (_, reject) => setTimeout(() => reject(new Error(`Self-analysis timed out after ${SELF_ANALYSIS_TIMEOUT_MS / 1e3}s`)), SELF_ANALYSIS_TIMEOUT_MS)
4164
+ );
4165
+ const structuredOutput = await Promise.race([analysisPromise, timeoutPromise]);
4156
4166
  const analysis = structuredOutput ? safeParse(SelfAnalysisResultSchema, structuredOutput) : null;
4157
4167
  if (!analysis) {
4158
- log.debug("Self-analysis: no valid structured output");
4168
+ log.warn("Self-analysis: no valid structured output");
4159
4169
  return;
4160
4170
  }
4161
4171
  log.info(
@@ -4167,7 +4177,7 @@ Respond with a JSON object now.`;
4167
4177
  log.debug("Self-analysis: no improvements to report \u2014 skipping feedback");
4168
4178
  }
4169
4179
  } catch (err) {
4170
- log.debug(`Self-analysis error: ${errorMessage(err)}`);
4180
+ log.warn(`Self-analysis error: ${errorMessage(err)}`);
4171
4181
  }
4172
4182
  }
4173
4183
 
@@ -7074,7 +7084,7 @@ function registerJobCommands(program2) {
7074
7084
  jobCmd.command("list").description("List your defined jobs").action(async () => {
7075
7085
  try {
7076
7086
  const userId = await getCurrentUserId();
7077
- const { JobRunner: JobRunner2 } = await import("./job-runner-RGP4CLYV.js");
7087
+ const { JobRunner: JobRunner2 } = await import("./job-runner-W6CTTJMR.js");
7078
7088
  const runner = new JobRunner2();
7079
7089
  const jobs = await runner.listJobs();
7080
7090
  if (jobs.length === 0) {
@@ -7098,7 +7108,7 @@ function registerJobCommands(program2) {
7098
7108
  jobCmd.command("status [name]").description("Show run history for a job (or all jobs)").option("-l, --limit <number>", "Max runs to show (default: 5)").action(async (name, opts) => {
7099
7109
  try {
7100
7110
  const userId = await getCurrentUserId();
7101
- const { JobRunner: JobRunner2 } = await import("./job-runner-RGP4CLYV.js");
7111
+ const { JobRunner: JobRunner2 } = await import("./job-runner-W6CTTJMR.js");
7102
7112
  const runner = new JobRunner2();
7103
7113
  const runs = await runner.getRunHistory(name, parseInt(opts.limit || "5"));
7104
7114
  if (runs.length === 0) {
@@ -7137,7 +7147,7 @@ Job Run History${name ? ` \u2014 ${name}` : ""}:`));
7137
7147
  process.exit(1);
7138
7148
  }
7139
7149
  const userId = await getCurrentUserId();
7140
- const { JobRunner: JobRunner2 } = await import("./job-runner-RGP4CLYV.js");
7150
+ const { JobRunner: JobRunner2 } = await import("./job-runner-W6CTTJMR.js");
7141
7151
  const runner = new JobRunner2();
7142
7152
  const job = await runner.loadJob(name);
7143
7153
  if (!job) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JobRunner
3
- } from "./chunk-ECEOBNDM.js";
3
+ } from "./chunk-3V6TCGZG.js";
4
4
  import "./chunk-JVA6DHXD.js";
5
5
  export {
6
6
  JobRunner
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assistme",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "AssistMe CLI Agent - AI-powered assistant that controls your real browser",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,6 +23,7 @@ import {
23
23
  SELF_ANALYSIS_MAX_CONVERSATION_MESSAGES,
24
24
  SELF_ANALYSIS_LOG_CONTEXT_CHARS,
25
25
  SELF_ANALYSIS_EVENT_CONTEXT_CHARS,
26
+ SELF_ANALYSIS_TIMEOUT_MS,
26
27
  EDSGER_PRODUCT_SLUG,
27
28
  } from "../utils/constants.js";
28
29
  import type { ToolCallRecord } from "./skill-extractor.js";
@@ -345,10 +346,42 @@ async function submitSelfAnalysisFeedback(analysis: SelfAnalysisResult): Promise
345
346
  }
346
347
  }
347
348
 
349
+ // ── Query Runner ────────────────────────────────────────────────
350
+
351
+ async function runAnalysisQuery(model: string, prompt: string): Promise<unknown> {
352
+ let structuredOutput: unknown;
353
+
354
+ // Use independent query() instead of session resume to avoid
355
+ // conflicts with skill evaluation which also resumes the session
356
+ for await (const message of query({
357
+ prompt,
358
+ options: {
359
+ model,
360
+ maxTurns: 1,
361
+ allowedTools: [],
362
+ effort: "low",
363
+ outputFormat: SELF_ANALYSIS_OUTPUT_FORMAT,
364
+ },
365
+ })) {
366
+ if (message.type === "result") {
367
+ const resultMsg = message as SDKResultMessage;
368
+ if (resultMsg.subtype === "success") {
369
+ const successMsg = resultMsg as SDKResultSuccess;
370
+ structuredOutput = successMsg.structured_output;
371
+ log.debug(
372
+ `Self-analysis cost: $${successMsg.total_cost_usd.toFixed(4)}`
373
+ );
374
+ }
375
+ }
376
+ }
377
+
378
+ return structuredOutput;
379
+ }
380
+
348
381
  // ── Main Entry Point ────────────────────────────────────────────
349
382
 
350
383
  /**
351
- * Post-task self-analysis: resume the agent SDK session to critically
384
+ * Post-task self-analysis: starts a new agent SDK query to critically
352
385
  * analyze AssistMe's own performance and code quality.
353
386
  *
354
387
  * If improvements are found, submits feedback via edsger-feedback.
@@ -378,6 +411,8 @@ export async function analyzeSelfPostTask(opts: {
378
411
  } = opts;
379
412
 
380
413
  try {
414
+ log.info(`Self-analysis starting for task ${taskId}`);
415
+
381
416
  // Build context from all available data sources
382
417
  const analysisContext = await buildAnalysisContext({
383
418
  taskId,
@@ -392,31 +427,13 @@ export async function analyzeSelfPostTask(opts: {
392
427
 
393
428
  const prompt = `${SELF_ANALYSIS_PROMPT}\n${analysisContext}\n\nRespond with a JSON object now.`;
394
429
 
395
- let structuredOutput: unknown;
396
-
397
- // Use independent query() instead of session resume to avoid
398
- // conflicts with skill evaluation which also resumes the session
399
- for await (const message of query({
400
- prompt,
401
- options: {
402
- model,
403
- maxTurns: 1,
404
- allowedTools: [],
405
- effort: "low",
406
- outputFormat: SELF_ANALYSIS_OUTPUT_FORMAT,
407
- },
408
- })) {
409
- if (message.type === "result") {
410
- const resultMsg = message as SDKResultMessage;
411
- if (resultMsg.subtype === "success") {
412
- const successMsg = resultMsg as SDKResultSuccess;
413
- structuredOutput = successMsg.structured_output;
414
- log.debug(
415
- `Self-analysis cost: $${successMsg.total_cost_usd.toFixed(4)}`
416
- );
417
- }
418
- }
419
- }
430
+ // Race the analysis against a timeout to avoid hanging forever
431
+ const analysisPromise = runAnalysisQuery(model, prompt);
432
+ const timeoutPromise = new Promise<never>((_, reject) =>
433
+ setTimeout(() => reject(new Error(`Self-analysis timed out after ${SELF_ANALYSIS_TIMEOUT_MS / 1000}s`)), SELF_ANALYSIS_TIMEOUT_MS)
434
+ );
435
+
436
+ const structuredOutput = await Promise.race([analysisPromise, timeoutPromise]);
420
437
 
421
438
  // Validate against Zod schema
422
439
  const analysis = structuredOutput
@@ -424,7 +441,7 @@ export async function analyzeSelfPostTask(opts: {
424
441
  : null;
425
442
 
426
443
  if (!analysis) {
427
- log.debug("Self-analysis: no valid structured output");
444
+ log.warn("Self-analysis: no valid structured output");
428
445
  return;
429
446
  }
430
447
 
@@ -439,6 +456,6 @@ export async function analyzeSelfPostTask(opts: {
439
456
  log.debug("Self-analysis: no improvements to report — skipping feedback");
440
457
  }
441
458
  } catch (err) {
442
- log.debug(`Self-analysis error: ${errorMessage(err)}`);
459
+ log.warn(`Self-analysis error: ${errorMessage(err)}`);
443
460
  }
444
461
  }
@@ -106,6 +106,9 @@ export const SELF_ANALYSIS_LOG_CONTEXT_CHARS = 20_000;
106
106
  /** Max characters for event context in self-analysis */
107
107
  export const SELF_ANALYSIS_EVENT_CONTEXT_CHARS = 20_000;
108
108
 
109
+ /** Timeout for the self-analysis query in ms (3 minutes) */
110
+ export const SELF_ANALYSIS_TIMEOUT_MS = 180_000;
111
+
109
112
  /** Edsger feedback product slug for assistme */
110
113
  export const EDSGER_PRODUCT_SLUG = "assistme";
111
114