@vellumai/assistant 0.4.11 → 0.4.13

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.
Files changed (111) hide show
  1. package/ARCHITECTURE.md +401 -385
  2. package/package.json +1 -1
  3. package/src/__tests__/guardian-verify-setup-skill-regression.test.ts +75 -61
  4. package/src/__tests__/registry.test.ts +235 -187
  5. package/src/__tests__/secure-keys.test.ts +27 -0
  6. package/src/__tests__/session-agent-loop.test.ts +521 -256
  7. package/src/__tests__/session-surfaces-task-progress.test.ts +1 -0
  8. package/src/__tests__/session-tool-setup-app-refresh.test.ts +1 -0
  9. package/src/__tests__/session-tool-setup-memory-scope.test.ts +1 -0
  10. package/src/__tests__/session-tool-setup-side-effect-flag.test.ts +1 -0
  11. package/src/__tests__/skills.test.ts +334 -276
  12. package/src/__tests__/slack-skill.test.ts +124 -0
  13. package/src/__tests__/starter-task-flow.test.ts +7 -17
  14. package/src/agent/loop.ts +10 -3
  15. package/src/config/bundled-skills/chatgpt-import/tools/chatgpt-import.ts +449 -0
  16. package/src/config/bundled-skills/doordash/SKILL.md +171 -0
  17. package/src/config/bundled-skills/doordash/__tests__/doordash-client.test.ts +203 -0
  18. package/src/config/bundled-skills/doordash/__tests__/doordash-session.test.ts +164 -0
  19. package/src/config/bundled-skills/doordash/doordash-cli.ts +1193 -0
  20. package/src/config/bundled-skills/doordash/doordash-entry.ts +22 -0
  21. package/src/config/bundled-skills/doordash/lib/cart-queries.ts +787 -0
  22. package/src/config/bundled-skills/doordash/lib/client.ts +1071 -0
  23. package/src/config/bundled-skills/doordash/lib/order-queries.ts +85 -0
  24. package/src/config/bundled-skills/doordash/lib/queries.ts +28 -0
  25. package/src/config/bundled-skills/doordash/lib/query-extractor.ts +94 -0
  26. package/src/config/bundled-skills/doordash/lib/search-queries.ts +203 -0
  27. package/src/config/bundled-skills/doordash/lib/session.ts +93 -0
  28. package/src/config/bundled-skills/doordash/lib/shared/errors.ts +61 -0
  29. package/src/config/bundled-skills/doordash/lib/shared/ipc.ts +32 -0
  30. package/src/config/bundled-skills/doordash/lib/shared/network-recorder.ts +380 -0
  31. package/src/config/bundled-skills/doordash/lib/shared/platform.ts +35 -0
  32. package/src/config/bundled-skills/doordash/lib/shared/recording-store.ts +43 -0
  33. package/src/config/bundled-skills/doordash/lib/shared/recording-types.ts +49 -0
  34. package/src/config/bundled-skills/doordash/lib/shared/truncate.ts +6 -0
  35. package/src/config/bundled-skills/doordash/lib/store-queries.ts +246 -0
  36. package/src/config/bundled-skills/doordash/lib/types.ts +367 -0
  37. package/src/config/bundled-skills/google-calendar/SKILL.md +4 -5
  38. package/src/config/bundled-skills/google-oauth-setup/SKILL.md +41 -41
  39. package/src/config/bundled-skills/messaging/SKILL.md +59 -42
  40. package/src/config/bundled-skills/messaging/TOOLS.json +14 -92
  41. package/src/config/bundled-skills/messaging/tools/gmail-archive-by-query.ts +5 -1
  42. package/src/config/bundled-skills/messaging/tools/gmail-batch-archive.ts +11 -2
  43. package/src/config/bundled-skills/messaging/tools/gmail-outreach-scan.ts +8 -1
  44. package/src/config/bundled-skills/messaging/tools/gmail-sender-digest.ts +12 -4
  45. package/src/config/bundled-skills/messaging/tools/gmail-unsubscribe.ts +5 -1
  46. package/src/config/bundled-skills/messaging/tools/messaging-archive-by-sender.ts +5 -1
  47. package/src/config/bundled-skills/messaging/tools/messaging-sender-digest.ts +5 -2
  48. package/src/config/bundled-skills/notion/SKILL.md +240 -0
  49. package/src/config/bundled-skills/notion-oauth-setup/SKILL.md +127 -0
  50. package/src/config/bundled-skills/oauth-setup/SKILL.md +144 -0
  51. package/src/config/bundled-skills/phone-calls/SKILL.md +76 -45
  52. package/src/config/bundled-skills/skills-catalog/SKILL.md +32 -29
  53. package/src/config/bundled-skills/slack/SKILL.md +49 -0
  54. package/src/config/bundled-skills/slack/TOOLS.json +167 -0
  55. package/src/config/bundled-skills/slack/tools/shared.ts +23 -0
  56. package/src/config/bundled-skills/{messaging → slack}/tools/slack-add-reaction.ts +2 -5
  57. package/src/config/bundled-skills/slack/tools/slack-channel-details.ts +33 -0
  58. package/src/config/bundled-skills/slack/tools/slack-configure-channels.ts +75 -0
  59. package/src/config/bundled-skills/{messaging → slack}/tools/slack-delete-message.ts +2 -5
  60. package/src/config/bundled-skills/{messaging → slack}/tools/slack-leave-channel.ts +2 -5
  61. package/src/config/bundled-skills/slack/tools/slack-scan-digest.ts +193 -0
  62. package/src/config/{vellum-skills → bundled-skills}/sms-setup/SKILL.md +29 -22
  63. package/src/config/{vellum-skills → bundled-skills}/telegram-setup/SKILL.md +17 -14
  64. package/src/config/{vellum-skills → bundled-skills}/twilio-setup/SKILL.md +20 -5
  65. package/src/config/bundled-tool-registry.ts +292 -267
  66. package/src/config/schema.ts +1 -1
  67. package/src/daemon/handlers/skills.ts +334 -234
  68. package/src/daemon/ipc-contract/messages.ts +2 -0
  69. package/src/daemon/ipc-contract/surfaces.ts +2 -0
  70. package/src/daemon/lifecycle.ts +358 -221
  71. package/src/daemon/response-tier.ts +2 -0
  72. package/src/daemon/server.ts +453 -193
  73. package/src/daemon/session-agent-loop-handlers.ts +43 -2
  74. package/src/daemon/session-agent-loop.ts +3 -0
  75. package/src/daemon/session-lifecycle.ts +3 -0
  76. package/src/daemon/session-process.ts +1 -0
  77. package/src/daemon/session-surfaces.ts +22 -20
  78. package/src/daemon/session-tool-setup.ts +1 -0
  79. package/src/daemon/session.ts +5 -2
  80. package/src/messaging/outreach-classifier.ts +12 -5
  81. package/src/messaging/provider-types.ts +5 -0
  82. package/src/messaging/provider.ts +1 -1
  83. package/src/messaging/providers/gmail/adapter.ts +11 -5
  84. package/src/messaging/providers/gmail/client.ts +2 -0
  85. package/src/messaging/providers/slack/adapter.ts +1 -0
  86. package/src/messaging/providers/slack/client.ts +8 -0
  87. package/src/messaging/providers/slack/types.ts +5 -0
  88. package/src/runtime/http-errors.ts +33 -20
  89. package/src/runtime/http-server.ts +706 -291
  90. package/src/runtime/http-types.ts +26 -16
  91. package/src/runtime/routes/secret-routes.ts +57 -2
  92. package/src/runtime/routes/surface-action-routes.ts +66 -0
  93. package/src/runtime/routes/trust-rules-routes.ts +140 -0
  94. package/src/security/keychain-to-encrypted-migration.ts +59 -0
  95. package/src/security/secure-keys.ts +17 -0
  96. package/src/skills/frontmatter.ts +9 -7
  97. package/src/tools/apps/executors.ts +2 -1
  98. package/src/tools/tool-manifest.ts +44 -42
  99. package/src/tools/types.ts +9 -0
  100. package/src/__tests__/skill-mirror-parity.test.ts +0 -176
  101. package/src/config/vellum-skills/catalog.json +0 -63
  102. package/src/config/vellum-skills/chatgpt-import/tools/chatgpt-import.ts +0 -295
  103. package/src/skills/vellum-catalog-remote.ts +0 -166
  104. package/src/tools/skills/vellum-catalog.ts +0 -168
  105. /package/src/config/{vellum-skills → bundled-skills}/chatgpt-import/SKILL.md +0 -0
  106. /package/src/config/{vellum-skills → bundled-skills}/chatgpt-import/TOOLS.json +0 -0
  107. /package/src/config/{vellum-skills → bundled-skills}/deploy-fullstack-vercel/SKILL.md +0 -0
  108. /package/src/config/{vellum-skills → bundled-skills}/document-writer/SKILL.md +0 -0
  109. /package/src/config/{vellum-skills → bundled-skills}/guardian-verify-setup/SKILL.md +0 -0
  110. /package/src/config/{vellum-skills → bundled-skills}/slack-oauth-setup/SKILL.md +0 -0
  111. /package/src/config/{vellum-skills → bundled-skills}/trusted-contacts/SKILL.md +0 -0
