@pixerate/editor 0.22.0 → 0.23.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 +80 -2
- package/THIRD_PARTY_NOTICES.md +88 -0
- package/dist/agent/index.cjs +83 -108
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +69 -211
- package/dist/agent/index.d.ts +69 -211
- package/dist/agent/index.js +76 -101
- package/dist/agent/index.js.map +1 -1
- package/dist/arrangeShortcuts-B8O3f8-P.d.cts +184 -0
- package/dist/arrangeShortcuts-sLlD2rSX.d.ts +184 -0
- package/dist/canvas/index.cjs +879 -83
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +291 -186
- package/dist/canvas/index.d.ts +291 -186
- package/dist/canvas/index.js +865 -69
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-26BVFKHU.cjs +453 -0
- package/dist/chunk-26BVFKHU.cjs.map +1 -0
- package/dist/chunk-2H7ZHPEJ.js +762 -0
- package/dist/chunk-2H7ZHPEJ.js.map +1 -0
- package/dist/chunk-7DWMJCAT.js +453 -0
- package/dist/chunk-7DWMJCAT.js.map +1 -0
- package/dist/chunk-ARRTP33I.js +101 -0
- package/dist/chunk-ARRTP33I.js.map +1 -0
- package/dist/chunk-CPOKFNBG.cjs +101 -0
- package/dist/chunk-CPOKFNBG.cjs.map +1 -0
- package/dist/chunk-G2I4QJOT.cjs +762 -0
- package/dist/chunk-G2I4QJOT.cjs.map +1 -0
- package/dist/{chunk-RU52I7QO.js → chunk-K3R5NG2D.js} +147 -42
- package/dist/chunk-K3R5NG2D.js.map +1 -0
- package/dist/{chunk-DENSCKFC.js → chunk-QBJ22YZR.js} +423 -30
- package/dist/chunk-QBJ22YZR.js.map +1 -0
- package/dist/{chunk-SAZRENEZ.cjs → chunk-RIKBJLS2.cjs} +424 -31
- package/dist/chunk-RIKBJLS2.cjs.map +1 -0
- package/dist/{chunk-6M3BCTBD.cjs → chunk-XDMXXC4Z.cjs} +230 -125
- package/dist/chunk-XDMXXC4Z.cjs.map +1 -0
- package/dist/commands/index.cjs +860 -0
- package/dist/commands/index.cjs.map +1 -0
- package/dist/commands/index.d.cts +592 -0
- package/dist/commands/index.d.ts +592 -0
- package/dist/commands/index.js +860 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/{controller-B7GIybc4.d.cts → controller-pePCJLT1.d.cts} +78 -5
- package/dist/{controller-B7GIybc4.d.ts → controller-pePCJLT1.d.ts} +78 -5
- package/dist/history/index.cjs +12 -2
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +211 -7
- package/dist/history/index.d.ts +211 -7
- package/dist/history/index.js +13 -3
- package/dist/image-editor/index.cjs +418 -13
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +154 -3
- package/dist/image-editor/index.d.ts +154 -3
- package/dist/image-editor/index.js +417 -12
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +34 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -42
- package/dist/index.d.ts +5 -42
- package/dist/index.js +27 -69
- package/dist/index.js.map +1 -1
- package/dist/registry-D5-R90p0.d.cts +209 -0
- package/dist/registry-D5-R90p0.d.ts +209 -0
- package/dist/spreadsheet/index.cjs +19 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +67 -9
- package/dist/spreadsheet/index.d.ts +67 -9
- package/dist/spreadsheet/index.js +18 -2
- package/dist/{types-CJ4U-HHI.d.cts → types-DX4Mh4SL.d.cts} +1 -1
- package/dist/{types-CJ4U-HHI.d.ts → types-DX4Mh4SL.d.ts} +1 -1
- package/dist/types-GT5a5YAX.d.cts +86 -0
- package/dist/types-GT5a5YAX.d.ts +86 -0
- package/package.json +8 -2
- package/dist/chunk-2TWGLC5K.cjs +0 -262
- package/dist/chunk-2TWGLC5K.cjs.map +0 -1
- package/dist/chunk-6M3BCTBD.cjs.map +0 -1
- package/dist/chunk-DENSCKFC.js.map +0 -1
- package/dist/chunk-KAADNAPF.js +0 -262
- package/dist/chunk-KAADNAPF.js.map +0 -1
- package/dist/chunk-RU52I7QO.js.map +0 -1
- package/dist/chunk-SAZRENEZ.cjs.map +0 -1
- package/dist/types-BZgcDsC5.d.cts +0 -42
- package/dist/types-BZgcDsC5.d.ts +0 -42
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-Schema-lite: the subset of JSON Schema used by MCP tool `inputSchema`s,
|
|
3
|
+
* plus a small validator for tool-call arguments. Unknown keywords are ignored.
|
|
4
|
+
*/
|
|
5
|
+
type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
6
|
+
interface JsonSchema {
|
|
7
|
+
type?: JsonSchemaType | readonly JsonSchemaType[];
|
|
8
|
+
description?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
enum?: readonly unknown[];
|
|
11
|
+
const?: unknown;
|
|
12
|
+
default?: unknown;
|
|
13
|
+
properties?: {
|
|
14
|
+
readonly [key: string]: JsonSchema;
|
|
15
|
+
};
|
|
16
|
+
required?: readonly string[];
|
|
17
|
+
additionalProperties?: boolean | JsonSchema;
|
|
18
|
+
items?: JsonSchema;
|
|
19
|
+
minItems?: number;
|
|
20
|
+
maxItems?: number;
|
|
21
|
+
minimum?: number;
|
|
22
|
+
maximum?: number;
|
|
23
|
+
minLength?: number;
|
|
24
|
+
maxLength?: number;
|
|
25
|
+
pattern?: string;
|
|
26
|
+
[keyword: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
interface SchemaValidationError {
|
|
29
|
+
/** JSON-pointer-like path to the offending value, e.g. `/node/id` (`""` is the root). */
|
|
30
|
+
path: string;
|
|
31
|
+
message: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Validates `value` against `schema` and returns every error found (an empty
|
|
35
|
+
* array means valid). Supports `type` (incl. arrays of types), `enum`, `const`,
|
|
36
|
+
* `properties`, `required`, `additionalProperties`, `items`, `minItems`,
|
|
37
|
+
* `maxItems`, `minimum`, `maximum`, `minLength`, `maxLength` and `pattern`.
|
|
38
|
+
*/
|
|
39
|
+
declare function validateJsonSchema(value: unknown, schema: JsonSchema | undefined, path?: string): SchemaValidationError[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* MCP-shaped tool definition, as returned by `tools/list`.
|
|
43
|
+
*/
|
|
44
|
+
interface McpToolDefinition {
|
|
45
|
+
name: string;
|
|
46
|
+
title?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
inputSchema: JsonSchema & {
|
|
49
|
+
type: 'object';
|
|
50
|
+
};
|
|
51
|
+
outputSchema?: JsonSchema;
|
|
52
|
+
annotations?: {
|
|
53
|
+
title?: string;
|
|
54
|
+
readOnlyHint?: boolean;
|
|
55
|
+
destructiveHint?: boolean;
|
|
56
|
+
idempotentHint?: boolean;
|
|
57
|
+
openWorldHint?: boolean;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
type McpToolContent = {
|
|
62
|
+
type: 'text';
|
|
63
|
+
text: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'image';
|
|
66
|
+
data: string;
|
|
67
|
+
mimeType: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: string;
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
};
|
|
72
|
+
/** MCP `tools/call` result. */
|
|
73
|
+
interface McpToolResult {
|
|
74
|
+
content: McpToolContent[];
|
|
75
|
+
structuredContent?: Record<string, unknown>;
|
|
76
|
+
isError?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/** MCP `tools/list` result. */
|
|
79
|
+
interface McpListToolsResult {
|
|
80
|
+
tools: McpToolDefinition[];
|
|
81
|
+
}
|
|
82
|
+
interface ToolCallContext {
|
|
83
|
+
/** Name the tool was called by (possibly namespaced). */
|
|
84
|
+
name: string;
|
|
85
|
+
/** Id of the provider that owns the tool. */
|
|
86
|
+
providerId: string;
|
|
87
|
+
signal?: AbortSignal;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Handler return values are normalized into an {@link McpToolResult}: a full
|
|
91
|
+
* result (`{ content: [...] }`) is passed through, a string becomes a text
|
|
92
|
+
* block, `undefined` becomes an empty result, and anything else is returned
|
|
93
|
+
* as `structuredContent` (plain objects) plus a JSON text block.
|
|
94
|
+
*/
|
|
95
|
+
type AgentToolHandler = (args: Record<string, any>, context: ToolCallContext) => unknown | Promise<unknown>;
|
|
96
|
+
interface AgentTool extends McpToolDefinition {
|
|
97
|
+
handler: AgentToolHandler;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A source of tools, typically one per mounted editor, spreadsheet or canvas.
|
|
101
|
+
*/
|
|
102
|
+
interface AgentToolProvider {
|
|
103
|
+
/** Unique id within a registry, e.g. `doc-1`. Used as the namespace on collisions. */
|
|
104
|
+
id: string;
|
|
105
|
+
/** Always prefix this provider's tools with `<namespace>__`. */
|
|
106
|
+
namespace?: string;
|
|
107
|
+
/** Tools, or a function returning the current tools (re-read on every `listTools`). */
|
|
108
|
+
tools: readonly AgentTool[] | (() => readonly AgentTool[]);
|
|
109
|
+
/** Lets the provider signal that its tool list changed; returns an unsubscribe function. */
|
|
110
|
+
subscribe?: (notify: () => void) => () => void;
|
|
111
|
+
}
|
|
112
|
+
type ToolErrorCode = 'unknown_tool' | 'invalid_arguments' | 'tool_failed';
|
|
113
|
+
/** Structured error carried in `structuredContent.error` of a failed call. */
|
|
114
|
+
interface ToolCallError {
|
|
115
|
+
code: ToolErrorCode;
|
|
116
|
+
message: string;
|
|
117
|
+
tool: string;
|
|
118
|
+
details?: SchemaValidationError[];
|
|
119
|
+
}
|
|
120
|
+
declare class ToolRegistryError extends Error {
|
|
121
|
+
readonly code: 'duplicate_provider' | 'name_collision' | 'invalid_tool';
|
|
122
|
+
constructor(code: ToolRegistryError['code'], message: string);
|
|
123
|
+
}
|
|
124
|
+
interface ToolRegistryOptions {
|
|
125
|
+
/**
|
|
126
|
+
* What to do when two providers contribute the same tool name:
|
|
127
|
+
* `namespace` (default) exposes every colliding tool as `<providerId>__<name>`;
|
|
128
|
+
* `error` makes `register` throw.
|
|
129
|
+
*/
|
|
130
|
+
onCollision?: 'namespace' | 'error';
|
|
131
|
+
/** Coalescing window for `listChanged` notifications in ms (default 0: same tick). */
|
|
132
|
+
listChangedDelayMs?: number;
|
|
133
|
+
/** Validate arguments against `inputSchema` before calling handlers (default `true`). */
|
|
134
|
+
validateArguments?: boolean;
|
|
135
|
+
}
|
|
136
|
+
/** Separator between namespace and tool name; valid in MCP and LLM tool-name charsets. */
|
|
137
|
+
declare const TOOL_NAMESPACE_SEPARATOR = "__";
|
|
138
|
+
/** Normalizes a handler's return value into an MCP `tools/call` result. */
|
|
139
|
+
declare function toToolResult(value: unknown): McpToolResult;
|
|
140
|
+
/**
|
|
141
|
+
* Transport-agnostic registry of agent tools contributed by live providers.
|
|
142
|
+
*
|
|
143
|
+
* `listTools()` and `callTool()` return MCP `tools/list` / `tools/call`
|
|
144
|
+
* result shapes, and `onListChanged` fires (coalesced) whenever the exposed
|
|
145
|
+
* tool list changes, mirroring MCP's `notifications/tools/list_changed`, so an
|
|
146
|
+
* MCP server can be a thin wrapper around it.
|
|
147
|
+
*/
|
|
148
|
+
declare class ToolRegistry {
|
|
149
|
+
/** MCP server capabilities this registry supports. */
|
|
150
|
+
readonly capabilities: {
|
|
151
|
+
readonly tools: {
|
|
152
|
+
readonly listChanged: true;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
private readonly entries;
|
|
156
|
+
private readonly listeners;
|
|
157
|
+
private readonly options;
|
|
158
|
+
private timer;
|
|
159
|
+
private lastSignature;
|
|
160
|
+
constructor(options?: ToolRegistryOptions);
|
|
161
|
+
/**
|
|
162
|
+
* Registers a provider and returns a function that unregisters it.
|
|
163
|
+
* Throws a {@link ToolRegistryError} for a duplicate provider id, an invalid
|
|
164
|
+
* tool name, or (with `onCollision: 'error'`) a tool name collision.
|
|
165
|
+
*/
|
|
166
|
+
register(provider: AgentToolProvider): () => void;
|
|
167
|
+
/** Removes a provider by id or instance. Returns whether it was registered. */
|
|
168
|
+
unregister(providerOrId: string | AgentToolProvider): boolean;
|
|
169
|
+
/** Registered provider ids in registration order. */
|
|
170
|
+
providerIds(): string[];
|
|
171
|
+
/**
|
|
172
|
+
* Resolves exposed names. Tools are ordered by provider registration, then
|
|
173
|
+
* by their order within the provider.
|
|
174
|
+
*/
|
|
175
|
+
private resolve;
|
|
176
|
+
/** MCP `tools/list` result for the current providers. */
|
|
177
|
+
listTools(): McpListToolsResult;
|
|
178
|
+
/** Whether a tool with this exposed name exists. */
|
|
179
|
+
hasTool(name: string): boolean;
|
|
180
|
+
/** Looks up a tool definition by exposed name. */
|
|
181
|
+
getTool(name: string): McpToolDefinition | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Calls a tool by exposed name and returns an MCP `tools/call` result.
|
|
184
|
+
* Never rejects: unknown tools, invalid arguments and handler errors come
|
|
185
|
+
* back as `isError: true` results with a {@link ToolCallError} in
|
|
186
|
+
* `structuredContent.error` (MCP transports may map `unknown_tool` to a
|
|
187
|
+
* JSON-RPC `-32602` error instead).
|
|
188
|
+
*/
|
|
189
|
+
callTool(name: string, args?: Record<string, unknown>, options?: {
|
|
190
|
+
signal?: AbortSignal;
|
|
191
|
+
}): Promise<McpToolResult>;
|
|
192
|
+
/**
|
|
193
|
+
* Subscribes to tool-list changes. Notifications are coalesced: many
|
|
194
|
+
* registrations or provider signals within the delay window produce one
|
|
195
|
+
* call, and none if the exposed list ends up unchanged (e.g. a provider
|
|
196
|
+
* unmounted and remounted). Returns an unsubscribe function.
|
|
197
|
+
*/
|
|
198
|
+
onListChanged(listener: (tools: McpToolDefinition[]) => void): () => void;
|
|
199
|
+
/** Schedules a coalesced `listChanged` check; providers may call it directly. */
|
|
200
|
+
notifyListChanged(): void;
|
|
201
|
+
/** Runs a pending `listChanged` check immediately. */
|
|
202
|
+
flush(): void;
|
|
203
|
+
private signature;
|
|
204
|
+
/** Unregisters every provider and listener and cancels pending notifications. */
|
|
205
|
+
dispose(): void;
|
|
206
|
+
}
|
|
207
|
+
declare function createToolRegistry(options?: ToolRegistryOptions): ToolRegistry;
|
|
208
|
+
|
|
209
|
+
export { type AgentToolProvider as A, type JsonSchema as J, type McpListToolsResult as M, type SchemaValidationError as S, TOOL_NAMESPACE_SEPARATOR as T, type AgentTool as a, type AgentToolHandler as b, type JsonSchemaType as c, type McpToolContent as d, type McpToolDefinition as e, type McpToolResult as f, type ToolCallContext as g, type ToolCallError as h, type ToolErrorCode as i, ToolRegistry as j, ToolRegistryError as k, type ToolRegistryOptions as l, createToolRegistry as m, toToolResult as t, validateJsonSchema as v };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON-Schema-lite: the subset of JSON Schema used by MCP tool `inputSchema`s,
|
|
3
|
+
* plus a small validator for tool-call arguments. Unknown keywords are ignored.
|
|
4
|
+
*/
|
|
5
|
+
type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
|
|
6
|
+
interface JsonSchema {
|
|
7
|
+
type?: JsonSchemaType | readonly JsonSchemaType[];
|
|
8
|
+
description?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
enum?: readonly unknown[];
|
|
11
|
+
const?: unknown;
|
|
12
|
+
default?: unknown;
|
|
13
|
+
properties?: {
|
|
14
|
+
readonly [key: string]: JsonSchema;
|
|
15
|
+
};
|
|
16
|
+
required?: readonly string[];
|
|
17
|
+
additionalProperties?: boolean | JsonSchema;
|
|
18
|
+
items?: JsonSchema;
|
|
19
|
+
minItems?: number;
|
|
20
|
+
maxItems?: number;
|
|
21
|
+
minimum?: number;
|
|
22
|
+
maximum?: number;
|
|
23
|
+
minLength?: number;
|
|
24
|
+
maxLength?: number;
|
|
25
|
+
pattern?: string;
|
|
26
|
+
[keyword: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
interface SchemaValidationError {
|
|
29
|
+
/** JSON-pointer-like path to the offending value, e.g. `/node/id` (`""` is the root). */
|
|
30
|
+
path: string;
|
|
31
|
+
message: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Validates `value` against `schema` and returns every error found (an empty
|
|
35
|
+
* array means valid). Supports `type` (incl. arrays of types), `enum`, `const`,
|
|
36
|
+
* `properties`, `required`, `additionalProperties`, `items`, `minItems`,
|
|
37
|
+
* `maxItems`, `minimum`, `maximum`, `minLength`, `maxLength` and `pattern`.
|
|
38
|
+
*/
|
|
39
|
+
declare function validateJsonSchema(value: unknown, schema: JsonSchema | undefined, path?: string): SchemaValidationError[];
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* MCP-shaped tool definition, as returned by `tools/list`.
|
|
43
|
+
*/
|
|
44
|
+
interface McpToolDefinition {
|
|
45
|
+
name: string;
|
|
46
|
+
title?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
inputSchema: JsonSchema & {
|
|
49
|
+
type: 'object';
|
|
50
|
+
};
|
|
51
|
+
outputSchema?: JsonSchema;
|
|
52
|
+
annotations?: {
|
|
53
|
+
title?: string;
|
|
54
|
+
readOnlyHint?: boolean;
|
|
55
|
+
destructiveHint?: boolean;
|
|
56
|
+
idempotentHint?: boolean;
|
|
57
|
+
openWorldHint?: boolean;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
type McpToolContent = {
|
|
62
|
+
type: 'text';
|
|
63
|
+
text: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: 'image';
|
|
66
|
+
data: string;
|
|
67
|
+
mimeType: string;
|
|
68
|
+
} | {
|
|
69
|
+
type: string;
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
};
|
|
72
|
+
/** MCP `tools/call` result. */
|
|
73
|
+
interface McpToolResult {
|
|
74
|
+
content: McpToolContent[];
|
|
75
|
+
structuredContent?: Record<string, unknown>;
|
|
76
|
+
isError?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/** MCP `tools/list` result. */
|
|
79
|
+
interface McpListToolsResult {
|
|
80
|
+
tools: McpToolDefinition[];
|
|
81
|
+
}
|
|
82
|
+
interface ToolCallContext {
|
|
83
|
+
/** Name the tool was called by (possibly namespaced). */
|
|
84
|
+
name: string;
|
|
85
|
+
/** Id of the provider that owns the tool. */
|
|
86
|
+
providerId: string;
|
|
87
|
+
signal?: AbortSignal;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Handler return values are normalized into an {@link McpToolResult}: a full
|
|
91
|
+
* result (`{ content: [...] }`) is passed through, a string becomes a text
|
|
92
|
+
* block, `undefined` becomes an empty result, and anything else is returned
|
|
93
|
+
* as `structuredContent` (plain objects) plus a JSON text block.
|
|
94
|
+
*/
|
|
95
|
+
type AgentToolHandler = (args: Record<string, any>, context: ToolCallContext) => unknown | Promise<unknown>;
|
|
96
|
+
interface AgentTool extends McpToolDefinition {
|
|
97
|
+
handler: AgentToolHandler;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A source of tools, typically one per mounted editor, spreadsheet or canvas.
|
|
101
|
+
*/
|
|
102
|
+
interface AgentToolProvider {
|
|
103
|
+
/** Unique id within a registry, e.g. `doc-1`. Used as the namespace on collisions. */
|
|
104
|
+
id: string;
|
|
105
|
+
/** Always prefix this provider's tools with `<namespace>__`. */
|
|
106
|
+
namespace?: string;
|
|
107
|
+
/** Tools, or a function returning the current tools (re-read on every `listTools`). */
|
|
108
|
+
tools: readonly AgentTool[] | (() => readonly AgentTool[]);
|
|
109
|
+
/** Lets the provider signal that its tool list changed; returns an unsubscribe function. */
|
|
110
|
+
subscribe?: (notify: () => void) => () => void;
|
|
111
|
+
}
|
|
112
|
+
type ToolErrorCode = 'unknown_tool' | 'invalid_arguments' | 'tool_failed';
|
|
113
|
+
/** Structured error carried in `structuredContent.error` of a failed call. */
|
|
114
|
+
interface ToolCallError {
|
|
115
|
+
code: ToolErrorCode;
|
|
116
|
+
message: string;
|
|
117
|
+
tool: string;
|
|
118
|
+
details?: SchemaValidationError[];
|
|
119
|
+
}
|
|
120
|
+
declare class ToolRegistryError extends Error {
|
|
121
|
+
readonly code: 'duplicate_provider' | 'name_collision' | 'invalid_tool';
|
|
122
|
+
constructor(code: ToolRegistryError['code'], message: string);
|
|
123
|
+
}
|
|
124
|
+
interface ToolRegistryOptions {
|
|
125
|
+
/**
|
|
126
|
+
* What to do when two providers contribute the same tool name:
|
|
127
|
+
* `namespace` (default) exposes every colliding tool as `<providerId>__<name>`;
|
|
128
|
+
* `error` makes `register` throw.
|
|
129
|
+
*/
|
|
130
|
+
onCollision?: 'namespace' | 'error';
|
|
131
|
+
/** Coalescing window for `listChanged` notifications in ms (default 0: same tick). */
|
|
132
|
+
listChangedDelayMs?: number;
|
|
133
|
+
/** Validate arguments against `inputSchema` before calling handlers (default `true`). */
|
|
134
|
+
validateArguments?: boolean;
|
|
135
|
+
}
|
|
136
|
+
/** Separator between namespace and tool name; valid in MCP and LLM tool-name charsets. */
|
|
137
|
+
declare const TOOL_NAMESPACE_SEPARATOR = "__";
|
|
138
|
+
/** Normalizes a handler's return value into an MCP `tools/call` result. */
|
|
139
|
+
declare function toToolResult(value: unknown): McpToolResult;
|
|
140
|
+
/**
|
|
141
|
+
* Transport-agnostic registry of agent tools contributed by live providers.
|
|
142
|
+
*
|
|
143
|
+
* `listTools()` and `callTool()` return MCP `tools/list` / `tools/call`
|
|
144
|
+
* result shapes, and `onListChanged` fires (coalesced) whenever the exposed
|
|
145
|
+
* tool list changes, mirroring MCP's `notifications/tools/list_changed`, so an
|
|
146
|
+
* MCP server can be a thin wrapper around it.
|
|
147
|
+
*/
|
|
148
|
+
declare class ToolRegistry {
|
|
149
|
+
/** MCP server capabilities this registry supports. */
|
|
150
|
+
readonly capabilities: {
|
|
151
|
+
readonly tools: {
|
|
152
|
+
readonly listChanged: true;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
private readonly entries;
|
|
156
|
+
private readonly listeners;
|
|
157
|
+
private readonly options;
|
|
158
|
+
private timer;
|
|
159
|
+
private lastSignature;
|
|
160
|
+
constructor(options?: ToolRegistryOptions);
|
|
161
|
+
/**
|
|
162
|
+
* Registers a provider and returns a function that unregisters it.
|
|
163
|
+
* Throws a {@link ToolRegistryError} for a duplicate provider id, an invalid
|
|
164
|
+
* tool name, or (with `onCollision: 'error'`) a tool name collision.
|
|
165
|
+
*/
|
|
166
|
+
register(provider: AgentToolProvider): () => void;
|
|
167
|
+
/** Removes a provider by id or instance. Returns whether it was registered. */
|
|
168
|
+
unregister(providerOrId: string | AgentToolProvider): boolean;
|
|
169
|
+
/** Registered provider ids in registration order. */
|
|
170
|
+
providerIds(): string[];
|
|
171
|
+
/**
|
|
172
|
+
* Resolves exposed names. Tools are ordered by provider registration, then
|
|
173
|
+
* by their order within the provider.
|
|
174
|
+
*/
|
|
175
|
+
private resolve;
|
|
176
|
+
/** MCP `tools/list` result for the current providers. */
|
|
177
|
+
listTools(): McpListToolsResult;
|
|
178
|
+
/** Whether a tool with this exposed name exists. */
|
|
179
|
+
hasTool(name: string): boolean;
|
|
180
|
+
/** Looks up a tool definition by exposed name. */
|
|
181
|
+
getTool(name: string): McpToolDefinition | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Calls a tool by exposed name and returns an MCP `tools/call` result.
|
|
184
|
+
* Never rejects: unknown tools, invalid arguments and handler errors come
|
|
185
|
+
* back as `isError: true` results with a {@link ToolCallError} in
|
|
186
|
+
* `structuredContent.error` (MCP transports may map `unknown_tool` to a
|
|
187
|
+
* JSON-RPC `-32602` error instead).
|
|
188
|
+
*/
|
|
189
|
+
callTool(name: string, args?: Record<string, unknown>, options?: {
|
|
190
|
+
signal?: AbortSignal;
|
|
191
|
+
}): Promise<McpToolResult>;
|
|
192
|
+
/**
|
|
193
|
+
* Subscribes to tool-list changes. Notifications are coalesced: many
|
|
194
|
+
* registrations or provider signals within the delay window produce one
|
|
195
|
+
* call, and none if the exposed list ends up unchanged (e.g. a provider
|
|
196
|
+
* unmounted and remounted). Returns an unsubscribe function.
|
|
197
|
+
*/
|
|
198
|
+
onListChanged(listener: (tools: McpToolDefinition[]) => void): () => void;
|
|
199
|
+
/** Schedules a coalesced `listChanged` check; providers may call it directly. */
|
|
200
|
+
notifyListChanged(): void;
|
|
201
|
+
/** Runs a pending `listChanged` check immediately. */
|
|
202
|
+
flush(): void;
|
|
203
|
+
private signature;
|
|
204
|
+
/** Unregisters every provider and listener and cancels pending notifications. */
|
|
205
|
+
dispose(): void;
|
|
206
|
+
}
|
|
207
|
+
declare function createToolRegistry(options?: ToolRegistryOptions): ToolRegistry;
|
|
208
|
+
|
|
209
|
+
export { type AgentToolProvider as A, type JsonSchema as J, type McpListToolsResult as M, type SchemaValidationError as S, TOOL_NAMESPACE_SEPARATOR as T, type AgentTool as a, type AgentToolHandler as b, type JsonSchemaType as c, type McpToolContent as d, type McpToolDefinition as e, type McpToolResult as f, type ToolCallContext as g, type ToolCallError as h, type ToolErrorCode as i, ToolRegistry as j, ToolRegistryError as k, type ToolRegistryOptions as l, createToolRegistry as m, toToolResult as t, validateJsonSchema as v };
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
var
|
|
55
|
+
var _chunkXDMXXC4Zcjs = require('../chunk-XDMXXC4Z.cjs');
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
|
|
@@ -79,7 +79,6 @@ var _chunk6M3BCTBDcjs = require('../chunk-6M3BCTBD.cjs');
|
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
var _chunkSAZRENEZcjs = require('../chunk-SAZRENEZ.cjs');
|
|
83
82
|
|
|
84
83
|
|
|
85
84
|
|
|
@@ -88,6 +87,7 @@ var _chunkSAZRENEZcjs = require('../chunk-SAZRENEZ.cjs');
|
|
|
88
87
|
|
|
89
88
|
|
|
90
89
|
|
|
90
|
+
var _chunkRIKBJLS2cjs = require('../chunk-RIKBJLS2.cjs');
|
|
91
91
|
|
|
92
92
|
|
|
93
93
|
|
|
@@ -159,5 +159,21 @@ var _chunkSAZRENEZcjs = require('../chunk-SAZRENEZ.cjs');
|
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
exports.DEFAULT_COLUMN_WIDTH = _chunkXDMXXC4Zcjs.DEFAULT_COLUMN_WIDTH; exports.DEFAULT_ROW_HEIGHT = _chunkXDMXXC4Zcjs.DEFAULT_ROW_HEIGHT; exports.DataSourceBinder = _chunkXDMXXC4Zcjs.DataSourceBinder; exports.DependencyGraph = _chunkXDMXXC4Zcjs.DependencyGraph; exports.FORMULA_ERRORS = _chunkRIKBJLS2cjs.FORMULA_ERRORS; exports.FormulaEvaluator = _chunkRIKBJLS2cjs.FormulaEvaluator; exports.FormulaParser = _chunkRIKBJLS2cjs.FormulaParser; exports.MAX_FORMULA_ARRAY_SIZE = _chunkRIKBJLS2cjs.MAX_FORMULA_ARRAY_SIZE; exports.SPREADSHEET_CLIPBOARD_MIME = _chunkXDMXXC4Zcjs.SPREADSHEET_CLIPBOARD_MIME; exports.SPREADSHEET_IMPORT_ADAPTERS = _chunkXDMXXC4Zcjs.SPREADSHEET_IMPORT_ADAPTERS; exports.SPREADSHEET_TABLE_ACTIONS = _chunkXDMXXC4Zcjs.SPREADSHEET_TABLE_ACTIONS; exports.SpreadsheetController = _chunkXDMXXC4Zcjs.SpreadsheetController; exports.WHOLE_COLUMN_END_ROW = _chunkRIKBJLS2cjs.WHOLE_COLUMN_END_ROW; exports.aggregateValues = _chunkXDMXXC4Zcjs.aggregateValues; exports.applyFormulaSuggestion = _chunkXDMXXC4Zcjs.applyFormulaSuggestion; exports.bindSpreadsheetTableActions = _chunkXDMXXC4Zcjs.bindSpreadsheetTableActions; exports.buildSpreadsheetView = _chunkXDMXXC4Zcjs.buildSpreadsheetView; exports.checkFormulaArgumentCount = _chunkRIKBJLS2cjs.checkFormulaArgumentCount; exports.clampMenuPosition = _chunkXDMXXC4Zcjs.clampMenuPosition; exports.colNameToIndex = _chunkRIKBJLS2cjs.colNameToIndex; exports.columnDependencyKey = _chunkXDMXXC4Zcjs.columnDependencyKey; exports.compareCellValues = _chunkXDMXXC4Zcjs.compareCellValues; exports.compareNumbers = _chunkRIKBJLS2cjs.compareNumbers; exports.compareValues = _chunkRIKBJLS2cjs.compareValues; exports.computeFillTarget = _chunkXDMXXC4Zcjs.computeFillTarget; exports.computeRowGroups = _chunkXDMXXC4Zcjs.computeRowGroups; exports.createSpreadsheetClipboardData = _chunkXDMXXC4Zcjs.createSpreadsheetClipboardData; exports.csvImportAdapter = _chunkXDMXXC4Zcjs.csvImportAdapter; exports.describeFormulaError = _chunkRIKBJLS2cjs.describeFormulaError; exports.escapeCsvField = _chunkXDMXXC4Zcjs.escapeCsvField; exports.extractCellDependencies = _chunkXDMXXC4Zcjs.extractCellDependencies; exports.fillSeries = _chunkXDMXXC4Zcjs.fillSeries; exports.formatCellDisplay = _chunkRIKBJLS2cjs.formatCellDisplay; exports.formatValueWithCode = _chunkRIKBJLS2cjs.formatValueWithCode; exports.getFillDirection = _chunkXDMXXC4Zcjs.getFillDirection; exports.getFormulaArgumentSpecIndex = _chunkRIKBJLS2cjs.getFormulaArgumentSpecIndex; exports.getFormulaCaretContext = _chunkXDMXXC4Zcjs.getFormulaCaretContext; exports.getFormulaFunction = _chunkRIKBJLS2cjs.getFormulaFunction; exports.getFormulaHints = _chunkXDMXXC4Zcjs.getFormulaHints; exports.getFormulaSignature = _chunkRIKBJLS2cjs.getFormulaSignature; exports.getFormulaSignatureParts = _chunkRIKBJLS2cjs.getFormulaSignatureParts; exports.getRowSection = _chunkXDMXXC4Zcjs.getRowSection; exports.getSpreadsheetMenuItems = _chunkXDMXXC4Zcjs.getSpreadsheetMenuItems; exports.getTableSections = _chunkXDMXXC4Zcjs.getTableSections; exports.importFileIntoSpreadsheet = _chunkXDMXXC4Zcjs.importFileIntoSpreadsheet; exports.indexToColName = _chunkRIKBJLS2cjs.indexToColName; exports.isBlankValue = _chunkXDMXXC4Zcjs.isBlankValue; exports.isFormulaError = _chunkRIKBJLS2cjs.isFormulaError; exports.isSingleCellRange = _chunkXDMXXC4Zcjs.isSingleCellRange; exports.listFormulaFunctions = _chunkRIKBJLS2cjs.listFormulaFunctions; exports.mapFormulaReferences = _chunkXDMXXC4Zcjs.mapFormulaReferences; exports.matchesFilterRule = _chunkXDMXXC4Zcjs.matchesFilterRule; exports.normalizeRange = _chunkXDMXXC4Zcjs.normalizeRange; exports.numberToText = _chunkRIKBJLS2cjs.numberToText; exports.offsetFormulaReferences = _chunkXDMXXC4Zcjs.offsetFormulaReferences; exports.parseCellInput = _chunkRIKBJLS2cjs.parseCellInput; exports.parseCellReference = _chunkRIKBJLS2cjs.parseCellReference; exports.parseCriteria = _chunkRIKBJLS2cjs.parseCriteria; exports.parseCsv = _chunkXDMXXC4Zcjs.parseCsv; exports.parseFormula = _chunkRIKBJLS2cjs.parseFormula; exports.parseHtmlTable = _chunkXDMXXC4Zcjs.parseHtmlTable; exports.parseNumberText = _chunkRIKBJLS2cjs.parseNumberText; exports.parseRange = _chunkRIKBJLS2cjs.parseRange; exports.parseTsv = _chunkXDMXXC4Zcjs.parseTsv; exports.rangeContains = _chunkXDMXXC4Zcjs.rangeContains; exports.rangeContainsRange = _chunkXDMXXC4Zcjs.rangeContainsRange; exports.rangesIntersect = _chunkXDMXXC4Zcjs.rangesIntersect; exports.readSpreadsheetClipboard = _chunkXDMXXC4Zcjs.readSpreadsheetClipboard; exports.rebaseClipboardRows = _chunkXDMXXC4Zcjs.rebaseClipboardRows; exports.registerFormulaFunction = _chunkRIKBJLS2cjs.registerFormulaFunction; exports.registerSpreadsheetImportAdapters = _chunkXDMXXC4Zcjs.registerSpreadsheetImportAdapters; exports.remapFormulaReferences = _chunkXDMXXC4Zcjs.remapFormulaReferences; exports.roundFloat = _chunkXDMXXC4Zcjs.roundFloat; exports.rowPassesFilters = _chunkXDMXXC4Zcjs.rowPassesFilters; exports.searchFormulaFunctions = _chunkRIKBJLS2cjs.searchFormulaFunctions; exports.serialFromYmd = _chunkRIKBJLS2cjs.serialFromYmd; exports.serializeCsv = _chunkXDMXXC4Zcjs.serializeCsv; exports.serializeHtmlTable = _chunkXDMXXC4Zcjs.serializeHtmlTable; exports.serializeTsv = _chunkXDMXXC4Zcjs.serializeTsv; exports.shiftFormulaReferences = _chunkXDMXXC4Zcjs.shiftFormulaReferences; exports.sortCompareValues = _chunkRIKBJLS2cjs.sortCompareValues; exports.toNumber = _chunkXDMXXC4Zcjs.toNumber; exports.tokenizeFormula = _chunkRIKBJLS2cjs.tokenizeFormula; exports.tsvImportAdapter = _chunkXDMXXC4Zcjs.tsvImportAdapter; exports.unregisterFormulaFunction = _chunkRIKBJLS2cjs.unregisterFormulaFunction; exports.wildcardToRegExp = _chunkRIKBJLS2cjs.wildcardToRegExp;
|
|
163
179
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/spreadsheet/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/spreadsheet/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,ykLAAC","file":"/home/runner/work/editor/editor/packages/core/dist/spreadsheet/index.cjs"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ASTNode, r as FormulaErrorCode, v as FormulaRange, G as GroupAggregate, O as SortDirection, e as CellRange, d as CellPosition, p as FilterRule, S as SpreadsheetController } from '../controller-
|
|
2
|
-
export { B as BinaryOpNode, C as CellCoordinate,
|
|
1
|
+
import { A as ASTNode, r as FormulaErrorCode, v as FormulaRange, a as CellData, c as CellFormat, G as GroupAggregate, O as SortDirection, e as CellRange, d as CellPosition, p as FilterRule, S as SpreadsheetController } from '../controller-pePCJLT1.cjs';
|
|
2
|
+
export { B as BinaryOpNode, C as CellCoordinate, b as CellDep, f as CellRefNode, g as CellValueReader, h as ColumnBinding, i as ColumnType, j as CsvExportOptions, k as CsvImportOptions, D as DEFAULT_COLUMN_WIDTH, l as DEFAULT_ROW_HEIGHT, m as DataSourceBinder, n as DependencyGraph, E as EvaluationContext, F as FORMULA_ERRORS, o as FilterOperator, q as FormulaDiagnostic, s as FormulaEvaluationResult, t as FormulaEvaluator, u as FormulaParser, w as FormulaToken, x as FormulaTokenType, y as FunctionCallNode, z as GroupSummary, L as LiteralNode, M as MAX_FORMULA_ARRAY_SIZE, N as NameNode, H as NewFilterRule, P as ParsedSpreadsheetClipboard, I as PropertyRefNode, R as RangeNode, J as RowType, K as SPREADSHEET_CLIPBOARD_MIME, Q as SortKey, T as SpillRefNode, U as SpreadsheetCellSpan, V as SpreadsheetClipboardCell, W as SpreadsheetClipboardData, X as SpreadsheetClipboardPayload, Y as SpreadsheetClipboardSource, Z as SpreadsheetColumn, _ as SpreadsheetControllerOptions, $ as SpreadsheetDataSource, a0 as SpreadsheetDataSourceField, a1 as SpreadsheetDocument, a2 as SpreadsheetFilterState, a3 as SpreadsheetGrouping, a4 as SpreadsheetRow, a5 as SpreadsheetRowGroup, a6 as SpreadsheetRowSection, a7 as SpreadsheetSpill, a8 as SpreadsheetTableSettings, a9 as SpreadsheetViewColumn, aa as SpreadsheetViewModel, ab as SpreadsheetViewRow, ac as StructuralChange, ad as UnaryOpNode, ae as WHOLE_COLUMN_END_ROW, af as buildSpreadsheetView, ag as colNameToIndex, ah as columnDependencyKey, ai as compareNumbers, aj as compareValues, ak as computeRowGroups, al as createSpreadsheetClipboardData, am as describeFormulaError, an as extractCellDependencies, ao as getRowSection, ap as getTableSections, aq as indexToColName, ar as isFormulaError, as as mapFormulaReferences, at as numberToText, au as offsetFormulaReferences, av as parseCellReference, aw as parseFormula, ax as parseHtmlTable, ay as parseRange, az as readSpreadsheetClipboard, aA as rebaseClipboardRows, aB as remapFormulaReferences, aC as rowPassesFilters, aD as serializeHtmlTable, aE as shiftFormulaReferences, aF as sortCompareValues, aG as tokenizeFormula } from '../controller-pePCJLT1.cjs';
|
|
3
3
|
import { I as ImportAdapterRegistry, c as ImportAdapter, h as ImportInput, a as ImportOutcome } from '../registry-GJI4gToU.cjs';
|
|
4
4
|
|
|
5
5
|
type FormulaFunctionCategory = 'math' | 'statistical' | 'logical' | 'text' | 'lookup' | 'date' | 'information';
|
|
@@ -202,13 +202,22 @@ declare function wildcardToRegExp(pattern: string): RegExp;
|
|
|
202
202
|
* Parses a criterion as used by SUMIF, COUNTIFS etc.:
|
|
203
203
|
* - a number or boolean matches equal values (`5` matches 5 and the text "5");
|
|
204
204
|
* - text may start with `=`, `<>`, `<`, `<=`, `>` or `>=`. Numeric operands
|
|
205
|
-
*
|
|
205
|
+
* (typed-input rules: `">1,000"`, `"<50%"`, `">$5"`) compare numbers; date
|
|
206
|
+
* operands (`">=3/1/2026"`, `"<2026-03-01"`) compare ISO dates (and serial
|
|
207
|
+
* numbers) chronologically; text operands compare text case-insensitively;
|
|
206
208
|
* - `=`/`<>` text operands and plain text support `*` and `?` wildcards;
|
|
207
209
|
* - `""` and `"="` match blank cells, `"<>"` matches non-blank cells.
|
|
208
210
|
* Error values in the data never match.
|
|
209
211
|
*/
|
|
210
212
|
declare function parseCriteria(criterion: unknown): FormulaCriteriaPredicate;
|
|
211
213
|
|
|
214
|
+
/**
|
|
215
|
+
* The text a cell shows: its error, or its value formatted with the number
|
|
216
|
+
* format chosen for typed input (`numberFormat`, e.g. `"$"#,##0.00` for
|
|
217
|
+
* `$1,200.50`, `0%` for `10%`, `m/d/yyyy` for `3/4/2026`). Other numbers use
|
|
218
|
+
* up to 15 significant digits and booleans show as TRUE/FALSE.
|
|
219
|
+
*/
|
|
220
|
+
declare function formatCellDisplay(cell: Pick<CellData, 'value' | 'error' | 'numberFormat'> | null | undefined): string;
|
|
212
221
|
/**
|
|
213
222
|
* A subset of spreadsheet number format codes, as used by TEXT():
|
|
214
223
|
* - numbers: `0`, `#`, `0.00`, `#,##0`, `#,##0.00`, `0%`, `0.0%`, `0.00E+00`,
|
|
@@ -220,6 +229,53 @@ declare function parseCriteria(criterion: unknown): FormulaCriteriaPredicate;
|
|
|
220
229
|
*/
|
|
221
230
|
declare function formatValueWithCode(value: unknown, format: string): string | null;
|
|
222
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Parsing what people type into a cell (and numeric text in formulas).
|
|
234
|
+
*
|
|
235
|
+
* Recognises numbers with thousands separators, percentages, currency,
|
|
236
|
+
* scientific notation, fractions (`1 1/2`), dates (`3/4/2026`, `2026-03-04`,
|
|
237
|
+
* `4-Mar-2026`, `Mar 4, 2026`), times (`10:30`, `10:30:15 PM`) and
|
|
238
|
+
* date-times. Locale: en-US (month/day/year).
|
|
239
|
+
*
|
|
240
|
+
* Representation: our engine keeps dates as ISO text (`2026-03-04`, or
|
|
241
|
+
* `2026-03-04 18:00:00` with a time), so a typed date becomes ISO text, not a
|
|
242
|
+
* serial number. A time typed on its own (`12:00`) has no date to anchor ISO
|
|
243
|
+
* text to, so it becomes a fraction of a day (0.5), as in Excel.
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
/** Kind of automatic number format chosen for typed input. */
|
|
247
|
+
type CellInputFormatKind = 'number' | 'currency' | 'percentage' | 'date' | 'time';
|
|
248
|
+
interface ParsedCellInput {
|
|
249
|
+
/** The typed value: number, boolean, ISO date text, error code or text. `''` for empty input. */
|
|
250
|
+
value: string | number | boolean;
|
|
251
|
+
type: 'empty' | 'text' | 'number' | 'boolean' | 'error' | 'date';
|
|
252
|
+
/**
|
|
253
|
+
* Number format code Excel would apply automatically (e.g. `"$"#,##0.00`,
|
|
254
|
+
* `0%`, `#,##0`, `m/d/yyyy`, `h:mm`), or undefined for General.
|
|
255
|
+
*/
|
|
256
|
+
numberFormat?: string;
|
|
257
|
+
/** What kind of format that is, if any. */
|
|
258
|
+
formatKind?: CellInputFormatKind;
|
|
259
|
+
/** `formatKind` mapped onto `CellFormat` (times have no `CellFormat` and map to undefined). */
|
|
260
|
+
cellFormat?: CellFormat;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Excel 1900-system serial for a date (1 = 1900-01-01, 60 = the fictitious
|
|
264
|
+
* 1900-02-29). Month and day overflow roll over like `DATE()`; years 0–1899
|
|
265
|
+
* are added to 1900. Null before the epoch or after 9999-12-31.
|
|
266
|
+
*/
|
|
267
|
+
declare function serialFromYmd(year: number, month: number, day: number): number | null;
|
|
268
|
+
/**
|
|
269
|
+
* Interprets typed cell input (not formulas). Text that isn't a number,
|
|
270
|
+
* date, time, boolean or error stays text; a leading apostrophe forces text.
|
|
271
|
+
*/
|
|
272
|
+
declare function parseCellInput(input: string): ParsedCellInput;
|
|
273
|
+
/**
|
|
274
|
+
* Numeric text as arithmetic coerces it ("1,000", "50%", "$3", "1/2/2020",
|
|
275
|
+
* "10:00"); dates become 1900-system serial numbers. Null when it isn't numeric.
|
|
276
|
+
*/
|
|
277
|
+
declare function parseNumberText(text: string): number | null;
|
|
278
|
+
|
|
223
279
|
/**
|
|
224
280
|
* RFC 4180 CSV (and other delimiter-separated values) parsing and
|
|
225
281
|
* serialization.
|
|
@@ -288,9 +344,11 @@ declare function isBlankValue(value: unknown): boolean;
|
|
|
288
344
|
/** The numeric value of a number or numeric string, or null. */
|
|
289
345
|
declare function toNumber(value: unknown): number | null;
|
|
290
346
|
/**
|
|
291
|
-
* Sort order for cell values: numbers (ascending)
|
|
292
|
-
*
|
|
293
|
-
*
|
|
347
|
+
* Sort order for cell values, as in Excel: numbers (ascending), then text,
|
|
348
|
+
* booleans and errors; `desc` reverses that order. Numbers compare at 15
|
|
349
|
+
* significant digits and ISO dates chronologically. Text uses a natural,
|
|
350
|
+
* case-insensitive order ("Item 2" before "Item 10"). Blanks always sort
|
|
351
|
+
* last, whatever the direction.
|
|
294
352
|
*/
|
|
295
353
|
declare function compareCellValues(a: unknown, b: unknown, direction?: SortDirection): number;
|
|
296
354
|
/** Whether a cell value passes one filter rule. */
|
|
@@ -308,8 +366,8 @@ declare function roundFloat(value: number): number;
|
|
|
308
366
|
* nearest-first) by `count` values, the way a fill handle does:
|
|
309
367
|
*
|
|
310
368
|
* - numbers: one value repeats; two or more continue their linear trend
|
|
311
|
-
* -
|
|
312
|
-
* continue their day or month step
|
|
369
|
+
* - dates (ISO `YYYY-MM-DD`, or typed like `3/4/2026`): one date counts up
|
|
370
|
+
* by a day; two or more continue their day or month step (as ISO dates)
|
|
313
371
|
* - text ending in a number ("Item 1"): the number counts up (or continues
|
|
314
372
|
* the step of several values with the same prefix/suffix)
|
|
315
373
|
* - anything else (or a mix) repeats the source cyclically
|
|
@@ -427,4 +485,4 @@ interface ImportFileIntoSpreadsheetOptions {
|
|
|
427
485
|
*/
|
|
428
486
|
declare function importFileIntoSpreadsheet(controller: SpreadsheetController, input: ImportInput, options: ImportFileIntoSpreadsheetOptions): Promise<ImportOutcome<SpreadsheetImport>>;
|
|
429
487
|
|
|
430
|
-
export { ASTNode, CellPosition, CellRange, type CsvParseOptions, type CsvSerializeOptions, type FillDirection, FilterRule, type FormulaActiveCall, type FormulaArgument, type FormulaArgumentSpec, type FormulaArgumentType, type FormulaCaretContext, type FormulaCriteriaPredicate, FormulaErrorCode, type FormulaFunctionCategory, type FormulaFunctionContext, type FormulaFunctionDefinition, type FormulaFunctionSuggestion, type FormulaHints, FormulaRange, type FormulaSignaturePart, GroupAggregate, type ImportFileIntoSpreadsheetOptions, SPREADSHEET_IMPORT_ADAPTERS, SPREADSHEET_TABLE_ACTIONS, SortDirection, SpreadsheetController, type SpreadsheetImport, type SpreadsheetImportAdapter, type SpreadsheetMenuItem, type SpreadsheetTableActionName, type SpreadsheetTableActions, aggregateValues, applyFormulaSuggestion, bindSpreadsheetTableActions, checkFormulaArgumentCount, clampMenuPosition, compareCellValues, computeFillTarget, csvImportAdapter, escapeCsvField, fillSeries, formatValueWithCode, getFillDirection, getFormulaArgumentSpecIndex, getFormulaCaretContext, getFormulaFunction, getFormulaHints, getFormulaSignature, getFormulaSignatureParts, getSpreadsheetMenuItems, importFileIntoSpreadsheet, isBlankValue, isSingleCellRange, listFormulaFunctions, matchesFilterRule, normalizeRange, parseCriteria, parseCsv, parseTsv, rangeContains, rangeContainsRange, rangesIntersect, registerFormulaFunction, registerSpreadsheetImportAdapters, roundFloat, searchFormulaFunctions, serializeCsv, serializeTsv, toNumber, tsvImportAdapter, unregisterFormulaFunction, wildcardToRegExp };
|
|
488
|
+
export { ASTNode, CellData, CellFormat, type CellInputFormatKind, CellPosition, CellRange, type CsvParseOptions, type CsvSerializeOptions, type FillDirection, FilterRule, type FormulaActiveCall, type FormulaArgument, type FormulaArgumentSpec, type FormulaArgumentType, type FormulaCaretContext, type FormulaCriteriaPredicate, FormulaErrorCode, type FormulaFunctionCategory, type FormulaFunctionContext, type FormulaFunctionDefinition, type FormulaFunctionSuggestion, type FormulaHints, FormulaRange, type FormulaSignaturePart, GroupAggregate, type ImportFileIntoSpreadsheetOptions, type ParsedCellInput, SPREADSHEET_IMPORT_ADAPTERS, SPREADSHEET_TABLE_ACTIONS, SortDirection, SpreadsheetController, type SpreadsheetImport, type SpreadsheetImportAdapter, type SpreadsheetMenuItem, type SpreadsheetTableActionName, type SpreadsheetTableActions, aggregateValues, applyFormulaSuggestion, bindSpreadsheetTableActions, checkFormulaArgumentCount, clampMenuPosition, compareCellValues, computeFillTarget, csvImportAdapter, escapeCsvField, fillSeries, formatCellDisplay, formatValueWithCode, getFillDirection, getFormulaArgumentSpecIndex, getFormulaCaretContext, getFormulaFunction, getFormulaHints, getFormulaSignature, getFormulaSignatureParts, getSpreadsheetMenuItems, importFileIntoSpreadsheet, isBlankValue, isSingleCellRange, listFormulaFunctions, matchesFilterRule, normalizeRange, parseCellInput, parseCriteria, parseCsv, parseNumberText, parseTsv, rangeContains, rangeContainsRange, rangesIntersect, registerFormulaFunction, registerSpreadsheetImportAdapters, roundFloat, searchFormulaFunctions, serialFromYmd, serializeCsv, serializeTsv, toNumber, tsvImportAdapter, unregisterFormulaFunction, wildcardToRegExp };
|