open-agents-ai 0.187.431 → 0.187.433

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 CHANGED
@@ -355,105 +355,6 @@ var init_typed_node_events = __esm({
355
355
  }
356
356
  });
357
357
 
358
- // packages/cli/src/ui/spinner.ts
359
- var FRAMES, INTERVAL_MS, Spinner;
360
- var init_spinner = __esm({
361
- "packages/cli/src/ui/spinner.ts"() {
362
- "use strict";
363
- FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
364
- INTERVAL_MS = 80;
365
- Spinner = class {
366
- _text;
367
- _frameIndex = 0;
368
- _timer = null;
369
- _isSpinning = false;
370
- constructor(text) {
371
- this._text = text;
372
- }
373
- // --------------------------------------------------------------------------
374
- // Public API
375
- // --------------------------------------------------------------------------
376
- get text() {
377
- return this._text;
378
- }
379
- set text(value2) {
380
- this._text = value2;
381
- if (this._isSpinning && process.stdout.isTTY) {
382
- this._render();
383
- }
384
- }
385
- get isSpinning() {
386
- return this._isSpinning;
387
- }
388
- start() {
389
- if (this._isSpinning) return this;
390
- this._isSpinning = true;
391
- this._frameIndex = 0;
392
- if (process.stdout.isTTY) {
393
- process.stdout.write("\x1B[?25l");
394
- this._render();
395
- this._timer = setInterval(() => {
396
- this._frameIndex = (this._frameIndex + 1) % FRAMES.length;
397
- this._render();
398
- }, INTERVAL_MS);
399
- } else {
400
- process.stdout.write(`${this._text}
401
- `);
402
- }
403
- return this;
404
- }
405
- stop() {
406
- if (!this._isSpinning) return this;
407
- this._isSpinning = false;
408
- if (this._timer !== null) {
409
- clearInterval(this._timer);
410
- this._timer = null;
411
- }
412
- if (process.stdout.isTTY) {
413
- process.stdout.write("\r\x1B[K");
414
- process.stdout.write("\x1B[?25h");
415
- }
416
- return this;
417
- }
418
- succeed(message2) {
419
- this.stop();
420
- const msg = message2 ?? this._text;
421
- process.stdout.write(`\x1B[32m✔\x1B[0m ${msg}
422
- `);
423
- return this;
424
- }
425
- fail(message2) {
426
- this.stop();
427
- const msg = message2 ?? this._text;
428
- process.stdout.write(`\x1B[31m✖\x1B[0m ${msg}
429
- `);
430
- return this;
431
- }
432
- warn(message2) {
433
- this.stop();
434
- const msg = message2 ?? this._text;
435
- process.stdout.write(`\x1B[33m⚠\x1B[0m ${msg}
436
- `);
437
- return this;
438
- }
439
- info(message2) {
440
- this.stop();
441
- const msg = message2 ?? this._text;
442
- process.stdout.write(`\x1B[36mℹ\x1B[0m ${msg}
443
- `);
444
- return this;
445
- }
446
- // --------------------------------------------------------------------------
447
- // Private
448
- // --------------------------------------------------------------------------
449
- _render() {
450
- const frame = FRAMES[this._frameIndex] ?? FRAMES[0];
451
- process.stdout.write(`\r\x1B[36m${frame}\x1B[0m ${this._text}`);
452
- }
453
- };
454
- }
455
- });
456
-
457
358
  // packages/backend-vllm/dist/sleep.js
458
359
  var SleepManager;
