titan-agent 5.5.26 → 5.5.28

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.
@@ -1018,7 +1018,8 @@ Continue executing this task NOW using the appropriate tools. Do NOT re-explain,
1018
1018
  { pattern: /\b(?:paperclip|sidecars?|helpers?)\b/i, widget: "system:paperclip", name: "Paperclip" },
1019
1019
  { pattern: /\b(?:tests?|flaky|failing|coverage|eval)\b/i, widget: "system:eval", name: "Test Lab" }
1020
1020
  ];
1021
- const matchedWidget = systemWidgetPatterns.find((p) => p.pattern.test(message));
1021
+ const hasWidgetIntent = /\b(?:widget|panel|dashboard|monitor|hub|tab|page|view|gallery|kitchen|scheduler|router|lab|tools)\b/i.test(message);
1022
+ const matchedWidget = hasWidgetIntent ? systemWidgetPatterns.find((p) => p.pattern.test(message)) : null;
1022
1023
  if (matchedWidget && !taskEnforcementActive) {
1023
1024
  systemPrompt += `
1024
1025
 
@@ -1075,7 +1076,27 @@ CRITICAL: Widgets are NOT files. Do NOT use write_file, edit_file, or any file t
1075
1076
  } catch {
1076
1077
  }
1077
1078
  const { resolveActivePersona: __resolvePersona } = await import("./personaProfiles.js");
1078
- const earlyPersona = __resolvePersona({ channel });
1079
+ let earlyPersona = __resolvePersona({ channel });
1080
+ let __cohortAssignment = null;
1081
+ if (earlyPersona) {
1082
+ try {
1083
+ const { pickCohortAssignment } = await import("./personaRollout.js");
1084
+ const assignment = pickCohortAssignment(earlyPersona.id, { sessionId: session.id, channel });
1085
+ if (assignment) {
1086
+ __cohortAssignment = { cohortId: assignment.cohortId, role: assignment.role };
1087
+ if (assignment.role === "candidate" && assignment.personaId !== earlyPersona.id) {
1088
+ const { resolveActivePersona } = await import("./personaProfiles.js");
1089
+ const candidate = resolveActivePersona({ forceId: assignment.personaId });
1090
+ if (candidate) {
1091
+ logger.info(COMPONENT, `[Cohort:${assignment.cohortId}] swap ${earlyPersona.id} \u2192 ${candidate.id}`);
1092
+ earlyPersona = candidate;
1093
+ }
1094
+ }
1095
+ }
1096
+ } catch (err) {
1097
+ logger.warn(COMPONENT, `cohort assignment skipped: ${err.message}`);
1098
+ }
1099
+ }
1079
1100
  if (earlyPersona?.systemPromptAppendix) {
1080
1101
  enrichedSystemPrompt += earlyPersona.systemPromptAppendix;
1081
1102
  logger.info(COMPONENT, `[Persona:${earlyPersona.id}] system prompt appendix injected`);
@@ -1332,6 +1353,30 @@ Synthesize these results into a coherent response for the user.`
1332
1353
  recordUsage(session.id, providerName, modelUsed, totalPromptTokens, totalCompletionTokens);
1333
1354
  const durationMs = Date.now() - startTime;
1334
1355
  logger.info(COMPONENT, `Response generated in ${durationMs}ms (${totalPromptTokens + totalCompletionTokens} tokens)`);
1356
+ if (__cohortAssignment) {
1357
+ void (async () => {
1358
+ try {
1359
+ const { recordOutcome } = await import("./personaRollout.js");
1360
+ let safetySat = null;
1361
+ try {
1362
+ const { loadDriveHistory } = await import("../organism/drives.js");
1363
+ const persisted = loadDriveHistory();
1364
+ const safety = persisted?.latest?.drives?.find((d) => d.id === "safety");
1365
+ safetySat = safety ? safety.satisfaction : null;
1366
+ } catch {
1367
+ }
1368
+ recordOutcome({
1369
+ cohortId: __cohortAssignment.cohortId,
1370
+ role: __cohortAssignment.role,
1371
+ sessionId: session.id,
1372
+ success: !budgetExhausted && finalContent.length > 0,
1373
+ latencyMs: durationMs,
1374
+ safetySat
1375
+ });
1376
+ } catch {
1377
+ }
1378
+ })();
1379
+ }
1335
1380
  if (toolsUsed.length > 0) {
1336
1381
  const uniqueTools = [...new Set(toolsUsed)];
1337
1382
  learnFact(