@xrkseek/harness 0.4.8 → 0.4.9
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/node_modules/@xrkseek/cordis/LICENSE +21 -0
- package/node_modules/@xrkseek/cordis/README.md +14 -0
- package/node_modules/@xrkseek/cordis/bin.js +16 -0
- package/node_modules/@xrkseek/cordis/lib/index.js +1828 -0
- package/node_modules/@xrkseek/cordis/lib/types/context.d.ts +101 -0
- package/node_modules/@xrkseek/cordis/lib/types/context.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/lib/types/events.d.ts +240 -0
- package/node_modules/@xrkseek/cordis/lib/types/events.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/lib/types/fiber.d.ts +202 -0
- package/node_modules/@xrkseek/cordis/lib/types/fiber.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/lib/types/index.d.ts +15 -0
- package/node_modules/@xrkseek/cordis/lib/types/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/lib/types/logger.d.ts +105 -0
- package/node_modules/@xrkseek/cordis/lib/types/logger.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/lib/types/reflect.d.ts +186 -0
- package/node_modules/@xrkseek/cordis/lib/types/reflect.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/lib/types/registry.d.ts +201 -0
- package/node_modules/@xrkseek/cordis/lib/types/registry.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/lib/types/service.d.ts +55 -0
- package/node_modules/@xrkseek/cordis/lib/types/service.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/lib/types/utils.d.ts +62 -0
- package/node_modules/@xrkseek/cordis/lib/types/utils.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/package.json +49 -0
- package/node_modules/@xrkseek/cordis/src/context.d.ts +101 -0
- package/node_modules/@xrkseek/cordis/src/context.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/src/context.js +99 -0
- package/node_modules/@xrkseek/cordis/src/context.js.map +1 -0
- package/node_modules/@xrkseek/cordis/src/context.ts +146 -0
- package/node_modules/@xrkseek/cordis/src/events.d.ts +240 -0
- package/node_modules/@xrkseek/cordis/src/events.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/src/events.js +199 -0
- package/node_modules/@xrkseek/cordis/src/events.js.map +1 -0
- package/node_modules/@xrkseek/cordis/src/events.ts +352 -0
- package/node_modules/@xrkseek/cordis/src/fiber.d.ts +202 -0
- package/node_modules/@xrkseek/cordis/src/fiber.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/src/fiber.js +677 -0
- package/node_modules/@xrkseek/cordis/src/fiber.js.map +1 -0
- package/node_modules/@xrkseek/cordis/src/fiber.ts +754 -0
- package/node_modules/@xrkseek/cordis/src/index.d.ts +15 -0
- package/node_modules/@xrkseek/cordis/src/index.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/src/index.js +15 -0
- package/node_modules/@xrkseek/cordis/src/index.js.map +1 -0
- package/node_modules/@xrkseek/cordis/src/index.ts +14 -0
- package/node_modules/@xrkseek/cordis/src/logger.d.ts +105 -0
- package/node_modules/@xrkseek/cordis/src/logger.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/src/logger.js +193 -0
- package/node_modules/@xrkseek/cordis/src/logger.js.map +1 -0
- package/node_modules/@xrkseek/cordis/src/logger.ts +270 -0
- package/node_modules/@xrkseek/cordis/src/reflect.d.ts +186 -0
- package/node_modules/@xrkseek/cordis/src/reflect.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/src/reflect.js +311 -0
- package/node_modules/@xrkseek/cordis/src/reflect.js.map +1 -0
- package/node_modules/@xrkseek/cordis/src/reflect.ts +418 -0
- package/node_modules/@xrkseek/cordis/src/registry.d.ts +201 -0
- package/node_modules/@xrkseek/cordis/src/registry.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/src/registry.js +218 -0
- package/node_modules/@xrkseek/cordis/src/registry.js.map +1 -0
- package/node_modules/@xrkseek/cordis/src/registry.ts +337 -0
- package/node_modules/@xrkseek/cordis/src/service.d.ts +55 -0
- package/node_modules/@xrkseek/cordis/src/service.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/src/service.js +113 -0
- package/node_modules/@xrkseek/cordis/src/service.js.map +1 -0
- package/node_modules/@xrkseek/cordis/src/service.ts +115 -0
- package/node_modules/@xrkseek/cordis/src/utils.d.ts +62 -0
- package/node_modules/@xrkseek/cordis/src/utils.d.ts.map +1 -0
- package/node_modules/@xrkseek/cordis/src/utils.js +271 -0
- package/node_modules/@xrkseek/cordis/src/utils.js.map +1 -0
- package/node_modules/@xrkseek/cordis/src/utils.ts +287 -0
- package/node_modules/@xrkseek/core-agent-loop/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-agent-loop/dist/index.js +39 -68
- package/node_modules/@xrkseek/core-agent-loop/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/compaction.d.ts +4 -3
- package/node_modules/@xrkseek/core-session/dist/compaction.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-session/dist/compaction.js.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.d.ts.map +1 -1
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js +2 -1
- package/node_modules/@xrkseek/core-tools/dist/subagent-prompt.js.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/README.md +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/catalog.d.ts +16 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/catalog.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/catalog.js +152 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/catalog.js.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/deepinfra-http.d.ts +9 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/deepinfra-http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/deepinfra-http.js +21 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/deepinfra-http.js.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/fal-http.d.ts +16 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/fal-http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/fal-http.js +189 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/fal-http.js.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/index.d.ts +10 -5
- package/node_modules/@xrkseek/exec-image-gen/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/index.js +174 -18
- package/node_modules/@xrkseek/exec-image-gen/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/krea-http.d.ts +16 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/krea-http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/krea-http.js +144 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/krea-http.js.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/meta-ai-http.d.ts +9 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/meta-ai-http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/meta-ai-http.js +21 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/meta-ai-http.js.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/openai-http.d.ts +4 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/openai-http.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/openai-http.js +7 -5
- package/node_modules/@xrkseek/exec-image-gen/dist/openai-http.js.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/openrouter-http.d.ts +14 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/openrouter-http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/openrouter-http.js +117 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/openrouter-http.js.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/tools.js +43 -6
- package/node_modules/@xrkseek/exec-image-gen/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/types.d.ts +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/types.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/types.js.map +1 -1
- package/node_modules/@xrkseek/exec-image-gen/dist/xai-http.d.ts +16 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/xai-http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/xai-http.js +137 -0
- package/node_modules/@xrkseek/exec-image-gen/dist/xai-http.js.map +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/consolidate-pipeline.d.ts +52 -0
- package/node_modules/@xrkseek/exec-memory/dist/consolidate-pipeline.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/consolidate-pipeline.js +216 -0
- package/node_modules/@xrkseek/exec-memory/dist/consolidate-pipeline.js.map +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/index.d.ts +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/index.js +1 -0
- package/node_modules/@xrkseek/exec-memory/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-memory/dist/tools.js +20 -7
- package/node_modules/@xrkseek/exec-memory/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/README.md +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/catalog.d.ts +14 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/catalog.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/catalog.js +99 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/catalog.js.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/deepinfra-http.d.ts +9 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/deepinfra-http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/deepinfra-http.js +17 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/deepinfra-http.js.map +1 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/fal-http.d.ts +14 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/fal-http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/fal-http.js +342 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/fal-http.js.map +1 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/index.d.ts +8 -6
- package/node_modules/@xrkseek/exec-video-gen/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/index.js +122 -19
- package/node_modules/@xrkseek/exec-video-gen/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/openai-http.d.ts +4 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/openai-http.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/openai-http.js +21 -15
- package/node_modules/@xrkseek/exec-video-gen/dist/openai-http.js.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/openrouter-http.d.ts +9 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/openrouter-http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/openrouter-http.js +18 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/openrouter-http.js.map +1 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/tools.js +26 -6
- package/node_modules/@xrkseek/exec-video-gen/dist/tools.js.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/types.d.ts +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/types.d.ts.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/types.js.map +1 -1
- package/node_modules/@xrkseek/exec-video-gen/dist/xai-http.d.ts +18 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/xai-http.d.ts.map +1 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/xai-http.js +263 -0
- package/node_modules/@xrkseek/exec-video-gen/dist/xai-http.js.map +1 -0
- package/node_modules/@xrkseek/preset-harness/dist/preset.d.ts.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/preset.js +12 -3
- package/node_modules/@xrkseek/preset-harness/dist/preset.js.map +1 -1
- package/node_modules/@xrkseek/preset-harness/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-minimal/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/preset-server/dist/tsconfig.tsbuildinfo +1 -1
- package/node_modules/@xrkseek/server-face/dist/agent-team-graph.d.ts +31 -0
- package/node_modules/@xrkseek/server-face/dist/agent-team-graph.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/agent-team-graph.js +125 -1
- package/node_modules/@xrkseek/server-face/dist/agent-team-graph.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/context.d.ts +19 -1
- package/node_modules/@xrkseek/server-face/dist/context.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.d.ts +3 -3
- package/node_modules/@xrkseek/server-face/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.js +1 -1
- package/node_modules/@xrkseek/server-face/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/mcp-oauth.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/mcp-oauth.js +25 -3
- package/node_modules/@xrkseek/server-face/dist/mcp-oauth.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/ralph-tool.d.ts +2 -0
- package/node_modules/@xrkseek/server-face/dist/ralph-tool.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/ralph-tool.js +11 -5
- package/node_modules/@xrkseek/server-face/dist/ralph-tool.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/runtime.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/runtime.js +1 -0
- package/node_modules/@xrkseek/server-face/dist/runtime.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-status.d.ts +16 -0
- package/node_modules/@xrkseek/server-face/dist/session-status.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/session-status.js +44 -5
- package/node_modules/@xrkseek/server-face/dist/session-status.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.d.ts +9 -0
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.js +50 -0
- package/node_modules/@xrkseek/server-face/dist/settings-credentials.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-document.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-document.js +40 -0
- package/node_modules/@xrkseek/server-face/dist/settings-document.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js +20 -4
- package/node_modules/@xrkseek/server-face/dist/settings-schemas.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.js +191 -0
- package/node_modules/@xrkseek/server-face/dist/subagent-tools.js.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/wire/rpc-error.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-face/dist/wire/rpc-error.js +8 -0
- package/node_modules/@xrkseek/server-face/dist/wire/rpc-error.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/index.js +135 -24
- package/node_modules/@xrkseek/server-host/dist/index.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js +6 -0
- package/node_modules/@xrkseek/server-host/dist/sidebar-face-bridge.js.map +1 -1
- package/node_modules/@xrkseek/server-host/dist/workflow-engine-mount.d.ts +32 -0
- package/node_modules/@xrkseek/server-host/dist/workflow-engine-mount.d.ts.map +1 -0
- package/node_modules/@xrkseek/server-host/dist/workflow-engine-mount.js +134 -0
- package/node_modules/@xrkseek/server-host/dist/workflow-engine-mount.js.map +1 -0
- package/node_modules/@xrkseek/server-host/package.json +2 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.d.ts.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.js +20 -0
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-adapter.js.map +1 -1
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-face-bridge.d.ts +10 -2
- package/node_modules/@xrkseek/server-http/dist/sidebar/sidebar-face-bridge.d.ts.map +1 -1
- package/node_modules/@xrkseek/xrk-workflow/README.i18n.yaml +6 -0
- package/node_modules/@xrkseek/xrk-workflow/README.md +73 -0
- package/node_modules/@xrkseek/xrk-workflow/README.zh.md +72 -0
- package/node_modules/@xrkseek/xrk-workflow/lib/types/index.d.ts +177 -0
- package/node_modules/@xrkseek/xrk-workflow/lib/types/index.js +730 -0
- package/node_modules/@xrkseek/xrk-workflow/lib/types/invariant.d.ts +13 -0
- package/node_modules/@xrkseek/xrk-workflow/lib/types/invariant.js +118 -0
- package/node_modules/@xrkseek/xrk-workflow/lib/types/runtime-types.d.ts +45 -0
- package/node_modules/@xrkseek/xrk-workflow/lib/types/runtime-types.js +9 -0
- package/node_modules/@xrkseek/xrk-workflow/lib/types/types.d.ts +118 -0
- package/node_modules/@xrkseek/xrk-workflow/lib/types/types.js +16 -0
- package/node_modules/@xrkseek/xrk-workflow/package.json +53 -0
- package/node_modules/@xrkseek/xrk-workflow/src/index.ts +947 -0
- package/package.json +5 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Context } from './context.ts';
|
|
2
|
+
import { Fiber } from './fiber.ts';
|
|
3
|
+
import { symbols } from './utils.ts';
|
|
4
|
+
declare module './context.ts' {
|
|
5
|
+
interface Intercept {
|
|
6
|
+
logger: LoggerService.Intercept;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/** Logger method name and severity category. */
|
|
10
|
+
export type LoggerType = 'error' | 'info' | 'warn' | 'debug';
|
|
11
|
+
/** Callable shape for one logger severity method. */
|
|
12
|
+
export type LoggerMethod = (format: any, ...param: any[]) => void;
|
|
13
|
+
/** Formatter used to resolve a printf-style placeholder. */
|
|
14
|
+
export type Formatter = (value: any, exporter: Exporter, message: Message) => any;
|
|
15
|
+
/** Numeric severity used when exporters decide whether to emit a message. */
|
|
16
|
+
export declare const enum LoggerLevel {
|
|
17
|
+
ERROR = 0,
|
|
18
|
+
INFO = 1,
|
|
19
|
+
WARN = 2,
|
|
20
|
+
DEBUG = 3
|
|
21
|
+
}
|
|
22
|
+
/** Structured log record delivered to exporters. */
|
|
23
|
+
export interface Message {
|
|
24
|
+
sn: number;
|
|
25
|
+
ts: number;
|
|
26
|
+
name: string;
|
|
27
|
+
type: LoggerType;
|
|
28
|
+
level: number;
|
|
29
|
+
args: any[];
|
|
30
|
+
fiber?: WeakRef<Fiber>;
|
|
31
|
+
}
|
|
32
|
+
/** Sink that receives structured log messages. */
|
|
33
|
+
export interface Exporter {
|
|
34
|
+
colors?: number | false;
|
|
35
|
+
maxLength?: number;
|
|
36
|
+
levels?: Record<string, number>;
|
|
37
|
+
formatters?: Record<string, Formatter>;
|
|
38
|
+
export(message: Message): void;
|
|
39
|
+
}
|
|
40
|
+
/** Built-in placeholder formatters used by `Logger.format()`. */
|
|
41
|
+
export declare const defaultFormatters: Record<string, Formatter>;
|
|
42
|
+
/** Options used when creating a named logger facade. */
|
|
43
|
+
export interface LoggerOptions {
|
|
44
|
+
/** The logger name shown with each message. */
|
|
45
|
+
name: string;
|
|
46
|
+
/** Message fields merged into every record from this logger. */
|
|
47
|
+
meta?: Partial<Message>;
|
|
48
|
+
/** Default maximum level exported when an exporter has no own threshold. */
|
|
49
|
+
level?: number;
|
|
50
|
+
}
|
|
51
|
+
/** Logger facade identity, inherited message metadata, and optional minimum level. */
|
|
52
|
+
export interface Logger extends LoggerOptions {
|
|
53
|
+
}
|
|
54
|
+
/** Logger facade severity methods. */
|
|
55
|
+
export interface Logger extends Record<LoggerType, LoggerMethod> {
|
|
56
|
+
}
|
|
57
|
+
/** Logger facade for one named subsystem. */
|
|
58
|
+
export declare class Logger {
|
|
59
|
+
private service;
|
|
60
|
+
static color(exporter: Exporter, code: number, value: any, decoration?: string): string;
|
|
61
|
+
static code(name: string, level?: false | number): number;
|
|
62
|
+
static format(exporter: Exporter, message: Message): string;
|
|
63
|
+
constructor(options: LoggerOptions, service: LoggerService);
|
|
64
|
+
private _method;
|
|
65
|
+
}
|
|
66
|
+
/** ANSI 16-color palette indexes used for logger name coloring. */
|
|
67
|
+
export declare const c16: number[];
|
|
68
|
+
/** ANSI 256-color palette indexes used for logger name coloring. */
|
|
69
|
+
export declare const c256: number[];
|
|
70
|
+
/** Logger service configuration merged from context intercepts. */
|
|
71
|
+
export declare namespace LoggerService {
|
|
72
|
+
interface Intercept {
|
|
73
|
+
name?: string;
|
|
74
|
+
level?: number;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** Callable `ctx.logger` service shape. */
|
|
78
|
+
export interface LoggerService extends Record<LoggerType, LoggerMethod> {
|
|
79
|
+
(name?: string): Logger;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Built-in logging service.
|
|
83
|
+
*
|
|
84
|
+
* Call `ctx.logger()` to create a named logger, or call `ctx.logger.info()`
|
|
85
|
+
* directly to log with the current fiber-derived name.
|
|
86
|
+
*/
|
|
87
|
+
export declare class LoggerService {
|
|
88
|
+
bufferSize: number;
|
|
89
|
+
buffer: Message[];
|
|
90
|
+
ctx: Context;
|
|
91
|
+
_snMessage: number;
|
|
92
|
+
_snExporter: number;
|
|
93
|
+
exporters: Map<number, Exporter>;
|
|
94
|
+
constructor(ctx: Context);
|
|
95
|
+
/**
|
|
96
|
+
* Register an exporter and dispose it with the current fiber.
|
|
97
|
+
*
|
|
98
|
+
* @param exporter — the sink that receives structured log messages.
|
|
99
|
+
* @returns a disposer that removes the exporter.
|
|
100
|
+
*/
|
|
101
|
+
exporter(exporter: Exporter): import("./fiber.ts").Disposable<Promise<void>>;
|
|
102
|
+
private _resolveConfig;
|
|
103
|
+
[symbols.invoke](name?: string): Logger;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAiC,OAAO,EAAgB,MAAM,YAAY,CAAA;AAEjF,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,SAAS;QACjB,MAAM,EAAE,aAAa,CAAC,SAAS,CAAA;KAChC;CACF;AAED,gDAAgD;AAChD,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAE5D,qDAAqD;AACrD,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;AAEjE,4DAA4D;AAC5D,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,KAAK,GAAG,CAAA;AAEjF,6EAA6E;AAC7E,0BAAkB,WAAW;IAC3B,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI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E,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM;IAUhD,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM;gBAkC/C,OAAO,EAAE,aAAa,EAAU,OAAO,EAAE,aAAa;IAQlE,OAAO,CAAC,OAAO;CAqBhB;AAED,mEAAmE;AACnE,eAAO,MAAM,GAAG,UAAqB,CAAA;AACrC,oEAAoE;AACpE,eAAO,MAAM,IAAI,UAMhB,CAAA;AAED,mEAAmE;AACnE,yBAAiB,aAAa,CAAC;IAC7B,UAAiB,SAAS;QACxB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;KACf;CACF;AAED,2CAA2C;AAC3C,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,UAAU,EAAE,YAAY,CAAC;IACrE,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACxB;AAED;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,UAAU,SAAO;IACjB,MAAM,EAAE,OAAO,EAAE,CAAK;IACtB,GAAG,EAAG,OAAO,CAAA;IAEb,UAAU,SAAI;IACd,WAAW,SAAI;IACf,SAAS,wBAA8B;gBAE3B,GAAG,EAAE,OAAO;IAuBxB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ;IAO3B,OAAO,CAAC,cAAc;IAYtB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;CAmBxC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import type { Dict } from '@xrkseek/cosmokit';
|
|
2
|
+
import { Context } from './context.ts';
|
|
3
|
+
import { Fiber } from './fiber.ts';
|
|
4
|
+
declare module './context.ts' {
|
|
5
|
+
interface Context {
|
|
6
|
+
/**
|
|
7
|
+
* Read a service from the store without the inject requirement.
|
|
8
|
+
*
|
|
9
|
+
* @param name — the service name.
|
|
10
|
+
* @param strict — when `true` (default), only return implementations
|
|
11
|
+
* whose providing fiber is currently active.
|
|
12
|
+
* @returns the service value, or `undefined` when not (yet) provided.
|
|
13
|
+
*/
|
|
14
|
+
get<K extends string & keyof this>(name: K, strict?: boolean): undefined | this[K];
|
|
15
|
+
/** Same as above for service names outside the typed `Context` surface. */
|
|
16
|
+
get(name: string, strict?: boolean): any;
|
|
17
|
+
/**
|
|
18
|
+
* Overwrite a provided service's value.
|
|
19
|
+
*
|
|
20
|
+
* Only the fiber that provided the service may set it; setting an
|
|
21
|
+
* unprovided name throws.
|
|
22
|
+
*
|
|
23
|
+
* @param name — the service name.
|
|
24
|
+
* @param value — the new service value.
|
|
25
|
+
*/
|
|
26
|
+
set<K extends string & keyof this>(name: K, value: undefined | this[K]): void;
|
|
27
|
+
/** Same as above for service names outside the typed `Context` surface. */
|
|
28
|
+
set(name: string, value: any): void;
|
|
29
|
+
/**
|
|
30
|
+
* Register a service implementation owned by the current fiber.
|
|
31
|
+
*
|
|
32
|
+
* The service becomes visible to dependents in the same isolation scope
|
|
33
|
+
* once the fiber is active; it is unregistered (waking dependents) when
|
|
34
|
+
* the returned disposer runs or the fiber unloads. Throws if the name is
|
|
35
|
+
* already provided in this scope or declared as an accessor.
|
|
36
|
+
*
|
|
37
|
+
* @param name — the service name.
|
|
38
|
+
* @param value — the service value.
|
|
39
|
+
* @returns a disposer that unregisters the service.
|
|
40
|
+
*/
|
|
41
|
+
provide<K extends string & keyof this>(name: K, value: undefined | this[K]): () => void;
|
|
42
|
+
/** Same as above for service names outside the typed `Context` surface. */
|
|
43
|
+
provide(name: string, value?: any): () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Define a computed context property backed by get/set hooks.
|
|
46
|
+
*
|
|
47
|
+
* The accessor is removed when the current fiber unloads. Throws if the
|
|
48
|
+
* name is already declared.
|
|
49
|
+
*
|
|
50
|
+
* @param name — the context property name.
|
|
51
|
+
* @param options — the `get` hook and optional `set` hook.
|
|
52
|
+
*/
|
|
53
|
+
accessor(name: string, options: Omit<Property.Accessor, 'type'>): void;
|
|
54
|
+
/**
|
|
55
|
+
* Expose selected members of a service directly on `ctx`.
|
|
56
|
+
*
|
|
57
|
+
* Each mixed-in key becomes an accessor that forwards to the service
|
|
58
|
+
* (binding methods to it), so e.g. `ctx.on` forwards to `ctx.events.on`.
|
|
59
|
+
* Mixins are removed when the current fiber unloads.
|
|
60
|
+
*
|
|
61
|
+
* @param name — the context property holding the source service.
|
|
62
|
+
* @param mixins — keys to forward, or a source-key → ctx-key map.
|
|
63
|
+
*/
|
|
64
|
+
mixin<K extends string & keyof this>(name: K, mixins: (keyof this & keyof this[K])[] | Dict<string>): void;
|
|
65
|
+
/** Same as above with a source object instead of a context property name. */
|
|
66
|
+
mixin<T extends {}>(source: T, mixins: (keyof this & keyof T)[] | Dict<string>): void;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Context property definition known by the reflection service. */
|
|
70
|
+
export type Property = Property.Service | Property.Accessor;
|
|
71
|
+
/** Property definition variants understood by `ReflectService`. */
|
|
72
|
+
export declare namespace Property {
|
|
73
|
+
/** Service property backed by a provided implementation. */
|
|
74
|
+
interface Service {
|
|
75
|
+
/** Discriminator. */
|
|
76
|
+
type: 'service';
|
|
77
|
+
}
|
|
78
|
+
/** Computed context property backed by custom get/set hooks. */
|
|
79
|
+
interface Accessor {
|
|
80
|
+
/** Discriminator. */
|
|
81
|
+
type: 'accessor';
|
|
82
|
+
/** Compute the property value; `error` carries the caller stack for diagnostics. */
|
|
83
|
+
get: (this: Context, receiver: any, error: Error) => any;
|
|
84
|
+
/** Optional setter; return `false` to reject the write. */
|
|
85
|
+
set?: (this: Context, value: any, receiver: any, error: Error) => boolean;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Concrete service implementation record stored in the root reflect service. */
|
|
89
|
+
export interface Impl {
|
|
90
|
+
/** The service name. */
|
|
91
|
+
name: string;
|
|
92
|
+
/** The fiber that provided the service (owns its lifetime). */
|
|
93
|
+
fiber: Fiber;
|
|
94
|
+
/** The current service value. */
|
|
95
|
+
value?: any;
|
|
96
|
+
/** Optional availability predicate consulted before dependents may load. */
|
|
97
|
+
check?: () => boolean;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Reflection and service-resolution layer installed as `ctx.reflect`.
|
|
101
|
+
*
|
|
102
|
+
* This service powers the context proxy, service registration, accessors, and
|
|
103
|
+
* the mixins that expose core service methods directly on `ctx`.
|
|
104
|
+
*/
|
|
105
|
+
export declare class ReflectService {
|
|
106
|
+
ctx: Context;
|
|
107
|
+
/** Proxy traps implementing service resolution for every context object. */
|
|
108
|
+
static handler: ProxyHandler<Context>;
|
|
109
|
+
/** Service implementations, keyed by isolation label. */
|
|
110
|
+
store: Dict<Impl, symbol>;
|
|
111
|
+
/** Declared context properties (services and accessors), by name. */
|
|
112
|
+
props: Dict<Property>;
|
|
113
|
+
constructor(ctx: Context);
|
|
114
|
+
/**
|
|
115
|
+
* Read a service from the store without the inject requirement.
|
|
116
|
+
*
|
|
117
|
+
* @param name — the service name.
|
|
118
|
+
* @param strict — when `true`, only return implementations whose providing
|
|
119
|
+
* fiber is currently active.
|
|
120
|
+
* @returns the service value, or `undefined` when not (yet) provided.
|
|
121
|
+
*/
|
|
122
|
+
get(name: string, strict?: boolean): any;
|
|
123
|
+
_getImpl(name: string, strict?: boolean): Impl | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Overwrite a provided service's value.
|
|
126
|
+
*
|
|
127
|
+
* @param name — the service name.
|
|
128
|
+
* @param value — the new service value.
|
|
129
|
+
* @param error — carrier for the caller stack in diagnostics.
|
|
130
|
+
* @returns `true` on success.
|
|
131
|
+
* @throws when `name` was never provided, or was provided by another fiber.
|
|
132
|
+
*/
|
|
133
|
+
set(name: string, value: any, error?: Error): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Register a service implementation owned by the current fiber.
|
|
136
|
+
*
|
|
137
|
+
* See the `ctx.provide()` overload above for the full contract.
|
|
138
|
+
*
|
|
139
|
+
* @param name — the service name.
|
|
140
|
+
* @param value — the service value.
|
|
141
|
+
* @param check — optional availability predicate for dependents.
|
|
142
|
+
* @returns a disposer that unregisters the service.
|
|
143
|
+
*/
|
|
144
|
+
provide(name: string, value?: any, check?: () => boolean): import("./fiber.ts").Disposable<Promise<void>>;
|
|
145
|
+
/**
|
|
146
|
+
* Re-evaluate every fiber that requires one of the given services.
|
|
147
|
+
*
|
|
148
|
+
* @param names — the service names that changed.
|
|
149
|
+
* @param filter — restricts notification to matching isolation scopes.
|
|
150
|
+
* @returns the fibers whose dependency state was refreshed.
|
|
151
|
+
*/
|
|
152
|
+
notify(names: string[], filter?: (ctx: Context, name: string) => boolean): Fiber[];
|
|
153
|
+
/**
|
|
154
|
+
* Define a computed context property backed by get/set hooks.
|
|
155
|
+
*
|
|
156
|
+
* @param name — the context property name.
|
|
157
|
+
* @param options — the `get` hook and optional `set` hook.
|
|
158
|
+
* @returns a disposer that removes the accessor.
|
|
159
|
+
*/
|
|
160
|
+
accessor(name: string, options: Omit<Property.Accessor, 'type'>): import("./fiber.ts").Disposable<Promise<void>>;
|
|
161
|
+
/**
|
|
162
|
+
* Expose selected members of a service directly on `ctx`.
|
|
163
|
+
*
|
|
164
|
+
* See the `ctx.mixin()` overload above for the full contract.
|
|
165
|
+
*
|
|
166
|
+
* @param source — a context property name or a source object.
|
|
167
|
+
* @param mixins — keys to forward, or a source-key → ctx-key map.
|
|
168
|
+
* @returns a disposer that removes all created accessors.
|
|
169
|
+
*/
|
|
170
|
+
mixin(source: any, mixins: string[] | Dict<string>): import("./fiber.ts").Disposable<Promise<void>>;
|
|
171
|
+
/**
|
|
172
|
+
* Attach this context's tracing wrapper to a value.
|
|
173
|
+
*
|
|
174
|
+
* @param value — the value to wrap.
|
|
175
|
+
* @returns the traceable wrapper (or the value itself when not applicable).
|
|
176
|
+
*/
|
|
177
|
+
trace<T>(value: T): T;
|
|
178
|
+
/**
|
|
179
|
+
* Wrap a callback so calls trace `this` and arguments to this context.
|
|
180
|
+
*
|
|
181
|
+
* @param callback — the function to wrap.
|
|
182
|
+
* @returns a proxy delegating to `callback` with traced values.
|
|
183
|
+
*/
|
|
184
|
+
bind<T extends Function>(callback: T): T;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=reflect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflect.d.ts","sourceRoot":"","sources":["../../src/reflect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,KAAK,EAAc,MAAM,YAAY,CAAA;AAE9C,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,OAAO;QACf;;;;;;;WAOG;QACH,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QAClF,2EAA2E;QAC3E,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,GAAG,CAAA;QACxC;;;;;;;;WAQG;QACH,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;QAC7E,2EAA2E;QAC3E,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAA;QACnC;;;;;;;;;;;WAWG;QACH,OAAO,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,SAAS,GAAG,IAA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MAAM,CAAC;IAU/D;;;;;;;;OAQG;IACH,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;IA4BlD;;;;;OAKG;IACH,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;IAIjB;;;;;OAKG;IACH,IAAI,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC;CAUrC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { Dict } from '@xrkseek/cosmokit';
|
|
2
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
+
import { Context } from './context.ts';
|
|
4
|
+
import { Fiber } from './fiber.ts';
|
|
5
|
+
import { DisposableList, symbols } from './utils.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Service dependency declaration accepted by plugins and the `@Inject`
|
|
8
|
+
* decorator.
|
|
9
|
+
*
|
|
10
|
+
* Array form requests services without intercept config. Object form maps each
|
|
11
|
+
* service name to optional intercept config for the plugin context.
|
|
12
|
+
*/
|
|
13
|
+
export type Inject<M = Dict> = (keyof M)[] | {
|
|
14
|
+
[K in keyof M]?: M[K];
|
|
15
|
+
};
|
|
16
|
+
/** Context keys that correspond to services with typed intercept config. */
|
|
17
|
+
export type InjectKey = keyof {
|
|
18
|
+
[K in keyof Context & string as Context[K] extends {
|
|
19
|
+
[symbols.config]: any;
|
|
20
|
+
} ? K : never]: any;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Decorator for declaring service dependencies on classes or class methods.
|
|
24
|
+
*
|
|
25
|
+
* On classes it contributes to the plugin's static `inject` map. On methods it
|
|
26
|
+
* delays the method call until the declared services are available.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* @param name — the required service name.
|
|
30
|
+
* @param config — optional intercept config applied for that service.
|
|
31
|
+
* @returns the class or method decorator.
|
|
32
|
+
*/
|
|
33
|
+
export declare function Inject<K extends InjectKey>(name: K, config?: Context[K] extends {
|
|
34
|
+
[symbols.config]: infer T;
|
|
35
|
+
} ? T : never): (value: any, decorator: ClassDecoratorContext<any> | ClassMethodDecoratorContext<any>) => void;
|
|
36
|
+
/** Utilities for normalizing plugin dependency declarations. */
|
|
37
|
+
export declare namespace Inject {
|
|
38
|
+
/**
|
|
39
|
+
* Convert array/object/class-inherited inject metadata into a plain map.
|
|
40
|
+
*
|
|
41
|
+
* @param inject — the declaration to normalize; `null`/`undefined` add nothing.
|
|
42
|
+
* @param result — the map to fill (service name → intercept config or `null`).
|
|
43
|
+
* @returns `result`.
|
|
44
|
+
*/
|
|
45
|
+
function resolve(inject: Inject | null | undefined, result?: Dict): Dict;
|
|
46
|
+
}
|
|
47
|
+
/** Supported plugin entrypoint shapes. */
|
|
48
|
+
export type Plugin<T = any> = Plugin.Function<T> | Plugin.Constructor<T> | Plugin.Object<T>;
|
|
49
|
+
/** Types associated with plugin entrypoints and runtime records. */
|
|
50
|
+
export declare namespace Plugin {
|
|
51
|
+
/** Shared metadata understood by the plugin registry and related tooling. */
|
|
52
|
+
interface Base<T = any> {
|
|
53
|
+
/** Display name used for fiber diagnostics and logger names. */
|
|
54
|
+
name?: string;
|
|
55
|
+
/** Standard-schema validator applied to config before the plugin starts. */
|
|
56
|
+
Config?: StandardSchemaV1<any, T>;
|
|
57
|
+
/** Services the plugin requires; it only loads while all are available. */
|
|
58
|
+
inject?: Inject;
|
|
59
|
+
/** Service name(s) the plugin provides (read by `Service` and by loaders). */
|
|
60
|
+
provide?: string | string[];
|
|
61
|
+
/** Service names whose intercept config the plugin declares it consumes. */
|
|
62
|
+
intercept?: Dict<boolean>;
|
|
63
|
+
}
|
|
64
|
+
interface Transform<S, T> {
|
|
65
|
+
/** Marks the transform object as a schema/config transform. */
|
|
66
|
+
schema?: true;
|
|
67
|
+
/** Convert user-facing config to runtime config. */
|
|
68
|
+
Config: (config: S) => T;
|
|
69
|
+
}
|
|
70
|
+
/** Function plugin called with `(ctx, config)`. */
|
|
71
|
+
interface Function<T = any> extends Base<T> {
|
|
72
|
+
(ctx: Context, config: T): any;
|
|
73
|
+
}
|
|
74
|
+
/** Class plugin constructed with `(ctx, config)`. */
|
|
75
|
+
interface Constructor<T = any> extends Base<T> {
|
|
76
|
+
new (ctx: Context, config: T): any;
|
|
77
|
+
}
|
|
78
|
+
/** Object plugin with an `apply(ctx, config)` method. */
|
|
79
|
+
interface Object<T = any> extends Base<T> {
|
|
80
|
+
apply(ctx: Context, config: T): any;
|
|
81
|
+
}
|
|
82
|
+
/** Mutable registry record shared by all fibers of one plugin callback. */
|
|
83
|
+
interface Runtime {
|
|
84
|
+
/** Display name copied from the first registered plugin shape. */
|
|
85
|
+
name?: string;
|
|
86
|
+
/** Every live fiber of this plugin (one per `ctx.plugin()` call). */
|
|
87
|
+
fibers: DisposableList<Fiber>;
|
|
88
|
+
/** The executable entrypoint all fibers share (registry identity key). */
|
|
89
|
+
callback: globalThis.Function;
|
|
90
|
+
/** Standard-schema validator applied to each fiber's config. */
|
|
91
|
+
Config?: StandardSchemaV1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
type Spread<T> = undefined extends T ? [config?: T] : [config: T];
|
|
95
|
+
type GetPluginParameters<P> = P extends (ctx: Context, ...args: infer R) => any ? R : P extends new (ctx: Context, ...args: infer R) => any ? R : P extends {
|
|
96
|
+
apply(ctx: Context, ...args: infer R): any;
|
|
97
|
+
} ? R : never;
|
|
98
|
+
type GetPluginConfig<P> = P extends Plugin.Transform<infer S, any> ? S : GetPluginParameters<P>[0];
|
|
99
|
+
declare module './context.ts' {
|
|
100
|
+
interface Context {
|
|
101
|
+
/**
|
|
102
|
+
* Run a callback once the requested services are available.
|
|
103
|
+
*
|
|
104
|
+
* Shorthand for `ctx.plugin({ inject, apply: callback })`: the callback
|
|
105
|
+
* is unloaded and re-run whenever a required service changes.
|
|
106
|
+
*
|
|
107
|
+
* @param deps — required services, as an array or a name → config map.
|
|
108
|
+
* @param callback — plugin body called with `(ctx, config)`.
|
|
109
|
+
* @returns the fiber; awaiting it settles once loading finished.
|
|
110
|
+
*/
|
|
111
|
+
inject(deps: Inject, callback: Plugin.Function<void>): Fiber & PromiseLike<Fiber>;
|
|
112
|
+
/**
|
|
113
|
+
* Load a plugin in the current context.
|
|
114
|
+
*
|
|
115
|
+
* @param plugin — a function, class, or `{ apply }` object plugin.
|
|
116
|
+
* @param args — the plugin config, validated against its `Config` schema.
|
|
117
|
+
* @returns the fiber; awaiting it settles once loading finished
|
|
118
|
+
* (rejecting on config or startup errors).
|
|
119
|
+
*/
|
|
120
|
+
plugin<P extends Plugin>(plugin: P, ...args: Spread<GetPluginConfig<P>>): Fiber & PromiseLike<Fiber>;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Plugin registry installed as `ctx.registry` and mixed into every context.
|
|
125
|
+
*
|
|
126
|
+
* It normalizes plugin shapes, tracks plugin runtimes, starts fibers, and
|
|
127
|
+
* exposes map-like inspection over active plugin callbacks.
|
|
128
|
+
*/
|
|
129
|
+
export declare class RegistryService {
|
|
130
|
+
ctx: Context;
|
|
131
|
+
private _counter;
|
|
132
|
+
private _internal;
|
|
133
|
+
constructor(ctx: Context);
|
|
134
|
+
/** Allocate the next fiber uid (increments on every read). */
|
|
135
|
+
get counter(): number;
|
|
136
|
+
/** Number of registered plugin runtimes. */
|
|
137
|
+
get size(): number;
|
|
138
|
+
/**
|
|
139
|
+
* Resolve a supported plugin shape to its executable callback.
|
|
140
|
+
*
|
|
141
|
+
* @param plugin — a function, class, or `{ apply }` object plugin.
|
|
142
|
+
* @returns the callback identifying the plugin, or `undefined` if invalid.
|
|
143
|
+
*/
|
|
144
|
+
resolve(plugin: Plugin): Function | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Look up the runtime record for a plugin.
|
|
147
|
+
*
|
|
148
|
+
* @param plugin — any supported plugin shape.
|
|
149
|
+
* @returns the runtime, or `undefined` when the plugin is not registered.
|
|
150
|
+
*/
|
|
151
|
+
get(plugin: Plugin): Plugin.Runtime | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* Check whether a plugin has a registered runtime.
|
|
154
|
+
*
|
|
155
|
+
* @param plugin — any supported plugin shape.
|
|
156
|
+
* @returns `true` when at least one fiber of the plugin exists.
|
|
157
|
+
*/
|
|
158
|
+
has(plugin: Plugin): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Dispose every running fiber for a plugin and remove its runtime record.
|
|
161
|
+
*
|
|
162
|
+
* @param plugin — any supported plugin shape.
|
|
163
|
+
* @returns the removed runtime, or `undefined` when none was registered.
|
|
164
|
+
*/
|
|
165
|
+
delete(plugin: Plugin): Plugin.Runtime | undefined;
|
|
166
|
+
/** Iterate the registered plugin callbacks. */
|
|
167
|
+
keys(): MapIterator<Function>;
|
|
168
|
+
/** Iterate the registered plugin runtimes. */
|
|
169
|
+
values(): MapIterator<Plugin.Runtime>;
|
|
170
|
+
/** Iterate `[callback, runtime]` pairs. */
|
|
171
|
+
entries(): MapIterator<[Function, Plugin.Runtime]>;
|
|
172
|
+
/**
|
|
173
|
+
* Visit every registered runtime.
|
|
174
|
+
*
|
|
175
|
+
* @param callback — receives each runtime and its identifying callback.
|
|
176
|
+
*/
|
|
177
|
+
forEach(callback: (value: Plugin.Runtime, key: Function) => void): void;
|
|
178
|
+
/**
|
|
179
|
+
* Start a callback once the requested dependencies are available.
|
|
180
|
+
*
|
|
181
|
+
* @param inject — required services, as an array or a name → config map.
|
|
182
|
+
* @param callback — plugin body called with `(ctx, config)`.
|
|
183
|
+
* @returns the fiber; awaiting it settles once loading finished.
|
|
184
|
+
*/
|
|
185
|
+
inject(inject: Inject, callback: Plugin.Function<void>): Fiber & PromiseLike<Fiber>;
|
|
186
|
+
/**
|
|
187
|
+
* Start a plugin in the current context and return its fiber.
|
|
188
|
+
*
|
|
189
|
+
* Creates (or reuses) the plugin's runtime record, then starts a new fiber
|
|
190
|
+
* under the current context. Throws if `plugin` is not a supported shape or
|
|
191
|
+
* if the current fiber is already disposed.
|
|
192
|
+
*
|
|
193
|
+
* @param plugin — a function, class, or `{ apply }` object plugin.
|
|
194
|
+
* @param config — the plugin config, validated against its `Config` schema.
|
|
195
|
+
* @param getOuterStack — captures the caller stack for effect diagnostics.
|
|
196
|
+
* @returns the fiber; awaiting it settles once loading finished.
|
|
197
|
+
*/
|
|
198
|
+
plugin(plugin: Plugin, config?: any, getOuterStack?: () => string[]): Fiber & PromiseLike<Fiber>;
|
|
199
|
+
}
|
|
200
|
+
export {};
|
|
201
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAmB,cAAc,EAAE,OAAO,EAAa,MAAM,YAAY,CAAA;AAMhF;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAAE,CAAA;AAEtE,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GAAG,MAAM;KAC3B,CAAC,IAAI,MAAM,OAAO,GAAG,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,SAAS;QAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,CAAA;KAAE,GAAG,CAAC,GAAG,KAAK,GAAG,GAAG;CAC/F,CAAA;AAED;;;;;GAKG;AACH;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,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;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,KAAK,IAAI;IAIhE;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAItD;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,aAAa,iBAAoB;CAqBvE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Context } from './context.ts';
|
|
2
|
+
import { symbols } from './utils.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Base class for services that expose a named API on `ctx`.
|
|
5
|
+
*
|
|
6
|
+
* Subclasses call `super(ctx, name)` from their constructor. The service is
|
|
7
|
+
* registered immediately and is automatically removed with the owning fiber.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class Service<out T = never> {
|
|
10
|
+
protected ctx: Context;
|
|
11
|
+
/** Symbol key of an instance method run after construction (class plugins). */
|
|
12
|
+
static readonly init: unique symbol;
|
|
13
|
+
/** Symbol key of the availability predicate passed to `ctx.provide()`. */
|
|
14
|
+
static readonly check: unique symbol;
|
|
15
|
+
/** Symbol key of the phantom intercept-config type parameter. */
|
|
16
|
+
static readonly config: unique symbol;
|
|
17
|
+
/** Symbol key of the call body making a service callable (e.g. `ctx.logger()`). */
|
|
18
|
+
static readonly invoke: unique symbol;
|
|
19
|
+
/** Symbol key of the helper deriving an extended service instance. */
|
|
20
|
+
static readonly extend: unique symbol;
|
|
21
|
+
/** Symbol key of the tracker metadata used for context tracing. */
|
|
22
|
+
static readonly tracker: unique symbol;
|
|
23
|
+
/** Symbol key of the intercept-config resolution helper below. */
|
|
24
|
+
static readonly resolveConfig: unique symbol;
|
|
25
|
+
[symbols.config]: T;
|
|
26
|
+
/** The service name this instance is registered under. */
|
|
27
|
+
name: string;
|
|
28
|
+
/**
|
|
29
|
+
* Register this instance as `name` in the current context.
|
|
30
|
+
*
|
|
31
|
+
* Calls `ctx.reflect.provide(name, this, this[Service.check])`, so the
|
|
32
|
+
* service is unregistered automatically when the owning fiber unloads.
|
|
33
|
+
* Services with a `[Service.invoke]` body return a callable instance.
|
|
34
|
+
*
|
|
35
|
+
* @param ctx — the context to register in (stored as `this.ctx`).
|
|
36
|
+
* @param name — the service name; defaults to the static `provide` field.
|
|
37
|
+
*/
|
|
38
|
+
constructor(ctx: Context, name: string);
|
|
39
|
+
protected [symbols.filter](ctx: Context): boolean;
|
|
40
|
+
protected [symbols.extend](props?: any): any;
|
|
41
|
+
/**
|
|
42
|
+
* Merge intercept config from ancestors with optional base and head values.
|
|
43
|
+
*
|
|
44
|
+
* Entries added closer to the root apply first; `base` is prepended and
|
|
45
|
+
* `head` appended. Uses `Config.merge` when the service declares one,
|
|
46
|
+
* otherwise a shallow `Object.assign`.
|
|
47
|
+
*
|
|
48
|
+
* @param base — lowest-precedence config merged before all intercepts.
|
|
49
|
+
* @param head — highest-precedence config merged after all intercepts.
|
|
50
|
+
* @returns the merged config.
|
|
51
|
+
*/
|
|
52
|
+
[symbols.resolveConfig](base?: T, head?: T): T;
|
|
53
|
+
static [Symbol.hasInstance](instance: any): boolean;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAiC,OAAO,EAAgB,MAAM,YAAY,CAAA;AAEjF;;;;;GAKG;AACH,8BAAsB,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK;IA+B7B,SAAS,CAAC,GAAG,EAAE,OAAO;IA9BlC,+EAA+E;IAC/E,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,MAAM,CAAe;IAClD,0EAA0E;IAC1E,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,MAAM,CAAgB;IACpD,iEAAiE;IACjE,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,MAAM,CAAiB;IACtD,mFAAmF;IACnF,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,MAAM,CAAiB;IACtD,sEAAsE;IACtE,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,MAAM,CAAiB;IACtD,mEAAmE;IACnE,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAkB;IACxD,kEAAkE;IAClE,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,MAAM,CAAwB;IAE5D,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAE3B,0DAA0D;IACnD,IAAI,EAAG,MAAM,CAAA;IAEpB;;;;;;;;;OASG;gBACmB,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM;IAmBhD,SAAS,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO;IAIvC,SAAS,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG;IAUtC;;;;;;;;;;OAUG;IACH,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC;IAkB9C,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,GAAG;CAW1C"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Context, Service } from './index.ts';
|
|
2
|
+
/** Ordered collection of disposable values with O(1) deletion by value. */
|
|
3
|
+
export declare class DisposableList<T extends WeakKey> {
|
|
4
|
+
private sn;
|
|
5
|
+
private map;
|
|
6
|
+
private weak;
|
|
7
|
+
get length(): number;
|
|
8
|
+
push(value: T): () => boolean;
|
|
9
|
+
delete(value: T): boolean;
|
|
10
|
+
clear(): T[];
|
|
11
|
+
[Symbol.iterator](): MapIterator<T>;
|
|
12
|
+
}
|
|
13
|
+
/** Metadata used by traceable proxies to rebind `ctx` and associated services. */
|
|
14
|
+
export interface Tracker {
|
|
15
|
+
associate?: string;
|
|
16
|
+
property?: string;
|
|
17
|
+
noShadow?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Shared symbols used to avoid public property-name collisions. */
|
|
20
|
+
export declare const symbols: {
|
|
21
|
+
shadow: symbol;
|
|
22
|
+
receiver: symbol;
|
|
23
|
+
original: symbol;
|
|
24
|
+
metadata: symbol;
|
|
25
|
+
initHooks: symbol;
|
|
26
|
+
checkProto: symbol;
|
|
27
|
+
effect: typeof Context.effect;
|
|
28
|
+
filter: typeof Context.filter;
|
|
29
|
+
isolate: typeof Context.isolate;
|
|
30
|
+
intercept: typeof Context.intercept;
|
|
31
|
+
init: typeof Service.init;
|
|
32
|
+
check: typeof Service.check;
|
|
33
|
+
config: typeof Service.config;
|
|
34
|
+
invoke: typeof Service.invoke;
|
|
35
|
+
extend: typeof Service.extend;
|
|
36
|
+
tracker: typeof Service.tracker;
|
|
37
|
+
resolveConfig: typeof Service.resolveConfig;
|
|
38
|
+
};
|
|
39
|
+
/** Return true when a plugin callback should be constructed with `new`. */
|
|
40
|
+
export declare function isConstructor(func: any): func is new (...args: any) => any;
|
|
41
|
+
/** Merge two prototype chains while preserving descriptors from `proto1`. */
|
|
42
|
+
export declare function joinPrototype(proto1: {}, proto2: {}): any;
|
|
43
|
+
/** Return true for non-null objects and functions. */
|
|
44
|
+
export declare function isObject(value: any): value is {};
|
|
45
|
+
/** Find a property descriptor by walking an object's prototype chain. */
|
|
46
|
+
export declare function getPropertyDescriptor(target: any, prop: string | symbol): TypedPropertyDescriptor<any> | undefined;
|
|
47
|
+
/** Wrap services/functions so method calls see the caller's active context. */
|
|
48
|
+
export declare function getTraceable<T>(ctx: Context, value: T): T;
|
|
49
|
+
/** Return a proxy that overlays readonly or writable properties onto a target. */
|
|
50
|
+
export declare function withProps(target: any, props?: {}): any;
|
|
51
|
+
/** Create a callable service object that dispatches through `symbols.invoke`. */
|
|
52
|
+
export declare function createCallable(name: string, proto: {}, tracker: Tracker): any;
|
|
53
|
+
interface StackInfo {
|
|
54
|
+
offset: number;
|
|
55
|
+
error: Error;
|
|
56
|
+
}
|
|
57
|
+
/** Run a callback and splice outer call-site frames into thrown async errors. */
|
|
58
|
+
export declare function composeError<T>(callback: (info: StackInfo) => T, getOuterStack?: () => string[]): T;
|
|
59
|
+
/** Capture a lazy stack-frame supplier for later error composition. */
|
|
60
|
+
export declare function buildOuterStack(offset?: number): () => string[];
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAElD,2EAA2E;AAC3E,qBAAa,cAAc,CAAC,CAAC,SAAS,OAAO;IAC3C,OAAO,CAAC,EAAE,CAAI;IACd,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,IAAI,CAA2B;IAEvC,IAAI,MAAM,WAET;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;IAOb,MAAM,CAAC,KAAK,EAAE,CAAC;IAMf,KAAK;IAML,CAAC,MAAM,CAAC,QAAQ,CAAC;CAOlB;AAED,kFAAkF;AAClF,MAAM,WAAW,OAAO;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,oEAAoE;AACpE,eAAO,MAAM,OAAO;;;;;;;YAUqB,OAAO,OAAO,CAAC,MAAM;YACrB,OAAO,OAAO,CAAC,MAAM;a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