@webex/plugin-attachment-actions 3.13.0-next.1 → 3.13.0-next.10

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.
@@ -0,0 +1,354 @@
1
+ ---
2
+ type: Module Spec
3
+ title: 'Attachment actions plugin specification'
4
+ description: Responsibilities, boundaries, design, invariants, and verification for the Attachment actions plugin module.
5
+ tags: [module, specification]
6
+ ---
7
+ <!-- sdd-generated-metadata
8
+ doc_kind: module-spec
9
+ generated_from: module-spec@0.3.0
10
+ generated_by: claude-code
11
+ approved_by: rarajes2@cisco.com
12
+ updated_at: 2026-11-13T02:56:49Z
13
+ validation_status: pass-with-warnings
14
+ -->
15
+
16
+ # Attachment actions plugin
17
+
18
+ This source-local document at `src/docs/README.md` owns the stable specification for **the Attachment
19
+ actions plugin**: the public plugin `webex.attachmentActions`. An attachment action is what a user
20
+ produces by pressing an `Action.Submit` button on an adaptive card attached to a Webex message. The
21
+ plugin posts and reads attachment actions through the `attachment/actions` resource of the Webex REST
22
+ API (catalog service `hydra`), and, once `listen()` is called, it turns `cardAction` activities from
23
+ the Mercury socket into webhook-shaped `created` events. Ground every claim in package evidence and
24
+ link to the [package architecture](../../docs/architecture.md) instead of repeating broader facts. No
25
+ service specification exists because this package is a library.
26
+
27
+ Related context: [documentation index](../../docs/index.md) ·
28
+ [package agent instructions](../../AGENTS.md)
29
+
30
+ ## Metadata
31
+
32
+ | Field | Value |
33
+ | ----------------- | ----- |
34
+ | Owner | @webex/web-sdk |
35
+ | Source path | `src` |
36
+ | Resource kind | package |
37
+ | Status | Draft |
38
+ | Last verified | 2026-11-13 at `c22331c97b` |
39
+ | Module id | `plugin-attachment-actions` |
40
+ | Parent spec | — |
41
+ | Doc kind | Module spec |
42
+ | Coverage score | 100% assessed 2026-11-13 by the generator — 13 of 13 mandatory fields PRESENT, critical 7 of 7; the package has no unit tests and no `test:unit` script, so no requirement has running test evidence; `test/integration/spec/attachmentActions.js` holds 2 live-service cases that no package script runs |
43
+ | Validation status | Pass-with-warnings — 0 Blocking, 2 Important; assessed 2026-11-13 by validator runtime 01a1d2c4-c928-7fc0-bc29-9bf787bf37bc. Prior F-001 is fixed; F-002 and F-003 remain Important findings. |
44
+
45
+ ## Applicability
46
+
47
+ | Condition ID | Status | Evidence or reason | Owned section |
48
+ | ------------------------------------ | ---------- | ------------------ | ------------- |
49
+ | `module.has_tiers` | N/A | No tier policy exists in `package.json` or `src/attachmentActions.js` | Tier |
50
+ | `module.has_ui` | N/A | `src/attachmentActions.js` returns records and emits events; it renders nothing | UI use-case flow |
51
+ | `module.crosses_service_boundaries` | Applicable | `src/attachmentActions.js` calls the Webex REST API attachment actions resource and listens on the Mercury socket | Cross-boundary use-case flow |
52
+ | `module.holds_client_state` | N/A | The only instance property `src/attachmentActions.js` sets is the event envelope, recorded under Business rules and invariants; no record is cached | Client state model |
53
+ | `module.enforces_domain_rules` | Applicable | The cardAction-only mapping, the Hydra id construction, and the conditional inputs field in `src/attachmentActions.js` | Business rules and invariants |
54
+ | `module.is_concurrent_async` | Applicable | `src/attachmentActions.js` returns promises and handles socket activities as they arrive | Concurrency and reactive flow |
55
+ | `module.owns_persistence` | N/A | Nothing is stored; `src/attachmentActions.js` resolves what Hydra returns | Data, schema, and migration discipline |
56
+ | `module.stateful_transitions` | N/A | No entity moves through states in `src/attachmentActions.js` | State machine |
57
+ | `module.exposes_wire_protocol` | Applicable | The attachment actions requests and the webhook-shaped event built in `src/attachmentActions.js` | Protocol and wire format |
58
+ | `module.ui_multi_screen` | N/A | No UI | UI flow |
59
+ | `module.large_data_model` | N/A | One shape, the attachment action object, typed only by the JSDoc AttachmentActionObject in `src/attachmentActions.js`; covered under Protocol and wire format | Data model |
60
+ | `module.returns_caller_errors` | Applicable | Request failures reject, and a failed event conversion is logged and dropped in `src/attachmentActions.js` | Caller-visible failure modes |
61
+ | `module.module_specific_conventions` | Applicable | Hydra attachment action, message, person, and room ids and the webhook-shaped event envelope in `src/attachmentActions.js` | Module-specific rules |
62
+ | `module.published_package` | Applicable | `package.json` names the package @webex/plugin-attachment-actions and defines deploy:npm | Export stability |
63
+ | `module.embedded_in_host` | N/A | No host theme or embed API | Host integration and theming |
64
+ | `module.has_design_tradeoff` | Applicable | Events from the Mercury socket, built from the activity alone without a Hydra fetch, in `src/attachmentActions.js` | Key design trade-off |
65
+ | `module.has_submodules` | N/A | The src directory has no child module | Sub-modules |
66
+
67
+ ## Evidence register
68
+
69
+ | Evidence | What it establishes |
70
+ | -------- | ------------------- |
71
+ | `src/index.js` | Imports `@webex/internal-plugin-conversation` (code comment: "decrypt mercury activities") and `@webex/internal-plugin-mercury` for their registration side effects, then `registerPlugin('attachmentActions', AttachmentActions)` with no options; re-exports only the default `AttachmentActions` |
72
+ | `src/attachmentActions.js` | `AttachmentActions` extends `WebexPlugin` with `initialize`, `listen`, `create`, `get`, and the JSDoc-`@private` `onWebexApiEvent` and `getattachmentActionEvent`; a module-level `debug('attachmentActions')` logger; the `AttachmentActionObject` typedef. Its JSDoc and code comments are the only recorded rationale |
73
+ | `package.json` | Name, `main` (`dist/index.js`), `devMain` (`src/index.js`), `engines` (`node >=16`), dependencies, peer dependencies on `@webex/plugin-logger`, `@webex/plugin-messages`, and `@webex/plugin-people`, and scripts; `build`, `build:src`, `test:style`, `test:browser:broken`, `deploy:npm`, and `test` exist, and `test:unit`, `test:integration`, and `test:browser` do not |
74
+ | `test/integration/spec/attachmentActions.js` | 2 live-service cases: `create` by a second user on a card the first user sent, checking the returned record and the `created` event the first user receives; and `get` of that record. The event checks name the envelope fields and the `data` fields. No case runs (see Verification) |
75
+ | `README.md` | Retained npm page; context only. It holds no usage example; see `docs/adr/0001-retain-product-readme.md` |
76
+ | Sibling package common, file src/docs/README.md | Module spec consulted, agrees with code. Hydra ids are base64url of `ciscospark://<cluster>/<TYPE>/<id>` and `PEOPLE` ids always use cluster `us` (MOD-006, INV-001); the internal US clusters normalise to `us` (INV-005); `createEventEnvelope` resolves `undefined` when the identity lookup fails (MOD-011). The code was read for the `SDK_EVENT` values the plugin uses (verb `cardAction`, Mercury event `event:conversation.activity`, resource `attachmentActions`, event `created`), for `hydraTypes`, `constructHydraId`, and `getHydraClusterString`, which throws below three cluster parts, and for `ensureMyIdIsAvailable`, which caches the current user as `webex.internal.me` |
77
+ | Sibling package webex-core, file src/docs/README.md | Module spec consulted, agrees with code. `registerPlugin` keeps the first registration of a name (MOD-013) and adds `webex.<name>` to later instances (MOD-014); `WebexPlugin` is an ampersand-state base supplying `webex`, `logger`, request, and the ampersand event methods. The spec is silent on the service catalog, so `src/lib/services/services.js` was the referee for `getClusterId` |
78
+ | Sibling package internal-plugin-mercury, file src/docs/README.md | Module spec consulted, agrees with code on what this package uses. Importing the package registers internal plugin `mercury` (MOD-001); `connect()` shares a connect in flight and resolves at once when connected (MOD-002); an inbound envelope with event type `conversation.activity` is emitted as `event:conversation.activity` (MOD-009). Its code was read to confirm that `_emit` catches and logs a listener error. The spec's description of sessions is stale against `src/mercury.js`, but this package passes no argument to `connect()` |
79
+ | Sibling package internal-plugin-conversation, files src/index.js and src/decryption-transforms.js | No module spec exists, so the code is the referee. Importing it registers internal plugin `conversation` with payload-transformer predicates, one of which transforms (decrypts) any inbound event that has an `activity`; `decryptSubmit` decrypts `object.inputs` of a submit object and, when that fails, logs a warning and replaces `inputs` with the configured `decryptionFailureMessage`. This plugin calls no conversation method |
80
+ | Observation, no stated WHY | Behavior the code shows without stating a reason is recorded once, under Pitfalls and constraints or Caller-visible failure modes |
81
+
82
+ ## Purpose and boundary
83
+
84
+ - Responsibility: give applications the submit actions of adaptive cards as Hydra-style records — post
85
+ one on behalf of the current user, read one by id — plus webhook-shaped `created` events over the
86
+ existing Mercury socket when anyone submits a card in a space the user can see.
87
+ - In scope: registration of `attachmentActions`; `create`, `get`, and `listen`; turning `cardAction`
88
+ activities into `created` events.
89
+ - Out of scope: the request pipeline, authorization, and service-catalog resolution
90
+ (`@webex/webex-core`); Hydra id encoding, the event envelope, and the event vocabulary
91
+ (`@webex/common`); the socket connection (`@webex/internal-plugin-mercury`); decrypting activities and
92
+ card inputs (`@webex/internal-plugin-conversation`); sending the card itself (the messages plugin);
93
+ listing, updating, or deleting attachment actions, which this plugin does not offer; caching records;
94
+ what Hydra stores or returns.
95
+ - Consumers: in this repository the `webex` and `webex-node` packages import the package to register
96
+ it (workspace-root files `packages/webex/src/webex.js` and `packages/webex-node/src/webex-node.js`),
97
+ and the workspace sample `docs/samples/browser-socket/app.js` uses `listen()` and the `created`
98
+ event. No other package calls it. Applications reach the plugin as `webex.attachmentActions`.
99
+
100
+ ## Structure and key files
101
+
102
+ | Path | Responsibility |
103
+ | ---- | -------------- |
104
+ | `src/index.js` | Registers the conversation and Mercury internal plugins by import, registers public plugin `attachmentActions`, and re-exports the class as default |
105
+ | `src/attachmentActions.js` | `AttachmentActions` and the `debug` trace logger |
106
+ | `package.json` | Package name, entry points, scripts, dependencies, and peer dependencies |
107
+ | `babel.config.js`, `jest.config.js` | Re-exports of the legacy Babel and Jest configurations; no unit spec uses the Jest one |
108
+ | `.eslintrc.js` | Sets `root: true` and extends `@webex/eslint-config-legacy` |
109
+ | `process` | Package-root file exporting `{browser: true}`; not imported by `src/` |
110
+ | `src/docs/README.md` | This module specification; ignored by the build and by lint |
111
+ | `test/integration/spec/attachmentActions.js` | Live-service cases that no package script runs |
112
+ | dist/ (generated) | Build output of `build:src`; ignored by Git and never edited by hand |
113
+
114
+ ## Public surface
115
+
116
+ | Surface | Consumer | Compatibility commitment | Source |
117
+ | ------- | -------- | ------------------------ | ------ |
118
+ | Import side effect: public plugin `attachmentActions`, and internal plugins `conversation` and `mercury` | `webex`, `webex-node` | First registration of the name wins; reached as `webex.attachmentActions` | `src/index.js` |
119
+ | `create(attachmentAction)`, `get(attachmentAction)` | Applications | Hydra attachment action records | `src/attachmentActions.js` |
120
+ | `listen()` and the `created` event | Applications; the socket sample | Webhook-shaped events triggered on `webex.attachmentActions`; removed with the inherited `off` and `stopListening` | `src/attachmentActions.js` |
121
+ | `onWebexApiEvent(event)`, `getattachmentActionEvent(activity, event)` | The Mercury listener | Marked `@private`; the JSDoc says external users should not call them | `src/attachmentActions.js` |
122
+ | Default export `AttachmentActions` | Hosts that mount the class themselves | The entry exports nothing else | `src/index.js` |
123
+
124
+ Contract ID `attachment-actions-public-sdk` is indexed in the
125
+ [package architecture](../../docs/architecture.md#public-and-consumer-surfaces) and registered in
126
+ `.sdd/manifest.json`. Export stability is under [Export stability](#export-stability).
127
+
128
+ ## Dependencies
129
+
130
+ | Dependency | Why it is required | Failure behavior |
131
+ | ---------- | ------------------ | ---------------- |
132
+ | `@webex/webex-core` plugin host (module spec consulted) | `registerPlugin` and `WebexPlugin` (`webex`, `request`, `logger`, and the event methods `on`, `off`, `trigger`, `listenTo`, `stopListening`) | A request rejection rejects the method |
133
+ | `@webex/webex-core` services (code consulted) | Resolves `service: 'hydra'`; `getClusterId` for cluster strings | An unknown cluster makes `getHydraClusterString` throw; see Caller-visible failure modes |
134
+ | `@webex/common` (module spec consulted; code consulted for `SDK_EVENT` and `hydraTypes`) | `createEventEnvelope`, `constructHydraId`, `getHydraClusterString`, `hydraTypes`, and `SDK_EVENT` | See Caller-visible failure modes |
135
+ | `@webex/internal-plugin-conversation` (no spec; code consulted) | Registered by import; its inbound payload transformer decrypts socket activities, card inputs included | Not called directly |
136
+ | `@webex/internal-plugin-mercury` (module spec consulted, stale on sessions; code consulted) | Registered by import; `mercury.connect()` and the `event:conversation.activity` event | A connect failure rejects `listen()` |
137
+ | `@webex/plugin-people` (peer dependency) | `createEventEnvelope` calls `webex.people.get('me')` once per instance to fill the envelope | The envelope comes back `undefined`; see Caller-visible failure modes |
138
+ | `@webex/plugin-logger` (peer dependency) | Supplies `webex.logger` used when a conversion fails | Not imported by `src/` |
139
+ | `@webex/plugin-messages` (peer dependency) | Not imported by `src/`; the integration spec sends the card with it | — |
140
+ | `lodash` | `cloneDeep` of the event envelope | — |
141
+ | `debug` | The `attachmentActions` trace line for each created event | — |
142
+ | Webex REST API attachment actions resource (external) | Attachment action records | Errors propagate |
143
+
144
+ ## Requirements
145
+
146
+ | ID | WHAT | WHY | Source evidence | Test or example evidence | Assumptions or gaps | Confidence |
147
+ | -- | ---- | --- | --------------- | ------------------------ | ------------------- | ---------- |
148
+ | `MOD-001` | Importing the package first imports `@webex/internal-plugin-conversation` and `@webex/internal-plugin-mercury`, registering both internal plugins, then registers `AttachmentActions` as public plugin `attachmentActions` with no config or other options. The entry re-exports only the default `AttachmentActions`. | The code comment: the conversation import is there to decrypt Mercury activities; `listen()` needs `webex.internal.mercury` (inferred from that call); applications reach the plugin as `webex.attachmentActions`. | `src/index.js` | `test/integration/spec/attachmentActions.js` imports the package and relies on it (not run) | WHY of the Mercury import inferred | Present |
149
+ | `MOD-002` | `create(attachmentAction)` sends `POST attachment/actions` to service `hydra` through `this.request` with the caller's object as the JSON `body`, unchanged and unvalidated, and resolves the response body. | The JSDoc: post a new attachment action for a message with an attachment; the caller supplies `type` (for example `submit`), `messageId`, and `inputs`, and Hydra fills `id`, `personId`, `roomId`, and `created`. | `src/attachmentActions.js` | `test/integration/spec/attachmentActions.js` #create() checks `id`, `created`, `type`, `messageId`, `inputs`, and `personId` (not run) | — | Present |
150
+ | `MOD-003` | `get(attachmentAction)` takes `attachmentAction.id`, else `attachmentAction`, as the id, sends `GET attachment/actions/<id>` to service `hydra`, and resolves `res.body.items` when present, else `res.body`. | The JSDoc: returns a single attachment action. | `src/attachmentActions.js` | `test/integration/spec/attachmentActions.js` #get() passes the record from `create` (not run) | Why `items` is checked is not stated | Present |
151
+ | `MOD-004` | `listen()` resolves `createEventEnvelope(webex, 'attachmentActions')`, stores it as `this.eventEnvelope`, calls `webex.internal.mercury.connect()`, and then listens on Mercury for `event:conversation.activity`, passing each event to `onWebexApiEvent`. It resolves `undefined`. | The JSDoc: an alternative to attachmentAction webhooks with webhook-like payloads that omit webhook-only fields (name, secret, url) and can add `inputs`; it needs the `spark:all` and `spark:kms` scopes. | `src/attachmentActions.js` | `test/integration/spec/attachmentActions.js` waits for `created` after `listen()` (not run) | No guard against a second `listen()`; see Pitfalls | Present |
152
+ | `MOD-005` | `onWebexApiEvent(event)` reads `event.data.activity`. When `activity.verb` is `cardAction` it builds the event with `getattachmentActionEvent(activity, 'created')` and, when that returns a value, writes a `debug` trace of it and triggers `created` on `webex.attachmentActions` with it. Every other verb is ignored. | The JSDoc: called when an internal Mercury event fires after `listen()`; external users should not call it. A card submit arrives as a `cardAction` activity (common `SDK_EVENT`; the conversation plugin's `cardAction` builder uses the same verb). | `src/attachmentActions.js` | None found | — | Present |
153
+ | `MOD-006` | `getattachmentActionEvent(activity, event)` deep-clones the envelope, sets `event`, and, with the cluster of `activity.target.url`, sets `data.created` to `activity.published`; `actorId` and `data.personId` to the Hydra person id of `activity.actor.entryUUID`; `data.roomId` to the Hydra room id of `activity.target.id`; `data.messageId` to the Hydra message id of `activity.parent.id`; `data.id` to the Hydra attachment action id of `activity.id`; `data.inputs` to `activity.object.inputs` only when that is truthy; and `data.type` to `activity.object.objectType`. It sends no request and returns the event. | The JSDoc: adhere to Hydra's webhook data structure. The code comment: `personEmail` would be useful but is not in the Hydra webhook, so it is left out. | `src/attachmentActions.js` | `test/integration/spec/attachmentActions.js` compares `actorId`, `data.id`, `data.roomId`, `data.personId`, and `data.inputs` with the created record (not run) | — | Present |
154
+ | `MOD-007` | When building the event throws for any reason, `getattachmentActionEvent` logs one `webex.logger.error` line naming the event type and the error message and returns `null`, so `onWebexApiEvent` triggers nothing. | The JSDoc marks it as an internal builder; the catch keeps a malformed activity from reaching the listener (inferred). | `src/attachmentActions.js` | None found | — | Present |
155
+
156
+ ## Design overview
157
+
158
+ `AttachmentActions` is a `WebexPlugin` with two paths. The record path sends one Hydra request per call
159
+ to the `attachment/actions` resource and resolves what Hydra returns: `create` posts the caller's
160
+ object, and `get` reads one record by id. The plugin offers no list, update, or delete.
161
+
162
+ The event path starts with `listen()`. It builds one webhook-style envelope for the current user,
163
+ connects the Mercury socket, and listens for conversation activities, which the conversation plugin
164
+ decrypts on the way in, card inputs included. A `cardAction` activity becomes a `created` event built
165
+ from the activity alone: every id is re-encoded as a Hydra id, and the submitted inputs are copied when
166
+ present. Other verbs are ignored. A conversion failure is logged and the event is dropped. Nothing is
167
+ cached; every record call reaches Hydra.
168
+
169
+ ## Data flow and sequence coverage
170
+
171
+ Call style: in-process method calls on `webex.attachmentActions`; outbound HTTPS through
172
+ `webex.request` to catalog service `hydra`; inbound events from the Mercury socket. Two operation groups
173
+ differ in actors and outcome. The event group crosses several components and has a diagram; the record
174
+ group is one request per call.
175
+
176
+ | Operation group | Entry and outcome | Diagram or evidence | Failure and recovery coverage |
177
+ | --------------- | ----------------- | ------------------- | ----------------------------- |
178
+ | Attachment action records | `create`, `get`; one Hydra request each | `src/attachmentActions.js` | The request error rejects; nothing is retried |
179
+ | Attachment action events | `listen()`; Mercury `cardAction` activities become `created` events | Diagram 1; `src/attachmentActions.js` | A connect failure rejects `listen()`; a conversion error is logged and drops the event |
180
+
181
+ Diagram 1 — attachment action events:
182
+
183
+ ```mermaid
184
+ sequenceDiagram
185
+ participant C as Caller
186
+ participant A as AttachmentActions
187
+ participant P as common createEventEnvelope
188
+ participant M as mercury
189
+ participant V as conversation transformer
190
+ C->>A: listen()
191
+ A->>P: createEventEnvelope(webex, 'attachmentActions')
192
+ P-->>A: envelope (stored)
193
+ A->>M: connect(), then listenTo event:conversation.activity
194
+ M->>V: inbound activity
195
+ V-->>M: activity with decrypted inputs
196
+ M-->>A: activity (verb cardAction)
197
+ A->>A: clone envelope, build Hydra ids from the activity
198
+ alt conversion succeeds
199
+ A-->>C: trigger created
200
+ else conversion throws
201
+ A->>A: webex.logger.error, no event
202
+ end
203
+ ```
204
+
205
+ ## Class and component relationships
206
+
207
+ ```mermaid
208
+ classDiagram
209
+ class WebexPlugin
210
+ class AttachmentActions {
211
+ eventEnvelope
212
+ initialize(args)
213
+ listen()
214
+ create(attachmentAction)
215
+ get(attachmentAction)
216
+ onWebexApiEvent(event)
217
+ getattachmentActionEvent(activity, event)
218
+ }
219
+ class debug
220
+ WebexPlugin <|-- AttachmentActions
221
+ AttachmentActions ..> debug : onWebexApiEvent trace
222
+ ```
223
+
224
+ ## Use cases and flows
225
+
226
+ | Use case | Actor or caller | Primary steps and outcome | Failure or boundary behavior | Evidence |
227
+ | -------- | --------------- | ------------------------- | ---------------------------- | -------- |
228
+ | `UC-001` | Application submitting a card for its user | `create({type: 'submit', messageId, inputs})` resolves the Hydra record | The Hydra error rejects | `src/attachmentActions.js` |
229
+ | `UC-002` | Application reading a submit | `get(id)` or `get(record)` | The request error rejects | `src/attachmentActions.js` |
230
+ | `UC-003` | Bot or application replacing attachmentAction webhooks | `listen()`, then `on('created')`; `stopListening()` and `off('created')` to stop | Needs `spark:all` and `spark:kms`; a connect failure rejects `listen()` | `src/attachmentActions.js` |
231
+
232
+ ### Cross-boundary use-case flow
233
+
234
+ | Boundary | Transport and ordering | Compatibility | Timeout, retry, and recovery |
235
+ | -------- | ---------------------- | ------------- | ---------------------------- |
236
+ | Webex REST API attachment actions resource (`UC-001`, `UC-002`) | HTTPS through `webex.request`, catalog service `hydra`, one per call | Requests under Protocol and wire format | No retry or timeout in this module; webex-core interceptors apply |
237
+ | Mercury socket (`UC-003`) | `mercury.connect()`, then events in socket order | The activity fields read by `getattachmentActionEvent` | Reconnects are Mercury's (internal-plugin-mercury MOD-005); events during a disconnect are not replayed here |
238
+
239
+ ## Business rules and invariants
240
+
241
+ | ID | Invariant | WHY | Enforcement source | Test evidence |
242
+ | -- | --------- | --- | ------------------ | ------------- |
243
+ | `INV-001` | Only the verb `cardAction` produces an event, and the only event is `created`. | A `cardAction` activity records a submit, which is a new attachment action (inferred from the single `switch` case); `SDK_EVENT` also defines `updated` and `deleted`, and the code uses neither. | `src/attachmentActions.js` | None found |
244
+ | `INV-002` | Event ids are Hydra ids built with the cluster of `activity.target.url`, so they have the form the attachment actions resource returns; person ids always use cluster `us`. | Callers match events to records, messages, and rooms by id (inferred); common MOD-006 and INV-001. | `src/attachmentActions.js` | Only `test/integration/spec/attachmentActions.js`, which compares event ids with the created record and is not run |
245
+ | `INV-003` | Every event is built from a deep clone of the one envelope stored by `listen()`, so one event's fields never leak into the next. | The envelope is shared across events (inferred from `cloneDeep`). | `src/attachmentActions.js` | None found |
246
+ | `INV-004` | A failure while building an event never reaches the caller as an exception or a partial event: it becomes one error log line and no event. | The `try`/`catch` and the `null` check in `onWebexApiEvent` (`MOD-007`). | `src/attachmentActions.js` | None found |
247
+
248
+ ## Concurrency and reactive flow
249
+
250
+ - Execution model: one JavaScript event loop; `create`, `get`, and `listen` return promises.
251
+ `onWebexApiEvent` and `getattachmentActionEvent` are synchronous, so each `created` event is
252
+ triggered while Mercury is still delivering its activity.
253
+ - Ordering guarantees: events are triggered in the order Mercury emits the activities, because no
254
+ event waits for a request.
255
+ - Parallel work: none inside the plugin; record calls are independent.
256
+ - Idempotency and retry: `get` is a read and safe to repeat; `create` posts a new attachment action
257
+ each time. Nothing is retried here.
258
+ - Fire-and-forget work: none; the event path starts no promise.
259
+ - Shared-state protection: `this.eventEnvelope` is replaced by each `listen()` and read by each event;
260
+ both run on the one event loop.
261
+
262
+ ## Protocol and wire format
263
+
264
+ | Message or frame | Version | Producer or serializer | Consumer or parser | Compatibility and ordering rule |
265
+ | ---------------- | ------- | ---------------------- | ------------------ | ------------------------------- |
266
+ | `POST <hydra>/attachment/actions` with the attachment action as JSON body | Unversioned path under the catalog URL | `create` | Webex REST API | The caller's object as given; the JSDoc names `type`, `messageId`, and `inputs` |
267
+ | `GET <hydra>/attachment/actions/<id>` | Unversioned | `get` | Webex REST API | The id is interpolated without URL encoding |
268
+ | Attachment action object | — | Webex REST API | Callers | The JSDoc typedef names `id`, `messageId`, `type`, `inputs`, `personId`, `roomId`, and `created` |
269
+ | Socket activity `{id, verb, published, actor.entryUUID, object.objectType, object.inputs, parent.id, target.id, target.url}` | — | Mercury, decrypted by the conversation transformer | `getattachmentActionEvent` | Only `verb` `cardAction` is read further |
270
+ | Event `{createdBy, orgId, resource, ownedBy, status, created, data, event, actorId}` | — | `createEventEnvelope` plus `getattachmentActionEvent` | `on('created')` listeners | `resource` is `attachmentActions`, `ownedBy` `creator`, `status` `active`, `event` `created`; `data` holds `id`, `messageId`, `personId`, `roomId`, `created`, `type`, and `inputs` when present; it holds no `personEmail` |
271
+
272
+ ## Caller-visible failure modes
273
+
274
+ | Condition | Signal or result | Caller behavior | Retry or recovery | Evidence |
275
+ | --------- | ---------------- | --------------- | ----------------- | -------- |
276
+ | A Hydra request fails | `create` or `get` rejects with the webex-core request error | Handle the error | Call again | `src/attachmentActions.js` |
277
+ | `get` is called with `undefined` or `null` | Throws a `TypeError` synchronously when it reads `.id`, before any promise exists | Pass a record or an id | — | `src/attachmentActions.js` |
278
+ | `mercury.connect()` rejects | `listen()` rejects | Handle the error | Call `listen()` again | `src/attachmentActions.js` |
279
+ | The current-user lookup inside `createEventEnvelope` fails | The envelope resolves `undefined` (common MOD-011) and `listen()` still resolves; every later `cardAction` activity fails to build, logs the conversion error line, and triggers no event | No signal reaches the caller; watch the logger | Call `listen()` again once `webex.people.get('me')` succeeds | `src/attachmentActions.js` |
280
+ | An activity lacks `actor`, `object`, `parent`, or `target`, or the target URL has no known cluster | `webex.logger.error` logs `Unable to generate SDK event from mercury 'socket activity for attachmentAction:created event: <message>`; no event | No signal reaches the caller; watch the logger | — | `src/attachmentActions.js` |
281
+ | An event has no `data.activity` | `onWebexApiEvent` throws a `TypeError` outside the catch; Mercury's `_emit` catches and logs it | — | — | `src/attachmentActions.js` |
282
+ | The conversation plugin cannot decrypt the card inputs | The event is triggered with `data.inputs` set to the conversation plugin's `decryptionFailureMessage` string instead of an object; the conversation plugin logs a warning | Check the type of `data.inputs` | — | `src/attachmentActions.js`; internal-plugin-conversation src/decryption-transforms.js |
283
+
284
+ ## Pitfalls and constraints
285
+
286
+ - Each `listen()` call adds another Mercury listener, so calling it twice triggers every event twice.
287
+ `stopListening()` with no arguments, inherited from the ampersand event model, removes every listener
288
+ the plugin registered; it does not disconnect Mercury. The `listen` JSDoc example and the integration
289
+ spec call it with `off('created')`.
290
+ - The top-level `created` of an event is the time `listen()` built the envelope, shared by every event;
291
+ the time of the submit is `data.created`.
292
+ - The `debug` trace in `onWebexApiEvent` prints the whole event, card inputs included, whenever the
293
+ `DEBUG` environment variable enables `attachmentActions`.
294
+ - `create` passes the caller's object to Hydra unchecked; a missing `messageId` or `type` is reported
295
+ only by the Hydra error.
296
+ - JSDoc drift: `listen` is filed under `@memberof Messages` and the private methods under
297
+ `AttachmentAction`; `get` types its argument as `{string}` while it also takes a record; the `create` and `get`
298
+ examples call `webex.rooms`, which this package does not declare, and the `create` example has
299
+ syntax errors.
300
+ - The integration spec's `before` hook does not return the inner `people.get('me')` chain, so
301
+ `buttonPusher` and `messageSender` may still be unset when the first case starts.
302
+ - `test:style` reports one warning, `@typescript-eslint/no-var-requires` for the `debug` require in
303
+ `src/attachmentActions.js`, and prints "File ignored" for this specification.
304
+
305
+ ## Module-specific rules
306
+
307
+ - Do: send every attachment action request to service `hydra` through `this.request` so webex-core
308
+ interceptors and the catalog apply.
309
+ - Do: build ids only with `constructHydraId` and the cluster from `getHydraClusterString`, so
310
+ `INV-002` holds.
311
+ - Do: keep every field assignment of an event inside the `try` of `getattachmentActionEvent`
312
+ (`INV-004`).
313
+ - Do not: add fields to an event without deep-cloning the stored envelope first (`INV-003`).
314
+ - Do not: change the event name `created`, the `resource` `attachmentActions`, or the registered name;
315
+ listeners and the socket sample rely on them.
316
+ - Do not: log card inputs, ids, or email addresses through `webex.logger`; only the fixed conversion
317
+ error line is logged today.
318
+
319
+ ## Export stability
320
+
321
+ | Export or entry point | Consumer | Stability | Versioning and deprecation rule | Declaration or API report |
322
+ | --------------------- | -------- | --------- | ------------------------------- | ------------------------- |
323
+ | Import side effect: public plugin `attachmentActions` | `webex`, `webex-node` | Public | No rule is declared in the package | `src/index.js` |
324
+ | Default export `AttachmentActions`, `create`, `get`, `listen`, and the `created` event | Applications | Public | Same | `src/index.js`, `src/attachmentActions.js` |
325
+
326
+ The build writes JavaScript only; `package.json` has no `types` entry, so no declarations or API
327
+ report are published.
328
+
329
+ ## Key design trade-off
330
+
331
+ | Chosen trade-off | Preserved invariant or benefit | Cost or limitation | Decision evidence |
332
+ | ---------------- | ------------------------------ | ------------------ | ----------------- |
333
+ | Events from the Mercury socket instead of webhooks | No public endpoint needed; webhook-shaped payloads (`INV-001`, `INV-003`) that can carry `inputs` | Needs `spark:all` and `spark:kms`; a failed envelope turns every event into a log line | `src/attachmentActions.js` JSDoc of listen |
334
+ | Events built from the activity alone, with no Hydra fetch | No extra request per event; events keep socket order (`INV-002`) | The event has no `personEmail` and none of the fields a Hydra read would add | `src/attachmentActions.js` comment in getattachmentActionEvent |
335
+
336
+ ## Verification
337
+
338
+ | Requirement or invariant | Test level | Positive evidence | Negative or boundary evidence | Gap |
339
+ | ------------------------ | ---------- | ----------------- | ----------------------------- | --- |
340
+ | `MOD-001` | None run | `test/integration/spec/attachmentActions.js` (not run) | None found | No unit case |
341
+ | `MOD-002`, `MOD-003` | None run | `test/integration/spec/attachmentActions.js` #create() and #get() (not run) | None found | The request options and the `items` branch of `get` have no case |
342
+ | `MOD-004` to `MOD-006`, `INV-001` to `INV-003` | None run | `test/integration/spec/attachmentActions.js` created-event checks (not run) | None found | The verb filter, the id construction, and the conditional `inputs` have no case |
343
+ | `MOD-007`, `INV-004` | None run | None found | None found | The conversion error path has no case |
344
+
345
+ The package has no unit tests: `package.json` defines no `test:unit` script and there is no
346
+ `test/unit` directory. It defines no `test:integration` script either, so mocha never runs
347
+ `test/integration/spec/attachmentActions.js`. `test:browser:broken` runs that spec through karma and
348
+ reported 0 tests on 2026-11-13 under Node 22.14, because the karma bundle failed to parse `isbot`,
349
+ while still exiting 0. The aggregate `test` script exits 1 at the missing `test:unit`. `build:src`,
350
+ `build`, and `test:style` exit 0. A module specification is complete only when its public surface,
351
+ invariants, failure modes, and test evidence agree with the implementation. Generator-side field
352
+ measurement is complete (100%, assessed 2026-11-13); independent validation passed with warnings
353
+ (0 Blocking, 2 Important). The module stays Partial pending the command-role and unit-test follow-ups,
354
+ a unit suite, and a characterization baseline.