@agent-surface/core 0.15.0 → 0.17.0
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/README.md +14 -41
- package/dist/explain.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +529 -0
- package/dist/index.js.map +1 -1
- package/dist/{registry-XD1QsGQ4.d.ts → registry-QvbeJMRD.d.ts} +175 -1
- package/package.json +2 -2
|
@@ -719,6 +719,178 @@ interface AgentProcedureDescriptor {
|
|
|
719
719
|
type AgentCapabilityDescriptorUnion = AgentObservationDescriptor | AgentActionDescriptor | AgentProcedureDescriptor;
|
|
720
720
|
declare function matchesScope(type: string, scope: string[] | undefined): boolean;
|
|
721
721
|
|
|
722
|
+
/** Contract format emitted by @agent-surface/compiler. */
|
|
723
|
+
declare const CAPABILITY_CONTRACT_FORMAT_VERSION: 4;
|
|
724
|
+
type CapabilityContractKind = "observation" | "action" | "procedure" | "external";
|
|
725
|
+
interface CapabilityPolicyAttachment {
|
|
726
|
+
name: string;
|
|
727
|
+
phase?: "discovery" | "authorize" | "invoke";
|
|
728
|
+
}
|
|
729
|
+
interface CapabilityContractEntry {
|
|
730
|
+
declarationId: string;
|
|
731
|
+
capabilityId: string;
|
|
732
|
+
kind: CapabilityContractKind;
|
|
733
|
+
description: string;
|
|
734
|
+
effect: AgentEffect;
|
|
735
|
+
inputSchema?: JsonSchema;
|
|
736
|
+
outputSchema?: JsonSchema;
|
|
737
|
+
confirmation?: "never" | "optional" | "required";
|
|
738
|
+
policies?: CapabilityPolicyAttachment[];
|
|
739
|
+
tags?: string[];
|
|
740
|
+
contractHash: string;
|
|
741
|
+
targets: string[];
|
|
742
|
+
origin: string;
|
|
743
|
+
}
|
|
744
|
+
interface ExternalCapabilityContractDigest {
|
|
745
|
+
package?: string;
|
|
746
|
+
source: string;
|
|
747
|
+
digest: string;
|
|
748
|
+
}
|
|
749
|
+
interface CapabilityContractManifest {
|
|
750
|
+
formatVersion: typeof CAPABILITY_CONTRACT_FORMAT_VERSION;
|
|
751
|
+
compilerVersion: string;
|
|
752
|
+
targets: string[];
|
|
753
|
+
capabilities: CapabilityContractEntry[];
|
|
754
|
+
externalContracts: ExternalCapabilityContractDigest[];
|
|
755
|
+
completeness: {
|
|
756
|
+
status: "proven";
|
|
757
|
+
};
|
|
758
|
+
/** sha256 of the canonical manifest payload without this field. */
|
|
759
|
+
hash: string;
|
|
760
|
+
}
|
|
761
|
+
declare const CAPABILITY_AUTHORITY_TYPE: unique symbol;
|
|
762
|
+
/** Immutable runtime source of truth. Only objects minted here are accepted. */
|
|
763
|
+
interface CapabilityAuthority {
|
|
764
|
+
readonly manifest: CapabilityContractManifest;
|
|
765
|
+
readonly [CAPABILITY_AUTHORITY_TYPE]: true;
|
|
766
|
+
}
|
|
767
|
+
interface AgentObservationContract<TOut extends JsonValue> {
|
|
768
|
+
description: string;
|
|
769
|
+
output: AgentSchema<TOut>;
|
|
770
|
+
meta?: Record<string, JsonValue>;
|
|
771
|
+
timeoutMs?: number;
|
|
772
|
+
policies?: CapabilityPolicyAttachment[];
|
|
773
|
+
tags?: string[];
|
|
774
|
+
}
|
|
775
|
+
interface AgentActionContract<TIn extends JsonValue, TOut extends JsonValue | void = void> {
|
|
776
|
+
description: string;
|
|
777
|
+
input: AgentSchema<TIn>;
|
|
778
|
+
output?: AgentSchema<Exclude<TOut, void>>;
|
|
779
|
+
effect: "local-state" | "navigation";
|
|
780
|
+
idempotent?: boolean;
|
|
781
|
+
reversible?: boolean;
|
|
782
|
+
confirmation?: "never" | "optional" | "required";
|
|
783
|
+
audit?: "none" | "metadata" | "full";
|
|
784
|
+
meta?: Record<string, JsonValue>;
|
|
785
|
+
timeoutMs?: number;
|
|
786
|
+
concurrency?: AgentConcurrency;
|
|
787
|
+
policies?: CapabilityPolicyAttachment[];
|
|
788
|
+
tags?: string[];
|
|
789
|
+
}
|
|
790
|
+
declare function observationContract<TOut extends JsonValue>(contract: AgentObservationContract<TOut>): AgentObservationContract<TOut>;
|
|
791
|
+
declare function actionContract<TIn extends JsonValue, TOut extends JsonValue | void = void>(contract: AgentActionContract<TIn, TOut>): AgentActionContract<TIn, TOut>;
|
|
792
|
+
type ObservationBindings<C> = C extends AgentObservationContract<infer TOut> ? {
|
|
793
|
+
read(ctx: AgentReadContext): TOut | Promise<TOut>;
|
|
794
|
+
when?: () => boolean;
|
|
795
|
+
unavailableReason?: string | (() => string);
|
|
796
|
+
policies?: AgentPolicy[];
|
|
797
|
+
} : never;
|
|
798
|
+
type ActionBindings<C> = C extends AgentActionContract<infer TIn, infer TOut> ? {
|
|
799
|
+
execute(input: TIn, ctx: AgentActionContext): TOut | Promise<TOut>;
|
|
800
|
+
when?: () => boolean;
|
|
801
|
+
unavailableReason?: string | (() => string);
|
|
802
|
+
precondition?(input: TIn, ctx: AgentReadContext): void | PreconditionFailure;
|
|
803
|
+
policies?: AgentPolicy[];
|
|
804
|
+
} : never;
|
|
805
|
+
interface AgentComponentContractDefinition<TObservations extends Record<string, AgentObservationContract<any>> = Record<string, AgentObservationContract<any>>, TActions extends Record<string, AgentActionContract<any, any>> = Record<string, AgentActionContract<any, any>>> {
|
|
806
|
+
type: string;
|
|
807
|
+
description: string;
|
|
808
|
+
meta?: Record<string, JsonValue>;
|
|
809
|
+
origin?: string;
|
|
810
|
+
priority?: number;
|
|
811
|
+
policies?: CapabilityPolicyAttachment[];
|
|
812
|
+
tags?: string[];
|
|
813
|
+
observations?: TObservations;
|
|
814
|
+
actions?: TActions;
|
|
815
|
+
}
|
|
816
|
+
interface AgentComponentRuntimeBindings<TObservations extends Record<string, AgentObservationContract<any>>, TActions extends Record<string, AgentActionContract<any, any>>> {
|
|
817
|
+
instanceId?: string;
|
|
818
|
+
parent?: {
|
|
819
|
+
type: string;
|
|
820
|
+
instanceId?: string;
|
|
821
|
+
};
|
|
822
|
+
internal?: Record<string, unknown>;
|
|
823
|
+
enabled?: boolean;
|
|
824
|
+
policies?: AgentPolicy[];
|
|
825
|
+
observations?: {
|
|
826
|
+
[K in keyof TObservations]: ObservationBindings<TObservations[K]>;
|
|
827
|
+
};
|
|
828
|
+
actions?: {
|
|
829
|
+
[K in keyof TActions]: ActionBindings<TActions[K]>;
|
|
830
|
+
};
|
|
831
|
+
procedures?: AgentProcedureBinding<any, any>[];
|
|
832
|
+
}
|
|
833
|
+
interface AgentComponentContract<TObservations extends Record<string, AgentObservationContract<any>>, TActions extends Record<string, AgentActionContract<any, any>>> extends AgentComponentContractDefinition<TObservations, TActions> {
|
|
834
|
+
readonly kind: "agent-component-contract";
|
|
835
|
+
bind(bindings: AgentComponentRuntimeBindings<TObservations, TActions>): AgentComponentDefinition;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Compiler macro. The second argument is injected by @agent-surface/compiler;
|
|
839
|
+
* author code must never supply it.
|
|
840
|
+
*/
|
|
841
|
+
declare function defineAgentComponentContract<TObservations extends Record<string, AgentObservationContract<any>> = Record<never, never>, TActions extends Record<string, AgentActionContract<any, any>> = Record<never, never>>(definition: AgentComponentContractDefinition<TObservations, TActions>): AgentComponentContract<TObservations, TActions>;
|
|
842
|
+
interface ExternalAgentToolContractDefinition<TIn extends JsonValue, TOut extends JsonValue> {
|
|
843
|
+
id: string;
|
|
844
|
+
description: string;
|
|
845
|
+
input: AgentSchema<TIn>;
|
|
846
|
+
output?: AgentSchema<TOut>;
|
|
847
|
+
effect: AgentEffect;
|
|
848
|
+
confirmation?: "never" | "optional" | "required";
|
|
849
|
+
policies?: CapabilityPolicyAttachment[];
|
|
850
|
+
tags?: string[];
|
|
851
|
+
}
|
|
852
|
+
interface AgentProcedureContractDefinition<TIn extends JsonValue, TOut extends JsonValue> {
|
|
853
|
+
id: `domain:${string}`;
|
|
854
|
+
description: string;
|
|
855
|
+
input: AgentSchema<TIn>;
|
|
856
|
+
output?: AgentSchema<TOut>;
|
|
857
|
+
effect: "server-query" | "server-mutation" | "external-side-effect" | "destructive";
|
|
858
|
+
confirmation?: "never" | "optional" | "required";
|
|
859
|
+
policies?: CapabilityPolicyAttachment[];
|
|
860
|
+
tags?: string[];
|
|
861
|
+
}
|
|
862
|
+
interface AgentProcedureContract<TIn extends JsonValue, TOut extends JsonValue> {
|
|
863
|
+
readonly kind: "agent-procedure-contract";
|
|
864
|
+
readonly definition: AgentProcedureContractDefinition<TIn, TOut>;
|
|
865
|
+
}
|
|
866
|
+
declare function defineAgentProcedureContract<TIn extends JsonValue, TOut extends JsonValue = JsonValue>(definition: AgentProcedureContractDefinition<TIn, TOut>): AgentProcedureContract<TIn, TOut>;
|
|
867
|
+
interface CompiledExternalAgentTool<TIn extends JsonValue = JsonValue, TOut extends JsonValue = JsonValue> {
|
|
868
|
+
name: string;
|
|
869
|
+
description: string;
|
|
870
|
+
inputSchema: JsonSchema;
|
|
871
|
+
execute(input: TIn): TOut | Promise<TOut>;
|
|
872
|
+
}
|
|
873
|
+
interface ExternalAgentToolContract<TIn extends JsonValue, TOut extends JsonValue> {
|
|
874
|
+
readonly kind: "external-agent-tool-contract";
|
|
875
|
+
readonly definition: ExternalAgentToolContractDefinition<TIn, TOut>;
|
|
876
|
+
bind(binding: {
|
|
877
|
+
execute(input: TIn): TOut | Promise<TOut>;
|
|
878
|
+
}): CompiledExternalAgentTool<TIn, TOut>;
|
|
879
|
+
}
|
|
880
|
+
declare function defineExternalAgentToolContract<TIn extends JsonValue, TOut extends JsonValue = JsonValue>(definition: ExternalAgentToolContractDefinition<TIn, TOut>): ExternalAgentToolContract<TIn, TOut>;
|
|
881
|
+
/** Preserve compiler proof while an adapter replaces handlers with latest-ref delegates. */
|
|
882
|
+
declare function deriveAgentComponentBinding(source: AgentComponentDefinition, derived: AgentComponentDefinition): AgentComponentDefinition;
|
|
883
|
+
/** Bind a compiled procedure contract to its contextual runtime definition. */
|
|
884
|
+
declare function authorizeAgentProcedureBinding(contract: AgentProcedureContract<any, any>, definition: AgentComponentDefinition): AgentComponentDefinition;
|
|
885
|
+
declare function createCapabilityAuthority(manifest: CapabilityContractManifest): CapabilityAuthority;
|
|
886
|
+
/** Mandatory runtime authority check used by every registry registration. */
|
|
887
|
+
declare function assertDefinitionAuthorized(definition: AgentComponentDefinition, authority: CapabilityAuthority): void;
|
|
888
|
+
interface AgentExposureGateway {
|
|
889
|
+
expose<T extends CompiledExternalAgentTool>(tools: readonly T[]): T[];
|
|
890
|
+
}
|
|
891
|
+
/** Final provider/MCP boundary: arbitrary tool objects cannot pass. */
|
|
892
|
+
declare function createAgentExposureGateway(authority: CapabilityAuthority): AgentExposureGateway;
|
|
893
|
+
|
|
722
894
|
interface RegistrationCandidate {
|
|
723
895
|
definition: AgentComponentDefinition;
|
|
724
896
|
stack?: string;
|
|
@@ -743,6 +915,8 @@ interface RegistryOptions {
|
|
|
743
915
|
limits?: Partial<AgentSurfaceLimits>;
|
|
744
916
|
/** Injectable clock (docs/08 determinism); default Date.now. */
|
|
745
917
|
now?: () => number;
|
|
918
|
+
/** Compiler-generated runtime source of truth. Required outside repository tests. */
|
|
919
|
+
authority?: CapabilityAuthority;
|
|
746
920
|
}
|
|
747
921
|
interface AgentRegistrationHandle {
|
|
748
922
|
readonly registrationId: string;
|
|
@@ -774,4 +948,4 @@ interface AgentSurfaceRegistry {
|
|
|
774
948
|
}
|
|
775
949
|
declare function createAgentSurfaceRegistry(options?: RegistryOptions): AgentSurfaceRegistry;
|
|
776
950
|
|
|
777
|
-
export { type
|
|
951
|
+
export { type AgentSurfaceLimits as $, type AgentRouteInfo as A, type AgentObservationContract as B, type AgentObservationDefinition as C, type DiscoveryDecision as D, type AgentObservationDescriptor as E, type AgentPolicy as F, type AgentPolicyContext as G, type AgentProcedureBinding as H, type AgentProcedureBindingRuntimeConfig as I, type JsonSchema as J, type AgentProcedureContract as K, type AgentProcedureContractDefinition as L, type AgentProcedureDescriptor as M, type AgentProcedureEffect as N, type AgentProcedureExecutor as O, type AgentProcedureRefDescriptor as P, type AgentReadContext as Q, type AgentRegistrationHandle as R, type SnapshotContext as S, type AgentSchema as T, type Unsubscribe as U, AgentSchemaError as V, type AgentSchemaIssue as W, AgentSurfaceDefinitionError as X, type AgentSurfaceDefinitionErrorCode as Y, AgentSurfaceError as Z, type AgentSurfaceEvent as _, type AgentConsumer as a, type AgentSurfaceSnapshot as a0, type AuditEvent as a1, type AuditSink as a2, CAPABILITY_CONTRACT_FORMAT_VERSION as a3, CONFIRMATION_ESCALATION as a4, type CapabilityAuthority as a5, type CapabilityContractEntry as a6, type CapabilityContractKind as a7, type CapabilityContractManifest as a8, type CapabilityPolicyAttachment as a9, defineAgentComponentContract as aA, defineAgentProcedureContract as aB, defineExternalAgentToolContract as aC, deriveAgentComponentBinding as aD, emptyObjectSchema as aE, environment as aF, evaluateDiscovery as aG, fromJsonSchema as aH, fromStandardSchema as aI, hasPermission as aJ, isAgentSurfaceError as aK, memoryAuditSink as aL, observation as aM, observationContract as aN, rateLimit as aO, requireConfirmation as aP, tenantBoundary as aQ, validateComponentDefinition as aR, validateJsonSchemaDocument as aS, validateValueAgainstSchema as aT, type CompiledExternalAgentTool as aa, type ConfirmationController as ab, type ConfirmationEscalation as ac, DEFAULT_LIMITS as ad, type ExternalAgentToolContract as ae, type ExternalAgentToolContractDefinition as af, type ExternalCapabilityContractDigest as ag, type InvokeOptions as ah, type PendingConfirmation as ai, type PreconditionFailure as aj, type ProcedureCallInfo as ak, type RegistrationCandidate as al, type RegistryOptions as am, type StandardSchemaV1 as an, action as ao, actionContract as ap, assertDefinitionAuthorized as aq, audit as ar, authenticated as as, authorizeAgentProcedureBinding as at, composeInvokeChain as au, consoleAuditSink as av, createAgentExposureGateway as aw, createAgentSurfaceRegistry as ax, createCapabilityAuthority as ay, defineAgentComponent as az, type AgentSurfaceRegistry as b, type JsonValue as c, type AgentInvocationResult as d, AGENT_CAPABILITY_ERROR_CODES as e, type AgentActionContext as f, type AgentActionContract as g, type AgentActionDefinition as h, type AgentActionDescriptor as i, type AgentAuthorizationContext as j, type AgentCapabilityDescriptorUnion as k, type AgentCapabilityErrorCode as l, matchesScope as m, type AgentCapabilityErrorPayload as n, type AgentComponentContract as o, type AgentComponentContractDefinition as p, type AgentComponentDefinition as q, type AgentComponentDescriptor as r, type AgentComponentRuntimeBindings as s, type AgentConcurrency as t, type AgentEffect as u, type AgentEnvironment as v, type AgentErrorRetry as w, type AgentExposureGateway as x, type AgentInvocation as y, type AgentInvocationPolicyContext as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-surface/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Framework-agnostic registry, types, policies, errors, snapshot, invocation for frontend agent surfaces",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"size-limit": [
|
|
59
59
|
{
|
|
60
60
|
"path": "dist/index.js",
|
|
61
|
-
"limit": "
|
|
61
|
+
"limit": "22 kB"
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
"path": "dist/explain.js",
|