@ganju/utils 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +26 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +107 -9
- package/dist/customCodeToken.d.ts +11 -0
- package/dist/customCodeToken.d.ts.map +1 -1
- package/dist/customCodeToken.js +41 -1
- package/dist/data.d.ts +13 -0
- package/dist/data.d.ts.map +1 -0
- package/dist/data.js +103 -0
- package/dist/dataApi.d.ts +578 -0
- package/dist/dataApi.d.ts.map +1 -0
- package/dist/dataApi.js +399 -0
- package/dist/dataCompiler.d.ts +68 -0
- package/dist/dataCompiler.d.ts.map +1 -0
- package/dist/dataCompiler.js +730 -0
- package/dist/dataCsv.d.ts +20 -0
- package/dist/dataCsv.d.ts.map +1 -0
- package/dist/dataCsv.js +102 -0
- package/dist/dataDdl.d.ts +29 -0
- package/dist/dataDdl.d.ts.map +1 -0
- package/dist/dataDdl.js +354 -0
- package/dist/dataEngine.d.ts +143 -0
- package/dist/dataEngine.d.ts.map +1 -0
- package/dist/dataEngine.js +2042 -0
- package/dist/dataIdentifiers.d.ts +8 -0
- package/dist/dataIdentifiers.d.ts.map +1 -0
- package/dist/dataIdentifiers.js +55 -0
- package/dist/dataImport.d.ts +79 -0
- package/dist/dataImport.d.ts.map +1 -0
- package/dist/dataImport.js +453 -0
- package/dist/dataQueries.d.ts +73 -0
- package/dist/dataQueries.d.ts.map +1 -0
- package/dist/dataQueries.js +513 -0
- package/dist/dataRpc.d.ts +150 -0
- package/dist/dataRpc.d.ts.map +1 -0
- package/dist/dataRpc.js +2 -0
- package/dist/dataTools.d.ts +40 -0
- package/dist/dataTools.d.ts.map +1 -0
- package/dist/dataTools.js +280 -0
- package/dist/dataTypes.d.ts +159 -0
- package/dist/dataTypes.d.ts.map +1 -0
- package/dist/dataTypes.js +160 -0
- package/dist/index.d.ts +394 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/oauth.d.ts +14 -0
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +42 -2
- package/dist/resourceRerank.d.ts +3 -2
- package/dist/resourceRerank.d.ts.map +1 -1
- package/dist/resourceRerank.js +5 -2
- package/dist/schema.d.ts +376 -4
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +268 -1
- package/dist/sdkConstants.d.ts +1 -0
- package/dist/sdkConstants.d.ts.map +1 -1
- package/dist/sdkConstants.js +2 -1
- package/package.json +17 -2
- package/src/constants.ts +121 -9
- package/src/customCodeToken.ts +74 -0
- package/src/data.ts +108 -0
- package/src/dataApi.ts +479 -0
- package/src/dataCompiler.ts +952 -0
- package/src/dataCsv.ts +99 -0
- package/src/dataDdl.ts +419 -0
- package/src/dataEngine.ts +2773 -0
- package/src/dataIdentifiers.ts +63 -0
- package/src/dataImport.ts +557 -0
- package/src/dataQueries.ts +730 -0
- package/src/dataRpc.ts +132 -0
- package/src/dataTools.ts +338 -0
- package/src/dataTypes.ts +318 -0
- package/src/index.ts +13 -1
- package/src/oauth.ts +42 -1
- package/src/resourceRerank.ts +5 -2
- package/src/schema.ts +315 -1
- package/src/sdkConstants.ts +1 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { DataCaller, DataDeleteImpact, DataResult, DataSchema, DataTable, DataTableCopy } from './dataTypes';
|
|
2
|
+
import type { DataQuery } from './dataQueries';
|
|
3
|
+
export type ExportFormat = 'jsonl' | 'csv';
|
|
4
|
+
export interface ExportFile {
|
|
5
|
+
table: string | null;
|
|
6
|
+
key: string;
|
|
7
|
+
rows: number;
|
|
8
|
+
bytes: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ExportState {
|
|
11
|
+
id: string;
|
|
12
|
+
format: ExportFormat;
|
|
13
|
+
status: 'running' | 'done' | 'failed';
|
|
14
|
+
startedAt: string;
|
|
15
|
+
finishedAt: string | null;
|
|
16
|
+
actor: string;
|
|
17
|
+
tables: string[];
|
|
18
|
+
tableIndex: number;
|
|
19
|
+
afterId: number;
|
|
20
|
+
upload: {
|
|
21
|
+
key: string;
|
|
22
|
+
uploadId: string;
|
|
23
|
+
parts: {
|
|
24
|
+
partNumber: number;
|
|
25
|
+
etag: string;
|
|
26
|
+
}[];
|
|
27
|
+
rows: number;
|
|
28
|
+
bytes: number;
|
|
29
|
+
carryKey: string | null;
|
|
30
|
+
} | null;
|
|
31
|
+
files: ExportFile[];
|
|
32
|
+
error: string | null;
|
|
33
|
+
}
|
|
34
|
+
export interface DatabaseInfo {
|
|
35
|
+
artifactId: string | null;
|
|
36
|
+
name: string | null;
|
|
37
|
+
initializedAt: string | null;
|
|
38
|
+
deletedAt: string | null;
|
|
39
|
+
firstWriteAt: string | null;
|
|
40
|
+
timeZone: string | null;
|
|
41
|
+
schemaVersion: number;
|
|
42
|
+
size: number;
|
|
43
|
+
tables: {
|
|
44
|
+
name: string;
|
|
45
|
+
label: string | null;
|
|
46
|
+
columns: number;
|
|
47
|
+
}[];
|
|
48
|
+
copy: DataTableCopy | null;
|
|
49
|
+
}
|
|
50
|
+
export interface RestoreResult {
|
|
51
|
+
bookmark: string;
|
|
52
|
+
undoBookmark: string;
|
|
53
|
+
}
|
|
54
|
+
type R<T> = Promise<DataResult<T>>;
|
|
55
|
+
export interface ProjectDatabaseRpc {
|
|
56
|
+
init(args: {
|
|
57
|
+
artifactId: string;
|
|
58
|
+
name: string;
|
|
59
|
+
}): R<DatabaseInfo>;
|
|
60
|
+
info(): R<DatabaseInfo>;
|
|
61
|
+
rename(args: {
|
|
62
|
+
name: string;
|
|
63
|
+
}): R<DatabaseInfo>;
|
|
64
|
+
size(): R<{
|
|
65
|
+
bytes: number;
|
|
66
|
+
}>;
|
|
67
|
+
setTimeZone(caller: DataCaller, args: {
|
|
68
|
+
timeZone: string | null;
|
|
69
|
+
}): R<DatabaseInfo>;
|
|
70
|
+
markDeleted(caller: DataCaller): R<{
|
|
71
|
+
deletedAt: string | null;
|
|
72
|
+
bookmark: string;
|
|
73
|
+
}>;
|
|
74
|
+
undelete(caller: DataCaller): R<DatabaseInfo>;
|
|
75
|
+
purge(): R<{
|
|
76
|
+
purged: true;
|
|
77
|
+
bookmark: string;
|
|
78
|
+
}>;
|
|
79
|
+
currentBookmark(): R<{
|
|
80
|
+
bookmark: string;
|
|
81
|
+
}>;
|
|
82
|
+
restoreTo(caller: DataCaller, args: {
|
|
83
|
+
timestamp: number;
|
|
84
|
+
}): R<RestoreResult>;
|
|
85
|
+
restoreToBookmark(args: {
|
|
86
|
+
bookmark: string;
|
|
87
|
+
}): R<RestoreResult>;
|
|
88
|
+
schemaRead(): R<DataSchema>;
|
|
89
|
+
createTable(caller: DataCaller, input: unknown): R<DataTable>;
|
|
90
|
+
updateTable(caller: DataCaller, table: string, patch: unknown): R<DataTable>;
|
|
91
|
+
dropTable(caller: DataCaller, table: string): R<{
|
|
92
|
+
dropped: string;
|
|
93
|
+
bookmark: string;
|
|
94
|
+
}>;
|
|
95
|
+
addColumn(caller: DataCaller, table: string, input: unknown): R<DataTable>;
|
|
96
|
+
updateColumn(caller: DataCaller, table: string, column: string, patch: unknown): R<{
|
|
97
|
+
table: DataTable;
|
|
98
|
+
bookmark: string | null;
|
|
99
|
+
copy: DataTableCopy | null;
|
|
100
|
+
}>;
|
|
101
|
+
dropColumn(caller: DataCaller, table: string, column: string): R<{
|
|
102
|
+
table: DataTable;
|
|
103
|
+
bookmark: string;
|
|
104
|
+
copy: DataTableCopy | null;
|
|
105
|
+
}>;
|
|
106
|
+
dismissCopy(caller: DataCaller): R<{
|
|
107
|
+
copy: null;
|
|
108
|
+
}>;
|
|
109
|
+
describe(caller: DataCaller, args?: unknown): R<unknown>;
|
|
110
|
+
query(caller: DataCaller, args: unknown): R<unknown>;
|
|
111
|
+
write(caller: DataCaller, args: unknown): R<{
|
|
112
|
+
ok: true;
|
|
113
|
+
results: unknown[];
|
|
114
|
+
}>;
|
|
115
|
+
deleteImpact(caller: DataCaller, args: {
|
|
116
|
+
table: string;
|
|
117
|
+
ids?: number[];
|
|
118
|
+
}): R<DataDeleteImpact>;
|
|
119
|
+
history(caller: DataCaller, args: {
|
|
120
|
+
table: string;
|
|
121
|
+
id: number;
|
|
122
|
+
limit?: number;
|
|
123
|
+
cursor?: number;
|
|
124
|
+
}): R<unknown>;
|
|
125
|
+
listQueries(caller: DataCaller): R<DataQuery[]>;
|
|
126
|
+
saveQuery(caller: DataCaller, input: unknown): R<DataQuery>;
|
|
127
|
+
dropQuery(caller: DataCaller, name: string): R<{
|
|
128
|
+
dropped: string;
|
|
129
|
+
}>;
|
|
130
|
+
runQuery(caller: DataCaller, args: {
|
|
131
|
+
name: string;
|
|
132
|
+
params?: Record<string, unknown>;
|
|
133
|
+
limit?: number;
|
|
134
|
+
}): R<{
|
|
135
|
+
query: string;
|
|
136
|
+
rows: Record<string, unknown>[];
|
|
137
|
+
truncated?: string;
|
|
138
|
+
}>;
|
|
139
|
+
exportStart(caller: DataCaller, args?: {
|
|
140
|
+
format?: ExportFormat;
|
|
141
|
+
}): R<{
|
|
142
|
+
exportId: string;
|
|
143
|
+
status: ExportState['status'];
|
|
144
|
+
}>;
|
|
145
|
+
exportStatus(args?: {
|
|
146
|
+
exportId?: string;
|
|
147
|
+
}): R<ExportState>;
|
|
148
|
+
}
|
|
149
|
+
export {};
|
|
150
|
+
//# sourceMappingURL=dataRpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataRpc.d.ts","sourceRoot":"","sources":["../src/dataRpc.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,SAAS,EACT,aAAa,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,KAAK,CAAC;AAE3C,MAAM,WAAW,UAAU;IAEzB,KAAK,EAAE,MAAM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AAU,EAClB,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACvE,CAAC,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,WAAW,CACT,MAAM,EAAE,UAAU,EAClB,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,YAAY,CAAA;KAAE,GAC/B,CAAC,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;KAAE,CAAC,CAAC;IAC1D,YAAY,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC;CAC5D"}
|
package/dist/dataRpc.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DataCaller, DataSchema } from './dataTypes';
|
|
2
|
+
import type { DataQuery } from './dataQueries';
|
|
3
|
+
export declare const DATA_TOOL_DESCRIBE = "data-describe";
|
|
4
|
+
export declare const DATA_TOOL_QUERY = "data-query";
|
|
5
|
+
export declare const DATA_TOOL_WRITE = "data-write";
|
|
6
|
+
export declare const DATA_TOOL_ADMIN = "data-admin";
|
|
7
|
+
export declare const DATA_TOOL_NAMES: readonly ["data-describe", "data-query", "data-write", "data-admin"];
|
|
8
|
+
export declare const DATA_TOOL_TITLES: Record<string, string>;
|
|
9
|
+
export declare const DATA_TOOL_MAX_LIMIT = 100;
|
|
10
|
+
export interface DataToolDefinition {
|
|
11
|
+
name: string;
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputSchema: Record<string, unknown>;
|
|
15
|
+
annotations: {
|
|
16
|
+
readOnlyHint: boolean;
|
|
17
|
+
destructiveHint: boolean;
|
|
18
|
+
openWorldHint: boolean;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Whether the caller may use the data tools at all: it sees a table. */
|
|
22
|
+
export declare const hasDataToolTables: (schema: DataSchema, caller: DataCaller) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* data-describe, data-query and, when the caller may add rows somewhere,
|
|
25
|
+
* data-write. Only tables the caller may see are named, so a hidden table
|
|
26
|
+
* doesn't exist for the model. `queries` are the named queries it may run.
|
|
27
|
+
*/
|
|
28
|
+
export declare const dataToolDefinitions: (schema: DataSchema, caller: DataCaller, options?: {
|
|
29
|
+
queries?: DataQuery[];
|
|
30
|
+
}) => DataToolDefinition[];
|
|
31
|
+
export declare const DATA_ADMIN_ACTIONS: readonly ["schema", "create_table", "update_table", "drop_table", "add_column", "update_column", "drop_column", "save_query", "drop_query", "import", "export"];
|
|
32
|
+
export type DataAdminAction = (typeof DATA_ADMIN_ACTIONS)[number];
|
|
33
|
+
/**
|
|
34
|
+
* data-admin: the owner's own MCP client managing the database's structure.
|
|
35
|
+
* One tool, so it costs one slot in the session it exists in; destructive, so
|
|
36
|
+
* every call goes through confirmation and, after outside content, the
|
|
37
|
+
* approval link.
|
|
38
|
+
*/
|
|
39
|
+
export declare const dataAdminToolDefinition: () => DataToolDefinition;
|
|
40
|
+
//# sourceMappingURL=dataTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataTools.d.ts","sourceRoot":"","sources":["../src/dataTools.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,UAAU,EAEV,UAAU,EAEX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAClD,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,eAAe,sEAKlB,CAAC;AAIX,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKnD,CAAC;AAIF,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,WAAW,EAAE;QACX,YAAY,EAAE,OAAO,CAAC;QACtB,eAAe,EAAE,OAAO,CAAC;QACzB,aAAa,EAAE,OAAO,CAAC;KACxB,CAAC;CACH;AA2DD,yEAAyE;AACzE,eAAO,MAAM,iBAAiB,GAAI,QAAQ,UAAU,EAAE,QAAQ,UAAU,YACpC,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,UAAU,EAClB,QAAQ,UAAU,EAClB,UAAS;IAAE,OAAO,CAAC,EAAE,SAAS,EAAE,CAAA;CAAO,KACtC,kBAAkB,EA6JpB,CAAC;AAEF,eAAO,MAAM,kBAAkB,iKAYrB,CAAC;AACX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAAO,kBAsCzC,CAAC"}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dataAdminToolDefinition = exports.DATA_ADMIN_ACTIONS = exports.dataToolDefinitions = exports.hasDataToolTables = exports.DATA_TOOL_MAX_LIMIT = exports.DATA_TOOL_TITLES = exports.DATA_TOOL_NAMES = exports.DATA_TOOL_ADMIN = exports.DATA_TOOL_WRITE = exports.DATA_TOOL_QUERY = exports.DATA_TOOL_DESCRIBE = void 0;
|
|
4
|
+
// The data tools as a model sees them: names, descriptions and input schemas,
|
|
5
|
+
// built from the database's schema for one caller. The MCP worker registers
|
|
6
|
+
// them and the tool-design eval measures them, so the text the eval scored is
|
|
7
|
+
// the text that ships.
|
|
8
|
+
const dataTypes_1 = require("./dataTypes");
|
|
9
|
+
exports.DATA_TOOL_DESCRIBE = 'data-describe';
|
|
10
|
+
exports.DATA_TOOL_QUERY = 'data-query';
|
|
11
|
+
exports.DATA_TOOL_WRITE = 'data-write';
|
|
12
|
+
exports.DATA_TOOL_ADMIN = 'data-admin';
|
|
13
|
+
exports.DATA_TOOL_NAMES = [
|
|
14
|
+
exports.DATA_TOOL_DESCRIBE,
|
|
15
|
+
exports.DATA_TOOL_QUERY,
|
|
16
|
+
exports.DATA_TOOL_WRITE,
|
|
17
|
+
exports.DATA_TOOL_ADMIN
|
|
18
|
+
];
|
|
19
|
+
// How Tool health names them: they have no install row, and aren't a name
|
|
20
|
+
// the model made up.
|
|
21
|
+
exports.DATA_TOOL_TITLES = {
|
|
22
|
+
[exports.DATA_TOOL_DESCRIBE]: 'Describe the database',
|
|
23
|
+
[exports.DATA_TOOL_QUERY]: 'Query the database',
|
|
24
|
+
[exports.DATA_TOOL_WRITE]: 'Change rows in the database',
|
|
25
|
+
[exports.DATA_TOOL_ADMIN]: 'Manage the database'
|
|
26
|
+
};
|
|
27
|
+
// How many rows data-query returns at most. The engine pages up to 500; a
|
|
28
|
+
// model reading 500 rows answers worse, not better.
|
|
29
|
+
exports.DATA_TOOL_MAX_LIMIT = 100;
|
|
30
|
+
const READS = {
|
|
31
|
+
readOnlyHint: true,
|
|
32
|
+
destructiveHint: false,
|
|
33
|
+
openWorldHint: false
|
|
34
|
+
};
|
|
35
|
+
// One annotation per tool: a write may delete, so the tool says it is
|
|
36
|
+
// destructive, and the runner and the MCP confirmation decide per call.
|
|
37
|
+
const CHANGES = {
|
|
38
|
+
readOnlyHint: false,
|
|
39
|
+
destructiveHint: true,
|
|
40
|
+
openWorldHint: false
|
|
41
|
+
};
|
|
42
|
+
const WHERE_HELP = 'Filter object. { "column": value } matches exactly; { "column": { "op": value } } with op one of eq, ne, gt, gte, lt, lte, in, notIn (lists), contains, startsWith (text, case-insensitive), isNull (true/false). Several keys must all match; { "or": [ {...}, {...} ] } matches any. A relation column takes the related row\'s id, or filter on a column of the related table with "relation.column", e.g. { "product.name": "Margherita" }. Datetimes are ISO 8601; include the offset for local times, e.g. "2026-10-19T00:00:00-05:00".';
|
|
43
|
+
const accessOf = (caller, table) => caller.restricted ? table.access : 'full';
|
|
44
|
+
const visible = (schema, caller) => schema.tables.filter(table => dataTypes_1.DATA_ACCESS_RANK[accessOf(caller, table)] >= 1);
|
|
45
|
+
// One column as data-query's description lists it: the type when it isn't
|
|
46
|
+
// plain text, so the model can write filters without guessing names.
|
|
47
|
+
const columnHint = (column) => column.type === 'relation'
|
|
48
|
+
? `${column.name} (→ ${column.table})`
|
|
49
|
+
: column.type === 'enum'
|
|
50
|
+
? `${column.name} (${(column.values ?? []).join('|')})`
|
|
51
|
+
: column.type === 'text' || column.type === 'long_text'
|
|
52
|
+
? column.name
|
|
53
|
+
: `${column.name} (${column.type}${column.min !== null ? `, ≥ ${column.min}` : ''})`;
|
|
54
|
+
const tableLine = (caller, table) => {
|
|
55
|
+
const access = accessOf(caller, table);
|
|
56
|
+
const description = table.description?.trim().replace(/\.$/, '');
|
|
57
|
+
return `- ${table.name}${description ? `: ${description}.` : '.'}${caller.restricted && table.customerScoped
|
|
58
|
+
? " Only this customer's own rows are visible."
|
|
59
|
+
: ''}${access === 'read' ? ' Read only.' : access === 'add' ? ' Rows can be added, not changed.' : ''} Columns: ${table.columns
|
|
60
|
+
.map(columnHint)
|
|
61
|
+
.join(', ')}.`;
|
|
62
|
+
};
|
|
63
|
+
const queryLine = (query) => `- ${query.name}${query.description ? `: ${query.description.replace(/\.$/, '')}.` : '.'}${query.params.length
|
|
64
|
+
? ` Params: ${query.params
|
|
65
|
+
.map(p => `${p.name} (${p.type}${p.required === false ? ', optional' : ''})`)
|
|
66
|
+
.join(', ')}.`
|
|
67
|
+
: ''}`;
|
|
68
|
+
/** Whether the caller may use the data tools at all: it sees a table. */
|
|
69
|
+
const hasDataToolTables = (schema, caller) => visible(schema, caller).length > 0;
|
|
70
|
+
exports.hasDataToolTables = hasDataToolTables;
|
|
71
|
+
/**
|
|
72
|
+
* data-describe, data-query and, when the caller may add rows somewhere,
|
|
73
|
+
* data-write. Only tables the caller may see are named, so a hidden table
|
|
74
|
+
* doesn't exist for the model. `queries` are the named queries it may run.
|
|
75
|
+
*/
|
|
76
|
+
const dataToolDefinitions = (schema, caller, options = {}) => {
|
|
77
|
+
const tables = visible(schema, caller);
|
|
78
|
+
if (tables.length === 0)
|
|
79
|
+
return [];
|
|
80
|
+
const queries = options.queries ?? [];
|
|
81
|
+
const timeZone = caller.timeZone || 'UTC';
|
|
82
|
+
const tools = [
|
|
83
|
+
{
|
|
84
|
+
name: exports.DATA_TOOL_DESCRIBE,
|
|
85
|
+
title: exports.DATA_TOOL_TITLES[exports.DATA_TOOL_DESCRIBE],
|
|
86
|
+
description: "Describe the project's database: its tables, their columns (type, allowed values, which table a relation points to, the owner's description of each), row counts, which columns full-text search covers, and what the assistant may do with each table (read, add, or full). Call it before querying a table whose columns you haven't seen in this conversation.",
|
|
87
|
+
inputSchema: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
table: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
description: 'One table to describe. Leave out to describe all of them.'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
annotations: READS
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: exports.DATA_TOOL_QUERY,
|
|
100
|
+
title: exports.DATA_TOOL_TITLES[exports.DATA_TOOL_QUERY],
|
|
101
|
+
description: [
|
|
102
|
+
"Read rows from the project's database: structured records such as products, prices, stock, orders, bookings or customers. Use it for anything with fields and numbers; use the knowledge/resource tools for documents and pages.",
|
|
103
|
+
'Returns matching rows (relation columns come back as { id, label }), the total that match, and nextCursor when there are more. With "aggregate" it returns counts, sums, averages, minimums or maximums instead of rows, optionally per group: use that for "how many" and "how much" rather than adding rows up yourself.',
|
|
104
|
+
"The database holds only what these tables and columns hold. When a question needs something they don't have (opening hours, parking, calories, reviews, forecasts), look in the knowledge tools if you have them; if nothing has it, say you don't have that information. Never guess it.",
|
|
105
|
+
`Every table also has id, created_at and updated_at. Datetimes come back in the project's time zone (${timeZone}) with their offset; read them as local times.`,
|
|
106
|
+
'Tables:',
|
|
107
|
+
tables.map(table => tableLine(caller, table)).join('\n'),
|
|
108
|
+
...(queries.length
|
|
109
|
+
? [
|
|
110
|
+
'Saved reports: instead of "table", pass "query" with its name and "params"; they return exactly what the report computes.',
|
|
111
|
+
queries.map(queryLine).join('\n')
|
|
112
|
+
]
|
|
113
|
+
: [])
|
|
114
|
+
].join('\n'),
|
|
115
|
+
inputSchema: {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {
|
|
118
|
+
table: { type: 'string', description: 'Table to read.' },
|
|
119
|
+
where: { type: 'object', description: WHERE_HELP },
|
|
120
|
+
search: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
description: "Words to look for in the table's searchable text columns (accents and case ignored, ranked by relevance). Use it when the user names something loosely; use where for exact values."
|
|
123
|
+
},
|
|
124
|
+
sort: {
|
|
125
|
+
type: 'array',
|
|
126
|
+
items: { type: 'string' },
|
|
127
|
+
description: 'Columns to sort by, "-" first for descending, e.g. ["-created_at"]. Relation paths allowed.'
|
|
128
|
+
},
|
|
129
|
+
limit: {
|
|
130
|
+
type: 'integer',
|
|
131
|
+
description: `Rows to return, 1 to ${exports.DATA_TOOL_MAX_LIMIT}. Default 20.`
|
|
132
|
+
},
|
|
133
|
+
cursor: {
|
|
134
|
+
type: 'string',
|
|
135
|
+
description: 'nextCursor from the previous call, to get the next page.'
|
|
136
|
+
},
|
|
137
|
+
include: {
|
|
138
|
+
type: 'array',
|
|
139
|
+
items: { type: 'string' },
|
|
140
|
+
description: 'Relation columns to expand into the full related row, e.g. ["customer"].'
|
|
141
|
+
},
|
|
142
|
+
aggregate: {
|
|
143
|
+
type: 'array',
|
|
144
|
+
description: 'Compute instead of listing rows. Each item is { "fn": "count" } or { "fn": "sum"|"avg"|"min"|"max", "column": "..." } (relation paths allowed, e.g. "order.total"). Add "times": "<number column>" to aggregate a product, e.g. { "fn": "sum", "column": "stock", "times": "unit_cost" } for stock value.',
|
|
145
|
+
items: {
|
|
146
|
+
type: 'object',
|
|
147
|
+
properties: {
|
|
148
|
+
fn: {
|
|
149
|
+
type: 'string',
|
|
150
|
+
enum: ['count', 'sum', 'avg', 'min', 'max']
|
|
151
|
+
},
|
|
152
|
+
column: { type: 'string' },
|
|
153
|
+
times: { type: 'string' }
|
|
154
|
+
},
|
|
155
|
+
required: ['fn']
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
groupBy: {
|
|
159
|
+
type: 'array',
|
|
160
|
+
items: { type: 'string' },
|
|
161
|
+
description: 'With aggregate: columns to group by, e.g. ["status"] or ["product"]. Groups come back largest first.'
|
|
162
|
+
},
|
|
163
|
+
...(queries.length
|
|
164
|
+
? {
|
|
165
|
+
query: {
|
|
166
|
+
type: 'string',
|
|
167
|
+
enum: queries.map(q => q.name),
|
|
168
|
+
description: 'A saved report to run instead of reading a table.'
|
|
169
|
+
},
|
|
170
|
+
params: {
|
|
171
|
+
type: 'object',
|
|
172
|
+
description: 'The saved report\'s parameters, e.g. { "from": "2026-10-01" }.'
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
: {})
|
|
176
|
+
},
|
|
177
|
+
...(queries.length ? {} : { required: ['table'] })
|
|
178
|
+
},
|
|
179
|
+
annotations: READS
|
|
180
|
+
}
|
|
181
|
+
];
|
|
182
|
+
if (tables.some(table => dataTypes_1.DATA_ACCESS_RANK[accessOf(caller, table)] >= dataTypes_1.DATA_ACCESS_RANK.add)) {
|
|
183
|
+
tools.push({
|
|
184
|
+
name: exports.DATA_TOOL_WRITE,
|
|
185
|
+
title: exports.DATA_TOOL_TITLES[exports.DATA_TOOL_WRITE],
|
|
186
|
+
description: [
|
|
187
|
+
"Add, change or delete rows in the project's database. All operations in one call succeed together or none is applied, so put everything that belongs together (an order, its lines and the stock they use) in one call.",
|
|
188
|
+
'- insert: { "op": "insert", "table": "...", "values": { column: value } }. A relation column takes the related row\'s id; to point at a row inserted earlier in the same call use { "$ref": n }, n being that operation\'s position (0-based).',
|
|
189
|
+
'- update: { "op": "update", "table": "...", "id": 12, "set": { column: value } }. For numbers, { "decrement": 2 } or { "increment": 2 } changes the value relative to what is stored. Instead of id you can give "where" (same format as data-query).',
|
|
190
|
+
'- delete: { "op": "delete", "table": "...", "id": 12 } (or "where").',
|
|
191
|
+
'Guards: an update or delete also takes "where" conditions that must hold, e.g. "where": { "stock": { "gte": 2 } }, and "expect", how many rows must change (1 by default when id is given). If a guard fails, nothing in the call is written and the error says why (e.g. how much stock is left).',
|
|
192
|
+
'Only use ids you got from data-query or from an earlier insert; never guess them.'
|
|
193
|
+
].join('\n'),
|
|
194
|
+
inputSchema: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {
|
|
197
|
+
operations: {
|
|
198
|
+
type: 'array',
|
|
199
|
+
items: {
|
|
200
|
+
type: 'object',
|
|
201
|
+
properties: {
|
|
202
|
+
op: { type: 'string', enum: ['insert', 'update', 'delete'] },
|
|
203
|
+
table: { type: 'string' },
|
|
204
|
+
id: { type: 'integer' },
|
|
205
|
+
values: { type: 'object' },
|
|
206
|
+
set: { type: 'object' },
|
|
207
|
+
where: { type: 'object' },
|
|
208
|
+
expect: { type: 'integer' }
|
|
209
|
+
},
|
|
210
|
+
required: ['op', 'table']
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
required: ['operations']
|
|
215
|
+
},
|
|
216
|
+
annotations: CHANGES
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return tools;
|
|
220
|
+
};
|
|
221
|
+
exports.dataToolDefinitions = dataToolDefinitions;
|
|
222
|
+
exports.DATA_ADMIN_ACTIONS = [
|
|
223
|
+
'schema',
|
|
224
|
+
'create_table',
|
|
225
|
+
'update_table',
|
|
226
|
+
'drop_table',
|
|
227
|
+
'add_column',
|
|
228
|
+
'update_column',
|
|
229
|
+
'drop_column',
|
|
230
|
+
'save_query',
|
|
231
|
+
'drop_query',
|
|
232
|
+
'import',
|
|
233
|
+
'export'
|
|
234
|
+
];
|
|
235
|
+
/**
|
|
236
|
+
* data-admin: the owner's own MCP client managing the database's structure.
|
|
237
|
+
* One tool, so it costs one slot in the session it exists in; destructive, so
|
|
238
|
+
* every call goes through confirmation and, after outside content, the
|
|
239
|
+
* approval link.
|
|
240
|
+
*/
|
|
241
|
+
const dataAdminToolDefinition = () => ({
|
|
242
|
+
name: exports.DATA_TOOL_ADMIN,
|
|
243
|
+
title: exports.DATA_TOOL_TITLES[exports.DATA_TOOL_ADMIN],
|
|
244
|
+
description: [
|
|
245
|
+
"Manage the project's database structure as its owner: tables, columns, indexes, descriptions, saved reports, imports and exports. To read or change rows use data-query and data-write.",
|
|
246
|
+
'- schema: every table as it would be written again (columns with type, required, unique, filterable, searchable, description, enum values, relation target and minimum), plus the saved reports.',
|
|
247
|
+
'- create_table: "input" is { name, description, displayColumn, access (none|read|add|full: what channel bots may do), customerScoped, columns: [{ name, type, ... }] }. Types: text, long_text, integer, decimal, boolean, date, datetime, enum (with "values"), json, email, url, phone, relation (with "table" and "onDelete": restrict|cascade|set_null), file.',
|
|
248
|
+
'- update_table: "table" and "input" with what changes: name, description, displayColumn, access, customerScoped, history.',
|
|
249
|
+
'- drop_table: "table". It can be undone with a restore from the dashboard.',
|
|
250
|
+
'- add_column: "table" and "input" as one column of create_table.',
|
|
251
|
+
'- update_column: "table", "column" and "input" with what changes: name, type, description, required, unique, filterable (adds an index), searchable, values, min, default. A type change copies the table and refuses if a value doesn\'t fit.',
|
|
252
|
+
'- drop_column: "table" and "column".',
|
|
253
|
+
'- save_query: "input" is { name, description, sql, params: [{ name, type: text|integer|decimal|boolean|date|datetime, description }], assistant }. sql is one SELECT with named parameters (:from); it is checked to only read. assistant: true lets channel bots run it.',
|
|
254
|
+
'- drop_query: "name".',
|
|
255
|
+
'- import: "table" and "resource", the uri of a CSV or Excel file in the project\'s knowledge ("sheet" picks one, the first by default). Headers are matched to columns by name or label, and relation columns by the related row\'s name; rows are added, not replaced. Up to 5 MB.',
|
|
256
|
+
'- export: start a copy of the whole database (format jsonl or csv); download it from the Data page.'
|
|
257
|
+
].join('\n'),
|
|
258
|
+
inputSchema: {
|
|
259
|
+
type: 'object',
|
|
260
|
+
properties: {
|
|
261
|
+
action: { type: 'string', enum: [...exports.DATA_ADMIN_ACTIONS] },
|
|
262
|
+
table: { type: 'string' },
|
|
263
|
+
column: { type: 'string' },
|
|
264
|
+
name: { type: 'string', description: 'drop_query: the saved report.' },
|
|
265
|
+
resource: {
|
|
266
|
+
type: 'string',
|
|
267
|
+
description: 'import: the CSV or Excel resource uri.'
|
|
268
|
+
},
|
|
269
|
+
sheet: {
|
|
270
|
+
type: 'string',
|
|
271
|
+
description: 'import: the Excel sheet; the first by default.'
|
|
272
|
+
},
|
|
273
|
+
format: { type: 'string', enum: ['jsonl', 'csv'] },
|
|
274
|
+
input: { type: 'object' }
|
|
275
|
+
},
|
|
276
|
+
required: ['action']
|
|
277
|
+
},
|
|
278
|
+
annotations: CHANGES
|
|
279
|
+
});
|
|
280
|
+
exports.dataAdminToolDefinition = dataAdminToolDefinition;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
export declare const DATA_COLUMN_TYPES: readonly ["text", "long_text", "integer", "decimal", "boolean", "date", "datetime", "enum", "json", "email", "url", "phone", "relation", "file"];
|
|
2
|
+
export type DataColumnType = (typeof DATA_COLUMN_TYPES)[number];
|
|
3
|
+
export declare const DATA_ACCESS_LEVELS: readonly ["none", "read", "add", "full"];
|
|
4
|
+
export type DataAccess = (typeof DATA_ACCESS_LEVELS)[number];
|
|
5
|
+
export declare const DATA_ACCESS_RANK: Record<DataAccess, number>;
|
|
6
|
+
export declare const DATA_ON_DELETE: readonly ["restrict", "cascade", "set_null"];
|
|
7
|
+
export type DataOnDelete = (typeof DATA_ON_DELETE)[number];
|
|
8
|
+
export type DataDefaultValue = string | number | boolean | null;
|
|
9
|
+
export interface DataColumnInput {
|
|
10
|
+
name: string;
|
|
11
|
+
type: DataColumnType;
|
|
12
|
+
label?: string | null;
|
|
13
|
+
description?: string | null;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
unique?: boolean;
|
|
16
|
+
filterable?: boolean;
|
|
17
|
+
searchable?: boolean;
|
|
18
|
+
personal?: boolean;
|
|
19
|
+
values?: string[];
|
|
20
|
+
table?: string;
|
|
21
|
+
onDelete?: DataOnDelete;
|
|
22
|
+
min?: number | null;
|
|
23
|
+
default?: DataDefaultValue;
|
|
24
|
+
}
|
|
25
|
+
export interface DataTableInput {
|
|
26
|
+
name: string;
|
|
27
|
+
label?: string | null;
|
|
28
|
+
description?: string | null;
|
|
29
|
+
displayColumn?: string | null;
|
|
30
|
+
access?: DataAccess;
|
|
31
|
+
customerScoped?: boolean;
|
|
32
|
+
history?: boolean;
|
|
33
|
+
columns: DataColumnInput[];
|
|
34
|
+
}
|
|
35
|
+
export interface DataColumn {
|
|
36
|
+
id: number;
|
|
37
|
+
name: string;
|
|
38
|
+
type: DataColumnType;
|
|
39
|
+
label: string | null;
|
|
40
|
+
description: string | null;
|
|
41
|
+
required: boolean;
|
|
42
|
+
unique: boolean;
|
|
43
|
+
filterable: boolean;
|
|
44
|
+
searchable: boolean;
|
|
45
|
+
personal: boolean;
|
|
46
|
+
values: string[] | null;
|
|
47
|
+
table: string | null;
|
|
48
|
+
onDelete: DataOnDelete | null;
|
|
49
|
+
min: number | null;
|
|
50
|
+
default: DataDefaultValue | undefined;
|
|
51
|
+
position: number;
|
|
52
|
+
}
|
|
53
|
+
export interface DataTable {
|
|
54
|
+
id: number;
|
|
55
|
+
name: string;
|
|
56
|
+
label: string | null;
|
|
57
|
+
description: string | null;
|
|
58
|
+
displayColumn: string | null;
|
|
59
|
+
access: DataAccess;
|
|
60
|
+
customerScoped: boolean;
|
|
61
|
+
history: boolean;
|
|
62
|
+
position: number;
|
|
63
|
+
columns: DataColumn[];
|
|
64
|
+
}
|
|
65
|
+
export interface DataSchema {
|
|
66
|
+
tables: DataTable[];
|
|
67
|
+
timeZone?: string | null;
|
|
68
|
+
}
|
|
69
|
+
export interface DataCaller {
|
|
70
|
+
actor: string;
|
|
71
|
+
restricted?: boolean;
|
|
72
|
+
participantId?: string;
|
|
73
|
+
tables?: string[];
|
|
74
|
+
timeZone?: string;
|
|
75
|
+
limits?: DataCallerLimits;
|
|
76
|
+
}
|
|
77
|
+
export interface DataCallerLimits {
|
|
78
|
+
maxBytes?: number | null;
|
|
79
|
+
maxTables?: number | null;
|
|
80
|
+
readOnly?: boolean;
|
|
81
|
+
}
|
|
82
|
+
export interface DataUsage {
|
|
83
|
+
rowsRead: number;
|
|
84
|
+
rowsWritten: number;
|
|
85
|
+
}
|
|
86
|
+
export declare const DATA_ERROR_CODES: readonly ["invalid", "not_found", "forbidden", "conflict", "constraint", "guard", "too_large", "full", "read_only", "deleted", "not_initialised", "restore", "internal"];
|
|
87
|
+
export type DataErrorCode = (typeof DATA_ERROR_CODES)[number];
|
|
88
|
+
export declare class DataError extends Error {
|
|
89
|
+
readonly code: DataErrorCode;
|
|
90
|
+
readonly details: Record<string, unknown> | undefined;
|
|
91
|
+
constructor(message: string, code?: DataErrorCode, details?: Record<string, unknown>);
|
|
92
|
+
get status(): 400 | 403 | 404 | 409 | 500;
|
|
93
|
+
toBody(): Record<string, unknown>;
|
|
94
|
+
}
|
|
95
|
+
export declare const isDataError: (error: unknown) => error is DataError;
|
|
96
|
+
export type DataResult<T> = {
|
|
97
|
+
ok: true;
|
|
98
|
+
value: T;
|
|
99
|
+
usage: DataUsage;
|
|
100
|
+
} | {
|
|
101
|
+
ok: false;
|
|
102
|
+
error: {
|
|
103
|
+
code: DataErrorCode;
|
|
104
|
+
message: string;
|
|
105
|
+
details?: Record<string, unknown>;
|
|
106
|
+
};
|
|
107
|
+
usage: DataUsage;
|
|
108
|
+
};
|
|
109
|
+
export declare const DATA_MAX_PARAMS = 100;
|
|
110
|
+
export declare const DATA_MAX_STATEMENT_BYTES = 90000;
|
|
111
|
+
export declare const DATA_MAX_COLUMNS = 93;
|
|
112
|
+
export declare const DATA_MAX_TABLES = 50;
|
|
113
|
+
export declare const DATA_DEFAULT_PAGE = 20;
|
|
114
|
+
export declare const DATA_MAX_PAGE = 500;
|
|
115
|
+
export declare const DATA_MAX_RESULT_BYTES: number;
|
|
116
|
+
export declare const DATA_LARGE_TABLE_ROWS = 200000;
|
|
117
|
+
export declare const DATA_MAX_WRITE_OPERATIONS = 50;
|
|
118
|
+
export declare const DATA_MAX_INSERT_ROWS = 500;
|
|
119
|
+
export declare const DATA_MAX_ROWS_PER_WRITE = 5000;
|
|
120
|
+
export declare const DATA_MAX_VALUE_BYTES = 1000000;
|
|
121
|
+
export declare const DATA_MAX_DESCRIPTION = 300;
|
|
122
|
+
export declare const DATA_MAX_LABEL = 100;
|
|
123
|
+
export declare const DATA_MAX_ENUM_VALUES = 100;
|
|
124
|
+
export declare const DATA_MAX_IN_VALUES = 50;
|
|
125
|
+
export declare const DATA_MAX_SORT_KEYS = 3;
|
|
126
|
+
export declare const DATA_MAX_AGGREGATES = 5;
|
|
127
|
+
export declare const DATA_MAX_GROUP_BY = 3;
|
|
128
|
+
export declare const DATA_MAX_GROUPS = 100;
|
|
129
|
+
export declare const DATA_REBUILD_MAX_ROWS = 100000;
|
|
130
|
+
export declare const DATA_COPY_STEP_ROWS = 5000;
|
|
131
|
+
export declare const DATA_IMPACT_MAX_ROWS = 200000;
|
|
132
|
+
export declare const DATA_IMPACT_MAX_IDS = 5000;
|
|
133
|
+
export declare const DATA_HISTORY_DAYS = 90;
|
|
134
|
+
export interface DataDeleteImpact {
|
|
135
|
+
table: string;
|
|
136
|
+
rows: number;
|
|
137
|
+
effects: {
|
|
138
|
+
table: string;
|
|
139
|
+
column: string;
|
|
140
|
+
onDelete: DataOnDelete;
|
|
141
|
+
rows: number;
|
|
142
|
+
depth: number;
|
|
143
|
+
}[];
|
|
144
|
+
blocked: boolean;
|
|
145
|
+
truncated: boolean;
|
|
146
|
+
}
|
|
147
|
+
export interface DataTableCopy {
|
|
148
|
+
table: string;
|
|
149
|
+
column: string;
|
|
150
|
+
kind: 'change' | 'drop';
|
|
151
|
+
rows: number;
|
|
152
|
+
copied: number;
|
|
153
|
+
startedAt: string;
|
|
154
|
+
actor: string;
|
|
155
|
+
status: 'running' | 'failed';
|
|
156
|
+
error: string | null;
|
|
157
|
+
}
|
|
158
|
+
export declare const toTableInput: (table: DataTable) => DataTableInput;
|
|
159
|
+
//# sourceMappingURL=dataTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataTypes.d.ts","sourceRoot":"","sources":["../src/dataTypes.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,kJAepB,CAAC;AACX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAIhE,eAAO,MAAM,kBAAkB,0CAA2C,CAAC;AAC3E,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC7D,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAKvD,CAAC;AAEF,eAAO,MAAM,cAAc,8CAA+C,CAAC;AAC3E,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MA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