f254f5ac2b
Add explicit package summary delivery and exact retained manifest pages while preserving complete MCP defaults, one-shot CLI output, provider requests, source identity and session lifetime. Return distinct linked Evidence and preserve partial/null facts; reject unavailable retention before engine work. Validation: 27 relevant SDK/domain/Android boundary checks, focused test-only correction rerun, full supported compiler/lint and docs checks, real NewPipe SDK pairs, authentic old Evidence continuation, four actual Codex trials with failures/regressions retained, and all 39 exact-head CI checks. Package replies shrink 119,527 to 8,659 bytes; no model-token or time gain is established. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
177 lines
5.3 KiB
TypeScript
177 lines
5.3 KiB
TypeScript
import { z } from "zod";
|
|
import { localPathStringSchema } from "../localPath.js";
|
|
|
|
const target = {
|
|
path: localPathStringSchema.describe(
|
|
"Local APK path; the target is never executed",
|
|
),
|
|
};
|
|
const classTarget = {
|
|
...target,
|
|
class_name: z.string().min(1).describe("Exact fully qualified class name"),
|
|
};
|
|
|
|
/** Caller intent for static Android inspection, independent of its engine. */
|
|
export const androidInputSchemas = {
|
|
inspect_android_package: z.strictObject(target),
|
|
search_android_classes: z.strictObject({
|
|
...target,
|
|
query: z
|
|
.string()
|
|
.describe("Case-sensitive class-name substring; empty lists all classes"),
|
|
}),
|
|
inspect_android_class: z.strictObject(classTarget),
|
|
inspect_android_method: z.strictObject({
|
|
...classTarget,
|
|
method_name: z.string().min(1),
|
|
overload_index: z
|
|
.number()
|
|
.int()
|
|
.nonnegative()
|
|
.optional()
|
|
.describe(
|
|
"Explicit index among same-name methods; required when ambiguous",
|
|
),
|
|
}),
|
|
trace_android_references: z.strictObject({
|
|
...classTarget,
|
|
method_name: z
|
|
.string()
|
|
.min(1)
|
|
.optional()
|
|
.describe(
|
|
"Omit for class references; ambiguous overloaded methods are unsupported",
|
|
),
|
|
}),
|
|
} as const;
|
|
|
|
/** Optional retained delivery is separate from the engine's APK request. */
|
|
export const androidPackageInspectionInputSchema =
|
|
androidInputSchemas.inspect_android_package.extend({
|
|
detail: z.enum(["complete", "summary"]).optional(),
|
|
});
|
|
|
|
/** Supported static Android operations. */
|
|
export type AndroidOperation = keyof typeof androidInputSchemas;
|
|
/** Validated Android requests carry their selected operation. */
|
|
export type AndroidRequest = {
|
|
[Name in AndroidOperation]: {
|
|
operation: Name;
|
|
input: z.infer<(typeof androidInputSchemas)[Name]>;
|
|
};
|
|
}[AndroidOperation];
|
|
|
|
/** Validate operation and input together so their types remain correlated. */
|
|
export const androidRequestSchema = z.discriminatedUnion("operation", [
|
|
z.strictObject({
|
|
operation: z.literal("inspect_android_package"),
|
|
input: androidInputSchemas.inspect_android_package,
|
|
}),
|
|
z.strictObject({
|
|
operation: z.literal("search_android_classes"),
|
|
input: androidInputSchemas.search_android_classes,
|
|
}),
|
|
z.strictObject({
|
|
operation: z.literal("inspect_android_class"),
|
|
input: androidInputSchemas.inspect_android_class,
|
|
}),
|
|
z.strictObject({
|
|
operation: z.literal("inspect_android_method"),
|
|
input: androidInputSchemas.inspect_android_method,
|
|
}),
|
|
z.strictObject({
|
|
operation: z.literal("trace_android_references"),
|
|
input: androidInputSchemas.trace_android_references,
|
|
}),
|
|
]);
|
|
|
|
const textCoverage = z.strictObject({
|
|
status: z.enum(["complete", "partial"]),
|
|
text: z.string(),
|
|
reported_total_bytes: z.number().int().nonnegative().nullable(),
|
|
});
|
|
const method = z.strictObject({
|
|
name: z.string(),
|
|
reported_signature: z.string(),
|
|
overload_index: z.number().int().nonnegative(),
|
|
is_constructor: z.boolean(),
|
|
dex_descriptor: z.null(),
|
|
});
|
|
const engine = z.strictObject({
|
|
name: z.string().min(1),
|
|
version: z.string().nullable(),
|
|
artifact_sha256: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
source_revision: z.string().nullable(),
|
|
worker_count: z.number().int().positive(),
|
|
heap_limit_mib: z.number().int().positive().nullable(),
|
|
});
|
|
const common = { engine };
|
|
|
|
/** Portable observations with explicit decompiler and identity limitations. */
|
|
export const androidResultSchemas = {
|
|
inspect_android_package: z.strictObject({
|
|
...common,
|
|
package_name: z.string().nullable(),
|
|
version_name: z.string().nullable(),
|
|
version_code: z.string().nullable(),
|
|
min_sdk: z.string().nullable(),
|
|
target_sdk: z.string().nullable(),
|
|
permissions: z.array(z.string()),
|
|
manifest: textCoverage,
|
|
class_count: z.number().int().nonnegative(),
|
|
resource_count: z.number().int().nonnegative(),
|
|
signature_verification: z.literal("not_performed"),
|
|
}),
|
|
search_android_classes: z.strictObject({
|
|
...common,
|
|
query: z.string(),
|
|
total_classes: z.number().int().nonnegative(),
|
|
matches: z.array(z.string()),
|
|
duplicate_names: z.array(
|
|
z.strictObject({
|
|
name: z.string(),
|
|
occurrences: z.number().int().min(2),
|
|
}),
|
|
),
|
|
coverage: z.literal("complete"),
|
|
}),
|
|
inspect_android_class: z.strictObject({
|
|
...common,
|
|
class_name: z.string(),
|
|
methods: z.array(method),
|
|
fields: z.array(
|
|
z.strictObject({ name: z.string(), reported_type: z.string() }),
|
|
),
|
|
inner_classes: z.array(z.string()),
|
|
}),
|
|
inspect_android_method: z.strictObject({
|
|
...common,
|
|
class_name: z.string(),
|
|
method: method,
|
|
overload_count: z.number().int().positive(),
|
|
representation: z.enum(["java", "smali"]),
|
|
body_status: z.enum(["available", "not_available"]),
|
|
fell_back: z.boolean(),
|
|
markers: z.array(z.string()),
|
|
source: textCoverage,
|
|
}),
|
|
trace_android_references: z.strictObject({
|
|
...common,
|
|
class_name: z.string(),
|
|
method_name: z.string().nullable(),
|
|
total: z.number().int().nonnegative(),
|
|
references: z.array(
|
|
z.strictObject({
|
|
kind: z.string(),
|
|
name: z.string(),
|
|
reported_full_name: z.string(),
|
|
containing_class: z.string(),
|
|
top_class: z.string(),
|
|
source_line: z.null(),
|
|
dex_offset: z.null(),
|
|
}),
|
|
),
|
|
coverage: z.literal("complete"),
|
|
}),
|
|
} as const;
|