@sprigr/apps-app-sdk 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,7 +15,7 @@ The runtime injects the `env.SPRIGR` host object **only on `/__sprigr/*` dispatc
15
15
  - `canEmit(env)` — whether an emit could reach the platform by either transport. Gate work that only exists to feed an emit on this, not on `env.SPRIGR?.emit`.
16
16
  - `withSprigrEmitFallback(env)` — repair `env.SPRIGR.emit` once and leave existing call sites untouched. Matches the host object's contract (resolves `{ ok, eventId, queued }`, throws on non-2xx).
17
17
  - `logToPlatform(env, entry | entry[], opts?)`: durable app logging from either context (`env.SPRIGR.log` on dispatch, `POST ${SPRIGR_PLATFORM_BASE}/internal/wfp/log` from an inline route). Rows land in the platform's `system_logs` Analytics Engine dataset (90-day retention, scoped to the install's company, category prefixed with the app slug), so use it instead of a per-webhook or per-tick audit row in your D1: D1 bills every row written, AE does not. Validation throws synchronously on a cap violation (summary 256, detail 4096, metadata JSON 3840, category 64 matching `[A-Za-z0-9._:-]`, 50 entries per call; nothing is ever truncated); after that the promise never rejects and resolves `{ ok: true, written }` or `{ ok: false, error, status?, detail? }`. Pass `{ waitUntil: ctx.waitUntil.bind(ctx) }` on an inline route so the send outlives the response. `withSprigrLogFallback(env, opts?)` installs `env.SPRIGR.log` once for many call sites; `canLog(env)` gates work whose only purpose is a log row; the `SprigrLogEntry` / `SprigrLogFn` types let your env interface declare the host member.
