@aglyn/aglyn 1.23.1 → 1.25.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.
Files changed (69) hide show
  1. package/package.json +11 -11
  2. package/src/lib/app-utils/activity-labels.js +4 -1
  3. package/src/lib/app-utils/activity-labels.js.map +1 -1
  4. package/src/lib/app-utils/activity-presenter.d.ts +11 -0
  5. package/src/lib/app-utils/activity-presenter.js +9 -0
  6. package/src/lib/app-utils/activity-presenter.js.map +1 -1
  7. package/src/lib/app-utils/activity-search.d.ts +1 -0
  8. package/src/lib/app-utils/activity-search.js +1 -0
  9. package/src/lib/app-utils/activity-search.js.map +1 -1
  10. package/src/lib/app-utils/agent-api-catalog.d.ts +18 -0
  11. package/src/lib/app-utils/agent-api-catalog.js +8 -1
  12. package/src/lib/app-utils/agent-api-catalog.js.map +1 -1
  13. package/src/lib/app-utils/binding-token-catalog.d.ts +15 -0
  14. package/src/lib/app-utils/binding-token-catalog.js +16 -0
  15. package/src/lib/app-utils/binding-token-catalog.js.map +1 -1
  16. package/src/lib/app-utils/business-details.d.ts +5 -0
  17. package/src/lib/app-utils/business-details.js +4 -0
  18. package/src/lib/app-utils/business-details.js.map +1 -1
  19. package/src/lib/app-utils/connector-discovery.d.ts +80 -0
  20. package/src/lib/app-utils/connector-discovery.js +107 -0
  21. package/src/lib/app-utils/connector-discovery.js.map +1 -0
  22. package/src/lib/app-utils/crm.d.ts +17 -30
  23. package/src/lib/app-utils/crm.js +139 -3
  24. package/src/lib/app-utils/crm.js.map +1 -1
  25. package/src/lib/app-utils/docs-help-sections.generated.js +5 -1
  26. package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
  27. package/src/lib/app-utils/docs-help.generated.d.ts +5 -5
  28. package/src/lib/app-utils/docs-help.generated.js +12 -3
  29. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  30. package/src/lib/app-utils/docs-index.generated.js +149 -9
  31. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  32. package/src/lib/app-utils/entity-picker-context.d.ts +6 -0
  33. package/src/lib/app-utils/entity-picker-context.js.map +1 -1
  34. package/src/lib/app-utils/expand-repeatables.js +25 -2
  35. package/src/lib/app-utils/expand-repeatables.js.map +1 -1
  36. package/src/lib/app-utils/host-tokens.d.ts +17 -0
  37. package/src/lib/app-utils/host-tokens.js +18 -0
  38. package/src/lib/app-utils/host-tokens.js.map +1 -1
  39. package/src/lib/app-utils/native-app-association.d.ts +9 -5
  40. package/src/lib/app-utils/native-app-association.js +10 -5
  41. package/src/lib/app-utils/native-app-association.js.map +1 -1
  42. package/src/lib/app-utils/native-nav.js +1 -1
  43. package/src/lib/app-utils/native-nav.js.map +1 -1
  44. package/src/lib/app-utils/organizations.js +4 -2
  45. package/src/lib/app-utils/organizations.js.map +1 -1
  46. package/src/lib/app-utils/plan-entitlements.d.ts +227 -36
  47. package/src/lib/app-utils/plan-entitlements.js +335 -43
  48. package/src/lib/app-utils/plan-entitlements.js.map +1 -1
  49. package/src/lib/app-utils/plugin-release-flags.generated.js +2 -2
  50. package/src/lib/app-utils/plugin-release-flags.generated.js.map +1 -1
  51. package/src/lib/app-utils/reusable-component-keys.d.ts +9 -0
  52. package/src/lib/app-utils/reusable-component-keys.js +9 -0
  53. package/src/lib/app-utils/reusable-component-keys.js.map +1 -1
  54. package/src/lib/app-utils/server.d.ts +1 -0
  55. package/src/lib/app-utils/server.js +1 -0
  56. package/src/lib/app-utils/server.js.map +1 -1
  57. package/src/lib/app-utils/sign-in-visibility.d.ts +78 -0
  58. package/src/lib/app-utils/sign-in-visibility.js +79 -0
  59. package/src/lib/app-utils/sign-in-visibility.js.map +1 -0
  60. package/src/lib/app-utils/site-live-url.d.ts +4 -1
  61. package/src/lib/app-utils/site-live-url.js +17 -3
  62. package/src/lib/app-utils/site-live-url.js.map +1 -1
  63. package/src/lib/app-utils/usage-level.d.ts +50 -0
  64. package/src/lib/app-utils/usage-level.js +94 -0
  65. package/src/lib/app-utils/usage-level.js.map +1 -0
  66. package/src/lib/foundation/definitions/org-billing.types.d.ts +24 -2
  67. package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
  68. package/src/lib/plugin-manager/plugin-contact-capture.d.ts +2 -0
  69. package/src/lib/plugin-manager/plugin-contact-capture.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/aglyn",
3
- "version": "1.23.1",
3
+ "version": "1.25.0",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -37,16 +37,16 @@
37
37
  "./package.json": "./package.json"
38
38
  },
