@myagentroam/node 0.9.171 → 0.9.172
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildCompactEvidence, countModelTokens, generateModelText } from '@myagentroam/agent';
|
|
1
|
+
import { buildCompactEvidence, countModelTokens, generateModelText, MarAgentError } from '@myagentroam/agent';
|
|
2
2
|
import { marAgentRuntimeCompactConfigurationSchema } from '@myagentroam/protocol';
|
|
3
3
|
/** Resolve optional dedicated credentials in the same factory batch without widening the SDK catalog. */
|
|
4
4
|
export function compactRuntimeConfigurations(models, raw) {
|
|
@@ -58,6 +58,7 @@ export function marAgentCompactExtensionSource(state) {
|
|
|
58
58
|
}
|
|
59
59
|
export async function generateMarAgentCompact(context, selected, signal) {
|
|
60
60
|
signal.throwIfAborted();
|
|
61
|
+
const startedAt = Date.now();
|
|
61
62
|
const instruction = context.getPrompt();
|
|
62
63
|
const overhead = countModelTokens(system) + countModelTokens(instruction) + 128;
|
|
63
64
|
const full = buildCompactEvidence(context.messages, {
|
|
@@ -66,14 +67,39 @@ export async function generateMarAgentCompact(context, selected, signal) {
|
|
|
66
67
|
});
|
|
67
68
|
const window = selected.model.contextWindowTokens;
|
|
68
69
|
const budget = Math.floor(window * 0.9) - overhead;
|
|
69
|
-
|
|
70
|
+
let modelRequests = 0;
|
|
71
|
+
let inputTokensEstimateAfter = overhead;
|
|
72
|
+
const report = async (state, reason, errorCode) => {
|
|
73
|
+
try {
|
|
74
|
+
await context.reportDiagnostic?.({
|
|
75
|
+
modelId: selected.model.id,
|
|
76
|
+
providerModelId: selected.model.modelId,
|
|
77
|
+
reasoningEffort: selected.reasoningEffort,
|
|
78
|
+
state,
|
|
79
|
+
inputTokensEstimateBefore: countModelTokens(full) + overhead,
|
|
80
|
+
inputTokensEstimateAfter,
|
|
81
|
+
modelRequests,
|
|
82
|
+
elapsedMs: Math.max(0, Date.now() - startedAt),
|
|
83
|
+
...(reason === undefined ? {} : { reason }),
|
|
84
|
+
...(errorCode === undefined ? {} : { errorCode })
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// Telemetry is best effort and cannot turn a successful generation into a fallback.
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
if (budget <= 0) {
|
|
92
|
+
await report('DECLINED', 'INPUT_BUDGET_EXHAUSTED');
|
|
70
93
|
return undefined;
|
|
94
|
+
}
|
|
71
95
|
const evidence = countModelTokens(full) + overhead <= window
|
|
72
96
|
? full
|
|
73
97
|
: buildCompactEvidence(context.messages, {
|
|
74
98
|
maxTokens: budget,
|
|
75
99
|
...(context.focus === undefined ? {} : { focus: context.focus })
|
|
76
100
|
});
|
|
101
|
+
inputTokensEstimateAfter = countModelTokens(evidence) + overhead;
|
|
102
|
+
await report('STARTED');
|
|
77
103
|
try {
|
|
78
104
|
const result = await generateModelText({
|
|
79
105
|
model: selected.model,
|
|
@@ -84,14 +110,22 @@ export async function generateMarAgentCompact(context, selected, signal) {
|
|
|
84
110
|
{ role: 'user', content: instruction }
|
|
85
111
|
],
|
|
86
112
|
outputLimit: Math.min(selected.model.maxOutputTokens, context.summaryTokenBudget),
|
|
113
|
+
onAttemptDiagnostic: async (diagnostic) => {
|
|
114
|
+
if (diagnostic.state === 'STARTED') {
|
|
115
|
+
modelRequests++;
|
|
116
|
+
await report('STARTED');
|
|
117
|
+
}
|
|
118
|
+
},
|
|
87
119
|
signal
|
|
88
120
|
});
|
|
121
|
+
await report(result ? 'SUCCEEDED' : 'DECLINED', result ? undefined : 'MODEL_INCOMPLETE');
|
|
89
122
|
return result
|
|
90
123
|
? { summary: result.text, ...(result.usage === undefined ? {} : { usage: result.usage }) }
|
|
91
124
|
: undefined;
|
|
92
125
|
}
|
|
93
|
-
catch {
|
|
126
|
+
catch (error) {
|
|
94
127
|
signal.throwIfAborted();
|
|
128
|
+
await report('FAILED', 'MODEL_FAILED', error instanceof MarAgentError ? error.code : 'MAR_AGENT_COMPACT_MODEL_FAILED');
|
|
95
129
|
return undefined;
|
|
96
130
|
}
|
|
97
131
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myagentroam/node",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.172",
|
|
4
4
|
"description": "MyAgentRoam Node runtime CLI.",
|
|
5
5
|
"license": "Apache-2.0 AND GPL-2.0-or-later",
|
|
6
6
|
"type": "module",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"playwright": "1.62.1",
|
|
37
37
|
"ws": "^8.21.3",
|
|
38
38
|
"zod": "4.4.3",
|
|
39
|
-
"@myagentroam/agent": "0.9.
|
|
40
|
-
"@myagentroam/code-navigation": "0.9.129",
|
|
39
|
+
"@myagentroam/agent": "0.9.172",
|
|
41
40
|
"@myagentroam/marctl": "0.9.123",
|
|
42
|
-
"@myagentroam/
|
|
41
|
+
"@myagentroam/code-navigation": "0.9.129",
|
|
42
|
+
"@myagentroam/protocol": "0.9.172"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/ws": "^8.18.1"
|