@notionhq/apps 0.0.24 → 0.0.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notionhq/apps",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "An SDK for building workflow apps for Notion",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -86,9 +86,9 @@ root exports support:
86
86
  `database(resourceId, { datasources: { Key: { resourceId, schema } }, views?, parent? })`,
87
87
  returning sources as `handle.datasources.Key`. A source's `addPage` declares a row;
88
88
  the database handle also exposes `addView`.
89
- - `customAgent({ resourceId, name, instructions?, access?, webAccess?, trustedUrls? })`.
90
- Access grants pair declared page or database resource IDs with a role. Inspect
91
- the installed types before specifying models, triggers, or URL trust.
89
+ - `customAgent({ resourceId, name, ... })`; only `resourceId` and `name` are
90
+ required. Choose optional fields individually as described below, and inspect
91
+ the installed types before using them.
92
92
  - `view({ databaseResourceId, resourceId, type, dataSourceResourceId, ... })`,
93
93
  returning a handle with `resourceId`. This is also available as `notion.view`.
94
94
  Use property resource IDs in view filters, sorts, and layout options; calendar
@@ -127,11 +127,72 @@ use `{ type: "resourceId", resourceId: parent.resourceId }`; child helpers set
127
127
  this reference for you. Pages and databases without a parent default to private
128
128
  top-level resources in the Apps workspace.
129
129
 
130
- Page and database covers accept `{ type: "url", url, position? }`. Custom-agent
131
- triggers are discriminated unions for recurrence, page-added, and
132
- property-updated triggers. Weekly recurrences require at least one weekday, and
133
- property-updated triggers require property conditions or
134
- `triggerWhenPageContentEdited: true`.
130
+ Page and database covers accept `{ type: "url", url, position? }`.
131
+
132
+ ## Configure a custom agent
133
+
134
+ Start with the smallest declaration that describes the requested agent:
135
+
136
+ ```ts
137
+ import { customAgent } from "@notionhq/apps";
138
+
139
+ const analyst = customAgent({
140
+ resourceId: "project-analyst",
141
+ name: "Project analyst",
142
+ instructions: "Summarize project status and identify blocked work.",
143
+ });
144
+ ```
145
+
146
+ Do not add every optional field by default. Decide on each field separately:
147
+
148
+ - `instructions`: set when the App should define the agent's purpose or
149
+ behavior. Omit rather than inventing placeholder instructions.
150
+ - `icon`: set only when the agent needs a specified visual identity. Custom
151
+ agents accept an emoji or Notion icon, but not a file-backed icon.
152
+ - `model`: set only when the user or product requirement calls for one of the
153
+ exact model values in the installed declarations. Otherwise omit it and let
154
+ Notion choose the model.
155
+ - `access`: set only for declared pages or databases the agent must use. Grant
156
+ the least-capable suitable role: `can_view` for reading, `can_comment` for
157
+ comments, `can_edit_content` for editing content, or `full_access` only when
158
+ broader access is required. Use the target handle's `resourceId`; this is
159
+ separate from a workflow's `access.call(agent)` binding.
160
+ - `webAccess`: set `true` only when the agent must search the web. Set `false`
161
+ when the declaration must explicitly disable web search. For a new agent,
162
+ omission defaults to `false`; for an existing agent, omission preserves its
163
+ current web access and domain restrictions.
164
+ - `trustedUrls`: set `{ type: "all" }` only when the agent must trust every HTTP
165
+ and HTTPS URL. URL trust is independent of web search, so do not add it merely
166
+ because `webAccess` is enabled. Omission disables URL trust for a new agent
167
+ and preserves the current policy for an existing agent. The current type has
168
+ no value that clears an existing trust policy.
169
+ - `triggers`: set only when the agent should run automatically. Use
170
+ `recurrence` for a schedule, `page_added` for new rows in a data source, and
171
+ `property_updated` for selected property edits and/or page-content edits.
172
+ Do not add a trigger merely because its data source also appears in `access`.
173
+
174
+ For an existing agent, `access` is additive: each entry adds a grant or updates
175
+ that resource's role, while unlisted grants remain unchanged. Omitting `access`
176
+ and passing `access: []` both preserve existing grants. Reuse declared resource
177
+ IDs and choose roles deliberately:
178
+
179
+ ```ts
180
+ customAgent({
181
+ resourceId: "project-analyst",
182
+ name: "Project analyst",
183
+ instructions: "Summarize project status and identify blocked work.",
184
+ access: [{ resourceId: projects.resourceId, role: "can_view" }],
185
+ webAccess: true,
186
+ });
187
+ ```
188
+
189
+ For a recurrence trigger, always set `interval`, `start`, and `timeZone`; add
190
+ `end` only for a finite schedule. Weekly triggers also require a nonempty
191
+ `weekdays` object, and monthly triggers require `monthlyRestriction`. Page-added
192
+ and property-updated triggers reference a declared data source by
193
+ `dataSourceResourceId`. Property-updated triggers require property conditions
194
+ or `triggerWhenPageContentEdited: true`. Give every trigger its own stable
195
+ `resourceId`.
135
196
 
136
197
  Database page layouts are typed against their keyed data-source schema. Reference
137
198
  property resource IDs, not schema keys. The SDK restricts relation groups to