@memberjunction/server 5.40.2 → 5.42.0
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/agentSessions/HostInstance.d.ts +19 -0
- package/dist/agentSessions/HostInstance.d.ts.map +1 -0
- package/dist/agentSessions/HostInstance.js +48 -0
- package/dist/agentSessions/HostInstance.js.map +1 -0
- package/dist/agentSessions/SessionJanitor.d.ts +97 -0
- package/dist/agentSessions/SessionJanitor.d.ts.map +1 -0
- package/dist/agentSessions/SessionJanitor.js +222 -0
- package/dist/agentSessions/SessionJanitor.js.map +1 -0
- package/dist/agentSessions/SessionManager.d.ts +142 -0
- package/dist/agentSessions/SessionManager.d.ts.map +1 -0
- package/dist/agentSessions/SessionManager.js +308 -0
- package/dist/agentSessions/SessionManager.js.map +1 -0
- package/dist/agentSessions/index.d.ts +5 -0
- package/dist/agentSessions/index.d.ts.map +1 -0
- package/dist/agentSessions/index.js +31 -0
- package/dist/agentSessions/index.js.map +1 -0
- package/dist/agentSessions/remoteBrowserGoalEngine.d.ts +102 -0
- package/dist/agentSessions/remoteBrowserGoalEngine.d.ts.map +1 -0
- package/dist/agentSessions/remoteBrowserGoalEngine.js +164 -0
- package/dist/agentSessions/remoteBrowserGoalEngine.js.map +1 -0
- package/dist/agentSessions/remoteBrowserGoalRegistry.d.ts +66 -0
- package/dist/agentSessions/remoteBrowserGoalRegistry.d.ts.map +1 -0
- package/dist/agentSessions/remoteBrowserGoalRegistry.js +86 -0
- package/dist/agentSessions/remoteBrowserGoalRegistry.js.map +1 -0
- package/dist/auth/initializeProviders.d.ts.map +1 -1
- package/dist/auth/initializeProviders.js +4 -2
- package/dist/auth/initializeProviders.js.map +1 -1
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -2
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +41 -7
- package/dist/context.js.map +1 -1
- package/dist/generated/generated.d.ts +1296 -49
- package/dist/generated/generated.d.ts.map +1 -1
- package/dist/generated/generated.js +50343 -43421
- package/dist/generated/generated.js.map +1 -1
- package/dist/generic/ResolverBase.js +1 -1
- package/dist/generic/ResolverBase.js.map +1 -1
- package/dist/generic/RunViewResolver.js +9 -10
- package/dist/generic/RunViewResolver.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +127 -54
- package/dist/index.js.map +1 -1
- package/dist/integration/CustomColumnPromoter.d.ts +108 -0
- package/dist/integration/CustomColumnPromoter.d.ts.map +1 -0
- package/dist/integration/CustomColumnPromoter.js +508 -0
- package/dist/integration/CustomColumnPromoter.js.map +1 -0
- package/dist/logging/StartupLogger.d.ts +177 -0
- package/dist/logging/StartupLogger.d.ts.map +1 -0
- package/dist/logging/StartupLogger.js +354 -0
- package/dist/logging/StartupLogger.js.map +1 -0
- package/dist/logging/variablesLoggingMiddleware.d.ts.map +1 -1
- package/dist/logging/variablesLoggingMiddleware.js +21 -2
- package/dist/logging/variablesLoggingMiddleware.js.map +1 -1
- package/dist/resolvers/AgentSessionResolver.d.ts +42 -0
- package/dist/resolvers/AgentSessionResolver.d.ts.map +1 -0
- package/dist/resolvers/AgentSessionResolver.js +152 -0
- package/dist/resolvers/AgentSessionResolver.js.map +1 -0
- package/dist/resolvers/EntityPermissionResolver.d.ts +16 -0
- package/dist/resolvers/EntityPermissionResolver.d.ts.map +1 -0
- package/dist/resolvers/EntityPermissionResolver.js +95 -0
- package/dist/resolvers/EntityPermissionResolver.js.map +1 -0
- package/dist/resolvers/ExecuteRemoteOperationResolver.d.ts +27 -0
- package/dist/resolvers/ExecuteRemoteOperationResolver.d.ts.map +1 -0
- package/dist/resolvers/ExecuteRemoteOperationResolver.js +136 -0
- package/dist/resolvers/ExecuteRemoteOperationResolver.js.map +1 -0
- package/dist/resolvers/IntegrationDiscoveryResolver.d.ts +101 -1
- package/dist/resolvers/IntegrationDiscoveryResolver.d.ts.map +1 -1
- package/dist/resolvers/IntegrationDiscoveryResolver.js +544 -42
- package/dist/resolvers/IntegrationDiscoveryResolver.js.map +1 -1
- package/dist/resolvers/RealtimeBridgeResolver.d.ts +121 -0
- package/dist/resolvers/RealtimeBridgeResolver.d.ts.map +1 -0
- package/dist/resolvers/RealtimeBridgeResolver.js +533 -0
- package/dist/resolvers/RealtimeBridgeResolver.js.map +1 -0
- package/dist/resolvers/RealtimeClientSessionResolver.d.ts +688 -0
- package/dist/resolvers/RealtimeClientSessionResolver.d.ts.map +1 -0
- package/dist/resolvers/RealtimeClientSessionResolver.js +1774 -0
- package/dist/resolvers/RealtimeClientSessionResolver.js.map +1 -0
- package/dist/resolvers/RemoteBrowserActionResolver.d.ts +432 -0
- package/dist/resolvers/RemoteBrowserActionResolver.d.ts.map +1 -0
- package/dist/resolvers/RemoteBrowserActionResolver.js +1108 -0
- package/dist/resolvers/RemoteBrowserActionResolver.js.map +1 -0
- package/dist/resolvers/RunAIAgentResolver.d.ts.map +1 -1
- package/dist/resolvers/RunAIAgentResolver.js +0 -7
- package/dist/resolvers/RunAIAgentResolver.js.map +1 -1
- package/dist/rest/setupRESTEndpoints.d.ts.map +1 -1
- package/dist/rest/setupRESTEndpoints.js +5 -3
- package/dist/rest/setupRESTEndpoints.js.map +1 -1
- package/dist/services/ScheduledJobsService.d.ts.map +1 -1
- package/dist/services/ScheduledJobsService.js +6 -5
- package/dist/services/ScheduledJobsService.js.map +1 -1
- package/package.json +83 -74
- package/src/__tests__/RealtimeBridgeResolver.test.ts +100 -0
- package/src/__tests__/RealtimeClientSessionResolver.test.ts +2605 -0
- package/src/__tests__/RemoteBrowserAudioStream.test.ts +181 -0
- package/src/__tests__/RemoteBrowserGoalEngine.test.ts +144 -0
- package/src/__tests__/SessionJanitor.test.ts +234 -0
- package/src/__tests__/SessionManager.test.ts +465 -0
- package/src/__tests__/remoteBrowserGoalRegistry.test.ts +81 -0
- package/src/__tests__/subscriptionRedaction.test.ts +5 -0
- package/src/agentSessions/HostInstance.ts +53 -0
- package/src/agentSessions/SessionJanitor.ts +267 -0
- package/src/agentSessions/SessionManager.ts +446 -0
- package/src/agentSessions/index.ts +32 -0
- package/src/agentSessions/remoteBrowserGoalEngine.ts +191 -0
- package/src/agentSessions/remoteBrowserGoalRegistry.ts +122 -0
- package/src/auth/initializeProviders.ts +4 -2
- package/src/config.ts +13 -2
- package/src/context.ts +42 -7
- package/src/generated/generated.ts +33808 -29025
- package/src/generic/ResolverBase.ts +1 -1
- package/src/generic/RunViewResolver.ts +9 -9
- package/src/index.ts +128 -54
- package/src/integration/CustomColumnPromoter.ts +597 -0
- package/src/logging/StartupLogger.ts +441 -0
- package/src/logging/variablesLoggingMiddleware.ts +25 -5
- package/src/resolvers/AgentSessionResolver.ts +138 -0
- package/src/resolvers/EntityPermissionResolver.ts +73 -0
- package/src/resolvers/ExecuteRemoteOperationResolver.ts +108 -0
- package/src/resolvers/IntegrationDiscoveryResolver.ts +396 -37
- package/src/resolvers/RealtimeBridgeResolver.ts +450 -0
- package/src/resolvers/RealtimeClientSessionResolver.ts +2162 -0
- package/src/resolvers/RemoteBrowserActionResolver.ts +1122 -0
- package/src/resolvers/RunAIAgentResolver.ts +1 -9
- package/src/rest/setupRESTEndpoints.ts +5 -3
- package/src/services/ScheduledJobsService.ts +6 -5
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server log verbosity levels, ordered from least to most chatty.
|
|
3
|
+
*
|
|
4
|
+
* Reuses the SAME enum shape as `telemetry.level` in `config.ts` so operators
|
|
5
|
+
* have a single knob (`telemetry.level` in mj.config.cjs) that governs both
|
|
6
|
+
* telemetry verbosity and server-log verbosity — there is no parallel setting.
|
|
7
|
+
*
|
|
8
|
+
* Ordering (ascending): `minimal` < `standard` < `verbose` < `debug`.
|
|
9
|
+
*/
|
|
10
|
+
export type ServerLogLevel = 'minimal' | 'standard' | 'verbose' | 'debug';
|
|
11
|
+
/**
|
|
12
|
+
* MJServer-local startup + per-request log gating helper.
|
|
13
|
+
*
|
|
14
|
+
* Holds the resolved {@link ServerLogLevel} (from `telemetry.level`) and exposes
|
|
15
|
+
* a small surface for level-gated logging, startup phase-timing capture, and the
|
|
16
|
+
* compact summary block printed once at the end of boot.
|
|
17
|
+
*
|
|
18
|
+
* This is deliberately NOT a `BaseSingleton` and does NOT touch
|
|
19
|
+
* `@memberjunction/core` logging internals — it is a thin, process-local gate
|
|
20
|
+
* that wraps `console.*` / `LogStatus`. The point is the *gating*, not a new
|
|
21
|
+
* logging framework.
|
|
22
|
+
*
|
|
23
|
+
* Usage:
|
|
24
|
+
* ```ts
|
|
25
|
+
* const logger = new StartupLogger();
|
|
26
|
+
* logger.LogIf('verbose', 'Registered auth provider: azure');
|
|
27
|
+
* const t = logger.StartPhase();
|
|
28
|
+
* // ... work ...
|
|
29
|
+
* logger.EndPhase('DB Pool Connect', t);
|
|
30
|
+
* logger.PrintSummary();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class StartupLogger {
|
|
34
|
+
private readonly resolvedLevel;
|
|
35
|
+
private readonly phaseTimings;
|
|
36
|
+
private readonly summary;
|
|
37
|
+
/** Transient boot spinner — active only at `standard` level on a TTY (see {@link spinnerEnabled}). */
|
|
38
|
+
private spinner;
|
|
39
|
+
/** Interval that ticks the live elapsed counter on the spinner line. */
|
|
40
|
+
private bootTimer;
|
|
41
|
+
/** Wall-clock start of the boot indicator, for the live elapsed counter. */
|
|
42
|
+
private bootStartMs;
|
|
43
|
+
/** Most recent phase label, shown on the spinner line. */
|
|
44
|
+
private currentPhase?;
|
|
45
|
+
/**
|
|
46
|
+
* @param level Optional explicit level override (primarily for tests).
|
|
47
|
+
* When omitted, the level is resolved from config.
|
|
48
|
+
*/
|
|
49
|
+
constructor(level?: ServerLogLevel);
|
|
50
|
+
/**
|
|
51
|
+
* The resolved log level in effect for this logger instance.
|
|
52
|
+
*/
|
|
53
|
+
get Level(): ServerLogLevel;
|
|
54
|
+
/**
|
|
55
|
+
* Resolves the active server log level from configuration.
|
|
56
|
+
*
|
|
57
|
+
* Source of truth is `telemetry.level` (the pre-existing enum), so a single
|
|
58
|
+
* operator knob governs both telemetry and server logging. Defaults to
|
|
59
|
+
* `standard` when unset or unrecognized.
|
|
60
|
+
*/
|
|
61
|
+
static resolveLevelFromConfig(): ServerLogLevel;
|
|
62
|
+
/**
|
|
63
|
+
* True when the active level is at least `minLevel` (using the ascending
|
|
64
|
+
* `minimal < standard < verbose < debug` ordering).
|
|
65
|
+
*/
|
|
66
|
+
IsAtLeast(minLevel: ServerLogLevel): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Logs `message` only when the active level is at least `minLevel`.
|
|
69
|
+
* Routes through MJ's `LogStatus` so the line participates in MJ's
|
|
70
|
+
* standard status-logging pipeline.
|
|
71
|
+
*/
|
|
72
|
+
LogIf(minLevel: ServerLogLevel, message: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Starts a phase timer. Returns an opaque start timestamp to pass to
|
|
75
|
+
* {@link EndPhase}.
|
|
76
|
+
*/
|
|
77
|
+
StartPhase(): number;
|
|
78
|
+
/**
|
|
79
|
+
* True when the transient boot spinner should animate: only at `standard`
|
|
80
|
+
* level AND when stdout is an interactive TTY. In non-TTY contexts (Docker,
|
|
81
|
+
* systemd, piped logs) a spinner emits escape codes that pollute log
|
|
82
|
+
* aggregation, and at `verbose`+ the inline phase lines would fight it — so
|
|
83
|
+
* both fall back to plain, line-oriented output.
|
|
84
|
+
*/
|
|
85
|
+
private get spinnerEnabled();
|
|
86
|
+
/** Prefix for the transient boot indicator (no rocket — we haven't launched yet). */
|
|
87
|
+
private static readonly BOOT_LABEL;
|
|
88
|
+
/** Composes the boot label, plus the current phase when known (no elapsed counter). */
|
|
89
|
+
private bootText;
|
|
90
|
+
/** Repaints the spinner line with the current phase and a live elapsed counter. */
|
|
91
|
+
private refreshBootText;
|
|
92
|
+
/**
|
|
93
|
+
* Begins the transient "Bootstrapping…" indicator, replaced by the 🚀 summary
|
|
94
|
+
* block once {@link PrintSummary} runs (so the rocket appears only after launch).
|
|
95
|
+
*
|
|
96
|
+
* - `standard` + TTY: an animated, self-clearing `ora` spinner (its glyph is the
|
|
97
|
+
* leading "working" icon; phase status is appended inline).
|
|
98
|
+
* - `verbose`/`debug`, or non-TTY at `standard`: a single plain line with an
|
|
99
|
+
* hourglass icon (can't be cleared, but inline phase logs / the final block
|
|
100
|
+
* carry the detail). `minimal` stays silent.
|
|
101
|
+
*/
|
|
102
|
+
StartBoot(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Marks the beginning of a named phase: updates the spinner status (when active)
|
|
105
|
+
* and returns a start timestamp to pass to {@link EndPhase}. Pure timing helper
|
|
106
|
+
* when the spinner is disabled — equivalent to {@link StartPhase}.
|
|
107
|
+
*
|
|
108
|
+
* @param phase Friendly label for the upcoming phase, shown after the boot label.
|
|
109
|
+
*/
|
|
110
|
+
BeginPhase(phase: string): number;
|
|
111
|
+
/** Stops and clears the boot spinner + its elapsed-counter interval. Safe to call when inactive. */
|
|
112
|
+
StopBoot(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Records the elapsed time for a phase since `startedAt`, buffering it for the
|
|
115
|
+
* summary. At `verbose`+ the phase is also printed immediately (matching the
|
|
116
|
+
* legacy `⏱️ [Startup] X: Yms` lines); at `standard` it is collapsed into the
|
|
117
|
+
* one-line `Startup` summary printed by {@link PrintSummary}.
|
|
118
|
+
*
|
|
119
|
+
* @returns A fresh timestamp, so callers can chain phases ergonomically.
|
|
120
|
+
*/
|
|
121
|
+
EndPhase(label: string, startedAt: number): number;
|
|
122
|
+
/** Records the server package version for the summary header. */
|
|
123
|
+
SetVersion(version: string | undefined): void;
|
|
124
|
+
/** Records the resolved config-file path for the summary `Config` line. */
|
|
125
|
+
SetConfigPath(path: string | undefined): void;
|
|
126
|
+
/** Records DB platform + connection + entity count for the summary `DB` line. */
|
|
127
|
+
SetDatabaseInfo(platform: string, connection: string, entityCount: number): void;
|
|
128
|
+
/** Adds a registered auth-provider name to the summary `Auth` line. */
|
|
129
|
+
AddAuthProvider(name: string): void;
|
|
130
|
+
/** Records whether the REST API is enabled for the summary `Auth` line. */
|
|
131
|
+
SetRestEnabled(enabled: boolean): void;
|
|
132
|
+
/** Records the active scheduled-job count for the summary `Auth` line. */
|
|
133
|
+
SetScheduledJobCount(count: number): void;
|
|
134
|
+
/** Records the ready URL for the summary `Ready` line. */
|
|
135
|
+
SetReadyUrl(url: string): void;
|
|
136
|
+
/**
|
|
137
|
+
* Prints the boot summary appropriate for the active level:
|
|
138
|
+
* - `minimal`: only the `Ready <url>` line.
|
|
139
|
+
* - `standard`: the compact ~8-line summary block (with phases collapsed).
|
|
140
|
+
* - `verbose`/`debug`: the same compact block (individual phase lines and
|
|
141
|
+
* all detail lines were already printed inline during boot).
|
|
142
|
+
*/
|
|
143
|
+
PrintSummary(): void;
|
|
144
|
+
/** Prints just the ready URL (minimal level). */
|
|
145
|
+
private printReadyLineOnly;
|
|
146
|
+
/** Renders and prints the multi-line compact summary block. */
|
|
147
|
+
private printSummaryBlock;
|
|
148
|
+
/** Builds the array of summary lines (header + indented detail rows). */
|
|
149
|
+
private buildSummaryLines;
|
|
150
|
+
/** `🚀 MemberJunction Server · v<version>` (version omitted if unknown). */
|
|
151
|
+
private buildHeaderLine;
|
|
152
|
+
/** ` DB <platform> · <connection> · <N> entities`. */
|
|
153
|
+
private buildDbLine;
|
|
154
|
+
/** ` Config <path>` (omitted when no config file was resolved). */
|
|
155
|
+
private buildConfigLine;
|
|
156
|
+
/** ` Auth <providers> REST <on/off> · <N> scheduled jobs`. */
|
|
157
|
+
private buildAuthLine;
|
|
158
|
+
/**
|
|
159
|
+
* ` Startup <total>s (<phase> <x>s · … · other <z>s)`.
|
|
160
|
+
*
|
|
161
|
+
* The headline `<total>` is the TRUE wall-clock since process start — in Node,
|
|
162
|
+
* `performance.now()` is measured from `performance.timeOrigin` (≈ process
|
|
163
|
+
* start), so it captures the entire bootstrap (module import, config load,
|
|
164
|
+
* ServerBootstrap, and `serve()`), not just the timed phases. The parenthetical
|
|
165
|
+
* lists each captured phase; `other` is the unattributed remainder (import +
|
|
166
|
+
* config + any untimed setup) shown only when it's non-trivial.
|
|
167
|
+
*/
|
|
168
|
+
private buildStartupLine;
|
|
169
|
+
/**
|
|
170
|
+
* Abbreviates a verbose phase label into a compact token for the collapsed
|
|
171
|
+
* summary line (e.g. "Metadata + Provider Setup" → "metadata").
|
|
172
|
+
*/
|
|
173
|
+
private shortPhaseLabel;
|
|
174
|
+
/** ` Ready <url>`. */
|
|
175
|
+
private buildReadyLine;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=StartupLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StartupLogger.d.ts","sourceRoot":"","sources":["../../src/logging/StartupLogger.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;AAgD1E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiB;IAC/C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqB;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6C;IACrE,sGAAsG;IACtG,OAAO,CAAC,OAAO,CAAoB;IACnC,wEAAwE;IACxE,OAAO,CAAC,SAAS,CAA+C;IAChE,4EAA4E;IAC5E,OAAO,CAAC,WAAW,CAAK;IACxB,0DAA0D;IAC1D,OAAO,CAAC,YAAY,CAAC,CAAS;IAE9B;;;OAGG;gBACS,KAAK,CAAC,EAAE,cAAc;IAIlC;;OAEG;IACH,IAAW,KAAK,IAAI,cAAc,CAEjC;IAED;;;;;;OAMG;WACW,sBAAsB,IAAI,cAAc;IAQtD;;;OAGG;IACI,SAAS,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO;IAInD;;;;OAIG;IACI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,CAAC,iBAAiB;IAWzB,8EAA8E;IAC9E,OAAO,CAAC,eAAe;IAKvB,+DAA+D;IAC/D,OAAO,CAAC,WAAW;IAcnB,wEAAwE;IACxE,OAAO,CAAC,eAAe;IAOvB,8EAA8E;IAC9E,OAAO,CAAC,aAAa;IAerB;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAuBvB,4BAA4B;IAC5B,OAAO,CAAC,cAAc;CAMvB"}
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { configInfo } from '../config.js';
|
|
2
|
+
import { LogStatus } from '@memberjunction/core';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
/** Numeric rank for each level, used for `>=` threshold comparisons. */
|
|
5
|
+
const LEVEL_RANK = {
|
|
6
|
+
minimal: 0,
|
|
7
|
+
standard: 1,
|
|
8
|
+
verbose: 2,
|
|
9
|
+
debug: 3,
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* MJServer-local startup + per-request log gating helper.
|
|
13
|
+
*
|
|
14
|
+
* Holds the resolved {@link ServerLogLevel} (from `telemetry.level`) and exposes
|
|
15
|
+
* a small surface for level-gated logging, startup phase-timing capture, and the
|
|
16
|
+
* compact summary block printed once at the end of boot.
|
|
17
|
+
*
|
|
18
|
+
* This is deliberately NOT a `BaseSingleton` and does NOT touch
|
|
19
|
+
* `@memberjunction/core` logging internals — it is a thin, process-local gate
|
|
20
|
+
* that wraps `console.*` / `LogStatus`. The point is the *gating*, not a new
|
|
21
|
+
* logging framework.
|
|
22
|
+
*
|
|
23
|
+
* Usage:
|
|
24
|
+
* ```ts
|
|
25
|
+
* const logger = new StartupLogger();
|
|
26
|
+
* logger.LogIf('verbose', 'Registered auth provider: azure');
|
|
27
|
+
* const t = logger.StartPhase();
|
|
28
|
+
* // ... work ...
|
|
29
|
+
* logger.EndPhase('DB Pool Connect', t);
|
|
30
|
+
* logger.PrintSummary();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export class StartupLogger {
|
|
34
|
+
/**
|
|
35
|
+
* @param level Optional explicit level override (primarily for tests).
|
|
36
|
+
* When omitted, the level is resolved from config.
|
|
37
|
+
*/
|
|
38
|
+
constructor(level) {
|
|
39
|
+
this.phaseTimings = [];
|
|
40
|
+
this.summary = { AuthProviders: [] };
|
|
41
|
+
/** Transient boot spinner — active only at `standard` level on a TTY (see {@link spinnerEnabled}). */
|
|
42
|
+
this.spinner = null;
|
|
43
|
+
/** Interval that ticks the live elapsed counter on the spinner line. */
|
|
44
|
+
this.bootTimer = null;
|
|
45
|
+
/** Wall-clock start of the boot indicator, for the live elapsed counter. */
|
|
46
|
+
this.bootStartMs = 0;
|
|
47
|
+
this.resolvedLevel = level ?? StartupLogger.resolveLevelFromConfig();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The resolved log level in effect for this logger instance.
|
|
51
|
+
*/
|
|
52
|
+
get Level() {
|
|
53
|
+
return this.resolvedLevel;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolves the active server log level from configuration.
|
|
57
|
+
*
|
|
58
|
+
* Source of truth is `telemetry.level` (the pre-existing enum), so a single
|
|
59
|
+
* operator knob governs both telemetry and server logging. Defaults to
|
|
60
|
+
* `standard` when unset or unrecognized.
|
|
61
|
+
*/
|
|
62
|
+
static resolveLevelFromConfig() {
|
|
63
|
+
const raw = configInfo.telemetry?.level;
|
|
64
|
+
if (raw === 'minimal' || raw === 'standard' || raw === 'verbose' || raw === 'debug') {
|
|
65
|
+
return raw;
|
|
66
|
+
}
|
|
67
|
+
return 'standard';
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* True when the active level is at least `minLevel` (using the ascending
|
|
71
|
+
* `minimal < standard < verbose < debug` ordering).
|
|
72
|
+
*/
|
|
73
|
+
IsAtLeast(minLevel) {
|
|
74
|
+
return LEVEL_RANK[this.resolvedLevel] >= LEVEL_RANK[minLevel];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Logs `message` only when the active level is at least `minLevel`.
|
|
78
|
+
* Routes through MJ's `LogStatus` so the line participates in MJ's
|
|
79
|
+
* standard status-logging pipeline.
|
|
80
|
+
*/
|
|
81
|
+
LogIf(minLevel, message) {
|
|
82
|
+
if (this.IsAtLeast(minLevel)) {
|
|
83
|
+
LogStatus(message);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Starts a phase timer. Returns an opaque start timestamp to pass to
|
|
88
|
+
* {@link EndPhase}.
|
|
89
|
+
*/
|
|
90
|
+
StartPhase() {
|
|
91
|
+
return performance.now();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* True when the transient boot spinner should animate: only at `standard`
|
|
95
|
+
* level AND when stdout is an interactive TTY. In non-TTY contexts (Docker,
|
|
96
|
+
* systemd, piped logs) a spinner emits escape codes that pollute log
|
|
97
|
+
* aggregation, and at `verbose`+ the inline phase lines would fight it — so
|
|
98
|
+
* both fall back to plain, line-oriented output.
|
|
99
|
+
*/
|
|
100
|
+
get spinnerEnabled() {
|
|
101
|
+
return this.resolvedLevel === 'standard' && process.stdout.isTTY === true;
|
|
102
|
+
}
|
|
103
|
+
/** Prefix for the transient boot indicator (no rocket — we haven't launched yet). */
|
|
104
|
+
static { this.BOOT_LABEL = 'Bootstrapping MemberJunction Server'; }
|
|
105
|
+
/** Composes the boot label, plus the current phase when known (no elapsed counter). */
|
|
106
|
+
bootText(phase) {
|
|
107
|
+
return phase ? `${StartupLogger.BOOT_LABEL} · ${phase}` : StartupLogger.BOOT_LABEL;
|
|
108
|
+
}
|
|
109
|
+
/** Repaints the spinner line with the current phase and a live elapsed counter. */
|
|
110
|
+
refreshBootText() {
|
|
111
|
+
if (this.spinner) {
|
|
112
|
+
const elapsed = ((performance.now() - this.bootStartMs) / 1000).toFixed(1);
|
|
113
|
+
this.spinner.text = `${this.bootText(this.currentPhase)} ${elapsed}s`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Begins the transient "Bootstrapping…" indicator, replaced by the 🚀 summary
|
|
118
|
+
* block once {@link PrintSummary} runs (so the rocket appears only after launch).
|
|
119
|
+
*
|
|
120
|
+
* - `standard` + TTY: an animated, self-clearing `ora` spinner (its glyph is the
|
|
121
|
+
* leading "working" icon; phase status is appended inline).
|
|
122
|
+
* - `verbose`/`debug`, or non-TTY at `standard`: a single plain line with an
|
|
123
|
+
* hourglass icon (can't be cleared, but inline phase logs / the final block
|
|
124
|
+
* carry the detail). `minimal` stays silent.
|
|
125
|
+
*/
|
|
126
|
+
StartBoot() {
|
|
127
|
+
if (this.spinner) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (this.spinnerEnabled) {
|
|
131
|
+
this.bootStartMs = performance.now();
|
|
132
|
+
this.spinner = ora({ text: this.bootText(), stream: process.stdout }).start();
|
|
133
|
+
// Tick the elapsed counter independently of ora's glyph animation. Unref'd so
|
|
134
|
+
// it never keeps the event loop alive; cleared by StopBoot before the block prints.
|
|
135
|
+
this.bootTimer = setInterval(() => this.refreshBootText(), 200);
|
|
136
|
+
this.bootTimer.unref();
|
|
137
|
+
}
|
|
138
|
+
else if (this.resolvedLevel !== 'minimal') {
|
|
139
|
+
// eslint-disable-next-line no-console
|
|
140
|
+
console.log(`⏳ ${this.bootText()}…`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Marks the beginning of a named phase: updates the spinner status (when active)
|
|
145
|
+
* and returns a start timestamp to pass to {@link EndPhase}. Pure timing helper
|
|
146
|
+
* when the spinner is disabled — equivalent to {@link StartPhase}.
|
|
147
|
+
*
|
|
148
|
+
* @param phase Friendly label for the upcoming phase, shown after the boot label.
|
|
149
|
+
*/
|
|
150
|
+
BeginPhase(phase) {
|
|
151
|
+
this.currentPhase = phase;
|
|
152
|
+
this.refreshBootText();
|
|
153
|
+
return performance.now();
|
|
154
|
+
}
|
|
155
|
+
/** Stops and clears the boot spinner + its elapsed-counter interval. Safe to call when inactive. */
|
|
156
|
+
StopBoot() {
|
|
157
|
+
if (this.bootTimer) {
|
|
158
|
+
clearInterval(this.bootTimer);
|
|
159
|
+
this.bootTimer = null;
|
|
160
|
+
}
|
|
161
|
+
if (this.spinner) {
|
|
162
|
+
this.spinner.stop();
|
|
163
|
+
this.spinner = null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Records the elapsed time for a phase since `startedAt`, buffering it for the
|
|
168
|
+
* summary. At `verbose`+ the phase is also printed immediately (matching the
|
|
169
|
+
* legacy `⏱️ [Startup] X: Yms` lines); at `standard` it is collapsed into the
|
|
170
|
+
* one-line `Startup` summary printed by {@link PrintSummary}.
|
|
171
|
+
*
|
|
172
|
+
* @returns A fresh timestamp, so callers can chain phases ergonomically.
|
|
173
|
+
*/
|
|
174
|
+
EndPhase(label, startedAt) {
|
|
175
|
+
const ms = performance.now() - startedAt;
|
|
176
|
+
this.phaseTimings.push({ Label: label, Ms: ms });
|
|
177
|
+
if (this.IsAtLeast('verbose')) {
|
|
178
|
+
// eslint-disable-next-line no-console
|
|
179
|
+
console.log(`⏱️ [Startup] ${label}: ${ms.toFixed(0)}ms`);
|
|
180
|
+
}
|
|
181
|
+
return performance.now();
|
|
182
|
+
}
|
|
183
|
+
/** Records the server package version for the summary header. */
|
|
184
|
+
SetVersion(version) {
|
|
185
|
+
this.summary.Version = version;
|
|
186
|
+
}
|
|
187
|
+
/** Records the resolved config-file path for the summary `Config` line. */
|
|
188
|
+
SetConfigPath(path) {
|
|
189
|
+
this.summary.ConfigPath = path;
|
|
190
|
+
}
|
|
191
|
+
/** Records DB platform + connection + entity count for the summary `DB` line. */
|
|
192
|
+
SetDatabaseInfo(platform, connection, entityCount) {
|
|
193
|
+
this.summary.DbPlatform = platform;
|
|
194
|
+
this.summary.DbConnection = connection;
|
|
195
|
+
this.summary.EntityCount = entityCount;
|
|
196
|
+
}
|
|
197
|
+
/** Adds a registered auth-provider name to the summary `Auth` line. */
|
|
198
|
+
AddAuthProvider(name) {
|
|
199
|
+
this.summary.AuthProviders.push(name);
|
|
200
|
+
}
|
|
201
|
+
/** Records whether the REST API is enabled for the summary `Auth` line. */
|
|
202
|
+
SetRestEnabled(enabled) {
|
|
203
|
+
this.summary.RestEnabled = enabled;
|
|
204
|
+
}
|
|
205
|
+
/** Records the active scheduled-job count for the summary `Auth` line. */
|
|
206
|
+
SetScheduledJobCount(count) {
|
|
207
|
+
this.summary.ScheduledJobCount = count;
|
|
208
|
+
}
|
|
209
|
+
/** Records the ready URL for the summary `Ready` line. */
|
|
210
|
+
SetReadyUrl(url) {
|
|
211
|
+
this.summary.ReadyUrl = url;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Prints the boot summary appropriate for the active level:
|
|
215
|
+
* - `minimal`: only the `Ready <url>` line.
|
|
216
|
+
* - `standard`: the compact ~8-line summary block (with phases collapsed).
|
|
217
|
+
* - `verbose`/`debug`: the same compact block (individual phase lines and
|
|
218
|
+
* all detail lines were already printed inline during boot).
|
|
219
|
+
*/
|
|
220
|
+
PrintSummary() {
|
|
221
|
+
// Clear the transient spinner before any block output so the line it
|
|
222
|
+
// occupied is replaced cleanly by the summary.
|
|
223
|
+
this.StopBoot();
|
|
224
|
+
if (this.resolvedLevel === 'minimal') {
|
|
225
|
+
this.printReadyLineOnly();
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
this.printSummaryBlock();
|
|
229
|
+
}
|
|
230
|
+
/** Prints just the ready URL (minimal level). */
|
|
231
|
+
printReadyLineOnly() {
|
|
232
|
+
if (this.summary.ReadyUrl) {
|
|
233
|
+
// eslint-disable-next-line no-console
|
|
234
|
+
console.log(`🚀 Ready ${this.summary.ReadyUrl}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/** Renders and prints the multi-line compact summary block. */
|
|
238
|
+
printSummaryBlock() {
|
|
239
|
+
const lines = this.buildSummaryLines();
|
|
240
|
+
// eslint-disable-next-line no-console
|
|
241
|
+
console.log('\n' + lines.join('\n') + '\n');
|
|
242
|
+
}
|
|
243
|
+
/** Builds the array of summary lines (header + indented detail rows). */
|
|
244
|
+
buildSummaryLines() {
|
|
245
|
+
const lines = [];
|
|
246
|
+
lines.push(this.buildHeaderLine());
|
|
247
|
+
lines.push(this.buildDbLine());
|
|
248
|
+
lines.push(this.buildConfigLine());
|
|
249
|
+
lines.push(this.buildAuthLine());
|
|
250
|
+
lines.push(this.buildStartupLine());
|
|
251
|
+
lines.push(this.buildReadyLine());
|
|
252
|
+
return lines.filter((l) => l.length > 0);
|
|
253
|
+
}
|
|
254
|
+
/** `🚀 MemberJunction Server · v<version>` (version omitted if unknown). */
|
|
255
|
+
buildHeaderLine() {
|
|
256
|
+
const version = this.summary.Version ? ` · v${this.summary.Version}` : '';
|
|
257
|
+
return `🚀 MemberJunction Server${version}`;
|
|
258
|
+
}
|
|
259
|
+
/** ` DB <platform> · <connection> · <N> entities`. */
|
|
260
|
+
buildDbLine() {
|
|
261
|
+
if (!this.summary.DbPlatform) {
|
|
262
|
+
return '';
|
|
263
|
+
}
|
|
264
|
+
const parts = [this.summary.DbPlatform];
|
|
265
|
+
if (this.summary.DbConnection) {
|
|
266
|
+
parts.push(this.summary.DbConnection);
|
|
267
|
+
}
|
|
268
|
+
if (this.summary.EntityCount != null) {
|
|
269
|
+
parts.push(`${this.summary.EntityCount} entities`);
|
|
270
|
+
}
|
|
271
|
+
return ` DB ${parts.join(' · ')}`;
|
|
272
|
+
}
|
|
273
|
+
/** ` Config <path>` (omitted when no config file was resolved). */
|
|
274
|
+
buildConfigLine() {
|
|
275
|
+
if (!this.summary.ConfigPath) {
|
|
276
|
+
return '';
|
|
277
|
+
}
|
|
278
|
+
return ` Config ${this.summary.ConfigPath}`;
|
|
279
|
+
}
|
|
280
|
+
/** ` Auth <providers> REST <on/off> · <N> scheduled jobs`. */
|
|
281
|
+
buildAuthLine() {
|
|
282
|
+
const providers = this.summary.AuthProviders.length > 0
|
|
283
|
+
? this.summary.AuthProviders.join(', ')
|
|
284
|
+
: 'none';
|
|
285
|
+
const rest = this.summary.RestEnabled == null
|
|
286
|
+
? ''
|
|
287
|
+
: `REST ${this.summary.RestEnabled ? 'on' : 'off'}`;
|
|
288
|
+
const jobs = this.summary.ScheduledJobCount == null
|
|
289
|
+
? ''
|
|
290
|
+
: `${this.summary.ScheduledJobCount} scheduled jobs`;
|
|
291
|
+
const trailer = [rest, jobs].filter((s) => s.length > 0).join(' · ');
|
|
292
|
+
const trailerPart = trailer ? ` ${trailer}` : '';
|
|
293
|
+
return ` Auth ${providers}${trailerPart}`;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* ` Startup <total>s (<phase> <x>s · … · other <z>s)`.
|
|
297
|
+
*
|
|
298
|
+
* The headline `<total>` is the TRUE wall-clock since process start — in Node,
|
|
299
|
+
* `performance.now()` is measured from `performance.timeOrigin` (≈ process
|
|
300
|
+
* start), so it captures the entire bootstrap (module import, config load,
|
|
301
|
+
* ServerBootstrap, and `serve()`), not just the timed phases. The parenthetical
|
|
302
|
+
* lists each captured phase; `other` is the unattributed remainder (import +
|
|
303
|
+
* config + any untimed setup) shown only when it's non-trivial.
|
|
304
|
+
*/
|
|
305
|
+
buildStartupLine() {
|
|
306
|
+
if (this.phaseTimings.length === 0) {
|
|
307
|
+
return '';
|
|
308
|
+
}
|
|
309
|
+
const totalMs = performance.now();
|
|
310
|
+
const phaseSumMs = this.phaseTimings.reduce((sum, p) => sum + p.Ms, 0);
|
|
311
|
+
const otherMs = totalMs - phaseSumMs;
|
|
312
|
+
const parts = this.phaseTimings.map((p) => `${this.shortPhaseLabel(p.Label)} ${(p.Ms / 1000).toFixed(1)}s`);
|
|
313
|
+
// Surface unattributed boot time only when it's meaningful (>50ms), so the
|
|
314
|
+
// line stays clean when phases already account for ~all of startup.
|
|
315
|
+
if (otherMs > 50) {
|
|
316
|
+
parts.push(`other ${(otherMs / 1000).toFixed(1)}s`);
|
|
317
|
+
}
|
|
318
|
+
return ` Startup ${(totalMs / 1000).toFixed(1)}s (${parts.join(' · ')})`;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Abbreviates a verbose phase label into a compact token for the collapsed
|
|
322
|
+
* summary line (e.g. "Metadata + Provider Setup" → "metadata").
|
|
323
|
+
*/
|
|
324
|
+
shortPhaseLabel(label) {
|
|
325
|
+
const lower = label.toLowerCase();
|
|
326
|
+
if (lower.includes('metadata') || lower.includes('provider')) {
|
|
327
|
+
return 'metadata';
|
|
328
|
+
}
|
|
329
|
+
if (lower.includes('schema')) {
|
|
330
|
+
return 'schema';
|
|
331
|
+
}
|
|
332
|
+
if (lower.includes('db') || lower.includes('pool')) {
|
|
333
|
+
return 'db';
|
|
334
|
+
}
|
|
335
|
+
if (lower.includes('resolver') || lower.includes('middleware')) {
|
|
336
|
+
return 'resolvers';
|
|
337
|
+
}
|
|
338
|
+
if (lower.includes('apollo') || lower.includes('express')) {
|
|
339
|
+
return 'http';
|
|
340
|
+
}
|
|
341
|
+
if (lower.includes('telemetry') || lower.includes('cache')) {
|
|
342
|
+
return 'cache';
|
|
343
|
+
}
|
|
344
|
+
return lower.split(' ')[0];
|
|
345
|
+
}
|
|
346
|
+
/** ` Ready <url>`. */
|
|
347
|
+
buildReadyLine() {
|
|
348
|
+
if (!this.summary.ReadyUrl) {
|
|
349
|
+
return '';
|
|
350
|
+
}
|
|
351
|
+
return ` Ready ${this.summary.ReadyUrl}`;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
//# sourceMappingURL=StartupLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StartupLogger.js","sourceRoot":"","sources":["../../src/logging/StartupLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,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O,CAAC,QAAQ,EAAE,CAAC;YAC3B,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,gBAAgB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variablesLoggingMiddleware.d.ts","sourceRoot":"","sources":["../../src/logging/variablesLoggingMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"variablesLoggingMiddleware.d.ts","sourceRoot":"","sources":["../../src/logging/variablesLoggingMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA2F9C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,0BAA0B,EAAE,YAAY,CAAC,UAAU,CA0E/D,CAAC"}
|
|
@@ -3,6 +3,21 @@ import { getNamedType } from 'graphql';
|
|
|
3
3
|
import { configInfo } from '../config.js';
|
|
4
4
|
import { redactArg } from './secretRedactor.js';
|
|
5
5
|
import { hasNoLogParameter, getNoLogFields } from './NoLog.js';
|
|
6
|
+
import { StartupLogger } from './StartupLogger.js';
|
|
7
|
+
/**
|
|
8
|
+
* Memoized "is the server log level `debug`?" check. The per-resolver
|
|
9
|
+
* variables echo is gated behind BOTH `logVariables` (opt-in redaction path)
|
|
10
|
+
* AND `level === 'debug'` — it is a raw, constantly-on debug line, so it should
|
|
11
|
+
* never fire unless an operator explicitly opted into debug verbosity. Config
|
|
12
|
+
* is immutable post-boot, so caching the resolution is safe.
|
|
13
|
+
*/
|
|
14
|
+
let isDebugLevelCache;
|
|
15
|
+
function isDebugLogLevel() {
|
|
16
|
+
if (isDebugLevelCache === undefined) {
|
|
17
|
+
isDebugLevelCache = StartupLogger.resolveLevelFromConfig() === 'debug';
|
|
18
|
+
}
|
|
19
|
+
return isDebugLevelCache;
|
|
20
|
+
}
|
|
6
21
|
let resolverLookup;
|
|
7
22
|
function getResolverLookup() {
|
|
8
23
|
if (resolverLookup !== undefined) {
|
|
@@ -94,8 +109,12 @@ export const variablesLoggingMiddleware = async (action, next) => {
|
|
|
94
109
|
hasUndecoratedCustomArg = true;
|
|
95
110
|
}
|
|
96
111
|
}
|
|
97
|
-
//
|
|
98
|
-
|
|
112
|
+
// Raw per-resolver variables echo — gated to debug-only so it never streams
|
|
113
|
+
// constantly even when an operator turns on logVariables at a lower level.
|
|
114
|
+
if (isDebugLogLevel()) {
|
|
115
|
+
// eslint-disable-next-line no-console
|
|
116
|
+
console.dir({ operation: action.info.fieldName, args: redactedArgs }, { depth: null, breakLength: 200 });
|
|
117
|
+
}
|
|
99
118
|
if (hasUndecoratedCustomArg && resolverEntry) {
|
|
100
119
|
const signature = `${resolverEntry.target.name}.${resolverEntry.methodName}`;
|
|
101
120
|
if (!warnedResolverSignatures.has(signature)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variablesLoggingMiddleware.js","sourceRoot":"","sources":["../../src/logging/variablesLoggingMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"variablesLoggingMiddleware.js","sourceRoot":"","sources":["../../src/logging/variablesLoggingMiddleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAA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AC;AAChB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AppContext } from '../types.js';
|
|
2
|
+
import { ResolverBase } from '../generic/ResolverBase.js';
|
|
3
|
+
/** Result of {@link AgentSessionResolver.StartAgentSession}. */
|
|
4
|
+
export declare class StartAgentSessionResult {
|
|
5
|
+
/** ID of the newly created session. */
|
|
6
|
+
agentSessionId: string;
|
|
7
|
+
/** Lifecycle status of the session (always `Active` on a successful start). */
|
|
8
|
+
status: string;
|
|
9
|
+
/** ID of the conversation the session is attached to (supplied or freshly created). */
|
|
10
|
+
conversationId: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolver for the AI Agent Session record lifecycle. A single {@link SessionManager} instance is
|
|
14
|
+
* shared across requests — it holds no per-user/provider state (only heartbeat-coalescing
|
|
15
|
+
* timestamps), and every method is passed the request `contextUser` + provider explicitly.
|
|
16
|
+
*/
|
|
17
|
+
export declare class AgentSessionResolver extends ResolverBase {
|
|
18
|
+
private readonly sessionManager;
|
|
19
|
+
/**
|
|
20
|
+
* Open a new session for an agent. Authorization (`CanRun`) is enforced inside
|
|
21
|
+
* {@link SessionManager.CreateSession}; a denial surfaces as a thrown error and no row is written.
|
|
22
|
+
*/
|
|
23
|
+
StartAgentSession(agentId: string, { userPayload, providers }: AppContext, conversationId?: string, lastSessionId?: string, configJson?: string): Promise<StartAgentSessionResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Close a session. Rejects unless the caller owns it. Returns `true` on a successful (or
|
|
26
|
+
* idempotent) close, `false` if the session can't be loaded.
|
|
27
|
+
*/
|
|
28
|
+
CloseAgentSession(agentSessionId: string, { userPayload, providers }: AppContext): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Record activity on a session (coalesced). Rejects unless the caller owns it. Returns `true`
|
|
31
|
+
* when the heartbeat was accepted (written or coalesced), `false` if the session is gone/closed.
|
|
32
|
+
*/
|
|
33
|
+
AgentSessionHeartbeat(agentSessionId: string, { userPayload, providers }: AppContext): Promise<boolean>;
|
|
34
|
+
/** Resolve the request user + read-write provider, throwing a clear error if unauthenticated. */
|
|
35
|
+
private requireUserAndProvider;
|
|
36
|
+
/**
|
|
37
|
+
* Inbound ownership gate (the one genuinely new session-authz primitive): the session's `UserID`
|
|
38
|
+
* must equal the caller's. Throws on mismatch or when the session can't be loaded.
|
|
39
|
+
*/
|
|
40
|
+
private assertOwnership;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=AgentSessionResolver.d.ts.map
|