@firedrill-tools/salesforce 0.1.1

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 (41) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +156 -0
  3. package/firedrill/agent.target.json +17 -0
  4. package/firedrill/api-limit-exceeded.scenario.json +11 -0
  5. package/firedrill/baseline.scenario.json +2213 -0
  6. package/firedrill/conformance.suite.json +23 -0
  7. package/firedrill/row-locked.scenario.json +11 -0
  8. package/firedrill/salesforce-api-limit-exceeded.drill.json +336 -0
  9. package/firedrill/salesforce-collections-composite.drill.json +277 -0
  10. package/firedrill/salesforce-denied.drill.json +74 -0
  11. package/firedrill/salesforce-fresh-install.drill.json +86 -0
  12. package/firedrill/salesforce-inactive-user.drill.json +43 -0
  13. package/firedrill/salesforce-invalid-session.drill.json +336 -0
  14. package/firedrill/salesforce-large-responses.drill.json +138 -0
  15. package/firedrill/salesforce-mcp-aliases.drill.json +156 -0
  16. package/firedrill/salesforce-profile-permissions.drill.json +241 -0
  17. package/firedrill/salesforce-read-only.drill.json +154 -0
  18. package/firedrill/salesforce-rest-flow.drill.json +714 -0
  19. package/firedrill/salesforce-row-locked.drill.json +227 -0
  20. package/firedrill/salesforce-sharing.drill.json +201 -0
  21. package/firedrill/salesforce-soql.drill.json +139 -0
  22. package/firedrill/salesforce-tight-limits.drill.json +336 -0
  23. package/firedrill/salesforce-write-committed-lost.drill.json +176 -0
  24. package/firedrill/tight-limits.scenario.json +41 -0
  25. package/firedrill/tools/salesforce/behavior.mjs +637 -0
  26. package/firedrill/tools/salesforce/lib/bytes.mjs +56 -0
  27. package/firedrill/tools/salesforce/lib/ids.mjs +68 -0
  28. package/firedrill/tools/salesforce/lib/match.mjs +352 -0
  29. package/firedrill/tools/salesforce/lib/records.mjs +506 -0
  30. package/firedrill/tools/salesforce/lib/schema.mjs +429 -0
  31. package/firedrill/tools/salesforce/lib/search.mjs +92 -0
  32. package/firedrill/tools/salesforce/lib/soql.mjs +1119 -0
  33. package/firedrill/tools/salesforce/lib/state.mjs +378 -0
  34. package/firedrill/tools/salesforce/lib/wire.mjs +109 -0
  35. package/firedrill/tools/salesforce/salesforce.tool.json +3939 -0
  36. package/firedrill/world.json +2705 -0
  37. package/firedrill/write-committed-lost.scenario.json +11 -0
  38. package/firedrill.json +5 -0
  39. package/package.json +64 -0
  40. package/starter.json +2212 -0
  41. package/test/conformance.mjs +1122 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Reload Tech Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,156 @@
