mindoodb-app-sdk 0.0.53 → 0.0.55

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.
@@ -118,6 +118,13 @@ interface MindooDBAppDefinitionListing {
118
118
  summary?: MindooDBAppLocalizedText;
119
119
  /** Longer plain text. Blank lines separate paragraphs; no markup is rendered. */
120
120
  description?: MindooDBAppLocalizedText;
121
+ /**
122
+ * The same description with formatting: the Markdown subset of `listingMarkdown.ts`
123
+ * (paragraphs, headings, lists, bold/italic, code, `https:`/`mailto:` links).
124
+ * Readers that know this field show it instead of `description`; older ones ignore it
125
+ * and keep showing `description`, so set both when older Haven versions matter.
126
+ */
127
+ descriptionMarkdown?: MindooDBAppLocalizedText;
121
128
  /** Square icon, path relative to the app origin or an absolute `https:` URL. */
122
129
  icon?: string;
123
130
  screenshots?: MindooDBAppDefinitionScreenshot[];
@@ -1234,8 +1241,117 @@ interface MindooDBAppNotifyInput {
1234
1241
  interface MindooDBAppNotifyResult {
1235
1242
  id: string;
1236
1243
  }
1244
+ /**
1245
+ * Why an agent tool call failed, in terms an AI agent can act on. Haven passes
1246
+ * the code through to the agent unchanged.
1247
+ *
1248
+ * - `NOT_FOUND`: an id the agent passed does not exist (any more).
1249
+ * - `INVALID_INPUT`: the input does not match the schema or allowed values.
1250
+ * - `INVALID_STATE`: the call is valid but cannot run in the app's current state.
1251
+ * - `STATE_CHANGED`: what the agent planned on changed in between.
1252
+ * - `NOT_ALLOWED`: the user or a policy does not permit it.
1253
+ * - `FAILED`: anything else.
1254
+ *
1255
+ * `LOCKED` is Haven's own and never comes from an app.
1256
+ */
1257
+ type MindooDBAppAgentToolErrorCode = "NOT_FOUND" | "INVALID_INPUT" | "INVALID_STATE" | "STATE_CHANGED" | "NOT_ALLOWED" | "FAILED";
1258
+ /** Hints an agent uses to decide how carefully to treat a tool (WebMCP `ToolAnnotations`). */
1259
+ interface MindooDBAppAgentToolAnnotations {
1260
+ /** The tool only reads. */
1261
+ readOnlyHint?: boolean;
1262
+ /** The tool changes something the user would want to confirm; Haven asks first. */
1263
+ consequentialHint?: boolean;
1264
+ /** The result carries text other people wrote (names, notes, document content). */
1265
+ untrustedContentHint?: boolean;
1266
+ }
1267
+ /** What an app tells Haven about one agent tool; everything but the implementation. */
1268
+ interface MindooDBAppAgentToolDescriptor {
1269
+ /**
1270
+ * Name within the app: lower case, digits, underscore, starting with a letter.
1271
+ * Haven exposes it to agents prefixed with the app's key (`vega_maps_list`).
1272
+ */
1273
+ name: string;
1274
+ /** Written for an AI agent: what the tool does, when to use it, where ids come from. */
1275
+ description: string;
1276
+ /** JSON Schema of the input object. */
1277
+ inputSchema: Record<string, unknown>;
1278
+ annotations?: MindooDBAppAgentToolAnnotations;
1279
+ }
1280
+ /** One agent tool an app offers. `execute` runs inside the app; its result must be JSON. */
1281
+ interface MindooDBAppAgentTool extends MindooDBAppAgentToolDescriptor {
1282
+ execute(input: Record<string, unknown>): Promise<unknown>;
1283
+ }
1284
+ /** Haven's answer to {@link MindooDBAppAgentApi.registerTools}. */
1285
+ interface MindooDBAppAgentRegistration {
1286
+ /**
1287
+ * Whether agents can call the tools right now. `false` while the user has agent
1288
+ * access off, globally or for this app; Haven keeps the tools and offers them
1289
+ * as soon as access is switched on.
1290
+ */
1291
+ enabled: boolean;
1292
+ /** The names agents see, prefix included. */
1293
+ exposedNames: string[];
1294
+ }
1295
+ /**
1296
+ * Lets an app offer operations to AI agents through Haven.
1297
+ *
1298
+ * The app declares tools; Haven registers them with the browser's agent
1299
+ * interface (WebMCP) under the app's namespace, checks the user's permission,
1300
+ * asks for confirmation where a tool is consequential, and calls `execute`
1301
+ * through the bridge. The tools disappear when the app closes.
1302
+ */
1303
+ interface MindooDBAppAgentApi {
1304
+ /** Replaces the app's whole tool set. Pass `[]` to withdraw all tools. */
1305
+ registerTools(tools: MindooDBAppAgentTool[]): Promise<MindooDBAppAgentRegistration>;
1306
+ /**
1307
+ * The app's state as an agent should see it (open document, view, selection).
1308
+ * Shown to agents in `haven_get_context` under the focused app. `null` clears it.
1309
+ * Keep it small and semantic; it is not a UI dump.
1310
+ */
1311
+ setContext(context: Record<string, unknown> | null): Promise<void>;
1312
+ /**
1313
+ * Hands Haven a file the app produced (an export, a rendering, an attachment)
1314
+ * and returns a short-lived `fileRef` (ten minutes). Return the ref from a
1315
+ * tool; the agent passes it to `haven_files_export` to get the file into the
1316
+ * user's exchange folder. Files never travel through the agent as bytes.
1317
+ */
1318
+ provideFile(data: Blob | ArrayBuffer | Uint8Array, options: {
1319
+ name: string;
1320
+ mimeType?: string;
1321
+ }): Promise<{
1322
+ fileRef: string;
1323
+ size: number;
1324
+ }>;
1325
+ /**
1326
+ * Takes a file Haven imported for this app (`haven_files_import` with the
1327
+ * app's key). Fails for refs that expired or were imported for another app.
1328
+ */
1329
+ takeFile(fileRef: string): Promise<File>;
1330
+ }
1331
+ /** Host → app: an agent called one of the app's tools. */
1332
+ interface MindooDBAppBridgeAgentInvokeMessage {
1333
+ protocol: "mindoodb-app-bridge";
1334
+ kind: "agent-invoke";
1335
+ callId: string;
1336
+ /** The tool's name as the app registered it, without the prefix. */
1337
+ tool: string;
1338
+ input: Record<string, unknown>;
1339
+ }
1340
+ /** App → host: the outcome of an {@link MindooDBAppBridgeAgentInvokeMessage}. */
1341
+ interface MindooDBAppBridgeAgentResultMessage {
1342
+ protocol: "mindoodb-app-bridge";
1343
+ kind: "agent-result";
1344
+ callId: string;
1345
+ ok: boolean;
1346
+ result?: unknown;
1347
+ error?: {
1348
+ code: MindooDBAppAgentToolErrorCode;
1349
+ message: string;
1350
+ requiredAction?: string;
1351
+ };
1352
+ }
1237
1353
  /** Any message that can travel across the dedicated bridge MessagePort. */
1238
- type MindooDBAppBridgePortMessage = MindooDBAppBridgeRpcMessage | MindooDBAppBridgeStreamMessage | MindooDBAppBridgeThemeChangedMessage | MindooDBAppBridgeViewportChangedMessage | MindooDBAppBridgeUiPreferencesChangedMessage | MindooDBAppBridgeLocaleChangedMessage | MindooDBAppBridgeQueryResultMessage | MindooDBAppBridgeViewChangedMessage | MindooDBAppBridgeBeforeCloseMessage | MindooDBAppBridgeBeforeCloseAck | MindooDBAppBridgeShortcutsChangedMessage | MindooDBAppBridgeShortcutInvokedMessage | MindooDBAppBridgeWorkspaceFocusRequestedMessage | MindooDBAppBridgeHostFocusChangedMessage | MindooDBAppBridgeDragOverMessage | MindooDBAppBridgeDragLeaveMessage | MindooDBAppBridgeDragDropMessage;
1354
+ type MindooDBAppBridgePortMessage = MindooDBAppBridgeRpcMessage | MindooDBAppBridgeStreamMessage | MindooDBAppBridgeThemeChangedMessage | MindooDBAppBridgeViewportChangedMessage | MindooDBAppBridgeUiPreferencesChangedMessage | MindooDBAppBridgeLocaleChangedMessage | MindooDBAppBridgeQueryResultMessage | MindooDBAppBridgeViewChangedMessage | MindooDBAppBridgeBeforeCloseMessage | MindooDBAppBridgeBeforeCloseAck | MindooDBAppBridgeShortcutsChangedMessage | MindooDBAppBridgeShortcutInvokedMessage | MindooDBAppBridgeWorkspaceFocusRequestedMessage | MindooDBAppBridgeHostFocusChangedMessage | MindooDBAppBridgeAgentInvokeMessage | MindooDBAppBridgeAgentResultMessage | MindooDBAppBridgeDragOverMessage | MindooDBAppBridgeDragLeaveMessage | MindooDBAppBridgeDragDropMessage;
1239
1355
  /** Placement hint for a host-rendered overlay menu. */
1240
1356
  type MindooDBAppMenuPlacement = "auto" | "bottom-start" | "bottom-end" | "top-start" | "top-end" | "right-start" | "left-start";
1241
1357
  /** Semantic hint allowing Haven to tune menu behavior or styling. */
@@ -2101,8 +2217,29 @@ interface MindooDBAppDirectoryApi {
2101
2217
  /**
2102
2218
  * Active directory usernames in this tenant, for recipient pickers.
2103
2219
  * Requires the `directory` capability.
2220
+ *
2221
+ * Without options: every username. With options: one page, filtered by a
2222
+ * case-insensitive `query` and continued with `nextCursor` — use this for large
2223
+ * directories. Hosts without paging support return the full list; the SDK then
2224
+ * filters and pages it on the client, so the paged form works everywhere.
2104
2225
  */
2105
2226
  listUsers(): Promise<string[]>;
2227
+ listUsers(options: MindooDBAppListUsersOptions): Promise<MindooDBAppListUsersPage>;
2228
+ }
2229
+ /** Paging and search for {@link MindooDBAppDirectoryApi.listUsers}. */
2230
+ interface MindooDBAppListUsersOptions {
2231
+ /** Case-insensitive substring of the username. */
2232
+ query?: string;
2233
+ /** `nextCursor` of the previous page; omit for the first page. */
2234
+ cursor?: string | null;
2235
+ /** Page size, default 50, at most 500. */
2236
+ limit?: number;
2237
+ }
2238
+ /** One page of {@link MindooDBAppDirectoryApi.listUsers}. */
2239
+ interface MindooDBAppListUsersPage {
2240
+ users: string[];
2241
+ /** Cursor for the next page, `null` on the last page. */
2242
+ nextCursor: string | null;
2106
2243
  }
2107
2244
  /**
2108
2245
  * The only signing domain apps may request today. Domain separation is not
@@ -2877,6 +3014,11 @@ interface MindooDBAppSession {
2877
3014
  * replace one from another launch.
2878
3015
  */
2879
3016
  notify(input: MindooDBAppNotifyInput): Promise<MindooDBAppNotifyResult>;
3017
+ /**
3018
+ * Offer operations to AI agents through Haven. Absent on hosts that predate
3019
+ * agent tools, so check before use.
3020
+ */
3021
+ agent?: MindooDBAppAgentApi;
2880
3022
  /**
2881
3023
  * Tear down the session: close the bridge port and release all host-side
2882
3024
  * resources of this launch (navigators, live queries, streams). The
@@ -2895,4 +3037,4 @@ interface MindooDBAppBridge {
2895
3037
  connect(options?: MindooDBAppBridgeConnectOptions): Promise<MindooDBAppSession>;
2896
3038
  }
2897
3039
 
2898
- export { type MindooDBAppBridgeRpcRequest as $, type MindooDBAppAttachmentApi as A, type MindooDBAppAttachmentChunk as B, type MindooDBAppAttachmentInfo as C, type MindooDBAppAttachmentPreviewOptions as D, type MindooDBAppAttachmentPreviewSession as E, type MindooDBAppAutomergeChangesPatch as F, type MindooDBAppAutomergeChangesSince as G, type MindooDBAppAutomergeGetOptions as H, type MindooDBAppAutomergePatchResult as I, type MindooDBAppAutomergeSnapshot as J, type MindooDBAppBridgeBeforeCloseAck as K, type MindooDBAppBridgeBeforeCloseMessage as L, type MindooDBAppAttachmentPreviewMode as M, type MindooDBAppBridgeConnectMessage as N, type MindooDBAppBridgeConnectOptions as O, type MindooDBAppBridgeConnectedMessage as P, type MindooDBAppBridgeDragDropMessage as Q, type MindooDBAppBridgeDragLeaveMessage as R, type MindooDBAppBridgeDragOverMessage as S, type MindooDBAppBridgeErrorPayload as T, type MindooDBAppBridgeHandshakeErrorMessage as U, type MindooDBAppBridgeHostFocusChangedMessage as V, type MindooDBAppBridgeLocaleChangedMessage as W, type MindooDBAppBridgePortMessage as X, type MindooDBAppBridgeQueryResultMessage as Y, type MindooDBAppBridgeRpcError as Z, type MindooDBAppBridgeRpcMessage as _, type MindooDBAppDragBindSourceOptions as a, type MindooDBAppEntryProvenance as a$, type MindooDBAppBridgeRpcSuccess as a0, type MindooDBAppBridgeShortcutInvokedMessage as a1, type MindooDBAppBridgeShortcutsChangedMessage as a2, type MindooDBAppBridgeStreamAbortRequest as a3, type MindooDBAppBridgeStreamAck as a4, type MindooDBAppBridgeStreamCloseRequest as a5, type MindooDBAppBridgeStreamError as a6, type MindooDBAppBridgeStreamMessage as a7, type MindooDBAppBridgeStreamOpenResult as a8, type MindooDBAppBridgeStreamReadRequest as a9, type MindooDBAppDefinitionDatabase as aA, type MindooDBAppDefinitionListing as aB, type MindooDBAppDefinitionPermission as aC, type MindooDBAppDefinitionRegistrationPermission as aD, type MindooDBAppDefinitionScreenshot as aE, type MindooDBAppDefinitionValidation as aF, type MindooDBAppDirectoryApi as aG, type MindooDBAppDirectoryEntry as aH, type MindooDBAppDocumentApi as aI, type MindooDBAppDocumentHeadCursorResult as aJ, type MindooDBAppDocumentHistoryEntry as aK, type MindooDBAppDocumentListQuery as aL, type MindooDBAppDocumentListResult as aM, type MindooDBAppDocumentQuery as aN, type MindooDBAppDocumentRevisionId as aO, type MindooDBAppDocumentScanPreset as aP, type MindooDBAppDocumentSummary as aQ, type MindooDBAppDragApi as aR, type MindooDBAppDragCancelReason as aS, type MindooDBAppDragDropEvent as aT, type MindooDBAppDragEffect as aU, type MindooDBAppDragHoverResult as aV, type MindooDBAppDragOffer as aW, type MindooDBAppDragOverEvent as aX, type MindooDBAppDragPointer as aY, type MindooDBAppDragProfile as aZ, type MindooDBAppEntryAttachmentRef as a_, type MindooDBAppBridgeStreamWriteRequest as aa, type MindooDBAppBridgeThemeChangedMessage as ab, type MindooDBAppBridgeUiPreferencesChangedMessage as ac, type MindooDBAppBridgeViewChangedMessage as ad, type MindooDBAppBridgeViewportChangedMessage as ae, type MindooDBAppBridgeWorkspaceFocusRequestedMessage as af, type MindooDBAppCapability as ag, type MindooDBAppConfiguredViewCategorizationStyle as ah, type MindooDBAppConfiguredViewColumn as ai, type MindooDBAppConfiguredViewColumnRole as aj, type MindooDBAppConfiguredViewExpressionMode as ak, type MindooDBAppConfiguredViewFieldExpression as al, type MindooDBAppConfiguredViewFilterDefinition as am, type MindooDBAppConfiguredViewFilterMode as an, type MindooDBAppConfiguredViewFilterRule as ao, type MindooDBAppConfiguredViewFormulaExpression as ap, type MindooDBAppConfiguredViewFormulaFilterDefinition as aq, type MindooDBAppConfiguredViewPreviewMode as ar, type MindooDBAppConfiguredViewRuleFilterDefinition as as, type MindooDBAppConfiguredViewRuleMatchMode as at, type MindooDBAppConfiguredViewRuleOperator as au, type MindooDBAppConfiguredViewValueExpression as av, type MindooDBAppCreateKeyInfo as aw, type MindooDBAppCreateViewInput as ax, type MindooDBAppCreateViewNavigatorInput as ay, type MindooDBAppDatabaseInfo as az, type MindooDBAppDragStartInput as b, type MindooDBAppRichTextSpliceStep as b$, type MindooDBAppExtractDocumentTextInput as b0, type MindooDBAppExtractDocumentTextResult as b1, type MindooDBAppExtractTextFormat as b2, type MindooDBAppExtractionSetup as b3, type MindooDBAppFulltextSetup as b4, type MindooDBAppHistoricalDocument as b5, type MindooDBAppHistoryQuery as b6, type MindooDBAppHostTheme as b7, type MindooDBAppIdentityApi as b8, type MindooDBAppInaccessibleDocument as b9, type MindooDBAppMenuSeparatorItem as bA, type MindooDBAppNotificationSeverity as bB, type MindooDBAppNotifyInput as bC, type MindooDBAppNotifyResult as bD, type MindooDBAppProposeAppInput as bE, type MindooDBAppProposeAppResult as bF, type MindooDBAppQueryCoverage as bG, type MindooDBAppQueryInclude as bH, type MindooDBAppQueryIncludeCardinality as bI, type MindooDBAppQueryIncludeSlots as bJ, type MindooDBAppQueryResult as bK, type MindooDBAppQueryRow as bL, type MindooDBAppQuerySortKey as bM, type MindooDBAppQueryTextClause as bN, type MindooDBAppReadableAttachmentStream as bO, type MindooDBAppRecipientOptions as bP, type MindooDBAppResolvedViewDefinition as bQ, type MindooDBAppResolvedViewSource as bR, type MindooDBAppRevisionPhase as bS, type MindooDBAppRevisionVerification as bT, type MindooDBAppRichTextBlockSpan as bU, type MindooDBAppRichTextGetOptions as bV, type MindooDBAppRichTextImmutableString as bW, type MindooDBAppRichTextMarkRange as bX, type MindooDBAppRichTextMaterializeValue as bY, type MindooDBAppRichTextPatch as bZ, type MindooDBAppRichTextScalar as b_, type MindooDBAppInaccessibleDocumentListQuery as ba, type MindooDBAppInaccessibleDocumentListResult as bb, type MindooDBAppJsonCounterIncrementPatch as bc, type MindooDBAppJsonListDeletePatch as bd, type MindooDBAppJsonListInsertPatch as be, type MindooDBAppJsonPatch as bf, type MindooDBAppJsonSetPatch as bg, type MindooDBAppJsonTextMarkPatch as bh, type MindooDBAppJsonTextSplicePatch as bi, type MindooDBAppJsonTextUnmarkPatch as bj, type MindooDBAppJsonUnsetPatch as bk, type MindooDBAppLaunchContext as bl, type MindooDBAppLiveQuerySubscription as bm, type MindooDBAppLocalizedText as bn, type MindooDBAppMenuAnchor as bo, type MindooDBAppMenuApi as bp, type MindooDBAppMenuCommandItem as bq, type MindooDBAppMenuDismissReason as br, type MindooDBAppMenuDismissedResult as bs, type MindooDBAppMenuItem as bt, type MindooDBAppMenuKind as bu, type MindooDBAppMenuPlacement as bv, type MindooDBAppMenuPointAnchor as bw, type MindooDBAppMenuRect as bx, type MindooDBAppMenuRectAnchor as by, type MindooDBAppMenuSelectionResult as bz, type MindooDBAppDragStartResult as c, type MindooDBAppRichTextStep as c0, type MindooDBAppRichTextStepPatch as c1, type MindooDBAppRichTextTextSpan as c2, type MindooDBAppRuntime as c3, type MindooDBAppScanAttachmentOptions as c4, type MindooDBAppScanAttachmentResult as c5, type MindooDBAppScopedDocId as c6, type MindooDBAppScopedDocumentSummary as c7, type MindooDBAppSealIntent as c8, type MindooDBAppSealedChannelOpenInput as c9, type MindooDBAppViewEntry as cA, type MindooDBAppViewEntryKind as cB, type MindooDBAppViewNavigator as cC, type MindooDBAppViewNavigatorExpansionState as cD, type MindooDBAppViewNavigatorOpenOptions as cE, type MindooDBAppViewNavigatorPageOptions as cF, type MindooDBAppViewNavigatorPageResult as cG, type MindooDBAppViewNavigatorRangeQuery as cH, type MindooDBAppViewNavigatorSelectionState as cI, type MindooDBAppViewUpdateStats as cJ, type MindooDBAppViewport as cK, type MindooDBAppWellKnownDragType as cL, type MindooDBAppWritableAttachmentStream as cM, resolveMindooDBAppDefinitionUrl as cN, resolveMindooDBAppListingAssetUrl as cO, resolveMindooDBAppLocalizedText as cP, validateMindooDBAppDefinition as cQ, type MindooDBAppSealedChannelOpenResult as ca, type MindooDBAppSealedChannelRequestInput as cb, type MindooDBAppSession as cc, type MindooDBAppShowMenuInput as cd, type MindooDBAppShowMenuResult as ce, type MindooDBAppSignPreview as cf, type MindooDBAppSignPreviewScope as cg, type MindooDBAppSignStatementInput as ch, type MindooDBAppSignStatementResult as ci, type MindooDBAppStorageApi as cj, type MindooDBAppSummarySetup as ck, type MindooDBAppTextCursorOptions as cl, type MindooDBAppTextCursorPosition as cm, type MindooDBAppTextCursorPositionsResult as cn, type MindooDBAppTextCursorsResult as co, type MindooDBAppTextEdit as cp, type MindooDBAppTextPatch as cq, type MindooDBAppThemeMode as cr, type MindooDBAppTimestampApi as cs, type MindooDBAppTimestampInput as ct, type MindooDBAppTimestampProvider as cu, type MindooDBAppTimestampResult as cv, type MindooDBAppUiPreferences as cw, type MindooDBAppUpdateDocumentInput as cx, type MindooDBAppViewCursorDocumentListResult as cy, type MindooDBAppViewCursorResult as cz, type MindooDBAppDragPreview as d, type MindooDBAppBridge as e, type MindooDBAppHostShortcutBinding as f, type MindooDBAppHostShortcutAction as g, type MindooDBAppHostingMode as h, type MindooDBAppDefinition as i, type MindooDBAppDatabase as j, type MindooDBAppDocument as k, type MindooDBAppRichTextSpan as l, type MindooDBAppRichTextSnapshot as m, type MindooDBAppCreateDocumentInput as n, MINDOODB_APP_DEFINITION_FILE_NAME as o, MINDOODB_APP_DEFINITION_FORMAT as p, MINDOODB_APP_DEFINITION_PERMISSIONS as q, MINDOODB_APP_DEFINITION_REGISTRATION_PERMISSIONS as r, MINDOODB_APP_DEFINITION_VERSION as s, MINDOODB_APP_LISTING_DESCRIPTION_MAX as t, MINDOODB_APP_LISTING_MAX_SCREENSHOTS as u, MINDOODB_APP_LISTING_SUMMARY_MAX as v, MINDOODB_APP_SEAL_SIGNING_DOMAIN as w, MINDOODB_APP_WELL_KNOWN_DRAG_TYPES as x, type MindooDBAppAccessDecision as y, type MindooDBAppAccessTier as z };
3040
+ export { type MindooDBAppBridgeErrorPayload as $, type MindooDBAppAccessTier as A, type MindooDBAppAgentApi as B, type MindooDBAppAgentRegistration as C, type MindooDBAppAgentTool as D, type MindooDBAppAgentToolAnnotations as E, type MindooDBAppAgentToolDescriptor as F, type MindooDBAppAttachmentApi as G, type MindooDBAppAttachmentChunk as H, type MindooDBAppAttachmentInfo as I, type MindooDBAppAttachmentPreviewOptions as J, type MindooDBAppAttachmentPreviewSession as K, type MindooDBAppAutomergeChangesPatch as L, type MindooDBAppAttachmentPreviewMode as M, type MindooDBAppAutomergeChangesSince as N, type MindooDBAppAutomergeGetOptions as O, type MindooDBAppAutomergePatchResult as P, type MindooDBAppAutomergeSnapshot as Q, type MindooDBAppBridgeAgentInvokeMessage as R, type MindooDBAppBridgeAgentResultMessage as S, type MindooDBAppBridgeBeforeCloseAck as T, type MindooDBAppBridgeBeforeCloseMessage as U, type MindooDBAppBridgeConnectMessage as V, type MindooDBAppBridgeConnectOptions as W, type MindooDBAppBridgeConnectedMessage as X, type MindooDBAppBridgeDragDropMessage as Y, type MindooDBAppBridgeDragLeaveMessage as Z, type MindooDBAppBridgeDragOverMessage as _, type MindooDBAppDragBindSourceOptions as a, type MindooDBAppDragDropEvent as a$, type MindooDBAppBridgeHandshakeErrorMessage as a0, type MindooDBAppBridgeHostFocusChangedMessage as a1, type MindooDBAppBridgeLocaleChangedMessage as a2, type MindooDBAppBridgePortMessage as a3, type MindooDBAppBridgeQueryResultMessage as a4, type MindooDBAppBridgeRpcError as a5, type MindooDBAppBridgeRpcMessage as a6, type MindooDBAppBridgeRpcRequest as a7, type MindooDBAppBridgeRpcSuccess as a8, type MindooDBAppBridgeShortcutInvokedMessage as a9, type MindooDBAppConfiguredViewRuleFilterDefinition as aA, type MindooDBAppConfiguredViewRuleMatchMode as aB, type MindooDBAppConfiguredViewRuleOperator as aC, type MindooDBAppConfiguredViewValueExpression as aD, type MindooDBAppCreateKeyInfo as aE, type MindooDBAppCreateViewInput as aF, type MindooDBAppCreateViewNavigatorInput as aG, type MindooDBAppDatabaseInfo as aH, type MindooDBAppDefinitionDatabase as aI, type MindooDBAppDefinitionListing as aJ, type MindooDBAppDefinitionPermission as aK, type MindooDBAppDefinitionRegistrationPermission as aL, type MindooDBAppDefinitionScreenshot as aM, type MindooDBAppDefinitionValidation as aN, type MindooDBAppDirectoryApi as aO, type MindooDBAppDirectoryEntry as aP, type MindooDBAppDocumentApi as aQ, type MindooDBAppDocumentHeadCursorResult as aR, type MindooDBAppDocumentHistoryEntry as aS, type MindooDBAppDocumentListQuery as aT, type MindooDBAppDocumentListResult as aU, type MindooDBAppDocumentQuery as aV, type MindooDBAppDocumentRevisionId as aW, type MindooDBAppDocumentScanPreset as aX, type MindooDBAppDocumentSummary as aY, type MindooDBAppDragApi as aZ, type MindooDBAppDragCancelReason as a_, type MindooDBAppBridgeShortcutsChangedMessage as aa, type MindooDBAppBridgeStreamAbortRequest as ab, type MindooDBAppBridgeStreamAck as ac, type MindooDBAppBridgeStreamCloseRequest as ad, type MindooDBAppBridgeStreamError as ae, type MindooDBAppBridgeStreamMessage as af, type MindooDBAppBridgeStreamOpenResult as ag, type MindooDBAppBridgeStreamReadRequest as ah, type MindooDBAppBridgeStreamWriteRequest as ai, type MindooDBAppBridgeThemeChangedMessage as aj, type MindooDBAppBridgeUiPreferencesChangedMessage as ak, type MindooDBAppBridgeViewChangedMessage as al, type MindooDBAppBridgeViewportChangedMessage as am, type MindooDBAppBridgeWorkspaceFocusRequestedMessage as an, type MindooDBAppCapability as ao, type MindooDBAppConfiguredViewCategorizationStyle as ap, type MindooDBAppConfiguredViewColumn as aq, type MindooDBAppConfiguredViewColumnRole as ar, type MindooDBAppConfiguredViewExpressionMode as as, type MindooDBAppConfiguredViewFieldExpression as at, type MindooDBAppConfiguredViewFilterDefinition as au, type MindooDBAppConfiguredViewFilterMode as av, type MindooDBAppConfiguredViewFilterRule as aw, type MindooDBAppConfiguredViewFormulaExpression as ax, type MindooDBAppConfiguredViewFormulaFilterDefinition as ay, type MindooDBAppConfiguredViewPreviewMode as az, type MindooDBAppDragStartInput as b, type MindooDBAppResolvedViewSource as b$, type MindooDBAppDragEffect as b0, type MindooDBAppDragHoverResult as b1, type MindooDBAppDragOffer as b2, type MindooDBAppDragOverEvent as b3, type MindooDBAppDragPointer as b4, type MindooDBAppDragProfile as b5, type MindooDBAppEntryAttachmentRef as b6, type MindooDBAppEntryProvenance as b7, type MindooDBAppExtractDocumentTextInput as b8, type MindooDBAppExtractDocumentTextResult as b9, type MindooDBAppMenuCommandItem as bA, type MindooDBAppMenuDismissReason as bB, type MindooDBAppMenuDismissedResult as bC, type MindooDBAppMenuItem as bD, type MindooDBAppMenuKind as bE, type MindooDBAppMenuPlacement as bF, type MindooDBAppMenuPointAnchor as bG, type MindooDBAppMenuRect as bH, type MindooDBAppMenuRectAnchor as bI, type MindooDBAppMenuSelectionResult as bJ, type MindooDBAppMenuSeparatorItem as bK, type MindooDBAppNotificationSeverity as bL, type MindooDBAppNotifyInput as bM, type MindooDBAppNotifyResult as bN, type MindooDBAppProposeAppInput as bO, type MindooDBAppProposeAppResult as bP, type MindooDBAppQueryCoverage as bQ, type MindooDBAppQueryInclude as bR, type MindooDBAppQueryIncludeCardinality as bS, type MindooDBAppQueryIncludeSlots as bT, type MindooDBAppQueryResult as bU, type MindooDBAppQueryRow as bV, type MindooDBAppQuerySortKey as bW, type MindooDBAppQueryTextClause as bX, type MindooDBAppReadableAttachmentStream as bY, type MindooDBAppRecipientOptions as bZ, type MindooDBAppResolvedViewDefinition as b_, type MindooDBAppExtractTextFormat as ba, type MindooDBAppExtractionSetup as bb, type MindooDBAppFulltextSetup as bc, type MindooDBAppHistoricalDocument as bd, type MindooDBAppHistoryQuery as be, type MindooDBAppHostTheme as bf, type MindooDBAppIdentityApi as bg, type MindooDBAppInaccessibleDocument as bh, type MindooDBAppInaccessibleDocumentListQuery as bi, type MindooDBAppInaccessibleDocumentListResult as bj, type MindooDBAppJsonCounterIncrementPatch as bk, type MindooDBAppJsonListDeletePatch as bl, type MindooDBAppJsonListInsertPatch as bm, type MindooDBAppJsonPatch as bn, type MindooDBAppJsonSetPatch as bo, type MindooDBAppJsonTextMarkPatch as bp, type MindooDBAppJsonTextSplicePatch as bq, type MindooDBAppJsonTextUnmarkPatch as br, type MindooDBAppJsonUnsetPatch as bs, type MindooDBAppLaunchContext as bt, type MindooDBAppListUsersOptions as bu, type MindooDBAppListUsersPage as bv, type MindooDBAppLiveQuerySubscription as bw, type MindooDBAppLocalizedText as bx, type MindooDBAppMenuAnchor as by, type MindooDBAppMenuApi as bz, type MindooDBAppDragStartResult as c, type MindooDBAppRevisionPhase as c0, type MindooDBAppRevisionVerification as c1, type MindooDBAppRichTextBlockSpan as c2, type MindooDBAppRichTextGetOptions as c3, type MindooDBAppRichTextImmutableString as c4, type MindooDBAppRichTextMarkRange as c5, type MindooDBAppRichTextMaterializeValue as c6, type MindooDBAppRichTextPatch as c7, type MindooDBAppRichTextScalar as c8, type MindooDBAppRichTextSpliceStep as c9, type MindooDBAppTextPatch as cA, type MindooDBAppThemeMode as cB, type MindooDBAppTimestampApi as cC, type MindooDBAppTimestampInput as cD, type MindooDBAppTimestampProvider as cE, type MindooDBAppTimestampResult as cF, type MindooDBAppUiPreferences as cG, type MindooDBAppUpdateDocumentInput as cH, type MindooDBAppViewCursorDocumentListResult as cI, type MindooDBAppViewCursorResult as cJ, type MindooDBAppViewEntry as cK, type MindooDBAppViewEntryKind as cL, type MindooDBAppViewNavigator as cM, type MindooDBAppViewNavigatorExpansionState as cN, type MindooDBAppViewNavigatorOpenOptions as cO, type MindooDBAppViewNavigatorPageOptions as cP, type MindooDBAppViewNavigatorPageResult as cQ, type MindooDBAppViewNavigatorRangeQuery as cR, type MindooDBAppViewNavigatorSelectionState as cS, type MindooDBAppViewUpdateStats as cT, type MindooDBAppViewport as cU, type MindooDBAppWellKnownDragType as cV, type MindooDBAppWritableAttachmentStream as cW, resolveMindooDBAppDefinitionUrl as cX, resolveMindooDBAppListingAssetUrl as cY, resolveMindooDBAppLocalizedText as cZ, validateMindooDBAppDefinition as c_, type MindooDBAppRichTextStep as ca, type MindooDBAppRichTextStepPatch as cb, type MindooDBAppRichTextTextSpan as cc, type MindooDBAppRuntime as cd, type MindooDBAppScanAttachmentOptions as ce, type MindooDBAppScanAttachmentResult as cf, type MindooDBAppScopedDocId as cg, type MindooDBAppScopedDocumentSummary as ch, type MindooDBAppSealIntent as ci, type MindooDBAppSealedChannelOpenInput as cj, type MindooDBAppSealedChannelOpenResult as ck, type MindooDBAppSealedChannelRequestInput as cl, type MindooDBAppSession as cm, type MindooDBAppShowMenuInput as cn, type MindooDBAppShowMenuResult as co, type MindooDBAppSignPreview as cp, type MindooDBAppSignPreviewScope as cq, type MindooDBAppSignStatementInput as cr, type MindooDBAppSignStatementResult as cs, type MindooDBAppStorageApi as ct, type MindooDBAppSummarySetup as cu, type MindooDBAppTextCursorOptions as cv, type MindooDBAppTextCursorPosition as cw, type MindooDBAppTextCursorPositionsResult as cx, type MindooDBAppTextCursorsResult as cy, type MindooDBAppTextEdit as cz, type MindooDBAppDragPreview as d, type MindooDBAppBridge as e, type MindooDBAppAgentToolErrorCode as f, type MindooDBAppHostShortcutBinding as g, type MindooDBAppHostShortcutAction as h, type MindooDBAppHostingMode as i, type MindooDBAppDefinition as j, type MindooDBAppDatabase as k, type MindooDBAppDocument as l, type MindooDBAppRichTextSpan as m, type MindooDBAppRichTextSnapshot as n, type MindooDBAppCreateDocumentInput as o, MINDOODB_APP_DEFINITION_FILE_NAME as p, MINDOODB_APP_DEFINITION_FORMAT as q, MINDOODB_APP_DEFINITION_PERMISSIONS as r, MINDOODB_APP_DEFINITION_REGISTRATION_PERMISSIONS as s, MINDOODB_APP_DEFINITION_VERSION as t, MINDOODB_APP_LISTING_DESCRIPTION_MAX as u, MINDOODB_APP_LISTING_MAX_SCREENSHOTS as v, MINDOODB_APP_LISTING_SUMMARY_MAX as w, MINDOODB_APP_SEAL_SIGNING_DOMAIN as x, MINDOODB_APP_WELL_KNOWN_DRAG_TYPES as y, type MindooDBAppAccessDecision as z };
@@ -26,22 +26,35 @@ interface HavenBundleOptions {
26
26
  }
27
27
  interface ResolvedViteConfig {
28
28
  root: string;
29
+ command?: "build" | "serve";
29
30
  build: {
30
31
  outDir: string;
31
32
  };
33
+ server?: {
34
+ host?: string | boolean;
35
+ port?: number;
36
+ };
37
+ }
38
+ interface ShareHtmlContext {
39
+ filename?: string;
40
+ server?: {
41
+ resolvedUrls?: {
42
+ local?: string[];
43
+ } | null;
44
+ };
32
45
  }
33
46
  /** Structural subset of Vite's `Plugin`, so the SDK does not need to depend on Vite. */
34
47
  interface HavenBundleVitePlugin {
35
48
  name: string;
36
- apply: "build";
49
+ /**
50
+ * Runs in dev and in build. The zip is still build-only; dev needs the same plugin so
51
+ * `index.html` carries the share tags while `vite dev` is serving it.
52
+ */
37
53
  configResolved: (config: ResolvedViteConfig) => void;
54
+ transformIndexHtml: (html: string, ctx: ShareHtmlContext) => Promise<string>;
38
55
  writeBundle: () => Promise<void>;
39
56
  closeBundle: () => Promise<void>;
40
57
  }
41
- /**
42
- * Emits `haven-bundle.json` and `haven-bundle.zip` next to the build output so a MindooDB
43
- * host can install and update the app from a URL.
44
- */
45
58
  declare function havenBundle(options?: HavenBundleOptions): HavenBundleVitePlugin;
46
59
 
47
60
  export { type HavenBundleOptions, type HavenBundleVitePlugin, havenBundle };
@@ -11,6 +11,127 @@ import { createHash } from "crypto";
11
11
  import { access, readdir, readFile, writeFile } from "fs/promises";
12
12
  import path from "path";
13
13
 
14
+ // src/shareMeta.ts
15
+ var SUMMARY_CARD = "summary";
16
+ function escapeText(value) {
17
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
18
+ }
19
+ function escapeAttr(value) {
20
+ return escapeText(value).replace(/"/g, "&quot;").replace(/[\t\n\r]/g, " ");
21
+ }
22
+ function meta(attr, key, content) {
23
+ return `<meta ${attr}="${key}" content="${escapeAttr(content)}">`;
24
+ }
25
+ function localized(value) {
26
+ if (typeof value === "string") {
27
+ return value.trim();
28
+ }
29
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
30
+ return "";
31
+ }
32
+ const record = value;
33
+ if (typeof record.en === "string" && record.en.trim()) {
34
+ return record.en.trim();
35
+ }
36
+ for (const text of Object.values(record)) {
37
+ if (typeof text === "string" && text.trim()) {
38
+ return text.trim();
39
+ }
40
+ }
41
+ return "";
42
+ }
43
+ function isRecord(value) {
44
+ return typeof value === "object" && value !== null && !Array.isArray(value);
45
+ }
46
+ function havenAppPublicUrl(raw) {
47
+ if (!isRecord(raw)) {
48
+ return void 0;
49
+ }
50
+ return havenAppSharePageUrl(raw.publicUrl);
51
+ }
52
+ function havenAppSharePageUrl(value) {
53
+ if (typeof value !== "string" || !value.trim()) {
54
+ return void 0;
55
+ }
56
+ try {
57
+ const url = new URL(value.trim());
58
+ if (url.protocol !== "https:" && url.protocol !== "http:") {
59
+ return void 0;
60
+ }
61
+ return url.origin + "/";
62
+ } catch {
63
+ return void 0;
64
+ }
65
+ }
66
+ function absoluteRasterUrl(asset, pageUrl) {
67
+ if (/\.svg($|\?)/i.test(asset)) {
68
+ return void 0;
69
+ }
70
+ try {
71
+ const url = new URL(asset, pageUrl);
72
+ if (url.protocol !== "https:" && url.protocol !== "http:") {
73
+ return void 0;
74
+ }
75
+ return url.href;
76
+ } catch {
77
+ return void 0;
78
+ }
79
+ }
80
+ function havenAppShareMeta(raw, pageUrl) {
81
+ const page = havenAppSharePageUrl(pageUrl);
82
+ if (!isRecord(raw) || !page) {
83
+ return void 0;
84
+ }
85
+ const title = typeof raw.label === "string" ? raw.label.trim() : "";
86
+ if (!title) {
87
+ return void 0;
88
+ }
89
+ const listing = isRecord(raw.listing) ? raw.listing : void 0;
90
+ const summary = localized(listing?.summary);
91
+ const descriptionText = localized(listing?.description);
92
+ const description = summary || descriptionText.split(/\n\s*\n/)[0]?.trim() || (typeof raw.description === "string" ? raw.description.trim() : "");
93
+ const icon = typeof listing?.icon === "string" ? listing.icon.trim() : "";
94
+ const imageUrl = icon ? absoluteRasterUrl(icon, page) : void 0;
95
+ return { title, description, pageUrl: page, ...imageUrl ? { imageUrl } : {} };
96
+ }
97
+ function renderHavenAppShareMeta(metaData) {
98
+ const lines = [
99
+ "<!-- mindoodb-share -->",
100
+ meta("name", "description", metaData.description),
101
+ meta("property", "og:type", "website"),
102
+ meta("property", "og:title", metaData.title),
103
+ meta("property", "og:description", metaData.description),
104
+ meta("property", "og:url", metaData.pageUrl)
105
+ ];
106
+ if (metaData.imageUrl) {
107
+ lines.push(meta("property", "og:image", metaData.imageUrl), meta("property", "og:image:alt", metaData.title));
108
+ }
109
+ lines.push(
110
+ meta("name", "twitter:card", SUMMARY_CARD),
111
+ meta("name", "twitter:title", metaData.title),
112
+ meta("name", "twitter:description", metaData.description)
113
+ );
114
+ if (metaData.imageUrl) {
115
+ lines.push(meta("name", "twitter:image", metaData.imageUrl));
116
+ }
117
+ lines.push("<!-- /mindoodb-share -->");
118
+ return lines.filter((line) => !line.includes('content=""')).join("\n");
119
+ }
120
+ var TITLE_PATTERN = /<title>[^<]*<\/title>/i;
121
+ function injectHavenAppShareMeta(html, metaData) {
122
+ if (html.includes("<!-- mindoodb-share -->")) {
123
+ return html;
124
+ }
125
+ const block = renderHavenAppShareMeta(metaData);
126
+ const titled = TITLE_PATTERN.test(html) ? html.replace(TITLE_PATTERN, `<title>${escapeText(metaData.title)}</title>`) : html;
127
+ const headEnd = titled.search(/<\/head>/i);
128
+ if (headEnd === -1) {
129
+ return titled;
130
+ }
131
+ return `${titled.slice(0, headEnd)}${block}
132
+ ${titled.slice(headEnd)}`;
133
+ }
134
+
14
135
  // src/vite/zip.ts
15
136
  import { deflateRawSync } from "zlib";
16
137
  var CRC32_TABLE = (() => {
@@ -229,11 +350,26 @@ async function readPackageMetadata(root) {
229
350
  return { name: void 0, version: void 0 };
230
351
  }
231
352
  }
353
+ function devPageUrl(config, ctx) {
354
+ const local = ctx.server?.resolvedUrls?.local ?? [];
355
+ const fromServer = havenAppSharePageUrl(local.find((url) => url.includes("127.0.0.1")) ?? local[0]);
356
+ if (fromServer) {
357
+ return fromServer;
358
+ }
359
+ const port = config.server?.port;
360
+ if (!port) {
361
+ return void 0;
362
+ }
363
+ const host = config.server?.host;
364
+ const hostname = !host || host === true || host === "0.0.0.0" ? "127.0.0.1" : host;
365
+ return havenAppSharePageUrl(`http://${hostname}:${port}/`);
366
+ }
232
367
  function havenBundle(options = {}) {
233
368
  let resolvedConfig = null;
234
369
  let emitted = false;
370
+ let isBuild = true;
235
371
  async function emitBundle() {
236
- if (emitted) {
372
+ if (!isBuild || emitted) {
237
373
  return;
238
374
  }
239
375
  if (!resolvedConfig) {
@@ -296,9 +432,27 @@ function havenBundle(options = {}) {
296
432
  }
297
433
  return {
298
434
  name: "haven-bundle",
299
- apply: "build",
300
435
  configResolved(config) {
301
436
  resolvedConfig = config;
437
+ isBuild = config.command !== "serve";
438
+ },
439
+ async transformIndexHtml(html, ctx) {
440
+ if (!resolvedConfig || ctx.filename?.includes("__haven-test")) {
441
+ return html;
442
+ }
443
+ let raw;
444
+ try {
445
+ raw = JSON.parse(await readFile(path.join(resolvedConfig.root, "public", "haven-app.json"), "utf8"));
446
+ } catch {
447
+ return html;
448
+ }
449
+ const baked = havenAppPublicUrl(raw);
450
+ const pageUrl = resolvedConfig.command === "serve" ? devPageUrl(resolvedConfig, ctx) ?? baked : baked;
451
+ if (!pageUrl) {
452
+ return html;
453
+ }
454
+ const meta2 = havenAppShareMeta(raw, pageUrl);
455
+ return meta2 ? injectHavenAppShareMeta(html, meta2) : html;
302
456
  },
303
457
  async writeBundle() {
304
458
  await emitBundle();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindoodb-app-sdk",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "engines": {
5
5
  "node": ">=22.13.0"
6
6
  },