18
- - `partialUpdateData(env, objects, opts?)`: merge fields into objects already in the app's data index without reading them first (`env.SPRIGR.data.partialUpdate` on dispatch, `POST ${SPRIGR_PLATFORM_BASE}/internal/wfp/data/partial-update` from an inline route). Deep merge: nested objects recurse, arrays and scalars replace wholesale, absent keys survive, `null` overwrites. `createIfNotExists` defaults to `false`; on a sharded logical index every patch must carry the `shard_field` value or the batch fails with `shard_field_invalid`; 1000 objects per call like `import`. Throws on a bad batch before sending (`SprigrDataValidationError`) and on a platform rejection (`.status`, `.error`, `.detail` on the `Error`), the same contract as `import`. `canPartialUpdate(env)` gates a patch step on either transport; the `SprigrDataPartialUpdateOpts` / `SprigrDataPartialUpdateResult` types let your env interface declare the host member.
18
+ - `partialUpdateData(env, objects, opts?)`: merge fields into objects already in the app's data index without reading them first (`env.SPRIGR.data.partialUpdate` on dispatch, `POST ${SPRIGR_PLATFORM_BASE}/internal/wfp/data/partial-update` from an inline route). Deep merge: nested objects recurse, arrays and scalars replace wholesale, absent keys survive, `null` overwrites. `createIfNotExists` defaults to `false`; on a sharded logical index every patch must carry the `shard_field` value or the batch fails with `shard_field_invalid`; 1000 objects per call like `import`. Throws on a bad batch before sending (`SprigrDataValidationError`) and on a platform rejection (`.status`, `.error`, `.detail` on the `Error`), the same contract as `import`. With `{ withAcl: true }` it patches existing rows of the app's `-acl-files` index: each object carries `objectID` plus `acl_principals` and/or label fields the manifest declares in `data_index.acl_patchable_fields` (never `content`), and an object that omits `acl_principals` keeps its stored ones. `canPartialUpdate(env)` gates a patch step on either transport; the `SprigrDataPartialUpdateOpts` / `SprigrDataPartialUpdateResult` types let your env interface declare the host member.
19
19
  - `resolveInstallBridge(env)` / `installTokenPost(bridge, path, body, opts?)`: build your own `/internal/wfp/*` fallback (collections, files, inbox) with the auth and error extraction handled. A non-2xx throws an `Error` whose `.status`, `.error` (the platform's code) and `.detail` are set alongside the message.
20
20
  - `overlaySprigr(env, sprigr)` — overlay a patched `SPRIGR` via `Object.create`. Never rebuild a dispatch-path env by spread: the real bindings live on the prototype and `SPRIGR` is non-enumerable, so `{ ...env }` yields an env whose `DB` is `undefined`.
21
21
 
package/dist/index.d.ts CHANGED
@@ -1496,6 +1496,19 @@ interface AppApprovalEnvelope {
1496
1496
  * `ApprovalSpec.count`.
1497
1497
  */
1498
1498
  count?: number;
1499
+ /**
1500
+ * What the platform does when nobody can be asked (a schedule, workflow
1501
+ * step or delegation turn). Omitted, the write is withheld unless the
1502
+ * step's standing approval covers it. `'proceed'` runs the granted pass
1503
+ * instead, so the card appears only when a person is on the turn: the
1504
+ * contract the platform's built-in email send gate has always had. Use it
1505
+ * for writes automations legitimately make (sending mail, posting a chat
1506
+ * message); keep the default for deletes, money and bulk writes. Needs a
1507
+ * platform with sprigr-team decision 0160; an older one ignores it and
1508
+ * withholds. Set it through `ApprovalSpec.unattended` when you use the
1509
+ * wrappers.
1510
+ */
1511
+ unattended?: 'proceed';
1499
1512
  }
1500
1513
  /**
1501
1514
  * Platform-stamped marker telling an app that a human approved this call. The
@@ -1562,6 +1575,29 @@ declare function seq(values: unknown): string;
1562
1575
  */
1563
1576
  declare function approvalHash(...parts: Array<string | number | undefined | null>): string;
1564
1577
 
1578
+ /**
1579
+ * Helpers for the text on an approval card for a message send (an email, a
1580
+ * chat post), shared so each mail app does not grow its own copy.
1581
+ *
1582
+ * The card is display only. The grant hash and the arguments the platform
1583
+ * replays on approval (sprigr-team decision 0012) carry the full message, so
1584
+ * shortening the PREVIEW drops nothing that is sent.
1585
+ */
1586
+ /**
1587
+ * Lower-cased addresses from any recipient shape a send tool accepts: an array
1588
+ * of `{ email }` objects or strings, or one string separated by commas or
1589
+ * semicolons. Feed it to `set()` for an order-insensitive hash part.
1590
+ */
1591
+ declare function approvalRecipients(value: unknown): string[];
1592
+ /** Default preview length: enough to recognise the message, short enough not to bury the question. */
1593
+ declare const APPROVAL_PREVIEW_MAX = 600;
1594
+ /**
1595
+ * Plain-text preview of a message body for the card: tags stripped, `&nbsp;`
1596
+ * and runs of whitespace collapsed, and an ellipsis when it is cut so the
1597
+ * reader can tell the preview is not the whole message.
1598
+ */
1599
+ declare function approvalPreview(value: unknown, max?: number): string;
1600
+
1565
1601
  /**
1566
1602
  * Thrown by `undoEnvelope` for a field the platform would reject.
1567
1603
  *
@@ -1720,6 +1756,13 @@ interface ApprovalSpec<P = unknown, E = unknown> {
1720
1756
  * can ever cover it, which is the safe side but not the useful one.
1721
1757
  */
1722
1758
  count?: (args: ToolArgs) => number;
1759
+ /**
1760
+ * `'proceed'`: ask only when a person is on the turn, and let an unattended
1761
+ * run (schedule, workflow step, delegation) do the write. Omit to withhold
1762
+ * unattended writes unless a standing approval covers them. See
1763
+ * `AppApprovalEnvelope.unattended`.
1764
+ */
1765
+ unattended?: 'proceed';
1723
1766
  /**
1724
1767
  * Overrides the gate's `resolveConnection` for THIS spec only; the gate's
1725
1768
  * value stays the default for every spec that omits it.
@@ -2720,14 +2763,20 @@ interface SprigrDataPartialUpdateOpts extends SprigrDataIndexOpts {
2720
2763
  */
2721
2764
  createIfNotExists?: boolean;
2722
2765
  /**
2723
- * Re-stamp `acl_principals` on rows already in the app's `-acl-files`
2724
- * index without rewriting the rest of each row. Every object must be
2725
- * exactly `{ objectID, acl_principals }` with a non-empty, valid principal
2726
- * list; `createIfNotExists` and `index` are refused alongside it. Use it
2727
- * when the source changes who may see an item without reporting the item
2728
- * as changed (OneDrive's delta omits sharing-only changes). Needs a
2729
- * platform with sprigr/sprigr-team#9843; older wrappers drop the flag,
2730
- * which `partialUpdateData` detects and throws on.
2766
+ * Patch rows already in the app's `-acl-files` index without rewriting
2767
+ * the rest of each row. Each object carries `objectID` plus
2768
+ * `acl_principals` (a non-empty, valid list: re-stamps who may see it)
2769
+ * and/or label fields the manifest declares in
2770
+ * `data_index.acl_patchable_fields` (for example `tags`, `properties`).
2771
+ * An object that omits `acl_principals` keeps its stored ones. `content`
2772
+ * is never patchable, and `createIfNotExists` and `index` are refused. Use
2773
+ * it when the source changes who may see an item, or only its labels,
2774
+ * without changing its content (OneDrive's delta omits sharing-only
2775
+ * changes; a Dropbox tag edit leaves the file's text as it was). The
2776
+ * re-stamp needs a platform with sprigr/sprigr-team#9843, label fields one
2777
+ * with #10371 (an older one answers `acl_partial_update_fields`: fall back
2778
+ * to a whole-row import). Older wrappers drop the flag, which
2779
+ * `partialUpdateData` detects and throws on.
2731
2780
  */
2732
2781
  withAcl?: boolean;
2733
2782
  }
