MCPcopy Create free account
hub / github.com/github/gh-aw / resolveEntityNumber

Function resolveEntityNumber

actions/setup/js/close_entity_helpers.cjs:154–200  ·  view source on GitHub ↗

* Resolve the entity number based on target configuration and context * @param {EntityConfig} config - Entity configuration * @param {string} target - Target configuration ("triggering", "*", or explicit number) * @param {any} item - The agent output item * @param {boolean} isEntityContext - Whe

(config, target, item, isEntityContext)

Source from the content-addressed store, hash-verified

152 * @returns {{success: true, number: number} | {success: false, message: string}}
153 */
154function resolveEntityNumber(config, target, item, isEntityContext) {
155 if (target === "*") {
156 const targetNumber = item[config.numberField];
157 if (targetNumber) {
158 const parsed = parseInt(targetNumber, 10);
159 if (isNaN(parsed) || parsed <= 0) {
160 return {
161 success: false,
162 message: `Invalid ${config.displayName} number specified: ${targetNumber}`,
163 };
164 }
165 return { success: true, number: parsed };
166 }
167 return {
168 success: false,
169 message: `Target is "*" but no ${config.numberField} specified in ${config.itemTypeDisplay} item`,
170 };
171 }
172
173 if (target !== "triggering") {
174 const parsed = parseInt(target, 10);
175 if (isNaN(parsed) || parsed <= 0) {
176 return {
177 success: false,
178 message: `Invalid ${config.displayName} number in target configuration: ${target}`,
179 };
180 }
181 return { success: true, number: parsed };
182 }
183
184 // Default behavior: use triggering entity
185 if (isEntityContext) {
186 const number = context.payload[config.contextPayloadField]?.number;
187 if (!number) {
188 return {
189 success: false,
190 message: `${config.displayNameCapitalized} context detected but no ${config.displayName} found in payload`,
191 };
192 }
193 return { success: true, number };
194 }
195
196 return {
197 success: false,
198 message: `Not in ${config.displayName} context and no explicit target specified`,
199 };
200}
201
202/**
203 * Escape special markdown characters in a title

Callers 2

processCloseEntityItemsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected