@framers/agentos 0.15.70 → 0.15.72

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.
Files changed (103) hide show
  1. package/.github/badges/tests.json +1 -1
  2. package/dist/api/generateText.d.ts.map +1 -1
  3. package/dist/api/generateText.js +28 -64
  4. package/dist/api/generateText.js.map +1 -1
  5. package/dist/api/runtime/ExternalToolResultHandler.d.ts.map +1 -1
  6. package/dist/api/runtime/ExternalToolResultHandler.js +9 -2
  7. package/dist/api/runtime/ExternalToolResultHandler.js.map +1 -1
  8. package/dist/api/runtime/responseFormatForProvider.d.ts +2 -3
  9. package/dist/api/runtime/responseFormatForProvider.d.ts.map +1 -1
  10. package/dist/api/runtime/responseFormatForProvider.js +2 -3
  11. package/dist/api/runtime/responseFormatForProvider.js.map +1 -1
  12. package/dist/api/server/AgentOSServer.d.ts +9 -0
  13. package/dist/api/server/AgentOSServer.d.ts.map +1 -1
  14. package/dist/api/server/AgentOSServer.js +92 -6
  15. package/dist/api/server/AgentOSServer.js.map +1 -1
  16. package/dist/api/streamText.d.ts.map +1 -1
  17. package/dist/api/streamText.js +26 -56
  18. package/dist/api/streamText.js.map +1 -1
  19. package/dist/api/types/AgentOSInput.d.ts +6 -0
  20. package/dist/api/types/AgentOSInput.d.ts.map +1 -1
  21. package/dist/cognition/substrate/GMI.d.ts +12 -0
  22. package/dist/cognition/substrate/GMI.d.ts.map +1 -1
  23. package/dist/cognition/substrate/GMI.js +71 -11
  24. package/dist/cognition/substrate/GMI.js.map +1 -1
  25. package/dist/cognition/substrate/IGMI.d.ts +8 -0
  26. package/dist/cognition/substrate/IGMI.d.ts.map +1 -1
  27. package/dist/cognition/substrate/IGMI.js.map +1 -1
  28. package/dist/core/llm/providers/AIModelProviderManager.d.ts +5 -5
  29. package/dist/core/llm/providers/AIModelProviderManager.d.ts.map +1 -1
  30. package/dist/core/llm/providers/AIModelProviderManager.js +11 -14
  31. package/dist/core/llm/providers/AIModelProviderManager.js.map +1 -1
  32. package/dist/core/llm/providers/implementations/OpenAIProvider.d.ts +7 -6
  33. package/dist/core/llm/providers/implementations/OpenAIProvider.d.ts.map +1 -1
  34. package/dist/core/llm/providers/implementations/OpenAIProvider.js +39 -54
  35. package/dist/core/llm/providers/implementations/OpenAIProvider.js.map +1 -1
  36. package/dist/core/llm/providers/implementations/OpenRouterProvider.d.ts.map +1 -1
  37. package/dist/core/llm/providers/implementations/OpenRouterProvider.js +20 -30
  38. package/dist/core/llm/providers/implementations/OpenRouterProvider.js.map +1 -1
  39. package/dist/core/logging/ILogger.d.ts +12 -0
  40. package/dist/core/logging/ILogger.d.ts.map +1 -1
  41. package/dist/core/logging/ILogger.js +5 -0
  42. package/dist/core/logging/ILogger.js.map +1 -1
  43. package/dist/core/logging/Logger.d.ts +52 -0
  44. package/dist/core/logging/Logger.d.ts.map +1 -0
  45. package/dist/core/logging/Logger.js +11 -0
  46. package/dist/core/logging/Logger.js.map +1 -0
  47. package/dist/core/logging/PinoLogger.d.ts +24 -2
  48. package/dist/core/logging/PinoLogger.d.ts.map +1 -1
  49. package/dist/core/logging/PinoLogger.js +39 -3
  50. package/dist/core/logging/PinoLogger.js.map +1 -1
  51. package/dist/core/logging/contentSafeTelemetry.d.ts +1 -1
  52. package/dist/core/logging/contentSafeTelemetry.d.ts.map +1 -1
  53. package/dist/core/logging/contentSafeTelemetry.js +1 -1
  54. package/dist/core/logging/contentSafeTelemetry.js.map +1 -1
  55. package/dist/core/logging/events.d.ts +349 -0
  56. package/dist/core/logging/events.d.ts.map +1 -0
  57. package/dist/core/logging/events.js +164 -0
  58. package/dist/core/logging/events.js.map +1 -0
  59. package/dist/core/logging/forward.d.ts +93 -0
  60. package/dist/core/logging/forward.d.ts.map +1 -0
  61. package/dist/core/logging/forward.js +167 -0
  62. package/dist/core/logging/forward.js.map +1 -0
  63. package/dist/core/logging/index.d.ts +8 -3
  64. package/dist/core/logging/index.d.ts.map +1 -1
  65. package/dist/core/logging/index.js +7 -3
  66. package/dist/core/logging/index.js.map +1 -1
  67. package/dist/core/logging/kit/allowList.d.ts +68 -0
  68. package/dist/core/logging/kit/allowList.d.ts.map +1 -0
  69. package/dist/core/logging/kit/allowList.js +219 -0
  70. package/dist/core/logging/kit/allowList.js.map +1 -0
  71. package/dist/core/logging/kit/burst.d.ts +38 -0
  72. package/dist/core/logging/kit/burst.d.ts.map +1 -0
  73. package/dist/core/logging/kit/burst.js +91 -0
  74. package/dist/core/logging/kit/burst.js.map +1 -0
  75. package/dist/core/logging/kit/consoleCapture.d.ts +47 -0
  76. package/dist/core/logging/kit/consoleCapture.d.ts.map +1 -0
  77. package/dist/core/logging/kit/consoleCapture.js +121 -0
  78. package/dist/core/logging/kit/consoleCapture.js.map +1 -0
  79. package/dist/core/logging/kit/index.d.ts +12 -0
  80. package/dist/core/logging/kit/index.d.ts.map +1 -0
  81. package/dist/core/logging/kit/index.js +12 -0
  82. package/dist/core/logging/kit/index.js.map +1 -0
  83. package/dist/core/logging/kit/processHandlers.d.ts +48 -0
  84. package/dist/core/logging/kit/processHandlers.d.ts.map +1 -0
  85. package/dist/core/logging/kit/processHandlers.js +77 -0
  86. package/dist/core/logging/kit/processHandlers.js.map +1 -0
  87. package/dist/core/logging/level.d.ts +33 -0
  88. package/dist/core/logging/level.d.ts.map +1 -0
  89. package/dist/core/logging/level.js +36 -0
  90. package/dist/core/logging/level.js.map +1 -0
  91. package/dist/core/logging/loggerFactory.d.ts +74 -15
  92. package/dist/core/logging/loggerFactory.d.ts.map +1 -1
  93. package/dist/core/logging/loggerFactory.js +138 -18
  94. package/dist/core/logging/loggerFactory.js.map +1 -1
  95. package/dist/core/logging/state.d.ts +77 -0
  96. package/dist/core/logging/state.d.ts.map +1 -0
  97. package/dist/core/logging/state.js +25 -0
  98. package/dist/core/logging/state.js.map +1 -0
  99. package/dist/core/utils/terminal.d.ts +22 -0
  100. package/dist/core/utils/terminal.d.ts.map +1 -0
  101. package/dist/core/utils/terminal.js +27 -0
  102. package/dist/core/utils/terminal.js.map +1 -0
  103. package/package.json +6 -1