@@ -7,7 +7,11 @@ import { err,ok } from './shared.js';
7
7
  const BATCH_MODIFY_LIMIT = 1000;
8
8
  const MAX_MESSAGES = 5000;
9
9
 
10
- export async function run(input: Record<string, unknown>, _context: ToolContext): Promise<ToolExecutionResult> {
10
+ export async function run(input: Record<string, unknown>, context: ToolContext): Promise<ToolExecutionResult> {
11
+ if (!context.triggeredBySurfaceAction) {
12
+ return err('This tool requires user confirmation via a surface action. Present results in a selection table with action buttons and wait for the user to click before proceeding.');
13
+ }
14
+
11
15
  const query = input.query as string;
12
16
 
13
17
  if (!query) {
@@ -4,7 +4,13 @@ import { withValidToken } from '../../../../security/token-manager.js';
4
4
  import type { ToolContext, ToolExecutionResult } from '../../../../tools/types.js';
5
5
  import { err,ok } from './shared.js';
6
6
 
7
- export async function run(input: Record<string, unknown>, _context: ToolContext): Promise<ToolExecutionResult> {
7
+ const BATCH_MODIFY_LIMIT = 1000;
8
+
9
+ export async function run(input: Record<string, unknown>, context: ToolContext): Promise<ToolExecutionResult> {
10
+ if (!context.triggeredBySurfaceAction) {
11
+ return err('This tool requires user confirmation via a surface action. Present results in a selection table with action buttons and wait for the user to click before proceeding.');
12
+ }
13
+
8
14
  const messageIds = input.message_ids as string[];
9
15
 
10
16
  if (!messageIds?.length) {
@@ -14,7 +20,10 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
14
20
  try {
15
21
  const provider = getMessagingProvider('gmail');
16
22
  return withValidToken(provider.credentialService, async (token) => {
17
- await batchModifyMessages(token, messageIds, { removeLabelIds: ['INBOX'] });
23
+ for (let i = 0; i < messageIds.length; i += BATCH_MODIFY_LIMIT) {
24
+ const chunk = messageIds.slice(i, i + BATCH_MODIFY_LIMIT);
25
+ await batchModifyMessages(token, chunk, { removeLabelIds: ['INBOX'] });
26
+ }
18
27
  return ok(`Archived ${messageIds.length} message(s).`);
19
28
  });
20
29
  } catch (e) {
@@ -70,6 +70,7 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
70
70
  const maxSenders = (input.max_senders as number) ?? 30;
71
71
  const timeRange = (input.time_range as string) ?? '90d';
72
72
  const minConfidence = (input.min_confidence as number) ?? 0.5;
73
+ const inputPageToken = input.page_token as string | undefined;
73
74
 
74
75
  const query = `in:inbox -has:unsubscribe newer_than:${timeRange}`;
75
76
 
@@ -78,7 +79,8 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
78
79
  return withValidToken(provider.credentialService, async (token) => {
79
80
  // Paginate through listMessages to collect up to maxMessages IDs
80
81
  const allMessageIds: string[] = [];
81
- let pageToken: string | undefined;
82
+ let pageToken: string | undefined = inputPageToken;
83
+ let truncated = false;
82
84
 
83
85
  while (allMessageIds.length < maxMessages) {
84
86
  const pageSize = Math.min(100, maxMessages - allMessageIds.length);
@@ -90,6 +92,10 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
90
92
  if (!pageToken) break;
91
93
  }
92
94
 
95
+ if (allMessageIds.length >= maxMessages && pageToken) {
96
+ truncated = true;
97
+ }
98
+
93
99
  if (allMessageIds.length === 0) {
94
100
  return ok(JSON.stringify({ senders: [], total_scanned: 0, outreach_detected: 0, message: 'No emails found matching the query.' }));
95
101
  }
@@ -215,6 +221,7 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
215
221
  senders,
216
222
  total_scanned: allMessageIds.length,
217
223
  outreach_detected: totalOutreachDetected,
224
+ ...(truncated ? { truncated: true, next_page_token: pageToken } : {}),
218
225
  }));
219
226
  });
220
227
  } catch (e) {
@@ -4,8 +4,8 @@ import { withValidToken } from '../../../../security/token-manager.js';
4
4
  import type { ToolContext, ToolExecutionResult } from '../../../../tools/types.js';
5
5
  import { err,ok } from './shared.js';
6
6
 
7
- const MAX_MESSAGES_CAP = 2000;
8
- const MAX_IDS_PER_SENDER = 1000;
7
+ const MAX_MESSAGES_CAP = 500;
8
+ const MAX_IDS_PER_SENDER = 500;
9
9
  const MAX_SAMPLE_SUBJECTS = 3;
10
10
 
11
11
  interface SenderAggregation {
@@ -38,13 +38,15 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
38
38
  const query = (input.query as string) ?? 'category:promotions newer_than:90d';
39
39
  const maxMessages = Math.min((input.max_messages as number) ?? 500, MAX_MESSAGES_CAP);
40
40
  const maxSenders = (input.max_senders as number) ?? 30;
41
+ const inputPageToken = input.page_token as string | undefined;
41
42
 
42
43
  try {
43
44
  const provider = getMessagingProvider('gmail');
44
45
  return withValidToken(provider.credentialService, async (token) => {
45
46
  // Paginate through listMessages to collect up to maxMessages IDs
46
47
  const allMessageIds: string[] = [];
47
- let pageToken: string | undefined;
48
+ let pageToken: string | undefined = inputPageToken;
49
+ let truncated = false;
48
50
 
49
51
  while (allMessageIds.length < maxMessages) {
50
52
  const pageSize = Math.min(100, maxMessages - allMessageIds.length);
@@ -56,6 +58,11 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
56
58
  if (!pageToken) break;
57
59
  }
58
60
 
61
+ // If we stopped because we hit the cap but there were still more pages, flag truncation
62
+ if (allMessageIds.length >= maxMessages && pageToken) {
63
+ truncated = true;
64
+ }
65
+
59
66
  if (allMessageIds.length === 0) {
60
67
  return ok(JSON.stringify({ senders: [], total_scanned: 0, message: 'No emails found matching the query. Try broadening the search (e.g. remove category filter or extend date range).' }));
61
68
  }
@@ -165,7 +172,8 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
165
172
  senders: result,
166
173
  total_scanned: allMessageIds.length,
167
174
  query_used: query,
168
- note: `message_count reflects emails found per sender within the ${allMessageIds.length} messages scanned. The archive tool may find additional messages beyond this sample.`,
175
+ ...(truncated ? { truncated: true, next_page_token: pageToken } : {}),
176
+ note: `message_count reflects emails found per sender within the ${allMessageIds.length} messages scanned. Use the message_ids array with gmail_batch_archive to archive exactly these messages.`,
169
177
  }));
170
178
  });
171
179
  } catch (e) {
@@ -5,7 +5,11 @@ import { isPrivateOrLocalHost, resolveHostAddresses, resolveRequestAddress } fro
5
5
  import type { ToolContext, ToolExecutionResult } from '../../../../tools/types.js';
6
6
  import { err, ok, pinnedHttpsRequest } from './shared.js';
7
7
 
8
- export async function run(input: Record<string, unknown>, _context: ToolContext): Promise<ToolExecutionResult> {
8
+ export async function run(input: Record<string, unknown>, context: ToolContext): Promise<ToolExecutionResult> {
9
+ if (!context.triggeredBySurfaceAction) {
10
+ return err('This tool requires user confirmation via a surface action. Present results in a selection table with action buttons and wait for the user to click before proceeding.');
11
+ }
12
+
9
13
  const messageId = input.message_id as string;
10
14
 
11
15
  if (!messageId) {
@@ -1,7 +1,11 @@
1
1
  import type { ToolContext, ToolExecutionResult } from '../../../../tools/types.js';
2
2
  import { err, ok, resolveProvider, withProviderToken } from './shared.js';
3
3
 
4
- export async function run(input: Record<string, unknown>, _context: ToolContext): Promise<ToolExecutionResult> {
4
+ export async function run(input: Record<string, unknown>, context: ToolContext): Promise<ToolExecutionResult> {
5
+ if (!context.triggeredBySurfaceAction) {
6
+ return err('This tool requires user confirmation via a surface action. Present results in a selection table with action buttons and wait for the user to click before proceeding.');
7
+ }
8
+
5
9
  const platform = input.platform as string | undefined;
6
10
  const query = input.query as string;
7
11
 
@@ -6,6 +6,7 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
6
6
  const query = (input.query as string) ?? 'category:promotions newer_than:90d';
7
7
  const maxMessages = input.max_messages as number | undefined;
8
8
  const maxSenders = input.max_senders as number | undefined;
9
+ const pageToken = input.page_token as string | undefined;
9
10
 
10
11
  try {
11
12
  const provider = resolveProvider(platform);
@@ -15,13 +16,14 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
15
16
  }
16
17
 
17
18
  return withProviderToken(provider, async (token) => {
18
- const result = await provider.senderDigest!(token, query, { maxMessages, maxSenders });
19
+ const result = await provider.senderDigest!(token, query, { maxMessages, maxSenders, pageToken });
19
20
 
20
21
  if (result.senders.length === 0) {
21
22
  return ok(JSON.stringify({
22
23
  senders: [],
23
24
  total_scanned: result.totalScanned,
24
25
  query_used: result.queryUsed,
26
+ ...(result.truncated ? { truncated: true, next_page_token: result.nextPageToken } : {}),
25
27
  message: 'No emails found matching the query. Try broadening the search (e.g. remove category filter or extend date range).',
26
28
  }));
27
29
  }
@@ -43,7 +45,8 @@ export async function run(input: Record<string, unknown>, _context: ToolContext)
43
45
  senders,
44
46
  total_scanned: result.totalScanned,
45
47
  query_used: result.queryUsed,
46
- note: `message_count reflects emails found per sender within the ${result.totalScanned} messages scanned. The archive tool may find additional messages beyond this sample.`,
48
+ ...(result.truncated ? { truncated: true, next_page_token: result.nextPageToken } : {}),
49
+ note: `message_count reflects emails found per sender within the ${result.totalScanned} messages scanned. Use the message_ids array with the archive tool to archive exactly these messages.`,
47
50
  }));
48
51
  });
49
52
  } catch (e) {
@@ -0,0 +1,240 @@
1
+ ---
2
+ name: "Notion"
3
+ description: "Read and write Notion pages and databases using the Notion API"
4
+ user-invocable: false
5
+ metadata: {"vellum": {"emoji": "📝"}}
6
+ ---
7
+
8
+ You have access to the Notion API via the stored OAuth token for `integration:notion`. Use `bash` with `network_mode: "proxied"` to call the Notion API — the proxy automatically injects the Bearer token for `api.notion.com`.
9
+
10
+ ## Authentication
11
+
12
+ The Notion access token is stored securely and never exposed as plaintext. Use the credential proxy to inject the Bearer token automatically.
13
+
14
+ **Step 1 — Get the credential ID:**
15
+ ```
16
+ credential_store action=list
17
+ ```
18
+ Find the entry with `service: "integration:notion"` and `field: "access_token"`. Note its `credential_id`.
19
+
20
+ If no such entry exists, tell the user: "Notion is not connected yet. Load the **notion-oauth-setup** skill to set it up first."
21
+
22
+ **Step 2 — Make authenticated API calls via the proxy:**
23
+
24
+ Use `bash` with `network_mode: "proxied"` and `credential_ids: ["<credential_id>"]`. The proxy automatically injects `Authorization: Bearer <token>` and any required headers into requests to `api.notion.com`.
25
+
26
+ Example:
27
+ ```
28
+ bash:
29
+ network_mode: proxied
30
+ credential_ids: ["<credential_id from step 1>"]
31
+ command: |
32
+ curl -s -X POST https://api.notion.com/v1/search \
33
+ -H "Notion-Version: 2022-06-28" \
34
+ -H "Content-Type: application/json" \
35
+ -d '{}'
36
+ ```
37
+
38
+ All Notion API calls go to `https://api.notion.com/v1/`. Always include the `Notion-Version: 2022-06-28` header.
39
+
40
+ ## Reading Pages
41
+
42
+ ### Get a page by ID
43
+ ```
44
+ GET https://api.notion.com/v1/pages/{page_id}
45
+ ```
46
+ Returns page properties. Use the page ID from a Notion URL — the last segment of the URL, e.g. for `https://notion.so/My-Page-abc123def456` the ID is `abc123def456` (formatted as UUID: `abc123de-f456-...`).
47
+
48
+ ### Get page content (blocks)
49
+ ```
50
+ GET https://api.notion.com/v1/blocks/{block_id}/children?page_size=100
51
+ ```
52
+ Pages are blocks too — use the page ID as the `block_id`. Iterates through the page's child blocks. Use `start_cursor` for pagination when `has_more` is `true`.
53
+
54
+ **Block types and how to render them:**
55
+ - `paragraph`: Read `paragraph.rich_text[].plain_text`
56
+ - `heading_1`, `heading_2`, `heading_3`: Read `heading_N.rich_text[].plain_text`
57
+ - `bulleted_list_item`, `numbered_list_item`: Read `*.rich_text[].plain_text`
58
+ - `to_do`: Read `to_do.rich_text[].plain_text` and `to_do.checked`
59
+ - `toggle`: Read `toggle.rich_text[].plain_text`; children are nested blocks
60
+ - `code`: Read `code.rich_text[].plain_text` and `code.language`
61
+ - `quote`: Read `quote.rich_text[].plain_text`
62
+ - `callout`: Read `callout.rich_text[].plain_text`
63
+ - `divider`: Render as `---`
64
+ - `image`: Read `image.external.url` or `image.file.url`
65
+ - `child_page`: Read `child_page.title`; use its `id` to recursively fetch if needed
66
+
67
+ ## Searching
68
+
69
+ ### Search pages and databases
70
+ ```
71
+ POST https://api.notion.com/v1/search
72
+ {
73
+ "query": "your search term",
74
+ "filter": { "value": "page", "property": "object" },
75
+ "sort": { "direction": "descending", "timestamp": "last_edited_time" },
76
+ "page_size": 10
77
+ }
78
+ ```
79
+ Omit `filter` to search both pages and databases. Use `filter.value: "database"` to search only databases.
80
+
81
+ Returns `results[]` with `id`, `url`, `properties.title` (for pages), and `title[]` (for databases).
82
+
83
+ ## Reading Databases
84
+
85
+ ### Get database metadata
86
+ ```
87
+ GET https://api.notion.com/v1/databases/{database_id}
88
+ ```
89
+ Returns the database schema (all property definitions).
90
+
91
+ ### Query a database
92
+ ```
93
+ POST https://api.notion.com/v1/databases/{database_id}/query
94
+ {
95
+ "filter": {
96
+ "property": "Status",
97
+ "select": { "equals": "In Progress" }
98
+ },
99
+ "sorts": [
100
+ { "property": "Created", "direction": "descending" }
101
+ ],
102
+ "page_size": 20
103
+ }
104
+ ```
105
+ Omit `filter` to retrieve all rows. Returns `results[]` where each item is a page (database row).
106
+
107
+ **Extracting property values from database rows:**
108
+ - `title`: `properties.Name.title[].plain_text`
109
+ - `rich_text`: `properties.Notes.rich_text[].plain_text`
110
+ - `number`: `properties.Price.number`
111
+ - `select`: `properties.Status.select.name`
112
+ - `multi_select`: `properties.Tags.multi_select[].name`
113
+ - `date`: `properties.Due.date.start` (ISO 8601)
114
+ - `checkbox`: `properties.Done.checkbox`
115
+ - `url`: `properties.Link.url`
116
+ - `email`: `properties.Email.email`
117
+ - `people`: `properties.Owner.people[].name`
118
+ - `relation`: `properties.Projects.relation[].id` (array of page IDs)
119
+
120
+ ## Creating Pages
121
+
122
+ ### Create a new page
123
+ ```
124
+ POST https://api.notion.com/v1/pages
125
+ {
126
+ "parent": { "page_id": "<parent_page_id>" },
127
+ "properties": {
128
+ "title": {
129
+ "title": [{ "text": { "content": "My New Page" } }]
130
+ }
131
+ },
132
+ "children": [
133
+ {
134
+ "object": "block",
135
+ "type": "paragraph",
136
+ "paragraph": {
137
+ "rich_text": [{ "text": { "content": "Page content here." } }]
138
+ }
139
+ }
140
+ ]
141
+ }
142
+ ```
143
+
144
+ For database rows, use `"parent": { "database_id": "<database_id>" }` and include the database's required properties.
145
+
146
+ ## Updating Pages
147
+
148
+ ### Update page properties
149
+ ```
150
+ PATCH https://api.notion.com/v1/pages/{page_id}
151
+ {
152
+ "properties": {
153
+ "Status": { "select": { "name": "Done" } },
154
+ "Due": { "date": { "start": "2024-12-31" } }
155
+ }
156
+ }
157
+ ```
158
+
159
+ ### Append blocks to a page
160
+ ```
161
+ PATCH https://api.notion.com/v1/blocks/{block_id}/children
162
+ {
163
+ "children": [
164
+ {
165
+ "object": "block",
166
+ "type": "paragraph",
167
+ "paragraph": {
168
+ "rich_text": [{ "text": { "content": "Appended content." } }]
169
+ }
170
+ },
171
+ {
172
+ "object": "block",
173
+ "type": "heading_2",
174
+ "heading_2": {
175
+ "rich_text": [{ "text": { "content": "A heading" } }]
176
+ }
177
+ },
178
+ {
179
+ "object": "block",
180
+ "type": "bulleted_list_item",
181
+ "bulleted_list_item": {
182
+ "rich_text": [{ "text": { "content": "A bullet point" } }]
183
+ }
184
+ },
185
+ {
186
+ "object": "block",
187
+ "type": "to_do",
188
+ "to_do": {
189
+ "rich_text": [{ "text": { "content": "A task" } }],
190
+ "checked": false
191
+ }
192
+ }
193
+ ]
194
+ }
195
+ ```
196
+
197
+ ### Update a block's content
198
+ ```
199
+ PATCH https://api.notion.com/v1/blocks/{block_id}
200
+ {
201
+ "paragraph": {
202
+ "rich_text": [{ "text": { "content": "Updated text." } }]
203
+ }
204
+ }
205
+ ```
206
+
207
+ ### Delete (archive) a block
208
+ ```
209
+ DELETE https://api.notion.com/v1/blocks/{block_id}
210
+ ```
211
+
212
+ ## Archive / Delete Pages
213
+
214
+ Notion does not permanently delete pages via the API — it archives them:
215
+ ```
216
+ PATCH https://api.notion.com/v1/pages/{page_id}
217
+ {
218
+ "archived": true
219
+ }
220
+ ```
221
+
222
+ ## Pagination
223
+
224
+ When a response includes `"has_more": true`, pass `"start_cursor": response.next_cursor` in the next request to get the next page of results.
225
+
226
+ ## Error Handling
227
+
228
+ - **401 Unauthorized**: The access token is missing or expired. Ask the user to reconnect Notion via the **notion-oauth-setup** skill.
229
+ - **403 Forbidden**: The integration doesn't have access to the requested page or database. Remind the user that they need to share the page/database with the "Vellum Assistant" integration in Notion (via the Share menu → "Add connections").
230
+ - **404 Not Found**: The page or database ID doesn't exist or the integration can't see it. Verify the ID and check sharing settings.
231
+ - **400 Bad Request**: Check the request body structure. The Notion API error response includes a `message` field with details.
232
+ - **429 Too Many Requests**: Wait a few seconds and retry.
233
+
234
+ ## Tips
235
+
236
+ - Notion page IDs in URLs are formatted without hyphens. The API accepts both forms: `abc123def456...` or `abc123de-f456-...`.
237
+ - When extracting IDs from Notion URLs, strip any query parameters and trailing path components after the 32-character ID segment.
238
+ - Always include `Notion-Version: 2022-06-28` header to get stable API behavior.
239
+ - For rich text, concatenate all `plain_text` values in the array to get the full text content.
240
+ - When creating content with rich text formatting (bold, italic, links), use the `annotations` and `href` fields in rich_text objects.
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: "Notion OAuth Setup"
3
+ description: "Create a Notion integration and OAuth credentials for Notion integration using browser automation"
4
+ user-invocable: true
5
+ includes: ["browser", "public-ingress"]
6
+ metadata: {"vellum": {"emoji": "🔑"}}
7
+ ---
8
+
9
+ You are helping your user create a Notion integration (OAuth app) so Vellum can connect to their Notion workspace. Walk through each step below using `browser_navigate`, `browser_snapshot`, `browser_screenshot`, `browser_click`, `browser_type`, and `browser_extract` tools.
10
+
11
+ **Tone:** Be friendly and reassuring throughout. Narrate what you're doing in plain language so the user always knows what's happening. After each step, briefly confirm what was accomplished before moving on.
12
+
13
+ ## Prerequisites
14
+
15
+ Before starting, check that `ingress.publicBaseUrl` is configured (Settings > Public Ingress, or `INGRESS_PUBLIC_BASE_URL` env var). If it is not set, load and execute the **public-ingress** skill first (`skill_load` with `skill: "public-ingress"`) to set up an ngrok tunnel and persist the public URL. The OAuth redirect URI depends on this value.
16
+
17
+ ## Before You Start
18
+
19
+ Tell the user:
20
+ - "I'll walk you through creating a Notion integration so Vellum can read and write pages and databases in your workspace. The whole process takes a few minutes."
21
+ - "I'll be automating the Notion integrations page in the browser — you'll be able to see everything I'm doing."
22
+ - "I'll ask for your approval before each major step, so nothing happens without your say-so."
23
+ - "No sensitive credentials will be shown in the conversation."
24
+
25
+ ## Step 1: Navigate to Notion Integrations
26
+
27
+ Tell the user: "First, let me open the Notion integrations page."
28
+
29
+ Use `browser_navigate` to go to `https://www.notion.so/my-integrations`.
30
+
31
+ Take a `browser_screenshot` to show the user what loaded, then take a `browser_snapshot` to check the page state:
32
+ - **If a sign-in page appears:** Tell the user "Please sign in to your Notion account in the browser window. Let me know when you're done." Wait for their confirmation, then take another snapshot.
33
+ - **If the integrations dashboard loads:** Tell the user "Notion integrations page is loaded. Let's create your integration!" and continue to Step 2.
34
+
35
+ ## Step 2: Create a New Integration
36
+
37
+ **Ask for approval before proceeding.** Use `ui_show` with `surface_type: "confirmation"` and this message:
38
+
39
+ > **Create a Notion Integration**
40
+ >
41
+ > I'm about to create a new Notion integration called "Vellum Assistant". This integration will only have the capabilities you approve — it won't access any pages or databases until you explicitly share them with it or authorize it via OAuth.
42
+
43
+ Wait for the user to approve. If they decline, explain that the integration is required for OAuth and offer to try again or cancel.
44
+
45
+ Once approved:
46
+ 1. Click "New integration" (or the "+" button)
47
+ 2. Select "Public" as the integration type (required for OAuth)
48
+ 3. Enter integration name: "Vellum Assistant"
49
+ 4. Select the user's workspace
50
+ 5. Click "Submit" or "Create"
51
+
52
+ Take a `browser_screenshot` to show the result.
53
+
54
+ Tell the user: "Integration created! Now let's configure the OAuth settings."
55
+
56
+ ## Step 3: Configure OAuth Settings
57
+
58
+ Navigate to the integration's "Distribution" or "OAuth Domain & URIs" tab.
59
+
60
+ **Ask for approval before proceeding.** Use `ui_show` with `surface_type: "confirmation"` and this message:
61
+
62
+ > **Configure OAuth Redirect URI**
63
+ >
64
+ > I'm about to add the OAuth redirect URI to your Notion integration. This allows Notion to send the authorization code back to Vellum after you approve the connection.
65
+
66
+ Wait for the user to approve.
67
+
68
+ Once approved:
69
+ 1. Find the "Redirect URIs" field
70
+ 2. Enter `${ingress.publicBaseUrl}/webhooks/oauth/callback` (e.g. `https://abc123.ngrok-free.app/webhooks/oauth/callback`). Read the `ingress.publicBaseUrl` value from the assistant's workspace config (Settings > Public Ingress) or the `INGRESS_PUBLIC_BASE_URL` environment variable.
71
+ 3. Save the settings
72
+
73
+ Take a `browser_snapshot` to confirm.
74
+
75
+ Tell the user: "Redirect URI configured. Now let's get your OAuth credentials."
76
+
77
+ ## Step 4: Extract Client ID and Client Secret
78
+
79
+ Stay on the integration settings page and navigate to the "Secrets" or "OAuth Clients" section.
80
+
81
+ Use `browser_extract` to read:
82
+ 1. **OAuth client_id** — this is the integration's OAuth client ID
83
+ 2. **OAuth client_secret** — click "Show" or "Reveal" first, then extract the value
84
+
85
+ **Important:** Notion requires a client secret for the token exchange (sent via HTTP Basic Auth). Both values are needed.
86
+
87
+ Tell the user: "Credentials extracted! Now let's connect your Notion workspace."
88
+
89
+ ## Step 5: Connect Notion
90
+
91
+ Tell the user: "Opening Notion authorization so you can grant Vellum access to your workspace. You'll see a Notion consent page — just click 'Allow access'."
92
+
93
+ Use the `credential_store` tool to connect Notion via OAuth2:
94
+
95
+ ```
96
+ action: "oauth2_connect"
97
+ service: "integration:notion"
98
+ client_id: "<the extracted OAuth client_id>"
99
+ client_secret: "<the extracted OAuth client_secret>"
100
+ auth_url: "https://api.notion.com/v1/oauth/authorize"
101
+ token_url: "https://api.notion.com/v1/oauth/token"
102
+ scopes: []
103
+ extra_params: {"owner": "user"}
104
+ token_endpoint_auth_method: "client_secret_basic"
105
+ ```
106
+
107
+ This will open the Notion authorization page in the user's browser. Wait for the flow to complete.
108
+
109
+ ## Step 6: Celebrate!
110
+
111
+ Once connected, tell the user:
112
+
113
+ "**Notion is connected!** You're all set. You can now read and write pages and databases in your Notion workspace through Vellum. Try asking me to list your databases or read a specific page!"
114
+
115
+ Summarize what was accomplished:
116
+ - Created a Notion public integration called "Vellum Assistant"
117
+ - Configured the OAuth redirect URI
118
+ - Connected your Notion workspace with read and write access
119
+
120
+ ## Error Handling
121
+
122
+ - **Page load failures:** Retry navigation once. If it still fails, tell the user and ask them to check their internet connection.
123
+ - **"Public" integration type not available:** The user may need to enable public integrations in their workspace settings. Guide them to Workspace Settings > Integrations.
124
+ - **Element not found for click/type:** Take a fresh `browser_snapshot` to re-assess the page layout. Notion's UI may have changed; adapt your selectors.
125
+ - **User declines an approval gate:** Don't push back. Explain briefly why the step matters, offer to try again, or cancel gracefully.
126
+ - **OAuth flow timeout or failure:** Tell the user what happened and offer to retry. The integration is already created, so they only need to re-run the connect step.
127
+ - **Any unexpected state:** Take a `browser_screenshot` and `browser_snapshot`, describe what you see, and ask the user for guidance.