@@ -3100,4 +3149,4 @@ interface ExecutionContextLike {
3100
3149
  }
3101
3150
  type HandlerFn<TArgs, TResult> = (args: TArgs, env: Record<string, unknown>, ctx?: ExecutionContextLike) => Promise<TResult>;
3102
3151
 
3103
- export { ACTOR_RETIRED_HOOK_TOOL, ACTOR_RETIRE_REASONS, APPROVAL_GRANTED_KEY, APP_FILES_ROOT, APP_OWNER_SEGMENT, type Actor, type ActorRetireReason, type ActorRetired, type ActorRetiredHookBody, type ActorRetiredResult, type AppApprovalEnvelope, type AppFileListItem, type AppFileUrlArgs, type AppFileUrlResult, type AppFilesEnv, type AppToolEffectsDeclaration, type AppUndoEnvelope, type ApplyPoliciesOptions, type ApprovalGateOptions, type ApprovalSpec, type ArchiveOfferOptions, type ArchiveOfferRefusal, type CallerKeyResolution, type CaptureJournal, type ConfirmCondition, type ConfirmRule, type ConfirmationPolicy, type ConnectCompleteRequest, type ConnectCompleteResult, type D1Like, type D1PreparedStatementLike, DATA_PARTIAL_UPDATE_PATH, DEFAULT_EMIT_TIMEOUT_MS, DEFAULT_LOG_TIMEOUT_MS, DEFAULT_MAX_FILE_BYTES, DEFAULT_MONEY_FIELDS, DEFAULT_WRITE_PREFIXES, type DerivePolicyOptions, type DerivedPolicy, type DispatcherApprovalGate, type DispatcherApprovalOptions, type EmitMarketplaceEventOptions, type EmitResult, type EmitTransport, type EventArgs, type ExecutionContextLike, type FetchFileResult, type FetchWithRetryOptions, type GetAppFileResult, type HandlerFn, INBOX_SEND_CONTRACT_V1, type InboxAddress, type InboxAppendRequest, type InboxAppendResult, type InboxChannelDeclaration, type InboxFoldersRequest, type InboxFoldersResult, type InboxOwner, type InboxSendConnection, type InboxSendHandlerImpl, InboxSendRefusal, type InboxSendSupports, type InboxSendV1Args, type InboxSendV1Result, type InstallBridge, InvalidUndoEnvelopeError, type JournalRowLike, type LogToPlatformOptions, type ManifestDispatchBlock, type ManifestLike, type ManifestToolLike, type MarketplaceEventEmitOpts, type MarketplaceEventSourceIntegration, NotConnectedError, type OAuthBouncerSignals, type OAuthState, type OfferUndoArgs, type PartialUpdateDataOptions, type PlatformHostEnv, type PolicyCheckInput, type PolicySource, type PutAppFileArgs, type PutAppFileResult, type PutAppFileStreamArgs, type RequireApprovalOptions, type ResolveViewerOptions, type RestoreResult, type RestoreSpec, SPRIGR_DATA_MAX_OBJECTS_PER_CALL, SPRIGR_LOG_LEVELS, SPRIGR_LOG_LIMITS, type ScheduleArgs, type SprigrDataAggregationCell, type SprigrDataAggregationResult, type SprigrDataAggregationSpec, type SprigrDataApi, type SprigrDataImportOpts, type SprigrDataIndexOpts, type SprigrDataPartialUpdateBody, type SprigrDataPartialUpdateOpts, type SprigrDataPartialUpdateResult, type SprigrDataPatch, type SprigrDataSearchOpts, type SprigrDataSearchResult, SprigrDataValidationError, type SprigrFilesApi, type SprigrFilesApiWithEdit, type SprigrFilesCreateInput, type SprigrFilesCreateResult, type SprigrFilesEditInput, type SprigrFilesEditResult, type SprigrFilesJobResult, type SprigrFilesListItem, type SprigrFilesListResult, type SprigrInboxApi, type SprigrLogEntry, type SprigrLogFn, type SprigrLogLevel, type SprigrLogResult, SprigrLogValidationError, type SyncedAttachment, type SyncedMessage, type ToolArgs, type ToolHandler, type ToolResult, type ToolWrapperOptions, UNIT_SEP, type UndoApplyOptions, type UndoApplyResult, type UndoCaptureSpec, type UndoFidelity, VIEWER_ANONYMOUS, VIEWER_CONTEXT_HEADER, VIEWER_PLATFORM_USER_ID_HEADER, VIEWER_ROLE_HEADER, VIEWER_USER_ID_HEADER, type VerbRule, type ViewerContext, type ViewerContextFailure, type ViewerContextVerification, type ViewerEnv, type WebhookArgs, type WfpBridgeEnv, type WfpEmitReply, actorKey, actorRetiredHook, actorTool, agentFileKeyFromUrl, appFileUrl, appKeyFromCallerKey, applyConfirmationPolicies, approvalHash, archiveOfferRefusal, base64ToBytes, buildConfirmationPolicy, buildMarketplaceWebhookUrl, buildPartialUpdateBody, bytesToBase64, callerKeyRefusal, canEmit, canLog, canPartialUpdate, checkConfirmationPolicy, commonDestructiveVerbs, connectComplete, connectDisconnect, constantTimeEqual, createMarketplaceEmitter, createToolWrappers, decodeState, defineInboxSendHandler, deleteAppFile, deriveConfirmationPolicy, describeMissingBridge, dispatcherApproval, emitMarketplaceEvent, encodeState, fetchFileAsBase64, fetchFileBytes, fetchWithRetry, fullWarning, getAppFile, hmacSha256Hex, installTokenPost, isNotConnectedError, isStagingHost, listAppFiles, logToPlatform, manifestIsFresh, offerUndo, overlaySprigr, ownerFromActorKey, parseActor, parseActorRetiredArgs, partialUpdateData, putAppFile, putAppFileStream, randomHex, readableStoredKey, recreatedWarning, refuseWithoutForce, requireApproval, resolveInstallBridge, resolveOAuthBouncerBase, resolveOAuthBouncerCallbackUrl, resolvePlatformWebhookBase, resolveViewerContext, resolveViewerUserId, runUndoApply, safeCapture, seq, serializeManifest, set, tool, undoEnvelope, validateLogEntries, validateLogEntry, verifyViewerToken, withSprigrEmitFallback, withSprigrInboxFallback, withSprigrLogFallback };
3152
+ export { ACTOR_RETIRED_HOOK_TOOL, ACTOR_RETIRE_REASONS, APPROVAL_GRANTED_KEY, APPROVAL_PREVIEW_MAX, APP_FILES_ROOT, APP_OWNER_SEGMENT, type Actor, type ActorRetireReason, type ActorRetired, type ActorRetiredHookBody, type ActorRetiredResult, type AppApprovalEnvelope, type AppFileListItem, type AppFileUrlArgs, type AppFileUrlResult, type AppFilesEnv, type AppToolEffectsDeclaration, type AppUndoEnvelope, type ApplyPoliciesOptions, type ApprovalGateOptions, type ApprovalSpec, type ArchiveOfferOptions, type ArchiveOfferRefusal, type CallerKeyResolution, type CaptureJournal, type ConfirmCondition, type ConfirmRule, type ConfirmationPolicy, type ConnectCompleteRequest, type ConnectCompleteResult, type D1Like, type D1PreparedStatementLike, DATA_PARTIAL_UPDATE_PATH, DEFAULT_EMIT_TIMEOUT_MS, DEFAULT_LOG_TIMEOUT_MS, DEFAULT_MAX_FILE_BYTES, DEFAULT_MONEY_FIELDS, DEFAULT_WRITE_PREFIXES, type DerivePolicyOptions, type DerivedPolicy, type DispatcherApprovalGate, type DispatcherApprovalOptions, type EmitMarketplaceEventOptions, type EmitResult, type EmitTransport, type EventArgs, type ExecutionContextLike, type FetchFileResult, type FetchWithRetryOptions, type GetAppFileResult, type HandlerFn, INBOX_SEND_CONTRACT_V1, type InboxAddress, type InboxAppendRequest, type InboxAppendResult, type InboxChannelDeclaration, type InboxFoldersRequest, type InboxFoldersResult, type InboxOwner, type InboxSendConnection, type InboxSendHandlerImpl, InboxSendRefusal, type InboxSendSupports, type InboxSendV1Args, type InboxSendV1Result, type InstallBridge, InvalidUndoEnvelopeError, type JournalRowLike, type LogToPlatformOptions, type ManifestDispatchBlock, type ManifestLike, type ManifestToolLike, type MarketplaceEventEmitOpts, type MarketplaceEventSourceIntegration, NotConnectedError, type OAuthBouncerSignals, type OAuthState, type OfferUndoArgs, type PartialUpdateDataOptions, type PlatformHostEnv, type PolicyCheckInput, type PolicySource, type PutAppFileArgs, type PutAppFileResult, type PutAppFileStreamArgs, type RequireApprovalOptions, type ResolveViewerOptions, type RestoreResult, type RestoreSpec, SPRIGR_DATA_MAX_OBJECTS_PER_CALL, SPRIGR_LOG_LEVELS, SPRIGR_LOG_LIMITS, type ScheduleArgs, type SprigrDataAggregationCell, type SprigrDataAggregationResult, type SprigrDataAggregationSpec, type SprigrDataApi, type SprigrDataImportOpts, type SprigrDataIndexOpts, type SprigrDataPartialUpdateBody, type SprigrDataPartialUpdateOpts, type SprigrDataPartialUpdateResult, type SprigrDataPatch, type SprigrDataSearchOpts, type SprigrDataSearchResult, SprigrDataValidationError, type SprigrFilesApi, type SprigrFilesApiWithEdit, type SprigrFilesCreateInput, type SprigrFilesCreateResult, type SprigrFilesEditInput, type SprigrFilesEditResult, type SprigrFilesJobResult, type SprigrFilesListItem, type SprigrFilesListResult, type SprigrInboxApi, type SprigrLogEntry, type SprigrLogFn, type SprigrLogLevel, type SprigrLogResult, SprigrLogValidationError, type SyncedAttachment, type SyncedMessage, type ToolArgs, type ToolHandler, type ToolResult, type ToolWrapperOptions, UNIT_SEP, type UndoApplyOptions, type UndoApplyResult, type UndoCaptureSpec, type UndoFidelity, VIEWER_ANONYMOUS, VIEWER_CONTEXT_HEADER, VIEWER_PLATFORM_USER_ID_HEADER, VIEWER_ROLE_HEADER, VIEWER_USER_ID_HEADER, type VerbRule, type ViewerContext, type ViewerContextFailure, type ViewerContextVerification, type ViewerEnv, type WebhookArgs, type WfpBridgeEnv, type WfpEmitReply, actorKey, actorRetiredHook, actorTool, agentFileKeyFromUrl, appFileUrl, appKeyFromCallerKey, applyConfirmationPolicies, approvalHash, approvalPreview, approvalRecipients, archiveOfferRefusal, base64ToBytes, buildConfirmationPolicy, buildMarketplaceWebhookUrl, buildPartialUpdateBody, bytesToBase64, callerKeyRefusal, canEmit, canLog, canPartialUpdate, checkConfirmationPolicy, commonDestructiveVerbs, connectComplete, connectDisconnect, constantTimeEqual, createMarketplaceEmitter, createToolWrappers, decodeState, defineInboxSendHandler, deleteAppFile, deriveConfirmationPolicy, describeMissingBridge, dispatcherApproval, emitMarketplaceEvent, encodeState, fetchFileAsBase64, fetchFileBytes, fetchWithRetry, fullWarning, getAppFile, hmacSha256Hex, installTokenPost, isNotConnectedError, isStagingHost, listAppFiles, logToPlatform, manifestIsFresh, offerUndo, overlaySprigr, ownerFromActorKey, parseActor, parseActorRetiredArgs, partialUpdateData, putAppFile, putAppFileStream, randomHex, readableStoredKey, recreatedWarning, refuseWithoutForce, requireApproval, resolveInstallBridge, resolveOAuthBouncerBase, resolveOAuthBouncerCallbackUrl, resolvePlatformWebhookBase, resolveViewerContext, resolveViewerUserId, runUndoApply, safeCapture, seq, serializeManifest, set, tool, undoEnvelope, validateLogEntries, validateLogEntry, verifyViewerToken, withSprigrEmitFallback, withSprigrInboxFallback, withSprigrLogFallback };
package/dist/index.js CHANGED
@@ -580,19 +580,26 @@ function checkAclRestamp(objects, opts, at) {
580
580
  }
