7e69e675ba
Add authorized exact-contract lookup, revision-fenced views, generated typed package/browser descriptors, and lifecycle-safe React discovery. Preserve closed generic contracts without competing-conformance policies or new authority grants. Document supported workarounds and privacy boundaries for agent feedback. Publish matching protocol/SDK exports and update scaffold/starter pins; leave the deployed template unchanged.
96 lines
3.3 KiB
TypeScript
96 lines
3.3 KiB
TypeScript
import { type Value } from "./camino/api_pb.js";
|
|
import { liveValue, type RuntimeHandler, type DerivedHandler } from "./index.js";
|
|
export type { QxObjectRef } from "./references.js";
|
|
declare const watchBrand: unique symbol;
|
|
export type QxWatchHandle = string & {
|
|
readonly [watchBrand]: true;
|
|
};
|
|
export type MessageBinding<T> = {
|
|
encode(value: T): Value;
|
|
decode(value: Value): T;
|
|
};
|
|
export type QxLiveValue = ReturnType<typeof liveValue>;
|
|
export type BindingValue<B> = B extends MessageBinding<infer T> ? T : never;
|
|
export type QxHandler<C, O> = (context: C) => O | Promise<O>;
|
|
export type QxDerived<C, O> = {
|
|
kind: "derived";
|
|
get: QxHandler<C, O>;
|
|
};
|
|
export type QxSession<C> = {
|
|
id: string;
|
|
run<T>(work: (context: C) => Promise<T>): Promise<T>;
|
|
close(): Promise<void>;
|
|
};
|
|
export type QxContextLifecycle<C> = {
|
|
signal?: AbortSignal;
|
|
openSession?: () => Promise<QxSession<C>>;
|
|
};
|
|
declare const contractView: unique symbol;
|
|
/** Generated exact closed contract. A descriptor is type evidence, never authority. */
|
|
export type QxInterfaceContract<View> = {
|
|
readonly interfaceRevisionId: string;
|
|
readonly operations: Record<string, QxOperationSpec>;
|
|
readonly [contractView]: (value: View) => View;
|
|
};
|
|
export declare const defineQxInterfaceContract: <View>(interfaceRevisionId: string, operations: Record<string, QxOperationSpec>) => QxInterfaceContract<View>;
|
|
export type QxConformer = {
|
|
tryConform<View>(object: import("./references.js").QxObjectRef, contract: QxInterfaceContract<View>): Promise<View | undefined>;
|
|
};
|
|
export declare const qxDerived: <C, O>(get: QxHandler<C, O>) => QxDerived<C, O>;
|
|
/** Versioned binding ABI. This mirrors the language-neutral value IR. */
|
|
export type QxValueType = {
|
|
kind: "builtin";
|
|
name: "unit" | "watch-handle";
|
|
} | {
|
|
kind: "scalar";
|
|
name: string;
|
|
} | {
|
|
kind: "message";
|
|
descriptorId: string;
|
|
} | {
|
|
kind: "record";
|
|
fields: Record<string, QxValueType>;
|
|
} | {
|
|
kind: "object-ref";
|
|
expectation: unknown;
|
|
} | {
|
|
kind: "optional" | "list";
|
|
value: QxValueType;
|
|
};
|
|
export type QxOperationSpec = {
|
|
id: string;
|
|
inputType: QxValueType;
|
|
outputType: QxValueType;
|
|
};
|
|
export type QxPortSpec = {
|
|
kind: "state";
|
|
id: string;
|
|
valueType: QxValueType;
|
|
primitives: string[];
|
|
} | {
|
|
kind: "edge";
|
|
id: string;
|
|
primitives: string[];
|
|
} | {
|
|
kind: "interface";
|
|
id: string;
|
|
interfaceRevisionId: string;
|
|
operations: Record<string, QxOperationSpec>;
|
|
} | {
|
|
kind: "constructor";
|
|
id: string;
|
|
inputType: QxValueType;
|
|
};
|
|
export type QxHandlerSpec = {
|
|
receiver?: "none";
|
|
inputType: QxValueType;
|
|
outputType: QxValueType;
|
|
eventType?: QxValueType;
|
|
ports: Record<string, QxPortSpec>;
|
|
};
|
|
export type QxMessages = Record<string, MessageBinding<any>>;
|
|
export declare const decodeQxValue: (type: QxValueType, value: Value | undefined, messages: QxMessages) => any;
|
|
export declare const encodeQxValue: (type: QxValueType, value: any, messages: QxMessages) => Value;
|
|
/** The sole unchecked cast connects generated contracts to the dynamic RPC runtime. */
|
|
export declare const bindQxHandler: <C, O>(spec: QxHandlerSpec, handler: QxHandler<C, O> | QxDerived<C, O>, messages: QxMessages) => RuntimeHandler | DerivedHandler;
|
|
//# sourceMappingURL=bindings.d.ts.map
|