@adminide-stack/yantra-mobile 12.0.141-alpha.1 → 12.0.142-alpha.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/lib/features/agent-chat/NativeAgentChat.js +21 -4
- package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
- package/lib/features/chat/ApprovalCard.js +353 -0
- package/lib/features/chat/ApprovalCard.js.map +1 -0
- package/lib/features/chat/AskUserCard.js +9 -2
- package/lib/features/chat/AskUserCard.js.map +1 -1
- package/lib/features/chat/askUser.js +25 -3
- package/lib/features/chat/askUser.js.map +1 -1
- package/lib/features/chat/queuedFollowUpRows.js +13 -0
- package/lib/features/chat/queuedFollowUpRows.js.map +1 -0
- package/lib/features/dictate/DictateExperience.js +59 -7
- package/lib/features/dictate/DictateExperience.js.map +1 -1
- package/lib/features/dictate/components/NoteView.js +227 -12
- package/lib/features/dictate/components/NoteView.js.map +1 -1
- package/lib/features/dictate/dictateClient.js +93 -23
- package/lib/features/dictate/dictateClient.js.map +1 -1
- package/lib/features/dictate/dictatePreference.js +19 -0
- package/lib/features/dictate/dictatePreference.js.map +1 -0
- package/lib/features/dictate/noteText.js +17 -2
- package/lib/features/dictate/noteText.js.map +1 -1
- package/lib/features/dictate/privacy.js +96 -0
- package/lib/features/dictate/privacy.js.map +1 -0
- package/lib/features/dictate/shownNote.js +24 -0
- package/lib/features/dictate/shownNote.js.map +1 -0
- package/lib/features/discover/DiscoverArticle.js +105 -92
- package/lib/features/discover/DiscoverArticle.js.map +1 -1
- package/lib/features/discover/DiscoverFeed.js +97 -48
- package/lib/features/discover/DiscoverFeed.js.map +1 -1
- package/lib/features/discover/DiscoverFollowUp.js +135 -0
- package/lib/features/discover/DiscoverFollowUp.js.map +1 -0
- package/lib/features/discover/DiscoverSidebar.js +555 -0
- package/lib/features/discover/DiscoverSidebar.js.map +1 -0
- package/lib/features/discover/DiscoverSkeletons.js +123 -0
- package/lib/features/discover/DiscoverSkeletons.js.map +1 -0
- package/lib/features/discover/DiscoverStoryCards.js +193 -87
- package/lib/features/discover/DiscoverStoryCards.js.map +1 -1
- package/lib/features/discover/followUpQuery.js +42 -0
- package/lib/features/discover/followUpQuery.js.map +1 -0
- package/lib/features/discover/markets.js +37 -0
- package/lib/features/discover/markets.js.map +1 -0
- package/lib/features/discover/useDiscoverSidebar.js +148 -0
- package/lib/features/discover/useDiscoverSidebar.js.map +1 -0
- package/lib/features/discover/weather.js +42 -0
- package/lib/features/discover/weather.js.map +1 -0
- package/lib/features/expenses/ExpensesAgentChatPane.js +1 -1
- package/lib/features/expenses/ExpensesAgentChatPane.js.map +1 -1
- package/lib/features/inbox/InboxAgentChatPane.js +1 -1
- package/lib/features/inbox/InboxAgentChatPane.js.map +1 -1
- package/lib/features/job-search/JobSearchAgentChatPane.js +1 -0
- package/lib/features/job-search/JobSearchAgentChatPane.js.map +1 -1
- package/lib/features/local-services/LocalServicesAgentChatPane.js +1 -1
- package/lib/features/local-services/LocalServicesAgentChatPane.js.map +1 -1
- package/lib/features/movies/MoviesAgentChatPane.js +1 -1
- package/lib/features/movies/MoviesAgentChatPane.js.map +1 -1
- package/lib/features/notion/NotionBlockSheets.js +206 -0
- package/lib/features/notion/NotionBlockSheets.js.map +1 -0
- package/lib/features/notion/NotionBlockView.js +36 -0
- package/lib/features/notion/NotionBlockView.js.map +1 -0
- package/lib/features/notion/NotionCommentsSheet.js +461 -0
- package/lib/features/notion/NotionCommentsSheet.js.map +1 -0
- package/lib/features/notion/NotionConnectionsSheet.js +244 -0
- package/lib/features/notion/NotionConnectionsSheet.js.map +1 -0
- package/lib/features/notion/NotionHistorySheet.js +439 -0
- package/lib/features/notion/NotionHistorySheet.js.map +1 -0
- package/lib/features/notion/NotionMediaBlocks.js +803 -0
- package/lib/features/notion/NotionMediaBlocks.js.map +1 -0
- package/lib/features/notion/NotionMentionSheet.js +279 -0
- package/lib/features/notion/NotionMentionSheet.js.map +1 -0
- package/lib/features/notion/NotionPageMenu.js +585 -0
- package/lib/features/notion/NotionPageMenu.js.map +1 -0
- package/lib/features/notion/NotionPageTree.js +220 -0
- package/lib/features/notion/NotionPageTree.js.map +1 -0
- package/lib/features/notion/NotionPageView.js +1253 -152
- package/lib/features/notion/NotionPageView.js.map +1 -1
- package/lib/features/notion/NotionShareSheet.js +606 -0
- package/lib/features/notion/NotionShareSheet.js.map +1 -0
- package/lib/features/notion/NotionSheets.js +87 -15
- package/lib/features/notion/NotionSheets.js.map +1 -1
- package/lib/features/notion/NotionSidebarSections.js +492 -0
- package/lib/features/notion/NotionSidebarSections.js.map +1 -0
- package/lib/features/notion/NotionWorkspaceAdmin.js +659 -0
- package/lib/features/notion/NotionWorkspaceAdmin.js.map +1 -0
- package/lib/features/notion/NotionWorkspaceView.js +257 -45
- package/lib/features/notion/NotionWorkspaceView.js.map +1 -1
- package/lib/features/notion/database/DatabaseCells.js +554 -0
- package/lib/features/notion/database/DatabaseCells.js.map +1 -0
- package/lib/features/notion/database/DatabaseDateLayouts.js +792 -0
- package/lib/features/notion/database/DatabaseDateLayouts.js.map +1 -0
- package/lib/features/notion/database/DatabaseLayouts.js +461 -0
- package/lib/features/notion/database/DatabaseLayouts.js.map +1 -0
- package/lib/features/notion/database/DatabaseSheets.js +791 -0
- package/lib/features/notion/database/DatabaseSheets.js.map +1 -0
- package/lib/features/notion/database/NotionDatabaseView.js +817 -0
- package/lib/features/notion/database/NotionDatabaseView.js.map +1 -0
- package/lib/features/notion/database/RowPropertiesPanel.js +162 -0
- package/lib/features/notion/database/RowPropertiesPanel.js.map +1 -0
- package/lib/features/notion/database/chartData.js +89 -0
- package/lib/features/notion/database/chartData.js.map +1 -0
- package/lib/features/notion/database/chartView.js +112 -0
- package/lib/features/notion/database/chartView.js.map +1 -0
- package/lib/features/notion/database/connectorButton.js +33 -0
- package/lib/features/notion/database/connectorButton.js.map +1 -0
- package/lib/features/notion/database/databaseCalc.js +208 -0
- package/lib/features/notion/database/databaseCalc.js.map +1 -0
- package/lib/features/notion/database/databaseCalendar.js +157 -0
- package/lib/features/notion/database/databaseCalendar.js.map +1 -0
- package/lib/features/notion/database/databaseCsv.js +98 -0
- package/lib/features/notion/database/databaseCsv.js.map +1 -0
- package/lib/features/notion/database/databaseCsvActions.js +58 -0
- package/lib/features/notion/database/databaseCsvActions.js.map +1 -0
- package/lib/features/notion/database/databaseFilter.js +473 -0
- package/lib/features/notion/database/databaseFilter.js.map +1 -0
- package/lib/features/notion/database/databaseFormula.js +1072 -0
- package/lib/features/notion/database/databaseFormula.js.map +1 -0
- package/lib/features/notion/database/databaseGroup.js +151 -0
- package/lib/features/notion/database/databaseGroup.js.map +1 -0
- package/lib/features/notion/database/databaseRollup.js +58 -0
- package/lib/features/notion/database/databaseRollup.js.map +1 -0
- package/lib/features/notion/database/databaseTimeline.js +156 -0
- package/lib/features/notion/database/databaseTimeline.js.map +1 -0
- package/lib/features/notion/database/databaseView.js +1188 -0
- package/lib/features/notion/database/databaseView.js.map +1 -0
- package/lib/features/notion/database/databaseViews.js +310 -0
- package/lib/features/notion/database/databaseViews.js.map +1 -0
- package/lib/features/notion/database/relationSource.js +92 -0
- package/lib/features/notion/database/relationSource.js.map +1 -0
- package/lib/features/notion/database/uniqueId.js +17 -0
- package/lib/features/notion/database/uniqueId.js.map +1 -0
- package/lib/features/notion/database/useNotionDatabase.js +617 -0
- package/lib/features/notion/database/useNotionDatabase.js.map +1 -0
- package/lib/features/notion/notionAgentRunStatus.js +39 -0
- package/lib/features/notion/notionAgentRunStatus.js.map +1 -0
- package/lib/features/notion/notionCodeLanguages.js +112 -0
- package/lib/features/notion/notionCodeLanguages.js.map +1 -0
- package/lib/features/notion/notionComments.js +86 -0
- package/lib/features/notion/notionComments.js.map +1 -0
- package/lib/features/notion/notionConnections.js +74 -0
- package/lib/features/notion/notionConnections.js.map +1 -0
- package/lib/features/notion/notionDocuments.js +453 -1
- package/lib/features/notion/notionDocuments.js.map +1 -1
- package/lib/features/notion/notionEditorModel.js +142 -7
- package/lib/features/notion/notionEditorModel.js.map +1 -1
- package/lib/features/notion/notionMarkdownShortcuts.js +51 -0
- package/lib/features/notion/notionMarkdownShortcuts.js.map +1 -0
- package/lib/features/notion/notionMedia.js +119 -0
- package/lib/features/notion/notionMedia.js.map +1 -0
- package/lib/features/notion/notionMentionDate.js +32 -0
- package/lib/features/notion/notionMentionDate.js.map +1 -0
- package/lib/features/notion/notionMentionOptions.js +162 -0
- package/lib/features/notion/notionMentionOptions.js.map +1 -0
- package/lib/features/notion/notionNotesAgent.js +445 -0
- package/lib/features/notion/notionNotesAgent.js.map +1 -0
- package/lib/features/notion/notionPageAccess.js +168 -0
- package/lib/features/notion/notionPageAccess.js.map +1 -0
- package/lib/features/notion/notionPageActions.js +138 -0
- package/lib/features/notion/notionPageActions.js.map +1 -0
- package/lib/features/notion/notionPageHistory.js +154 -0
- package/lib/features/notion/notionPageHistory.js.map +1 -0
- package/lib/features/notion/notionPageKinds.js +200 -0
- package/lib/features/notion/notionPageKinds.js.map +1 -0
- package/lib/features/notion/notionRecents.js +48 -0
- package/lib/features/notion/notionRecents.js.map +1 -0
- package/lib/features/notion/notionRichText.js +177 -0
- package/lib/features/notion/notionRichText.js.map +1 -0
- package/lib/features/notion/notionRichTitle.js +336 -0
- package/lib/features/notion/notionRichTitle.js.map +1 -0
- package/lib/features/notion/useNotionWorkspace.js +272 -13
- package/lib/features/notion/useNotionWorkspace.js.map +1 -1
- package/lib/features/notion/usePageActions.js +155 -0
- package/lib/features/notion/usePageActions.js.map +1 -0
- package/lib/features/resume/ResumeAgentChatPane.js +1 -1
- package/lib/features/resume/ResumeAgentChatPane.js.map +1 -1
- package/lib/features/shopping/ShoppingAgentChatPane.js +1 -1
- package/lib/features/shopping/ShoppingAgentChatPane.js.map +1 -1
- package/lib/features/study/StudyAgentChatPane.js +1 -1
- package/lib/features/study/StudyAgentChatPane.js.map +1 -1
- package/lib/features/travel/TravelAgentChatPane.js +1 -1
- package/lib/features/travel/TravelAgentChatPane.js.map +1 -1
- package/lib/features/webbuilder/WebBuilderExperience.js +40 -8
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/buildFragments.js +1 -1
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/codeFiles.js +302 -0
- package/lib/features/webbuilder/codeFiles.js.map +1 -0
- package/lib/features/webbuilder/codeHighlight.js +209 -0
- package/lib/features/webbuilder/codeHighlight.js.map +1 -0
- package/lib/features/webbuilder/components/CodeView.js +682 -52
- package/lib/features/webbuilder/components/CodeView.js.map +1 -1
- package/lib/features/webbuilder/components/PreviewScreen.js +59 -38
- package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +3 -3
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/stepLabels.js +68 -0
- package/lib/features/webbuilder/stepLabels.js.map +1 -0
- package/lib/hooks/useHostChatSteering.js +45 -0
- package/lib/hooks/useHostChatSteering.js.map +1 -0
- package/lib/screens/Chat/index.js +2 -12
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/ExpensesNative/useExpensesHostChat.js +25 -5
- package/lib/screens/ExpensesNative/useExpensesHostChat.js.map +1 -1
- package/lib/screens/InboxNative/useInboxHostChat.js +25 -5
- package/lib/screens/InboxNative/useInboxHostChat.js.map +1 -1
- package/lib/screens/JobSearchNative/useJobSearchHostChat.js +25 -5
- package/lib/screens/JobSearchNative/useJobSearchHostChat.js.map +1 -1
- package/lib/screens/LocalServicesNative/useLocalServicesHostChat.js +25 -5
- package/lib/screens/LocalServicesNative/useLocalServicesHostChat.js.map +1 -1
- package/lib/screens/MoviesNative/useMoviesHostChat.js +25 -5
- package/lib/screens/MoviesNative/useMoviesHostChat.js.map +1 -1
- package/lib/screens/NotionPage/index.js +2 -2
- package/lib/screens/NotionPage/index.js.map +1 -1
- package/lib/screens/ResumeNative/useResumeHostChat.js +25 -5
- package/lib/screens/ResumeNative/useResumeHostChat.js.map +1 -1
- package/lib/screens/ShoppingNative/useShoppingHostChat.js +25 -5
- package/lib/screens/ShoppingNative/useShoppingHostChat.js.map +1 -1
- package/lib/screens/StudyNative/useStudyHostChat.js +25 -5
- package/lib/screens/StudyNative/useStudyHostChat.js.map +1 -1
- package/lib/screens/TravelNative/useTravelHostChat.js +25 -5
- package/lib/screens/TravelNative/useTravelHostChat.js.map +1 -1
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js +222 -0
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js.map +1 -0
- package/lib/screens/WebBuilderNative/index.js +1 -1
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/sandboxProxyApi.js +126 -4
- package/lib/screens/WebBuilderNative/sandboxProxyApi.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +120 -11
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import {datePresets,absoluteDateLabel,toLocalISODate,parseMentionDate}from'./notionMentionDate.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
const matches = (label, q) => {
|
|
21
|
+
if (!q) return true;
|
|
22
|
+
const t = label.toLowerCase();
|
|
23
|
+
return t.startsWith(q) || t.split(/\s+/).some((w) => w.startsWith(q)) || t.includes(q);
|
|
24
|
+
};
|
|
25
|
+
function parseTypedDate(query) {
|
|
26
|
+
const q = query.trim();
|
|
27
|
+
if (!/\d/.test(q) || q.length < 6) return null;
|
|
28
|
+
const iso = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(q);
|
|
29
|
+
if (iso) {
|
|
30
|
+
const d = new Date(Number(iso[1]), Number(iso[2]) - 1, Number(iso[3]));
|
|
31
|
+
return d.getMonth() === Number(iso[2]) - 1 ? toLocalISODate(d) : null;
|
|
32
|
+
}
|
|
33
|
+
const t = Date.parse(q);
|
|
34
|
+
if (Number.isNaN(t)) return null;
|
|
35
|
+
return toLocalISODate(new Date(t));
|
|
36
|
+
}
|
|
37
|
+
function buildMentionSections(input) {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
39
|
+
const q = input.query.trim().toLowerCase();
|
|
40
|
+
const now = (_a = input.now) != null ? _a : /* @__PURE__ */ new Date();
|
|
41
|
+
const sections = [];
|
|
42
|
+
const dates = datePresets(now).filter((p) => matches(p.label, q) || q === "now" && p.key === "today").map((p) => ({
|
|
43
|
+
kind: "date",
|
|
44
|
+
key: `date:${p.key}`,
|
|
45
|
+
label: p.label,
|
|
46
|
+
start: p.start,
|
|
47
|
+
hint: absoluteDateLabel(p.start)
|
|
48
|
+
}));
|
|
49
|
+
const typed = parseTypedDate(input.query);
|
|
50
|
+
if (typed && !dates.some((d) => d.kind === "date" && d.start === typed)) dates.unshift({
|
|
51
|
+
kind: "date",
|
|
52
|
+
key: `date:${typed}`,
|
|
53
|
+
label: absoluteDateLabel(typed),
|
|
54
|
+
start: typed,
|
|
55
|
+
hint: ""
|
|
56
|
+
});
|
|
57
|
+
if (!q || matches("pick a date", q) || matches("date", q)) dates.push({
|
|
58
|
+
kind: "pick_date",
|
|
59
|
+
key: "date:pick",
|
|
60
|
+
label: "Pick a date\u2026"
|
|
61
|
+
});
|
|
62
|
+
if (dates.length) sections.push({
|
|
63
|
+
id: "date",
|
|
64
|
+
title: "Date",
|
|
65
|
+
options: dates
|
|
66
|
+
});
|
|
67
|
+
const people = [];
|
|
68
|
+
const seen = /* @__PURE__ */ new Set();
|
|
69
|
+
const me = ((_c = (_b = input.me) == null ? void 0 : _b.name) == null ? void 0 : _c.trim()) ? input.me : null;
|
|
70
|
+
if (me && (matches("me", q) || matches(me.name, q))) {
|
|
71
|
+
people.push(__spreadProps(__spreadValues({
|
|
72
|
+
kind: "user",
|
|
73
|
+
key: "user:me",
|
|
74
|
+
label: `${me.name} (Me)`,
|
|
75
|
+
name: me.name
|
|
76
|
+
}, me.id ? {
|
|
77
|
+
id: me.id
|
|
78
|
+
} : {}), {
|
|
79
|
+
isMe: true
|
|
80
|
+
}));
|
|
81
|
+
seen.add(me.name.toLowerCase());
|
|
82
|
+
}
|
|
83
|
+
for (const name of (_d = input.people) != null ? _d : []) {
|
|
84
|
+
if (people.length >= ((_e = input.maxPeople) != null ? _e : 6)) break;
|
|
85
|
+
const n = name.trim();
|
|
86
|
+
if (!n || seen.has(n.toLowerCase()) || !matches(n, q)) continue;
|
|
87
|
+
seen.add(n.toLowerCase());
|
|
88
|
+
people.push({
|
|
89
|
+
kind: "user",
|
|
90
|
+
key: `user:${n}`,
|
|
91
|
+
label: n,
|
|
92
|
+
name: n
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const typedName = input.query.trim();
|
|
96
|
+
const realPeople = people.length;
|
|
97
|
+
if (typedName && typedName.length <= 60 && !seen.has(typedName.toLowerCase()) && !typed) people.push({
|
|
98
|
+
kind: "user",
|
|
99
|
+
key: "user:new",
|
|
100
|
+
label: `Add \u201C${typedName}\u201D`,
|
|
101
|
+
name: typedName,
|
|
102
|
+
isNew: true
|
|
103
|
+
});
|
|
104
|
+
const peopleSection = people.length ? {
|
|
105
|
+
id: "people",
|
|
106
|
+
title: "People",
|
|
107
|
+
options: people
|
|
108
|
+
} : null;
|
|
109
|
+
if (peopleSection && realPeople) sections.push(peopleSection);
|
|
110
|
+
const pages = ((_f = input.pages) != null ? _f : []).slice(0, (_g = input.maxPages) != null ? _g : 8).map((p) => ({
|
|
111
|
+
kind: "page",
|
|
112
|
+
key: `page:${p.id}`,
|
|
113
|
+
label: p.title || "Untitled",
|
|
114
|
+
page: p
|
|
115
|
+
}));
|
|
116
|
+
if (pages.length) sections.push({
|
|
117
|
+
id: "pages",
|
|
118
|
+
title: "Pages",
|
|
119
|
+
options: pages
|
|
120
|
+
});
|
|
121
|
+
if (peopleSection && !realPeople) sections.push(peopleSection);
|
|
122
|
+
return sections;
|
|
123
|
+
}
|
|
124
|
+
function mentionRunFor(option, start) {
|
|
125
|
+
switch (option.kind) {
|
|
126
|
+
case "date":
|
|
127
|
+
return {
|
|
128
|
+
content: absoluteDateLabel(option.start),
|
|
129
|
+
mention: {
|
|
130
|
+
type: "date",
|
|
131
|
+
start: option.start
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
case "pick_date":
|
|
135
|
+
if (!start || !parseMentionDate(start)) return null;
|
|
136
|
+
return {
|
|
137
|
+
content: absoluteDateLabel(start),
|
|
138
|
+
mention: {
|
|
139
|
+
type: "date",
|
|
140
|
+
start
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
case "user":
|
|
144
|
+
return {
|
|
145
|
+
content: option.name,
|
|
146
|
+
mention: __spreadValues({
|
|
147
|
+
type: "user",
|
|
148
|
+
name: option.name
|
|
149
|
+
}, option.id ? {
|
|
150
|
+
id: option.id
|
|
151
|
+
} : {})
|
|
152
|
+
};
|
|
153
|
+
case "page":
|
|
154
|
+
return {
|
|
155
|
+
content: option.page.title || "Untitled",
|
|
156
|
+
mention: {
|
|
157
|
+
type: "page",
|
|
158
|
+
id: option.page.id
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}export{buildMentionSections,mentionRunFor,parseTypedDate};//# sourceMappingURL=notionMentionOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notionMentionOptions.js","sources":["../../../src/features/notion/notionMentionOptions.ts"],"sourcesContent":["// Ported from forms-stack packages/notion-api/browser/src/utils/mentionOptions.ts (develop); only import paths changed.\n/* eslint-disable */\n/**\n * The @ mention picker's options (pure): Date (Today, Tomorrow, Next week, Pick a date…),\n * People (\"Me\", names used in person properties, \"Add “typed name”\") and Pages.\n */\nimport { absoluteDateLabel, datePresets, parseMentionDate, toLocalISODate } from './notionMentionDate';\nimport type { RichRun } from './notionRichTitle';\n\nexport interface MentionPageCandidate {\n id: string;\n title: string;\n icon?: string;\n type: string;\n}\n\nexport type MentionOption =\n | { kind: 'date'; key: string; label: string; start: string; hint: string }\n | { kind: 'pick_date'; key: string; label: string }\n | { kind: 'user'; key: string; label: string; name: string; id?: string; isMe?: boolean; isNew?: boolean }\n | { kind: 'page'; key: string; label: string; page: MentionPageCandidate };\n\nexport interface MentionSection {\n id: 'date' | 'people' | 'pages';\n title: string;\n options: MentionOption[];\n}\n\nexport interface MentionOptionsInput {\n query: string;\n now?: Date;\n me?: { id?: string; name: string } | null;\n people?: string[];\n pages?: MentionPageCandidate[];\n maxPeople?: number;\n maxPages?: number;\n}\n\nconst matches = (label: string, q: string) => {\n if (!q) return true;\n const t = label.toLowerCase();\n return t.startsWith(q) || t.split(/\\s+/).some((w) => w.startsWith(q)) || t.includes(q);\n};\n\n/** A typed date (\"2027-01-23\", \"Jan 23 2027\", \"1/23/2027\") → `YYYY-MM-DD`, else null. */\nexport function parseTypedDate(query: string): string | null {\n const q = query.trim();\n if (!/\\d/.test(q) || q.length < 6) return null;\n const iso = /^(\\d{4})-(\\d{1,2})-(\\d{1,2})$/.exec(q);\n if (iso) {\n const d = new Date(Number(iso[1]), Number(iso[2]) - 1, Number(iso[3]));\n return d.getMonth() === Number(iso[2]) - 1 ? toLocalISODate(d) : null;\n }\n const t = Date.parse(q);\n if (Number.isNaN(t)) return null;\n return toLocalISODate(new Date(t));\n}\n\nexport function buildMentionSections(input: MentionOptionsInput): MentionSection[] {\n const q = input.query.trim().toLowerCase();\n const now = input.now ?? new Date();\n const sections: MentionSection[] = [];\n\n // Date\n const dates: MentionOption[] = datePresets(now)\n .filter((p) => matches(p.label, q) || (q === 'now' && p.key === 'today'))\n .map((p) => ({\n kind: 'date' as const,\n key: `date:${p.key}`,\n label: p.label,\n start: p.start,\n hint: absoluteDateLabel(p.start),\n }));\n const typed = parseTypedDate(input.query);\n if (typed && !dates.some((d) => d.kind === 'date' && d.start === typed))\n dates.unshift({ kind: 'date', key: `date:${typed}`, label: absoluteDateLabel(typed), start: typed, hint: '' });\n if (!q || matches('pick a date', q) || matches('date', q))\n dates.push({ kind: 'pick_date', key: 'date:pick', label: 'Pick a date…' });\n if (dates.length) sections.push({ id: 'date', title: 'Date', options: dates });\n\n // People\n const people: MentionOption[] = [];\n const seen = new Set<string>();\n const me = input.me?.name?.trim() ? input.me : null;\n if (me && (matches('me', q) || matches(me.name, q))) {\n people.push({\n kind: 'user',\n key: 'user:me',\n label: `${me.name} (Me)`,\n name: me.name,\n ...(me.id ? { id: me.id } : {}),\n isMe: true,\n });\n seen.add(me.name.toLowerCase());\n }\n for (const name of input.people ?? []) {\n if (people.length >= (input.maxPeople ?? 6)) break;\n const n = name.trim();\n if (!n || seen.has(n.toLowerCase()) || !matches(n, q)) continue;\n seen.add(n.toLowerCase());\n people.push({ kind: 'user', key: `user:${n}`, label: n, name: n });\n }\n const typedName = input.query.trim();\n const realPeople = people.length;\n if (typedName && typedName.length <= 60 && !seen.has(typedName.toLowerCase()) && !typed)\n people.push({ kind: 'user', key: 'user:new', label: `Add “${typedName}”`, name: typedName, isNew: true });\n // With no matching person, \"Add “x”\" goes after Pages so a real page match is the default pick.\n const peopleSection: MentionSection | null = people.length\n ? { id: 'people', title: 'People', options: people }\n : null;\n if (peopleSection && realPeople) sections.push(peopleSection);\n\n // Pages (already ranked by the caller)\n const pages: MentionOption[] = (input.pages ?? []).slice(0, input.maxPages ?? 8).map((p) => ({\n kind: 'page' as const,\n key: `page:${p.id}`,\n label: p.title || 'Untitled',\n page: p,\n }));\n if (pages.length) sections.push({ id: 'pages', title: 'Pages', options: pages });\n if (peopleSection && !realPeople) sections.push(peopleSection);\n return sections;\n}\n\n/** The run to insert for a picked option (`pick_date` needs a date first: pass `start`). */\nexport function mentionRunFor(option: MentionOption, start?: string): RichRun | null {\n switch (option.kind) {\n case 'date':\n return { content: absoluteDateLabel(option.start), mention: { type: 'date', start: option.start } };\n case 'pick_date':\n if (!start || !parseMentionDate(start)) return null;\n return { content: absoluteDateLabel(start), mention: { type: 'date', start } };\n case 'user':\n return {\n content: option.name,\n mention: { type: 'user', name: option.name, ...(option.id ? { id: option.id } : {}) },\n };\n case 'page':\n return { content: option.page.title || 'Untitled', mention: { type: 'page', id: option.page.id } };\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAuDA,MAAM,OAAA,GAAU,CAAC,KAAA,EAAe,CAAc,KAAA;AAC5C,EAAI,IAAA,CAAC,GAAU,OAAA,IAAA;AACf,EAAM,MAAA,CAAA,GAAI,MAAM,WAAY,EAAA;AAC5B,EAAA,OAAO,EAAE,UAAW,CAAA,CAAC,CAAK,IAAA,CAAA,CAAE,MAAM,KAAK,CAAA,CAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,UAAW,CAAA,CAAC,CAAC,CAAK,IAAA,CAAA,CAAE,SAAS,CAAC,CAAA;AACrF,CAAA;AAGO,SAAS,eAAe,KAA8B,EAAA;AAC3D,EAAM,MAAA,CAAA,GAAI,MAAM,IAAK,EA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OAAA,EAAS,MAAO,CAAA,IAAA,CAAK,KAAS,IAAA,UAAA;AAAA,QAC9B,OAAS,EAAA;AAAA,UACP,IAAM,EAAA,MAAA;AAAA,UACN,EAAA,EAAI,OAAO,IAAK,CAAA;AAAA;AAClB,OACF;AAAA;AAEN"}
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import {newAgentProperties}from'./notionPageKinds.js';import {isAgentRunStatus,AGENT_RUN_STATUSES,RUN_STATUS_OPTION}from'./notionAgentRunStatus.js';import {textTitle}from'./notionRichTitle.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
const YANTRA_NOTION_TOOL = {
|
|
21
|
+
kind: "yantra-notion",
|
|
22
|
+
connector: "yantra-notion"
|
|
23
|
+
};
|
|
24
|
+
const str = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
|
|
25
|
+
const strList = (v) => Array.isArray(v) ? [...new Set(v.filter((x) => typeof x === "string" && !!x.trim()))] : [];
|
|
26
|
+
function normalizeTrigger(raw) {
|
|
27
|
+
if (!raw || typeof raw !== "object") return null;
|
|
28
|
+
const r = raw;
|
|
29
|
+
switch (r.type) {
|
|
30
|
+
case "manual":
|
|
31
|
+
return {
|
|
32
|
+
type: "manual"
|
|
33
|
+
};
|
|
34
|
+
case "schedule": {
|
|
35
|
+
const cron = str(r.cron);
|
|
36
|
+
if (!cron) return null;
|
|
37
|
+
return __spreadValues(__spreadValues({
|
|
38
|
+
type: "schedule",
|
|
39
|
+
cron
|
|
40
|
+
}, str(r.timezone) ? {
|
|
41
|
+
timezone: str(r.timezone)
|
|
42
|
+
} : {}), str(r.label) ? {
|
|
43
|
+
label: str(r.label)
|
|
44
|
+
} : {});
|
|
45
|
+
}
|
|
46
|
+
case "database_row": {
|
|
47
|
+
const databaseId = str(r.databaseId);
|
|
48
|
+
if (!databaseId) return null;
|
|
49
|
+
return __spreadValues(__spreadValues({
|
|
50
|
+
type: "database_row",
|
|
51
|
+
databaseId,
|
|
52
|
+
on: r.on === "updated" ? "updated" : "created"
|
|
53
|
+
}, r.where && typeof r.where === "object" ? {
|
|
54
|
+
where: r.where
|
|
55
|
+
} : {}), str(r.databaseTitle) ? {
|
|
56
|
+
databaseTitle: str(r.databaseTitle)
|
|
57
|
+
} : {});
|
|
58
|
+
}
|
|
59
|
+
case "comment_mention":
|
|
60
|
+
return {
|
|
61
|
+
type: "comment_mention"
|
|
62
|
+
};
|
|
63
|
+
case "meeting_ended":
|
|
64
|
+
return {
|
|
65
|
+
type: "meeting_ended"
|
|
66
|
+
};
|
|
67
|
+
default:
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function triggerKey(t) {
|
|
72
|
+
return t.type === "database_row" ? `database_row:${t.databaseId}:${t.on}` : t.type;
|
|
73
|
+
}
|
|
74
|
+
function normalizeAgentConfig(raw) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const r = raw && typeof raw === "object" ? raw : {};
|
|
77
|
+
const triggers = [{
|
|
78
|
+
type: "manual"
|
|
79
|
+
}];
|
|
80
|
+
const seen = /* @__PURE__ */ new Set(["manual"]);
|
|
81
|
+
for (const t of Array.isArray(r.triggers) ? r.triggers : []) {
|
|
82
|
+
const n = normalizeTrigger(t);
|
|
83
|
+
if (!n || seen.has(triggerKey(n))) continue;
|
|
84
|
+
seen.add(triggerKey(n));
|
|
85
|
+
triggers.push(n);
|
|
86
|
+
}
|
|
87
|
+
const tools = [__spreadValues({}, YANTRA_NOTION_TOOL)];
|
|
88
|
+
const toolSeen = /* @__PURE__ */ new Set(["yantra-notion"]);
|
|
89
|
+
for (const t of Array.isArray(r.tools) ? r.tools : []) {
|
|
90
|
+
if (!t || typeof t !== "object") continue;
|
|
91
|
+
const tt = t;
|
|
92
|
+
const connector = str(tt.connector);
|
|
93
|
+
if (!connector || toolSeen.has(connector) || tt.kind === "yantra-notion") continue;
|
|
94
|
+
toolSeen.add(connector);
|
|
95
|
+
tools.push(__spreadValues(__spreadValues({
|
|
96
|
+
kind: "connector",
|
|
97
|
+
connector
|
|
98
|
+
}, Array.isArray(tt.actions) ? {
|
|
99
|
+
actions: strList(tt.actions)
|
|
100
|
+
} : {}), str(tt.label) ? {
|
|
101
|
+
label: str(tt.label)
|
|
102
|
+
} : {}));
|
|
103
|
+
}
|
|
104
|
+
const s = r.scope && typeof r.scope === "object" ? r.scope : {};
|
|
105
|
+
const titles = s.titles && typeof s.titles === "object" ? Object.fromEntries(Object.entries(s.titles).filter((e) => typeof e[1] === "string")) : void 0;
|
|
106
|
+
const scope = __spreadValues(__spreadValues({
|
|
107
|
+
pageIds: strList(s.pageIds),
|
|
108
|
+
databaseIds: strList(s.databaseIds)
|
|
109
|
+
}, str(s.teamspace) ? {
|
|
110
|
+
teamspace: str(s.teamspace)
|
|
111
|
+
} : {}), titles && Object.keys(titles).length ? {
|
|
112
|
+
titles
|
|
113
|
+
} : {});
|
|
114
|
+
const lr = r.lastRun;
|
|
115
|
+
const lastRun = lr && typeof lr === "object" && isAgentRunStatus(lr.status) ? __spreadValues(__spreadValues({
|
|
116
|
+
runId: (_a = str(lr.runId)) != null ? _a : "",
|
|
117
|
+
at: (_b = str(lr.at)) != null ? _b : "",
|
|
118
|
+
status: lr.status
|
|
119
|
+
}, str(lr.summary) ? {
|
|
120
|
+
summary: str(lr.summary)
|
|
121
|
+
} : {}), str(lr.sessionId) ? {
|
|
122
|
+
sessionId: str(lr.sessionId)
|
|
123
|
+
} : {}) : void 0;
|
|
124
|
+
return __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({
|
|
125
|
+
version: 1,
|
|
126
|
+
enabled: r.enabled === true
|
|
127
|
+
}, str(r.color) ? {
|
|
128
|
+
color: str(r.color)
|
|
129
|
+
} : {}), {
|
|
130
|
+
triggers,
|
|
131
|
+
tools,
|
|
132
|
+
scope
|
|
133
|
+
}), str(r.model) ? {
|
|
134
|
+
model: str(r.model)
|
|
135
|
+
} : {}), typeof r.requireApproval === "boolean" ? {
|
|
136
|
+
requireApproval: r.requireApproval
|
|
137
|
+
} : {}), lastRun ? {
|
|
138
|
+
lastRun
|
|
139
|
+
} : {}), str(r.runsDatabaseId) ? {
|
|
140
|
+
runsDatabaseId: str(r.runsDatabaseId)
|
|
141
|
+
} : {}), isAgentTemplateId(r.template) ? {
|
|
142
|
+
template: r.template
|
|
143
|
+
} : {});
|
|
144
|
+
}
|
|
145
|
+
const WEEKDAY_NAMES = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
146
|
+
const MAX_MONTH_DAY = 28;
|
|
147
|
+
const clamp = (n, lo, hi, dflt) => {
|
|
148
|
+
const v = typeof n === "number" && Number.isFinite(n) ? Math.round(n) : dflt;
|
|
149
|
+
return Math.min(hi, Math.max(lo, v));
|
|
150
|
+
};
|
|
151
|
+
function scheduleToCron(s) {
|
|
152
|
+
const m = clamp(s.minute, 0, 59, 0);
|
|
153
|
+
const h = clamp(s.hour, 0, 23, 9);
|
|
154
|
+
switch (s.frequency) {
|
|
155
|
+
case "hourly":
|
|
156
|
+
return `${m} * * * *`;
|
|
157
|
+
case "daily":
|
|
158
|
+
return `${m} ${h} * * *`;
|
|
159
|
+
case "weekdays":
|
|
160
|
+
return `${m} ${h} * * 1-5`;
|
|
161
|
+
case "weekly":
|
|
162
|
+
return `${m} ${h} * * ${clamp(s.weekday, 0, 6, 1)}`;
|
|
163
|
+
case "monthly":
|
|
164
|
+
return `${m} ${h} ${clamp(s.dayOfMonth, 1, MAX_MONTH_DAY, 1)} * *`;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const INT = /^\d{1,2}$/;
|
|
168
|
+
function cronToSchedule(cron) {
|
|
169
|
+
const parts = cron.trim().split(/\s+/);
|
|
170
|
+
if (parts.length !== 5) return null;
|
|
171
|
+
const [mi, ho, dom, mon, dow] = parts;
|
|
172
|
+
if (!INT.test(mi) || Number(mi) > 59 || mon !== "*") return null;
|
|
173
|
+
const minute = Number(mi);
|
|
174
|
+
if (ho === "*" && dom === "*" && dow === "*") return {
|
|
175
|
+
frequency: "hourly",
|
|
176
|
+
hour: 0,
|
|
177
|
+
minute
|
|
178
|
+
};
|
|
179
|
+
if (!INT.test(ho) || Number(ho) > 23) return null;
|
|
180
|
+
const hour = Number(ho);
|
|
181
|
+
if (dom === "*" && dow === "*") return {
|
|
182
|
+
frequency: "daily",
|
|
183
|
+
hour,
|
|
184
|
+
minute
|
|
185
|
+
};
|
|
186
|
+
if (dom === "*" && dow === "1-5") return {
|
|
187
|
+
frequency: "weekdays",
|
|
188
|
+
hour,
|
|
189
|
+
minute
|
|
190
|
+
};
|
|
191
|
+
if (dom === "*" && /^[0-7]$/.test(dow)) return {
|
|
192
|
+
frequency: "weekly",
|
|
193
|
+
hour,
|
|
194
|
+
minute,
|
|
195
|
+
weekday: Number(dow) % 7
|
|
196
|
+
};
|
|
197
|
+
if (dow === "*" && INT.test(dom) && Number(dom) >= 1 && Number(dom) <= MAX_MONTH_DAY) {
|
|
198
|
+
return {
|
|
199
|
+
frequency: "monthly",
|
|
200
|
+
hour,
|
|
201
|
+
minute,
|
|
202
|
+
dayOfMonth: Number(dom)
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
const pad2 = (n) => String(n).padStart(2, "0");
|
|
208
|
+
function scheduleLabel(s) {
|
|
209
|
+
const time = `${clamp(s.hour, 0, 23, 9)}:${pad2(clamp(s.minute, 0, 59, 0))}`;
|
|
210
|
+
switch (s.frequency) {
|
|
211
|
+
case "hourly":
|
|
212
|
+
return s.minute ? `Every hour at :${pad2(clamp(s.minute, 0, 59, 0))}` : "Every hour";
|
|
213
|
+
case "daily":
|
|
214
|
+
return `Every day at ${time}`;
|
|
215
|
+
case "weekdays":
|
|
216
|
+
return `Every weekday at ${time}`;
|
|
217
|
+
case "weekly":
|
|
218
|
+
return `Every ${WEEKDAY_NAMES[clamp(s.weekday, 0, 6, 1)]} at ${time}`;
|
|
219
|
+
case "monthly":
|
|
220
|
+
return `Monthly on day ${clamp(s.dayOfMonth, 1, MAX_MONTH_DAY, 1)} at ${time}`;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function scheduleTrigger(s, timezone) {
|
|
224
|
+
return __spreadValues({
|
|
225
|
+
type: "schedule",
|
|
226
|
+
cron: scheduleToCron(s),
|
|
227
|
+
label: scheduleLabel(s)
|
|
228
|
+
}, {});
|
|
229
|
+
}
|
|
230
|
+
function triggerLabel(t) {
|
|
231
|
+
switch (t.type) {
|
|
232
|
+
case "manual":
|
|
233
|
+
return "Manual";
|
|
234
|
+
case "schedule": {
|
|
235
|
+
const friendly = cronToSchedule(t.cron);
|
|
236
|
+
return t.label || (friendly ? scheduleLabel(friendly) : `Cron ${t.cron}`);
|
|
237
|
+
}
|
|
238
|
+
case "database_row":
|
|
239
|
+
return `When a row is ${t.on} in ${t.databaseTitle ? `\u201C${t.databaseTitle}\u201D` : "a database"}`;
|
|
240
|
+
case "comment_mention":
|
|
241
|
+
return "When @mentioned in a comment";
|
|
242
|
+
case "meeting_ended":
|
|
243
|
+
return "When a meeting ends";
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const TRIGGER_KIND_LABEL = {
|
|
247
|
+
manual: "Manual",
|
|
248
|
+
schedule: "Schedule",
|
|
249
|
+
database_row: "Database row",
|
|
250
|
+
comment_mention: "Comment",
|
|
251
|
+
meeting_ended: "Meeting ended"
|
|
252
|
+
};
|
|
253
|
+
const AGENT_TEMPLATES = [{
|
|
254
|
+
id: "blank",
|
|
255
|
+
name: "Blank agent",
|
|
256
|
+
description: "Start from scratch: write what it should do in the page.",
|
|
257
|
+
color: "gray",
|
|
258
|
+
instructions: [{
|
|
259
|
+
type: "heading_2",
|
|
260
|
+
text: "Instructions"
|
|
261
|
+
}, {
|
|
262
|
+
type: "paragraph",
|
|
263
|
+
text: "Describe the job in plain words. The agent reads this page every time it runs."
|
|
264
|
+
}],
|
|
265
|
+
triggers: [{
|
|
266
|
+
type: "manual"
|
|
267
|
+
}],
|
|
268
|
+
tools: [__spreadValues({}, YANTRA_NOTION_TOOL)]
|
|
269
|
+
}, {
|
|
270
|
+
id: "project-updater",
|
|
271
|
+
name: "Project Updater",
|
|
272
|
+
description: "Reads what changed in your projects and posts a weekly update page.",
|
|
273
|
+
color: "blue",
|
|
274
|
+
instructions: [{
|
|
275
|
+
type: "heading_2",
|
|
276
|
+
text: "Goal"
|
|
277
|
+
}, {
|
|
278
|
+
type: "paragraph",
|
|
279
|
+
text: "Keep the team up to date without anyone writing a status report by hand."
|
|
280
|
+
}, {
|
|
281
|
+
type: "heading_2",
|
|
282
|
+
text: "Steps"
|
|
283
|
+
}, {
|
|
284
|
+
type: "numbered_list",
|
|
285
|
+
text: "Look at the pages and databases in scope that changed in the last 7 days."
|
|
286
|
+
}, {
|
|
287
|
+
type: "numbered_list",
|
|
288
|
+
text: "Group the changes by project: shipped, in progress, blocked, and what is due next week."
|
|
289
|
+
}, {
|
|
290
|
+
type: "numbered_list",
|
|
291
|
+
text: "Create a new page titled \u201CUpdate \u2014 <today\u2019s date>\u201D with a short summary and a bulleted list per group."
|
|
292
|
+
}, {
|
|
293
|
+
type: "numbered_list",
|
|
294
|
+
text: "Link every item back to its page or row."
|
|
295
|
+
}, {
|
|
296
|
+
type: "heading_2",
|
|
297
|
+
text: "Style"
|
|
298
|
+
}, {
|
|
299
|
+
type: "bulleted_list",
|
|
300
|
+
text: "Short, factual bullets. No filler."
|
|
301
|
+
}, {
|
|
302
|
+
type: "bulleted_list",
|
|
303
|
+
text: "Call out anything overdue or blocked first."
|
|
304
|
+
}],
|
|
305
|
+
triggers: [{
|
|
306
|
+
type: "manual"
|
|
307
|
+
}, scheduleTrigger({
|
|
308
|
+
frequency: "weekly",
|
|
309
|
+
hour: 9,
|
|
310
|
+
minute: 0,
|
|
311
|
+
weekday: 5
|
|
312
|
+
})],
|
|
313
|
+
tools: [__spreadValues({}, YANTRA_NOTION_TOOL)]
|
|
314
|
+
}, {
|
|
315
|
+
id: "task-router",
|
|
316
|
+
name: "Task Router",
|
|
317
|
+
description: "Finds unassigned tasks and sets an owner and a priority.",
|
|
318
|
+
color: "orange",
|
|
319
|
+
instructions: [{
|
|
320
|
+
type: "heading_2",
|
|
321
|
+
text: "Goal"
|
|
322
|
+
}, {
|
|
323
|
+
type: "paragraph",
|
|
324
|
+
text: "No task sits in the tracker without an owner or a priority."
|
|
325
|
+
}, {
|
|
326
|
+
type: "heading_2",
|
|
327
|
+
text: "Steps"
|
|
328
|
+
}, {
|
|
329
|
+
type: "numbered_list",
|
|
330
|
+
text: "Query the task databases in scope for rows with no \u201CAssigned to\u201D."
|
|
331
|
+
}, {
|
|
332
|
+
type: "numbered_list",
|
|
333
|
+
text: "Pick the owner from who already works on similar tasks; spread the load evenly."
|
|
334
|
+
}, {
|
|
335
|
+
type: "numbered_list",
|
|
336
|
+
text: "Set Priority from the due date and wording: Urgent (due in 2 days or \u201Coutage\u201D), High, Medium, Low."
|
|
337
|
+
}, {
|
|
338
|
+
type: "numbered_list",
|
|
339
|
+
text: "Reply with the rows you changed and why."
|
|
340
|
+
}, {
|
|
341
|
+
type: "heading_2",
|
|
342
|
+
text: "Rules"
|
|
343
|
+
}, {
|
|
344
|
+
type: "bulleted_list",
|
|
345
|
+
text: "Never change a row that already has an owner."
|
|
346
|
+
}, {
|
|
347
|
+
type: "bulleted_list",
|
|
348
|
+
text: "If you are unsure, leave the row and list it in the summary."
|
|
349
|
+
}],
|
|
350
|
+
triggers: [{
|
|
351
|
+
type: "manual"
|
|
352
|
+
}, scheduleTrigger({
|
|
353
|
+
frequency: "weekdays",
|
|
354
|
+
hour: 9,
|
|
355
|
+
minute: 0
|
|
356
|
+
})],
|
|
357
|
+
tools: [__spreadValues({}, YANTRA_NOTION_TOOL)]
|
|
358
|
+
}, {
|
|
359
|
+
id: "it-answer-bot",
|
|
360
|
+
name: "IT Answer Bot",
|
|
361
|
+
description: "Answers IT questions in comment threads from your IT docs.",
|
|
362
|
+
color: "purple",
|
|
363
|
+
note: "Replies in comment threads when comments are available.",
|
|
364
|
+
instructions: [{
|
|
365
|
+
type: "heading_2",
|
|
366
|
+
text: "Goal"
|
|
367
|
+
}, {
|
|
368
|
+
type: "paragraph",
|
|
369
|
+
text: "Answer IT questions (laptops, accounts, VPN, access requests) where people ask them."
|
|
370
|
+
}, {
|
|
371
|
+
type: "heading_2",
|
|
372
|
+
text: "Steps"
|
|
373
|
+
}, {
|
|
374
|
+
type: "numbered_list",
|
|
375
|
+
text: "Read the comment that mentioned you and the page it is on."
|
|
376
|
+
}, {
|
|
377
|
+
type: "numbered_list",
|
|
378
|
+
text: "Search the IT pages in scope for the answer."
|
|
379
|
+
}, {
|
|
380
|
+
type: "numbered_list",
|
|
381
|
+
text: "Reply in the same thread with a short answer and a link to the source page."
|
|
382
|
+
}, {
|
|
383
|
+
type: "heading_2",
|
|
384
|
+
text: "Rules"
|
|
385
|
+
}, {
|
|
386
|
+
type: "bulleted_list",
|
|
387
|
+
text: "If the docs don\u2019t cover it, say so and suggest who to ask."
|
|
388
|
+
}, {
|
|
389
|
+
type: "bulleted_list",
|
|
390
|
+
text: "Never share passwords or secrets."
|
|
391
|
+
}],
|
|
392
|
+
triggers: [{
|
|
393
|
+
type: "manual"
|
|
394
|
+
}, {
|
|
395
|
+
type: "comment_mention"
|
|
396
|
+
}],
|
|
397
|
+
tools: [__spreadValues({}, YANTRA_NOTION_TOOL)]
|
|
398
|
+
}];
|
|
399
|
+
function isAgentTemplateId(v) {
|
|
400
|
+
return typeof v === "string" && AGENT_TEMPLATES.some((t) => t.id === v);
|
|
401
|
+
}
|
|
402
|
+
function agentTemplate(id) {
|
|
403
|
+
var _a;
|
|
404
|
+
return (_a = AGENT_TEMPLATES.find((t) => t.id === id)) != null ? _a : AGENT_TEMPLATES[0];
|
|
405
|
+
}
|
|
406
|
+
function templateInstructionBlocks(t) {
|
|
407
|
+
return t.instructions.map((l) => ({
|
|
408
|
+
type: l.type,
|
|
409
|
+
properties: {
|
|
410
|
+
title: textTitle(l.text)
|
|
411
|
+
}
|
|
412
|
+
}));
|
|
413
|
+
}
|
|
414
|
+
({
|
|
415
|
+
Status: {
|
|
416
|
+
options: AGENT_RUN_STATUSES.map((s) => __spreadValues({}, RUN_STATUS_OPTION[s]))
|
|
417
|
+
},
|
|
418
|
+
Trigger: {
|
|
419
|
+
options: Object.keys(TRIGGER_KIND_LABEL).map((k, i) => {
|
|
420
|
+
var _a;
|
|
421
|
+
return {
|
|
422
|
+
name: TRIGGER_KIND_LABEL[k],
|
|
423
|
+
color: (_a = ["gray", "blue", "purple", "orange", "green"][i]) != null ? _a : "gray"
|
|
424
|
+
};
|
|
425
|
+
})
|
|
426
|
+
}});
|
|
427
|
+
function templateAgentProperties(id, opts = {}) {
|
|
428
|
+
var _a;
|
|
429
|
+
const t = agentTemplate(id);
|
|
430
|
+
const blank = t.id === "blank";
|
|
431
|
+
const base = newAgentProperties(__spreadProps(__spreadValues({}, blank ? {} : {
|
|
432
|
+
name: t.name,
|
|
433
|
+
color: t.color
|
|
434
|
+
}), {
|
|
435
|
+
teamspace: (_a = opts.teamspace) != null ? _a : null
|
|
436
|
+
}));
|
|
437
|
+
const agent = normalizeAgentConfig(__spreadProps(__spreadValues({}, base.agent), {
|
|
438
|
+
triggers: t.triggers,
|
|
439
|
+
tools: t.tools,
|
|
440
|
+
template: t.id
|
|
441
|
+
}));
|
|
442
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
443
|
+
agent
|
|
444
|
+
});
|
|
445
|
+
}export{AGENT_RUN_STATUSES,AGENT_TEMPLATES,MAX_MONTH_DAY,RUN_STATUS_OPTION,TRIGGER_KIND_LABEL,WEEKDAY_NAMES,YANTRA_NOTION_TOOL,agentTemplate,cronToSchedule,isAgentTemplateId,normalizeAgentConfig,scheduleLabel,scheduleToCron,scheduleTrigger,templateAgentProperties,templateInstructionBlocks,triggerKey,triggerLabel};//# sourceMappingURL=notionNotesAgent.js.map
|