assistme 0.6.1 → 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,
@@ -4132,31 +4158,14 @@ async function analyzeSelfPostTask(opts) {
4132
4158
  ${analysisContext}
4133
4159
 
4134
4160
  Respond with a JSON object now.`;
4135
- let structuredOutput;
4136
- for await (const message of query2({
4137
- prompt,
4138
- options: {
4139
- model,
4140
- maxTurns: 1,
4141
- allowedTools: [],
4142
- effort: "low",
4143
- outputFormat: SELF_ANALYSIS_OUTPUT_FORMAT
4144
- }
4145
- })) {
4146
- if (message.type === "result") {
4147
- const resultMsg = message;
4148
- if (resultMsg.subtype === "success") {
4149
- const successMsg = resultMsg;
4150
- structuredOutput = successMsg.structured_output;
4151
- log.debug(
4152
- `Self-analysis cost: $${successMsg.total_cost_usd.toFixed(4)}`
4153
- );
4154
- }
4155
- }
4156
- }
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]);
4157
4166
  const analysis = structuredOutput ? safeParse(SelfAnalysisResultSchema, structuredOutput) : null;
4158
4167
  if (!analysis) {
4159
- log.debug("Self-analysis: no valid structured output");
4168
+ log.warn("Self-analysis: no valid structured output");
4160
4169
  return;
4161
4170
  }
4162
4171
  log.info(
@@ -4168,7 +4177,7 @@ Respond with a JSON object now.`;
4168
4177
  log.debug("Self-analysis: no improvements to report \u2014 skipping feedback");
4169
4178
  }
4170
4179
  } catch (err) {
4171
- log.debug(`Self-analysis error: ${errorMessage(err)}`);
4180
+ log.warn(`Self-analysis error: ${errorMessage(err)}`);
4172
4181
  }
4173
4182
  }
4174
4183
 
@@ -7075,7 +7084,7 @@ function registerJobCommands(program2) {
7075
7084
  jobCmd.command("list").description("List your defined jobs").action(async () => {
7076
7085
  try {
7077
7086
  const userId = await getCurrentUserId();
7078
- const { JobRunner: JobRunner2 } = await import("./job-runner-RGP4CLYV.js");
7087
+ const { JobRunner: JobRunner2 } = await import("./job-runner-W6CTTJMR.js");
7079
7088
  const runner = new JobRunner2();
7080
7089
  const jobs = await runner.listJobs();
7081
7090
  if (jobs.length === 0) {
@@ -7099,7 +7108,7 @@ function registerJobCommands(program2) {
7099
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) => {
7100
7109
  try {
7101
7110
  const userId = await getCurrentUserId();
7102
- const { JobRunner: JobRunner2 } = await import("./job-runner-RGP4CLYV.js");
7111
+ const { JobRunner: JobRunner2 } = await import("./job-runner-W6CTTJMR.js");
7103
7112
  const runner = new JobRunner2();
7104
7113
  const runs = await runner.getRunHistory(name, parseInt(opts.limit || "5"));
7105
7114
  if (runs.length === 0) {
@@ -7138,7 +7147,7 @@ Job Run History${name ? ` \u2014 ${name}` : ""}:`));
7138
7147
  process.exit(1);
7139
7148
  }
7140
7149
  const userId = await getCurrentUserId();
7141
- const { JobRunner: JobRunner2 } = await import("./job-runner-RGP4CLYV.js");
7150
+ const { JobRunner: JobRunner2 } = await import("./job-runner-W6CTTJMR.js");
7142
7151
  const runner = new JobRunner2();
7143
7152
  const job = await runner.loadJob(name);
7144
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.1",
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,6 +346,38 @@ 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
  /**
@@ -394,31 +427,13 @@ export async function analyzeSelfPostTask(opts: {
394
427
 
395
428
  const prompt = `${SELF_ANALYSIS_PROMPT}\n${analysisContext}\n\nRespond with a JSON object now.`;
396
429
 
397
- let structuredOutput: unknown;
398
-
399
- // Use independent query() instead of session resume to avoid
400
- // conflicts with skill evaluation which also resumes the session
401
- for await (const message of query({
402
- prompt,
403
- options: {
404
- model,
405
- maxTurns: 1,
406
- allowedTools: [],
407
- effort: "low",
408
- outputFormat: SELF_ANALYSIS_OUTPUT_FORMAT,
409
- },
410
- })) {
411
- if (message.type === "result") {
412
- const resultMsg = message as SDKResultMessage;
413
- if (resultMsg.subtype === "success") {
414
- const successMsg = resultMsg as SDKResultSuccess;
415
- structuredOutput = successMsg.structured_output;
416
- log.debug(
417
- `Self-analysis cost: $${successMsg.total_cost_usd.toFixed(4)}`
418
- );
419
- }
420
- }
421
- }
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]);
422
437
 
423
438
  // Validate against Zod schema
424
439
  const analysis = structuredOutput
@@ -426,7 +441,7 @@ export async function analyzeSelfPostTask(opts: {
426
441
  : null;
427
442
 
428
443
  if (!analysis) {
429
- log.debug("Self-analysis: no valid structured output");
444
+ log.warn("Self-analysis: no valid structured output");
430
445
  return;
431
446
  }
432
447
 
@@ -441,6 +456,6 @@ export async function analyzeSelfPostTask(opts: {
441
456
  log.debug("Self-analysis: no improvements to report — skipping feedback");
442
457
  }
443
458
  } catch (err) {
444
- log.debug(`Self-analysis error: ${errorMessage(err)}`);
459
+ log.warn(`Self-analysis error: ${errorMessage(err)}`);
445
460
  }
446
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