1
+ # @firedrill-tools/salesforce
2
+
3
+ A synthetic **Salesforce org** for [Firedrill](https://firedrill.run): one org exposed through the subset of the Salesforce Platform REST API that agents actually use — sObject rows (`/services/data/vXX.X/sobjects/…`), upsert by external id, SOQL `query`/`queryAll` with query locators, parameterized search, sObject Collections, the Composite resource, `limits`, describe, the OpenID Connect `userinfo` endpoint — plus the two data-facing tool names of Salesforce's DX MCP server (`run_soql_query`, `get_username`). Agents that read and write Accounts, Contacts, Leads, Opportunities and Tasks can run against it instead of a real org: Firedrill owns the state, the virtual clock, faults and the evidence; nothing here contacts Salesforce and no e-mail, Chatter post, workflow or trigger ever runs.
4
+
5
+ Backend only (no bundled UI). Browse and edit the state with the Firedrill inspector, the REST routes or the MCP tools.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ firedrill tool add @firedrill-tools/salesforce --install
11
+ firedrill serve
12
+ ```
13
+
14
+ A fresh project receives the starter data (64 rows: the fictional **Brightwater Instruments** org) and an actor with exactly the 20 operation grants. An existing world is not changed: add the grants you need (`packageId: "salesforce"`, one `operationId` per row of the table below) to the actor that will call the Tool, and add the starter rows (or your own) as scenario state.
15
+
16
+ ## Identities
17
+
18
+ An access token acts as one Salesforce **User**; the org then applies that user's **profile** (object permissions) and its **org-wide defaults plus ownership** (sharing). The calling actor is mapped to a user by one attribute:
19
+
20
+ | actor attribute | meaning |
21
+ |---|---|
22
+ | `username` | resolved case-insensitively against `users[].Username`; must belong to an **active** user |
23
+ | *(none)* | the org's default identity (`org.defaultUserId`, seeded as `005Fd0000000001IAA` — Maren Solberg, System Administrator); if that row is gone, the first active user by row id. `firedrill tool add` creates such an actor, so a first run sees the seeded data |
24
+
25
+ A `username` that matches no user, or a deactivated user, fails every operation with `INVALID_SESSION_ID` (HTTP 401, `[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]`). Framework grants decide whether an operation may be called at all (a missing grant is the framework's `denied`, rendered as 403 `API_DISABLED_FOR_ORG`); the profile and the sharing rules below decide what the call may see and change.
26
+
27
+ ### Object permissions and sharing
28
+
29
+ Each `profiles` row carries `objectPermissions[sobjectType] = { create, read, edit, delete, viewAll, modifyAll }`. `User` and `Profile` are readable by every profile and writable by none (`INVALID_TYPE_FOR_OPERATION`). A type the profile cannot read is invisible: absent from the global describe, `NOT_FOUND` on basic info / describe, `INVALID_TYPE` everywhere else (Salesforce's exact "sObject type 'X' is not supported…" wording; 404 on sObject-row routes, 400 on query/search/collections). Missing `create`/`edit`/`delete` rights fail `INSUFFICIENT_ACCESS_OR_READONLY` (403).
30
+
31
+ Record visibility follows `org.orgWideDefaults[sobjectType]` plus ownership:
32
+
33
+ | org-wide default (seeded) | who can read a record | who can edit / delete it |
34
+ |---|---|---|
35
+ | `Private` (Opportunity, Task) | owner; anyone with `viewAll`/`modifyAll` | owner; `modifyAll` |
36
+ | `ReadOnly` — Public Read Only (Account) | every user with object `read` | owner; `modifyAll` |
37
+ | `ReadWrite` — Public Read/Write (Lead) | every user with object `read` | every user with object `edit`/`delete` |
38
+ | `ControlledByParent` (Contact) | as the parent Account; a contact without an Account behaves as `Private` | as the parent Account; without an Account: its owner |
39
+
40
+ A record the caller cannot read behaves as missing (`NOT_FOUND`, absent from queries, search, `recentItems` and collections retrieve); a readable but not editable record fails `INSUFFICIENT_ACCESS_OR_READONLY`. No role hierarchy, sharing rules, manual shares, permission sets, field-level security or territories.
41
+
42
+ ## Starting data
43
+
44
+ Brightwater Instruments (`00DFd0000000001MAA`, a fictional laboratory-equipment maker on `brightwater.example.com`; instance URL `https://brightwater.example.my.salesforce.test`, currency EUR, virtual time 2026-09-14T09:00:00Z):
45
+
46
+ - 4 profiles: System Administrator, Standard User, Read Only, Sales Development Rep (no Opportunity access, read-only Account, no Contact delete).
47
+ - 6 users: Maren Solberg (admin, default identity), Diego Álvarez and Aiko Tanaka (Standard Users), Ben Okafor (SDR), Lena Fischer (Read Only), Jonas Weber (Standard User, **inactive** — still owns records).
48
+ - 10 accounts (one deleted, one parent/subsidiary pair, two sharing the same name, three with `External_Id__c`), 14 contacts (one without an account, one deleted, non-ASCII names, a mixed-case e-mail), 8 leads (one converted), 9 opportunities (stages spread, one open opportunity without an Amount), 8 tasks (one overdue, one completed, Who/What links to contacts, leads, accounts and opportunities).
49
+ - Custom fields: `Account.External_Id__c` (external id, unique), `Account.Customer_Tier__c` (picklist), `Contact.External_Id__c` (external id, unique), `Opportunity.ARR__c` (currency).
50
+
51
+ `starter.json` and `firedrill/baseline.scenario.json` carry the same rows; ids are stable 18-character case-safe Salesforce ids (`001Fd0000000101IAA`, …) and the id counter (`meta/counters`) starts above the seeded record numbers, so a fresh org mints `001Fd0000001001IAA` first.
52
+
53
+ ## Operations
54
+
55
+ All routes accept `Authorization: Bearer <token>` or the legacy `Authorization: OAuth <token>` (the world token). Every `/services/data/{version}/…` route needs `v46.0` … `v66.0` (otherwise `NOT_FOUND`); canonical calls default to `v62.0`. Object-bodied responses and handler-raised errors carry `Sforce-Limit-Info: api-usage=U/M` from the `org` row.
56
+
57
+ | operation | MCP alias | HTTP route |
58
+ |---|---|---|
59
+ | `versions.list` | — | `GET /services/data` |
60
+ | `userinfo.get` | `get_username` | `GET /services/oauth2/userinfo` |
61
+ | `limits.get` | — | `GET /services/data/{version}/limits` |
62
+ | `sobjects.list` | — | `GET /services/data/{version}/sobjects` |
63
+ | `sobjects.basic-info` | — | `GET /services/data/{version}/sobjects/{sobjectType}` |
64
+ | `sobjects.describe` | — (canonical `salesforce.sobjects.describe`, or a composite subrequest `GET …/sobjects/{sobjectType}/describe`; see Limitations) | — |
65
+ | `records.create` | — | `POST /services/data/{version}/sobjects/{sobjectType}` (201 + `Location`) |
66
+ | `records.retrieve` | — | `GET …/sobjects/{sobjectType}/{id}` and `GET …/sobjects/{sobjectType}/{externalIdField}/{value}` (`?fields=` projection incl. `Owner.Name`) |
67
+ | `records.update` | — | `PATCH …/sobjects/{sobjectType}/{id}` (204) |
68
+ | `records.delete` | — | `DELETE …/sobjects/{sobjectType}/{id}` (204, cascades) |
69
+ | `records.upsert` | — | `PATCH …/sobjects/{sobjectType}/{externalIdField}/{value}` (200 with `created`) |
70
+ | `query.execute` | `run_soql_query` | `GET …/query?q=` and `GET …/queryAll?q=` (`Sforce-Query-Options: batchSize=N`) |
71
+ | `query.more` | — | `GET …/query/{locator}` and `GET …/queryAll/{locator}` |
72
+ | `search.parameterized` | — | `POST …/parameterizedSearch` |
73
+ | `collections.create` | — | `POST …/composite/sobjects` |
74
+ | `collections.retrieve` | — | `POST …/composite/sobjects/{sobjectType}` and `GET …?ids=&fields=` |
75
+ | `collections.update` | — | `PATCH …/composite/sobjects` |
76
+ | `collections.delete` | — | `DELETE …/composite/sobjects?ids=` |
77
+ | `collections.upsert` | — | `PATCH …/composite/sobjects/{sobjectType}/{externalIdField}` |
78
+ | `composite.execute` | — | `POST …/composite` |
79
+
80
+ Canonical names (`salesforce.<operation>`) are always exposed over MCP, direct and `POST /v1/operations/salesforce/<operation>`; canonical inputs fold the path/query parameters into one object (`sobjectType`, `id`, `externalIdField`, `value`, `record`, `q`, `fields`, `ids`, `version`, …) and canonical outputs are the Salesforce JSON shapes plus a `_limitInfo` string that the REST codec lifts into the header.
81
+
82
+ ### Records
83
+
84
+ Seven sObjects: `Account`, `Contact`, `Lead`, `Opportunity`, `Task` (writable) and `User`, `Profile` (read only), with a documented subset of the standard fields (see the describe output) plus the custom fields from the `custom-fields` rows. Writes validate like Salesforce: unknown field → `INVALID_FIELD`, read-only/system field → `INVALID_FIELD_FOR_INSERT_UPDATE`, missing required field (`Name`, `LastName`, `Company`, `StageName`, `CloseDate`) → `REQUIRED_FIELD_MISSING`, wrong JSON type → `JSON_PARSER_ERROR`, over-length text or bad e-mail → `INVALID_FIELD`, restricted picklist → `INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST`, malformed id → `MALFORMED_ID`, id of the wrong sObject → `FIELD_INTEGRITY_EXCEPTION`, missing/deleted/inactive target → `INVALID_CROSS_REFERENCE_KEY`, duplicate unique value → `DUPLICATE_VALUE`, converted lead → `CANNOT_UPDATE_CONVERTED_LEAD`, the seeded validation rule *Closed Won opportunities must have an Amount* → `FIELD_CUSTOM_VALIDATION_EXCEPTION`. `OwnerId` defaults to the caller; `Lead.Status`, `Task.Status`/`Priority` default; `Contact`/`Lead.Name`, `Opportunity.IsClosed`/`IsWon`/`ForecastCategory`/default `Probability` and `Task.IsClosed` derive on every write. Deletes are soft (recycle bin, visible through `queryAll`) and cascade as Salesforce does: Account → Contacts, Opportunities, Tasks; Contact/Lead → Tasks (`WhoId`); Opportunity → Tasks (`WhatId`). Ids may be given in 15- or 18-character form; 18 characters are always returned. A 15-character id is case-sensitive; an 18-character id is case-insensitive as in Salesforce: its suffix (any case) re-cases the first 15 characters, so `001fd0000000101iaa` resolves to `001Fd0000000101IAA`. A suffix that is not a valid checksum for the body (a case bit set on a digit position, or a character outside `A–Z0–5`, e.g. `…101IAB`) → `MALFORMED_ID`; a valid suffix that re-cases the body to an id that does not exist (e.g. `001Fd0000000101AAA` → `001fd0000000101`) → `NOT_FOUND`.
85
+
86
+ ### SOQL subset
87
+
88
+ `SELECT <fields> FROM <sObject> [WHERE …] [ORDER BY f [ASC|DESC] [NULLS FIRST|LAST], …] [LIMIT n] [OFFSET n]` and `SELECT COUNT() FROM …`. Fields: API names, relationship fields **one level** deep (`Account.Name`, `Owner.Username`, `CreatedBy.Name`, `Who.Name`, `Who.Type`, `What.Name`, `Profile.Name`), `FIELDS(ALL|STANDARD|CUSTOM)` (`ALL`/`CUSTOM` need `LIMIT ≤ 200`), child subqueries for `Account.Contacts`, `Account.Opportunities`, `Account.Tasks`, `Contact.Tasks`, `Lead.Tasks`, `Opportunity.Tasks`. WHERE: `=`, `!=`, `<>`, `<`, `<=`, `>`, `>=`, `LIKE` (`%` any sequence, `_` one character, `\%` and `\_` literal; case-insensitive; a `%`-free segment containing `_` at most 256 characters), `IN`, `NOT IN`, `AND`, `OR`, `NOT`, parentheses (nesting of parentheses and `NOT` up to 100 levels); strings with Salesforce's escapes (`\'`, `\"`, `\\`, `\n`, `\r`, `\t`, `\b`, `\f`, `\%`, `\_`; any other backslash sequence → `MALFORMED_QUERY`), numbers, `TRUE`/`FALSE`, `NULL`, dates, datetimes, and the date literals `TODAY`, `YESTERDAY`, `TOMORROW`, `THIS_WEEK`, `LAST_WEEK`, `NEXT_WEEK`, `THIS_MONTH`, `LAST_MONTH`, `NEXT_MONTH`, `THIS_YEAR`, `LAST_YEAR`, `LAST_90_DAYS`, `NEXT_90_DAYS`, `LAST_N_DAYS:n`, `NEXT_N_DAYS:n`, `LAST_N_MONTHS:n`, `NEXT_N_MONTHS:n`. Long text areas (`Description` on every sObject: textarea longer than 255 characters) cannot be filtered or sorted, as in Salesforce: `WHERE`/`ORDER BY` on them fails `INVALID_FIELD` (`field 'Description' can not be filtered in query call` / `… can not be sorted in a query call`), and describe reports them `filterable: false`, `sortable: false`; search still scans them. A string literal holds at most 4,000 characters (longer → `MALFORMED_QUERY`), as in Salesforce. Text comparisons are case-insensitive; the default sort is `ASC NULLS FIRST`; `ORDER BY` takes at most 32 fields, a statement at most 100,000 characters, `LIMIT`, `OFFSET` and `LAST_N_DAYS:n`-style counts are 32-bit integers (`LIMIT 99999999999999999999` or `LIMIT 2147483648` → `MALFORMED_QUERY` `numeric value out of range: …`; `OFFSET` above 2,000 → `MALFORMED_QUERY` `NUMBER_OUTSIDE_VALID_RANGE`), and a field selected twice fails `MALFORMED_QUERY` (`duplicate field selected: …`), as in Salesforce; unsorted results come in creation order. Everything else (`GROUP BY`, `HAVING`, aggregates other than bare `COUNT()`, semi-joins, `TYPEOF`, `WITH`, `USING SCOPE`, `FOR UPDATE`, `ALL ROWS`, `INCLUDES`, functions, deeper paths, fiscal/week literals) fails `MALFORMED_QUERY` with an explicit "unsupported" message; unknown fields fail `INVALID_FIELD`, unknown sObjects `INVALID_TYPE`.
89
+
90
+ Paging: `Sforce-Query-Options: batchSize=N` (default 2000). When rows remain, `done: false` and `nextRecordsUrl: /services/data/{version}/query/{locator}` follow; the locator is self-contained (`01g` + base64url of `{ q, includeDeleted, offset, batchSize, userId }` + `-offset`), so `query.more` re-runs the query deterministically. A locator that does not decode, belongs to another user or points past the end fails `INVALID_QUERY_LOCATOR`.
91
+
92
+ Response size: the framework refuses HTTP responses over 1 MiB, so every body whose size depends on stored rows is measured in encoded UTF-8 bytes of the JSON actually sent, row by row, before the row is admitted (a Tool budget of 900,000 bytes). A query page stops before it would pass the budget — like Salesforce, which returns smaller batches for wide rows — with `done: false` and a `nextRecordsUrl` that resumes at the first row not returned, so every row appears exactly once however wide or non-ASCII the rows are. A single row that alone would pass the budget (for example an Account whose child subquery returns many 32,000-character `Description` values) fails 400 `LIMIT_EXCEEDED` (`The response would exceed the 900,000-byte response budget of this Tool; …`) instead of a truncated row. Parameterized search and sObject Collections retrieve have no paging, so results past the budget fail the same `LIMIT_EXCEEDED`.
93
+
94
+ Error text: caller-supplied names and values quoted in error messages (unknown columns, sObject types, relationships, tokens, picklist values, ids, references) are clipped to 255 characters ending in `…`, every `fields` entry is clipped the same way (item errors declare `maxLength` 255), and a message never exceeds 3,000 characters. The error code and HTTP status are unchanged, so a 6,000-character unknown field answers Salesforce's 400 `INVALID_FIELD` rather than a framework 500.
95
+
96
+ ### Parameterized search
97
+
98
+ `POST …/parameterizedSearch` with `{ q, sobjects?: [{ name, fields?, where?, orderBy?, limit? }], in?: ALL|NAME|EMAIL|PHONE|SIDEBAR, fields?, overallLimit?, defaultLimit? }`. Terms (quoted phrases stay together) must each match as a case-insensitive prefix of a token (split on whitespace and `@ . / _ - , ; : ( ) " '`) of the scoped fields; `*` matches any run of non-whitespace characters and `?` one non-whitespace character. An sObject may appear only once in `sobjects` (a repeat → `MALFORMED_QUERY`, `MALFORMED_SEARCH: duplicate sObject type …`). Results respect sharing and are grouped by sObject in the order given; `Id` and `Name` (`Subject` for Task) are returned when `fields` is absent. A search string (`q` after trimming) shorter than two or longer than 200 characters, a bad `where`/`orderBy` → `MALFORMED_QUERY`.
99
+
100
+ ### Collections and composite
101
+
102
+ sObject Collections take up to 200 records (`attributes.type` per record, mixed types allowed) or 2,000 ids for retrieve, and answer 200 with a per-item array: `{ id, success, errors: [{ statusCode, message, fields }] }` (`created` on upsert); with `allOrNone: true` every write is rolled back and the would-be successes become `ALL_OR_NONE_OPERATION_ROLLED_BACK`. Composite takes up to 25 subrequests (at most 5 queries) over `sobjects/{type}` (POST create, GET basic info), `sobjects/{type}/{id}` (GET/PATCH/DELETE), `sobjects/{type}/{extIdField}/{value}` (GET/PATCH), `sobjects/{type}/describe`, `query?q=`, `queryAll?q=`, `limits`, with `@{referenceId.id}`, `@{ref.Field}`, `@{ref.records[N].Field}` and `@{ref.totalSize}` substitution in urls and string body values; results come back as `{ compositeResponse: [{ body, httpHeaders, httpStatusCode, referenceId }] }`; under `allOrNone` a failure rolls everything back and marks the siblings `PROCESSING_HALTED`; an unsupported subrequest url is a per-item 404, an unresolvable reference a per-item 400 `INVALID_INPUT`. The whole composite response shares the 900,000-byte budget: a `query`/`queryAll` subrequest returns a smaller page (`done: false`, working `nextRecordsUrl`) sized to the bytes left, and a GET subrequest (or an error entry) that no longer fits becomes a per-item 400 `[{"errorCode":"LIMIT_EXCEEDED","message":"The response would exceed the 900,000-byte response budget of this Tool; …"}]` (counts as a failure under `allOrNone`); write results are small and always admitted. Five `SELECT Id FROM Account` subrequests over 2,009 accounts answer 200 with three full 2,000-row pages, a 1,189-row page and one `LIMIT_EXCEEDED` entry (900,173 bytes). Item-level failures inside these 200 envelopes are not Firedrill `tool_error` outcomes — assert on state or events instead.
103
+
104
+ ## Events and faults
105
+
106
+ | id | kind | when |
107
+ |---|---|---|
108
+ | `record.created` | event | a record was inserted (`records.create`, upsert-create, collections, composite) — `{ sobjectType, id, ownerId, createdById }` |
109
+ | `record.updated` | event | stored fields actually changed — `{ sobjectType, id, changedFields }` (derived fields included) |
110
+ | `record.deleted` | event | a record was soft-deleted, including cascaded children (`cascadedFrom` = the parent id) |
111
+ | `api-limit-exceeded` | fault (`before`, all 20 operations) | HTTP 403 `[{"message":"TotalRequests Limit exceeded.","errorCode":"REQUEST_LIMIT_EXCEEDED"}]` |
112
+ | `row-locked` | fault (`before`, the nine writes) | HTTP 400 `UNABLE_TO_LOCK_ROW`; nothing is written, reads keep working |
113
+ | `write-committed-lost` | fault (`after_commit`, `records.create`, `records.upsert`, `collections.create`, `collections.upsert`) | the insert **commits** (row and `record.created` exist) but the caller sees 503 `SERVER_UNAVAILABLE`; a naive retry of an Account with `External_Id__c` then fails `DUPLICATE_VALUE`, a retry of a plain Contact silently duplicates — the trap an agent must handle by re-reading |
114
+
115
+ Select a fault in a scenario: `"faults": [{ "packageId": "salesforce", "faultId": "row-locked" }]`. Events for writes rolled back inside an `allOrNone` envelope are never emitted.
116
+
117
+ ## Limits
118
+
119
+ Every scan is bounded by `org.limits.maxRowsPerNamespace` (default and hard cap 10,000). A namespace beyond the bound fails the operation with `LIMIT_EXCEEDED` (`state exceeds the supported bound of N rows for <namespace>`) — never a silently truncated result; the conformance suite lowers the bound (`tight-limits` scenario) to prove it. LIKE patterns and search wildcards are matched without regular expressions, in time linear in the stored value's length (LIKE tests its anchored first and last segments on the raw value before anything else, folds each row's value at most once per query however many clauses read it, and locates `%`-free literal segments with Knuth–Morris–Pratt and segments containing `_` with a bit-parallel automaton; all search terms run as one bit-parallel automaton). A LIKE segment between two `%` wildcards that contains `_` may be at most 256 characters (longer → `MALFORMED_QUERY`; a Tool bound, not a Salesforce one); the leading and trailing segments are compared in place and have no such bound. Because only fields of at most 255 characters are filterable, each WHERE comparison of a row costs bounded work, and one request evaluates at most 500,000 WHERE comparisons × candidate rows, summed over every statement, child subquery and search `where` it runs (a composite shares one allowance); beyond that the statement fails `MALFORMED_QUERY` with Salesforce's `Query is either selecting too many fields or the filter conditions are too complicated` wording (Salesforce reports `QUERY_TOO_COMPLICATED`; a Tool bound). ORDER BY computes each row's sort keys lazily and at most once (a later key is read only for rows whose earlier keys tie), and one request computes at most 200,000 sort keys across all its statements, subqueries and search `orderBy` clauses (beyond → the same `MALFORMED_QUERY`; a Tool bound). Rows are indexed by id and child subqueries group their children by parent once per query, so relationship reads, sharing checks, subqueries and delete cascades cost one pass over the rows involved, not rows × rows. JSON request bodies nested deeper than 512 levels are refused at decode time with 400 `framework.HTTP_REQUEST_MAPPING_FAILED` (`JSON body nests deeper than 512 levels`) before schema validation recurses. Response bodies are byte-budgeted (see SOQL paging and Collections and composite). `LIMIT_EXCEEDED` also answers more than 200 records per collection call, 2,000 ids per retrieve, 25 composite subrequests or 5 composite queries.
120
+
121
+ ## Compatibility
122
+
123
+ - **Not verified against a real client.** jsforce (`new Connection({ instanceUrl, accessToken, version: "62.0" })`), simple-salesforce (`Salesforce(instance_url=…, session_id=…)`) and the Salesforce DX MCP server (`@salesforce/mcp`) are the intended clients — paths, field names, status codes and the error-array envelope follow the Salesforce REST API Developer Guide for the implemented subset — but none has been run against this Tool; the manifest `compatibility` array is empty. The two MCP aliases reproduce `@salesforce/mcp`'s tool names and accept its documented argument names (`query`, `usernameOrAlias`, `directory`, `useToolingApi`, `defaultTargetOrg`, `defaultDevHub`) as recalled from its published README, not verified against the running server (it is a stdio process over the `sf` CLI auth store).
124
+ - Authentication is the world token (`Bearer` or `OAuth` scheme) plus the actor's `username`; the OAuth token/authorize/revoke endpoints are not served and `GET /services/data`, which Salesforce serves without authentication, requires the token here.
125
+ - Connection recipe `salesforce-rest-client` maps `SALESFORCE_INSTANCE_URL` → `FIREDRILL_HTTP_URL` and `SALESFORCE_ACCESS_TOKEN` → `FIREDRILL_HTTP_TOKEN` for pointing an existing agent's environment seam at the Tool.
126
+ - MCP results carry the JSON value in the text content block; `structuredContent` must be an object, so array-shaped operations (`versions.list`, the collections) and their error outcomes arrive wrapped as `{ "result": … }`. Arguments are validated against the operation's input schema by the MCP layer before the Tool runs.
127
+ - Content type is `application/json;charset=UTF-8`; `Sforce-Limit-Info` is emitted on object-bodied successes and handler-raised errors only (array bodies, framework outcomes and fault-injected errors have no carrier — wire codecs are pure and have no state).
128
+
129
+ ## Limitations
130
+
131
+ - A bounded synthetic subset: 20 operations, 23 routes, seven sObjects (five writable) with a documented field subset (no compound `BillingAddress`/`MailingAddress`, formula, roll-up, rich-text, multi-select or geolocation fields; picklists are restricted; the only validation rule is `Closed_Won_Requires_Amount`). Everything else answers the framework's 404 (or 405 where only other methods exist on the path): no lead conversion, undelete, `updated`/`deleted` tracking, full SOSL `/search`, `composite/batch|tree|graph`, Bulk API, Tooling/Metadata API, Apex REST, Chatter, UI API, reports, list views, `recent`, layouts, quick actions, blobs, Case/Campaign/Event/Note/Product/Pricebook objects, custom objects (custom **fields** on the seeded objects only), duplicate-rule blocking, workflow/flow/trigger side effects, the `/services/data/vXX.X/` resource index or any other `@salesforce/mcp` tool.
132
+ - **Malformed percent-encoding in a path.** A plain route whose path segment is not valid percent-encoded UTF-8 (e.g. `GET …/sobjects/Account/001%E0%A4%A`) is answered by the framework with 404 `framework.HTTP_ROUTE_NOT_FOUND` before the Tool runs (the route matcher discards undecodable segments), not Salesforce's `[{"errorCode":"NOT_FOUND"}]` envelope. Inside `POST …/composite` the Tool parses subrequest urls itself: an undecodable path segment is a per-item 404 `NOT_FOUND`, an undecodable `q` a per-item 400 `MALFORMED_QUERY`, an undecodable `fields` a per-item 400 `INVALID_FIELD`, and an undecodable parameter the route does not read is ignored. `GET …/query?q=` and `…/queryAll?q=` with malformed encoding reach the Tool with the undecodable bytes replaced by U+FFFD (the framework does not expose the raw bytes), so any SOQL statement containing U+FFFD fails 400 `MALFORMED_QUERY` ("the q parameter is not valid percent-encoded UTF-8") instead of running with a corrupted literal. This also rejects a correctly encoded U+FFFD (`%EF%BF%BD`) and a literal U+FFFD sent through `run_soql_query` or canonical `query.execute`.
133
+ - **Route-overlap consequence.** The framework rejects `GET …/sobjects/{type}/describe`, `…/updated` and `…/deleted` because they overlap the record-retrieve template, so those literal segments reach `records.retrieve` and fail `MALFORMED_ID` 400. Full describe is available canonically, over MCP and as a composite subrequest.
134
+ - Upsert by external id answers 200 on both branches (Salesforce: 201 on create) because a route declares one success status; the body always carries `created`. `MALFORMED_ID` is 400 on every route (Salesforce answers 404 on some GET paths). Salesforce's `STRING_TOO_LONG`, `INVALID_EMAIL_ADDRESS`, `NUMBER_OUTSIDE_VALID_RANGE`, `INACTIVE_OWNER_OR_USER` and `MALFORMED_SEARCH` are folded into `INVALID_FIELD`, `MALFORMED_QUERY` and `INVALID_CROSS_REFERENCE_KEY` (the original code is named in the message).
135
+ - `Sforce-Query-Options: batchSize` is honoured down to 1 (Salesforce clamps to 200–2000) so paging can be exercised against small worlds; query locators re-run the query, so rows written between pages are visible (Salesforce cursors are snapshots). Date literals are evaluated in UTC with Sunday-start weeks (Salesforce uses the user's time zone and locale); `OFFSET` ≤ 2,000; `Probability` is defaulted from the stage but kept when sent explicitly.
136
+ - Ids are Salesforce-shaped (18 characters, real key prefixes, the real case-safe suffix) but the 9-digit body is a decimal counter. `recentItems` is "the five most recently modified visible records", not a per-user MRU. `Sforce-Limit-Info` and `limits.get` are constant decorations from the `org` row (`used` never increments). `_limitInfo` appears in canonical/MCP outputs. `attributes.url`/`nextRecordsUrl` are relative paths and `userinfo.urls` use the `.test` instance URL from the `org` row — the Tool does not know its public base URL.
137
+ - Object permissions come from the profile only; sharing knows org-wide defaults, ownership, `viewAll`/`modifyAll` and Controlled-by-Parent contacts. A multiple-match upsert (Salesforce 300) cannot occur because the seeded external id fields are unique. The recycle bin is permanent (no undelete, no purge).
138
+
139
+ ## Develop
140
+
141
+ ```sh
142
+ firedrill validate
143
+ firedrill tool test salesforce
144
+ firedrill serve --scenario baseline --actor admin
145
+ npm pack --ignore-scripts
146
+ ```
147
+
148
+ The conformance suite (`firedrill/conformance.suite.json`, 15 drills over 8 actors and 5 scenarios, target `test/conformance.mjs` using Node built-ins only) exercises every operation, every declared error on every operation that declares it, the three events and the three faults, and is run twice to prove determinism. The world has eight actors, so `firedrill serve` needs `--actor`.
149
+
150
+ ## Trademarks
151
+
152
+ Salesforce and the Salesforce product names belong to Salesforce, Inc. and are used only to identify the service this package simulates in a test environment. This package is not affiliated with or endorsed by Salesforce.
153
+
154
+ ## License
155
+
156
+ Apache-2.0 — see `LICENSE`.
@@ -0,0 +1,17 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "target": {
4
+ "id": "conformance-agent",
5
+ "kind": "command",
6
+ "bindings": [
7
+ "http",
8
+ "mcp"
9
+ ],
10
+ "executable": "node",
11
+ "arguments": [
12
+ "test/conformance.mjs"
13
+ ],
14
+ "workingDirectory": ".",
15
+ "timeoutMs": 90000
16
+ }
17
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "api-limit-exceeded",
4
+ "title": "The org's daily API allocation is exhausted: every call answers 403 REQUEST_LIMIT_EXCEEDED",
5
+ "faults": [
6
+ {
7
+ "packageId": "salesforce",
8
+ "faultId": "api-limit-exceeded"
9
+ }
10
+ ]
11
+ }