@@ -1 +1 @@
1
- {"version":3,"file":"loggerFactory.d.ts","sourceRoot":"","sources":["../../../src/core/logging/loggerFactory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC;AA+BtF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAA8B;AAE5F;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAGzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAGlF"}
1
+ {"version":3,"file":"loggerFactory.d.ts","sourceRoot":"","sources":["../../../src/core/logging/loggerFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAS,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAmB,KAAK,aAAa,EAAe,MAAM,YAAY,CAAC;AAE9E,OAAO,EAAqD,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC5H,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAOrD;AAkCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAA6D;AAE3H,sFAAsF;AACtF,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AA4BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAMlF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,WAAW,CAAC,aAAa,CAAC,CAEtG;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB,GAAG,WAAW,CAAC,aAAa,CAAC,CAE3G"}
@@ -1,10 +1,49 @@
1
- import { PinoLogger } from './PinoLogger.js';
1
+ /**
2
+ * @fileoverview How a host hands AgentOS its logger, the handles AgentOS writes through, and the
3
+ * guard that keeps every logger `createLogger` hands out inside content-safe telemetry.
4
+ *
5
+ * `setLogger` takes a pino-shaped logger, `setLoggerFactory` takes a factory of `ILogger`s,
6
+ * `setLogger(null)` silences AgentOS, and `resetLoggerFactory` returns to the default pino
7
+ * root, which is built on its first use. The last setter wins. `createLogger` calls the
8
+ * current factory at once and returns a guard over that factory's object: its calls reach the
9
+ * object until content-safe telemetry is enabled, and from then on each becomes one fixed
10
+ * event, even on a logger made earlier. `lazyLogger` returns a typed handle that reads the
11
+ * current target at each write, and so do its children; while content-safe telemetry is on,
12
+ * each of their lines is one fixed event as well.
13
+ *
14
+ * @module agentos/core/logging/loggerFactory
15
+ */
16
+ import { AGENTOS_CONTEXT } from './events.js';
17
+ import { getLoggingState } from './state.js';
18
+ import { checkContext, defaultRoot, forward, isValidationError } from './forward.js';
2
19
  import { emitContentSafeLog, isContentSafeTelemetryEnabled } from './contentSafeTelemetry.js';
3
- let rootLogger = new PinoLogger({ name: 'agentos' });
4
- let currentFactory = (name, bindings) => rootLogger.child({ component: name, ...(bindings || {}) });
20
+ /**
21
+ * Hands AgentOS a pino-shaped logger, or silences it with `null`. Lazy handles, whenever they
22
+ * were made, write to it from their next line; an object `createLogger` returned earlier keeps
23
+ * its target.
24
+ *
25
+ * @param logger - A logger with `debug`, `info`, `warn`, `error`, `fatal` and `child`, such as a pino logger or a pino child, or `null` to write nothing.
26
+ * @throws {TypeError} When one of those methods is missing, naming it.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import pino from 'pino';
31
+ * setLogger(pino());
32
+ * ```
33
+ */
34
+ export function setLogger(logger) {
35
+ if (logger !== null) {
36
+ for (const name of ['debug', 'info', 'warn', 'error', 'fatal', 'child']) {
37
+ if (typeof logger?.[name] !== 'function')
38
+ throw new TypeError(`Logger.${name} must be a function`);
39
+ }
40
+ }
41
+ getLoggingState().target = logger === null ? { mode: 'silent' } : { mode: 'logger', logger };
42
+ }
5
43
  /**
6
44
  * Wraps `raw` so each call is checked against content-safe telemetry when it is made. While the mode is off, a call
7
- * goes to `raw` with the caller's own arguments; while it is on, it becomes one fixed event and `raw` is not called.
45
+ * goes to `raw` with the caller's own arguments, a `fatal` call to `raw.error` when `raw` has no `fatal`; while it is
46
+ * on, it becomes one fixed event and `raw` is not called.
8
47
  */
9
48
  function guarded(raw) {
10
49
  const logger = {
@@ -24,6 +63,14 @@ function guarded(raw) {
24
63
  if (!emitContentSafeLog('debug', 'logger_factory'))
25
64
  raw?.debug?.(...args);
26
65
  },
66
+ fatal(...args) {
67
+ if (emitContentSafeLog('error', 'logger_factory'))
68
+ return;
69
+ if (raw?.fatal)
70
+ raw.fatal(...args);
71
+ else
72
+ raw?.error(...args);
73
+ },
27
74
  child(bindings) {
28
75
  if (isContentSafeTelemetryEnabled())
29
76
  return logger;
@@ -33,30 +80,103 @@ function guarded(raw) {
33
80
  return logger;
34
81
  }
35
82
  /**
36
- * Sets the factory that later `createLogger` calls delegate to.
83
+ * Hands AgentOS a factory of `ILogger`s. `createLogger` calls it at once. A lazy handle calls
84
+ * it at each write with its component and context, and writes `(event, fields)` to the logger
85
+ * it returns.
37
86
  *
38
- * @param factory - Makes the logger for a component name and optional bindings.
39
- */
40
- export function setLoggerFactory(factory) { currentFactory = factory; }
41
- /**
42
- * Restores the default factory: children of a new root `PinoLogger` named `agentos`.
87
+ * @param factory - The factory.
43
88
  */
89
+ export function setLoggerFactory(factory) { getLoggingState().target = { mode: 'factory', factory }; }
90
+ /** Returns AgentOS to its default pino root, which is built again on its next use. */
44
91
  export function resetLoggerFactory() {
45
- rootLogger = new PinoLogger({ name: 'agentos' });
46
- currentFactory = (name, bindings) => rootLogger.child({ component: name, ...(bindings || {}) });
92
+ const state = getLoggingState();
93
+ state.target = { mode: 'default' };
94
+ state.root = undefined;
95
+ }
96
+ // An ILogger over the target `target()` returns at each write. A child merges its bindings onto its parent's. With
97
+ // `strict` they are checked against AgentOS's context schema before the child is made: a child whose bindings fail
98
+ // writes one `log_refused` line and then nothing, and under NODE_ENV=test the failure is thrown instead. While
99
+ // content-safe telemetry is on, each line, a child's included, is one fixed event naming `origin`.
100
+ function adapter(target, bindings, strict, disabled = false, origin = 'library') {
101
+ const write = (level) => (event, fields = {}) => {
102
+ if (!disabled)
103
+ forward(target(), level, event, fields, bindings, strict, origin);
104
+ };
105
+ return {
106
+ debug: write('debug'), info: write('info'), warn: write('warn'), error: write('error'), fatal: write('fatal'),
107
+ child(child) {
108
+ const merged = { ...bindings, ...child };
109
+ if (strict) {
110
+ try {
111
+ checkContext(AGENTOS_CONTEXT, merged);
112
+ }
113
+ catch (error) {
114
+ if (!isValidationError(error))
115
+ throw error;
116
+ if (process.env.NODE_ENV === 'test')
117
+ throw error;
118
+ forward(target(), 'warn', 'log_refused', { reason: 'bad_context' }, {}, false, origin);
119
+ return adapter(target, {}, strict, true, origin);
120
+ }
121
+ }
122
+ return adapter(target, merged, strict, disabled, origin);
123
+ },
124
+ };
47
125
  }
48
126
  /**
49
- * A logger for one component. Its calls go to the logger the current factory makes, with the caller's arguments,
50
- * until content-safe telemetry is enabled; from then on each call becomes one fixed event for the host's sink, even
51
- * on a logger created earlier. While the mode is on, the factory is not called and `child` returns the same logger.
127
+ * Returns a component's logger: a guard over the logger the current target gives. With a factory
128
+ * set, it calls the factory at once; otherwise it takes a child of the default root, or an
129
+ * adapter over the logger or the silence set now, and that logger keeps its target after a later
130
+ * setter. The guard's calls reach that logger, with the caller's arguments, until content-safe
131
+ * telemetry is enabled; from then on each call becomes one fixed event for the host's sink, even
132
+ * on a logger made earlier, and `child` returns the same logger. While the mode is on, the
133
+ * factory is not called and nothing is made.
52
134
  *
53
- * @param name - The component name.
54
- * @param bindings - Fields every record of the logger carries.
135
+ * @param name - The component's name.
136
+ * @param bindings - Bindings for every line the logger writes.
55
137
  * @returns The component's logger.
56
138
  */
57
139
  export function createLogger(name, bindings) {
58
140
  if (isContentSafeTelemetryEnabled())
59
141
  return guarded();
60
- return guarded(currentFactory(name, bindings));
142
+ const target = getLoggingState().target;
143
+ if (target.mode === 'factory')
144
+ return guarded(target.factory(name, bindings));
145
+ if (target.mode === 'default')
146
+ return guarded(defaultRoot().child({ component: name, ...bindings }));
147
+ return guarded(adapter(() => target, { component: name, ...bindings }, false));
148
+ }
149
+ /**
150
+ * Returns a typed handle that reads the current target at each write, so a handle made at
151
+ * import follows a later `setLogger` or `setLoggerFactory`; its children do the same. Its
152
+ * methods take only an event `AGENTOS_EVENTS` declares, with that event's fields.
153
+ *
154
+ * @param component - The component the lines come from.
155
+ * @param context - More context keys to bind, such as `extension`.
156
+ * @returns The handle.
157
+ * @throws {LogValidationError} Under `NODE_ENV=test`, when the component or the context breaks AgentOS's context schema; otherwise such a handle writes one `log_refused` line and then nothing.
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * const log = lazyLogger('OpenAIProvider');
162
+ * log.warn('llm.retry', { provider: 'openai', status: 429, attempt: 1, waitMs: 2000 });
163
+ * ```
164
+ */
165
+ export function lazyLogger(component, context = {}) {
166
+ return adapter(() => getLoggingState().target, {}, true).child({ component, ...context });
167
+ }
168
+ /**
169
+ * The handle an AgentOS module writes through: a {@link lazyLogger} handle whose lines, while
170
+ * content-safe telemetry is on, each reach the sink as one fixed event naming the module, as
171
+ * the module's console lines do. An origin outside `CONTENT_SAFE_COMPONENTS` reads as
172
+ * `library`.
173
+ *
174
+ * @param component - The component the lines come from.
175
+ * @param origin - The module's fixed word in `CONTENT_SAFE_COMPONENTS`.
176
+ * @returns The handle.
177
+ * @internal
178
+ */
179
+ export function moduleLogger(component, origin) {
180
+ return adapter(() => getLoggingState().target, {}, true, false, origin).child({ component });
61
181
  }
62
182
  //# sourceMappingURL=loggerFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loggerFactory.js","sourceRoot":"","sources":["../../../src/core/logging/loggerFactory.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAM9F,IAAI,UAAU,GAAG,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AACrD,IAAI,cAAc,GAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CACrD,UAAU,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AAE7D;;;GAGG;AACH,SAAS,OAAO,CAAC,GAAa;IAC5B,MAAM,MAAM,GAAY;QACtB,IAAI,CAAC,GAAG,IAAiC;YACvC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,CAAC;gBAAE,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACxE,CAAC;QACD,IAAI,CAAC,GAAG,IAAiC;YACvC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,gBAAg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AO,OAAO,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,KAAM,CAAC,EAAE,SAAS,EAAE,CAA+B,CAAC;AAC9H,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @fileoverview The one logging state every copy of AgentOS in a process shares.
3
+ *
4
+ * The state lives on `globalThis` under `Symbol.for('agentos.logging.state.v1')`, so a
5
+ * product and a pack's nested install of AgentOS obey one hand-over. The `v1` in the key
6
+ * changes only when the state's shape does.
7
+ *
8
+ * @module agentos/core/logging/state
9
+ */
10
+ import { AsyncLocalStorage } from 'node:async_hooks';
11
+ import type { ILogger } from './ILogger.js';
12
+ import type { Logger } from './Logger.js';
13
+ import type { PinoLogger } from './PinoLogger.js';
14
+ /** A host's factory: called with a component's name and its bindings, it returns that component's logger. */
15
+ export type LoggerFactory = (name: string, bindings?: Record<string, any>) => ILogger;
16
+ /**
17
+ * Where AgentOS's lines go: the lazy default root, a logger from `setLogger`, a factory from
18
+ * `setLoggerFactory`, or nowhere after `setLogger(null)`.
19
+ */
20
+ export type Target = {
21
+ mode: 'default';
22
+ } | {
23
+ mode: 'silent';
24
+ } | {
25
+ mode: 'logger';
26
+ logger: Logger;
27
+ } | {
28
+ mode: 'factory';
29
+ factory: LoggerFactory;
30
+ };
31
+ /**
32
+ * One burst budget for the current minute, kept for an event or a refusal reason and shared by
33
+ * every kit instance in the process.
34
+ */
35
+ export interface Minute {
36
+ /** When the minute began, in milliseconds since the epoch. */
37
+ start: number;
38
+ /** Lines written in this minute. */
39
+ written: number;
40
+ /** Lines held back in this minute, reported in one line when the minute ends. */
41
+ held: number;
42
+ /** The smallest bound any kit asked for in this minute. */
43
+ limit: number;
44
+ /** The kit that opened the budget, whose writer reports the held lines. */
45
+ owner: symbol;
46
+ /** The event or the refusal reason the held-lines report names. */
47
+ name: string;
48
+ }
49
+ /** The process-wide logging state. */
50
+ export interface LoggingState {
51
+ /** Where lines go now. The last setter wins. */
52
+ target: Target;
53
+ /** The default pino root, built on its first use and dropped by `resetLoggerFactory`. */
54
+ root?: PinoLogger;
55
+ /** Whether the line about an unknown `AGENTOS_LOG_LEVEL` has been written; it is written once. */
56
+ levelWarned: boolean;
57
+ /** The current request's id, which the forwarding layer adds to each line's context. */
58
+ requests: AsyncLocalStorage<{
59
+ requestId: string;
60
+ }>;
61
+ /** The burst budgets of the current minute, by key. */
62
+ minutes: Map<string, Minute>;
63
+ /** Each open kit's writer for its held-lines reports. */
64
+ owners: Map<symbol, (name: string, n: number) => void>;
65
+ /** The unreferenced timer that reports held lines when a minute ends. */
66
+ timer?: ReturnType<typeof setTimeout>;
67
+ /** Removes the installed process handlers, when a kit has installed them. */
68
+ removeProcessHandlers?: () => void;
69
+ }
70
+ /**
71
+ * The process's logging state, created on the first call. Every copy of AgentOS in the
72
+ * process reads the same object.
73
+ *
74
+ * @returns The shared state.
75
+ */
76
+ export declare function getLoggingState(): LoggingState;
77
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/core/logging/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,6GAA6G;AAC7G,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC;AAEtF;;;GAGG;AACH,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IA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
3
+ *
4
+ * The state lives on `globalThis` under `Symbol.for('agentos.logging.state.v1')`, so a
5
+ * product and a pack's nested install of AgentOS obey one hand-over. The `v1` in the key
6
+ * changes only when the state's shape does.
7
+ *
8
+ * @module agentos/core/logging/state
9
+ */
10
+ import { AsyncLocalStorage } from 'node:async_hooks';
11
+ const KEY = Symbol.for('agentos.logging.state.v1');
12
+ /**
13
+ * The process's logging state, created on the first call. Every copy of AgentOS in the
14
+ * process reads the same object.
15
+ *
16
+ * @returns The shared state.
17
+ */
18
+ export function getLoggingState() {
19
+ const holder = globalThis;
20
+ return holder[KEY] ?? (holder[KEY] = {
21
+ target: { mode: 'default' }, levelWarned: false,
22
+ requests: new AsyncLocalStorage(), minutes: new Map(), owners: new Map(),
23
+ });
24
+ }
25
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/core/logging/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAoDrD,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,MAAM,GAAG,UAAiE,CAAC;IACjF,OAAO,MAAM,CAAC,GAAG,MAAV,MAAM,CAAC,GAAG,IAAM;QACrB,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,WAAW,EAAE,KAAK;QAC/C,QAAQ,EAAE,IAAI,iBAAiB,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,GAAG,EAAE;KACzE,EAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @fileoverview The one module allowed to write the standard streams directly.
3
+ *
4
+ * AgentOS's lines go through the logging hand-over; text meant for a person at a terminal, such
5
+ * as an interactive prompt or the frames-only stack the allow-list kit's console capture
6
+ * prints, goes through {@link terminal}.
7
+ *
8
+ * @module agentos/core/utils/terminal
9
+ */
10
+ /**
11
+ * Writes text to standard output or standard error. A failing stream never reaches the caller.
12
+ *
13
+ * @param text - The text to write, as it should appear, with its own line ending.
14
+ * @param stream - The stream to write to, `stdout` unless given.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * terminal('Continue? [y/N] ');
19
+ * ```
20
+ */
21
+ export declare function terminal(text: string, stream?: 'stdout' | 'stderr'): void;
22
+ //# sourceMappingURL=terminal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../../src/core/utils/terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,QAAQ,GAAG,QAAmB,GAAG,IAAI,CAEnF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fileoverview The one module allowed to write the standard streams directly.
3
+ *
4
+ * AgentOS's lines go through the logging hand-over; text meant for a person at a terminal, such
5
+ * as an interactive prompt or the frames-only stack the allow-list kit's console capture
6
+ * prints, goes through {@link terminal}.
7
+ *
8
+ * @module agentos/core/utils/terminal
9
+ */
10
+ /**
11
+ * Writes text to standard output or standard error. A failing stream never reaches the caller.
12
+ *
13
+ * @param text - The text to write, as it should appear, with its own line ending.
14
+ * @param stream - The stream to write to, `stdout` unless given.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * terminal('Continue? [y/N] ');
19
+ * ```
20
+ */
21
+ export function terminal(text, stream = 'stdout') {
22
+ try {
23
+ process[stream].write(text);
24
+ }
25
+ catch { /* Terminal output cannot fail the caller's operation. */ }
26
+ }
27
+ //# sourceMappingURL=terminal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../../src/core/utils/terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,SAA8B,QAAQ;IAC3E,IAAI,CAAC;QAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,yDAAyD,CAAC,CAAC;AAC1G,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@framers/agentos",
3
- "version": "0.15.70",
3
+ "version": "0.15.72",
4
4
  "description": "AgentOS: open-source TypeScript framework for autonomous AI agents. Unified graph orchestration, cognitive memory, runtime tool forging, multi-tier guardrails, voice pipeline, and 11 LLM providers.",
5
5
  "homepage": "https://agentos.sh",
6
6
  "repository": {
@@ -130,6 +130,11 @@
130
130
  "import": "./dist/core/logging/index.js",
131
131
  "default": "./dist/core/logging/index.js"
132
132
  },
133
+ "./logging/kit": {
134
+ "types": "./dist/core/logging/kit/index.d.ts",
135
+ "import": "./dist/core/logging/kit/index.js",
136
+ "default": "./dist/core/logging/kit/index.js"
137
+ },
133
138
  "./orchestration": {
134
139
  "import": "./dist/orchestration/index.js",
135
140
  "default": "./dist/orchestration/index.js",