39
39
  "dependencies": {
40
- "@aglyn/shared-data-enums": "1.23.1",
41
- "@aglyn/shared-data-mdi": "1.23.1",
42
- "@aglyn/shared-data-types": "1.23.1",
43
- "@aglyn/shared-util-email": "1.23.1",
44
- "@aglyn/shared-util-first-touch": "1.23.1",
45
- "@aglyn/shared-util-http": "1.23.1",
46
- "@aglyn/shared-util-logger": "1.23.1",
47
- "@aglyn/shared-util-timestamp": "1.23.1",
48
- "@aglyn/shared-util-tools": "1.23.1",
49
- "@aglyn/shared-util-vendor": "1.23.1",
40
+ "@aglyn/shared-data-enums": "1.25.0",
41
+ "@aglyn/shared-data-mdi": "1.25.0",
42
+ "@aglyn/shared-data-types": "1.25.0",
43
+ "@aglyn/shared-util-email": "1.25.0",
44
+ "@aglyn/shared-util-first-touch": "1.25.0",
45
+ "@aglyn/shared-util-http": "1.25.0",
46
+ "@aglyn/shared-util-logger": "1.25.0",
47
+ "@aglyn/shared-util-timestamp": "1.25.0",
48
+ "@aglyn/shared-util-tools": "1.25.0",
49
+ "@aglyn/shared-util-vendor": "1.25.0",
50
50
  "@data-driven-forms/react-form-renderer": "^4.2.3",
51
51
  "@msgpack/msgpack": "^3.1.3",
52
52
  "@types/unist": "^3.0.3",
@@ -126,6 +126,7 @@ import { isPluginJobTargetType, pluginActivityActionSentence, pluginActivityTarg
126
126
  'host.reattach-domain': 'Reattached a domain',
127
127
  'host.set-subdomain': 'Changed a site address',
128
128
  'host.transfer': 'Transferred a site',
129
+ 'host.usageLevel': 'Set the site usage level',
129
130
  'lockdown.lock': 'Locked the workspace down',
130
131
  'lockdown.payouts-pause': 'Paused payouts',
131
132
  'lockdown.payouts-restore': 'Restored payouts',
@@ -160,6 +161,7 @@ import { isPluginJobTargetType, pluginActivityActionSentence, pluginActivityTarg
160
161
  'org.successManagerSet': 'Assigned a success manager',
161
162
  'org.upgradeProposal.propose': 'Proposed an upgrade',
162
163
  'org.upgradeProposal.withdraw': 'Withdrew an upgrade proposal',
164
+ 'org.usageLevel': 'Set the workspace usage level',
163
165
  'orgs.unverified.reap': 'Removed unverified organizations',
164
166
  'person.erased': 'Erased a person',
165
167
  'person.erasure-requested': 'Requested erasure of a person',
@@ -194,7 +196,8 @@ import { isPluginJobTargetType, pluginActivityActionSentence, pluginActivityTarg
194
196
  'user.setAdAudienceOptOut': 'Changed the ad audience opt-out',
195
197
  'user.setPassword': 'Set the password',
196
198
  'user.signOutDevice': 'Signed a device out',
197
- 'user.updateProfile': 'Updated the profile'
199
+ 'user.updateProfile': 'Updated the profile',
200
+ 'user.usageLevel': 'Set the account usage level'
198
201
  };
199
202
  /** Leading namespaces as a reader names them. */ const NAMESPACE_LABELS = {
200
203
  org: 'Organization',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/activity-labels.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * ONE LABEL MAP FOR EVERY ACTIVITY AND AUDIT LIST (AGL-3660).\n *\n * Two logs feed the console's lists. The activity logs\n * (`orgs/{id}/activity`, `hosts/{id}/activity`) store a prose sentence or a\n * plugin's code plus a `{ type, id, name }` target. The staff audit trail\n * (`adminAudit`) stores a dotted code (`ai.job.output`, `org.override`) and\n * a Firestore PATH as its target (`orgs/abc/aiJobs/xyz`). The staff tables\n * printed both raw, so a reader saw `ai.job.output` next to\n * `orgs/9fK…/aiJobs/Qe2…` and had to know the schema to read their own\n * audit trail.\n *\n * Every list now draws its words from here: an action as a sentence\n * (`Created page Home with Aglyn AI`), a target as the site and the item,\n * and — for an audit row — why, the credits it spent and what came of it.\n * The raw code and path are kept on the description, for a tooltip and for\n * the staff details dialog, and never as the visible text.\n */\n\nimport {\n activityActionLabel,\n activityPrimaryText,\n activityTypeLabel,\n type ActivityEntryLike,\n type ActivityTargetLike,\n} from './activity-presenter'\nimport { orgOverrideReasonSummary } from './org-override-reason'\nimport {\n isPluginJobTargetType,\n pluginActivityActionSentence,\n pluginActivityTargetLabel,\n pluginStaffAuditActionLabel,\n pluginStaffAuditCollection,\n pluginStaffAuditDescribe,\n} from '../plugin-manager/plugin-activity-actions'\n\n/** What a list row and the details dialog show for one entry. */\nexport interface ActivityDescription {\n /** The act, as a sentence. Never a code. */\n action: string\n /** What it was done to, in words: the site and the item. Never a path. */\n target: string\n /** Why it was done, when the writer recorded a reason. */\n why: string | null\n /** AI credits it spent, when it spent any. */\n credits: number | null\n /** What came of it, when the writer recorded an outcome. */\n result: string | null\n /** The stored code, when the action was one — for a tooltip and staff. */\n code: string | null\n /** The stored target path (audit) or `type/id` (activity) — staff only. */\n path: string | null\n /** The organization the entry concerns, when it names one. */\n orgId: string | null\n /** The site the entry concerns, when it names one. */\n hostId: string | null\n /** The plugin job behind the entry (an AI job), when there is one. */\n jobId: string | null\n /** The account the entry concerns, when it names one. */\n uid: string | null\n}\n\n/** Names a route resolved for the ids an entry carries. */\nexport interface ActivityNames {\n /** Organization name by org id. */\n orgs?: Readonly<Record<string, string | null | undefined>>\n /** Site name by host id. */\n hosts?: Readonly<Record<string, string | null | undefined>>\n /** An account's address (or name) by uid. */\n users?: Readonly<Record<string, string | null | undefined>>\n}\n\n/** `screen` → `page`, `Home` → `page Home`: the noun a sentence uses. */\nexport function activityTargetPhrase(target: ActivityTargetLike | null | undefined): string {\n const noun = activityTypeLabel(target?.type)\n const lower = noun === 'Item' ? 'item' : noun.charAt(0).toLowerCase() + noun.slice(1)\n const name = target?.name?.trim()\n return name ? `${lower} ${name}` : lower\n}\n\n/**\n * An activity row's action as a sentence about its target. A plugin code\n * with a declared sentence fills it (`Created {target} with Aglyn AI`); any\n * other code reads as its label, and a prose action as itself.\n */\nexport function activityActionSentence(\n action: string | undefined,\n target?: ActivityTargetLike | null,\n): string {\n const stored = action?.trim() ?? ''\n const sentence = pluginActivityActionSentence(stored)\n if (sentence) return sentence.replace('{target}', activityTargetPhrase(target))\n return activityActionLabel(stored)\n}\n\n/**\n * A one-column feed's line: the sentence when the code declares one, else\n * the action with its target's name (`Saved the screen — Home`).\n */\nexport function activityRowText(entry: ActivityEntryLike): string {\n const stored = entry.action?.trim() ?? ''\n return pluginActivityActionSentence(stored)\n ? activityActionSentence(stored, entry.target)\n : activityPrimaryText(entry)\n}\n\n/** Whether a stored action is a dotted code rather than a sentence. */\nexport function isActivityCode(action: unknown): action is string {\n return typeof action === 'string' && /^[a-z][\\w-]*(\\.[\\w-]+)+$/i.test(action.trim())\n}\n\n/*==========================================\n * THE STAFF AUDIT TRAIL'S WORDS.\n *\n * Every code core's doors write. A plugin's doors declare their own through\n * `staffAuditLabels` (the AI plugin's `ai.job.*`), and a code neither knows\n * is humanized from its segments rather than shown raw, so a new writer\n * reads as `Billing: invoice paid` until somebody names it properly.\n *==========================================*/\nexport const STAFF_AUDIT_ACTION_LABELS: Readonly<Record<string, string>> = {\n 'account.closed.self': 'Closed their own account',\n 'account.exported.self': 'Exported their own account data',\n 'ai-usage.exported': 'Exported AI usage',\n 'billing.assistOverage.setCap': 'Set the AI overage ceiling',\n 'billing.assistOverage.setHardCap': 'Set the AI stop-at-band switch',\n 'billing.autoLocked': 'Locked automatically for billing',\n 'billing.bundle-link-minted': 'Made a bundle checkout link',\n 'billing.collaboratorAllocation': 'Changed collaborator seats',\n 'billing.dispute.opened': 'Payment dispute opened',\n 'billing.disputeClosed': 'Payment dispute closed',\n 'billing.disputeOpened': 'Payment dispute opened',\n 'billing.disputeUnattributed': 'Unattributed payment dispute',\n 'billing.invoice': 'Invoice event',\n 'billing.invoice.closed': 'Invoice closed',\n 'billing.invoice.failed': 'Invoice payment failed',\n 'billing.invoice.paid': 'Invoice paid',\n 'billing.manage': 'Opened billing management',\n 'billing.orphanedSubscription': 'Found a subscription with no workspace',\n 'billing.paymentFailed': 'Payment failed',\n 'billing.paymentMethod.changed': 'Changed the payment method',\n 'billing.platformDisputeLost': 'Lost a payment dispute',\n 'billing.platformInvoiceUncollectible': 'Invoice marked uncollectible',\n 'billing.registerAllocation': 'Changed register allocation',\n 'billing.storageOverage.setCap': 'Set the storage overage ceiling',\n 'billing.subscriptionCanceled': 'Subscription canceled',\n 'billing.usage': 'Recorded usage',\n 'billing.usageBudget.set': 'Set the usage budget',\n 'billing.view': 'Viewed billing',\n 'billing.webhookInert': 'Ignored a billing webhook',\n 'billing.webhookSignatureRejected': 'Rejected a billing webhook signature',\n 'broadcast.send': 'Sent a broadcast',\n 'client-build.preview-sent': 'Sent a client build preview',\n 'contact.phone.erased': 'Erased a phone number',\n 'contact.suppression.recorded': 'Added a contact suppression',\n 'contact.suppression.released': 'Released a contact suppression',\n 'coupon.create': 'Created a coupon',\n 'coupon.promotion_code.update': 'Updated a promotion code',\n 'data.transfer.export': 'Exported data',\n 'data.transfer.plan': 'Planned a data transfer',\n 'email.history-imported': 'Imported email history',\n 'email.message-viewed': 'Viewed an email message',\n 'email.sending-domains.reap': 'Removed unused sending domains',\n 'email.suppression.release': 'Released an email suppression',\n 'emailSendRate.update': 'Changed the email send rate',\n 'erasure.runBatch': 'Ran an erasure batch',\n 'erasures.replayed': 'Replayed erasures',\n 'firestore.export': 'Exported the database',\n 'firstPartyHosts.update': 'Changed first-party sites',\n 'flags.update': 'Changed feature flags',\n 'freeWorkspaceCap.update': 'Changed the free workspace cap',\n 'host.deleted': 'Deleted a site',\n 'host.domain.released': 'Released a domain',\n 'host.reattach-domain': 'Reattached a domain',\n 'host.set-subdomain': 'Changed a site address',\n 'host.transfer': 'Transferred a site',\n 'lockdown.lock': 'Locked the workspace down',\n 'lockdown.payouts-pause': 'Paused payouts',\n 'lockdown.payouts-restore': 'Restored payouts',\n 'lockdown.renewals-pause': 'Paused renewals',\n 'lockdown.renewals-resume': 'Resumed renewals',\n 'lockdown.resend-notice': 'Resent the lockdown notice',\n 'maintenance.auditArchive.run': 'Archived the audit log',\n 'maintenance.reapArtifacts.run': 'Removed stale build artifacts',\n 'maintenance.reverifyPlugins.run': 'Re-verified plugins',\n 'operatorAlerts.test': 'Sent a test operator alert',\n 'operatorAlerts.update': 'Changed operator alerts',\n 'org.acquisition-viewed': 'Viewed where the organization came from',\n 'org.auditLog': 'Viewed the organization audit log',\n 'org.discount.apply': 'Applied a discount',\n 'org.discount.remove': 'Removed a discount',\n 'org.enterprise.provision': 'Provisioned enterprise billing',\n 'org.erase-failed': 'Organization erasure failed',\n 'org.erased': 'Erased the organization',\n 'org.erasureCanceled': 'Canceled the organization erasure',\n 'org.erasureRequested': 'Requested organization erasure',\n 'org.exported': 'Exported the organization',\n 'org.name': 'Renamed the organization',\n 'org.note': 'Added a staff note',\n 'org.override': 'Overrode the plan',\n 'org.refund': 'Issued a refund',\n 'org.seatAddons.changed': 'Changed seat add-ons',\n 'org.sso.enforceSignInMethods': 'Changed enforced sign-in methods',\n 'org.sso.jit': 'Changed single sign-on provisioning',\n 'org.subscription-cancel': 'Canceled the subscription',\n 'org.subscriptionStarted.settle': 'Settled a new subscription',\n 'org.successManagerCleared': 'Removed the success manager',\n 'org.successManagerSet': 'Assigned a success manager',\n 'org.upgradeProposal.propose': 'Proposed an upgrade',\n 'org.upgradeProposal.withdraw': 'Withdrew an upgrade proposal',\n 'orgs.unverified.reap': 'Removed unverified organizations',\n 'person.erased': 'Erased a person',\n 'person.erasure-requested': 'Requested erasure of a person',\n 'plan.name': 'Renamed a plan',\n 'plugins.artifacts.reap': 'Removed stale plugin builds',\n 'plugins.remoteServer.load': 'Loaded a remote plugin server',\n 'plugins.verification.decline': 'Declined a plugin verification',\n 'plugins.verifier.regression': 'Plugin verifier regression',\n 'security.pageSecurityHold': 'Put a page on security hold',\n 'security.paymentFraudHold': 'Put a workspace on hold for payment fraud',\n 'security.staffGranted': 'Granted staff access',\n 'site.package.apply': 'Applied a site package',\n 'site.package.undo': 'Undid a site package',\n 'sso.domain.driftDetected': 'Single sign-on domain drift detected',\n 'staff.evidence': 'Recorded evidence',\n 'staff.paymentFailed': 'Payment failed (staff notice)',\n 'staff.planChanged': 'Plan changed (staff notice)',\n 'staff.subscriptionCanceled': 'Subscription canceled (staff notice)',\n 'staff.subscriptionStarted': 'Subscription started (staff notice)',\n 'systemEmail.staffSend': 'Sent a system email',\n 'systemEmail.test': 'Sent a test system email',\n 'taxFilingConfig.clear': 'Cleared the tax filing settings',\n 'taxFilingConfig.update': 'Changed the tax filing settings',\n 'taxablePurchases.clear': 'Cleared taxable purchases',\n 'taxablePurchases.update': 'Changed taxable purchases',\n 'user.acquisition-viewed': 'Viewed where the account came from',\n 'user.erased': 'Erased the account',\n 'user.impersonate': 'Signed in as the account',\n 'user.nativeAppCheck': 'Verified the desktop app for the account',\n 'user.nativeAppSignIn': 'Signed in to the app through the console',\n 'user.sendPasswordReset': 'Sent a password reset',\n 'user.setAdAudienceOptOut': 'Changed the ad audience opt-out',\n 'user.setPassword': 'Set the password',\n 'user.signOutDevice': 'Signed a device out',\n 'user.updateProfile': 'Updated the profile',\n}\n\n/** Leading namespaces as a reader names them. */\nconst NAMESPACE_LABELS: Readonly<Record<string, string>> = {\n org: 'Organization',\n orgs: 'Organizations',\n user: 'Account',\n host: 'Site',\n}\n\n/** `paymentMethod` → `payment method`, `reattach-domain` → `reattach domain`. */\nfunction words(segment: string): string {\n return segment\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[-_]+/g, ' ')\n .toLowerCase()\n .trim()\n}\n\n/** A code nobody named, as words: `billing.invoice.paid` → `Billing: invoice paid`. */\nexport function humanizeActivityCode(code: string): string {\n const [head = '', ...rest] = code.trim().split('.').filter(Boolean)\n const lead = NAMESPACE_LABELS[head] ?? words(head).replace(/^./, (c) => c.toUpperCase())\n if (!rest.length) return lead\n return `${lead}: ${rest.map(words).join(' ')}`\n}\n\n/** What a staff audit code reads as, everywhere it is shown. */\nexport function staffAuditActionLabel(action: string | null | undefined): string {\n const code = action?.trim() ?? ''\n if (!code) return '—'\n return (\n STAFF_AUDIT_ACTION_LABELS[code] ??\n pluginStaffAuditActionLabel(code) ??\n (isActivityCode(code) ? humanizeActivityCode(code) : code)\n )\n}\n\n/** The collections an audit path walks, named for a reader. */\nconst COLLECTION_NOUNS: Readonly<Record<string, string>> = {\n orgs: 'Organization',\n hosts: 'Site',\n users: 'Account',\n members: 'Member',\n invites: 'Invitation',\n screens: 'Page',\n layouts: 'Layout',\n components: 'Component',\n templates: 'Template',\n media: 'Media',\n emailDeliveries: 'Email',\n coupons: 'Coupon',\n flags: 'Feature flag',\n plugins: 'Plugin',\n subscriptions: 'Subscription',\n}\n\n/** `orgs/a/aiJobs/b` → `{ orgs: 'a', aiJobs: 'b' }`, in walk order. */\nfunction pathPairs(path: string): Array<[string, string]> {\n const segments = path.split('/').filter(Boolean)\n const pairs: Array<[string, string]> = []\n for (let at = 0; at < segments.length; at += 2) {\n pairs.push([segments[at] ?? '', segments[at + 1] ?? ''])\n }\n return pairs\n}\n\n/** The stored audit row, read defensively. */\nexport interface StaffAuditEntryLike {\n action?: string | null\n target?: string | null\n subjectUid?: string | null\n reason?: string | null\n note?: string | null\n /** The state the act left; AI rows carry `{ label, hostId, credits }`. */\n after?: Record<string, unknown> | null\n}\n\nconst str = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() ? value.trim() : null\nconst num = (value: unknown): number | null =>\n typeof value === 'number' && Number.isFinite(value) ? value : null\n\n/** What an audit act did, in words, and the words it was about. */\nexport function describeStaffAudit(\n entry: StaffAuditEntryLike,\n names: ActivityNames = {},\n): ActivityDescription {\n const code = str(entry.action)\n const path = str(entry.target)\n const after = entry.after ?? {}\n const pairs = path && path.includes('/') ? pathPairs(path) : []\n const idOf = (collection: string) => pairs.find(([name]) => name === collection)?.[1] || null\n const orgId = idOf('orgs')\n // A plugin's job collection (the AI plugin's jobs) names the job the row\n // links to; core knows it only through the plugin's declaration.\n const jobPair = pairs.find(([name]) => pluginStaffAuditCollection(name)?.job)\n const jobId = jobPair?.[1] || null\n const hostId = str(after['hostId']) ?? idOf('hosts')\n const uid = idOf('users') ?? str(entry.subjectUid)\n const label = str(after['label'])\n // A plugin may word the row from what the act left: the AI plugin names\n // what a job made (`Created page Home with Aglyn AI`).\n const declared = code ? pluginStaffAuditDescribe(code, after) : undefined\n const action = declared?.action ?? staffAuditActionLabel(code)\n\n const site = hostId ? (names.hosts?.[hostId] ?? null) : null\n const org = orgId ? (names.orgs?.[orgId] ?? null) : null\n const person = uid ? (names.users?.[uid] ?? null) : null\n const last = pairs[pairs.length - 1]\n const parts: string[] = []\n if (site) parts.push(site)\n else if (org) parts.push(org)\n if (jobPair) parts.push(label ?? pluginStaffAuditCollection(jobPair[0])?.noun ?? 'Job')\n else if (last && last[0] === 'users') parts.push(person ?? 'Account')\n else if (last && last[0] !== 'orgs' && last[0] !== 'hosts') {\n parts.push(\n COLLECTION_NOUNS[last[0]] ??\n pluginStaffAuditCollection(last[0])?.noun ??\n activityTypeLabel(last[0]),\n )\n }\n if (!parts.length) {\n if (last) parts.push(COLLECTION_NOUNS[last[0]] ?? pluginStaffAuditCollection(last[0])?.noun ?? 'Item')\n else if (path) parts.push(isActivityCode(path) || /^[\\w-]{16,}$/.test(path) ? 'Platform' : path)\n else parts.push('—')\n }\n\n const result = str(after['result']) ?? str(after['status']) ?? declared?.result ?? null\n\n return {\n action,\n target: parts.join(' · '),\n why: orgOverrideReasonSummary(entry.reason ?? null, entry.note ?? null) ?? str(entry.note),\n credits: num(after['credits']),\n result,\n code,\n path,\n orgId,\n hostId,\n jobId,\n uid,\n }\n}\n\n/** A stored activity row, read defensively, with where it was read from. */\nexport interface ActivityRowLike {\n action?: string | null\n target?: (ActivityTargetLike & { jobId?: string; credits?: number }) | null\n /** `host` or `org`: which log the row came from. */\n scopeType?: string\n scopeId?: string\n}\n\n/**\n * An activity row as the lists show it. Where is the site when the row came\n * from a site's log, else the organization.\n */\nexport function describeActivity(\n entry: ActivityRowLike,\n names: ActivityNames = {},\n): ActivityDescription {\n const stored = str(entry.action)\n const code = isActivityCode(stored) ? stored : null\n const target = entry.target ?? null\n const hostId = entry.scopeType === 'host' ? (entry.scopeId ?? null) : null\n const orgId = entry.scopeType === 'org' ? (entry.scopeId ?? null) : null\n const site = hostId ? (names.hosts?.[hostId] ?? null) : null\n const type = str(target?.type)\n const jobId = isPluginJobTargetType(type) ? str(target?.id) : str(target?.jobId)\n const noun = type ? (pluginActivityTargetLabel(type) ?? activityTypeLabel(type)) : null\n const item = str(target?.name) ?? noun\n const parts = [site, item].filter((part): part is string => Boolean(part))\n return {\n action: activityActionSentence(stored ?? undefined, target) || '—',\n target: parts.join(' · ') || '—',\n why: null,\n credits: num(target?.credits),\n result: null,\n code,\n path: type ? `${type}${target?.id ? `/${target.id}` : ''}` : null,\n orgId,\n hostId,\n jobId,\n uid: type === 'member' ? str(target?.id) : null,\n }\n}\n"],"names":["activityActionLabel","activityPrimaryText","activityTypeLabel","orgOverrideReasonSummary","isPluginJobTargetType","pluginActivityActionSentence","pluginActivityTargetLabel","pluginStaffAuditActionLabel","pluginStaffAuditCollection","pluginStaffAuditDescribe","activityTargetPhrase","target","noun","type","lower","charAt","toLowerCase","slice","name","trim","activityActionSentence","action","stored","sentence","replace","activityRowText","entry","isActivityCode","test","STAFF_AUDIT_ACTION_LABELS","NAMESPACE_LABELS","org","orgs","user","host","words","segment","humanizeActivityCode","code","head","rest","split","filter","Boolean","lead","c","toUpperCase","length","map","join","staffAuditActionLabel","COLLECTION_NOUNS","hosts","users","members","invites","screens","layouts","components","templates","media","emailDeliveries","coupons","flags","plugins","subscriptions","pathPairs","path","segments","pairs","at","push","str","value","num","Number","isFinite","describeStaffAudit","names","idOf","label","after","includes","collection","find","orgId","jobPair","job","jobId","hostId","uid","subjectUid","declared","undefined","site","person","last","parts","result","why","reason","note","credits","describeActivity","scopeType","scopeId","id","item","part"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;CAiBC,GAED,SACEA,mBAAmB,EACnBC,mBAAmB,EACnBC,iBAAiB,QAGZ,0BAAsB;AAC7B,SAASC,wBAAwB,QAAQ,2BAAuB;AAChE,SACEC,qBAAqB,EACrBC,4BAA4B,EAC5BC,yBAAyB,EACzBC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,wBAAwB,QACnB,+CAA2C;AAsClD,uEAAuE,GACvE,OAAO,SAASC,qBAAqBC,MAA6C;QAGnEA;IAFb,MAAMC,OAAOV,kBAAkBS,0BAAAA,OAAQE,IAAI;IAC3C,MAAMC,QAAQF,SAAS,SAAS,SAASA,KAAKG,MAAM,CAAC,GAAGC,WAAW,KAAKJ,KAAKK,KAAK,CAAC;IACnF,MAAMC,OAAOP,2BAAAA,eAAAA,OAAQO,IAAI,qBAAZP,aAAcQ,IAAI;IAC/B,OAAOD,OAAO,GAAGJ,MAAM,CAAC,EAAEI,MAAM,GAAGJ;AACrC;AAEA;;;;CAIC,GACD,OAAO,SAASM,uBACdC,MAA0B,EAC1BV,MAAkC;;IAElC,MAAMW,iBAASD,0BAAAA,OAAQF,IAAI,qBAAM;IACjC,MAAMI,WAAWlB,6BAA6BiB;IAC9C,IAAIC,UAAU,OAAOA,SAASC,O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,OAAO,YAAb/E,iBAAiB,OAAQ;IACtE,MAAM2D,QAAQ3D,MAAM8E,SAAS,KAAK,SAAS9E,kBAAAA,MAAM+E,OAAO,YAAb/E,kBAAiB,OAAQ;IACpE,MAAMoE,OAAOL,kBAAUX,eAAAA,MAAM1B,KAAK,qBAAX0B,YAAa,CAACW,OAAO,mBAAI,OAAQ;IACxD,MAAM5E,OAAO2D,IAAI7D,0BAAAA,OAAQE,IAAI;IAC7B,MAAM2E,QAAQpF,sBAAsBS,QAAQ2D,IAAI7D,0BAAAA,OAAQ+F,EAAE,IAAIlC,IAAI7D,0BAAAA,OAAQ6E,KAAK;IAC/E,MAAM5E,OAAOC,QAAQP,6BAAAA,0BAA0BO,iBAA1BP,6BAAmCJ,kBAAkBW,QAAS;IACnF,MAAM8F,QAAOnC,OAAAA,IAAI7D,0BAAAA,OAAQO,IAAI,aAAhBsD,OAAqB5D;IAClC,MAAMqF,QAAQ;QAACH;QAAMa;KAAK,CAACjE,MAAM,CAAC,CAACkE,OAAyBjE,QAAQiE;IACpE,OAAO;QACLvF,QAAQD,uBAAuBE,iBAAAA,SAAUuE,WAAWlF,WAAW;QAC/DA,QAAQsF,MAAMhD,IAAI,CAAC,UAAU;QAC7BkD,KAAK;QACLG,SAAS5B,IAAI/D,0BAAAA,OAAQ2F,OAAO;QAC5BJ,QAAQ;QACR5D;QACA6B,MAAMtD,OAAO,GAAGA,OAAOF,CAAAA,0BAAAA,OAAQ+F,EAAE,IAAG,CAAC,CAAC,EAAE/F,OAAO+F,EAAE,EAAE,GAAG,IAAI,GAAG;QAC7DrB;QACAI;QACAD;QACAE,KAAK7E,SAAS,WAAW2D,IAAI7D,0BAAAA,OAAQ+F,EAAE,IAAI;IAC7C;AACF"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/activity-labels.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * ONE LABEL MAP FOR EVERY ACTIVITY AND AUDIT LIST (AGL-3660).\n *\n * Two logs feed the console's lists. The activity logs\n * (`orgs/{id}/activity`, `hosts/{id}/activity`) store a prose sentence or a\n * plugin's code plus a `{ type, id, name }` target. The staff audit trail\n * (`adminAudit`) stores a dotted code (`ai.job.output`, `org.override`) and\n * a Firestore PATH as its target (`orgs/abc/aiJobs/xyz`). The staff tables\n * printed both raw, so a reader saw `ai.job.output` next to\n * `orgs/9fK…/aiJobs/Qe2…` and had to know the schema to read their own\n * audit trail.\n *\n * Every list now draws its words from here: an action as a sentence\n * (`Created page Home with Aglyn AI`), a target as the site and the item,\n * and — for an audit row — why, the credits it spent and what came of it.\n * The raw code and path are kept on the description, for a tooltip and for\n * the staff details dialog, and never as the visible text.\n */\n\nimport {\n activityActionLabel,\n activityPrimaryText,\n activityTypeLabel,\n type ActivityEntryLike,\n type ActivityTargetLike,\n} from './activity-presenter'\nimport { orgOverrideReasonSummary } from './org-override-reason'\nimport {\n isPluginJobTargetType,\n pluginActivityActionSentence,\n pluginActivityTargetLabel,\n pluginStaffAuditActionLabel,\n pluginStaffAuditCollection,\n pluginStaffAuditDescribe,\n} from '../plugin-manager/plugin-activity-actions'\n\n/** What a list row and the details dialog show for one entry. */\nexport interface ActivityDescription {\n /** The act, as a sentence. Never a code. */\n action: string\n /** What it was done to, in words: the site and the item. Never a path. */\n target: string\n /** Why it was done, when the writer recorded a reason. */\n why: string | null\n /** AI credits it spent, when it spent any. */\n credits: number | null\n /** What came of it, when the writer recorded an outcome. */\n result: string | null\n /** The stored code, when the action was one — for a tooltip and staff. */\n code: string | null\n /** The stored target path (audit) or `type/id` (activity) — staff only. */\n path: string | null\n /** The organization the entry concerns, when it names one. */\n orgId: string | null\n /** The site the entry concerns, when it names one. */\n hostId: string | null\n /** The plugin job behind the entry (an AI job), when there is one. */\n jobId: string | null\n /** The account the entry concerns, when it names one. */\n uid: string | null\n}\n\n/** Names a route resolved for the ids an entry carries. */\nexport interface ActivityNames {\n /** Organization name by org id. */\n orgs?: Readonly<Record<string, string | null | undefined>>\n /** Site name by host id. */\n hosts?: Readonly<Record<string, string | null | undefined>>\n /** An account's address (or name) by uid. */\n users?: Readonly<Record<string, string | null | undefined>>\n}\n\n/** `screen` → `page`, `Home` → `page Home`: the noun a sentence uses. */\nexport function activityTargetPhrase(target: ActivityTargetLike | null | undefined): string {\n const noun = activityTypeLabel(target?.type)\n const lower = noun === 'Item' ? 'item' : noun.charAt(0).toLowerCase() + noun.slice(1)\n const name = target?.name?.trim()\n return name ? `${lower} ${name}` : lower\n}\n\n/**\n * An activity row's action as a sentence about its target. A plugin code\n * with a declared sentence fills it (`Created {target} with Aglyn AI`); any\n * other code reads as its label, and a prose action as itself.\n */\nexport function activityActionSentence(\n action: string | undefined,\n target?: ActivityTargetLike | null,\n): string {\n const stored = action?.trim() ?? ''\n const sentence = pluginActivityActionSentence(stored)\n if (sentence) return sentence.replace('{target}', activityTargetPhrase(target))\n return activityActionLabel(stored)\n}\n\n/**\n * A one-column feed's line: the sentence when the code declares one, else\n * the action with its target's name (`Saved the screen — Home`).\n */\nexport function activityRowText(entry: ActivityEntryLike): string {\n const stored = entry.action?.trim() ?? ''\n return pluginActivityActionSentence(stored)\n ? activityActionSentence(stored, entry.target)\n : activityPrimaryText(entry)\n}\n\n/** Whether a stored action is a dotted code rather than a sentence. */\nexport function isActivityCode(action: unknown): action is string {\n return typeof action === 'string' && /^[a-z][\\w-]*(\\.[\\w-]+)+$/i.test(action.trim())\n}\n\n/*==========================================\n * THE STAFF AUDIT TRAIL'S WORDS.\n *\n * Every code core's doors write. A plugin's doors declare their own through\n * `staffAuditLabels` (the AI plugin's `ai.job.*`), and a code neither knows\n * is humanized from its segments rather than shown raw, so a new writer\n * reads as `Billing: invoice paid` until somebody names it properly.\n *==========================================*/\nexport const STAFF_AUDIT_ACTION_LABELS: Readonly<Record<string, string>> = {\n 'account.closed.self': 'Closed their own account',\n 'account.exported.self': 'Exported their own account data',\n 'ai-usage.exported': 'Exported AI usage',\n 'billing.assistOverage.setCap': 'Set the AI overage ceiling',\n 'billing.assistOverage.setHardCap': 'Set the AI stop-at-band switch',\n 'billing.autoLocked': 'Locked automatically for billing',\n 'billing.bundle-link-minted': 'Made a bundle checkout link',\n 'billing.collaboratorAllocation': 'Changed collaborator seats',\n 'billing.dispute.opened': 'Payment dispute opened',\n 'billing.disputeClosed': 'Payment dispute closed',\n 'billing.disputeOpened': 'Payment dispute opened',\n 'billing.disputeUnattributed': 'Unattributed payment dispute',\n 'billing.invoice': 'Invoice event',\n 'billing.invoice.closed': 'Invoice closed',\n 'billing.invoice.failed': 'Invoice payment failed',\n 'billing.invoice.paid': 'Invoice paid',\n 'billing.manage': 'Opened billing management',\n 'billing.orphanedSubscription': 'Found a subscription with no workspace',\n 'billing.paymentFailed': 'Payment failed',\n 'billing.paymentMethod.changed': 'Changed the payment method',\n 'billing.platformDisputeLost': 'Lost a payment dispute',\n 'billing.platformInvoiceUncollectible': 'Invoice marked uncollectible',\n 'billing.registerAllocation': 'Changed register allocation',\n 'billing.storageOverage.setCap': 'Set the storage overage ceiling',\n 'billing.subscriptionCanceled': 'Subscription canceled',\n 'billing.usage': 'Recorded usage',\n 'billing.usageBudget.set': 'Set the usage budget',\n 'billing.view': 'Viewed billing',\n 'billing.webhookInert': 'Ignored a billing webhook',\n 'billing.webhookSignatureRejected': 'Rejected a billing webhook signature',\n 'broadcast.send': 'Sent a broadcast',\n 'client-build.preview-sent': 'Sent a client build preview',\n 'contact.phone.erased': 'Erased a phone number',\n 'contact.suppression.recorded': 'Added a contact suppression',\n 'contact.suppression.released': 'Released a contact suppression',\n 'coupon.create': 'Created a coupon',\n 'coupon.promotion_code.update': 'Updated a promotion code',\n 'data.transfer.export': 'Exported data',\n 'data.transfer.plan': 'Planned a data transfer',\n 'email.history-imported': 'Imported email history',\n 'email.message-viewed': 'Viewed an email message',\n 'email.sending-domains.reap': 'Removed unused sending domains',\n 'email.suppression.release': 'Released an email suppression',\n 'emailSendRate.update': 'Changed the email send rate',\n 'erasure.runBatch': 'Ran an erasure batch',\n 'erasures.replayed': 'Replayed erasures',\n 'firestore.export': 'Exported the database',\n 'firstPartyHosts.update': 'Changed first-party sites',\n 'flags.update': 'Changed feature flags',\n 'freeWorkspaceCap.update': 'Changed the free workspace cap',\n 'host.deleted': 'Deleted a site',\n 'host.domain.released': 'Released a domain',\n 'host.reattach-domain': 'Reattached a domain',\n 'host.set-subdomain': 'Changed a site address',\n 'host.transfer': 'Transferred a site',\n 'host.usageLevel': 'Set the site usage level',\n 'lockdown.lock': 'Locked the workspace down',\n 'lockdown.payouts-pause': 'Paused payouts',\n 'lockdown.payouts-restore': 'Restored payouts',\n 'lockdown.renewals-pause': 'Paused renewals',\n 'lockdown.renewals-resume': 'Resumed renewals',\n 'lockdown.resend-notice': 'Resent the lockdown notice',\n 'maintenance.auditArchive.run': 'Archived the audit log',\n 'maintenance.reapArtifacts.run': 'Removed stale build artifacts',\n 'maintenance.reverifyPlugins.run': 'Re-verified plugins',\n 'operatorAlerts.test': 'Sent a test operator alert',\n 'operatorAlerts.update': 'Changed operator alerts',\n 'org.acquisition-viewed': 'Viewed where the organization came from',\n 'org.auditLog': 'Viewed the organization audit log',\n 'org.discount.apply': 'Applied a discount',\n 'org.discount.remove': 'Removed a discount',\n 'org.enterprise.provision': 'Provisioned enterprise billing',\n 'org.erase-failed': 'Organization erasure failed',\n 'org.erased': 'Erased the organization',\n 'org.erasureCanceled': 'Canceled the organization erasure',\n 'org.erasureRequested': 'Requested organization erasure',\n 'org.exported': 'Exported the organization',\n 'org.name': 'Renamed the organization',\n 'org.note': 'Added a staff note',\n 'org.override': 'Overrode the plan',\n 'org.refund': 'Issued a refund',\n 'org.seatAddons.changed': 'Changed seat add-ons',\n 'org.sso.enforceSignInMethods': 'Changed enforced sign-in methods',\n 'org.sso.jit': 'Changed single sign-on provisioning',\n 'org.subscription-cancel': 'Canceled the subscription',\n 'org.subscriptionStarted.settle': 'Settled a new subscription',\n 'org.successManagerCleared': 'Removed the success manager',\n 'org.successManagerSet': 'Assigned a success manager',\n 'org.upgradeProposal.propose': 'Proposed an upgrade',\n 'org.upgradeProposal.withdraw': 'Withdrew an upgrade proposal',\n 'org.usageLevel': 'Set the workspace usage level',\n 'orgs.unverified.reap': 'Removed unverified organizations',\n 'person.erased': 'Erased a person',\n 'person.erasure-requested': 'Requested erasure of a person',\n 'plan.name': 'Renamed a plan',\n 'plugins.artifacts.reap': 'Removed stale plugin builds',\n 'plugins.remoteServer.load': 'Loaded a remote plugin server',\n 'plugins.verification.decline': 'Declined a plugin verification',\n 'plugins.verifier.regression': 'Plugin verifier regression',\n 'security.pageSecurityHold': 'Put a page on security hold',\n 'security.paymentFraudHold': 'Put a workspace on hold for payment fraud',\n 'security.staffGranted': 'Granted staff access',\n 'site.package.apply': 'Applied a site package',\n 'site.package.undo': 'Undid a site package',\n 'sso.domain.driftDetected': 'Single sign-on domain drift detected',\n 'staff.evidence': 'Recorded evidence',\n 'staff.paymentFailed': 'Payment failed (staff notice)',\n 'staff.planChanged': 'Plan changed (staff notice)',\n 'staff.subscriptionCanceled': 'Subscription canceled (staff notice)',\n 'staff.subscriptionStarted': 'Subscription started (staff notice)',\n 'systemEmail.staffSend': 'Sent a system email',\n 'systemEmail.test': 'Sent a test system email',\n 'taxFilingConfig.clear': 'Cleared the tax filing settings',\n 'taxFilingConfig.update': 'Changed the tax filing settings',\n 'taxablePurchases.clear': 'Cleared taxable purchases',\n 'taxablePurchases.update': 'Changed taxable purchases',\n 'user.acquisition-viewed': 'Viewed where the account came from',\n 'user.erased': 'Erased the account',\n 'user.impersonate': 'Signed in as the account',\n 'user.nativeAppCheck': 'Verified the desktop app for the account',\n 'user.nativeAppSignIn': 'Signed in to the app through the console',\n 'user.sendPasswordReset': 'Sent a password reset',\n 'user.setAdAudienceOptOut': 'Changed the ad audience opt-out',\n 'user.setPassword': 'Set the password',\n 'user.signOutDevice': 'Signed a device out',\n 'user.updateProfile': 'Updated the profile',\n 'user.usageLevel': 'Set the account usage level',\n}\n\n/** Leading namespaces as a reader names them. */\nconst NAMESPACE_LABELS: Readonly<Record<string, string>> = {\n org: 'Organization',\n orgs: 'Organizations',\n user: 'Account',\n host: 'Site',\n}\n\n/** `paymentMethod` → `payment method`, `reattach-domain` → `reattach domain`. */\nfunction words(segment: string): string {\n return segment\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/[-_]+/g, ' ')\n .toLowerCase()\n .trim()\n}\n\n/** A code nobody named, as words: `billing.invoice.paid` → `Billing: invoice paid`. */\nexport function humanizeActivityCode(code: string): string {\n const [head = '', ...rest] = code.trim().split('.').filter(Boolean)\n const lead = NAMESPACE_LABELS[head] ?? words(head).replace(/^./, (c) => c.toUpperCase())\n if (!rest.length) return lead\n return `${lead}: ${rest.map(words).join(' ')}`\n}\n\n/** What a staff audit code reads as, everywhere it is shown. */\nexport function staffAuditActionLabel(action: string | null | undefined): string {\n const code = action?.trim() ?? ''\n if (!code) return '—'\n return (\n STAFF_AUDIT_ACTION_LABELS[code] ??\n pluginStaffAuditActionLabel(code) ??\n (isActivityCode(code) ? humanizeActivityCode(code) : code)\n )\n}\n\n/** The collections an audit path walks, named for a reader. */\nconst COLLECTION_NOUNS: Readonly<Record<string, string>> = {\n orgs: 'Organization',\n hosts: 'Site',\n users: 'Account',\n members: 'Member',\n invites: 'Invitation',\n screens: 'Page',\n layouts: 'Layout',\n components: 'Component',\n templates: 'Template',\n media: 'Media',\n emailDeliveries: 'Email',\n coupons: 'Coupon',\n flags: 'Feature flag',\n plugins: 'Plugin',\n subscriptions: 'Subscription',\n}\n\n/** `orgs/a/aiJobs/b` → `{ orgs: 'a', aiJobs: 'b' }`, in walk order. */\nfunction pathPairs(path: string): Array<[string, string]> {\n const segments = path.split('/').filter(Boolean)\n const pairs: Array<[string, string]> = []\n for (let at = 0; at < segments.length; at += 2) {\n pairs.push([segments[at] ?? '', segments[at + 1] ?? ''])\n }\n return pairs\n}\n\n/** The stored audit row, read defensively. */\nexport interface StaffAuditEntryLike {\n action?: string | null\n target?: string | null\n subjectUid?: string | null\n reason?: string | null\n note?: string | null\n /** The state the act left; AI rows carry `{ label, hostId, credits }`. */\n after?: Record<string, unknown> | null\n}\n\nconst str = (value: unknown): string | null =>\n typeof value === 'string' && value.trim() ? value.trim() : null\nconst num = (value: unknown): number | null =>\n typeof value === 'number' && Number.isFinite(value) ? value : null\n\n/** What an audit act did, in words, and the words it was about. */\nexport function describeStaffAudit(\n entry: StaffAuditEntryLike,\n names: ActivityNames = {},\n): ActivityDescription {\n const code = str(entry.action)\n const path = str(entry.target)\n const after = entry.after ?? {}\n const pairs = path && path.includes('/') ? pathPairs(path) : []\n const idOf = (collection: string) => pairs.find(([name]) => name === collection)?.[1] || null\n const orgId = idOf('orgs')\n // A plugin's job collection (the AI plugin's jobs) names the job the row\n // links to; core knows it only through the plugin's declaration.\n const jobPair = pairs.find(([name]) => pluginStaffAuditCollection(name)?.job)\n const jobId = jobPair?.[1] || null\n const hostId = str(after['hostId']) ?? idOf('hosts')\n const uid = idOf('users') ?? str(entry.subjectUid)\n const label = str(after['label'])\n // A plugin may word the row from what the act left: the AI plugin names\n // what a job made (`Created page Home with Aglyn AI`).\n const declared = code ? pluginStaffAuditDescribe(code, after) : undefined\n const action = declared?.action ?? staffAuditActionLabel(code)\n\n const site = hostId ? (names.hosts?.[hostId] ?? null) : null\n const org = orgId ? (names.orgs?.[orgId] ?? null) : null\n const person = uid ? (names.users?.[uid] ?? null) : null\n const last = pairs[pairs.length - 1]\n const parts: string[] = []\n if (site) parts.push(site)\n else if (org) parts.push(org)\n if (jobPair) parts.push(label ?? pluginStaffAuditCollection(jobPair[0])?.noun ?? 'Job')\n else if (last && last[0] === 'users') parts.push(person ?? 'Account')\n else if (last && last[0] !== 'orgs' && last[0] !== 'hosts') {\n parts.push(\n COLLECTION_NOUNS[last[0]] ??\n pluginStaffAuditCollection(last[0])?.noun ??\n activityTypeLabel(last[0]),\n )\n }\n if (!parts.length) {\n if (last) parts.push(COLLECTION_NOUNS[last[0]] ?? pluginStaffAuditCollection(last[0])?.noun ?? 'Item')\n else if (path) parts.push(isActivityCode(path) || /^[\\w-]{16,}$/.test(path) ? 'Platform' : path)\n else parts.push('—')\n }\n\n const result = str(after['result']) ?? str(after['status']) ?? declared?.result ?? null\n\n return {\n action,\n target: parts.join(' · '),\n why: orgOverrideReasonSummary(entry.reason ?? null, entry.note ?? null) ?? str(entry.note),\n credits: num(after['credits']),\n result,\n code,\n path,\n orgId,\n hostId,\n jobId,\n uid,\n }\n}\n\n/** A stored activity row, read defensively, with where it was read from. */\nexport interface ActivityRowLike {\n action?: string | null\n target?: (ActivityTargetLike & { jobId?: string; credits?: number }) | null\n /** `host` or `org`: which log the row came from. */\n scopeType?: string\n scopeId?: string\n}\n\n/**\n * An activity row as the lists show it. Where is the site when the row came\n * from a site's log, else the organization.\n */\nexport function describeActivity(\n entry: ActivityRowLike,\n names: ActivityNames = {},\n): ActivityDescription {\n const stored = str(entry.action)\n const code = isActivityCode(stored) ? stored : null\n const target = entry.target ?? null\n const hostId = entry.scopeType === 'host' ? (entry.scopeId ?? null) : null\n const orgId = entry.scopeType === 'org' ? (entry.scopeId ?? null) : null\n const site = hostId ? (names.hosts?.[hostId] ?? null) : null\n const type = str(target?.type)\n const jobId = isPluginJobTargetType(type) ? str(target?.id) : str(target?.jobId)\n const noun = type ? (pluginActivityTargetLabel(type) ?? activityTypeLabel(type)) : null\n const item = str(target?.name) ?? noun\n const parts = [site, item].filter((part): part is string => Boolean(part))\n return {\n action: activityActionSentence(stored ?? undefined, target) || '—',\n target: parts.join(' · ') || '—',\n why: null,\n credits: num(target?.credits),\n result: null,\n code,\n path: type ? `${type}${target?.id ? `/${target.id}` : ''}` : null,\n orgId,\n hostId,\n jobId,\n uid: type === 'member' ? str(target?.id) : null,\n }\n}\n"],"names":["activityActionLabel","activityPrimaryText","activityTypeLabel","orgOverrideReasonSummary","isPluginJobTargetType","pluginActivityActionSentence","pluginActivityTargetLabel","pluginStaffAuditActionLabel","pluginStaffAuditCollection","pluginStaffAuditDescribe","activityTargetPhrase","target","noun","type","lower","charAt","toLowerCase","slice","name","trim","activityActionSentence","action","stored","sentence","replace","activityRowText","entry","isActivityCode","test","STAFF_AUDIT_ACTION_LABELS","NAMESPACE_LABELS","org","orgs","user","host","words","segment","humanizeActivityCode","code","head","rest","split","filter","Boolean","lead","c","toUpperCase","length","map","join","staffAuditActionLabel","COLLECTION_NOUNS","hosts","users","members","invites","screens","layouts","components","templates","media","emailDeliveries","coupons","flags","plugins","subscriptions","pathPairs","path","segments","pairs","at","push","str","value","num","Number","isFinite","describeStaffAudit","names","idOf","label","after","includes","collection","find","orgId","jobPair","job","jobId","hostId","uid","subjectUid","declared","undefined","site","person","last","parts","result","why","reason","note","credits","describeActivity","scopeType","scopeId","id","item","part"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;CAiBC,GAED,SACEA,mBAAmB,EACnBC,mBAAmB,EACnBC,iBAAiB,QAGZ,0BAAsB;AAC7B,SAASC,wBAAwB,QAAQ,2BAAuB;AAChE,SACEC,qBAAqB,EACrBC,4BAA4B,EAC5BC,yBAAyB,EACzBC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,wBAAwB,QACnB,+CAA2C;AAsClD,uEAAuE,GACvE,OAAO,SAASC,qBAAqBC,MAA6C;QAGnEA;IAFb,MAAMC,OAAOV,kBAAkBS,0BAAAA,OAAQE,IAAI;IAC3C,MAAMC,QAAQF,SAAS,SAAS,SAASA,KAAKG,MAAM,CAAC,GAAGC,WAAW,KAAKJ,KAAKK,KAAK,C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GAAGA,OAAOF,CAAAA,0BAAAA,OAAQ+F,EAAE,IAAG,CAAC,CAAC,EAAE/F,OAAO+F,EAAE,EAAE,GAAG,IAAI,GAAG;QAC7DrB;QACAI;QACAD;QACAE,KAAK7E,SAAS,WAAW2D,IAAI7D,0BAAAA,OAAQ+F,EAAE,IAAI;IAC7C;AACF"}
@@ -47,6 +47,8 @@ export interface ActivityEntryLike {
47
47
  staffActorEmail?: string | null;
48
48
  /** The name of the API key that wrote the entry, when a key did (AGL-2632). */
49
49
  apiKeyName?: string | null;
50
+ /** The name of the connected app that wrote it, when one did (AGL-4225). */
51
+ connectedAppName?: string | null;
50
52
  }
51
53
  /**
52
54
  * Who a host activity entry is attributed to — the writer's half of the
@@ -63,6 +65,8 @@ export interface HostActivityActor {
63
65
  email?: string | null;
64
66
  /** The API key's name, for an entry an integration wrote. */
65
67
  apiKeyName?: string | null;
68
+ /** A connected app's own name, for an entry a connection wrote (AGL-4225). */
69
+ connectedAppName?: string | null;
66
70
  }
67
71
  /**
68
72
  * What the presenter needs to build a link. `host` is the `[host]` URL
@@ -108,6 +112,12 @@ export declare function activityEntryGroupId(entry: ActivityEntryLike): string |
108
112
  export declare function activityPrimaryText(entry: ActivityEntryLike): string;
109
113
  /** How an integration's key is named wherever an actor is: `API key Zapier`. */
110
114
  export declare function apiKeyActorLabel(name: string): string;
115
+ /**
116
+ * How a connected app is named wherever an actor is: `Connected app Cursor`
117
+ * (AGL-4225). Its name is the one the app registered under, so it is always
118
+ * shown behind this label and never on its own.
119
+ */
120
+ export declare function connectedAppActorLabel(name: string): string;
111
121
  /**
112
122
  * The "who" line for an entry — always someone a reader can narrow down.
113
123
  *
@@ -135,6 +145,7 @@ export interface RunTriggeredByLike {
135
145
  uid?: string;
136
146
  email?: string;
137
147
  apiKeyName?: string;
148
+ connectedAppName?: string;
138
149
  name?: string;
139
150
  }
140
151
  /**
@@ -94,6 +94,13 @@ import { ACTIVITY_TYPE_LABELS } from "./activity-type-labels.js";
94
94
  /** How an integration's key is named wherever an actor is: `API key Zapier`. */ export function apiKeyActorLabel(name) {
95
95
  return `API key ${name}`;
96
96
  }
97
+ /**
98
+ * How a connected app is named wherever an actor is: `Connected app Cursor`
99
+ * (AGL-4225). Its name is the one the app registered under, so it is always
100
+ * shown behind this label and never on its own.
101
+ */ export function connectedAppActorLabel(name) {
102
+ return `Connected app ${name}`;
103
+ }
97
104
  /**
98
105
  * The "who" line for an entry — always someone a reader can narrow down.
99
106
  *
@@ -113,6 +120,7 @@ import { ACTIVITY_TYPE_LABELS } from "./activity-type-labels.js";
113
120
  var _entry_target, _ref;
114
121
  var _entry_actorId;
115
122
  if (entry.actorEmail) return entry.actorEmail;
123
+ if (entry.connectedAppName) return connectedAppActorLabel(entry.connectedAppName);
116
124
  if (entry.apiKeyName) return apiKeyActorLabel(entry.apiKeyName);
117
125
  const actorId = (_entry_actorId = entry.actorId) == null ? void 0 : _entry_actorId.trim();
118
126
  if (actorId === 'api') return 'API key';
@@ -141,6 +149,7 @@ import { ACTIVITY_TYPE_LABELS } from "./activity-type-labels.js";
141
149
  case 'member':
142
150
  return by.email || (by.uid ? `Account ${by.uid}` : 'A member');
143
151
  case 'apiKey':
152
+ if (by.connectedAppName) return connectedAppActorLabel(by.connectedAppName);
144
153
  return by.apiKeyName ? apiKeyActorLabel(by.apiKeyName) : 'API key';
145
154
  case 'visitor':
146
155
  return by.email ? `Site visitor (${by.email})` : 'Site visitor';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/activity-presenter.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Activity-feed presenter (AGL-810). The `hosts/{id}/activity` and\n// `orgs/{id}/activity` logs store a free-text `action` plus a `{ type, id,\n// name }` target, written from ~40 scattered call sites. The three renderers\n// (host card, host table, org card) used to each format entries their own\n// way — one dropped the target entirely, one printed the raw Firestore doc\n// id when no name was recorded. This module is the single place that turns a\n// stored entry into something a human reads, and into a deep link to the\n// thing that changed. It is deliberately light (the string route table and\n// the record-route registry) so plugin libs and the console app can both\n// import it via `@aglyn/aglyn/app-utils/activity-presenter`.\n\nimport { Route, buildRoute } from './console-routes'\nimport {\n pluginRecordHref,\n pluginRecordListHref,\n type PluginRecordRouteContext,\n} from '../plugin-manager/plugin-record-routes'\nimport { PLATFORM_BRAND_NAME } from './platform-brand'\nimport { hostEventLabel } from './host-events'\nimport { duplicateActivityActionLabel } from './duplicate-resource'\nimport {\n pluginActivityActionLabel,\n pluginActivityGroupForAction,\n pluginActivityTargetLabel,\n pluginActivityTargetNoun,\n} from '../plugin-manager/plugin-activity-actions'\nimport { ACTIVITY_TYPE_LABELS } from './activity-type-labels'\n\n/** The stored `target` sub-object, read defensively (any field may be absent). */\nexport interface ActivityTargetLike {\n type?: string\n id?: string\n name?: string\n /** Present on screen saves so the deep link can hit the exact version. */\n versionId?: string\n}\n\n/** A stored activity document, read defensively. */\nexport interface ActivityEntryLike {\n action?: string\n target?: ActivityTargetLike | null\n // Some early org entries carried the type/target id at the top level rather\n // than nested under `target` — tolerate both so no entry renders blank.\n type?: string\n targetId?: string\n /**\n * The acting uid: a person's, the literal `'api'` for a key, a\n * `system:` id for a platform process, or null when no person acted.\n */\n actorId?: string | null\n /** The address the actor had when the entry was written; null for a key. */\n actorEmail?: string | null\n /**\n * The address `actorId` holds TODAY, looked up on read by a route with the\n * Admin SDK, for an entry that recorded a uid and no address.\n */\n actorEmailNow?: string | null\n /**\n * For a STAFF reader only: the staff member behind an entry the workspace\n * did not perform (a staff cancellation), resolved by the route.\n */\n staffActorEmail?: string | null\n /** The name of the API key that wrote the entry, when a key did (AGL-2632). */\n apiKeyName?: string | null\n}\n\n/**\n * Who a host activity entry is attributed to — the writer's half of the\n * contract whose reader is {@link activityActorLabel}.\n *\n * A person is their verified uid and the address they had at the time. An\n * integration is the literal uid `'api'`, no address, and the name the\n * organization gave its key — carried because a feed that says \"Someone\"\n * about every write a key made is an audit trail with a hole in it: three\n * Zapier zaps and a nightly import all read as the same nobody.\n */\nexport interface HostActivityActor {\n uid: string\n email?: string | null\n /** The API key's name, for an entry an integration wrote. */\n apiKeyName?: string | null\n}\n\n/**\n * What the presenter needs to build a link. `host` is the `[host]` URL\n * segment — the site SLUG the console routes by (AGL-622), NOT the host doc\n * id — so pass `useParams().host`, not the doc id. When it is present the\n * entry is treated as host-scoped, otherwise org-scoped — which\n * disambiguates `member`, the one type both logs use.\n */\nexport interface ActivityLinkContext {\n orgSlug?: string\n host?: string\n}\n\n/** Human, singular noun for a target type. Falls back to the raw type. */\nconst TYPE_LABELS = ACTIVITY_TYPE_LABELS\n\n/**\n * A plugin's record, where its owner publishes an address for the kind\n * (`plugin-record-routes`): its own page, or the list it lives on when the\n * entry named no id — a deleted record still has a list to land on.\n * `undefined` for a kind no plugin publishes here.\n */\nfunction pluginRecordActivityHref(\n type: string | undefined,\n id: string | undefined,\n context: PluginRecordRouteContext,\n): string | undefined {\n if (!type) return undefined\n return (id ? pluginRecordHref(type, context, id) : pluginRecordListHref(type, context)) ?? undefined\n}\n\n/**\n * Human noun for a target type, e.g. `'screen'` → `'Screen'`. A plugin's\n * own resource is stored as `pluginId:noun` (AGL-2978), and a reader sees\n * the noun: `acme-mail:mailbox` → `Mailbox`.\n */\nexport function activityTypeLabel(type: string | undefined): string {\n if (!type) return 'Item'\n const known = TYPE_LABELS[type] ?? pluginActivityTargetLabel(type)\n if (known) return known\n const noun = pluginActivityTargetNoun(type) ?? type\n return noun.charAt(0).toUpperCase() + noun.slice(1)\n}\n\n/**\n * A label for the target column/link. Prefers the recorded name; when none\n * was written (older entries, id-only saves) it degrades to the humanized\n * type — NEVER the raw doc id, which is meaningless to a reader.\n */\nexport function activityTargetLabel(\n target: ActivityTargetLike | null | undefined,\n): string {\n if (target?.name) return target.name\n return activityTypeLabel(target?.type)\n}\n\n/**\n * What the action column reads (AGL-2929). Most actions are the sentence\n * their writer stored; a plugin's rows store a code (`ai.job.output`) so\n * that three surfaces can recognize them without parsing prose, and the\n * code is translated here — once, from the plugin-declared catalog\n * (AGL-2940) — rather than shown to a reader as a dotted path.\n */\nexport function activityActionLabel(action: string | undefined): string {\n const stored = action?.trim() ?? ''\n return (\n pluginActivityActionLabel(stored) ??\n duplicateActivityActionLabel(stored) ??\n stored\n )\n}\n\n/**\n * The filter group an entry's code belongs to — the chip that keeps it —\n * or `undefined` for a prose action no plugin declared.\n */\nexport function activityEntryGroupId(entry: ActivityEntryLike): string | undefined {\n return pluginActivityGroupForAction(entry.action?.trim())?.id\n}\n\n/**\n * The primary line for a feed entry: the action, suffixed with the target\n * name when one is known, so \"Saved the screen\" becomes \"Saved the screen —\n * Home\". A missing action degrades to the target label rather than blank.\n */\nexport function activityPrimaryText(entry: ActivityEntryLike): string {\n const action = activityActionLabel(entry.action)\n const name = entry.target?.name?.trim()\n if (action && name) return `${action} — ${name}`\n if (action) return action\n return activityTargetLabel(entry.target)\n}\n\n/** How an integration's key is named wherever an actor is: `API key Zapier`. */\nexport function apiKeyActorLabel(name: string): string {\n return `API key ${name}`\n}\n\n/**\n * The \"who\" line for an entry — always someone a reader can narrow down.\n *\n * In order: the address recorded when the entry was written; the key that\n * wrote it, by name; the address the recorded uid holds now, when the writer\n * held a uid and no address (the billing webhook, before it carried the\n * address stamped at the console act); else the uid itself, for an account\n * that no longer resolves.\n *\n * An entry with no uid at all is not an anonymous one. Every writer that\n * leaves `actorId` null is a platform process, so the feed names it: a\n * workflow run by its workflow, anything else — the billing webhook,\n * inbound CRM mail, a background AI job, a staff cancellation — as the\n * platform; a staff reader is also told which staff member. Never \"Someone\", which read as a person nobody could identify\n * (AGL-3369).\n */\nexport function activityActorLabel(entry: ActivityEntryLike): string {\n if (entry.actorEmail) return entry.actorEmail\n if (entry.apiKeyName) return apiKeyActorLabel(entry.apiKeyName)\n const actorId = entry.actorId?.trim()\n if (actorId === 'api') return 'API key'\n if (actorId && !actorId.startsWith('system:')) {\n return entry.actorEmailNow || `Account ${actorId}`\n }\n const target = entry.target ?? undefined\n if ((target?.type ?? entry.type) === 'workflow') {\n const name = target?.name?.trim()\n return name ? `Workflow ${name}` : 'Workflow'\n }\n if (entry.staffActorEmail) {\n return `${PLATFORM_BRAND_NAME} staff (${entry.staffActorEmail})`\n }\n return PLATFORM_BRAND_NAME\n}\n\n/**\n * Who set a run off (AGL-3376), as a run row stores it: the actor the event's\n * door named, carried through the engine. `webhook` is an inbound webhook's\n * caller, named by the hook.\n */\nexport interface RunTriggeredByLike {\n kind?: string\n uid?: string\n email?: string\n apiKeyName?: string\n name?: string\n}\n\n/**\n * The run history's Who: whoever set the run off, never the automation\n * itself — every row in a run history is that automation, so naming it\n * again would answer nothing. A run written before its trigger was recorded\n * says so rather than guessing from the event's name.\n */\nexport function runTriggeredByLabel(entry: {\n triggeredBy?: RunTriggeredByLike | null\n}): string {\n const by = entry.triggeredBy\n switch (by?.kind) {\n case 'member':\n return by.email || (by.uid ? `Account ${by.uid}` : 'A member')\n case 'apiKey':\n return by.apiKeyName ? apiKeyActorLabel(by.apiKeyName) : 'API key'\n case 'visitor':\n return by.email ? `Site visitor (${by.email})` : 'Site visitor'\n case 'webhook':\n return by.name ? `Inbound webhook ${by.name}` : 'Inbound webhook'\n case 'platform':\n return PLATFORM_BRAND_NAME\n default:\n return 'Not recorded'\n }\n}\n\n/**\n * A deep link to the resource an entry points at, or `undefined` when it\n * cannot be built (missing context, or a type with nowhere sensible to go).\n * `buildRoute` emits `<orgSlug?>` placeholders for missing params, so every\n * branch guards its inputs and returns `undefined` rather than a dead link.\n */\nexport function activityHref(\n entry: ActivityEntryLike,\n ctx: ActivityLinkContext,\n): string | undefined {\n const { orgSlug, host } = ctx\n if (!orgSlug) return undefined\n const target = entry.target ?? undefined\n const type = target?.type ?? entry.type\n const id = target?.id ?? entry.targetId\n const versionId = target?.versionId\n\n // Host-scoped entries: every host route needs both orgSlug and host.\n if (host) {\n switch (type) {\n case 'host':\n return buildRoute(Route.HOST_DASHBOARD, { orgSlug, host })\n case 'screen':\n // The screen detail page is version-addressed; without a versionId\n // there is no \"current\" pointer to route through, so land on the list.\n return id && versionId\n ? buildRoute(Route.SCREEN_DETAILS, {\n orgSlug,\n host,\n screenId: id,\n versionId,\n })\n : buildRoute(Route.HOST_SCREENS, { orgSlug, host })\n case 'component':\n return id\n ? buildRoute(Route.COMPONENT_DETAILS, {\n orgSlug,\n host,\n componentId: id,\n })\n : buildRoute(Route.HOST_COMPONENTS, { orgSlug, host })\n case 'template':\n return id\n ? buildRoute(Route.TEMPLATE_DETAILS, {\n orgSlug,\n host,\n templateId: id,\n })\n : buildRoute(Route.HOST_TEMPLATES, { orgSlug, host })\n case 'layout':\n return id\n ? buildRoute(Route.LAYOUT_DETAILS, { orgSlug, host, layoutId: id })\n : buildRoute(Route.HOST_LAYOUTS, { orgSlug, host })\n case 'theme':\n return buildRoute(Route.HOST_SETUP_THEME, { orgSlug, host })\n case 'media':\n return buildRoute(Route.HOST_MEDIA, { orgSlug, host })\n case 'content':\n return buildRoute(Route.HOST_CONTENT, { orgSlug, host })\n case 'variable':\n return buildRoute(Route.HOST_DATA, { orgSlug, host })\n case 'function':\n return buildRoute(Route.HOST_LOGIC, { orgSlug, host })\n case 'workflow':\n return buildRoute(Route.HOST_AUTOMATION, { orgSlug, host })\n case 'member':\n // Site team is managed on the Setup page — there is no per-member\n // host route.\n return buildRoute(Route.HOST_SETUP, { orgSlug, host })\n default:\n // A plugin's record — a contact, a deal, an order — at the address\n // its owner publishes, which the route table does not hold.\n return pluginRecordActivityHref(type, id, { orgSlug, host })\n }\n }\n\n // Org-scoped entries.\n switch (type) {\n case 'org':\n return buildRoute(Route.ORG_SETTINGS, { orgSlug })\n case 'member':\n return id\n ? buildRoute(Route.MANAGE_TEAM_MEMBER, { orgSlug, uid: id })\n : buildRoute(Route.MANAGE_TEAM, { orgSlug })\n case 'invite':\n return buildRoute(Route.MANAGE_TEAM, { orgSlug })\n default:\n // A plugin's record acted on at the ORGANIZATION level (AGL-2634) — a\n // deal moved from the org board, a merge, a bulk bar's action — at the\n // organization address its owner publishes; a bulk line names no\n // record and lands on the list.\n return pluginRecordActivityHref(type, id, { orgSlug, host: null })\n }\n}\n\n/**\n * How an automation run ended (AGL-2171).\n *\n * `skipped` is a first-class outcome, not an absence. An unmet condition\n * used to be a bare `continue` that wrote nothing, so \"why didn't my\n * automation fire?\" — the most common support question about automations —\n * had no answer anywhere in the product, while `/product/workflows`\n * advertises an amber `Skipped` row that answers it.\n */\nexport type ActionRunResult = 'succeeded' | 'failed' | 'skipped'\n\n/** A stored run entry: an activity document with the run fields on it. */\nexport interface ActionRunEntryLike extends ActivityEntryLike {\n result?: string\n trigger?: string\n summary?: string\n}\n\n/**\n * `formSubmission` → `Form submitted`.\n *\n * The console rendered the raw camelCase identifier in the trigger select\n * and in every run row. The words are each event's declared label\n * (`host-events.ts`) — one map, so the picker an author chose from and the\n * run row they read afterwards cannot name the same event differently.\n */\nexport function actionTriggerLabel(event: string | undefined): string {\n return hostEventLabel(event)\n}\n\n/**\n * The run's outcome, tolerating rows written before it was recorded.\n *\n * A legacy entry carries only the prose `action` string, so it is read\n * back: `with errors:` means it failed and `Action ran on` means it\n * succeeded. Anything else is not a run at all — the activity collection\n * also holds publishes, media saves and member changes, and calling one of\n * those `succeeded` would put it in the run history under a verdict that\n * means nothing for it.\n */\nexport function actionRunResult(\n entry: ActionRunEntryLike,\n): ActionRunResult | undefined {\n const stored = String(entry.result ?? '').trim()\n if (stored === 'succeeded' || stored === 'failed' || stored === 'skipped') {\n return stored\n }\n const action = String(entry.action ?? '')\n if (!action.startsWith('Action ran on')) return undefined\n return action.includes('with errors:') ? 'failed' : 'succeeded'\n}\n\n/**\n * The `What happened` column: `Sent email · saved to Leads · webhook 200`.\n *\n * Falls back to the legacy prose, minus its `Action ran on <event>` prefix\n * — that fact is the Trigger column now, and repeating it in the summary\n * would make every historic row say the same thing twice.\n */\nexport function actionRunSummary(entry: ActionRunEntryLike): string {\n const summary = String(entry.summary ?? '').trim()\n if (summary) return summary\n const action = String(entry.action ?? '').trim()\n const errors = action.match(/with errors:\\s*(.+)$/)\n if (errors) return errors[1]\n // A pre-AGL-2171 success recorded nothing but the fact that it ran.\n if (action.startsWith('Action ran on')) return 'Ran'\n return action\n}\n"],"names":["Route","buildRoute","pluginRecordHref","pluginRecordListHref","PLATFORM_BRAND_NAME","hostEventLabel","duplicateActivityActionLabel","pluginActivityActionLabel","pluginActivityGroupForAction","pluginActivityTargetLabel","pluginActivityTargetNoun","ACTIVITY_TYPE_LABELS","TYPE_LABELS","pluginRecordActivityHref","type","id","context","undefined","activityTypeLabel","known","noun","charAt","toUpperCase","slice","activityTargetLabel","target","name","activityActionLabel","action","stored","trim","activityEntryGroupId","entry","activityPrimaryText","apiKeyActorLabel","activityActorLabel","actorEmail","apiKeyName","actorId","startsWith","actorEmailNow","staffActorEmail","runTriggeredByLabel","by","triggeredBy","kind","email","uid","activityHref","ctx","orgSlug","host","targetId","versionId","HOST_DASHBOARD","SCREEN_DETAILS","screenId","HOST_SCREENS","COMPONENT_DETAILS","componentId","HOST_COMPONENTS","TEMPLATE_DETAILS","templateId","HOST_TEMPLATES","LAYOUT_DETAILS","layoutId","HOST_LAYOUTS","HOST_SETUP_THEME","HOST_MEDIA","HOST_CONTENT","HOST_DATA","HOST_LOGIC","HOST_AUTOMATION","HOST_SETUP","ORG_SETTINGS","MANAGE_TEAM_MEMBER","MANAGE_TEAM","actionTriggerLabel","event","actionRunResult","String","result","includes","actionRunSummary","summary","errors","match"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,mEAAmE;AACnE,2EAA2E;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AAC,kBAAkB,OAAOtB;IAChD,OAAOW,OAAOsD,QAAQ,CAAC,kBAAkB,WAAW;AACtD;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,iBAAiBnD,KAAyB;QACjCA,gBAEDA;IAFtB,MAAMoD,UAAUJ,QAAOhD,iBAAAA,MAAMoD,OAAO,YAAbpD,iBAAiB,IAAIF,IAAI;IAChD,IAAIsD,SAAS,OAAOA;IACpB,MAAMxD,SAASoD,QAAOhD,gBAAAA,MAAMJ,MAAM,YAAZI,gBAAgB,IAAIF,IAAI;IAC9C,MAAMuD,SAASzD,OAAO0D,KAAK,CAAC;IAC5B,IAAID,QAAQ,OAAOA,MAAM,CAAC,EAAE;IAC5B,oEAAoE;IACpE,IAAIzD,OAAOW,UAAU,CAAC,kBAAkB,OAAO;IAC/C,OAAOX;AACT"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/activity-presenter.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Activity-feed presenter (AGL-810). The `hosts/{id}/activity` and\n// `orgs/{id}/activity` logs store a free-text `action` plus a `{ type, id,\n// name }` target, written from ~40 scattered call sites. The three renderers\n// (host card, host table, org card) used to each format entries their own\n// way — one dropped the target entirely, one printed the raw Firestore doc\n// id when no name was recorded. This module is the single place that turns a\n// stored entry into something a human reads, and into a deep link to the\n// thing that changed. It is deliberately light (the string route table and\n// the record-route registry) so plugin libs and the console app can both\n// import it via `@aglyn/aglyn/app-utils/activity-presenter`.\n\nimport { Route, buildRoute } from './console-routes'\nimport {\n pluginRecordHref,\n pluginRecordListHref,\n type PluginRecordRouteContext,\n} from '../plugin-manager/plugin-record-routes'\nimport { PLATFORM_BRAND_NAME } from './platform-brand'\nimport { hostEventLabel } from './host-events'\nimport { duplicateActivityActionLabel } from './duplicate-resource'\nimport {\n pluginActivityActionLabel,\n pluginActivityGroupForAction,\n pluginActivityTargetLabel,\n pluginActivityTargetNoun,\n} from '../plugin-manager/plugin-activity-actions'\nimport { ACTIVITY_TYPE_LABELS } from './activity-type-labels'\n\n/** The stored `target` sub-object, read defensively (any field may be absent). */\nexport interface ActivityTargetLike {\n type?: string\n id?: string\n name?: string\n /** Present on screen saves so the deep link can hit the exact version. */\n versionId?: string\n}\n\n/** A stored activity document, read defensively. */\nexport interface ActivityEntryLike {\n action?: string\n target?: ActivityTargetLike | null\n // Some early org entries carried the type/target id at the top level rather\n // than nested under `target` — tolerate both so no entry renders blank.\n type?: string\n targetId?: string\n /**\n * The acting uid: a person's, the literal `'api'` for a key, a\n * `system:` id for a platform process, or null when no person acted.\n */\n actorId?: string | null\n /** The address the actor had when the entry was written; null for a key. */\n actorEmail?: string | null\n /**\n * The address `actorId` holds TODAY, looked up on read by a route with the\n * Admin SDK, for an entry that recorded a uid and no address.\n */\n actorEmailNow?: string | null\n /**\n * For a STAFF reader only: the staff member behind an entry the workspace\n * did not perform (a staff cancellation), resolved by the route.\n */\n staffActorEmail?: string | null\n /** The name of the API key that wrote the entry, when a key did (AGL-2632). */\n apiKeyName?: string | null\n /** The name of the connected app that wrote it, when one did (AGL-4225). */\n connectedAppName?: string | null\n}\n\n/**\n * Who a host activity entry is attributed to — the writer's half of the\n * contract whose reader is {@link activityActorLabel}.\n *\n * A person is their verified uid and the address they had at the time. An\n * integration is the literal uid `'api'`, no address, and the name the\n * organization gave its key — carried because a feed that says \"Someone\"\n * about every write a key made is an audit trail with a hole in it: three\n * Zapier zaps and a nightly import all read as the same nobody.\n */\nexport interface HostActivityActor {\n uid: string\n email?: string | null\n /** The API key's name, for an entry an integration wrote. */\n apiKeyName?: string | null\n /** A connected app's own name, for an entry a connection wrote (AGL-4225). */\n connectedAppName?: string | null\n}\n\n/**\n * What the presenter needs to build a link. `host` is the `[host]` URL\n * segment — the site SLUG the console routes by (AGL-622), NOT the host doc\n * id — so pass `useParams().host`, not the doc id. When it is present the\n * entry is treated as host-scoped, otherwise org-scoped — which\n * disambiguates `member`, the one type both logs use.\n */\nexport interface ActivityLinkContext {\n orgSlug?: string\n host?: string\n}\n\n/** Human, singular noun for a target type. Falls back to the raw type. */\nconst TYPE_LABELS = ACTIVITY_TYPE_LABELS\n\n/**\n * A plugin's record, where its owner publishes an address for the kind\n * (`plugin-record-routes`): its own page, or the list it lives on when the\n * entry named no id — a deleted record still has a list to land on.\n * `undefined` for a kind no plugin publishes here.\n */\nfunction pluginRecordActivityHref(\n type: string | undefined,\n id: string | undefined,\n context: PluginRecordRouteContext,\n): string | undefined {\n if (!type) return undefined\n return (id ? pluginRecordHref(type, context, id) : pluginRecordListHref(type, context)) ?? undefined\n}\n\n/**\n * Human noun for a target type, e.g. `'screen'` → `'Screen'`. A plugin's\n * own resource is stored as `pluginId:noun` (AGL-2978), and a reader sees\n * the noun: `acme-mail:mailbox` → `Mailbox`.\n */\nexport function activityTypeLabel(type: string | undefined): string {\n if (!type) return 'Item'\n const known = TYPE_LABELS[type] ?? pluginActivityTargetLabel(type)\n if (known) return known\n const noun = pluginActivityTargetNoun(type) ?? type\n return noun.charAt(0).toUpperCase() + noun.slice(1)\n}\n\n/**\n * A label for the target column/link. Prefers the recorded name; when none\n * was written (older entries, id-only saves) it degrades to the humanized\n * type — NEVER the raw doc id, which is meaningless to a reader.\n */\nexport function activityTargetLabel(\n target: ActivityTargetLike | null | undefined,\n): string {\n if (target?.name) return target.name\n return activityTypeLabel(target?.type)\n}\n\n/**\n * What the action column reads (AGL-2929). Most actions are the sentence\n * their writer stored; a plugin's rows store a code (`ai.job.output`) so\n * that three surfaces can recognize them without parsing prose, and the\n * code is translated here — once, from the plugin-declared catalog\n * (AGL-2940) — rather than shown to a reader as a dotted path.\n */\nexport function activityActionLabel(action: string | undefined): string {\n const stored = action?.trim() ?? ''\n return (\n pluginActivityActionLabel(stored) ??\n duplicateActivityActionLabel(stored) ??\n stored\n )\n}\n\n/**\n * The filter group an entry's code belongs to — the chip that keeps it —\n * or `undefined` for a prose action no plugin declared.\n */\nexport function activityEntryGroupId(entry: ActivityEntryLike): string | undefined {\n return pluginActivityGroupForAction(entry.action?.trim())?.id\n}\n\n/**\n * The primary line for a feed entry: the action, suffixed with the target\n * name when one is known, so \"Saved the screen\" becomes \"Saved the screen —\n * Home\". A missing action degrades to the target label rather than blank.\n */\nexport function activityPrimaryText(entry: ActivityEntryLike): string {\n const action = activityActionLabel(entry.action)\n const name = entry.target?.name?.trim()\n if (action && name) return `${action} — ${name}`\n if (action) return action\n return activityTargetLabel(entry.target)\n}\n\n/** How an integration's key is named wherever an actor is: `API key Zapier`. */\nexport function apiKeyActorLabel(name: string): string {\n return `API key ${name}`\n}\n\n/**\n * How a connected app is named wherever an actor is: `Connected app Cursor`\n * (AGL-4225). Its name is the one the app registered under, so it is always\n * shown behind this label and never on its own.\n */\nexport function connectedAppActorLabel(name: string): string {\n return `Connected app ${name}`\n}\n\n/**\n * The \"who\" line for an entry — always someone a reader can narrow down.\n *\n * In order: the address recorded when the entry was written; the key that\n * wrote it, by name; the address the recorded uid holds now, when the writer\n * held a uid and no address (the billing webhook, before it carried the\n * address stamped at the console act); else the uid itself, for an account\n * that no longer resolves.\n *\n * An entry with no uid at all is not an anonymous one. Every writer that\n * leaves `actorId` null is a platform process, so the feed names it: a\n * workflow run by its workflow, anything else — the billing webhook,\n * inbound CRM mail, a background AI job, a staff cancellation — as the\n * platform; a staff reader is also told which staff member. Never \"Someone\", which read as a person nobody could identify\n * (AGL-3369).\n */\nexport function activityActorLabel(entry: ActivityEntryLike): string {\n if (entry.actorEmail) return entry.actorEmail\n if (entry.connectedAppName) return connectedAppActorLabel(entry.connectedAppName)\n if (entry.apiKeyName) return apiKeyActorLabel(entry.apiKeyName)\n const actorId = entry.actorId?.trim()\n if (actorId === 'api') return 'API key'\n if (actorId && !actorId.startsWith('system:')) {\n return entry.actorEmailNow || `Account ${actorId}`\n }\n const target = entry.target ?? undefined\n if ((target?.type ?? entry.type) === 'workflow') {\n const name = target?.name?.trim()\n return name ? `Workflow ${name}` : 'Workflow'\n }\n if (entry.staffActorEmail) {\n return `${PLATFORM_BRAND_NAME} staff (${entry.staffActorEmail})`\n }\n return PLATFORM_BRAND_NAME\n}\n\n/**\n * Who set a run off (AGL-3376), as a run row stores it: the actor the event's\n * door named, carried through the engine. `webhook` is an inbound webhook's\n * caller, named by the hook.\n */\nexport interface RunTriggeredByLike {\n kind?: string\n uid?: string\n email?: string\n apiKeyName?: string\n connectedAppName?: string\n name?: string\n}\n\n/**\n * The run history's Who: whoever set the run off, never the automation\n * itself — every row in a run history is that automation, so naming it\n * again would answer nothing. A run written before its trigger was recorded\n * says so rather than guessing from the event's name.\n */\nexport function runTriggeredByLabel(entry: {\n triggeredBy?: RunTriggeredByLike | null\n}): string {\n const by = entry.triggeredBy\n switch (by?.kind) {\n case 'member':\n return by.email || (by.uid ? `Account ${by.uid}` : 'A member')\n case 'apiKey':\n if (by.connectedAppName) return connectedAppActorLabel(by.connectedAppName)\n return by.apiKeyName ? apiKeyActorLabel(by.apiKeyName) : 'API key'\n case 'visitor':\n return by.email ? `Site visitor (${by.email})` : 'Site visitor'\n case 'webhook':\n return by.name ? `Inbound webhook ${by.name}` : 'Inbound webhook'\n case 'platform':\n return PLATFORM_BRAND_NAME\n default:\n return 'Not recorded'\n }\n}\n\n/**\n * A deep link to the resource an entry points at, or `undefined` when it\n * cannot be built (missing context, or a type with nowhere sensible to go).\n * `buildRoute` emits `<orgSlug?>` placeholders for missing params, so every\n * branch guards its inputs and returns `undefined` rather than a dead link.\n */\nexport function activityHref(\n entry: ActivityEntryLike,\n ctx: ActivityLinkContext,\n): string | undefined {\n const { orgSlug, host } = ctx\n if (!orgSlug) return undefined\n const target = entry.target ?? undefined\n const type = target?.type ?? entry.type\n const id = target?.id ?? entry.targetId\n const versionId = target?.versionId\n\n // Host-scoped entries: every host route needs both orgSlug and host.\n if (host) {\n switch (type) {\n case 'host':\n return buildRoute(Route.HOST_DASHBOARD, { orgSlug, host })\n case 'screen':\n // The screen detail page is version-addressed; without a versionId\n // there is no \"current\" pointer to route through, so land on the list.\n return id && versionId\n ? buildRoute(Route.SCREEN_DETAILS, {\n orgSlug,\n host,\n screenId: id,\n versionId,\n })\n : buildRoute(Route.HOST_SCREENS, { orgSlug, host })\n case 'component':\n return id\n ? buildRoute(Route.COMPONENT_DETAILS, {\n orgSlug,\n host,\n componentId: id,\n })\n : buildRoute(Route.HOST_COMPONENTS, { orgSlug, host })\n case 'template':\n return id\n ? buildRoute(Route.TEMPLATE_DETAILS, {\n orgSlug,\n host,\n templateId: id,\n })\n : buildRoute(Route.HOST_TEMPLATES, { orgSlug, host })\n case 'layout':\n return id\n ? buildRoute(Route.LAYOUT_DETAILS, { orgSlug, host, layoutId: id })\n : buildRoute(Route.HOST_LAYOUTS, { orgSlug, host })\n case 'theme':\n return buildRoute(Route.HOST_SETUP_THEME, { orgSlug, host })\n case 'media':\n return buildRoute(Route.HOST_MEDIA, { orgSlug, host })\n case 'content':\n return buildRoute(Route.HOST_CONTENT, { orgSlug, host })\n case 'variable':\n return buildRoute(Route.HOST_DATA, { orgSlug, host })\n case 'function':\n return buildRoute(Route.HOST_LOGIC, { orgSlug, host })\n case 'workflow':\n return buildRoute(Route.HOST_AUTOMATION, { orgSlug, host })\n case 'member':\n // Site team is managed on the Setup page — there is no per-member\n // host route.\n return buildRoute(Route.HOST_SETUP, { orgSlug, host })\n default:\n // A plugin's record — a contact, a deal, an order — at the address\n // its owner publishes, which the route table does not hold.\n return pluginRecordActivityHref(type, id, { orgSlug, host })\n }\n }\n\n // Org-scoped entries.\n switch (type) {\n case 'org':\n return buildRoute(Route.ORG_SETTINGS, { orgSlug })\n case 'member':\n return id\n ? buildRoute(Route.MANAGE_TEAM_MEMBER, { orgSlug, uid: id })\n : buildRoute(Route.MANAGE_TEAM, { orgSlug })\n case 'invite':\n return buildRoute(Route.MANAGE_TEAM, { orgSlug })\n default:\n // A plugin's record acted on at the ORGANIZATION level (AGL-2634) — a\n // deal moved from the org board, a merge, a bulk bar's action — at the\n // organization address its owner publishes; a bulk line names no\n // record and lands on the list.\n return pluginRecordActivityHref(type, id, { orgSlug, host: null })\n }\n}\n\n/**\n * How an automation run ended (AGL-2171).\n *\n * `skipped` is a first-class outcome, not an absence. An unmet condition\n * used to be a bare `continue` that wrote nothing, so \"why didn't my\n * automation fire?\" — the most common support question about automations —\n * had no answer anywhere in the product, while `/product/workflows`\n * advertises an amber `Skipped` row that answers it.\n */\nexport type ActionRunResult = 'succeeded' | 'failed' | 'skipped'\n\n/** A stored run entry: an activity document with the run fields on it. */\nexport interface ActionRunEntryLike extends ActivityEntryLike {\n result?: string\n trigger?: string\n summary?: string\n}\n\n/**\n * `formSubmission` → `Form submitted`.\n *\n * The console rendered the raw camelCase identifier in the trigger select\n * and in every run row. The words are each event's declared label\n * (`host-events.ts`) — one map, so the picker an author chose from and the\n * run row they read afterwards cannot name the same event differently.\n */\nexport function actionTriggerLabel(event: string | undefined): string {\n return hostEventLabel(event)\n}\n\n/**\n * The run's outcome, tolerating rows written before it was recorded.\n *\n * A legacy entry carries only the prose `action` string, so it is read\n * back: `with errors:` means it failed and `Action ran on` means it\n * succeeded. Anything else is not a run at all — the activity collection\n * also holds publishes, media saves and member changes, and calling one of\n * those `succeeded` would put it in the run history under a verdict that\n * means nothing for it.\n */\nexport function actionRunResult(\n entry: ActionRunEntryLike,\n): ActionRunResult | undefined {\n const stored = String(entry.result ?? '').trim()\n if (stored === 'succeeded' || stored === 'failed' || stored === 'skipped') {\n return stored\n }\n const action = String(entry.action ?? '')\n if (!action.startsWith('Action ran on')) return undefined\n return action.includes('with errors:') ? 'failed' : 'succeeded'\n}\n\n/**\n * The `What happened` column: `Sent email · saved to Leads · webhook 200`.\n *\n * Falls back to the legacy prose, minus its `Action ran on <event>` prefix\n * — that fact is the Trigger column now, and repeating it in the summary\n * would make every historic row say the same thing twice.\n */\nexport function actionRunSummary(entry: ActionRunEntryLike): string {\n const summary = String(entry.summary ?? '').trim()\n if (summary) return summary\n const action = String(entry.action ?? '').trim()\n const errors = action.match(/with errors:\\s*(.+)$/)\n if (errors) return errors[1]\n // A pre-AGL-2171 success recorded nothing but the fact that it ran.\n if (action.startsWith('Action ran on')) return 'Ran'\n return action\n}\n"],"names":["Route","buildRoute","pluginRecordHref","pluginRecordListHref","PLATFORM_BRAND_NAME","hostEventLabel","duplicateActivityActionLabel","pluginActivityActionLabel","pluginActivityGroupForAction","pluginActivityTargetLabel","pluginActivityTargetNoun","ACTIVITY_TYPE_LABELS","TYPE_LABELS","pluginRecordActivityHref","type","id","context","undefined","activityTypeLabel","known","noun","charAt","toUpperCase","slice","activityTargetLabel","target","name","activityActionLabel","action","stored","trim","activityEntryGroupId","entry","activityPrimaryText","apiKeyActorLabel","connectedAppActorLabel","activityActorLabel","actorEmail","connectedAppName","apiKeyName","actorId","startsWith","actorEmailNow","staffActorEmail","runTriggeredByLabel","by","triggeredBy","kind","email","uid","activityHref","ctx","orgSlug","host","targetId","versionId","HOST_DASHBOARD","SCREEN_DETAILS","screenId","HOST_SCREENS","COMPONENT_DETAILS","componentId","HOST_COMPONENTS","TEMPLATE_DETAILS","templateId","HOST_TEMPLATES","LAYOUT_DETAILS","layoutId","HOST_LAYOUTS","HOST_SETUP_THEME","HOST_MEDIA","HOST_CONTENT","HOST_DATA","HOST_LOGIC","HOST_AUTOMATION","HOST_SETUP","ORG_SETTINGS","MANAGE_TEAM_MEMBER","MANAGE_TEAM","actionTriggerLabel","event","actionRunResult","String","result","includes","actionRunSummary","summary","errors","match"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,mEAAmE;AACnE,2EAA2E;AAC3E,6EAA6E;AAC7E,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AAM,YAAZnD,gBAAgB,IAAIF,IAAI;IAC9C,IAAID,WAAW,eAAeA,WAAW,YAAYA,WAAW,WAAW;QACzE,OAAOA;IACT;IACA,MAAMD,SAASsD,QAAOlD,gBAAAA,MAAMJ,MAAM,YAAZI,gBAAgB;IACtC,IAAI,CAACJ,OAAOa,UAAU,CAAC,kBAAkB,OAAOxB;IAChD,OAAOW,OAAOwD,QAAQ,CAAC,kBAAkB,WAAW;AACtD;AAEA;;;;;;CAMC,GACD,OAAO,SAASC,iBAAiBrD,KAAyB;QACjCA,gBAEDA;IAFtB,MAAMsD,UAAUJ,QAAOlD,iBAAAA,MAAMsD,OAAO,YAAbtD,iBAAiB,IAAIF,IAAI;IAChD,IAAIwD,SAAS,OAAOA;IACpB,MAAM1D,SAASsD,QAAOlD,gBAAAA,MAAMJ,MAAM,YAAZI,gBAAgB,IAAIF,IAAI;IAC9C,MAAMyD,SAAS3D,OAAO4D,KAAK,CAAC;IAC5B,IAAID,QAAQ,OAAOA,MAAM,CAAC,EAAE;IAC5B,oEAAoE;IACpE,IAAI3D,OAAOa,UAAU,CAAC,kBAAkB,OAAO;IAC/C,OAAOb;AACT"}
@@ -20,6 +20,7 @@ export declare const ACTIVITY_SEARCH_TOKENS_PATH = "searchTokens";
20
20
  export interface ActivitySearchSource {
21
21
  actorEmail?: unknown;
22
22
  apiKeyName?: unknown;
23
+ connectedAppName?: unknown;
23
24
  /** The entry's target as stored — only its `name` is read. */
24
25
  target?: {
25
26
  name?: unknown;
@@ -77,6 +77,7 @@ const text = (value)=>typeof value === 'string' ? value.trim() : '';
77
77
  const words = [
78
78
  ...addressSearchWords(entry.actorEmail),
79
79
  text(entry.apiKeyName),
80
+ text(entry.connectedAppName),
80
81
  text((_entry_target = entry.target) == null ? void 0 : _entry_target.name)
81
82
  ].filter(Boolean);
82
83
  return nameSearchTokens(words.join(' '));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/activity-search.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { nameSearchTokens } from './name-search'\n\n/*\n * WHAT AN ACTIVITY LOG'S SEARCH BOX FINDS (AGL-3321).\n *\n * Every activity log — a site's (`hosts/{hostId}/activity`), an\n * organization's (`orgs/{orgId}/activity`), and the person-centred feeds read\n * across both — searches the same written token array, so the box promises\n * the same thing wherever it appears: a word typed there finds an entry when\n * it is the START of\n *\n * - the address the actor had when the entry was written, of its local\n * part or its domain, or of any run of letters and digits in it —\n * `ada`, `lovelace`, `ada.lovelace@`, `example.com`, `example` all find\n * `ada.lovelace@example.com`;\n * - a word of the API key's name, for an entry an integration wrote;\n * - a word of the name of what changed (`target.name`) — the screen, the\n * member, the workflow.\n *\n * Not the action sentence: it is prose written by forty call sites, some of\n * it three hundred characters of run errors, and every word of it would be\n * an index entry. Action is a Filters field instead.\n *\n * The array is `nameSearchTokens` over those words — the same normalizer the\n * query plan asks with (`nameSearchNormalizers`), so a typed word and a\n * stored token cannot disagree about case, whitespace or prefix length.\n *\n * ⚠️ Every writer stamps it, through `activitySearchTokens`: the site logger\n * in the browser, the two server loggers, the workflow engine's run rows, the\n * inbound-webhook runner, the site importer and the reconstruction backfill.\n * A writer that forgets writes an entry the log still LISTS and that no\n * search can find. The scripts that write or backfill entries use its\n * script-side twin, `tools/scripts/lib/activity-search-tokens.mjs`, held to\n * the same worked examples (`activity-search-tokens.fixtures.json` beside\n * it), which this library's spec asserts too.\n */\n\n/** The written field every activity search reads. */\nexport const ACTIVITY_SEARCH_TOKENS_PATH = 'searchTokens'\n\n/** What an entry's search tokens are derived from; every field may be absent. */\nexport interface ActivitySearchSource {\n actorEmail?: unknown\n apiKeyName?: unknown\n /** The entry's target as stored — only its `name` is read. */\n target?: { name?: unknown } | null\n}\n\nconst text = (value: unknown): string =>\n typeof value === 'string' ? value.trim() : ''\n\n/**\n * An address as the words a reader might start typing it by: the whole\n * address, its local part, its domain, and each run of letters and digits.\n * Shared by every search that finds a record by an address — the activity\n * logs' actor, and a site account's own address (the Site users list).\n */\nexport function addressSearchWords(address: unknown): string[] {\n const whole = text(address).toLowerCase()\n if (!whole) return []\n const at = whole.lastIndexOf('@')\n const halves = at > 0 ? [whole.slice(0, at), whole.slice(at + 1)] : []\n const runs = whole.split(/[^\\p{L}\\p{N}]+/u).filter(Boolean)\n return [whole, ...halves, ...runs].filter(Boolean)\n}\n\n/**\n * The search tokens one activity entry carries. Stamped by every writer as\n * `searchTokens`; see the note at the top of this file for what it promises.\n */\nexport function activitySearchTokens(entry: ActivitySearchSource): string[] {\n const words = [\n ...addressSearchWords(entry.actorEmail),\n text(entry.apiKeyName),\n text(entry.target?.name),\n ].filter(Boolean)\n return nameSearchTokens(words.join(' '))\n}\n"],"names":["nameSearchTokens","ACTIVITY_SEARCH_TOKENS_PATH","text","value","trim","addressSearchWords","address","whole","toLowerCase","at","lastIndexOf","halves","slice","runs","split","filter","Boolean","activitySearchTokens","entry","words","actorEmail","apiKeyName","target","name","join"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,gBAAgB,QAAQ,mBAAe;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCC,GAED,mDAAmD,GACnD,OAAO,MAAMC,8BAA8B,eAAc;AAUzD,MAAMC,OAAO,CAACC,QACZ,OAAOA,UAAU,WAAWA,MAAMC,IAAI,KAAK;AAE7C;;;;;CAKC,GACD,OAAO,SAASC,mBAAmBC,OAAgB;IACjD,MAAMC,QAAQL,KAAKI,SAASE,WAAW;IACvC,IAAI,CAACD,OAAO,OAAO,EAAE;IACrB,MAAME,KAAKF,MAAMG,WAAW,CAAC;IAC7B,MAAMC,SAASF,KAAK,IAAI;QAACF,MAAMK,KAAK,CAAC,GAAGH;QAAKF,MAAMK,KAAK,CAACH,KAAK;KAAG,GAAG,EAAE;IACtE,MAAMI,OAAON,MAAMO,KAAK,CAAC,8maAAmBC,MAAM,CAACC;IACnD,OAAO;QAACT;WAAUI;WAAWE;KAAK,CAACE,MAAM,CAACC;AAC5C;AAEA;;;CAGC,GACD,OAAO,SAASC,qBAAqBC,KAA2B;QAIvDA;IAHP,MAAMC,QAAQ;WACTd,mBAAmBa,MAAME,UAAU;QACtClB,KAAKgB,MAAMG,UAAU;QACrBnB,MAAKgB,gBAAAA,MAAMI,MAAM,qBAAZJ,cAAcK,IAAI;KACxB,CAACR,MAAM,CAACC;IACT,OAAOhB,iBAAiBmB,MAAMK,IAAI,CAAC;AACrC"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/activity-search.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { nameSearchTokens } from './name-search'\n\n/*\n * WHAT AN ACTIVITY LOG'S SEARCH BOX FINDS (AGL-3321).\n *\n * Every activity log — a site's (`hosts/{hostId}/activity`), an\n * organization's (`orgs/{orgId}/activity`), and the person-centred feeds read\n * across both — searches the same written token array, so the box promises\n * the same thing wherever it appears: a word typed there finds an entry when\n * it is the START of\n *\n * - the address the actor had when the entry was written, of its local\n * part or its domain, or of any run of letters and digits in it —\n * `ada`, `lovelace`, `ada.lovelace@`, `example.com`, `example` all find\n * `ada.lovelace@example.com`;\n * - a word of the API key's name, for an entry an integration wrote;\n * - a word of the name of what changed (`target.name`) — the screen, the\n * member, the workflow.\n *\n * Not the action sentence: it is prose written by forty call sites, some of\n * it three hundred characters of run errors, and every word of it would be\n * an index entry. Action is a Filters field instead.\n *\n * The array is `nameSearchTokens` over those words — the same normalizer the\n * query plan asks with (`nameSearchNormalizers`), so a typed word and a\n * stored token cannot disagree about case, whitespace or prefix length.\n *\n * ⚠️ Every writer stamps it, through `activitySearchTokens`: the site logger\n * in the browser, the two server loggers, the workflow engine's run rows, the\n * inbound-webhook runner, the site importer and the reconstruction backfill.\n * A writer that forgets writes an entry the log still LISTS and that no\n * search can find. The scripts that write or backfill entries use its\n * script-side twin, `tools/scripts/lib/activity-search-tokens.mjs`, held to\n * the same worked examples (`activity-search-tokens.fixtures.json` beside\n * it), which this library's spec asserts too.\n */\n\n/** The written field every activity search reads. */\nexport const ACTIVITY_SEARCH_TOKENS_PATH = 'searchTokens'\n\n/** What an entry's search tokens are derived from; every field may be absent. */\nexport interface ActivitySearchSource {\n actorEmail?: unknown\n apiKeyName?: unknown\n connectedAppName?: unknown\n /** The entry's target as stored — only its `name` is read. */\n target?: { name?: unknown } | null\n}\n\nconst text = (value: unknown): string =>\n typeof value === 'string' ? value.trim() : ''\n\n/**\n * An address as the words a reader might start typing it by: the whole\n * address, its local part, its domain, and each run of letters and digits.\n * Shared by every search that finds a record by an address — the activity\n * logs' actor, and a site account's own address (the Site users list).\n */\nexport function addressSearchWords(address: unknown): string[] {\n const whole = text(address).toLowerCase()\n if (!whole) return []\n const at = whole.lastIndexOf('@')\n const halves = at > 0 ? [whole.slice(0, at), whole.slice(at + 1)] : []\n const runs = whole.split(/[^\\p{L}\\p{N}]+/u).filter(Boolean)\n return [whole, ...halves, ...runs].filter(Boolean)\n}\n\n/**\n * The search tokens one activity entry carries. Stamped by every writer as\n * `searchTokens`; see the note at the top of this file for what it promises.\n */\nexport function activitySearchTokens(entry: ActivitySearchSource): string[] {\n const words = [\n ...addressSearchWords(entry.actorEmail),\n text(entry.apiKeyName),\n text(entry.connectedAppName),\n text(entry.target?.name),\n ].filter(Boolean)\n return nameSearchTokens(words.join(' '))\n}\n"],"names":["nameSearchTokens","ACTIVITY_SEARCH_TOKENS_PATH","text","value","trim","addressSearchWords","address","whole","toLowerCase","at","lastIndexOf","halves","slice","runs","split","filter","Boolean","activitySearchTokens","entry","words","actorEmail","apiKeyName","connectedAppName","target","name","join"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,gBAAgB,QAAQ,mBAAe;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCC,GAED,mDAAmD,GACnD,OAAO,MAAMC,8BAA8B,eAAc;AAWzD,MAAMC,OAAO,CAACC,QACZ,OAAOA,UAAU,WAAWA,MAAMC,IAAI,KAAK;AAE7C;;;;;CAKC,GACD,OAAO,SAASC,mBAAmBC,OAAgB;IACjD,MAAMC,QAAQL,KAAKI,SAASE,WAAW;IACvC,IAAI,CAACD,OAAO,OAAO,EAAE;IACrB,MAAME,KAAKF,MAAMG,WAAW,CAAC;IAC7B,MAAMC,SAASF,KAAK,IAAI;QAACF,MAAMK,KAAK,CAAC,GAAGH;QAAKF,MAAMK,KAAK,CAACH,KAAK;KAAG,GAAG,EAAE;IACtE,MAAMI,OAAON,MAAMO,KAAK,CAAC,8maAAmBC,MAAM,CAACC;IACnD,OAAO;QAACT;WAAUI;WAAWE;KAAK,CAACE,MAAM,CAACC;AAC5C;AAEA;;;CAGC,GACD,OAAO,SAASC,qBAAqBC,KAA2B;QAKvDA;IAJP,MAAMC,QAAQ;WACTd,mBAAmBa,MAAME,UAAU;QACtClB,KAAKgB,MAAMG,UAAU;QACrBnB,KAAKgB,MAAMI,gBAAgB;QAC3BpB,MAAKgB,gBAAAA,MAAMK,MAAM,qBAAZL,cAAcM,IAAI;KACxB,CAACT,MAAM,CAACC;IACT,OAAOhB,iBAAiBmB,MAAMM,IAAI,CAAC;AACrC"}
@@ -38,6 +38,24 @@ export interface CatalogApi {
38
38
  title: string;
39
39
  /** Machine-readable description: OpenAPI, published as `service-desc`. */
40
40
  specUrl?: string;
41
+ /**
42
+ * Media type of {@link specUrl}. Defaults to JSON, which is what an OpenAPI
43
+ * document is served as; an MCP Server Card has a type of its own
44
+ * (`application/mcp-server-card+json`) and says so.
45
+ */
46
+ specType?: string;
47
+ /**
48
+ * Further machine-readable metadata about the API, published as
49
+ * `service-meta` (RFC 8631 §4.3, one of the four relations RFC 9727
50
+ * Appendix A.1 names). For the MCP server: its OAuth protected-resource document
51
+ * (RFC 9728) and its authorization server's document (RFC 8414) — how a
52
+ * client signs in. No registered relation is specific to either, and
53
+ * `service-meta` is the general one RFC 9727 provides for exactly this.
54
+ */
55
+ metaLinks?: readonly {
56
+ href: string;
57
+ type: string;
58
+ }[];
41
59
  /** Human documentation, published as `service-doc`. */
42
60
  docsUrl?: string;
43
61
  /**
@@ -71,10 +71,11 @@
71
71
  anchor: api.url
72
72
  };
73
73
  if (api.specUrl) {
74
+ var _api_specType;
74
75
  context['service-desc'] = [
75
76
  {
76
77
  href: api.specUrl,
77
- type: 'application/json'
78
+ type: (_api_specType = api.specType) != null ? _api_specType : 'application/json'
78
79
  }
79
80
  ];
80
81
  }
@@ -87,6 +88,12 @@
87
88
  }
88
89
  ];
89
90
  }
91
+ if (api.metaLinks && api.metaLinks.length > 0) {
92
+ context['service-meta'] = api.metaLinks.map((link)=>({
93
+ href: link.href,
94
+ type: link.type
95
+ }));
96
+ }
90
97
  if (api.statusUrl) {
91
98
  context['status'] = [
92
99
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/agent-api-catalog.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype Schema = Record<string, unknown>\n\n/** The well-known location RFC 9727 reserves for an API catalog. */\nexport const API_CATALOG_PATH = '/.well-known/api-catalog'\n\n/**\n * The linkset media type RFC 9727 REQUIRES the catalog to support.\n *\n * Not `application/json`. RFC 9727 §3 says a catalog \"MUST support the Linkset\n * [RFC9264] format of application/linkset+json\", and a client that content-\n * negotiates for it is entitled to get it. The `+json` structured suffix means\n * anything that parses JSON still parses this.\n */\nexport const API_CATALOG_MEDIA_TYPE = 'application/linkset+json'\n\n/** One API in the catalog. */\nexport interface CatalogApi {\n /**\n * The API's root URI. This is the linkset `anchor` — the context every one\n * of its links hangs from — so it identifies the API rather than locating a\n * document about it.\n */\n url: string\n /** Human label, carried as the `title` target attribute on the listing. */\n title: string\n /** Machine-readable description: OpenAPI, published as `service-desc`. */\n specUrl?: string\n /** Human documentation, published as `service-doc`. */\n docsUrl?: string\n /**\n * Media type of {@link docsUrl}. Defaults to HTML because that is what a\n * documentation site serves — but a tenant's own documentation is\n * `/llms.txt`, which is Markdown, and declaring it HTML in a document whose\n * entire purpose is machine-readability would be a lie a client acts on.\n */\n docsType?: string\n /** Health endpoint, published as `status`. */\n statusUrl?: string\n}\n\nexport interface AgentApiCatalogOptions {\n /** The site's public origin, no trailing slash. */\n origin: string\n /** The APIs to advertise, in the order a reader should meet them. */\n apis: readonly CatalogApi[]\n}\n\n/**\n * The site's API catalog (RFC 9727), as an RFC 9264 linkset.\n *\n * ## What this is for\n *\n * A tenant's `/openapi.json` describes the SITE: its pages as Markdown, its\n * sitemap, its feeds, and the handful of JSON reads that serve them. That is an\n * honest description of a website, and it is not the typed REST API. The typed\n * API is the platform's, it lives on another origin, and until this document\n * existed nothing on a customer's site pointed at it — an agent standing on\n * `acme.com` had no way to learn that a full CRUD API describes the same data.\n *\n * A catalog is the published answer to exactly that question, which is why this\n * follows RFC 9727 rather than inventing a `/apis.json`: an agent that knows\n * the standard finds this without being told, and one that does not can still\n * read it, because a linkset is plain JSON.\n *\n * ## The shape, and why entries are separate objects\n *\n * A linkset is a list of link CONTEXTS, each keyed by its `anchor`. The first\n * context is anchored at the catalog itself and carries the `item` links — the\n * membership list, \"these are my APIs\". Every context after it is anchored at\n * one API's own root and carries that API's `service-desc`, `service-doc` and\n * `status`. Folding the metadata into the `item` entries would say something\n * different and weaker: that the CATALOG has a description, rather than that\n * each API does.\n *\n * ## Absent members are omitted, never emitted empty\n *\n * An operator running this platform themselves configures their own console\n * and docs origins, and may have neither. A `service-doc` pointing at an empty\n * string is a link an agent will follow and a 404 it will attribute to us, so\n * an API with nothing but an anchor contributes no context object at all.\n */\nexport function buildAgentApiCatalog(options: AgentApiCatalogOptions): Schema {\n const origin = options.origin.replace(/\\/+$/, '')\n const linkset: Schema[] = [\n {\n anchor: `${origin}${API_CATALOG_PATH}`,\n item: options.apis.map((api) => ({ href: api.url, title: api.title })),\n },\n ]\n\n for (const api of options.apis) {\n const context: Schema = { anchor: api.url }\n if (api.specUrl) {\n context['service-desc'] = [\n { href: api.specUrl, type: 'application/json' },\n ]\n }\n if (api.docsUrl) {\n context['service-doc'] = [\n { href: api.docsUrl, type: api.docsType ?? 'text/html' },\n ]\n }\n if (api.statusUrl) {\n context['status'] = [{ href: api.statusUrl, type: 'application/json' }]\n }\n // An anchor and nothing else describes nothing. See the note above.\n if (Object.keys(context).length > 1) linkset.push(context)\n }\n\n return { linkset }\n}\n"],"names":["API_CATALOG_PATH","API_CATALOG_MEDIA_TYPE","buildAgentApiCatalog","options","origin","replace","linkset","anchor","item","apis","map","api","href","url","title","context","specUrl","type","docsUrl","docsType","statusUrl","Object","keys","length","push"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID,kEAAkE,GAClE,OAAO,MAAMA,mBAAmB,2BAA0B;AAE1D;;;;;;;CAOC,GACD,OAAO,MAAMC,yBAAyB,2BAA0B;AAkChE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCC,GACD,OAAO,SAASC,qBAAqBC,OAA+B;IAClE,MAAMC,SAASD,QAAQC,MAAM,CAACC,OAAO,CAAC,QAAQ;IAC9C,MAAMC,UAAoB;QACxB;YACEC,QAAQ,GAAGH,SAASJ,kBAAkB;YACtCQ,MAAML,QAAQM,IAAI,CAACC,GAAG,CAAC,CAACC,MAAS,CAAA;oBAAEC,MAAMD,IAAIE,GAAG;oBAAEC,OAAOH,IAAIG,KAAK;gBAAC,CAAA;QACrE;KACD;IAED,KAAK,MAAMH,OAAOR,QAAQM,IAAI,CAAE;QAC9B,MAAMM,UAAkB;YAAER,QAAQI,IAAIE,GAAG;QAAC;QAC1C,IAAIF,IAAIK,OAAO,EAAE;YACfD,OAAO,CAAC,eAAe,GAAG;gBACxB;oBAAEH,MAAMD,IAAIK,OAAO;oBAAEC,MAAM;gBAAmB;aAC/C;QACH;QACA,IAAIN,IAAIO,OAAO,EAAE;gBAEcP;YAD7BI,OAAO,CAAC,cAAc,GAAG;gBACvB;oBAAEH,MAAMD,IAAIO,OAAO;oBAAED,IAAI,GAAEN,gBAAAA,IAAIQ,QAAQ,YAAZR,gBAAgB;gBAAY;aACxD;QACH;QACA,IAAIA,IAAIS,SAAS,EAAE;YACjBL,OAAO,CAAC,SAAS,GAAG;gBAAC;oBAAEH,MAAMD,IAAIS,SAAS;oBAAEH,MAAM;gBAAmB;aAAE;QACzE;QACA,oEAAoE;QACpE,IAAII,OAAOC,IAAI,CAACP,SAASQ,MAAM,GAAG,GAAGjB,QAAQkB,IAAI,CAACT;IACpD;IAEA,OAAO;QAAET;IAAQ;AACnB"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/agent-api-catalog.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\ntype Schema = Record<string, unknown>\n\n/** The well-known location RFC 9727 reserves for an API catalog. */\nexport const API_CATALOG_PATH = '/.well-known/api-catalog'\n\n/**\n * The linkset media type RFC 9727 REQUIRES the catalog to support.\n *\n * Not `application/json`. RFC 9727 §3 says a catalog \"MUST support the Linkset\n * [RFC9264] format of application/linkset+json\", and a client that content-\n * negotiates for it is entitled to get it. The `+json` structured suffix means\n * anything that parses JSON still parses this.\n */\nexport const API_CATALOG_MEDIA_TYPE = 'application/linkset+json'\n\n/** One API in the catalog. */\nexport interface CatalogApi {\n /**\n * The API's root URI. This is the linkset `anchor` — the context every one\n * of its links hangs from — so it identifies the API rather than locating a\n * document about it.\n */\n url: string\n /** Human label, carried as the `title` target attribute on the listing. */\n title: string\n /** Machine-readable description: OpenAPI, published as `service-desc`. */\n specUrl?: string\n /**\n * Media type of {@link specUrl}. Defaults to JSON, which is what an OpenAPI\n * document is served as; an MCP Server Card has a type of its own\n * (`application/mcp-server-card+json`) and says so.\n */\n specType?: string\n /**\n * Further machine-readable metadata about the API, published as\n * `service-meta` (RFC 8631 §4.3, one of the four relations RFC 9727\n * Appendix A.1 names). For the MCP server: its OAuth protected-resource document\n * (RFC 9728) and its authorization server's document (RFC 8414) — how a\n * client signs in. No registered relation is specific to either, and\n * `service-meta` is the general one RFC 9727 provides for exactly this.\n */\n metaLinks?: readonly { href: string; type: string }[]\n /** Human documentation, published as `service-doc`. */\n docsUrl?: string\n /**\n * Media type of {@link docsUrl}. Defaults to HTML because that is what a\n * documentation site serves — but a tenant's own documentation is\n * `/llms.txt`, which is Markdown, and declaring it HTML in a document whose\n * entire purpose is machine-readability would be a lie a client acts on.\n */\n docsType?: string\n /** Health endpoint, published as `status`. */\n statusUrl?: string\n}\n\nexport interface AgentApiCatalogOptions {\n /** The site's public origin, no trailing slash. */\n origin: string\n /** The APIs to advertise, in the order a reader should meet them. */\n apis: readonly CatalogApi[]\n}\n\n/**\n * The site's API catalog (RFC 9727), as an RFC 9264 linkset.\n *\n * ## What this is for\n *\n * A tenant's `/openapi.json` describes the SITE: its pages as Markdown, its\n * sitemap, its feeds, and the handful of JSON reads that serve them. That is an\n * honest description of a website, and it is not the typed REST API. The typed\n * API is the platform's, it lives on another origin, and until this document\n * existed nothing on a customer's site pointed at it — an agent standing on\n * `acme.com` had no way to learn that a full CRUD API describes the same data.\n *\n * A catalog is the published answer to exactly that question, which is why this\n * follows RFC 9727 rather than inventing a `/apis.json`: an agent that knows\n * the standard finds this without being told, and one that does not can still\n * read it, because a linkset is plain JSON.\n *\n * ## The shape, and why entries are separate objects\n *\n * A linkset is a list of link CONTEXTS, each keyed by its `anchor`. The first\n * context is anchored at the catalog itself and carries the `item` links — the\n * membership list, \"these are my APIs\". Every context after it is anchored at\n * one API's own root and carries that API's `service-desc`, `service-doc` and\n * `status`. Folding the metadata into the `item` entries would say something\n * different and weaker: that the CATALOG has a description, rather than that\n * each API does.\n *\n * ## Absent members are omitted, never emitted empty\n *\n * An operator running this platform themselves configures their own console\n * and docs origins, and may have neither. A `service-doc` pointing at an empty\n * string is a link an agent will follow and a 404 it will attribute to us, so\n * an API with nothing but an anchor contributes no context object at all.\n */\nexport function buildAgentApiCatalog(options: AgentApiCatalogOptions): Schema {\n const origin = options.origin.replace(/\\/+$/, '')\n const linkset: Schema[] = [\n {\n anchor: `${origin}${API_CATALOG_PATH}`,\n item: options.apis.map((api) => ({ href: api.url, title: api.title })),\n },\n ]\n\n for (const api of options.apis) {\n const context: Schema = { anchor: api.url }\n if (api.specUrl) {\n context['service-desc'] = [\n { href: api.specUrl, type: api.specType ?? 'application/json' },\n ]\n }\n if (api.docsUrl) {\n context['service-doc'] = [\n { href: api.docsUrl, type: api.docsType ?? 'text/html' },\n ]\n }\n if (api.metaLinks && api.metaLinks.length > 0) {\n context['service-meta'] = api.metaLinks.map((link) => ({\n href: link.href,\n type: link.type,\n }))\n }\n if (api.statusUrl) {\n context['status'] = [{ href: api.statusUrl, type: 'application/json' }]\n }\n // An anchor and nothing else describes nothing. See the note above.\n if (Object.keys(context).length > 1) linkset.push(context)\n }\n\n return { linkset }\n}\n"],"names":["API_CATALOG_PATH","API_CATALOG_MEDIA_TYPE","buildAgentApiCatalog","options","origin","replace","linkset","anchor","item","apis","map","api","href","url","title","context","specUrl","type","specType","docsUrl","docsType","metaLinks","length","link","statusUrl","Object","keys","push"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID,kEAAkE,GAClE,OAAO,MAAMA,mBAAmB,2BAA0B;AAE1D;;;;;;;CAOC,GACD,OAAO,MAAMC,yBAAyB,2BAA0B;AAiDhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCC,GACD,OAAO,SAASC,qBAAqBC,OAA+B;IAClE,MAAMC,SAASD,QAAQC,MAAM,CAACC,OAAO,CAAC,QAAQ;IAC9C,MAAMC,UAAoB;QACxB;YACEC,QAAQ,GAAGH,SAASJ,kBAAkB;YACtCQ,MAAML,QAAQM,IAAI,CAACC,GAAG,CAAC,CAACC,MAAS,CAAA;oBAAEC,MAAMD,IAAIE,GAAG;oBAAEC,OAAOH,IAAIG,KAAK;gBAAC,CAAA;QACrE;KACD;IAED,KAAK,MAAMH,OAAOR,QAAQM,IAAI,CAAE;QAC9B,MAAMM,UAAkB;YAAER,QAAQI,IAAIE,GAAG;QAAC;QAC1C,IAAIF,IAAIK,OAAO,EAAE;gBAEcL;YAD7BI,OAAO,CAAC,eAAe,GAAG;gBACxB;oBAAEH,MAAMD,IAAIK,OAAO;oBAAEC,IAAI,GAAEN,gBAAAA,IAAIO,QAAQ,YAAZP,gBAAgB;gBAAmB;aAC/D;QACH;QACA,IAAIA,IAAIQ,OAAO,EAAE;gBAEcR;YAD7BI,OAAO,CAAC,cAAc,GAAG;gBACvB;oBAAEH,MAAMD,IAAIQ,OAAO;oBAAEF,IAAI,GAAEN,gBAAAA,IAAIS,QAAQ,YAAZT,gBAAgB;gBAAY;aACxD;QACH;QACA,IAAIA,IAAIU,SAAS,IAAIV,IAAIU,SAAS,CAACC,MAAM,GAAG,GAAG;YAC7CP,OAAO,CAAC,eAAe,GAAGJ,IAAIU,SAAS,CAACX,GAAG,CAAC,CAACa,OAAU,CAAA;oBACrDX,MAAMW,KAAKX,IAAI;oBACfK,MAAMM,KAAKN,IAAI;gBACjB,CAAA;QACF;QACA,IAAIN,IAAIa,SAAS,EAAE;YACjBT,OAAO,CAAC,SAAS,GAAG;gBAAC;oBAAEH,MAAMD,IAAIa,SAAS;oBAAEP,MAAM;gBAAmB;aAAE;QACzE;QACA,oEAAoE;QACpE,IAAIQ,OAAOC,IAAI,CAACX,SAASO,MAAM,GAAG,GAAGhB,QAAQqB,IAAI,CAACZ;IACpD;IAEA,OAAO;QAAET;IAAQ;AACnB"}
@@ -72,3 +72,18 @@ export declare const AUTHOR_TOKEN_CATALOG: readonly BindingTokenCatalogEntry[];
72
72
  * only, so renaming a field never breaks a binding (AGL-578).
73
73
  */
74
74
  export declare function repeatItemToken(fieldId: string, targetFieldId?: string): string;
75
+ /**
76
+ * The record field type that holds an icon (AGL-4190): `{ iconId, iconPath }`,
77
+ * the shape a reusable component's Icon property holds. Named here, in core,
78
+ * because the plugin that keeps the records declares it and the Besigner's
79
+ * Icon picker binds to it, and neither may import the other. Persisted on
80
+ * field definitions — never rename.
81
+ */
82
+ export declare const RECORD_ICON_FIELD_TYPE = "icon";
83
+ /** The part of a record's icon that is its SVG path (AGL-4190). */
84
+ export declare const RECORD_ICON_PATH_PART = "iconPath";
85
+ /**
86
+ * The field id of a token that is nothing but one record field, `{{item.x}}`,
87
+ * or `null` for anything else (a hop, words around it, another kind of token).
88
+ */
89
+ export declare function matchWholeItemToken(value: unknown): string | null;
@@ -277,5 +277,21 @@
277
277
  */ export function repeatItemToken(fieldId, targetFieldId) {
278
278
  return targetFieldId ? `{{item.${fieldId}.${targetFieldId}}}` : `{{item.${fieldId}}}`;
279
279
  }
280
+ /**
281
+ * The record field type that holds an icon (AGL-4190): `{ iconId, iconPath }`,
282
+ * the shape a reusable component's Icon property holds. Named here, in core,
283
+ * because the plugin that keeps the records declares it and the Besigner's
284
+ * Icon picker binds to it, and neither may import the other. Persisted on
285
+ * field definitions — never rename.
286
+ */ export const RECORD_ICON_FIELD_TYPE = 'icon';
287
+ /** The part of a record's icon that is its SVG path (AGL-4190). */ export const RECORD_ICON_PATH_PART = 'iconPath';
288
+ /**
289
+ * The field id of a token that is nothing but one record field, `{{item.x}}`,
290
+ * or `null` for anything else (a hop, words around it, another kind of token).
291
+ */ export function matchWholeItemToken(value) {
292
+ if (typeof value !== 'string') return null;
293
+ const match = /^\s*\{\{\s*item\.([A-Za-z][A-Za-z0-9_]*)\s*\}\}\s*$/.exec(value);
294
+ return match ? match[1] : null;
295
+ }
280
296
 
281
297
  //# sourceMappingURL=binding-token-catalog.js.map