@vibeiao/sdk 0.1.44 → 0.1.45
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 +28 -9
- package/dist/treasuryGuardian.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -270,6 +270,19 @@ var inferTheme = (r) => {
|
|
|
270
270
|
if (/great|love|awesome|excellent/.test(t)) return "praise";
|
|
271
271
|
return "noise";
|
|
272
272
|
};
|
|
273
|
+
var classifyIssueSignal = (r) => {
|
|
274
|
+
const text = `${String(r.comment || "")} ${String(r.agent_response_comment || "")}`.toLowerCase();
|
|
275
|
+
const rating = Number(r.rating);
|
|
276
|
+
const criticalHint = /crash|broken|error|fail|unusable|cannot|can't|doesn't work|not work|timeout|data loss/.test(text);
|
|
277
|
+
const prefHint = /prefer|would like|i wish|could you|nice to have|personally|for me/.test(text);
|
|
278
|
+
if (criticalHint || Number.isFinite(rating) && rating <= 2 && /bug|reliability|ux|pricing|feature/.test(inferTheme(r))) {
|
|
279
|
+
return "critical_issue";
|
|
280
|
+
}
|
|
281
|
+
if (prefHint || inferTheme(r) === "feature" || inferTheme(r) === "praise" || inferTheme(r) === "noise") {
|
|
282
|
+
return "preference";
|
|
283
|
+
}
|
|
284
|
+
return "other";
|
|
285
|
+
};
|
|
273
286
|
var themeBaseWeight = {
|
|
274
287
|
bug: 1,
|
|
275
288
|
reliability: 0.95,
|
|
@@ -293,9 +306,12 @@ var aggregateFeedbackSignals = (reviews, options = {}) => {
|
|
|
293
306
|
const rating = Number(r.rating);
|
|
294
307
|
const severity = Number.isFinite(rating) ? clamp01((5 - Math.max(1, Math.min(5, rating))) / 4) : 0.4;
|
|
295
308
|
const score = themeBaseWeight[theme] * (0.5 + severity) * recencyWeight(r.created_at, nowMs);
|
|
296
|
-
const prev = bucket.get(theme) || { count: 0, weightedScore: 0 };
|
|
309
|
+
const prev = bucket.get(theme) || { count: 0, weightedScore: 0, criticalCount: 0, preferenceCount: 0 };
|
|
297
310
|
prev.count += 1;
|
|
298
311
|
prev.weightedScore += score;
|
|
312
|
+
const signalKind = classifyIssueSignal(r);
|
|
313
|
+
if (signalKind === "critical_issue") prev.criticalCount += 1;
|
|
314
|
+
if (signalKind === "preference") prev.preferenceCount += 1;
|
|
299
315
|
bucket.set(theme, prev);
|
|
300
316
|
}
|
|
301
317
|
const themes = [...bucket.entries()].map(([theme, v]) => ({ theme, ...v })).sort((a, b) => b.weightedScore - a.weightedScore);
|
|
@@ -318,27 +334,30 @@ var evaluateAdaptiveReflectionPolicy = (aggregate, state, policy = {}, nowMs = D
|
|
|
318
334
|
const rationale = [];
|
|
319
335
|
if (state.lastEvaluatedAt && nowMs - state.lastEvaluatedAt < evalIntervalMs) {
|
|
320
336
|
rationale.push("evaluation_interval_not_reached");
|
|
321
|
-
return { decision: "hold", rationale, confidence: 0.9, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
337
|
+
return { decision: "hold", immediate: false, rationale, confidence: 0.9, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
322
338
|
}
|
|
323
339
|
if (aggregate.totalReviews < minReviewsForAdaptation) {
|
|
324
340
|
rationale.push("insufficient_review_volume");
|
|
325
|
-
return { decision: "observe", rationale, confidence: 0.65, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
341
|
+
return { decision: "observe", immediate: false, rationale, confidence: 0.65, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
326
342
|
}
|
|
327
343
|
if (aggregate.topScore < minTopScore || !aggregate.topTheme) {
|
|
328
344
|
rationale.push("signal_below_threshold");
|
|
329
|
-
return { decision: "observe", rationale, confidence: 0.6, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
345
|
+
return { decision: "observe", immediate: false, rationale, confidence: 0.6, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
330
346
|
}
|
|
331
347
|
const lastThemeTs = state.lastAdaptedAtByTheme?.[aggregate.topTheme] || 0;
|
|
332
348
|
if (lastThemeTs && nowMs - lastThemeTs < themeCooldownMs) {
|
|
333
349
|
rationale.push("theme_cooldown_active");
|
|
334
|
-
return { decision: "hold", rationale, confidence: 0.85, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
350
|
+
return { decision: "hold", immediate: false, rationale, confidence: 0.85, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
335
351
|
}
|
|
336
352
|
if (adaptationsInLastDay(state, nowMs) >= maxAdaptationsPerDay) {
|
|
337
353
|
rationale.push("daily_adaptation_limit_reached");
|
|
338
|
-
return { decision: "hold", rationale, confidence: 0.85, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
354
|
+
return { decision: "hold", immediate: false, rationale, confidence: 0.85, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
339
355
|
}
|
|
356
|
+
const top = aggregate.themes.find((t) => t.theme === aggregate.topTheme);
|
|
357
|
+
const immediate = Boolean(top && (top.theme === "bug" || top.theme === "reliability") && top.criticalCount >= 2 && top.weightedScore >= Math.max(3, minTopScore));
|
|
358
|
+
if (immediate) rationale.push("immediate_fix_recommended");
|
|
340
359
|
rationale.push("aggregate_signal_passed");
|
|
341
|
-
return { decision: "adapt", rationale, confidence: 0.8, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
360
|
+
return { decision: "adapt", immediate, rationale, confidence: immediate ? 0.9 : 0.8, topTheme: aggregate.topTheme, topScore: aggregate.topScore };
|
|
342
361
|
};
|
|
343
362
|
var buildAdaptivePlan = (decision) => {
|
|
344
363
|
if (decision.decision !== "adapt" || !decision.topTheme) return null;
|
|
@@ -387,7 +406,7 @@ var buildAdaptivePlan = (decision) => {
|
|
|
387
406
|
rollbackCriteria: "N/A"
|
|
388
407
|
}
|
|
389
408
|
};
|
|
390
|
-
return { id, theme: decision.topTheme, ...byTheme[decision.topTheme] };
|
|
409
|
+
return { id, theme: decision.topTheme, ...byTheme[decision.topTheme], urgency: decision.immediate ? "immediate" : "normal" };
|
|
391
410
|
};
|
|
392
411
|
var runAdaptiveReflectionCycle = async (opts) => {
|
|
393
412
|
const now = opts.now || (() => Date.now());
|
|
@@ -546,7 +565,7 @@ var ReviewGate = class {
|
|
|
546
565
|
var DEFAULT_API_BASE = "https://api.vibeiao.com";
|
|
547
566
|
var DEFAULT_WEB_BASE = "https://vibeiao.com";
|
|
548
567
|
var DEFAULT_SDK_PACKAGE = "@vibeiao/sdk";
|
|
549
|
-
var DEFAULT_SDK_VERSION = "0.1.
|
|
568
|
+
var DEFAULT_SDK_VERSION = "0.1.44" ? "0.1.44" : "0.1.4";
|
|
550
569
|
var DEFAULT_SDK_REGISTRY = "https://registry.npmjs.org";
|
|
551
570
|
var DEFAULT_SDK_POLICY_PATH = "/v1/sdk/policy";
|
|
552
571
|
var DEFAULT_SDK_CHECK_INTERVAL_MS = 1e3 * 60 * 30;
|
|
@@ -837,6 +837,8 @@ type AdaptiveFeedbackAggregate = {
|
|
|
837
837
|
theme: AdaptiveTheme;
|
|
838
838
|
count: number;
|
|
839
839
|
weightedScore: number;
|
|
840
|
+
criticalCount: number;
|
|
841
|
+
preferenceCount: number;
|
|
840
842
|
}>;
|
|
841
843
|
topTheme?: AdaptiveTheme;
|
|
842
844
|
topScore: number;
|
|
@@ -860,6 +862,7 @@ type AdaptivePolicyState = {
|
|
|
860
862
|
};
|
|
861
863
|
type AdaptivePolicyDecision = {
|
|
862
864
|
decision: 'hold' | 'observe' | 'adapt';
|
|
865
|
+
immediate: boolean;
|
|
863
866
|
rationale: string[];
|
|
864
867
|
confidence: number;
|
|
865
868
|
topTheme?: AdaptiveTheme;
|
|
@@ -872,6 +875,7 @@ type AdaptiveAdaptationPlan = {
|
|
|
872
875
|
expectedImpact: string;
|
|
873
876
|
risk: 'low' | 'medium' | 'high';
|
|
874
877
|
rollbackCriteria: string;
|
|
878
|
+
urgency?: 'normal' | 'immediate';
|
|
875
879
|
};
|
|
876
880
|
type AdaptiveReflectionStore = ReflectionStore & {
|
|
877
881
|
loadPolicyState?: () => Promise<AdaptivePolicyState | null> | AdaptivePolicyState | null;
|