459
360
  var init_sleep = __esm({
@@ -88633,7 +88534,7 @@ var require_auto = __commonJS({
88633
88534
  // ../../../node_modules/acme-client/src/client.js
88634
88535
  var require_client = __commonJS({
88635
88536
  "../../../node_modules/acme-client/src/client.js"(exports, module) {
88636
- var { createHash: createHash13 } = __require("crypto");
88537
+ var { createHash: createHash14 } = __require("crypto");
88637
88538
  var { getPemBodyAsB64u } = require_crypto();
88638
88539
  var { log: log22 } = require_logger();
88639
88540
  var HttpClient = require_http();
@@ -88944,14 +88845,14 @@ var require_client = __commonJS({
88944
88845
  */
88945
88846
  async getChallengeKeyAuthorization(challenge) {
88946
88847
  const jwk = this.http.getJwk();
88947
- const keysum = createHash13("sha256").update(JSON.stringify(jwk));
88848
+ const keysum = createHash14("sha256").update(JSON.stringify(jwk));
88948
88849
  const thumbprint = keysum.digest("base64url");
88949
88850
  const result = `${challenge.token}.${thumbprint}`;
88950
88851
  if (challenge.type === "http-01") {
88951
88852
  return result;
88952
88853
  }
88953
88854
  if (challenge.type === "dns-01") {
88954
- return createHash13("sha256").update(result).digest("base64url");
88855
+ return createHash14("sha256").update(result).digest("base64url");
88955
88856
  }
88956
88857
  if (challenge.type === "tls-alpn-01") {
88957
88858
  return result;
@@ -231549,7 +231450,7 @@ var require_websocket2 = __commonJS({
231549
231450
  var http6 = __require("http");
231550
231451
  var net5 = __require("net");
231551
231452
  var tls2 = __require("tls");
231552
- var { randomBytes: randomBytes23, createHash: createHash13 } = __require("crypto");
231453
+ var { randomBytes: randomBytes23, createHash: createHash14 } = __require("crypto");
231553
231454
  var { Duplex: Duplex3, Readable } = __require("stream");
231554
231455
  var { URL: URL3 } = __require("url");
231555
231456
  var PerMessageDeflate2 = require_permessage_deflate2();
@@ -232209,7 +232110,7 @@ var require_websocket2 = __commonJS({
232209
232110
  abortHandshake(websocket, socket, "Invalid Upgrade header");
232210
232111
  return;
232211
232112
  }
232212
- const digest3 = createHash13("sha1").update(key + GUID).digest("base64");
232113
+ const digest3 = createHash14("sha1").update(key + GUID).digest("base64");
232213
232114
  if (res.headers["sec-websocket-accept"] !== digest3) {
232214
232115
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
232215
232116
  return;
@@ -232576,7 +232477,7 @@ var require_websocket_server = __commonJS({
232576
232477
  var EventEmitter12 = __require("events");
232577
232478
  var http6 = __require("http");
232578
232479
  var { Duplex: Duplex3 } = __require("stream");
232579
- var { createHash: createHash13 } = __require("crypto");
232480
+ var { createHash: createHash14 } = __require("crypto");
232580
232481
  var extension2 = require_extension2();
232581
232482
  var PerMessageDeflate2 = require_permessage_deflate2();
232582
232483
  var subprotocol2 = require_subprotocol();
@@ -232877,7 +232778,7 @@ var require_websocket_server = __commonJS({
232877
232778
  );
232878
232779
  }
232879
232780
  if (this._state > RUNNING) return abortHandshake(socket, 503);
232880
- const digest3 = createHash13("sha1").update(key + GUID).digest("base64");
232781
+ const digest3 = createHash14("sha1").update(key + GUID).digest("base64");
232881
232782
  const headers = [
232882
232783
  "HTTP/1.1 101 Switching Protocols",
232883
232784
  "Upgrade: websocket",
@@ -245684,13 +245585,13 @@ Justification: ${justification || "(none provided)"}`,
245684
245585
  }
245685
245586
  const snapshot = JSON.stringify(this.selfState, null, 2);
245686
245587
  try {
245687
- const { createHash: createHash13 } = await import("node:crypto");
245588
+ const { createHash: createHash14 } = await import("node:crypto");
245688
245589
  const snapshotDir = join24(this.cwd, ".oa", "identity", "snapshots");
245689
245590
  await mkdir6(snapshotDir, { recursive: true });
245690
245591
  const version4 = this.selfState.version;
245691
245592
  const snapshotPath = join24(snapshotDir, `v${version4}.json`);
245692
245593
  await writeFile11(snapshotPath, snapshot, "utf8");
245693
- const hash = createHash13("sha256").update(snapshot).digest("hex");
245594
+ const hash = createHash14("sha256").update(snapshot).digest("hex");
245694
245595
  await writeFile11(join24(this.cwd, ".oa", "identity", "latest-hash.txt"), hash, "utf8");
245695
245596
  let ipfsCid = "";
245696
245597
  try {
@@ -245823,8 +245724,8 @@ New: ${newNarrative.slice(0, 200)}...`,
245823
245724
  }
245824
245725
  // ── Helpers ──────────────────────────────────────────────────────────────
245825
245726
  createDefaultState() {
245826
- const { createHash: createHash13 } = __require("node:crypto");
245827
- const machineId = createHash13("sha256").update(this.cwd).digest("hex").slice(0, 12);
245727
+ const { createHash: createHash14 } = __require("node:crypto");
245728
+ const machineId = createHash14("sha256").update(this.cwd).digest("hex").slice(0, 12);
245828
245729
  return {
245829
245730
  self_id: `oa-${machineId}`,
245830
245731
  version: 1,
@@ -245906,9 +245807,9 @@ New: ${newNarrative.slice(0, 200)}...`,
245906
245807
  let cid;
245907
245808
  if (this.selfState.version > prevVersion) {
245908
245809
  try {
245909
- const { createHash: createHash13 } = await import("node:crypto");
245810
+ const { createHash: createHash14 } = await import("node:crypto");
245910
245811
  const stateJson = JSON.stringify(this.selfState);
245911
- const hash = createHash13("sha256").update(stateJson).digest("hex").slice(0, 32);
245812
+ const hash = createHash14("sha256").update(stateJson).digest("hex").slice(0, 32);
245912
245813
  const cidsPath = join24(this.cwd, ".oa", "identity", "cids.json");
245913
245814
  const cidsData = { latest: "", hash, version: this.selfState.version };
245914
245815
  try {
@@ -514374,9 +514275,634 @@ var init_embeddingAligner = __esm({
514374
514275
  }
514375
514276
  });
514376
514277
 
514278
+ // packages/memory/dist/crl/index.js
514279
+ var CRL_SYMBOLS, SYMBOL_MEANINGS, CRLParser, CRLEncoder, CRLDecoder, CRLTemplateResolver, CRL;
514280
+ var init_crl = __esm({
514281
+ "packages/memory/dist/crl/index.js"() {
514282
+ "use strict";
514283
+ CRL_SYMBOLS = {
514284
+ // Logical operators
514285
+ THEREFORE: "∴",
514286
+ BECAUSE: "∵",
514287
+ EQUIVALENT: "≡",
514288
+ IMPLIES: "→",
514289
+ BICONDITIONAL: "↔",
514290
+ NOT: "¬",
514291
+ AND: "∧",
514292
+ OR: "∨",
514293
+ XOR: "⊕",
514294
+ // Relational operators
514295
+ ELEMENT_OF: "∈",
514296
+ NOT_ELEMENT_OF: "∉",
514297
+ PROPER_SUBSET: "⊂",
514298
+ SUBSET_OR_EQUAL: "⊆",
514299
+ UNION: "∪",
514300
+ INTERSECTION: "∩",
514301
+ EMPTY: "∅",
514302
+ // Temporal/Sequential
514303
+ THEN: "⇒",
514304
+ FROM: "⇐",
514305
+ LOOP: "⟳",
514306
+ CYCLE: "↻",
514307
+ NEXT: "⏵",
514308
+ PREVIOUS: "⏴",
514309
+ // Modal/Evidential
514310
+ POSSIBLE: "◇",
514311
+ NECESSARY: "□",
514312
+ OBSERVED: "⊙",
514313
+ UNCERTAIN: "?",
514314
+ CRITICAL: "!",
514315
+ APPROXIMATE: "~",
514316
+ // Quantifiers
514317
+ FOR_ALL: "∀",
514318
+ EXISTS: "∃",
514319
+ NOT_EXISTS: "∄",
514320
+ AGGREGATE: "∑",
514321
+ PRODUCT: "∏"
514322
+ };
514323
+ SYMBOL_MEANINGS = {
514324
+ "∴": "therefore",
514325
+ "∵": "because",
514326
+ "≡": "equivalent",
514327
+ "→": "implies",
514328
+ "↔": "biconditional",
514329
+ "¬": "not",
514330
+ "∧": "and",
514331
+ "∨": "or",
514332
+ "⊕": "xor",
514333
+ "∈": "element_of",
514334
+ "∉": "not_element_of",
514335
+ "⊂": "proper_subset",
514336
+ "⊆": "subset_or_equal",
514337
+ "∪": "union",
514338
+ "∩": "intersection",
514339
+ "∅": "empty",
514340
+ "⇒": "then",
514341
+ "⇐": "from",
514342
+ "⟳": "loop",
514343
+ "↻": "cycle",
514344
+ "⏵": "next",
514345
+ "⏴": "previous",
514346
+ "◇": "possible",
514347
+ "□": "necessary",
514348
+ "⊙": "observed",
514349
+ "?": "uncertain",
514350
+ "!": "critical",
514351
+ "~": "approximate",
514352
+ "∀": "for_all",
514353
+ "∃": "exists",
514354
+ "∄": "not_exists",
514355
+ "∑": "aggregate",
514356
+ "∏": "product"
514357
+ };
514358
+ CRLParser = class {
514359
+ pos = 0;
514360
+ input = "";
514361
+ parse(input) {
514362
+ this.input = input;
514363
+ this.pos = 0;
514364
+ const nodes = [];
514365
+ const start2 = this.pos;
514366
+ while (this.pos < this.input.length) {
514367
+ this.skipWhitespace();
514368
+ if (this.pos >= this.input.length)
514369
+ break;
514370
+ const node = this.parseNode();
514371
+ if (node)
514372
+ nodes.push(node);
514373
+ }
514374
+ return {
514375
+ type: "statement",
514376
+ nodes,
514377
+ raw: input,
514378
+ position: { start: start2, end: this.pos }
514379
+ };
514380
+ }
514381
+ parseNode() {
514382
+ this.skipWhitespace();
514383
+ if (this.peek() === "[") {
514384
+ return this.parseConcept();
514385
+ }
514386
+ if (this.peek() === "$" && this.peek(1) === "{") {
514387
+ return this.parseTemplate();
514388
+ }
514389
+ if (this.isQuantifier(this.peek())) {
514390
+ return this.parseQuantifier();
514391
+ }
514392
+ if (this.isOperator(this.peek())) {
514393
+ return this.parseOperator();
514394
+ }
514395
+ this.pos++;
514396
+ return null;
514397
+ }
514398
+ parseConcept() {
514399
+ const start2 = this.pos;
514400
+ this.pos++;
514401
+ let name10 = "";
514402
+ while (this.pos < this.input.length && this.peek() !== "]") {
514403
+ name10 += this.peek();
514404
+ this.pos++;
514405
+ }
514406
+ this.pos++;
514407
+ let properties;
514408
+ if (this.peek() === "{") {
514409
+ properties = this.parseProperties();
514410
+ }
514411
+ let strength;
514412
+ if (this.peek() === "★") {
514413
+ strength = 0;
514414
+ while (this.peek() === "★") {
514415
+ strength++;
514416
+ this.pos++;
514417
+ }
514418
+ }
514419
+ return {
514420
+ type: "concept",
514421
+ name: name10.trim(),
514422
+ properties,
514423
+ strength,
514424
+ raw: this.input.substring(start2, this.pos),
514425
+ position: { start: start2, end: this.pos }
514426
+ };
514427
+ }
514428
+ parseProperties() {
514429
+ const props = {};
514430
+ this.pos++;
514431
+ while (this.pos < this.input.length && this.peek() !== "}") {
514432
+ const key = this.parseIdentifier();
514433
+ if (this.peek() === ":") {
514434
+ this.pos++;
514435
+ const value2 = this.parseIdentifier();
514436
+ props[key] = value2;
514437
+ }
514438
+ if (this.peek() === ",")
514439
+ this.pos++;
514440
+ }
514441
+ this.pos++;
514442
+ return props;
514443
+ }
514444
+ parseIdentifier() {
514445
+ let id = "";
514446
+ while (this.pos < this.input.length && /[a-zA-Z0-9_]/.test(this.peek())) {
514447
+ id += this.peek();
514448
+ this.pos++;
514449
+ }
514450
+ return id;
514451
+ }
514452
+ parseTemplate() {
514453
+ const start2 = this.pos;
514454
+ this.pos += 2;
514455
+ let variable = "";
514456
+ let defaultValue;
514457
+ let typeAnnotation;
514458
+ let transform;
514459
+ while (this.pos < this.input.length && this.peek() !== "}" && this.peek() !== ":" && this.peek() !== "|" && this.peek() !== "→") {
514460
+ variable += this.peek();
514461
+ this.pos++;
514462
+ }
514463
+ if (this.peek() === ":") {
514464
+ this.pos++;
514465
+ defaultValue = "";
514466
+ while (this.pos < this.input.length && this.peek() !== "}") {
514467
+ defaultValue += this.peek();
514468
+ this.pos++;
514469
+ }
514470
+ }
514471
+ if (this.peek() === "|") {
514472
+ this.pos++;
514473
+ typeAnnotation = "";
514474
+ while (this.pos < this.input.length && this.peek() !== "}" && this.peek() !== "→") {
514475
+ typeAnnotation += this.peek();
514476
+ this.pos++;
514477
+ }
514478
+ }
514479
+ if (this.peek() === "→") {
514480
+ this.pos++;
514481
+ transform = "";
514482
+ while (this.pos < this.input.length && this.peek() !== "}") {
514483
+ transform += this.peek();
514484
+ this.pos++;
514485
+ }
514486
+ }
514487
+ this.pos++;
514488
+ return {
514489
+ type: "template",
514490
+ variable: variable.trim(),
514491
+ defaultValue,
514492
+ typeAnnotation,
514493
+ transform,
514494
+ raw: this.input.substring(start2, this.pos),
514495
+ position: { start: start2, end: this.pos }
514496
+ };
514497
+ }
514498
+ parseQuantifier() {
514499
+ const start2 = this.pos;
514500
+ const quantifier = this.peek();
514501
+ this.pos++;
514502
+ let variable = "";
514503
+ while (this.pos < this.input.length && /[a-zA-Z_]/.test(this.peek())) {
514504
+ variable += this.peek();
514505
+ this.pos++;
514506
+ }
514507
+ let domain;
514508
+ if (this.peek() === "∈") {
514509
+ this.pos++;
514510
+ this.skipWhitespace();
514511
+ domain = this.parseConcept();
514512
+ }
514513
+ this.skipWhitespace();
514514
+ if (this.peek() === ":")
514515
+ this.pos++;
514516
+ this.skipWhitespace();
514517
+ const predicate = this.parseNode();
514518
+ return {
514519
+ type: "quantifier",
514520
+ quantifier,
514521
+ variable,
514522
+ domain,
514523
+ predicate,
514524
+ raw: this.input.substring(start2, this.pos),
514525
+ position: { start: start2, end: this.pos }
514526
+ };
514527
+ }
514528
+ parseOperator() {
514529
+ const start2 = this.pos;
514530
+ const op = this.peek();
514531
+ this.pos++;
514532
+ return {
514533
+ type: "relation",
514534
+ raw: op,
514535
+ position: { start: start2, end: this.pos }
514536
+ };
514537
+ }
514538
+ skipWhitespace() {
514539
+ while (this.pos < this.input.length && /\s/.test(this.peek())) {
514540
+ this.pos++;
514541
+ }
514542
+ }
514543
+ peek(offset = 0) {
514544
+ return this.input[this.pos + offset] || "";
514545
+ }
514546
+ isQuantifier(char) {
514547
+ return ["∀", "∃", "∄", "∑", "∏"].includes(char);
514548
+ }
514549
+ isOperator(char) {
514550
+ return [
514551
+ "∴",
514552
+ "∵",
514553
+ "≡",
514554
+ "→",
514555
+ "↔",
514556
+ "¬",
514557
+ "∧",
514558
+ "∨",
514559
+ "⊕",
514560
+ "∈",
514561
+ "∉",
514562
+ "⊂",
514563
+ "⊆",
514564
+ "∪",
514565
+ "∩",
514566
+ "⇒",
514567
+ "⇐"
514568
+ ].includes(char);
514569
+ }
514570
+ };
514571
+ CRLEncoder = class {
514572
+ conceptPatterns = /* @__PURE__ */ new Map();
514573
+ /**
514574
+ * Encode natural language text to CRL
514575
+ */
514576
+ encode(text) {
514577
+ const concepts = this.extractConcepts(text);
514578
+ const relations = this.extractRelations(text, concepts);
514579
+ return this.buildExpression(concepts, relations);
514580
+ }
514581
+ /**
514582
+ * Extract key concepts from text
514583
+ */
514584
+ extractConcepts(text) {
514585
+ const concepts = [];
514586
+ const conceptPattern = /\[([^\]]+)\]/g;
514587
+ let match;
514588
+ while ((match = conceptPattern.exec(text)) !== null) {
514589
+ concepts.push({
514590
+ type: "concept",
514591
+ name: match[1],
514592
+ raw: match[0],
514593
+ position: { start: match.index, end: match.index + match[0].length }
514594
+ });
514595
+ }
514596
+ const implicitPattern = /\b([A-Z][a-z]+(?:_[A-Z][a-z]+)*)\b/g;
514597
+ while ((match = implicitPattern.exec(text)) !== null) {
514598
+ if (!concepts.find((c9) => c9.name === match[1])) {
514599
+ concepts.push({
514600
+ type: "concept",
514601
+ name: match[1],
514602
+ raw: match[0],
514603
+ position: { start: match.index, end: match.index + match[0].length }
514604
+ });
514605
+ }
514606
+ }
514607
+ return concepts;
514608
+ }
514609
+ /**
514610
+ * Extract relations between concepts
514611
+ */
514612
+ extractRelations(text, concepts) {
514613
+ const relations = [];
514614
+ const relationPattern = /\[([^\]]+)\]\s*(→|↔|∴|∵|⇒|⇐)(?::(\w+))?\s*(?:→)?\s*\[([^\]]+)\]/g;
514615
+ let match;
514616
+ while ((match = relationPattern.exec(text)) !== null) {
514617
+ const from3 = concepts.find((c9) => c9.name === match[1]);
514618
+ const to = concepts.find((c9) => c9.name === match[4]);
514619
+ if (from3 && to) {
514620
+ relations.push({
514621
+ type: "relation",
514622
+ from: from3,
514623
+ to,
514624
+ operator: match[2],
514625
+ edgeType: match[3],
514626
+ raw: match[0],
514627
+ position: { start: match.index, end: match.index + match[0].length }
514628
+ });
514629
+ }
514630
+ }
514631
+ return relations;
514632
+ }
514633
+ /**
514634
+ * Build CRL expression from concepts and relations
514635
+ */
514636
+ buildExpression(concepts, relations) {
514637
+ const lines = [];
514638
+ for (const rel of relations) {
514639
+ let line = `[${rel.from.name}] ${rel.operator}`;
514640
+ if (rel.edgeType)
514641
+ line += `:${rel.edgeType}`;
514642
+ line += ` [${rel.to.name}]`;
514643
+ lines.push(line);
514644
+ }
514645
+ const relatedConcepts = /* @__PURE__ */ new Set();
514646
+ for (const rel of relations) {
514647
+ relatedConcepts.add(rel.from.name);
514648
+ relatedConcepts.add(rel.to.name);
514649
+ }
514650
+ for (const concept of concepts) {
514651
+ if (!relatedConcepts.has(concept.name)) {
514652
+ lines.push(`[${concept.name}]`);
514653
+ }
514654
+ }
514655
+ return lines.join("\n");
514656
+ }
514657
+ /**
514658
+ * Compress text using CRL patterns
514659
+ */
514660
+ compress(text) {
514661
+ const replacements = [
514662
+ [/therefore/gi, "∴"],
514663
+ [/because/gi, "∵"],
514664
+ [/implies that/gi, "→"],
514665
+ [/is equivalent to/gi, "≡"],
514666
+ [/is an? element of/gi, "∈"],
514667
+ [/is not an? element of/gi, "∉"],
514668
+ [/is a subset of/gi, "⊂"],
514669
+ [/for all/gi, "∀"],
514670
+ [/there exists/gi, "∃"],
514671
+ [/and then/gi, "⇒"],
514672
+ [/leads to/gi, "→"],
514673
+ [/causes/gi, "→:causes"],
514674
+ [/fixes/gi, "→:fixes"],
514675
+ [/relates to/gi, "∩"]
514676
+ ];
514677
+ let result = text;
514678
+ for (const [pattern, replacement] of replacements) {
514679
+ result = result.replace(pattern, replacement);
514680
+ }
514681
+ return result;
514682
+ }
514683
+ };
514684
+ CRLDecoder = class {
514685
+ /**
514686
+ * Decode CRL expression to natural language
514687
+ */
514688
+ decode(crl) {
514689
+ const parser2 = new CRLParser();
514690
+ const ast = parser2.parse(crl);
514691
+ return this.renderStatement(ast);
514692
+ }
514693
+ /**
514694
+ * Render a statement node
514695
+ */
514696
+ renderStatement(node) {
514697
+ return node.nodes.map((n2) => this.renderNode(n2)).filter(Boolean).join(". ");
514698
+ }
514699
+ /**
514700
+ * Render any CRL node
514701
+ */
514702
+ renderNode(node) {
514703
+ switch (node.type) {
514704
+ case "concept":
514705
+ return this.renderConcept(node);
514706
+ case "template":
514707
+ return this.renderTemplate(node);
514708
+ case "quantifier":
514709
+ return this.renderQuantifier(node);
514710
+ case "relation":
514711
+ return this.renderRelation(node);
514712
+ default:
514713
+ return "";
514714
+ }
514715
+ }
514716
+ /**
514717
+ * Render a concept
514718
+ */
514719
+ renderConcept(node) {
514720
+ let result = node.name;
514721
+ if (node.properties) {
514722
+ const props = Object.entries(node.properties).map(([k, v]) => `${k}=${v}`).join(", ");
514723
+ result += ` (${props})`;
514724
+ }
514725
+ if (node.strength) {
514726
+ result += ` [strength: ${node.strength}/5]`;
514727
+ }
514728
+ return result;
514729
+ }
514730
+ /**
514731
+ * Render a template
514732
+ */
514733
+ renderTemplate(node) {
514734
+ let result = node.variable;
514735
+ if (node.typeAnnotation) {
514736
+ result += ` (${node.typeAnnotation})`;
514737
+ }
514738
+ if (node.defaultValue) {
514739
+ result += ` [default: ${node.defaultValue}]`;
514740
+ }
514741
+ return result;
514742
+ }
514743
+ /**
514744
+ * Render a quantifier
514745
+ */
514746
+ renderQuantifier(node) {
514747
+ const quantifierMeanings = {
514748
+ "∀": "For all",
514749
+ "∃": "There exists",
514750
+ "∄": "There does not exist",
514751
+ "∑": "Sum of",
514752
+ "∏": "Product of"
514753
+ };
514754
+ let result = `${quantifierMeanings[node.quantifier]} ${node.variable}`;
514755
+ if (node.domain) {
514756
+ result += ` in ${this.renderNode(node.domain)}`;
514757
+ }
514758
+ if (node.predicate) {
514759
+ result += `, ${this.renderNode(node.predicate)}`;
514760
+ }
514761
+ return result;
514762
+ }
514763
+ /**
514764
+ * Render a relation
514765
+ */
514766
+ renderRelation(node) {
514767
+ const operatorMeanings = {
514768
+ "→": "implies",
514769
+ "∴": "therefore",
514770
+ "∵": "because",
514771
+ "≡": "is equivalent to",
514772
+ "↔": "is mutually related to",
514773
+ "∈": "is an element of",
514774
+ "⊂": "is a subset of",
514775
+ "∪": "combined with",
514776
+ "∩": "intersects with",
514777
+ "⇒": "then",
514778
+ "⇐": "from"
514779
+ };
514780
+ const from3 = this.renderConcept(node.from);
514781
+ const to = this.renderConcept(node.to);
514782
+ const op = operatorMeanings[node.operator] || node.operator;
514783
+ if (node.edgeType) {
514784
+ return `${from3} ${node.edgeType} ${to}`;
514785
+ }
514786
+ return `${from3} ${op} ${to}`;
514787
+ }
514788
+ /**
514789
+ * Expand CRL symbols to natural language
514790
+ */
514791
+ expand(text) {
514792
+ const expansions = {
514793
+ "∴": "therefore",
514794
+ "∵": "because",
514795
+ "≡": "is equivalent to",
514796
+ "→": "implies",
514797
+ "↔": "is mutually related to",
514798
+ "¬": "not",
514799
+ "∧": "and",
514800
+ "∨": "or",
514801
+ "∈": "is an element of",
514802
+ "∉": "is not an element of",
514803
+ "⊂": "is a subset of",
514804
+ "⊆": "is a subset of or equal to",
514805
+ "∪": "union with",
514806
+ "∩": "intersection with",
514807
+ "∅": "empty",
514808
+ "⇒": "then",
514809
+ "⇐": "from",
514810
+ "◇": "possibly",
514811
+ "□": "necessarily",
514812
+ "⊙": "observed",
514813
+ "∀": "for all",
514814
+ "∃": "there exists",
514815
+ "∄": "there does not exist"
514816
+ };
514817
+ let result = text;
514818
+ for (const [symbol3, expansion] of Object.entries(expansions)) {
514819
+ result = result.replace(new RegExp(symbol3, "g"), ` ${expansion} `);
514820
+ }
514821
+ return result.replace(/\s+/g, " ").trim();
514822
+ }
514823
+ };
514824
+ CRLTemplateResolver = class {
514825
+ /**
514826
+ * Resolve templates in CRL expression
514827
+ */
514828
+ resolve(crl, context2) {
514829
+ const templatePattern = /\$\{([^}]+)\}/g;
514830
+ return crl.replace(templatePattern, (match, template) => {
514831
+ return this.resolveTemplate(template, context2);
514832
+ });
514833
+ }
514834
+ resolveTemplate(template, context2) {
514835
+ const parts = template.split(/[:|→]/);
514836
+ const variable = parts[0].trim();
514837
+ const defaultValue = parts[1]?.trim();
514838
+ const typeAnnotation = parts[2]?.trim();
514839
+ let value2;
514840
+ if (variable.startsWith("ctx:")) {
514841
+ const ctxVar = variable.substring(5);
514842
+ value2 = context2[ctxVar];
514843
+ } else if (variable.startsWith("mem:")) {
514844
+ const memVar = variable.substring(4);
514845
+ const memArray = context2.memories?.[memVar];
514846
+ value2 = memArray?.join(", ");
514847
+ } else if (variable.startsWith("state:")) {
514848
+ const stateVar = variable.substring(6);
514849
+ value2 = context2.state?.[stateVar];
514850
+ } else {
514851
+ value2 = context2.variables?.[variable];
514852
+ }
514853
+ return value2 || defaultValue || `[${variable}]`;
514854
+ }
514855
+ };
514856
+ CRL = {
514857
+ parser: new CRLParser(),
514858
+ encoder: new CRLEncoder(),
514859
+ decoder: new CRLDecoder(),
514860
+ resolver: new CRLTemplateResolver(),
514861
+ symbols: CRL_SYMBOLS,
514862
+ meanings: SYMBOL_MEANINGS,
514863
+ /**
514864
+ * Quick encode: natural language → CRL
514865
+ */
514866
+ encode(text) {
514867
+ return this.encoder.encode(text);
514868
+ },
514869
+ /**
514870
+ * Quick decode: CRL → natural language
514871
+ */
514872
+ decode(crl) {
514873
+ return this.decoder.decode(crl);
514874
+ },
514875
+ /**
514876
+ * Quick compress: replace common patterns with symbols
514877
+ */
514878
+ compress(text) {
514879
+ return this.encoder.compress(text);
514880
+ },
514881
+ /**
514882
+ * Quick expand: replace symbols with natural language
514883
+ */
514884
+ expand(text) {
514885
+ return this.decoder.expand(text);
514886
+ },
514887
+ /**
514888
+ * Resolve templates with context
514889
+ */
514890
+ resolve(crl, context2) {
514891
+ return this.resolver.resolve(crl, context2);
514892
+ }
514893
+ };
514894
+ }
514895
+ });
514896
+
514377
514897
  // packages/memory/dist/index.js
514378
514898
  var dist_exports2 = {};
514379
514899
  __export(dist_exports2, {
514900
+ CRL: () => CRL,
514901
+ CRLDecoder: () => CRLDecoder,
514902
+ CRLEncoder: () => CRLEncoder,
514903
+ CRLParser: () => CRLParser,
514904
+ CRLTemplateResolver: () => CRLTemplateResolver,
514905
+ CRL_SYMBOLS: () => CRL_SYMBOLS,
514380
514906
  DECAY_TAU: () => DECAY_TAU,
514381
514907
  EmbeddingAligner: () => EmbeddingAligner,
514382
514908
  EpisodeStore: () => EpisodeStore,
@@ -514385,6 +514911,7 @@ __export(dist_exports2, {
514385
514911
  PatchHistoryStore: () => PatchHistoryStore,
514386
514912
  ProceduralMemoryStore: () => ProceduralMemoryStore,
514387
514913
  RepoProfileStore: () => RepoProfileStore,
514914
+ SYMBOL_MEANINGS: () => SYMBOL_MEANINGS,
514388
514915
  TaskMemoryStore: () => TaskMemoryStore,
514389
514916
  TemporalGraph: () => TemporalGraph,
514390
514917
  ToolPatternStore: () => ToolPatternStore,
@@ -514432,6 +514959,7 @@ var init_dist7 = __esm({
514432
514959
  init_proceduralMemoryStore();
514433
514960
  init_splanifold();
514434
514961
  init_embeddingAligner();
514962
+ init_crl();
514435
514963
  }
514436
514964
  });
514437
514965
 
@@ -524187,6 +524715,105 @@ var init_dist8 = __esm({
524187
524715
  }
524188
524716
  });
524189
524717
 
524718
+ // packages/cli/src/ui/spinner.ts
524719
+ var FRAMES, INTERVAL_MS, Spinner;
524720
+ var init_spinner = __esm({
524721
+ "packages/cli/src/ui/spinner.ts"() {
524722
+ "use strict";
524723
+ FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
524724
+ INTERVAL_MS = 80;
524725
+ Spinner = class {
524726
+ _text;
524727
+ _frameIndex = 0;
524728
+ _timer = null;
524729
+ _isSpinning = false;
524730
+ constructor(text) {
524731
+ this._text = text;
524732
+ }
524733
+ // --------------------------------------------------------------------------
524734
+ // Public API
524735
+ // --------------------------------------------------------------------------
524736
+ get text() {
524737
+ return this._text;
524738
+ }
524739
+ set text(value2) {
524740
+ this._text = value2;
524741
+ if (this._isSpinning && process.stdout.isTTY) {
524742
+ this._render();
524743
+ }
524744
+ }
524745
+ get isSpinning() {
524746
+ return this._isSpinning;
524747
+ }
524748
+ start() {
524749
+ if (this._isSpinning) return this;
524750
+ this._isSpinning = true;
524751
+ this._frameIndex = 0;
524752
+ if (process.stdout.isTTY) {
524753
+ process.stdout.write("\x1B[?25l");
524754
+ this._render();
524755
+ this._timer = setInterval(() => {
524756
+ this._frameIndex = (this._frameIndex + 1) % FRAMES.length;
524757
+ this._render();
524758
+ }, INTERVAL_MS);
524759
+ } else {
524760
+ process.stdout.write(`${this._text}
524761
+ `);
524762
+ }
524763
+ return this;
524764
+ }
524765
+ stop() {
524766
+ if (!this._isSpinning) return this;
524767
+ this._isSpinning = false;
524768
+ if (this._timer !== null) {
524769
+ clearInterval(this._timer);
524770
+ this._timer = null;
524771
+ }
524772
+ if (process.stdout.isTTY) {
524773
+ process.stdout.write("\r\x1B[K");
524774
+ process.stdout.write("\x1B[?25h");
524775
+ }
524776
+ return this;
524777
+ }
524778
+ succeed(message2) {
524779
+ this.stop();
524780
+ const msg = message2 ?? this._text;
524781
+ process.stdout.write(`\x1B[32m✔\x1B[0m ${msg}
524782
+ `);
524783
+ return this;
524784
+ }
524785
+ fail(message2) {
524786
+ this.stop();
524787
+ const msg = message2 ?? this._text;
524788
+ process.stdout.write(`\x1B[31m✖\x1B[0m ${msg}
524789
+ `);
524790
+ return this;
524791
+ }
524792
+ warn(message2) {
524793
+ this.stop();
524794
+ const msg = message2 ?? this._text;
524795
+ process.stdout.write(`\x1B[33m⚠\x1B[0m ${msg}
524796
+ `);
524797
+ return this;
524798
+ }
524799
+ info(message2) {
524800
+ this.stop();
524801
+ const msg = message2 ?? this._text;
524802
+ process.stdout.write(`\x1B[36mℹ\x1B[0m ${msg}
524803
+ `);
524804
+ return this;
524805
+ }
524806
+ // --------------------------------------------------------------------------
524807
+ // Private
524808
+ // --------------------------------------------------------------------------
524809
+ _render() {
524810
+ const frame = FRAMES[this._frameIndex] ?? FRAMES[0];
524811
+ process.stdout.write(`\r\x1B[36m${frame}\x1B[0m ${this._text}`);
524812
+ }
524813
+ };
524814
+ }
524815
+ });
524816
+
524190
524817
  // packages/cli/src/api/py-embed.ts
524191
524818
  var py_embed_exports = {};
524192
524819
  __export(py_embed_exports, {
@@ -527292,7 +527919,7 @@ var require_websocket3 = __commonJS({
527292
527919
  var http6 = __require("http");
527293
527920
  var net5 = __require("net");
527294
527921
  var tls2 = __require("tls");
527295
- var { randomBytes: randomBytes23, createHash: createHash13 } = __require("crypto");
527922
+ var { randomBytes: randomBytes23, createHash: createHash14 } = __require("crypto");
527296
527923
  var { Duplex: Duplex3, Readable } = __require("stream");
527297
527924
  var { URL: URL3 } = __require("url");
527298
527925
  var PerMessageDeflate2 = require_permessage_deflate3();
@@ -527952,7 +528579,7 @@ var require_websocket3 = __commonJS({
527952
528579
  abortHandshake(websocket, socket, "Invalid Upgrade header");
527953
528580
  return;
527954
528581
  }
527955
- const digest3 = createHash13("sha1").update(key + GUID).digest("base64");
528582
+ const digest3 = createHash14("sha1").update(key + GUID).digest("base64");
527956
528583
  if (res.headers["sec-websocket-accept"] !== digest3) {
527957
528584
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
527958
528585
  return;
@@ -528319,7 +528946,7 @@ var require_websocket_server2 = __commonJS({
528319
528946
  var EventEmitter12 = __require("events");
528320
528947
  var http6 = __require("http");
528321
528948
  var { Duplex: Duplex3 } = __require("stream");
528322
- var { createHash: createHash13 } = __require("crypto");
528949
+ var { createHash: createHash14 } = __require("crypto");
528323
528950
  var extension2 = require_extension3();
528324
528951
  var PerMessageDeflate2 = require_permessage_deflate3();
528325
528952
  var subprotocol2 = require_subprotocol2();
@@ -528620,7 +529247,7 @@ var require_websocket_server2 = __commonJS({
528620
529247
  );
528621
529248
  }
528622
529249
  if (this._state > RUNNING) return abortHandshake(socket, 503);
528623
- const digest3 = createHash13("sha1").update(key + GUID).digest("base64");
529250
+ const digest3 = createHash14("sha1").update(key + GUID).digest("base64");
528624
529251
  const headers = [
528625
529252
  "HTTP/1.1 101 Switching Protocols",
528626
529253
  "Upgrade: websocket",
@@ -529663,9 +530290,10 @@ __export(oa_directory_exports, {
529663
530290
  writeIndexData: () => writeIndexData,
529664
530291
  writeIndexMeta: () => writeIndexMeta
529665
530292
  });
529666
- import { existsSync as existsSync57, mkdirSync as mkdirSync32, readFileSync as readFileSync44, writeFileSync as writeFileSync29, readdirSync as readdirSync14, statSync as statSync17, unlinkSync as unlinkSync14, openSync as openSync2, closeSync as closeSync2 } from "node:fs";
530293
+ import { existsSync as existsSync57, mkdirSync as mkdirSync32, readFileSync as readFileSync44, writeFileSync as writeFileSync29, readdirSync as readdirSync14, statSync as statSync17, unlinkSync as unlinkSync14, openSync as openSync2, closeSync as closeSync2, renameSync as renameSync3 } from "node:fs";
529667
530294
  import { join as join75, relative as relative6, basename as basename13, dirname as dirname22 } from "node:path";
529668
530295
  import { homedir as homedir25 } from "node:os";
530296
+ import { createHash as createHash8 } from "node:crypto";
529669
530297
  function findGitRoot(startDir) {
529670
530298
  let dir = startDir;
529671
530299
  const visited = /* @__PURE__ */ new Set();
@@ -529944,6 +530572,14 @@ function loadPendingTask(repoRoot) {
529944
530572
  return null;
529945
530573
  }
529946
530574
  }
530575
+ function computeDedupeHash(task, savedAt) {
530576
+ return createHash8("sha256").update(`${task}|${savedAt}`).digest("hex").slice(0, 16);
530577
+ }
530578
+ function generateSessionId() {
530579
+ const timestamp = Date.now().toString(36);
530580
+ const random = Math.random().toString(36).slice(2, 8);
530581
+ return `${timestamp}-${random}`;
530582
+ }
529947
530583
  function acquireLock(lockPath) {
529948
530584
  const startTime = Date.now();
529949
530585
  const pid = process.pid;
@@ -530027,16 +530663,11 @@ function normalizeSessionContextEntry(entry) {
530027
530663
  const assistantResponse = normalizeSessionText(entry.assistantResponse, 1200);
530028
530664
  if (assistantResponse) normalized.assistantResponse = assistantResponse;
530029
530665
  if (entry.source) normalized.source = entry.source;
530030
- return normalized;
530031
- }
530032
- function sameStringArray(a2, b) {
530033
- const left = a2 ?? [];
530034
- const right = b ?? [];
530035
- if (left.length !== right.length) return false;
530036
- for (let i2 = 0; i2 < left.length; i2++) {
530037
- if (left[i2] !== right[i2]) return false;
530666
+ normalized._dedupeHash = computeDedupeHash(normalized.task, normalized.savedAt);
530667
+ if (!normalized.sessionId) {
530668
+ normalized.sessionId = generateSessionId();
530038
530669
  }
530039
- return true;
530670
+ return normalized;
530040
530671
  }
530041
530672
  function lastMatchingIndex(items, predicate) {
530042
530673
  for (let i2 = items.length - 1; i2 >= 0; i2--) {
@@ -530058,9 +530689,6 @@ function isWithinReplaceWindow(a2, b) {
530058
530689
  if (left == null || right == null) return true;
530059
530690
  return Math.abs(right - left) <= SAME_TASK_REPLACE_WINDOW_MS;
530060
530691
  }
530061
- function isExactSessionDuplicate(a2, b) {
530062
- return sameTask(a2, b) && a2.summary === b.summary && (a2.assistantResponse ?? "") === (b.assistantResponse ?? "") && sameStringArray(a2.filesModified, b.filesModified) && sameStringArray(a2.toolsUsed, b.toolsUsed) && (a2.provenance ?? "") === (b.provenance ?? "") && a2.toolCalls === b.toolCalls && a2.completed === b.completed && a2.model === b.model;
530063
- }
530064
530692
  function mergeSessionContextEntry(previous, incoming) {
530065
530693
  return {
530066
530694
  ...previous,
@@ -530099,12 +530727,19 @@ function saveSessionContext(repoRoot, entry) {
530099
530727
  ctx3 = { entries: [], maxEntries: MAX_CONTEXT_ENTRIES, updatedAt: "" };
530100
530728
  }
530101
530729
  const normalizedEntry = normalizeSessionContextEntry(entry);
530102
- const exactIndex = lastMatchingIndex(
530103
- ctx3.entries,
530104
- (existing) => isExactSessionDuplicate(normalizeSessionContextEntry(existing), normalizedEntry)
530105
- );
530106
- if (exactIndex >= 0) {
530107
- ctx3.entries[exactIndex] = mergeSessionContextEntry(ctx3.entries[exactIndex], normalizedEntry);
530730
+ const hashToIndex = /* @__PURE__ */ new Map();
530731
+ for (let i2 = 0; i2 < ctx3.entries.length; i2++) {
530732
+ const existing = ctx3.entries[i2];
530733
+ const hash = existing._dedupeHash || computeDedupeHash(
530734
+ cleanPromptForDiary(existing.task),
530735
+ existing.savedAt
530736
+ );
530737
+ hashToIndex.set(hash, i2);
530738
+ }
530739
+ const incomingHash = normalizedEntry._dedupeHash;
530740
+ const hashMatchIndex = hashToIndex.get(incomingHash);
530741
+ if (hashMatchIndex !== void 0) {
530742
+ ctx3.entries[hashMatchIndex] = mergeSessionContextEntry(ctx3.entries[hashMatchIndex], normalizedEntry);
530108
530743
  } else {
530109
530744
  const relatedIndex = lastMatchingIndex(ctx3.entries, (existing) => {
530110
530745
  const normalizedExisting = normalizeSessionContextEntry(existing);
@@ -530129,7 +530764,17 @@ function saveSessionContext(repoRoot, entry) {
530129
530764
  ctx3.entries = ctx3.entries.slice(-ctx3.maxEntries);
530130
530765
  }
530131
530766
  ctx3.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
530132
- writeFileSync29(filePath, JSON.stringify(ctx3, null, 2) + "\n", "utf-8");
530767
+ const tempFilePath = filePath + ".tmp";
530768
+ writeFileSync29(tempFilePath, JSON.stringify(ctx3, null, 2) + "\n", "utf-8");
530769
+ try {
530770
+ renameSync3(tempFilePath, filePath);
530771
+ } catch {
530772
+ writeFileSync29(filePath, JSON.stringify(ctx3, null, 2) + "\n", "utf-8");
530773
+ try {
530774
+ unlinkSync14(tempFilePath);
530775
+ } catch {
530776
+ }
530777
+ }
530133
530778
  try {
530134
530779
  writeFileSync29(
530135
530780
  join75(contextDir, "session-diary.md"),
@@ -534227,6 +534872,7 @@ ${CONTENT_BG_SEQ}`);
534227
534872
  process.stdout.write(RESET2);
534228
534873
  this._brailleSpinner.setMetrics({ isStreaming: false });
534229
534874
  this.renderFooterAndPositionInput();
534875
+ this.parkCursorInInput();
534230
534876
  this.scheduleMouseIdle();
534231
534877
  }
534232
534878
  }
@@ -534905,6 +535551,27 @@ ${CONTENT_BG_SEQ}`);
534905
535551
  this.termWrite(
534906
535552
  `\x1B[${this.scrollRegionTop};${pos.scrollEnd}r\x1B[${pos.scrollEnd};1H` + (clearScrollback ? "\x1B[3J" : "")
534907
535553
  );
535554
+ if (this.writeDepth === 0) {
535555
+ this.parkCursorInInput();
535556
+ }
535557
+ }
535558
+ /**
535559
+ * Park cursor in the input row — ensures cursor is always in the input area
535560
+ * after scroll region changes or other operations that may leave it elsewhere.
535561
+ * Called after applyScrollRegion() and in endContentWrite() for safety.
535562
+ */
535563
+ parkCursorInInput() {
535564
+ if (!this.active) return;
535565
+ const rows = termRows();
535566
+ const w = getTermWidth();
535567
+ const pos = this.rowPositions(rows);
535568
+ const inputWrap = this.wrapInput(w);
535569
+ const cursorRow = pos.inputStartRow + inputWrap.cursorRow;
535570
+ const cursorCol = inputWrap.cursorCol;
535571
+ if (process.env.OA_DEBUG_CURSOR === "1") {
535572
+ console.error(`[CURSOR DEBUG] parkCursorInInput: row=${cursorRow}, col=${cursorCol}, inputStartRow=${pos.inputStartRow}, cursorRow=${inputWrap.cursorRow}, writeDepth=${this.writeDepth}`);
535573
+ }
535574
+ this.termWrite(`\x1B[${cursorRow};${cursorCol}H\x1B[?25h`);
534908
535575
  }
534909
535576
  /**
534910
535577
  * WO-TASK-02 — Public hook for the TUI tasks renderer. When the tasks
@@ -557973,7 +558640,7 @@ var init_types = __esm({
557973
558640
  });
557974
558641
 
557975
558642
  // packages/cli/src/tui/p2p/secret-vault.ts
557976
- import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes18, scryptSync as scryptSync2, createHash as createHash8 } from "node:crypto";
558643
+ import { createCipheriv as createCipheriv3, createDecipheriv as createDecipheriv3, randomBytes as randomBytes18, scryptSync as scryptSync2, createHash as createHash9 } from "node:crypto";
557977
558644
  import { readFileSync as readFileSync54, writeFileSync as writeFileSync37, existsSync as existsSync69, mkdirSync as mkdirSync40 } from "node:fs";
557978
558645
  import { dirname as dirname26 } from "node:path";
557979
558646
  var PLACEHOLDER_PREFIX, PLACEHOLDER_SUFFIX, CIPHER_ALGO, SALT_LEN, IV_LEN, KEY_LEN, SecretVault;
@@ -558218,7 +558885,7 @@ var init_secret_vault = __esm({
558218
558885
  /** Generate a deterministic fingerprint of vault contents (for sync verification) */
558219
558886
  fingerprint() {
558220
558887
  const names = Array.from(this.secrets.keys()).sort();
558221
- const hash = createHash8("sha256");
558888
+ const hash = createHash9("sha256");
558222
558889
  for (const name10 of names) {
558223
558890
  hash.update(name10 + ":");
558224
558891
  hash.update(this.secrets.get(name10).value);
@@ -558233,7 +558900,7 @@ var init_secret_vault = __esm({
558233
558900
  // packages/cli/src/tui/p2p/peer-mesh.ts
558234
558901
  import { EventEmitter as EventEmitter7 } from "node:events";
558235
558902
  import { createServer as createServer5 } from "node:http";
558236
- import { randomBytes as randomBytes19, createHash as createHash9, generateKeyPairSync } from "node:crypto";
558903
+ import { randomBytes as randomBytes19, createHash as createHash10, generateKeyPairSync } from "node:crypto";
558237
558904
  var PING_INTERVAL_MS, PEER_TIMEOUT_MS, GOSSIP_INTERVAL_MS, MAX_PEERS, PeerMesh;
558238
558905
  var init_peer_mesh = __esm({
558239
558906
  "packages/cli/src/tui/p2p/peer-mesh.ts"() {
@@ -558250,7 +558917,7 @@ var init_peer_mesh = __esm({
558250
558917
  const { publicKey: publicKey2, privateKey } = generateKeyPairSync("ed25519");
558251
558918
  this.publicKey = publicKey2.export({ type: "spki", format: "der" });
558252
558919
  this.privateKey = privateKey.export({ type: "pkcs8", format: "der" });
558253
- this.peerId = createHash9("sha256").update(this.publicKey).digest("base64url").slice(0, 22);
558920
+ this.peerId = createHash10("sha256").update(this.publicKey).digest("base64url").slice(0, 22);
558254
558921
  this.capabilities = options2.capabilities;
558255
558922
  this.displayName = options2.displayName;
558256
558923
  this._authKey = options2.authKey ?? randomBytes19(24).toString("base64url");
@@ -566114,7 +566781,7 @@ import {
566114
566781
  readFileSync as readFileSync62,
566115
566782
  readdirSync as readdirSync25,
566116
566783
  writeFileSync as writeFileSync42,
566117
- renameSync as renameSync4,
566784
+ renameSync as renameSync5,
566118
566785
  mkdirSync as mkdirSync47,
566119
566786
  unlinkSync as unlinkSync21
566120
566787
  } from "node:fs";
@@ -566137,7 +566804,7 @@ function persistSession(s2) {
566137
566804
  const final2 = sessionPath(s2.id);
566138
566805
  const tmp = `${final2}.tmp.${process.pid}.${Date.now()}`;
566139
566806
  writeFileSync42(tmp, JSON.stringify(s2, null, 2), "utf-8");
566140
- renameSync4(tmp, final2);
566807
+ renameSync5(tmp, final2);
566141
566808
  } catch {
566142
566809
  }
566143
566810
  }
@@ -566147,7 +566814,7 @@ function persistInFlight(j) {
566147
566814
  const final2 = inFlightPath(j.sessionId);
566148
566815
  const tmp = `${final2}.tmp.${process.pid}.${Date.now()}`;
566149
566816
  writeFileSync42(tmp, JSON.stringify(j, null, 2), "utf-8");
566150
- renameSync4(tmp, final2);
566817
+ renameSync5(tmp, final2);
566151
566818
  } catch {
566152
566819
  }
566153
566820
  }
@@ -566529,7 +567196,7 @@ __export(projects_exports, {
566529
567196
  setCurrentProject: () => setCurrentProject,
566530
567197
  unregisterProject: () => unregisterProject
566531
567198
  });
566532
- import { readFileSync as readFileSync63, writeFileSync as writeFileSync43, mkdirSync as mkdirSync48, existsSync as existsSync79, statSync as statSync23, renameSync as renameSync5 } from "node:fs";
567199
+ import { readFileSync as readFileSync63, writeFileSync as writeFileSync43, mkdirSync as mkdirSync48, existsSync as existsSync79, statSync as statSync23, renameSync as renameSync6 } from "node:fs";
566533
567200
  import { homedir as homedir34 } from "node:os";
566534
567201
  import { basename as basename19, join as join97, resolve as resolve34 } from "node:path";
566535
567202
  import { randomUUID as randomUUID12 } from "node:crypto";
@@ -566548,7 +567215,7 @@ function writeAll(file) {
566548
567215
  mkdirSync48(OA_DIR3, { recursive: true });
566549
567216
  const tmp = `${PROJECTS_FILE}.${randomUUID12().slice(0, 8)}.tmp`;
566550
567217
  writeFileSync43(tmp, JSON.stringify(file, null, 2), "utf8");
566551
- renameSync5(tmp, PROJECTS_FILE);
567218
+ renameSync6(tmp, PROJECTS_FILE);
566552
567219
  }
566553
567220
  function listProjects() {
566554
567221
  const { projects } = readAll();
@@ -567542,7 +568209,7 @@ var init_disk_task_output = __esm({
567542
568209
  });
567543
568210
 
567544
568211
  // packages/cli/src/api/http.ts
567545
- import { createHash as createHash10 } from "node:crypto";
568212
+ import { createHash as createHash11 } from "node:crypto";
567546
568213
  function problemDetails(opts) {
567547
568214
  const p2 = {
567548
568215
  type: opts.type ?? "about:blank",
@@ -567605,7 +568272,7 @@ function paginated(items, page2, total) {
567605
568272
  }
567606
568273
  function computeEtag(payload) {
567607
568274
  const json = typeof payload === "string" ? payload : JSON.stringify(payload);
567608
- const hash = createHash10("sha1").update(json).digest("hex").slice(0, 16);
568275
+ const hash = createHash11("sha1").update(json).digest("hex").slice(0, 16);
567609
568276
  return `W/"${hash}"`;
567610
568277
  }
567611
568278
  function checkNotModified(req2, res, etag) {
@@ -575384,7 +576051,7 @@ import { homedir as homedir39 } from "node:os";
575384
576051
  import { spawn as spawn25, execSync as execSync55 } from "node:child_process";
575385
576052
  import { mkdirSync as mkdirSync54, writeFileSync as writeFileSync47, readFileSync as readFileSync69, readdirSync as readdirSync29, existsSync as existsSync87, watch as fsWatch3 } from "node:fs";
575386
576053
  import { randomBytes as randomBytes21, randomUUID as randomUUID13 } from "node:crypto";
575387
- import { createHash as createHash12 } from "node:crypto";
576054
+ import { createHash as createHash13 } from "node:crypto";
575388
576055
  function getVersion3() {
575389
576056
  try {
575390
576057
  const require3 = createRequire4(import.meta.url);
@@ -576131,8 +576798,9 @@ function checkAuth(req2, res, requiredScope = "read") {
576131
576798
  });
576132
576799
  return false;
576133
576800
  }
576134
- req2._authUser = auth.user;
576135
- req2._authScope = auth.scope;
576801
+ const reqWithAuth = req2;
576802
+ reqWithAuth._authUser = auth.user;
576803
+ reqWithAuth._authScope = auth.scope;
576136
576804
  return true;
576137
576805
  }
576138
576806
  function handleHealth(res) {
@@ -579410,7 +580078,7 @@ function listScheduledTasks() {
579410
580078
  const schedule = String(t2?.schedule || t2?.cron || t2?.when || "");
579411
580079
  const enabled2 = typeof t2?.enabled === "boolean" ? t2.enabled : true;
579412
580080
  const realId = typeof t2?.id === "string" && t2.id ? t2.id : null;
579413
- const fallbackId = createHash12("sha1").update(`${file}#${i2}`).digest("hex").slice(0, 16);
580081
+ const fallbackId = createHash13("sha1").update(`${file}#${i2}`).digest("hex").slice(0, 16);
579414
580082
  const uid = realId || fallbackId;
579415
580083
  const key = `${uid}`;
579416
580084
  if (seen.has(key)) return;
@@ -579527,8 +580195,8 @@ function deleteScheduledById(id) {
579527
580195
  if (id) candidates.push(id);
579528
580196
  if (typeof entry?.id === "string" && entry.id && !candidates.includes(entry.id)) candidates.push(entry.id);
579529
580197
  try {
579530
- const { createHash: createHash13 } = __require("node:crypto");
579531
- const fallback = createHash13("sha1").update(`${target.file}#${target.index}`).digest("hex").slice(0, 16);
580198
+ const { createHash: createHash14 } = __require("node:crypto");
580199
+ const fallback = createHash14("sha1").update(`${target.file}#${target.index}`).digest("hex").slice(0, 16);
579532
580200
  if (!candidates.includes(fallback)) candidates.push(fallback);
579533
580201
  } catch {
579534
580202
  }
@@ -587107,13 +587775,13 @@ ${fullInput}`;
587107
587775
  writeContent(() => renderError2(errMsg));
587108
587776
  if (failureStore) {
587109
587777
  try {
587110
- const { createHash: createHash13 } = await import("node:crypto");
587778
+ const { createHash: createHash14 } = await import("node:crypto");
587111
587779
  failureStore.insert({
587112
587780
  taskId: "",
587113
587781
  sessionId: `${Date.now()}`,
587114
587782
  repoRoot,
587115
587783
  failureType: "runtime-error",
587116
- fingerprint: createHash13("sha256").update(errMsg.slice(0, 200)).digest("hex").slice(0, 16),
587784
+ fingerprint: createHash14("sha256").update(errMsg.slice(0, 200)).digest("hex").slice(0, 16),
587117
587785
  filePath: null,
587118
587786
  errorMessage: errMsg.slice(0, 500),
587119
587787
  context: null,
@@ -588716,6 +589384,7 @@ import { dirname as dirname33, join as join109 } from "node:path";
588716
589384
 
588717
589385
  // packages/cli/src/cli.ts
588718
589386
  init_typed_node_events();
589387
+ init_dist8();
588719
589388
  import { createInterface } from "node:readline";
588720
589389
  function createCli(options2) {
588721
589390
  return {
@@ -588725,6 +589394,29 @@ function createCli(options2) {
588725
589394
  console.log(`Backend: ${options2.backendUrl}`);
588726
589395
  console.log(`Project: ${options2.projectRoot}`);
588727
589396
  console.log("");
589397
+ const backend = new OllamaAgenticBackend(options2.backendUrl, options2.model);
589398
+ const runner = new AgenticRunner(backend, {
589399
+ maxTurns: 50
589400
+ });
589401
+ runner.onEvent((event) => {
589402
+ switch (event.type) {
589403
+ case "tool_call":
589404
+ if (event.toolName) console.log(`[tool] ${event.toolName}`);
589405
+ break;
589406
+ case "tool_result":
589407
+ if (event.toolName) console.log(`[tool] ${event.toolName} ${event.success ? "✓" : "✗"}`);
589408
+ break;
589409
+ case "status":
589410
+ if (event.content) console.log(`[status] ${event.content.slice(0, 100)}`);
589411
+ break;
589412
+ case "assistant_text":
589413
+ if (event.content) process.stdout.write(event.content);
589414
+ break;
589415
+ case "error":
589416
+ if (event.content) console.error(`[error] ${event.content}`);
589417
+ break;
589418
+ }
589419
+ });
588728
589420
  const rl = createInterface({
588729
589421
  input: process.stdin,
588730
589422
  output: process.stdout,
@@ -588742,8 +589434,16 @@ function createCli(options2) {
588742
589434
  rl.close();
588743
589435
  return;
588744
589436
  }
588745
- console.log(`[agent] Processing: "${input}"`);
588746
- console.log("[agent] Agent loop not yet connected.");
589437
+ try {
589438
+ const result = await runner.run(input);
589439
+ console.log("");
589440
+ console.log(`[agent] Task completed: ${result.completed ? "success" : "incomplete"}`);
589441
+ if (result.summary) {
589442
+ console.log(`[agent] Summary: ${result.summary.slice(0, 200)}`);
589443
+ }
589444
+ } catch (err) {
589445
+ console.error("[agent] Error:", err instanceof Error ? err.message : String(err));
589446
+ }
588747
589447
  console.log("");
588748
589448
  rl.prompt();
588749
589449
  });