@lushly-dev/afd-server 1.0.0 → 2.1.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/README.md +297 -14
- package/dist/bootstrap/afd-context.d.ts +11 -2
- package/dist/bootstrap/afd-context.d.ts.map +1 -1
- package/dist/bootstrap/afd-context.js +56 -11
- package/dist/bootstrap/afd-context.js.map +1 -1
- package/dist/bootstrap/afd-docs.d.ts +6 -3
- package/dist/bootstrap/afd-docs.d.ts.map +1 -1
- package/dist/bootstrap/afd-docs.js +27 -9
- package/dist/bootstrap/afd-docs.js.map +1 -1
- package/dist/bootstrap/afd-help.d.ts +11 -3
- package/dist/bootstrap/afd-help.d.ts.map +1 -1
- package/dist/bootstrap/afd-help.js +15 -9
- package/dist/bootstrap/afd-help.js.map +1 -1
- package/dist/bootstrap/afd-schema.d.ts +8 -4
- package/dist/bootstrap/afd-schema.d.ts.map +1 -1
- package/dist/bootstrap/afd-schema.js +55 -42
- package/dist/bootstrap/afd-schema.js.map +1 -1
- package/dist/bootstrap/described-command.d.ts +35 -0
- package/dist/bootstrap/described-command.d.ts.map +1 -0
- package/dist/bootstrap/described-command.js +12 -0
- package/dist/bootstrap/described-command.js.map +1 -0
- package/dist/bootstrap/index.d.ts +1 -0
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/bootstrap/json-schema-to-ts.d.ts +27 -0
- package/dist/bootstrap/json-schema-to-ts.d.ts.map +1 -0
- package/dist/bootstrap/json-schema-to-ts.js +154 -0
- package/dist/bootstrap/json-schema-to-ts.js.map +1 -0
- package/dist/bootstrap/registry.d.ts +17 -6
- package/dist/bootstrap/registry.d.ts.map +1 -1
- package/dist/bootstrap/registry.js +29 -5
- package/dist/bootstrap/registry.js.map +1 -1
- package/dist/command-names.d.ts +19 -0
- package/dist/command-names.d.ts.map +1 -0
- package/dist/command-names.js +33 -0
- package/dist/command-names.js.map +1 -0
- package/dist/command-routing.d.ts +47 -0
- package/dist/command-routing.d.ts.map +1 -0
- package/dist/command-routing.js +75 -0
- package/dist/command-routing.js.map +1 -0
- package/dist/context-scope.d.ts +26 -0
- package/dist/context-scope.d.ts.map +1 -0
- package/dist/context-scope.js +31 -0
- package/dist/context-scope.js.map +1 -0
- package/dist/define.d.ts +42 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +41 -0
- package/dist/define.js.map +1 -0
- package/dist/direct-registry.d.ts +104 -0
- package/dist/direct-registry.d.ts.map +1 -0
- package/dist/direct-registry.js +103 -0
- package/dist/direct-registry.js.map +1 -0
- package/dist/execution.d.ts +9 -0
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +105 -321
- package/dist/execution.js.map +1 -1
- package/dist/http-handler.d.ts +24 -17
- package/dist/http-handler.d.ts.map +1 -1
- package/dist/http-handler.js +283 -252
- package/dist/http-handler.js.map +1 -1
- package/dist/http-security.d.ts +23 -0
- package/dist/http-security.d.ts.map +1 -0
- package/dist/http-security.js +101 -0
- package/dist/http-security.js.map +1 -0
- package/dist/http-sessions.d.ts +33 -0
- package/dist/http-sessions.d.ts.map +1 -0
- package/dist/http-sessions.js +65 -0
- package/dist/http-sessions.js.map +1 -0
- package/dist/http-sse.d.ts +30 -0
- package/dist/http-sse.d.ts.map +1 -0
- package/dist/http-sse.js +70 -0
- package/dist/http-sse.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/json-rpc.d.ts +56 -0
- package/dist/json-rpc.d.ts.map +1 -0
- package/dist/json-rpc.js +73 -0
- package/dist/json-rpc.js.map +1 -0
- package/dist/lazy-tools.d.ts +3 -12
- package/dist/lazy-tools.d.ts.map +1 -1
- package/dist/lazy-tools.js +10 -14
- package/dist/lazy-tools.js.map +1 -1
- package/dist/meta-tools.d.ts +116 -0
- package/dist/meta-tools.d.ts.map +1 -0
- package/dist/meta-tools.js +154 -0
- package/dist/meta-tools.js.map +1 -0
- package/dist/middleware.d.ts +34 -7
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +82 -40
- package/dist/middleware.js.map +1 -1
- package/dist/schema.d.ts +34 -6
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +22 -13
- package/dist/schema.js.map +1 -1
- package/dist/server-types.d.ts +90 -14
- package/dist/server-types.d.ts.map +1 -1
- package/dist/server-types.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +103 -21
- package/dist/server.js.map +1 -1
- package/dist/tool-router.d.ts +6 -5
- package/dist/tool-router.d.ts.map +1 -1
- package/dist/tool-router.js +105 -139
- package/dist/tool-router.js.map +1 -1
- package/dist/tools.d.ts +10 -420
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +82 -208
- package/dist/tools.js.map +1 -1
- package/package.json +13 -8
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Validating in-process registry for `DirectClient`.
|
|
3
|
+
*
|
|
4
|
+
* `createDirectRegistry()` runs commands through the same execution engine as
|
|
5
|
+
* `createMcpServer()`: Zod input validation, middleware, error sanitization and
|
|
6
|
+
* `onCommand`/`onError` hooks. It only lists and runs the commands exposed to
|
|
7
|
+
* one interface, `'agent'` by default.
|
|
8
|
+
*/
|
|
9
|
+
import type { CommandContext, CommandMiddleware, CommandResult, ExposeOptions, JsonSchema } from '@lushly-dev/afd-core';
|
|
10
|
+
import type { ZodCommandDefinition } from './schema.js';
|
|
11
|
+
/** An interface a command can be exposed to (`palette`, `mcp`, `agent`, `cli`). */
|
|
12
|
+
export type ExposeInterface = keyof ExposeOptions;
|
|
13
|
+
/**
|
|
14
|
+
* Options for {@link createDirectRegistry}.
|
|
15
|
+
*/
|
|
16
|
+
export interface DirectRegistryOptions {
|
|
17
|
+
/**
|
|
18
|
+
* The interface this registry serves. Only commands exposed to it are
|
|
19
|
+
* listed and executable. Default: `'agent'`, the in-app AI assistant.
|
|
20
|
+
*/
|
|
21
|
+
interface?: ExposeInterface;
|
|
22
|
+
/** Middleware applied to every command, in onion order (same as `createMcpServer`). */
|
|
23
|
+
middleware?: CommandMiddleware[];
|
|
24
|
+
/**
|
|
25
|
+
* Include exception messages and stacks in failures. Default: `false`, which
|
|
26
|
+
* returns a generic `COMMAND_EXECUTION_ERROR` message instead.
|
|
27
|
+
*/
|
|
28
|
+
devMode?: boolean;
|
|
29
|
+
/** Called after each command completes. A throwing hook never changes the result. */
|
|
30
|
+
onCommand?: (command: string, input: unknown, result: CommandResult) => void;
|
|
31
|
+
/** Called when a handler or input validation throws. */
|
|
32
|
+
onError?: (error: Error) => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Summary of a command the registry exposes, for building tool declarations.
|
|
36
|
+
*/
|
|
37
|
+
export interface DirectRegistryCommand {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
category?: string;
|
|
41
|
+
mutation?: boolean;
|
|
42
|
+
destructive?: boolean;
|
|
43
|
+
undoable?: boolean;
|
|
44
|
+
/** JSON Schema of the command input. */
|
|
45
|
+
inputSchema: JsonSchema;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A validating command registry. Structurally compatible with the
|
|
49
|
+
* `DirectRegistry` interface of `@lushly-dev/afd-client`, so it can be passed
|
|
50
|
+
* straight to `createDirectClient()` or `new DirectClient()`.
|
|
51
|
+
*/
|
|
52
|
+
export interface DirectCommandRegistry {
|
|
53
|
+
/** The interface this registry serves. */
|
|
54
|
+
readonly interface: ExposeInterface;
|
|
55
|
+
/**
|
|
56
|
+
* Validate the input with the command's Zod schema, then run the command
|
|
57
|
+
* through the middleware. Returns `COMMAND_NOT_FOUND` for unknown names,
|
|
58
|
+
* `COMMAND_NOT_EXPOSED` for commands not exposed to this interface and
|
|
59
|
+
* `VALIDATION_ERROR` for invalid input; the handler does not run for any of them.
|
|
60
|
+
*/
|
|
61
|
+
execute<T>(name: string, input?: unknown, context?: CommandContext): Promise<CommandResult<T>>;
|
|
62
|
+
/** Names of the commands exposed to this interface. */
|
|
63
|
+
listCommandNames(): string[];
|
|
64
|
+
/** Commands exposed to this interface, with their input schemas. */
|
|
65
|
+
listCommands(): DirectRegistryCommand[];
|
|
66
|
+
/** Whether a command is registered and exposed to this interface. */
|
|
67
|
+
hasCommand(name: string): boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Whether a command is exposed to an interface. Each flag the command's
|
|
71
|
+
* `expose` leaves out falls back to `defaultExpose`, so `expose: { mcp: true }`
|
|
72
|
+
* keeps the default `agent` and `palette` access. Set `agent: false` to keep a
|
|
73
|
+
* command away from in-app agents.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isExposedTo(command: Pick<ZodCommandDefinition, 'expose'>, iface: ExposeInterface): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Create a validating in-process registry for `DirectClient`.
|
|
78
|
+
*
|
|
79
|
+
* Unlike a hand-written registry that calls `command.handler(input)`, this
|
|
80
|
+
* registry validates input with the command's Zod schema (rejecting wrong
|
|
81
|
+
* types, nested objects and unknown shapes before the handler runs), applies
|
|
82
|
+
* middleware, hides exception details outside `devMode`, and refuses commands
|
|
83
|
+
* that are not exposed to the chosen interface.
|
|
84
|
+
*
|
|
85
|
+
* @param commands - Commands created with `defineCommand()`
|
|
86
|
+
* @param options - Interface, middleware and hooks
|
|
87
|
+
* @throws If two commands share a name
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* import { createDirectClient } from '@lushly-dev/afd-client';
|
|
92
|
+
* import { createDirectRegistry, createLoggingMiddleware } from '@lushly-dev/afd-server';
|
|
93
|
+
*
|
|
94
|
+
* const registry = createDirectRegistry(commands, {
|
|
95
|
+
* middleware: [createLoggingMiddleware()],
|
|
96
|
+
* });
|
|
97
|
+
* const client = createDirectClient(registry);
|
|
98
|
+
*
|
|
99
|
+
* await client.call('todo-create', { title: { nested: true } });
|
|
100
|
+
* // → { success: false, error: { code: 'VALIDATION_ERROR', ... } }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function createDirectRegistry(commands: ZodCommandDefinition[], options?: DirectRegistryOptions): DirectCommandRegistry;
|
|
104
|
+
//# sourceMappingURL=direct-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direct-registry.d.ts","sourceRoot":"","sources":["../src/direct-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACX,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,UAAU,EACV,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,mFAAmF;AACnF,MAAM,MAAM,eAAe,GAAG,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;OAGG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B,uFAAuF;IACvF,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEjC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,qFAAqF;IACrF,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAE7E,wDAAwD;IACxD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wCAAwC;IACxC,WAAW,EAAE,UAAU,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IAEpC;;;;;OAKG;IACH,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/F,uDAAuD;IACvD,gBAAgB,IAAI,MAAM,EAAE,CAAC;IAE7B,oEAAoE;IACpE,YAAY,IAAI,qBAAqB,EAAE,CAAC;IAExC,qEAAqE;IACrE,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAClC;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAC1B,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,EAC7C,KAAK,EAAE,eAAe,GACpB,OAAO,CAET;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CACnC,QAAQ,EAAE,oBAAoB,EAAE,EAChC,OAAO,GAAE,qBAA0B,GACjC,qBAAqB,CAoEvB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Validating in-process registry for `DirectClient`.
|
|
3
|
+
*
|
|
4
|
+
* `createDirectRegistry()` runs commands through the same execution engine as
|
|
5
|
+
* `createMcpServer()`: Zod input validation, middleware, error sanitization and
|
|
6
|
+
* `onCommand`/`onError` hooks. It only lists and runs the commands exposed to
|
|
7
|
+
* one interface, `'agent'` by default.
|
|
8
|
+
*/
|
|
9
|
+
import { failure, isExposedTo as isCoreExposedTo } from '@lushly-dev/afd-core';
|
|
10
|
+
import { createExecutionEngine } from './execution.js';
|
|
11
|
+
/**
|
|
12
|
+
* Whether a command is exposed to an interface. Each flag the command's
|
|
13
|
+
* `expose` leaves out falls back to `defaultExpose`, so `expose: { mcp: true }`
|
|
14
|
+
* keeps the default `agent` and `palette` access. Set `agent: false` to keep a
|
|
15
|
+
* command away from in-app agents.
|
|
16
|
+
*/
|
|
17
|
+
export function isExposedTo(command, iface) {
|
|
18
|
+
return isCoreExposedTo(command, iface);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a validating in-process registry for `DirectClient`.
|
|
22
|
+
*
|
|
23
|
+
* Unlike a hand-written registry that calls `command.handler(input)`, this
|
|
24
|
+
* registry validates input with the command's Zod schema (rejecting wrong
|
|
25
|
+
* types, nested objects and unknown shapes before the handler runs), applies
|
|
26
|
+
* middleware, hides exception details outside `devMode`, and refuses commands
|
|
27
|
+
* that are not exposed to the chosen interface.
|
|
28
|
+
*
|
|
29
|
+
* @param commands - Commands created with `defineCommand()`
|
|
30
|
+
* @param options - Interface, middleware and hooks
|
|
31
|
+
* @throws If two commands share a name
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* import { createDirectClient } from '@lushly-dev/afd-client';
|
|
36
|
+
* import { createDirectRegistry, createLoggingMiddleware } from '@lushly-dev/afd-server';
|
|
37
|
+
*
|
|
38
|
+
* const registry = createDirectRegistry(commands, {
|
|
39
|
+
* middleware: [createLoggingMiddleware()],
|
|
40
|
+
* });
|
|
41
|
+
* const client = createDirectClient(registry);
|
|
42
|
+
*
|
|
43
|
+
* await client.call('todo-create', { title: { nested: true } });
|
|
44
|
+
* // → { success: false, error: { code: 'VALIDATION_ERROR', ... } }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function createDirectRegistry(commands, options = {}) {
|
|
48
|
+
const iface = options.interface ?? 'agent';
|
|
49
|
+
const registered = new Map();
|
|
50
|
+
for (const command of commands) {
|
|
51
|
+
if (registered.has(command.name)) {
|
|
52
|
+
throw new Error(`Duplicate command name: ${command.name}`);
|
|
53
|
+
}
|
|
54
|
+
registered.set(command.name, command);
|
|
55
|
+
}
|
|
56
|
+
const exposed = new Map([...registered].filter(([, command]) => isExposedTo(command, iface)));
|
|
57
|
+
const engine = createExecutionEngine({
|
|
58
|
+
commandMap: exposed,
|
|
59
|
+
middleware: options.middleware ?? [],
|
|
60
|
+
devMode: options.devMode ?? false,
|
|
61
|
+
onCommand: options.onCommand,
|
|
62
|
+
onError: options.onError,
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
interface: iface,
|
|
66
|
+
async execute(name, input = {}, context = {}) {
|
|
67
|
+
if (!exposed.has(name) && registered.has(name)) {
|
|
68
|
+
const available = [...exposed.keys()];
|
|
69
|
+
return failure({
|
|
70
|
+
code: 'COMMAND_NOT_EXPOSED',
|
|
71
|
+
message: `Command '${name}' is not exposed to ${iface}`,
|
|
72
|
+
suggestion: available.length > 0
|
|
73
|
+
? `Use one of the commands exposed to ${iface}: ${available.join(', ')}`
|
|
74
|
+
: `No commands are exposed to ${iface}; set expose.${iface} on the commands it should call`,
|
|
75
|
+
retryable: false,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// SAFETY: T is the caller's assertion about the command's data, as in DirectRegistry.
|
|
79
|
+
return (await engine.executeCommand(name, input, {
|
|
80
|
+
...context,
|
|
81
|
+
interface: iface,
|
|
82
|
+
}));
|
|
83
|
+
},
|
|
84
|
+
listCommandNames() {
|
|
85
|
+
return [...exposed.keys()];
|
|
86
|
+
},
|
|
87
|
+
listCommands() {
|
|
88
|
+
return [...exposed.values()].map((command) => ({
|
|
89
|
+
name: command.name,
|
|
90
|
+
description: command.description,
|
|
91
|
+
category: command.category,
|
|
92
|
+
mutation: command.mutation,
|
|
93
|
+
destructive: command.destructive,
|
|
94
|
+
undoable: command.undoable,
|
|
95
|
+
inputSchema: command.jsonSchema,
|
|
96
|
+
}));
|
|
97
|
+
},
|
|
98
|
+
hasCommand(name) {
|
|
99
|
+
return exposed.has(name);
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=direct-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direct-registry.js","sourceRoot":"","sources":["../src/direct-registry.ts"],"names":[],"mappings":"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"}
|
package/dist/execution.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Command execution engine — single, batch, pipeline, and streaming execution.
|
|
3
|
+
*
|
|
4
|
+
* Single commands run here (validation, context, middleware, hooks). Batch,
|
|
5
|
+
* pipeline and stream execution delegate to the core executors
|
|
6
|
+
* (`executeBatch`, `executePipeline`, `executeStream`) with this engine's
|
|
7
|
+
* `executeCommand` as the callback, so their semantics are shared with the
|
|
8
|
+
* core registry and DirectClient.
|
|
3
9
|
*/
|
|
4
10
|
import type { BatchRequest, BatchResult, CommandContext, CommandMiddleware, CommandResult, PipelineRequest, PipelineResult, StreamChunk } from '@lushly-dev/afd-core';
|
|
11
|
+
import type { ContextState } from './bootstrap/afd-context.js';
|
|
5
12
|
import type { ZodCommandDefinition } from './schema.js';
|
|
6
13
|
export interface ExecutionDeps {
|
|
7
14
|
commandMap: Map<string, ZodCommandDefinition>;
|
|
8
15
|
middleware: CommandMiddleware[];
|
|
16
|
+
/** Context state used when the command context carries none (stdio). */
|
|
17
|
+
contextState?: ContextState;
|
|
9
18
|
devMode: boolean;
|
|
10
19
|
onCommand?: (command: string, input: unknown, result: CommandResult) => void;
|
|
11
20
|
onError?: (error: Error) => void;
|
package/dist/execution.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../src/execution.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACX,YAAY,EACZ,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,cAAc,EACd,WAAW,EACX,MAAM,sBAAsB,CAAC;AAS9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAQ/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAQxD,MAAM,WAAW,aAAa;IAC7B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC9C,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,wEAAwE;IACxE,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7E,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC;AAuBD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa;kCAe1C,MAAM,SACZ,OAAO,YACL,cAAc,KACrB,OAAO,CAAC,aAAa,CAAC;4BA0GM,YAAY,YAAW,cAAc,KAAQ,OAAO,CAAC,WAAW,CAAC;+BAStF,eAAe,YACf,cAAc,KACrB,OAAO,CAAC,cAAc,CAAC;iCAyBZ,MAAM,SACZ,OAAO,YACL,cAAc,KACrB,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC;EAK7C"}
|