581
581
  for (let i = 0; i < objects.length; i++) {
582
582
  const o = objects[i];
583
- const extra = Object.keys(o).find((k) => k !== "objectID" && k !== "acl_principals");
584
- if (extra !== void 0) {
583
+ if ("content" in o) {
585
584
  throw new SprigrDataValidationError(
586
- `${at}: objects[${i}] carries "${extra}"; a withAcl partial update sets only objectID and acl_principals (write content with data.import withAcl)`,
585
+ `${at}: objects[${i}] carries "content"; a withAcl partial update never writes extracted text (write content with data.import withAcl)`,
587
586
  { error: "acl_partial_update_fields", index: i }
588
587
  );
589
588
  }
590
- const principals = o.acl_principals;
591
- if (!Array.isArray(principals) || principals.length === 0) {
592
- throw new SprigrDataValidationError(`${at}: objects[${i}] needs a non-empty acl_principals: string[]`, {
593
- error: "missing_acl_principals",
594
- index: i
595
- });
589
+ if (!Object.keys(o).some((k) => k !== "objectID")) {
590
+ throw new SprigrDataValidationError(
591
+ `${at}: objects[${i}] sets nothing; send acl_principals or a field your manifest declares in data_index.acl_patchable_fields`,
592
+ { error: "acl_partial_update_empty", index: i }
593
+ );
594
+ }
595
+ if ("acl_principals" in o) {
596
+ const principals = o.acl_principals;
597
+ if (!Array.isArray(principals) || principals.length === 0) {
598
+ throw new SprigrDataValidationError(`${at}: objects[${i}] needs a non-empty acl_principals: string[]`, {
599
+ error: "missing_acl_principals",
600
+ index: i
601
+ });
602
+ }
596
603
  }
597
604
  }
598
605
  }
@@ -1037,6 +1044,32 @@ function approvalHash(...parts) {
1037
1044
  return parts.map((p) => p === void 0 || p === null ? "" : String(p)).join(UNIT_SEP);
1038
1045
  }
1039
1046
 
1047
+ // src/write-protection/approval-card.ts
1048
+ function approvalRecipients(value) {
1049
+ const out = [];
1050
+ const add = (s) => {
1051
+ if (typeof s !== "string") return;
1052
+ for (const part of s.split(/[,;]/)) {
1053
+ const t = part.trim().toLowerCase();
1054
+ if (t) out.push(t);
1055
+ }
1056
+ };
1057
+ if (Array.isArray(value)) {
1058
+ for (const item of value) {
1059
+ if (item && typeof item === "object") add(item.email);
1060
+ else add(item);
1061
+ }
1062
+ } else {
1063
+ add(value);
1064
+ }
1065
+ return out;
1066
+ }
1067
+ var APPROVAL_PREVIEW_MAX = 600;
1068
+ function approvalPreview(value, max = APPROVAL_PREVIEW_MAX) {
1069
+ const text = (typeof value === "string" ? value : "").replace(/<[^>]*>/g, " ").replace(/&nbsp;/g, " ").replace(/\s+/g, " ").trim();
1070
+ return text.length > max ? `${text.slice(0, max)}\u2026` : text;
1071
+ }
1072
+
1040
1073
  // src/write-protection/undo-envelope.ts
1041
1074
  var InvalidUndoEnvelopeError = class extends Error {
1042
1075
  constructor(message) {
@@ -1187,7 +1220,8 @@ async function askPass(name, spec, params, env, opts, hashPrefix) {
1187
1220
  _approval: {
1188
1221
  ...spec.describe(target, params, connection),
1189
1222
  hash: approvalHash(...hashPrefix, rawId, connection, ...extra),
1190
- ...count !== void 0 ? { count } : {}
1223
+ ...count !== void 0 ? { count } : {},
1224
+ ...spec.unattended === "proceed" ? { unattended: "proceed" } : {}
1191
1225
  }
1192
1226
  };
1193
1227
  }
@@ -1764,6 +1798,7 @@ export {
1764
1798
  ACTOR_RETIRED_HOOK_TOOL,
1765
1799
  ACTOR_RETIRE_REASONS,
1766
1800
  APPROVAL_GRANTED_KEY,
1801
+ APPROVAL_PREVIEW_MAX,
1767
1802
  APP_FILES_ROOT,
1768
1803
  APP_OWNER_SEGMENT,
1769
1804
  DATA_PARTIAL_UPDATE_PATH,
@@ -1795,6 +1830,8 @@ export {
1795
1830
  appKeyFromCallerKey,
1796
1831
  applyConfirmationPolicies,
1797
1832
  approvalHash,
1833
+ approvalPreview,
1834
+ approvalRecipients,
1798
1835
  archiveOfferRefusal,
1799
1836
  base64ToBytes,
1800
1837
  buildConfirmationPolicy,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprigr/apps-app-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",