rootr-cli 0.19.0 → 0.22.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.ko.md +45 -3
- package/README.md +41 -6
- package/bin/rootr.js +151 -8
- package/lib/client.js +100 -2
- package/lib/credentials.js +63 -24
- package/lib/mcp-tools/attachments.js +124 -6
- package/lib/mcp-tools/databases.js +289 -4
- package/lib/mcp-tools/forms.js +6 -1
- package/lib/mcp-tools/pages.js +29 -4
- package/lib/mcp-tools/workspaces.js +47 -2
- package/package.json +1 -1
|
@@ -412,6 +412,30 @@ export function registerDatabaseTools(server) {
|
|
|
412
412
|
'Default month. The year view shows twelve mini-months at once (darker = more rows that day). ' +
|
|
413
413
|
'Saved on the view, so everyone who opens it sees that span.',
|
|
414
414
|
),
|
|
415
|
+
cardProps: z
|
|
416
|
+
.array(z.string())
|
|
417
|
+
.nullable()
|
|
418
|
+
.optional()
|
|
419
|
+
.describe(
|
|
420
|
+
'board view only: the fields shown on each card, in this order (names or ids, up to 12). Rollups and formulas ' +
|
|
421
|
+
'work here (e.g. an interview date rolled up from a linked table) — only the picked ones are computed. ' +
|
|
422
|
+
'null or [] goes back to the default (the first 3 stored fields that have a value).',
|
|
423
|
+
),
|
|
424
|
+
rowColors: z
|
|
425
|
+
.array(
|
|
426
|
+
z.object({
|
|
427
|
+
propId: z.string(),
|
|
428
|
+
op: z.enum(['is', 'is_not_empty']),
|
|
429
|
+
values: z.array(z.string()).optional(),
|
|
430
|
+
color: z.string(),
|
|
431
|
+
}),
|
|
432
|
+
)
|
|
433
|
+
.nullable()
|
|
434
|
+
.optional()
|
|
435
|
+
.describe(
|
|
436
|
+
'Tint rows/cards by value: the first matching rule wins. e.g. [{propId:"진행상태",op:"is",values:["채용불가"],color:"red"}, ' +
|
|
437
|
+
'{propId:"면접예정일",op:"is_not_empty",color:"yellow"}]. Colors: gray, brown, orange, yellow, green, blue, purple, pink, red. null or [] turns it off.',
|
|
438
|
+
),
|
|
415
439
|
},
|
|
416
440
|
},
|
|
417
441
|
async ({
|
|
@@ -426,6 +450,8 @@ export function registerDatabaseTools(server) {
|
|
|
426
450
|
sort,
|
|
427
451
|
colWidths,
|
|
428
452
|
calendarScale,
|
|
453
|
+
cardProps,
|
|
454
|
+
rowColors,
|
|
429
455
|
}) => {
|
|
430
456
|
try {
|
|
431
457
|
const client = makeClient();
|
|
@@ -440,6 +466,8 @@ export function registerDatabaseTools(server) {
|
|
|
440
466
|
sort,
|
|
441
467
|
colWidths,
|
|
442
468
|
calendarScale,
|
|
469
|
+
cardProps,
|
|
470
|
+
rowColors,
|
|
443
471
|
});
|
|
444
472
|
return jsonResult({ view });
|
|
445
473
|
} catch (err) {
|
|
@@ -1055,9 +1083,57 @@ export function registerDatabaseTools(server) {
|
|
|
1055
1083
|
'chat, button AI-fill steps, formula/rollup columns and MCP reads still see the values; to hide values from ' +
|
|
1056
1084
|
'people, use an "own rows only" table or a private node. Table managers only. false puts the column back into the index.',
|
|
1057
1085
|
),
|
|
1086
|
+
optionRenames: z
|
|
1087
|
+
.array(z.object({ from: z.string(), to: z.string() }))
|
|
1088
|
+
.optional()
|
|
1089
|
+
.describe(
|
|
1090
|
+
'select/multi_select/status with `options`: rename choices and move every row that used the old name ' +
|
|
1091
|
+
'(e.g. [{from:"신규접수",to:"접수 완료"}]). A choice left out of `options` and not renamed is DELETED and the rows using it are emptied.',
|
|
1092
|
+
),
|
|
1093
|
+
dedupe: z
|
|
1094
|
+
.boolean()
|
|
1095
|
+
.optional()
|
|
1096
|
+
.describe(
|
|
1097
|
+
'title/text/phone/email/url only: warn when another row has the same value (phone numbers compare digits only, ' +
|
|
1098
|
+
'other text ignores case and spaces). People get a choose-merge-or-keep dialog; forms filled inside Rootr warn before submit; ' +
|
|
1099
|
+
'public forms leave a "possible duplicate" comment. See rootr_find_duplicates.',
|
|
1100
|
+
),
|
|
1101
|
+
dedupeShow: z
|
|
1102
|
+
.array(z.string())
|
|
1103
|
+
.nullable()
|
|
1104
|
+
.optional()
|
|
1105
|
+
.describe(
|
|
1106
|
+
'With dedupe on: which fields of the EXISTING row the duplicate dialog shows, in order (column ids). A relation column ' +
|
|
1107
|
+
'shows the latest 5 linked rows (contact history) and the total. Names or ids; an unknown name is refused (400), not dropped. ' +
|
|
1108
|
+
'null/[] = automatic (status, notes, dates, rollups; relations as history).',
|
|
1109
|
+
),
|
|
1110
|
+
relationFilter: z
|
|
1111
|
+
.array(z.object({ propId: z.string(), op: z.enum(['is', 'is_not_empty']), values: z.array(z.string()).optional() }))
|
|
1112
|
+
.nullable()
|
|
1113
|
+
.optional()
|
|
1114
|
+
.describe(
|
|
1115
|
+
'relation only: which rows of the linked table may be linked (all rules must match; propId is a column of the LINKED table). ' +
|
|
1116
|
+
'e.g. [{propId:"진행상태",op:"is",values:["채용"]}]. The picker hides others and the server refuses new links that fail. null turns it off.',
|
|
1117
|
+
),
|
|
1058
1118
|
},
|
|
1059
1119
|
},
|
|
1060
|
-
async ({
|
|
1120
|
+
async ({
|
|
1121
|
+
databaseId,
|
|
1122
|
+
propertyId,
|
|
1123
|
+
name,
|
|
1124
|
+
options,
|
|
1125
|
+
formula,
|
|
1126
|
+
rollup,
|
|
1127
|
+
prefix,
|
|
1128
|
+
reverseName,
|
|
1129
|
+
searchExcluded,
|
|
1130
|
+
optionRenames,
|
|
1131
|
+
dedupe,
|
|
1132
|
+
dedupeShow,
|
|
1133
|
+
relationFilter,
|
|
1134
|
+
type,
|
|
1135
|
+
dimensions,
|
|
1136
|
+
}) => {
|
|
1061
1137
|
// 조용히 무시하지 않는다 — 못 바꾸는 것을 넘기면 까닭과 할 일을 말한다(벡터 차원을 바꾸면 저장된 벡터가 전부 틀려진다).
|
|
1062
1138
|
if (type !== undefined || dimensions !== undefined) {
|
|
1063
1139
|
return errorResult(
|
|
@@ -1078,6 +1154,10 @@ export function registerDatabaseTools(server) {
|
|
|
1078
1154
|
prefix,
|
|
1079
1155
|
reverseName,
|
|
1080
1156
|
searchExcluded,
|
|
1157
|
+
optionRenames,
|
|
1158
|
+
dedupe,
|
|
1159
|
+
dedupeShow,
|
|
1160
|
+
relationFilter,
|
|
1081
1161
|
});
|
|
1082
1162
|
return jsonResult({ property });
|
|
1083
1163
|
} catch (err) {
|
|
@@ -1086,6 +1166,190 @@ export function registerDatabaseTools(server) {
|
|
|
1086
1166
|
},
|
|
1087
1167
|
);
|
|
1088
1168
|
|
|
1169
|
+
// ── DEDUPE(F5) — 같은 사람 찾기·합치기·새 행으로 두기 ─────────────────────
|
|
1170
|
+
//
|
|
1171
|
+
// 화면의 중복 창과 같은 일을 에이전트도 할 수 있어야 한다. 그렇지 않으면 "지원자 붙여 넣으면서 이미 있는 사람은 합쳐 줘"
|
|
1172
|
+
// 같은 부탁에서 에이전트가 표 전체를 읽어 전화번호를 손으로 견주게 된다(9천 행이면 수 MB).
|
|
1173
|
+
|
|
1174
|
+
server.registerTool(
|
|
1175
|
+
'rootr_find_duplicates',
|
|
1176
|
+
{
|
|
1177
|
+
title: 'Find existing rows that duplicate a row (same phone/email/name)',
|
|
1178
|
+
description:
|
|
1179
|
+
'Find rows of a Rootr (루터) DATABASE whose duplicate-detection columns (rootr_update_column dedupe:true — e.g. a phone ' +
|
|
1180
|
+
'column) hold the same value. Phone numbers compare digits only (010-1234-5678 = 01012345678); other text ignores case ' +
|
|
1181
|
+
'and spaces. Give `rowId` to check an existing row (it is excluded from the result) or `values` ({column name or id: value}) ' +
|
|
1182
|
+
'to check before adding. Each match comes with the fields the duplicate dialog shows (`preview`: status, notes, dates, rollups ' +
|
|
1183
|
+
'— or the column\'s dedupeShow list) and `history`: the latest 5 linked rows per relation column (e.g. call log) with the total. ' +
|
|
1184
|
+
'Only rows the caller can see are returned. Then use rootr_merge_rows or rootr_keep_duplicate.',
|
|
1185
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1186
|
+
inputSchema: {
|
|
1187
|
+
databaseId: z.string().describe(DATABASE_TARGET_DESC),
|
|
1188
|
+
rowId: z.string().optional().describe('Check this existing row (its current values).'),
|
|
1189
|
+
values: z.record(z.any()).optional().describe('Or check these values before adding a row: { "연락처": "010-1234-5678" }'),
|
|
1190
|
+
},
|
|
1191
|
+
},
|
|
1192
|
+
async ({ databaseId, rowId, values }) => {
|
|
1193
|
+
try {
|
|
1194
|
+
if (!rowId && !values) return errorResult(new Error('rowId 나 values 중 하나를 주세요.'));
|
|
1195
|
+
const client = makeClient();
|
|
1196
|
+
const id = await resolveNodeId(client, databaseId);
|
|
1197
|
+
return jsonResult(await client.findDuplicates(id, { rowId, values }));
|
|
1198
|
+
} catch (err) {
|
|
1199
|
+
return errorResult(err);
|
|
1200
|
+
}
|
|
1201
|
+
},
|
|
1202
|
+
);
|
|
1203
|
+
|
|
1204
|
+
server.registerTool(
|
|
1205
|
+
'rootr_merge_rows',
|
|
1206
|
+
{
|
|
1207
|
+
title: 'Merge a duplicate row into an existing row',
|
|
1208
|
+
description:
|
|
1209
|
+
'Merge row `rowId` into row `into` of the same Rootr (루터) DATABASE — the "same person applied again" case. Empty cells of ' +
|
|
1210
|
+
'`into` are filled from `rowId` (existing values are kept), relation/multi-select/people/files are unioned (so a call log linked ' +
|
|
1211
|
+
'to the new row moves to the old one), a "🔁 재지원" comment listing the new values is left on `into`, and `rowId` is DELETED ' +
|
|
1212
|
+
'(row history records it as merged into `into`). Both rows must be editable by the caller. Not reversible except by the table history.',
|
|
1213
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
1214
|
+
inputSchema: {
|
|
1215
|
+
databaseId: z.string().describe(DATABASE_TARGET_DESC),
|
|
1216
|
+
rowId: z.string().describe('The newer/duplicate row — it is deleted after merging'),
|
|
1217
|
+
into: z.string().describe('The existing row to keep'),
|
|
1218
|
+
},
|
|
1219
|
+
},
|
|
1220
|
+
async ({ databaseId, rowId, into }) => {
|
|
1221
|
+
try {
|
|
1222
|
+
const client = makeClient();
|
|
1223
|
+
const id = await resolveNodeId(client, databaseId);
|
|
1224
|
+
return jsonResult(await client.mergeRows(id, rowId, into));
|
|
1225
|
+
} catch (err) {
|
|
1226
|
+
return errorResult(err);
|
|
1227
|
+
}
|
|
1228
|
+
},
|
|
1229
|
+
);
|
|
1230
|
+
|
|
1231
|
+
server.registerTool(
|
|
1232
|
+
'rootr_keep_duplicate',
|
|
1233
|
+
{
|
|
1234
|
+
title: 'Keep a duplicate as a new row but link it to the earlier row',
|
|
1235
|
+
description:
|
|
1236
|
+
'The "keep as new row" choice: leaves row `rowId` as it is and writes a 🔗 comment on BOTH rows pointing at each other, so the ' +
|
|
1237
|
+
'earlier history follows the new row. Use when the same person really should have a separate row (e.g. a new application period).',
|
|
1238
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
1239
|
+
inputSchema: {
|
|
1240
|
+
databaseId: z.string().describe(DATABASE_TARGET_DESC),
|
|
1241
|
+
rowId: z.string().describe('The new row to keep'),
|
|
1242
|
+
from: z.string().describe('The earlier row of the same person'),
|
|
1243
|
+
},
|
|
1244
|
+
},
|
|
1245
|
+
async ({ databaseId, rowId, from }) => {
|
|
1246
|
+
try {
|
|
1247
|
+
const client = makeClient();
|
|
1248
|
+
const id = await resolveNodeId(client, databaseId);
|
|
1249
|
+
return jsonResult(await client.keepDuplicate(id, rowId, from));
|
|
1250
|
+
} catch (err) {
|
|
1251
|
+
return errorResult(err);
|
|
1252
|
+
}
|
|
1253
|
+
},
|
|
1254
|
+
);
|
|
1255
|
+
|
|
1256
|
+
// ── ROW-HISTORY / RESTORE(F6·F7·G3) — 행·표 이력과 되돌리기 ─────────────────
|
|
1257
|
+
|
|
1258
|
+
server.registerTool(
|
|
1259
|
+
'rootr_database_history',
|
|
1260
|
+
{
|
|
1261
|
+
title: 'Read the change history of a database (or one row)',
|
|
1262
|
+
description:
|
|
1263
|
+
'Newest-first change history of a Rootr (루터) DATABASE — every create/update/delete with who, when, how (via: button, ' +
|
|
1264
|
+
'automation, form, restore, option-edit, merge:<rowId>, link…) and the before/after values of the changed columns. Give `rowId` ' +
|
|
1265
|
+
'for one row. Page with `before` + `beforeId` (the `at` and `id` of the last item you got). Use the change `id`s with ' +
|
|
1266
|
+
'rootr_restore_row, or an `at` with rootr_restore_database.',
|
|
1267
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1268
|
+
inputSchema: {
|
|
1269
|
+
databaseId: z.string().describe(DATABASE_TARGET_DESC),
|
|
1270
|
+
rowId: z.string().optional(),
|
|
1271
|
+
before: z.string().optional().describe('ISO time — only changes before it (the `at` of the last item of the previous page)'),
|
|
1272
|
+
beforeId: z.string().optional().describe('The `id` of the last item of the previous page (needed when many changes share a time)'),
|
|
1273
|
+
limit: z.number().int().min(1).max(500).optional(),
|
|
1274
|
+
},
|
|
1275
|
+
},
|
|
1276
|
+
async ({ databaseId, rowId, before, beforeId, limit }) => {
|
|
1277
|
+
try {
|
|
1278
|
+
const client = makeClient();
|
|
1279
|
+
const id = await resolveNodeId(client, databaseId);
|
|
1280
|
+
return jsonResult(await client.databaseHistory(id, { rowId, before, beforeId, limit }));
|
|
1281
|
+
} catch (err) {
|
|
1282
|
+
return errorResult(err);
|
|
1283
|
+
}
|
|
1284
|
+
},
|
|
1285
|
+
);
|
|
1286
|
+
|
|
1287
|
+
server.registerTool(
|
|
1288
|
+
'rootr_restore_row',
|
|
1289
|
+
{
|
|
1290
|
+
title: 'Restore one row to how it was at a change',
|
|
1291
|
+
description:
|
|
1292
|
+
'Put ONE row of a Rootr (루터) DATABASE back to its state right after (`side: "after"`, default) or right before (`"before"`) ' +
|
|
1293
|
+
'the change `changeId` from rootr_database_history. A deleted row comes back with the same id (links on the other side are ' +
|
|
1294
|
+
'restored too). The restore itself is recorded in the history, so it can be undone the same way.',
|
|
1295
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
1296
|
+
inputSchema: {
|
|
1297
|
+
databaseId: z.string().describe(DATABASE_TARGET_DESC),
|
|
1298
|
+
rowId: z.string(),
|
|
1299
|
+
changeId: z.string().describe('The history item id'),
|
|
1300
|
+
side: z.enum(['after', 'before']).optional(),
|
|
1301
|
+
},
|
|
1302
|
+
},
|
|
1303
|
+
async ({ databaseId, rowId, changeId, side }) => {
|
|
1304
|
+
try {
|
|
1305
|
+
const client = makeClient();
|
|
1306
|
+
const id = await resolveNodeId(client, databaseId);
|
|
1307
|
+
return jsonResult(await client.restoreRow(id, rowId, changeId, side ?? 'after'));
|
|
1308
|
+
} catch (err) {
|
|
1309
|
+
return errorResult(err);
|
|
1310
|
+
}
|
|
1311
|
+
},
|
|
1312
|
+
);
|
|
1313
|
+
|
|
1314
|
+
server.registerTool(
|
|
1315
|
+
'rootr_restore_database',
|
|
1316
|
+
{
|
|
1317
|
+
title: 'Restore a whole database to a point in time',
|
|
1318
|
+
description:
|
|
1319
|
+
'Put a whole Rootr (루터) DATABASE back to how it was at `at` (ISO time): rows created after it are deleted, rows deleted after ' +
|
|
1320
|
+
'it come back, edited values go back — and the table definition too (columns incl. deleted ones and their values, select ' +
|
|
1321
|
+
'choices, views, buttons, automations) when it was recorded at that time. ALWAYS call with `dryRun: true` first and show ' +
|
|
1322
|
+
'the person the counts (`updates/creates/deletes`, `schema`). Table managers only. Big restores (over 300 rows) run in the ' +
|
|
1323
|
+
'background: the reply has `job`, and this tool waits up to ~2 minutes for it, then returns the progress — call ' +
|
|
1324
|
+
'rootr_restore_database again with `jobId` to keep checking. Automations do not fire while restoring.',
|
|
1325
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
1326
|
+
inputSchema: {
|
|
1327
|
+
databaseId: z.string().describe(DATABASE_TARGET_DESC),
|
|
1328
|
+
at: z.string().optional().describe('ISO time to go back to'),
|
|
1329
|
+
dryRun: z.boolean().optional().describe('true = only count what would change'),
|
|
1330
|
+
jobId: z.string().optional().describe('Check a running background restore instead of starting one'),
|
|
1331
|
+
},
|
|
1332
|
+
},
|
|
1333
|
+
async ({ databaseId, at, dryRun, jobId }) => {
|
|
1334
|
+
try {
|
|
1335
|
+
const client = makeClient();
|
|
1336
|
+
const id = await resolveNodeId(client, databaseId);
|
|
1337
|
+
if (jobId) return jsonResult({ job: await client.restoreJob(id, jobId) });
|
|
1338
|
+
if (!at) return errorResult(new Error('at(ISO 시각)을 주세요.'));
|
|
1339
|
+
const res = await client.restoreDatabase(id, at, { dryRun });
|
|
1340
|
+
if (!res.job) return jsonResult(res);
|
|
1341
|
+
let job = { ...res.job, done: 0, state: 'running' };
|
|
1342
|
+
for (let i = 0; i < 60 && job.state !== 'done'; i++) {
|
|
1343
|
+
await new Promise((r) => setTimeout(r, 2000));
|
|
1344
|
+
job = await client.restoreJob(id, res.job.id);
|
|
1345
|
+
}
|
|
1346
|
+
return jsonResult({ ...res, job });
|
|
1347
|
+
} catch (err) {
|
|
1348
|
+
return errorResult(err);
|
|
1349
|
+
}
|
|
1350
|
+
},
|
|
1351
|
+
);
|
|
1352
|
+
|
|
1089
1353
|
// ── DB-PERM-001 / DB-WATCH — 노션에 없는 두 가지: 자물쇠와 알림 ────────────
|
|
1090
1354
|
//
|
|
1091
1355
|
// 표를 만들 수 있으면 잠글 수도, 누구에게 알릴지 정할 수도 있어야 한다. 이게 없으면
|
|
@@ -1286,12 +1550,27 @@ export function registerDatabaseTools(server) {
|
|
|
1286
1550
|
'row the person pressed on, where `relation` is the relation column IN THE TARGET table that points back ' +
|
|
1287
1551
|
'here. That pair is how "press 전화 on an applicant → a call row already linked to them" becomes one ' +
|
|
1288
1552
|
'press instead of switching tables and searching the person again.\n' +
|
|
1553
|
+
' add_row also takes `match: { key: "{요청 건}", on: "업체명", normalize?: ["spaces","parens","suffix:의원",' +
|
|
1554
|
+
'"trailingDigits","case"], fill?: "empty" }` — FIND-OR-LINK instead of always creating: `key` (filled from the ' +
|
|
1555
|
+
'pressed row) is compared with the target column `on` — first exactly (spaces ignored, so "다라치과(홍대점)" ' +
|
|
1556
|
+
'picks that branch), then after `normalize` (parens drops "(긴급)"·"(소독)", suffix:X drops a trailing X, ' +
|
|
1557
|
+
'trailingDigits drops a trailing number). ONE match → no new row, the pressed row is ADDED to that row\'s `link` ' +
|
|
1558
|
+
'relation (fill:"empty" also fills its blank cells from `values`); NONE → created as usual; TWO OR MORE → ' +
|
|
1559
|
+
'nothing is created and the pressed row gets a "후보 여러 곳: A, B" comment so a person picks. The result ' +
|
|
1560
|
+
'says `matched: { linked, created, ambiguous }`.\n' +
|
|
1289
1561
|
'· {kind:"update_rows", target:"created"|"selected", values} — set values on the rows this button just ' +
|
|
1290
1562
|
'made, or on the rows the person ticked in the table.\n' +
|
|
1291
1563
|
'· {kind:"ai_fill", target, propId, prompt} — let AI write ONE cell. The prompt may quote the row with ' +
|
|
1292
1564
|
'{칸이름}, e.g. "{제목}과 {메모}를 한 문장으로 요약해". If the AI fails the button keeps going.\n' +
|
|
1293
1565
|
'· {kind:"open_row"} — open the row this button made (UI only; over the API it just reports the id).\n' +
|
|
1294
|
-
'Values accept @today, @today+7 and @me — the server fills them in at press time, not now
|
|
1566
|
+
'Values accept @today, @today+7 and @me — the server fills them in at press time, not now. A text value ' +
|
|
1567
|
+
'may also quote the pressed row with {칸이름}, e.g. "{이름} {통화 건수+1}차": computed columns (rollup, ' +
|
|
1568
|
+
'formula) are read too, {칸이름+N} / {칸이름-N} adds to a numeric value, and when several rows are ' +
|
|
1569
|
+
'selected each new row is filled from its own source row. A relation column resolves to the linked row: ' +
|
|
1570
|
+
'{지원자} is its TITLE (not the id) and {지원자.통화 건수} reads one of its columns — EXCEPT when the value ' +
|
|
1571
|
+
'is exactly "{관계 칸}" and the column it goes into is a relation to the SAME table: then the row ids are ' +
|
|
1572
|
+
'copied (e.g. 담당 매니저: "{배정 매니저}"). Ids the receiving column\'s relationFilter rejects are left out ' +
|
|
1573
|
+
'of that cell only (the rest still runs), commented on the row and reported in `notes`.\n' +
|
|
1295
1574
|
'A button never grants permission: it runs as whoever presses it — writing into another table needs ' +
|
|
1296
1575
|
'write access there too.',
|
|
1297
1576
|
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
@@ -1333,7 +1612,9 @@ export function registerDatabaseTools(server) {
|
|
|
1333
1612
|
'Returns `created` (the ARRAY of row ids it made, not a count), `updated` and `filled` counts, the ' +
|
|
1334
1613
|
'`openRowId` a final "open_row" step points at (with `openDatabaseId` when that row is in another ' +
|
|
1335
1614
|
'table), `createdIn` telling which table each new row landed in, and — if the AI could not write a cell — `aiFailed` ' +
|
|
1336
|
-
'with the reason (the rest of the button still ran). ' +
|
|
1615
|
+
'with the reason (the rest of the button still ran). `aiSkipped` counts rows where the AI answered but the ' +
|
|
1616
|
+
'answer could not go in the cell (e.g. not one of a select\'s options), with one sample in `aiSkippedAnswer`; ' +
|
|
1617
|
+
'`aiUnchanged` counts rows whose AI answer equals the current value (left as is, not counted in `filled`). ' +
|
|
1337
1618
|
'It runs with YOUR permissions: a button that writes a locked column stops there if you cannot edit it.',
|
|
1338
1619
|
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
1339
1620
|
inputSchema: {
|
|
@@ -1400,7 +1681,11 @@ export function registerDatabaseTools(server) {
|
|
|
1400
1681
|
'부재 3회 초과 → set the applicant to 보류; every morning at 09:00 → flag rows whose 재통화 예정일 is today.\n' +
|
|
1401
1682
|
'Rules run as the person who SAVED them, never with more permission than that. A rule that a computed ' +
|
|
1402
1683
|
'column (rollup/formula) triggers must use a value comparison, not changed/changed_to — the server ' +
|
|
1403
|
-
'refuses those instead of quietly never firing
|
|
1684
|
+
'refuses those instead of quietly never firing.\n' +
|
|
1685
|
+
'add_row `match` (find-or-link, see rootr_set_database_buttons) is how "투입확정 → 사업장 마스터에 등록" ' +
|
|
1686
|
+
'stops making duplicates for existing customers: one matching 사업장 → linked, none → created, several → a ' +
|
|
1687
|
+
'"후보 여러 곳" comment on the request row. Those notes, and relation ids skipped by a relationFilter, are ' +
|
|
1688
|
+
'written to the rule\'s lastError (with the row) — read them with rootr_list_database_automations.',
|
|
1404
1689
|
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
1405
1690
|
inputSchema: {
|
|
1406
1691
|
databaseId: z.string().describe(DATABASE_TARGET_DESC),
|
package/lib/mcp-tools/forms.js
CHANGED
|
@@ -31,6 +31,10 @@ const fieldShape = z
|
|
|
31
31
|
.boolean()
|
|
32
32
|
.optional()
|
|
33
33
|
.describe('Not shown; filled from the URL (?이름=값). Use to record where a signup came from.'),
|
|
34
|
+
range: z
|
|
35
|
+
.boolean()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe('date only: false = a single date (no end-date input). Omitted/true = start + optional end.'),
|
|
34
38
|
showIf: z
|
|
35
39
|
.object({ fieldId: z.string(), equals: z.string() })
|
|
36
40
|
.optional()
|
|
@@ -45,7 +49,8 @@ const FIELDS_GUIDE =
|
|
|
45
49
|
'Also: time (HH:MM) and file (uploaded on the published page only). ' +
|
|
46
50
|
'select/multi_select/matrix/ranking need `options` ({name,color}[]); matrix also needs `rows`. ' +
|
|
47
51
|
'Per-field extras: `help` (a hint line), `placeholder`, `page` (split into multiple pages), `hidden` + URL ' +
|
|
48
|
-
'params (record the traffic source), `showIf` (show only when an earlier answer matches)
|
|
52
|
+
'params (record the traffic source), `showIf` (show only when an earlier answer matches), `range: false` on a ' +
|
|
53
|
+
'date field (ask for ONE date — by default a date field also shows an optional end date). ' +
|
|
49
54
|
'Read the form first (rootr_read_form) before updating so ' +
|
|
50
55
|
'you keep each field\'s `id` stable — response values are keyed by field id, so renaming/dropping an id orphans ' +
|
|
51
56
|
'past responses\' answers for that field.';
|
package/lib/mcp-tools/pages.js
CHANGED
|
@@ -26,7 +26,9 @@ import {
|
|
|
26
26
|
const BLOCK_GUIDE =
|
|
27
27
|
'A page is `blocks[]` (ordered, max 200) + `config`. Each block is {id?, type, props}. ' +
|
|
28
28
|
'You assemble a page from these block types:\n' +
|
|
29
|
-
'· hero {title, subtitle?, align?:"left"|"center", background?:{kind:"color",color}|{kind:"image",attachmentId}, button?:{label,target}} — the opening banner
|
|
29
|
+
'· hero {title, subtitle?, align?:"left"|"center", size?:"normal"|"screen", background?:{kind:"color",color}|{kind:"image",attachmentId}, button?:{label,target}} — the opening banner. ' +
|
|
30
|
+
'size:"screen" makes it a FULL-SCREEN landing hero: edge to edge and one viewport tall (minus the top name bar, capped at 1200px), big headline, content centred vertically ' +
|
|
31
|
+
'(default "normal" = a compact banner inside the text column)\n' +
|
|
30
32
|
'· text {body (markdown), title?} — prose section; markdown is sanitized when rendered\n' +
|
|
31
33
|
'· features {columns?:1|2|3, items:[{title, body, icon?(emoji)}]} — "what it does" grid\n' +
|
|
32
34
|
'· gallery {images:[{attachmentId, caption?}]} — images must be workspace attachments (no external image URLs)\n' +
|
|
@@ -40,12 +42,35 @@ const BLOCK_GUIDE =
|
|
|
40
42
|
'· liveTable {source:{nodeId}, columns?:[name], rowLimit?(1-200), orderBy?:{column, dir:"asc"|"desc"}}\n' +
|
|
41
43
|
'· liveChart {source:{nodeId, sheet?, range?}, chart, labelColumn, valueColumn?, agg?, …} — a LIVE chart (46 kinds, see CHARTS below)\n' +
|
|
42
44
|
'· form {formNodeId(FORM node), headline?, submitLabel?} — visitors submit right on the page\n' +
|
|
43
|
-
'·
|
|
45
|
+
'· booking {bookingNodeId(DATABASE node id — a table that is published with visitor booking turned on, see rootr_set_booking), headline?, type?} — ' +
|
|
46
|
+
'a visitor scheduling calendar right on the page; `type` shows only one of the table\'s booking types. ' +
|
|
47
|
+
'bookingNodeId must be the node ID (names/paths are not resolved here); a table that is not published or has booking off renders as "not taking bookings"\n' +
|
|
48
|
+
'· custom {html, height?(40-4000, default 260), minHeight?:"none"|"screen", bleed?:boolean} — free HTML/CSS, rendered inside a locked-down sandboxed iframe ' +
|
|
44
49
|
'(no scripts, no same-origin, no network). Use it for a look the other blocks cannot make. Page theme colors are ' +
|
|
45
50
|
'available inside as var(--pg-bg|text|muted|faint|card|line|accent|on-accent) and var(--pg-font). Scripts and ' +
|
|
46
|
-
'on*= handlers are stripped on save — do not put behaviour here, only markup and CSS
|
|
51
|
+
'on*= handlers are stripped on save — do not put behaviour here, only markup and CSS. ' +
|
|
52
|
+
'bleed:true makes the frame span the FULL page width with no gap or padding around it, so consecutive bleed blocks ' +
|
|
53
|
+
'stack into seamless edge-to-edge colour bands (the sandbox is unchanged). Inside a bleed block paint your own ' +
|
|
54
|
+
'full-width background and keep the content in a centred max-width wrapper; still set `height` (the frame does not auto-size). ' +
|
|
55
|
+
'minHeight:"screen" makes the frame ONE VIEWPORT TALL on every device (same rule as hero size:"screen": minus the top name bar, capped at 1200px); ' +
|
|
56
|
+
'a numeric `height` given with it becomes the FLOOR — frame height = max(one screen, height) — so give the height your content ' +
|
|
57
|
+
'needs on a short phone and nothing is clipped. Inside, take the frame height with `height:100%` (html and body already are 100%) ' +
|
|
58
|
+
'and centre the content with flexbox. bleed:true + minHeight:"screen" = a full-screen section; stack several for a ' +
|
|
59
|
+
'section-per-screen landing page.\n' +
|
|
47
60
|
'LAYOUT: any block takes `width:"full"|"twoThirds"|"half"|"third"` — neighbouring blocks sit side by side (phones stack them). ' +
|
|
48
|
-
'That is how a page becomes a DASHBOARD: a row of `chart:"kpi"` blocks at width "third", then charts at width "half"
|
|
61
|
+
'That is how a page becomes a DASHBOARD: a row of `chart:"kpi"` blocks at width "third", then charts at width "half". ' +
|
|
62
|
+
'A hero with size:"screen" and a custom block with bleed:true always take the whole row — `width` is ignored (not stored) on them.\n' +
|
|
63
|
+
'REVEAL (scroll-in animation): any block takes `reveal:"fade"|"fade-up"` (default "none" = always visible). On the published page ' +
|
|
64
|
+
'the block appears ONCE when it scrolls into view (its top passes ~85% of the viewport height; blocks already on the first screen ' +
|
|
65
|
+
'play right after load): "fade" fades in, "fade-up" also rises a little. A hero staggers title → subtitle → button while its ' +
|
|
66
|
+
'background stays put. On a custom block, reveal ALSO starts the CSS animations inside the frame at that moment — the sandboxed ' +
|
|
67
|
+
'frame is created only when the block scrolls in, so `@keyframes`/`animation` in your html run from 0s exactly when the visitor ' +
|
|
68
|
+
'sees the section (without reveal they start at page load and are over before anyone scrolls down). Write those animations so ' +
|
|
69
|
+
'the content is still fine without them and wrap them in `@media (prefers-reduced-motion: no-preference)`. Visitors who ask ' +
|
|
70
|
+
'for reduced motion, and browsers without IntersectionObserver, simply see everything at once; nothing shifts layout. The editor ' +
|
|
71
|
+
'always shows blocks (the effect plays in its preview mode and on the published page).\n' +
|
|
72
|
+
'LANDING PAGE: start with hero size:"screen", follow with custom bleed:true bands (add minHeight:"screen" where a section should fill the screen), and set config.navEnabled:false so the hero owns the first screen. ' +
|
|
73
|
+
'All other blocks stay in the centred text column.\n' +
|
|
49
74
|
'CHARTS (liveChart): chart ∈ bar|barH|stackedBar|stackedBarH|percentBar|lollipop|dumbbell|bullet|waterfall|pareto|radar|polarBar|line|step|area|stackedArea|percentArea|combo|slope|stream|calendar|pie|donut|halfDonut|rose|funnel|treemap|sunburst|waffle|histogram|boxplot|heatmap|scatter|bubble|sankey|chord|network|tree|kpi|gauge|progress|ring|candlestick|gantt|wordCloud|pivot. ' +
|
|
50
75
|
'source = a DATABASE, SPREADSHEET or LOG node (sheet: {nodeId, sheet?(name), range?:"A1:F200"} — first row = column names, formula results are read). ' +
|
|
51
76
|
'Category charts: labelColumn (dates are bucketed: dateBucket day|week|month|quarter|year|weekday|hour, empty periods filled with 0) + ' +
|
|
@@ -3,8 +3,27 @@ import { z } from 'zod';
|
|
|
3
3
|
import { textResult, jsonResult, errorResult, makeClient, requireWorkspace } from './shared.js';
|
|
4
4
|
import { loadConfig } from '../config.js';
|
|
5
5
|
import { currentClientOverride } from '../context.js';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
candidateClients,
|
|
8
|
+
rememberSessionKey,
|
|
9
|
+
rememberWorkspace,
|
|
10
|
+
resolveWorkspaceSwitch,
|
|
11
|
+
surveyWorkspaces,
|
|
12
|
+
} from '../credentials.js';
|
|
7
13
|
import { parseRootrUrl } from '../resolve.js';
|
|
14
|
+
import { t as tr } from '../i18n.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* ISSUE-221 — the workspace this server process was pinned to at launch via the
|
|
18
|
+
* ROOTR_WORKSPACE env var ('' when it was not). Read once, before any switch
|
|
19
|
+
* rewrites process.env: a switch on an env-pinned server only lasts as long as
|
|
20
|
+
* the process does (the MCP client passes the same env again on every restart
|
|
21
|
+
* or reconnect, and env deliberately wins over the config file), so the switch
|
|
22
|
+
* reply has to say where the server will be after a restart — otherwise the
|
|
23
|
+
* next write after a reconnect lands in the pinned workspace while the agent
|
|
24
|
+
* still believes it is in the one it switched to.
|
|
25
|
+
*/
|
|
26
|
+
const LAUNCH_WORKSPACE = process.env.ROOTR_WORKSPACE || '';
|
|
8
27
|
|
|
9
28
|
/**
|
|
10
29
|
* Scaffold `tree` argument schema. Declared as an ARRAY of node objects so MCP
|
|
@@ -22,6 +41,11 @@ const ACCESS_HINT =
|
|
|
22
41
|
'lock) and `database.notifications` (who to notify on row changes). A database property may carry ' +
|
|
23
42
|
'`searchExcluded: true` (values stay out of the search index behind ask / AI explore / similar rows — not a read permission) and a `type: "vector"` ' +
|
|
24
43
|
'property needs `dimensions` (an embedding column agents fill with rootr_set_row_vectors). ' +
|
|
44
|
+
'A phone/email/name property may carry `dedupe: true` (warn when the same person is entered again) with ' +
|
|
45
|
+
'`dedupeShow: ["진행상태","특이사항","콜 이력"]` (fields of the existing row the warning shows — a relation shows its latest 5 rows); ' +
|
|
46
|
+
'a relation property may carry `relationFilter: [{ propId, op: "is"|"is_not_empty", values? }]` (which linked rows may be picked). ' +
|
|
47
|
+
'A board view config may carry `cardProps: ["면접예정일","연락처"]` (fields on each card, rollups too) and any view `rowColors` ' +
|
|
48
|
+
'(`[{ propId, op: "is"|"is_not_empty", values?, color }]`). ' +
|
|
25
49
|
'A DOCUMENT\'s `content` may embed a live ' +
|
|
26
50
|
'table/sheet/deck with a line `[[embed:<name of a node in this same tree>]]` or `[[embed:/absolute/path]]` — it is ' +
|
|
27
51
|
'linked to the real node after the whole tree is built (an unknown name rolls the whole tree back).';
|
|
@@ -49,6 +73,8 @@ export function registerWorkspaceTools(server) {
|
|
|
49
73
|
'reconfiguration, no restart. With an account key (PAT) you can switch to any workspace you belong ' +
|
|
50
74
|
'to; if separate workspace keys are configured, the one that covers the target is selected and ' +
|
|
51
75
|
'remembered automatically. Call rootr_workspaces first if you need to see what is available. ' +
|
|
76
|
+
'If the server was started with the ROOTR_WORKSPACE env var, the switch lasts until the server ' +
|
|
77
|
+
'restarts (the reply says so) — after a restart/reconnect, check rootr_workspaces again. ' +
|
|
52
78
|
'(A hosted/remote connector is bound to a single workspace at consent time and cannot switch.)',
|
|
53
79
|
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
54
80
|
inputSchema: {
|
|
@@ -91,6 +117,9 @@ export function registerWorkspaceTools(server) {
|
|
|
91
117
|
// process, same request loop) picks up the switch immediately.
|
|
92
118
|
if (process.env.ROOTR_WORKSPACE) process.env.ROOTR_WORKSPACE = match.workspace.id;
|
|
93
119
|
if (process.env.ROOTR_API_KEY && match.candidate && match.candidate.apiKey !== process.env.ROOTR_API_KEY) {
|
|
120
|
+
// ISSUE-221 — the key being replaced may exist nowhere but in this
|
|
121
|
+
// process's environment; keep it so switching back still works.
|
|
122
|
+
rememberSessionKey(process.env.ROOTR_API_KEY);
|
|
94
123
|
process.env.ROOTR_API_KEY = match.candidate.apiKey;
|
|
95
124
|
}
|
|
96
125
|
// Verify the switch actually took before reporting success — never
|
|
@@ -107,7 +136,23 @@ export function registerWorkspaceTools(server) {
|
|
|
107
136
|
);
|
|
108
137
|
}
|
|
109
138
|
const name = match.workspace.name || match.workspace.slug || '';
|
|
110
|
-
|
|
139
|
+
// ISSUE-221 — say how long the switch lasts when the server is env-pinned.
|
|
140
|
+
const pinnedNote =
|
|
141
|
+
LAUNCH_WORKSPACE && LAUNCH_WORKSPACE !== match.workspace.id
|
|
142
|
+
? tr(
|
|
143
|
+
`\n주의: 이 MCP 서버는 ROOTR_WORKSPACE 환경변수(${LAUNCH_WORKSPACE})로 고정되어 시작됐습니다. 이 전환은 서버가 ` +
|
|
144
|
+
`켜져 있는 동안만 유효하고, 서버가 재시작(재연결)되면 ${LAUNCH_WORKSPACE} 로 돌아갑니다 — 재시작 뒤에는 쓰기 전에 ` +
|
|
145
|
+
'rootr_workspaces 로 현재 워크스페이스를 다시 확인하세요. 계속 이 워크스페이스를 쓰려면 MCP 서버 설정의 ' +
|
|
146
|
+
`ROOTR_WORKSPACE 를 ${match.workspace.id} 로 바꾸거나 지우세요 (사용자가 직접).`,
|
|
147
|
+
`\nNote: this MCP server was started pinned to ROOTR_WORKSPACE=${LAUNCH_WORKSPACE}. The switch lasts only while ` +
|
|
148
|
+
`the server keeps running; after a restart/reconnect it is back on ${LAUNCH_WORKSPACE} — check rootr_workspaces ` +
|
|
149
|
+
'again before writing. To stay on this workspace, change (or remove) ROOTR_WORKSPACE in the MCP server ' +
|
|
150
|
+
`config to ${match.workspace.id} (a step for the user).`,
|
|
151
|
+
)
|
|
152
|
+
: '';
|
|
153
|
+
return textResult(
|
|
154
|
+
`활성 워크스페이스를 "${name}" (${match.workspace.id}) 로 바꿨습니다. 이후 도구 호출은 여기에 적용됩니다.${pinnedNote}`,
|
|
155
|
+
);
|
|
111
156
|
} catch (err) {
|
|
112
157
|
return errorResult(err);
|
|
113
158
|
}
|