omnius 1.0.381 → 1.0.382
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 +111 -28
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -566361,17 +566361,58 @@ function retentionStrength(note, now2 = Date.now()) {
|
|
|
566361
566361
|
const retention = Math.exp(-ageH / Math.max(1, stability));
|
|
566362
566362
|
return Math.min(1, Math.max(note.importance / 10 * 0.2, retention));
|
|
566363
566363
|
}
|
|
566364
|
+
function hashFeature(s2) {
|
|
566365
|
+
let h = 2166136261;
|
|
566366
|
+
for (let i2 = 0; i2 < s2.length; i2++) {
|
|
566367
|
+
h ^= s2.charCodeAt(i2);
|
|
566368
|
+
h = Math.imul(h, 16777619);
|
|
566369
|
+
}
|
|
566370
|
+
return h >>> 0;
|
|
566371
|
+
}
|
|
566372
|
+
function textFeatures(text2) {
|
|
566373
|
+
const tokens = text2.toLowerCase().split(/[^\p{L}\p{N}_./-]+/u).map((t2) => t2.trim()).filter(Boolean);
|
|
566374
|
+
const features = [...tokens];
|
|
566375
|
+
for (let i2 = 0; i2 < tokens.length - 1; i2++) {
|
|
566376
|
+
features.push(`${tokens[i2]} ${tokens[i2 + 1]}`);
|
|
566377
|
+
}
|
|
566378
|
+
return features;
|
|
566379
|
+
}
|
|
566380
|
+
function textToHashEmbedding(text2, dimensions = DEFAULT_HASH_DIMS) {
|
|
566381
|
+
const dim = Math.max(8, Math.floor(dimensions));
|
|
566382
|
+
const vec = new Array(dim).fill(0);
|
|
566383
|
+
for (const feature of textFeatures(text2)) {
|
|
566384
|
+
const h = hashFeature(feature);
|
|
566385
|
+
const idx = h % dim;
|
|
566386
|
+
const sign2 = (h & 2147483648) === 0 ? 1 : -1;
|
|
566387
|
+
vec[idx] += sign2;
|
|
566388
|
+
}
|
|
566389
|
+
const norm = Math.sqrt(vec.reduce((sum, v) => sum + v * v, 0));
|
|
566390
|
+
if (!norm)
|
|
566391
|
+
return vec;
|
|
566392
|
+
return vec.map((v) => Math.round(v / norm * 1e6) / 1e6);
|
|
566393
|
+
}
|
|
566394
|
+
function relevanceScore(note, queryEmbedding) {
|
|
566395
|
+
if (!queryEmbedding)
|
|
566396
|
+
return 0.5;
|
|
566397
|
+
if (!note.embedding || note.embedding.length !== queryEmbedding.length)
|
|
566398
|
+
return 0;
|
|
566399
|
+
return Math.max(0, cosine3(note.embedding, queryEmbedding));
|
|
566400
|
+
}
|
|
566364
566401
|
function scoreNote(note, opts = {}) {
|
|
566365
566402
|
const now2 = opts.now ?? Date.now();
|
|
566366
566403
|
const w = opts.weights ?? DEFAULT_WEIGHTS;
|
|
566367
566404
|
const recency = retentionStrength(note, now2);
|
|
566368
566405
|
const importance = Math.min(1, Math.max(0, note.importance / 10));
|
|
566369
|
-
const relevance = opts.queryEmbedding
|
|
566406
|
+
const relevance = opts.queryEmbedding ? relevanceScore(note, opts.queryEmbedding) : 0.5;
|
|
566370
566407
|
const total = w.recency * recency + w.importance * importance + w.relevance * relevance;
|
|
566371
566408
|
return Math.round(total / (w.recency + w.importance + w.relevance) * 1e4) / 1e4;
|
|
566372
566409
|
}
|
|
566373
566410
|
function selectTopNotes(notes, k, opts) {
|
|
566374
|
-
return [...notes].map((n2) => ({
|
|
566411
|
+
return [...notes].map((n2) => ({
|
|
566412
|
+
n: n2,
|
|
566413
|
+
s: scoreNote(n2, opts),
|
|
566414
|
+
r: relevanceScore(n2, opts?.queryEmbedding)
|
|
566415
|
+
})).filter(({ r: r2 }) => !opts?.queryEmbedding || opts.minRelevance === void 0 || r2 >= opts.minRelevance).sort((a2, b) => b.s - a2.s).slice(0, Math.max(0, k)).map((x) => x.n);
|
|
566375
566416
|
}
|
|
566376
566417
|
function findDuplicateGroups(notes, simThreshold = 0.92) {
|
|
566377
566418
|
const groups = [];
|
|
@@ -566438,7 +566479,7 @@ function planConsolidation(notes, opts = {}) {
|
|
|
566438
566479
|
}
|
|
566439
566480
|
return { keep, prune, merge: merge2, distill };
|
|
566440
566481
|
}
|
|
566441
|
-
var HOUR, ImportanceBudget, DEFAULT_WEIGHTS;
|
|
566482
|
+
var HOUR, ImportanceBudget, DEFAULT_WEIGHTS, DEFAULT_HASH_DIMS;
|
|
566442
566483
|
var init_memory_consolidation = __esm({
|
|
566443
566484
|
"packages/orchestrator/dist/memory-consolidation.js"() {
|
|
566444
566485
|
"use strict";
|
|
@@ -566465,6 +566506,7 @@ var init_memory_consolidation = __esm({
|
|
|
566465
566506
|
}
|
|
566466
566507
|
};
|
|
566467
566508
|
DEFAULT_WEIGHTS = { recency: 1, importance: 1, relevance: 1 };
|
|
566509
|
+
DEFAULT_HASH_DIMS = 256;
|
|
566468
566510
|
}
|
|
566469
566511
|
});
|
|
566470
566512
|
|
|
@@ -566508,6 +566550,10 @@ function noteAfterTask(args) {
|
|
|
566508
566550
|
createdAt: now2,
|
|
566509
566551
|
lastAccessedMs: now2,
|
|
566510
566552
|
accessCount: 0,
|
|
566553
|
+
embedding: textToHashEmbedding(`${args.summary || ""}
|
|
566554
|
+
${(args.keywords ?? []).join(" ")}`),
|
|
566555
|
+
sourceSurface: args.sourceSurface,
|
|
566556
|
+
sourceKey: args.sourceKey,
|
|
566511
566557
|
version: 1
|
|
566512
566558
|
});
|
|
566513
566559
|
const budget = new ImportanceBudget(THRESHOLD);
|
|
@@ -566555,11 +566601,28 @@ function noteAfterTask(args) {
|
|
|
566555
566601
|
save2(store2);
|
|
566556
566602
|
return result;
|
|
566557
566603
|
}
|
|
566558
|
-
function
|
|
566604
|
+
function ensureNoteEmbeddings(store2) {
|
|
566605
|
+
let changed = false;
|
|
566606
|
+
for (const note of store2.notes) {
|
|
566607
|
+
if (!Array.isArray(note.embedding) || note.embedding.length === 0) {
|
|
566608
|
+
note.embedding = textToHashEmbedding(`${note.content || ""}
|
|
566609
|
+
${(note.keywords ?? []).join(" ")}`);
|
|
566610
|
+
changed = true;
|
|
566611
|
+
}
|
|
566612
|
+
}
|
|
566613
|
+
return changed;
|
|
566614
|
+
}
|
|
566615
|
+
function recallTopNotes(k = 5, opts = {}) {
|
|
566559
566616
|
const store2 = load2();
|
|
566560
566617
|
if (!store2.notes.length)
|
|
566561
566618
|
return [];
|
|
566562
|
-
const
|
|
566619
|
+
const changed = ensureNoteEmbeddings(store2);
|
|
566620
|
+
const queryEmbedding = opts.query ? textToHashEmbedding(opts.query) : void 0;
|
|
566621
|
+
const top = selectTopNotes(store2.notes, k, {
|
|
566622
|
+
queryEmbedding,
|
|
566623
|
+
minRelevance: queryEmbedding ? opts.minRelevance ?? 0.18 : void 0,
|
|
566624
|
+
weights: queryEmbedding ? { recency: 0.5, importance: 0.75, relevance: 2 } : void 0
|
|
566625
|
+
});
|
|
566563
566626
|
const now2 = Date.now();
|
|
566564
566627
|
const ids = new Set(top.map((n2) => n2.id));
|
|
566565
566628
|
for (const n2 of store2.notes)
|
|
@@ -566567,11 +566630,12 @@ function recallTopNotes(k = 5) {
|
|
|
566567
566630
|
n2.accessCount += 1;
|
|
566568
566631
|
n2.lastAccessedMs = now2;
|
|
566569
566632
|
}
|
|
566570
|
-
|
|
566633
|
+
if (changed || ids.size > 0)
|
|
566634
|
+
save2(store2);
|
|
566571
566635
|
return top;
|
|
566572
566636
|
}
|
|
566573
|
-
function recallNotesBlock(k = 5) {
|
|
566574
|
-
const top = recallTopNotes(k);
|
|
566637
|
+
function recallNotesBlock(k = 5, opts = {}) {
|
|
566638
|
+
const top = recallTopNotes(k, opts);
|
|
566575
566639
|
if (!top.length)
|
|
566576
566640
|
return "";
|
|
566577
566641
|
const lines = top.map((n2) => `- (${n2.tier === "semantic" ? "learned" : "recent"}, imp ${n2.importance}) ${n2.content}`);
|
|
@@ -569258,6 +569322,8 @@ function violatesDirective(directive, input) {
|
|
|
569258
569322
|
if (input.toolName === "task_complete") {
|
|
569259
569323
|
return directive.state === "terminal_incomplete";
|
|
569260
569324
|
}
|
|
569325
|
+
if (input.toolName === "ask_user")
|
|
569326
|
+
return false;
|
|
569261
569327
|
const family = actionFamily(input.toolName, input.args);
|
|
569262
569328
|
if (directive.forbiddenActionFamilies.includes(family))
|
|
569263
569329
|
return true;
|
|
@@ -569267,20 +569333,41 @@ function violatesDirective(directive, input) {
|
|
|
569267
569333
|
case "update_todos":
|
|
569268
569334
|
return input.toolName !== "todo_write";
|
|
569269
569335
|
case "read_authoritative_target":
|
|
569270
|
-
return input.toolName
|
|
569336
|
+
return !isEvidenceGatheringTool(input.toolName);
|
|
569271
569337
|
case "run_verification":
|
|
569272
569338
|
return input.toolName !== "shell";
|
|
569273
569339
|
case "report_blocked":
|
|
569274
569340
|
case "report_incomplete":
|
|
569275
|
-
return input.toolName
|
|
569341
|
+
return !isReportTool(input.toolName);
|
|
569276
569342
|
case "edit_different_target":
|
|
569277
|
-
return input.toolName
|
|
569343
|
+
return !isEditTool(input.toolName) && !isEvidenceGatheringTool(input.toolName);
|
|
569278
569344
|
case "use_cached_evidence":
|
|
569279
569345
|
return directive.forbiddenActionFamilies.includes(family);
|
|
569280
569346
|
default:
|
|
569281
569347
|
return false;
|
|
569282
569348
|
}
|
|
569283
569349
|
}
|
|
569350
|
+
function isEvidenceGatheringTool(toolName) {
|
|
569351
|
+
return [
|
|
569352
|
+
"file_read",
|
|
569353
|
+
"grep_search",
|
|
569354
|
+
"find_files",
|
|
569355
|
+
"list_directory",
|
|
569356
|
+
"log_explore",
|
|
569357
|
+
"todo_write"
|
|
569358
|
+
].includes(toolName);
|
|
569359
|
+
}
|
|
569360
|
+
function isEditTool(toolName) {
|
|
569361
|
+
return [
|
|
569362
|
+
"file_write",
|
|
569363
|
+
"file_edit",
|
|
569364
|
+
"file_patch",
|
|
569365
|
+
"batch_edit"
|
|
569366
|
+
].includes(toolName);
|
|
569367
|
+
}
|
|
569368
|
+
function isReportTool(toolName) {
|
|
569369
|
+
return toolName === "task_complete" || toolName === "ask_user";
|
|
569370
|
+
}
|
|
569284
569371
|
function actionFamily(toolName, args) {
|
|
569285
569372
|
const target = args?.["path"] ?? args?.["file"] ?? args?.["filePath"] ?? args?.["file_path"] ?? args?.["command"] ?? args?.["cmd"] ?? "";
|
|
569286
569373
|
return `${toolName}:${normalizeTarget(String(target ?? "")) || "no-target"}`;
|
|
@@ -569313,6 +569400,7 @@ var init_focusSupervisor = __esm({
|
|
|
569313
569400
|
lastReason = "";
|
|
569314
569401
|
lastContext = null;
|
|
569315
569402
|
failureFamilies = /* @__PURE__ */ new Map();
|
|
569403
|
+
ignoredDirectiveStreak = 0;
|
|
569316
569404
|
constructor(options2 = {}) {
|
|
569317
569405
|
this.mode = options2.mode ?? "auto";
|
|
569318
569406
|
this.modelTier = options2.modelTier ?? "large";
|
|
@@ -569361,13 +569449,15 @@ var init_focusSupervisor = __esm({
|
|
|
569361
569449
|
const prior = this.directive;
|
|
569362
569450
|
if (prior && violatesDirective(prior, input)) {
|
|
569363
569451
|
prior.ignoredCount++;
|
|
569452
|
+
this.ignoredDirectiveStreak++;
|
|
569364
569453
|
const strict = this.shouldStrictlyIntervene(input.context);
|
|
569365
569454
|
if (strict && prior.ignoredCount >= 1) {
|
|
569455
|
+
const ignoredManyTimes = this.ignoredDirectiveStreak >= 3;
|
|
569366
569456
|
const directive = this.setDirective({
|
|
569367
569457
|
turn: input.turn,
|
|
569368
|
-
state: "single_next_action",
|
|
569369
|
-
reason: `model ignored prior directive ${prior.id}
|
|
569370
|
-
requiredNextAction: prior.requiredNextAction,
|
|
569458
|
+
state: ignoredManyTimes ? "verify_or_block" : "single_next_action",
|
|
569459
|
+
reason: ignoredManyTimes ? `model ignored ${this.ignoredDirectiveStreak} focus directives; report incomplete or ask for help instead of trying another variant` : `model ignored prior directive ${prior.id}; ${prior.reason}`,
|
|
569460
|
+
requiredNextAction: ignoredManyTimes ? "report_incomplete" : prior.requiredNextAction,
|
|
569371
569461
|
forbiddenActionFamilies: unique2([
|
|
569372
569462
|
...prior.forbiddenActionFamilies,
|
|
569373
569463
|
family
|
|
@@ -569403,7 +569493,7 @@ var init_focusSupervisor = __esm({
|
|
|
569403
569493
|
turn: input.turn,
|
|
569404
569494
|
state,
|
|
569405
569495
|
reason: input.cachedResultFailed ? `cached failed ${input.toolName} evidence already exists` : `duplicate ${input.toolName} call has cached evidence`,
|
|
569406
|
-
requiredNextAction: input.cachedResultFailed ? "
|
|
569496
|
+
requiredNextAction: input.cachedResultFailed ? "read_authoritative_target" : "use_cached_evidence",
|
|
569407
569497
|
forbiddenActionFamilies: [family]
|
|
569408
569498
|
});
|
|
569409
569499
|
if (strict && !advisoryOnly && (input.cachedResultFailed || duplicateHitCount >= hitLimit)) {
|
|
@@ -569429,6 +569519,8 @@ var init_focusSupervisor = __esm({
|
|
|
569429
569519
|
}
|
|
569430
569520
|
this.lastDecision = "pass";
|
|
569431
569521
|
this.lastReason = "";
|
|
569522
|
+
if (!this.directive)
|
|
569523
|
+
this.ignoredDirectiveStreak = 0;
|
|
569432
569524
|
return this.pass();
|
|
569433
569525
|
}
|
|
569434
569526
|
observeToolResult(input) {
|
|
@@ -569550,6 +569642,7 @@ var init_focusSupervisor = __esm({
|
|
|
569550
569642
|
this.lastReason = reason;
|
|
569551
569643
|
this.directive = null;
|
|
569552
569644
|
this.state = "observe";
|
|
569645
|
+
this.ignoredDirectiveStreak = 0;
|
|
569553
569646
|
}
|
|
569554
569647
|
pass() {
|
|
569555
569648
|
return { kind: "pass", state: this.state, ...this.directive ? { directive: this.directive } : {} };
|
|
@@ -578443,7 +578536,7 @@ ${_fanout}`;
|
|
|
578443
578536
|
} catch {
|
|
578444
578537
|
}
|
|
578445
578538
|
try {
|
|
578446
|
-
const _notes = recallNotesBlock(5);
|
|
578539
|
+
const _notes = recallNotesBlock(5, { query: persistentTaskGoal });
|
|
578447
578540
|
if (_notes)
|
|
578448
578541
|
systemPrompt = `${systemPrompt}
|
|
578449
578542
|
|
|
@@ -578453,21 +578546,11 @@ ${_notes}`;
|
|
|
578453
578546
|
try {
|
|
578454
578547
|
if (!this.options.subAgent) {
|
|
578455
578548
|
const _imp = Math.min(9, Math.max(3, 3 + Math.floor((persistentTaskGoal.length || 0) / 250)));
|
|
578456
|
-
const _kw = String(persistentTaskGoal || "").toLowerCase().match(/[a-z][a-z0-9_-]{3,}/g)?.filter((w) => ![
|
|
578457
|
-
"this",
|
|
578458
|
-
"that",
|
|
578459
|
-
"with",
|
|
578460
|
-
"from",
|
|
578461
|
-
"into",
|
|
578462
|
-
"your",
|
|
578463
|
-
"have",
|
|
578464
|
-
"will",
|
|
578465
|
-
"please"
|
|
578466
|
-
].includes(w)).slice(0, 6) ?? [];
|
|
578467
578549
|
noteAfterTask({
|
|
578468
578550
|
summary: `Task: ${persistentTaskGoal.slice(0, 200)}`,
|
|
578469
578551
|
importance: _imp,
|
|
578470
|
-
|
|
578552
|
+
sourceSurface: this._inferSurface(),
|
|
578553
|
+
sourceKey: this.options.stateDir ?? this.authoritativeWorkingDirectory()
|
|
578471
578554
|
});
|
|
578472
578555
|
}
|
|
578473
578556
|
} catch {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.382",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.382",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED