agentdev 0.1.4 → 0.1.6

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.
@@ -7,7 +7,7 @@ import {
7
7
  createLLM,
8
8
  getDefaultMCPConfigDir,
9
9
  loadConfigSync
10
- } from "./chunk-4FBF65TC.js";
10
+ } from "./chunk-OBOU27DM.js";
11
11
 
12
12
  // src/agents/system/BasicAgent.ts
13
13
  import { existsSync } from "fs";
@@ -95,4 +95,4 @@ var BasicAgent = class extends AgentBase {
95
95
  export {
96
96
  BasicAgent
97
97
  };
98
- //# sourceMappingURL=chunk-XE5IEUPW.js.map
98
+ //# sourceMappingURL=chunk-LQTEETML.js.map
@@ -608,6 +608,240 @@ var Context = class _Context {
608
608
  }
609
609
  };
610
610
 
611
+ // src/core/logging.ts
612
+ import { AsyncLocalStorage } from "async_hooks";
613
+ import { inspect } from "util";
614
+ var scopeStorage = new AsyncLocalStorage();
615
+ var rawConsole = {
616
+ log: console.log.bind(console),
617
+ info: console.info.bind(console),
618
+ warn: console.warn.bind(console),
619
+ error: console.error.bind(console),
620
+ debug: console.debug.bind(console)
621
+ };
622
+ var LOG_LEVEL_WEIGHT = {
623
+ trace: 10,
624
+ debug: 20,
625
+ info: 30,
626
+ warn: 40,
627
+ error: 50
628
+ };
629
+ var nextLogId = 1;
630
+ var consoleBridgeInstalled = false;
631
+ var bridgeReentry = false;
632
+ function installConsoleBridge() {
633
+ if (consoleBridgeInstalled) return;
634
+ consoleBridgeInstalled = true;
635
+ console.log = (...args) => bridgeConsole("info", args);
636
+ console.info = (...args) => bridgeConsole("info", args);
637
+ console.warn = (...args) => bridgeConsole("warn", args);
638
+ console.error = (...args) => bridgeConsole("error", args);
639
+ console.debug = (...args) => bridgeConsole("debug", args);
640
+ }
641
+ function bridgeConsole(level, args) {
642
+ const scope = scopeStorage.getStore();
643
+ if (!scope || bridgeReentry) {
644
+ writeRawConsole(level, args);
645
+ return;
646
+ }
647
+ bridgeReentry = true;
648
+ try {
649
+ const { message, data } = normalizeConsoleArgs(args);
650
+ emitLog(level, message, data, {
651
+ namespace: scope.namespace || "console",
652
+ context: scope
653
+ });
654
+ } finally {
655
+ bridgeReentry = false;
656
+ }
657
+ }
658
+ function writeRawConsole(level, args) {
659
+ switch (level) {
660
+ case "warn":
661
+ rawConsole.warn(...args);
662
+ break;
663
+ case "error":
664
+ rawConsole.error(...args);
665
+ break;
666
+ case "debug":
667
+ rawConsole.debug(...args);
668
+ break;
669
+ case "trace":
670
+ case "info":
671
+ default:
672
+ rawConsole.log(...args);
673
+ break;
674
+ }
675
+ }
676
+ function normalizeConsoleArgs(args) {
677
+ if (args.length === 0) {
678
+ return { message: "" };
679
+ }
680
+ const [first, ...rest] = args;
681
+ if (typeof first === "string") {
682
+ if (rest.length === 0) {
683
+ return { message: first };
684
+ }
685
+ return {
686
+ message: first,
687
+ data: rest.length === 1 ? rest[0] : rest
688
+ };
689
+ }
690
+ return {
691
+ message: args.map((item) => stringifyForLog(item)).join(" "),
692
+ data: args.length === 1 ? first : args
693
+ };
694
+ }
695
+ function stringifyForLog(value) {
696
+ if (typeof value === "string") return value;
697
+ if (typeof value === "number" || typeof value === "boolean" || value == null) {
698
+ return String(value);
699
+ }
700
+ try {
701
+ return inspect(value, { depth: 4, breakLength: 120 });
702
+ } catch {
703
+ return "[unserializable]";
704
+ }
705
+ }
706
+ function mergeTags(...tagSets) {
707
+ const merged = /* @__PURE__ */ new Set();
708
+ for (const tags of tagSets) {
709
+ for (const tag of tags || []) {
710
+ if (tag) merged.add(tag);
711
+ }
712
+ }
713
+ return merged.size > 0 ? Array.from(merged) : void 0;
714
+ }
715
+ function mergeScope(base, patch) {
716
+ return {
717
+ ...base || {},
718
+ ...patch || {},
719
+ tags: mergeTags(base?.tags, patch?.tags)
720
+ };
721
+ }
722
+ function createNotification(entry) {
723
+ return {
724
+ type: "log.entry",
725
+ category: "event",
726
+ timestamp: entry.timestamp,
727
+ data: entry
728
+ };
729
+ }
730
+ function shouldDrop(level, scope) {
731
+ const minLevel = scope?.minLevel;
732
+ if (!minLevel) return false;
733
+ return LOG_LEVEL_WEIGHT[level] < LOG_LEVEL_WEIGHT[minLevel];
734
+ }
735
+ function generateLogId() {
736
+ return `log-${Date.now()}-${nextLogId++}`;
737
+ }
738
+ function runWithLogScope(scope, fn) {
739
+ const merged = mergeScope(scopeStorage.getStore(), scope);
740
+ return scopeStorage.run(merged, fn);
741
+ }
742
+ function emitLog(level, message, data, options) {
743
+ const current = scopeStorage.getStore();
744
+ const mergedContext = mergeScope(current, options?.context);
745
+ if (shouldDrop(level, mergedContext)) {
746
+ return {
747
+ id: generateLogId(),
748
+ timestamp: Date.now(),
749
+ level,
750
+ message,
751
+ namespace: options?.namespace || mergedContext.namespace || "agent",
752
+ context: {
753
+ ...mergedContext,
754
+ tags: mergedContext.tags ? [...mergedContext.tags] : void 0
755
+ },
756
+ data,
757
+ delivery: {
758
+ hub: false,
759
+ console: false,
760
+ reason: "hub-unavailable"
761
+ }
762
+ };
763
+ }
764
+ const entry = {
765
+ id: generateLogId(),
766
+ timestamp: Date.now(),
767
+ level,
768
+ message,
769
+ namespace: options?.namespace || mergedContext.namespace || "agent",
770
+ context: {
771
+ ...mergedContext,
772
+ tags: mergedContext.tags ? [...mergedContext.tags] : void 0
773
+ },
774
+ data,
775
+ delivery: {
776
+ hub: false,
777
+ console: false,
778
+ reason: "hub-unavailable"
779
+ }
780
+ };
781
+ const agentId = entry.context.agentId;
782
+ if (!agentId) {
783
+ entry.delivery = {
784
+ hub: false,
785
+ console: true,
786
+ reason: "no-agent-context"
787
+ };
788
+ writeRawConsole(level, [message, ...data === void 0 ? [] : [data]]);
789
+ return entry;
790
+ }
791
+ const debugHub = DebugHub.getInstance();
792
+ if (debugHub.isConnected()) {
793
+ entry.delivery = {
794
+ hub: true,
795
+ console: false,
796
+ reason: "hub"
797
+ };
798
+ debugHub.pushNotification(agentId, createNotification(entry));
799
+ return entry;
800
+ }
801
+ entry.delivery = {
802
+ hub: false,
803
+ console: true,
804
+ reason: "hub-unavailable"
805
+ };
806
+ writeLocalFallback(entry);
807
+ return entry;
808
+ }
809
+ function writeLocalFallback(entry) {
810
+ const prefix = `[${entry.namespace}] [local-only:${entry.delivery.reason}] ${entry.message}`;
811
+ const args = entry.data === void 0 ? [prefix] : [prefix, entry.data];
812
+ writeRawConsole(entry.level, args);
813
+ }
814
+ var BoundLogger = class _BoundLogger {
815
+ constructor(namespace, bindings = {}) {
816
+ this.namespace = namespace;
817
+ this.bindings = bindings;
818
+ }
819
+ trace(message, data) {
820
+ emitLog("trace", message, data, { namespace: this.namespace, context: this.bindings });
821
+ }
822
+ debug(message, data) {
823
+ emitLog("debug", message, data, { namespace: this.namespace, context: this.bindings });
824
+ }
825
+ info(message, data) {
826
+ emitLog("info", message, data, { namespace: this.namespace, context: this.bindings });
827
+ }
828
+ warn(message, data) {
829
+ emitLog("warn", message, data, { namespace: this.namespace, context: this.bindings });
830
+ }
831
+ error(message, data) {
832
+ emitLog("error", message, data, { namespace: this.namespace, context: this.bindings });
833
+ }
834
+ child(options = {}) {
835
+ const childNamespace = options.namespace || this.namespace;
836
+ const mergedBindings = mergeScope(this.bindings, options);
837
+ delete mergedBindings.namespace;
838
+ return new _BoundLogger(childNamespace, mergedBindings);
839
+ }
840
+ };
841
+ function createLogger(namespace, bindings) {
842
+ return new BoundLogger(namespace, bindings);
843
+ }
844
+
611
845
  // src/core/session-store.ts
612
846
  import { mkdir, readFile, readdir, rm, writeFile } from "fs/promises";
613
847
  import { resolve } from "path";
@@ -1416,242 +1650,6 @@ import {
1416
1650
  CompatibilityCallToolResultSchema,
1417
1651
  ListToolsResultSchema
1418
1652
  } from "@modelcontextprotocol/sdk/types.js";
1419
-
1420
- // src/core/logging.ts
1421
- import { AsyncLocalStorage } from "async_hooks";
1422
- import { inspect } from "util";
1423
- var scopeStorage = new AsyncLocalStorage();
1424
- var rawConsole = {
1425
- log: console.log.bind(console),
1426
- info: console.info.bind(console),
1427
- warn: console.warn.bind(console),
1428
- error: console.error.bind(console),
1429
- debug: console.debug.bind(console)
1430
- };
1431
- var LOG_LEVEL_WEIGHT = {
1432
- trace: 10,
1433
- debug: 20,
1434
- info: 30,
1435
- warn: 40,
1436
- error: 50
1437
- };
1438
- var nextLogId = 1;
1439
- var consoleBridgeInstalled = false;
1440
- var bridgeReentry = false;
1441
- function installConsoleBridge() {
1442
- if (consoleBridgeInstalled) return;
1443
- consoleBridgeInstalled = true;
1444
- console.log = (...args) => bridgeConsole("info", args);
1445
- console.info = (...args) => bridgeConsole("info", args);
1446
- console.warn = (...args) => bridgeConsole("warn", args);
1447
- console.error = (...args) => bridgeConsole("error", args);
1448
- console.debug = (...args) => bridgeConsole("debug", args);
1449
- }
1450
- function bridgeConsole(level, args) {
1451
- const scope = scopeStorage.getStore();
1452
- if (!scope || bridgeReentry) {
1453
- writeRawConsole(level, args);
1454
- return;
1455
- }
1456
- bridgeReentry = true;
1457
- try {
1458
- const { message, data } = normalizeConsoleArgs(args);
1459
- emitLog(level, message, data, {
1460
- namespace: scope.namespace || "console",
1461
- context: scope
1462
- });
1463
- } finally {
1464
- bridgeReentry = false;
1465
- }
1466
- }
1467
- function writeRawConsole(level, args) {
1468
- switch (level) {
1469
- case "warn":
1470
- rawConsole.warn(...args);
1471
- break;
1472
- case "error":
1473
- rawConsole.error(...args);
1474
- break;
1475
- case "debug":
1476
- rawConsole.debug(...args);
1477
- break;
1478
- case "trace":
1479
- case "info":
1480
- default:
1481
- rawConsole.log(...args);
1482
- break;
1483
- }
1484
- }
1485
- function normalizeConsoleArgs(args) {
1486
- if (args.length === 0) {
1487
- return { message: "" };
1488
- }
1489
- const [first, ...rest] = args;
1490
- if (typeof first === "string") {
1491
- if (rest.length === 0) {
1492
- return { message: first };
1493
- }
1494
- return {
1495
- message: first,
1496
- data: rest.length === 1 ? rest[0] : rest
1497
- };
1498
- }
1499
- return {
1500
- message: args.map((item) => stringifyForLog(item)).join(" "),
1501
- data: args.length === 1 ? first : args
1502
- };
1503
- }
1504
- function stringifyForLog(value) {
1505
- if (typeof value === "string") return value;
1506
- if (typeof value === "number" || typeof value === "boolean" || value == null) {
1507
- return String(value);
1508
- }
1509
- try {
1510
- return inspect(value, { depth: 4, breakLength: 120 });
1511
- } catch {
1512
- return "[unserializable]";
1513
- }
1514
- }
1515
- function mergeTags(...tagSets) {
1516
- const merged = /* @__PURE__ */ new Set();
1517
- for (const tags of tagSets) {
1518
- for (const tag of tags || []) {
1519
- if (tag) merged.add(tag);
1520
- }
1521
- }
1522
- return merged.size > 0 ? Array.from(merged) : void 0;
1523
- }
1524
- function mergeScope(base, patch) {
1525
- return {
1526
- ...base || {},
1527
- ...patch || {},
1528
- tags: mergeTags(base?.tags, patch?.tags)
1529
- };
1530
- }
1531
- function createNotification(entry) {
1532
- return {
1533
- type: "log.entry",
1534
- category: "event",
1535
- timestamp: entry.timestamp,
1536
- data: entry
1537
- };
1538
- }
1539
- function shouldDrop(level, scope) {
1540
- const minLevel = scope?.minLevel;
1541
- if (!minLevel) return false;
1542
- return LOG_LEVEL_WEIGHT[level] < LOG_LEVEL_WEIGHT[minLevel];
1543
- }
1544
- function generateLogId() {
1545
- return `log-${Date.now()}-${nextLogId++}`;
1546
- }
1547
- function runWithLogScope(scope, fn) {
1548
- const merged = mergeScope(scopeStorage.getStore(), scope);
1549
- return scopeStorage.run(merged, fn);
1550
- }
1551
- function emitLog(level, message, data, options) {
1552
- const current = scopeStorage.getStore();
1553
- const mergedContext = mergeScope(current, options?.context);
1554
- if (shouldDrop(level, mergedContext)) {
1555
- return {
1556
- id: generateLogId(),
1557
- timestamp: Date.now(),
1558
- level,
1559
- message,
1560
- namespace: options?.namespace || mergedContext.namespace || "agent",
1561
- context: {
1562
- ...mergedContext,
1563
- tags: mergedContext.tags ? [...mergedContext.tags] : void 0
1564
- },
1565
- data,
1566
- delivery: {
1567
- hub: false,
1568
- console: false,
1569
- reason: "hub-unavailable"
1570
- }
1571
- };
1572
- }
1573
- const entry = {
1574
- id: generateLogId(),
1575
- timestamp: Date.now(),
1576
- level,
1577
- message,
1578
- namespace: options?.namespace || mergedContext.namespace || "agent",
1579
- context: {
1580
- ...mergedContext,
1581
- tags: mergedContext.tags ? [...mergedContext.tags] : void 0
1582
- },
1583
- data,
1584
- delivery: {
1585
- hub: false,
1586
- console: false,
1587
- reason: "hub-unavailable"
1588
- }
1589
- };
1590
- const agentId = entry.context.agentId;
1591
- if (!agentId) {
1592
- entry.delivery = {
1593
- hub: false,
1594
- console: true,
1595
- reason: "no-agent-context"
1596
- };
1597
- writeRawConsole(level, [message, ...data === void 0 ? [] : [data]]);
1598
- return entry;
1599
- }
1600
- const debugHub = DebugHub.getInstance();
1601
- if (debugHub.isConnected()) {
1602
- entry.delivery = {
1603
- hub: true,
1604
- console: false,
1605
- reason: "hub"
1606
- };
1607
- debugHub.pushNotification(agentId, createNotification(entry));
1608
- return entry;
1609
- }
1610
- entry.delivery = {
1611
- hub: false,
1612
- console: true,
1613
- reason: "hub-unavailable"
1614
- };
1615
- writeLocalFallback(entry);
1616
- return entry;
1617
- }
1618
- function writeLocalFallback(entry) {
1619
- const prefix = `[${entry.namespace}] [local-only:${entry.delivery.reason}] ${entry.message}`;
1620
- const args = entry.data === void 0 ? [prefix] : [prefix, entry.data];
1621
- writeRawConsole(entry.level, args);
1622
- }
1623
- var BoundLogger = class _BoundLogger {
1624
- constructor(namespace, bindings = {}) {
1625
- this.namespace = namespace;
1626
- this.bindings = bindings;
1627
- }
1628
- trace(message, data) {
1629
- emitLog("trace", message, data, { namespace: this.namespace, context: this.bindings });
1630
- }
1631
- debug(message, data) {
1632
- emitLog("debug", message, data, { namespace: this.namespace, context: this.bindings });
1633
- }
1634
- info(message, data) {
1635
- emitLog("info", message, data, { namespace: this.namespace, context: this.bindings });
1636
- }
1637
- warn(message, data) {
1638
- emitLog("warn", message, data, { namespace: this.namespace, context: this.bindings });
1639
- }
1640
- error(message, data) {
1641
- emitLog("error", message, data, { namespace: this.namespace, context: this.bindings });
1642
- }
1643
- child(options = {}) {
1644
- const childNamespace = options.namespace || this.namespace;
1645
- const mergedBindings = mergeScope(this.bindings, options);
1646
- delete mergedBindings.namespace;
1647
- return new _BoundLogger(childNamespace, mergedBindings);
1648
- }
1649
- };
1650
- function createLogger(namespace, bindings) {
1651
- return new BoundLogger(namespace, bindings);
1652
- }
1653
-
1654
- // src/mcp/connection-manager.ts
1655
1653
  var MCPConnectionManager = class {
1656
1654
  connections = /* @__PURE__ */ new Map();
1657
1655
  reconnectTimers = /* @__PURE__ */ new Map();
@@ -7156,14 +7154,14 @@ var AgentBase = class {
7156
7154
  async createAgentByType(type) {
7157
7155
  switch (type) {
7158
7156
  case "ExplorerAgent": {
7159
- const { ExplorerAgent } = await import("./ExplorerAgent-BITN4IBW.js");
7157
+ const { ExplorerAgent } = await import("./ExplorerAgent-4IT22VB7.js");
7160
7158
  return new ExplorerAgent({
7161
7159
  llm: this.llm
7162
7160
  });
7163
7161
  }
7164
7162
  case "BasicAgent":
7165
7163
  default: {
7166
- const { BasicAgent } = await import("./BasicAgent-UDSHJE5H.js");
7164
+ const { BasicAgent } = await import("./BasicAgent-QWEYCLV5.js");
7167
7165
  return new BasicAgent({
7168
7166
  llm: this.llm,
7169
7167
  tools: this.tools.getAll().slice(0, 3)
@@ -7613,6 +7611,9 @@ export {
7613
7611
  assistant,
7614
7612
  toolResult,
7615
7613
  Context,
7614
+ installConsoleBridge,
7615
+ runWithLogScope,
7616
+ createLogger,
7616
7617
  FileSessionStore,
7617
7618
  getDefaultSessionStore,
7618
7619
  TemplateLoader,
@@ -7620,6 +7621,11 @@ export {
7620
7621
  createListRenderer,
7621
7622
  TemplateComposer,
7622
7623
  CallStart,
7624
+ CallFinish,
7625
+ StepStart,
7626
+ StepFinish,
7627
+ ToolUse,
7628
+ ToolFinished,
7623
7629
  getPackageInfoFromSource,
7624
7630
  getDefaultMCPConfigDir,
7625
7631
  loadMCPConfigFromInput,
@@ -7656,4 +7662,4 @@ export {
7656
7662
  createLLM,
7657
7663
  AgentBase
7658
7664
  };
7659
- //# sourceMappingURL=chunk-4FBF65TC.js.map
7665
+ //# sourceMappingURL=chunk-OBOU27DM.js.map