@agent-surface/core 0.15.0 → 0.16.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.
@@ -719,6 +719,186 @@ 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: 3;
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
+ interface CompiledCapabilityToken {
762
+ manifestHash: string;
763
+ declarationId: string;
764
+ capabilityId: string;
765
+ contractHash: string;
766
+ }
767
+ interface CompiledComponentProvenance {
768
+ manifestHash: string;
769
+ declarationId: string;
770
+ capabilities: Record<string, CompiledCapabilityToken>;
771
+ }
772
+ /** Shared across duplicate copies of core in a bundle. Not enumerable/serializable. */
773
+ declare const COMPILED_CAPABILITY_PROVENANCE: unique symbol;
774
+ type ProvenanceCarrier = {
775
+ [COMPILED_CAPABILITY_PROVENANCE]?: CompiledComponentProvenance | CompiledCapabilityToken;
776
+ };
777
+ interface AgentObservationContract<TOut extends JsonValue> {
778
+ description: string;
779
+ output: AgentSchema<TOut>;
780
+ meta?: Record<string, JsonValue>;
781
+ timeoutMs?: number;
782
+ policies?: CapabilityPolicyAttachment[];
783
+ tags?: string[];
784
+ }
785
+ interface AgentActionContract<TIn extends JsonValue, TOut extends JsonValue | void = void> {
786
+ description: string;
787
+ input: AgentSchema<TIn>;
788
+ output?: AgentSchema<Exclude<TOut, void>>;
789
+ effect: "local-state" | "navigation";
790
+ idempotent?: boolean;
791
+ reversible?: boolean;
792
+ confirmation?: "never" | "optional" | "required";
793
+ audit?: "none" | "metadata" | "full";
794
+ meta?: Record<string, JsonValue>;
795
+ timeoutMs?: number;
796
+ concurrency?: AgentConcurrency;
797
+ policies?: CapabilityPolicyAttachment[];
798
+ tags?: string[];
799
+ }
800
+ declare function observationContract<TOut extends JsonValue>(contract: AgentObservationContract<TOut>): AgentObservationContract<TOut>;
801
+ declare function actionContract<TIn extends JsonValue, TOut extends JsonValue | void = void>(contract: AgentActionContract<TIn, TOut>): AgentActionContract<TIn, TOut>;
802
+ type ObservationBindings<C> = C extends AgentObservationContract<infer TOut> ? {
803
+ read(ctx: AgentReadContext): TOut | Promise<TOut>;
804
+ when?: () => boolean;
805
+ unavailableReason?: string | (() => string);
806
+ policies?: AgentPolicy[];
807
+ } : never;
808
+ type ActionBindings<C> = C extends AgentActionContract<infer TIn, infer TOut> ? {
809
+ execute(input: TIn, ctx: AgentActionContext): TOut | Promise<TOut>;
810
+ when?: () => boolean;
811
+ unavailableReason?: string | (() => string);
812
+ precondition?(input: TIn, ctx: AgentReadContext): void | PreconditionFailure;
813
+ policies?: AgentPolicy[];
814
+ } : never;
815
+ interface AgentComponentContractDefinition<TObservations extends Record<string, AgentObservationContract<any>> = Record<string, AgentObservationContract<any>>, TActions extends Record<string, AgentActionContract<any, any>> = Record<string, AgentActionContract<any, any>>> {
816
+ type: string;
817
+ description: string;
818
+ meta?: Record<string, JsonValue>;
819
+ origin?: string;
820
+ priority?: number;
821
+ policies?: CapabilityPolicyAttachment[];
822
+ tags?: string[];
823
+ observations?: TObservations;
824
+ actions?: TActions;
825
+ }
826
+ interface AgentComponentRuntimeBindings<TObservations extends Record<string, AgentObservationContract<any>>, TActions extends Record<string, AgentActionContract<any, any>>> {
827
+ instanceId?: string;
828
+ parent?: {
829
+ type: string;
830
+ instanceId?: string;
831
+ };
832
+ internal?: Record<string, unknown>;
833
+ enabled?: boolean;
834
+ policies?: AgentPolicy[];
835
+ observations?: {
836
+ [K in keyof TObservations]: ObservationBindings<TObservations[K]>;
837
+ };
838
+ actions?: {
839
+ [K in keyof TActions]: ActionBindings<TActions[K]>;
840
+ };
841
+ procedures?: AgentProcedureBinding<any, any>[];
842
+ }
843
+ interface AgentComponentContract<TObservations extends Record<string, AgentObservationContract<any>>, TActions extends Record<string, AgentActionContract<any, any>>> extends AgentComponentContractDefinition<TObservations, TActions> {
844
+ readonly kind: "agent-component-contract";
845
+ bind(bindings: AgentComponentRuntimeBindings<TObservations, TActions>): AgentComponentDefinition;
846
+ }
847
+ /**
848
+ * Compiler macro. The second argument is injected by @agent-surface/compiler;
849
+ * author code must never supply it.
850
+ */
851
+ 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>, compiled?: CompiledComponentProvenance): AgentComponentContract<TObservations, TActions>;
852
+ interface ExternalAgentToolContractDefinition<TIn extends JsonValue, TOut extends JsonValue> {
853
+ id: string;
854
+ description: string;
855
+ input: AgentSchema<TIn>;
856
+ output?: AgentSchema<TOut>;
857
+ effect: AgentEffect;
858
+ confirmation?: "never" | "optional" | "required";
859
+ policies?: CapabilityPolicyAttachment[];
860
+ tags?: string[];
861
+ }
862
+ interface AgentProcedureContractDefinition<TIn extends JsonValue, TOut extends JsonValue> {
863
+ id: `domain:${string}`;
864
+ description: string;
865
+ input: AgentSchema<TIn>;
866
+ output?: AgentSchema<TOut>;
867
+ effect: "server-query" | "server-mutation" | "external-side-effect" | "destructive";
868
+ confirmation?: "never" | "optional" | "required";
869
+ policies?: CapabilityPolicyAttachment[];
870
+ tags?: string[];
871
+ }
872
+ interface AgentProcedureContract<TIn extends JsonValue, TOut extends JsonValue> extends ProvenanceCarrier {
873
+ readonly kind: "agent-procedure-contract";
874
+ readonly definition: AgentProcedureContractDefinition<TIn, TOut>;
875
+ }
876
+ declare function defineAgentProcedureContract<TIn extends JsonValue, TOut extends JsonValue = JsonValue>(definition: AgentProcedureContractDefinition<TIn, TOut>, compiled?: CompiledCapabilityToken): AgentProcedureContract<TIn, TOut>;
877
+ interface CompiledExternalAgentTool<TIn extends JsonValue = JsonValue, TOut extends JsonValue = JsonValue> {
878
+ name: string;
879
+ description: string;
880
+ inputSchema: JsonSchema;
881
+ execute(input: TIn): TOut | Promise<TOut>;
882
+ [COMPILED_CAPABILITY_PROVENANCE]: CompiledCapabilityToken;
883
+ }
884
+ interface ExternalAgentToolContract<TIn extends JsonValue, TOut extends JsonValue> {
885
+ readonly kind: "external-agent-tool-contract";
886
+ readonly definition: ExternalAgentToolContractDefinition<TIn, TOut>;
887
+ bind(binding: {
888
+ execute(input: TIn): TOut | Promise<TOut>;
889
+ }): CompiledExternalAgentTool<TIn, TOut>;
890
+ }
891
+ declare function defineExternalAgentToolContract<TIn extends JsonValue, TOut extends JsonValue = JsonValue>(definition: ExternalAgentToolContractDefinition<TIn, TOut>, compiled?: CompiledCapabilityToken): ExternalAgentToolContract<TIn, TOut>;
892
+ declare function compiledCapabilityToken(contract: AgentProcedureContract<any, any> | ExternalAgentToolContract<any, any>): CompiledCapabilityToken;
893
+ declare function tryCompiledCapabilityToken(contract: AgentProcedureContract<any, any> | ExternalAgentToolContract<any, any>): CompiledCapabilityToken | undefined;
894
+ /** Runtime exposure ceiling used by the registry. */
895
+ declare function assertDefinitionInManifest(definition: AgentComponentDefinition, manifest: CapabilityContractManifest): void;
896
+ interface AgentExposureGateway {
897
+ expose<T extends CompiledExternalAgentTool>(tools: readonly T[]): T[];
898
+ }
899
+ /** Final provider/MCP boundary: arbitrary tool objects cannot pass. */
900
+ declare function createAgentExposureGateway(manifest: CapabilityContractManifest): AgentExposureGateway;
901
+
722
902
  interface RegistrationCandidate {
723
903
  definition: AgentComponentDefinition;
724
904
  stack?: string;
@@ -743,6 +923,8 @@ interface RegistryOptions {
743
923
  limits?: Partial<AgentSurfaceLimits>;
744
924
  /** Injectable clock (docs/08 determinism); default Date.now. */
745
925
  now?: () => number;
926
+ /** Compiler-generated runtime ceiling. When present, raw/stale bindings fail closed. */
927
+ manifest?: CapabilityContractManifest;
746
928
  }
747
929
  interface AgentRegistrationHandle {
748
930
  readonly registrationId: string;
@@ -774,4 +956,4 @@ interface AgentSurfaceRegistry {
774
956
  }
775
957
  declare function createAgentSurfaceRegistry(options?: RegistryOptions): AgentSurfaceRegistry;
776
958
 
777
- export { type InvokeOptions as $, type AgentRouteInfo as A, type AgentProcedureBindingRuntimeConfig as B, type AgentProcedureDescriptor as C, type DiscoveryDecision as D, type AgentProcedureEffect as E, type AgentProcedureExecutor as F, type AgentProcedureRefDescriptor as G, type AgentReadContext as H, type AgentRegistrationHandle as I, type JsonSchema as J, type AgentSchema as K, AgentSchemaError as L, type AgentSchemaIssue as M, AgentSurfaceDefinitionError as N, type AgentSurfaceDefinitionErrorCode as O, AgentSurfaceError as P, type AgentSurfaceEvent as Q, type AgentSurfaceLimits as R, type SnapshotContext as S, type AgentSurfaceSnapshot as T, type Unsubscribe as U, type AuditEvent as V, type AuditSink as W, CONFIRMATION_ESCALATION as X, type ConfirmationController as Y, type ConfirmationEscalation as Z, DEFAULT_LIMITS as _, type AgentConsumer as a, type PendingConfirmation as a0, type PreconditionFailure as a1, type ProcedureCallInfo as a2, type RegistrationCandidate as a3, type RegistryOptions as a4, type StandardSchemaV1 as a5, action as a6, audit as a7, authenticated as a8, composeInvokeChain as a9, consoleAuditSink as aa, createAgentSurfaceRegistry as ab, defineAgentComponent as ac, emptyObjectSchema as ad, environment as ae, evaluateDiscovery as af, fromJsonSchema as ag, fromStandardSchema as ah, hasPermission as ai, isAgentSurfaceError as aj, memoryAuditSink as ak, observation as al, rateLimit as am, requireConfirmation as an, tenantBoundary as ao, validateComponentDefinition as ap, validateJsonSchemaDocument as aq, validateValueAgainstSchema as ar, type AgentSurfaceRegistry as b, type JsonValue as c, type AgentInvocationResult as d, AGENT_CAPABILITY_ERROR_CODES as e, type AgentActionContext as f, type AgentActionDefinition as g, type AgentActionDescriptor as h, type AgentAuthorizationContext as i, type AgentCapabilityDescriptorUnion as j, type AgentCapabilityErrorCode as k, type AgentCapabilityErrorPayload as l, matchesScope as m, type AgentComponentDefinition as n, type AgentComponentDescriptor as o, type AgentConcurrency as p, type AgentEffect as q, type AgentEnvironment as r, type AgentErrorRetry as s, type AgentInvocation as t, type AgentInvocationPolicyContext as u, type AgentObservationDefinition as v, type AgentObservationDescriptor as w, type AgentPolicy as x, type AgentPolicyContext as y, type AgentProcedureBinding as z };
959
+ 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, COMPILED_CAPABILITY_PROVENANCE as a4, CONFIRMATION_ESCALATION as a5, type CapabilityContractEntry as a6, type CapabilityContractKind as a7, type CapabilityContractManifest as a8, type CapabilityPolicyAttachment as a9, defineAgentComponent as aA, defineAgentComponentContract as aB, defineAgentProcedureContract as aC, defineExternalAgentToolContract 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, tryCompiledCapabilityToken as aR, validateComponentDefinition as aS, validateJsonSchemaDocument as aT, validateValueAgainstSchema as aU, type CompiledCapabilityToken as aa, type CompiledComponentProvenance as ab, type CompiledExternalAgentTool as ac, type ConfirmationController as ad, type ConfirmationEscalation as ae, DEFAULT_LIMITS as af, type ExternalAgentToolContract as ag, type ExternalAgentToolContractDefinition as ah, type ExternalCapabilityContractDigest as ai, type InvokeOptions as aj, type PendingConfirmation as ak, type PreconditionFailure as al, type ProcedureCallInfo as am, type RegistrationCandidate as an, type RegistryOptions as ao, type StandardSchemaV1 as ap, action as aq, actionContract as ar, assertDefinitionInManifest as as, audit as at, authenticated as au, compiledCapabilityToken as av, composeInvokeChain as aw, consoleAuditSink as ax, createAgentExposureGateway as ay, createAgentSurfaceRegistry 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.15.0",
3
+ "version": "0.16.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": "19.5 kB"
61
+ "limit": "20.5 kB"
62
62
  },
63
63
  {
64
64
  "path": "dist/explain.js",