@openclaw/plugin-inspector 0.1.0 → 0.1.2
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/CHANGELOG.md +17 -0
- package/README.md +81 -138
- package/examples/github-actions-plugin-inspector.yml +2 -2
- package/examples/plugin-inspector.config.json +3 -0
- package/package.json +3 -2
- package/src/advanced.js +195 -0
- package/src/api.js +91 -0
- package/src/capture-api.js +180 -12
- package/src/cli.js +69 -27
- package/src/config.js +16 -2
- package/src/index.js +9 -184
- package/src/init.js +150 -0
- package/src/inspector.js +89 -14
- package/src/mock-sdk-capture-runner.js +110 -17
- package/src/runtime-capture-report.js +11 -1
- package/src/sdk-mock.js +1266 -13
- package/src/synthetic-probes.js +153 -9
package/src/synthetic-probes.js
CHANGED
|
@@ -203,6 +203,47 @@ export const defaultSyntheticRegistrationArguments = {
|
|
|
203
203
|
registerTool: [{ name: "fixture_tool", inputSchema: { type: "object", properties: {} }, run: "function" }],
|
|
204
204
|
};
|
|
205
205
|
|
|
206
|
+
export const defaultSyntheticRegistrationProbeInputs = {
|
|
207
|
+
registerCli: {
|
|
208
|
+
execute: commandProbeArgs,
|
|
209
|
+
handler: commandProbeArgs,
|
|
210
|
+
run: commandProbeArgs,
|
|
211
|
+
},
|
|
212
|
+
registerCommand: {
|
|
213
|
+
execute: commandProbeArgs,
|
|
214
|
+
handler: commandProbeArgs,
|
|
215
|
+
run: commandProbeArgs,
|
|
216
|
+
},
|
|
217
|
+
registerGatewayMethod: {
|
|
218
|
+
execute: gatewayProbeArgs,
|
|
219
|
+
handler: gatewayProbeArgs,
|
|
220
|
+
run: gatewayProbeArgs,
|
|
221
|
+
},
|
|
222
|
+
registerHttpRoute: {
|
|
223
|
+
execute: httpRouteProbeArgs,
|
|
224
|
+
handler: httpRouteProbeArgs,
|
|
225
|
+
run: httpRouteProbeArgs,
|
|
226
|
+
},
|
|
227
|
+
registerInteractiveHandler: {
|
|
228
|
+
execute: interactiveProbeArgs,
|
|
229
|
+
handler: interactiveProbeArgs,
|
|
230
|
+
run: interactiveProbeArgs,
|
|
231
|
+
},
|
|
232
|
+
registerService: {
|
|
233
|
+
start: lifecycleProbeArgs,
|
|
234
|
+
stop: lifecycleProbeArgs,
|
|
235
|
+
},
|
|
236
|
+
registerSpeechProvider: {
|
|
237
|
+
speak: speechProbeArgs,
|
|
238
|
+
synthesize: speechProbeArgs,
|
|
239
|
+
},
|
|
240
|
+
registerTool: {
|
|
241
|
+
execute: toolExecuteProbeArgs,
|
|
242
|
+
handler: toolRunProbeArgs,
|
|
243
|
+
run: toolRunProbeArgs,
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
|
|
206
247
|
export function buildSyntheticProbePlan(options = {}) {
|
|
207
248
|
if (!options.capture) {
|
|
208
249
|
throw new TypeError("buildSyntheticProbePlan requires a capture inventory");
|
|
@@ -411,7 +452,7 @@ async function runRegistrationProbes(entry, retainedEntry, captureIndex, options
|
|
|
411
452
|
return [metadataOnlyResult(entry, captureIndex, profile.reason)];
|
|
412
453
|
}
|
|
413
454
|
|
|
414
|
-
const descriptor = retainedEntry.arguments?.[0];
|
|
455
|
+
const descriptor = retainedEntry.arguments?.[0] ?? retainedEntry.returnValue;
|
|
415
456
|
if (!descriptor || typeof descriptor !== "object") {
|
|
416
457
|
return [blockedResult(entry, captureIndex, "captured registration has no object descriptor")];
|
|
417
458
|
}
|
|
@@ -419,7 +460,7 @@ async function runRegistrationProbes(entry, retainedEntry, captureIndex, options
|
|
|
419
460
|
return [blockedResult(entry, captureIndex, `captured registration requires ${profile.option}=true`)];
|
|
420
461
|
}
|
|
421
462
|
|
|
422
|
-
const invocations = registrationInvocations(entry.name, descriptor, profile, options);
|
|
463
|
+
const invocations = registrationInvocations(entry.name, descriptor, retainedEntry.returnValue, profile, options);
|
|
423
464
|
if (invocations.length === 0) {
|
|
424
465
|
return [blockedResult(entry, captureIndex, "captured registration has no supported callable probe")];
|
|
425
466
|
}
|
|
@@ -437,14 +478,21 @@ async function runRegistrationProbes(entry, retainedEntry, captureIndex, options
|
|
|
437
478
|
);
|
|
438
479
|
}
|
|
439
480
|
|
|
440
|
-
function registrationInvocations(registrar, descriptor, profile, options) {
|
|
481
|
+
function registrationInvocations(registrar, descriptor, returnValue, profile, options) {
|
|
441
482
|
const invocations = [];
|
|
483
|
+
const allowReturnValueFallback = descriptor === returnValue;
|
|
442
484
|
|
|
443
485
|
for (const property of profile.callableProperties) {
|
|
444
|
-
|
|
486
|
+
const callable =
|
|
487
|
+
typeof descriptor[property] === "function"
|
|
488
|
+
? descriptor[property]
|
|
489
|
+
: allowReturnValueFallback
|
|
490
|
+
? returnValue?.[property]
|
|
491
|
+
: undefined;
|
|
492
|
+
if (typeof callable === "function") {
|
|
445
493
|
invocations.push({
|
|
446
494
|
label: `${registrar}.${property}`,
|
|
447
|
-
invoke: () => invokeRegistrationCallable(
|
|
495
|
+
invoke: () => invokeRegistrationCallable(callable, registrar, property, options),
|
|
448
496
|
});
|
|
449
497
|
}
|
|
450
498
|
}
|
|
@@ -453,10 +501,9 @@ function registrationInvocations(registrar, descriptor, profile, options) {
|
|
|
453
501
|
|
|
454
502
|
function invokeRegistrationCallable(callable, registrar, property, options) {
|
|
455
503
|
const event = syntheticRegistrationEvent(registrar, property, options);
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
return callable(event);
|
|
504
|
+
const inputFactory = options.registrationProbeInputs?.[registrar]?.[property] ?? defaultSyntheticRegistrationProbeInputs[registrar]?.[property];
|
|
505
|
+
const args = inputFactory ? inputFactory(event, options) : [event];
|
|
506
|
+
return callable(...args);
|
|
460
507
|
}
|
|
461
508
|
|
|
462
509
|
function syntheticRegistrationEvent(registrar, property, options) {
|
|
@@ -478,6 +525,103 @@ function syntheticRegistrationEvent(registrar, property, options) {
|
|
|
478
525
|
};
|
|
479
526
|
}
|
|
480
527
|
|
|
528
|
+
function toolRunProbeArgs(event) {
|
|
529
|
+
return [
|
|
530
|
+
event.params,
|
|
531
|
+
{
|
|
532
|
+
source: event.source,
|
|
533
|
+
toolName: event.toolName,
|
|
534
|
+
toolCallId: event.toolCall.id,
|
|
535
|
+
signal: new AbortController().signal,
|
|
536
|
+
logger: console,
|
|
537
|
+
},
|
|
538
|
+
];
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
function toolExecuteProbeArgs(event) {
|
|
542
|
+
return [event.toolCall.id, event.params, new AbortController().signal, () => undefined];
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function httpRouteProbeArgs(event) {
|
|
546
|
+
return [
|
|
547
|
+
{
|
|
548
|
+
method: "POST",
|
|
549
|
+
path: "/fixture/probe",
|
|
550
|
+
url: "http://127.0.0.1/fixture/probe",
|
|
551
|
+
headers: event.headers,
|
|
552
|
+
body: event.body,
|
|
553
|
+
json: async () => event.body,
|
|
554
|
+
text: async () => JSON.stringify(event.body),
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
source: event.source,
|
|
558
|
+
params: event.params,
|
|
559
|
+
logger: console,
|
|
560
|
+
},
|
|
561
|
+
];
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
function commandProbeArgs(event) {
|
|
565
|
+
return [
|
|
566
|
+
event.input,
|
|
567
|
+
{
|
|
568
|
+
source: event.source,
|
|
569
|
+
signal: new AbortController().signal,
|
|
570
|
+
logger: console,
|
|
571
|
+
},
|
|
572
|
+
];
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function gatewayProbeArgs(event) {
|
|
576
|
+
return [
|
|
577
|
+
{
|
|
578
|
+
params: event.params,
|
|
579
|
+
body: event.body,
|
|
580
|
+
headers: event.headers,
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
source: event.source,
|
|
584
|
+
logger: console,
|
|
585
|
+
},
|
|
586
|
+
];
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function interactiveProbeArgs(event) {
|
|
590
|
+
return [
|
|
591
|
+
{
|
|
592
|
+
id: "interaction-fixture",
|
|
593
|
+
payload: event.body,
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
source: event.source,
|
|
597
|
+
logger: console,
|
|
598
|
+
},
|
|
599
|
+
];
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function lifecycleProbeArgs(event) {
|
|
603
|
+
return [
|
|
604
|
+
{
|
|
605
|
+
source: event.source,
|
|
606
|
+
logger: console,
|
|
607
|
+
signal: new AbortController().signal,
|
|
608
|
+
},
|
|
609
|
+
];
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function speechProbeArgs(event) {
|
|
613
|
+
return [
|
|
614
|
+
{
|
|
615
|
+
text: "fixture speech request",
|
|
616
|
+
voice: "fixture",
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
source: event.source,
|
|
620
|
+
logger: console,
|
|
621
|
+
},
|
|
622
|
+
];
|
|
623
|
+
}
|
|
624
|
+
|
|
481
625
|
async function runProbe({ captureIndex, kind, seam, label, invoke }) {
|
|
482
626
|
try {
|
|
483
627
|
const output = await invoke();
|