assistme 0.6.2 → 0.6.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/index.js +26 -6
- package/package.json +1 -1
- package/src/agent/self-analyzer.ts +27 -9
package/dist/index.js
CHANGED
|
@@ -3846,11 +3846,11 @@ var SELF_ANALYSIS_OUTPUT_FORMAT = {
|
|
|
3846
3846
|
type: "object",
|
|
3847
3847
|
properties: {
|
|
3848
3848
|
is_perfect: { type: "boolean" },
|
|
3849
|
-
overall_score: { type: "number" },
|
|
3849
|
+
overall_score: { type: "number", minimum: 1, maximum: 10 },
|
|
3850
3850
|
task_completion_quality: {
|
|
3851
3851
|
type: "object",
|
|
3852
3852
|
properties: {
|
|
3853
|
-
score: { type: "number" },
|
|
3853
|
+
score: { type: "number", minimum: 1, maximum: 10 },
|
|
3854
3854
|
assessment: { type: "string" }
|
|
3855
3855
|
},
|
|
3856
3856
|
required: ["score", "assessment"]
|
|
@@ -3875,11 +3875,11 @@ var SELF_ANALYSIS_OUTPUT_FORMAT = {
|
|
|
3875
3875
|
type: "object",
|
|
3876
3876
|
properties: {
|
|
3877
3877
|
session_logs_useful: { type: "boolean" },
|
|
3878
|
-
session_logs_gaps: { type: "string" },
|
|
3878
|
+
session_logs_gaps: { type: ["string", "null"] },
|
|
3879
3879
|
message_events_useful: { type: "boolean" },
|
|
3880
|
-
message_events_gaps: { type: "string" },
|
|
3880
|
+
message_events_gaps: { type: ["string", "null"] },
|
|
3881
3881
|
conversation_context_useful: { type: "boolean" },
|
|
3882
|
-
conversation_context_gaps: { type: "string" }
|
|
3882
|
+
conversation_context_gaps: { type: ["string", "null"] }
|
|
3883
3883
|
},
|
|
3884
3884
|
required: [
|
|
3885
3885
|
"session_logs_useful",
|
|
@@ -4125,6 +4125,15 @@ async function runAnalysisQuery(model, prompt) {
|
|
|
4125
4125
|
log.debug(
|
|
4126
4126
|
`Self-analysis cost: $${successMsg.total_cost_usd.toFixed(4)}`
|
|
4127
4127
|
);
|
|
4128
|
+
if (!structuredOutput) {
|
|
4129
|
+
log.warn(
|
|
4130
|
+
`Self-analysis: success but no structured_output. result text: ${String(successMsg.result ?? "").slice(0, 500)}`
|
|
4131
|
+
);
|
|
4132
|
+
}
|
|
4133
|
+
} else {
|
|
4134
|
+
log.warn(
|
|
4135
|
+
`Self-analysis: query returned subtype="${resultMsg.subtype}". result: ${String(resultMsg.result ?? "").slice(0, 500)}`
|
|
4136
|
+
);
|
|
4128
4137
|
}
|
|
4129
4138
|
}
|
|
4130
4139
|
}
|
|
@@ -4163,7 +4172,18 @@ Respond with a JSON object now.`;
|
|
|
4163
4172
|
(_, reject) => setTimeout(() => reject(new Error(`Self-analysis timed out after ${SELF_ANALYSIS_TIMEOUT_MS / 1e3}s`)), SELF_ANALYSIS_TIMEOUT_MS)
|
|
4164
4173
|
);
|
|
4165
4174
|
const structuredOutput = await Promise.race([analysisPromise, timeoutPromise]);
|
|
4166
|
-
|
|
4175
|
+
let analysis = null;
|
|
4176
|
+
if (structuredOutput) {
|
|
4177
|
+
const result = SelfAnalysisResultSchema.safeParse(structuredOutput);
|
|
4178
|
+
if (result.success) {
|
|
4179
|
+
analysis = result.data;
|
|
4180
|
+
} else {
|
|
4181
|
+
log.warn(
|
|
4182
|
+
`Self-analysis: schema validation failed: ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
|
|
4183
|
+
);
|
|
4184
|
+
log.debug(`Self-analysis: raw output: ${JSON.stringify(structuredOutput).slice(0, 500)}`);
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4167
4187
|
if (!analysis) {
|
|
4168
4188
|
log.warn("Self-analysis: no valid structured output");
|
|
4169
4189
|
return;
|
package/package.json
CHANGED
|
@@ -9,7 +9,6 @@ import { log } from "../utils/logger.js";
|
|
|
9
9
|
import {
|
|
10
10
|
SelfAnalysisResultSchema,
|
|
11
11
|
type SelfAnalysisResult,
|
|
12
|
-
safeParse,
|
|
13
12
|
} from "../utils/schemas.js";
|
|
14
13
|
import { errorMessage } from "../utils/errors.js";
|
|
15
14
|
import {
|
|
@@ -37,11 +36,11 @@ const SELF_ANALYSIS_OUTPUT_FORMAT: OutputFormat = {
|
|
|
37
36
|
type: "object",
|
|
38
37
|
properties: {
|
|
39
38
|
is_perfect: { type: "boolean" },
|
|
40
|
-
overall_score: { type: "number" },
|
|
39
|
+
overall_score: { type: "number", minimum: 1, maximum: 10 },
|
|
41
40
|
task_completion_quality: {
|
|
42
41
|
type: "object",
|
|
43
42
|
properties: {
|
|
44
|
-
score: { type: "number" },
|
|
43
|
+
score: { type: "number", minimum: 1, maximum: 10 },
|
|
45
44
|
assessment: { type: "string" },
|
|
46
45
|
},
|
|
47
46
|
required: ["score", "assessment"],
|
|
@@ -66,11 +65,11 @@ const SELF_ANALYSIS_OUTPUT_FORMAT: OutputFormat = {
|
|
|
66
65
|
type: "object",
|
|
67
66
|
properties: {
|
|
68
67
|
session_logs_useful: { type: "boolean" },
|
|
69
|
-
session_logs_gaps: { type: "string" },
|
|
68
|
+
session_logs_gaps: { type: ["string", "null"] },
|
|
70
69
|
message_events_useful: { type: "boolean" },
|
|
71
|
-
message_events_gaps: { type: "string" },
|
|
70
|
+
message_events_gaps: { type: ["string", "null"] },
|
|
72
71
|
conversation_context_useful: { type: "boolean" },
|
|
73
|
-
conversation_context_gaps: { type: "string" },
|
|
72
|
+
conversation_context_gaps: { type: ["string", "null"] },
|
|
74
73
|
},
|
|
75
74
|
required: [
|
|
76
75
|
"session_logs_useful",
|
|
@@ -371,6 +370,16 @@ async function runAnalysisQuery(model: string, prompt: string): Promise<unknown>
|
|
|
371
370
|
log.debug(
|
|
372
371
|
`Self-analysis cost: $${successMsg.total_cost_usd.toFixed(4)}`
|
|
373
372
|
);
|
|
373
|
+
if (!structuredOutput) {
|
|
374
|
+
// structured_output can be undefined even on success — log the text result
|
|
375
|
+
log.warn(
|
|
376
|
+
`Self-analysis: success but no structured_output. result text: ${String((successMsg as any).result ?? "").slice(0, 500)}`
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
} else {
|
|
380
|
+
log.warn(
|
|
381
|
+
`Self-analysis: query returned subtype="${resultMsg.subtype}". result: ${String((resultMsg as any).result ?? "").slice(0, 500)}`
|
|
382
|
+
);
|
|
374
383
|
}
|
|
375
384
|
}
|
|
376
385
|
}
|
|
@@ -436,9 +445,18 @@ export async function analyzeSelfPostTask(opts: {
|
|
|
436
445
|
const structuredOutput = await Promise.race([analysisPromise, timeoutPromise]);
|
|
437
446
|
|
|
438
447
|
// Validate against Zod schema
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
448
|
+
let analysis: SelfAnalysisResult | null = null;
|
|
449
|
+
if (structuredOutput) {
|
|
450
|
+
const result = SelfAnalysisResultSchema.safeParse(structuredOutput);
|
|
451
|
+
if (result.success) {
|
|
452
|
+
analysis = result.data;
|
|
453
|
+
} else {
|
|
454
|
+
log.warn(
|
|
455
|
+
`Self-analysis: schema validation failed: ${result.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ")}`
|
|
456
|
+
);
|
|
457
|
+
log.debug(`Self-analysis: raw output: ${JSON.stringify(structuredOutput).slice(0, 500)}`);
|
|
458
|
+
}
|
|
459
|
+
}
|
|
442
460
|
|
|
443
461
|
if (!analysis) {
|
|
444
462
|
log.warn("Self-analysis: no valid structured output");
|