cli-confirm-protocol 7.0.31 → 7.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/broker.mjs +19 -2
- package/package.json +1 -1
- package/skill/SKILL.md +1 -1
- package/skill/skill.json +1 -1
package/broker.mjs
CHANGED
|
@@ -24,6 +24,7 @@ const VALIDATION_STATES = new Set(['passed', 'failed', 'incomplete'])
|
|
|
24
24
|
const EVALUATION_SCHEMA = 'skill-automatic-evaluation/1.0'
|
|
25
25
|
const IDENTIFIER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/
|
|
26
26
|
const REQUEST_SCHEMA_PATTERN = /^([A-Za-z0-9.-]+\.skill)\.request\/([0-9]+\.[0-9]+)$/
|
|
27
|
+
const TRANSPORT_ERROR_CODE_PATTERN = /^[A-Z][A-Z0-9_]{1,63}$/
|
|
27
28
|
|
|
28
29
|
function asObject(value, label) {
|
|
29
30
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
@@ -222,6 +223,20 @@ function invocationRequest(context, operation, input) {
|
|
|
222
223
|
}
|
|
223
224
|
}
|
|
224
225
|
|
|
226
|
+
export function transportFailureCode(error) {
|
|
227
|
+
const inspected = new Set()
|
|
228
|
+
let candidate = error
|
|
229
|
+
while (candidate && typeof candidate === 'object' && !inspected.has(candidate)) {
|
|
230
|
+
inspected.add(candidate)
|
|
231
|
+
const code = typeof candidate.code === 'string' ? candidate.code.trim() : ''
|
|
232
|
+
if (TRANSPORT_ERROR_CODE_PATTERN.test(code)) return code
|
|
233
|
+
const name = typeof candidate.name === 'string' ? candidate.name.trim() : ''
|
|
234
|
+
if (name === 'AbortError' || name === 'TimeoutError') return name
|
|
235
|
+
candidate = candidate.cause
|
|
236
|
+
}
|
|
237
|
+
return 'UNKNOWN_TRANSPORT_ERROR'
|
|
238
|
+
}
|
|
239
|
+
|
|
225
240
|
export async function invokeOfficialSkill(context, operation, input, dependencies) {
|
|
226
241
|
const environment = asObject(dependencies.environment, 'broker environment')
|
|
227
242
|
if (typeof dependencies.request !== 'function') {
|
|
@@ -237,8 +252,10 @@ export async function invokeOfficialSkill(context, operation, input, dependencie
|
|
|
237
252
|
body: JSON.stringify({ input: requestEnvelope }),
|
|
238
253
|
signal: AbortSignal.timeout(CALL_TIMEOUT_MS),
|
|
239
254
|
})
|
|
240
|
-
} catch {
|
|
241
|
-
throw new Error(
|
|
255
|
+
} catch (error) {
|
|
256
|
+
throw new Error(
|
|
257
|
+
`${context.displayName} ${operation} invocation failed: network transport ${transportFailureCode(error)}`,
|
|
258
|
+
)
|
|
242
259
|
}
|
|
243
260
|
const payload = await responsePayload(response, `${context.displayName} ${operation} response`)
|
|
244
261
|
if (!response.ok || payload.ok !== true) {
|
package/package.json
CHANGED
package/skill/SKILL.md
CHANGED