{"version":3,"file":"guards.mjs","names":[],"sources":["../src/guards.ts"],"sourcesContent":["/**\n * Runtime type guards for ADK primitives, contexts, runners, tools, and artifacts.\n *\n * @module @nhtio/adk/guards\n *\n * @remarks\n * Type guards for every value-bearing primitive in the ADK. Each `is*` function is a\n * freestanding TypeScript type predicate (returns `value is X`) that delegates to the\n * cross-realm-safe {@link @nhtio/adk!isInstanceOf} helper.\n *\n * For internal primitives that are not exported as runtime classes (`BaseException`,\n * `TurnContext`, `DispatchContext`), the freestanding guard here is the canonical runtime\n * detection. For user-constructable classes (`Memory`, `Tool`, etc.) these freestanding guards\n * complement the static `ClassName.isClassName(value)` methods already on each class.\n */\n\nimport { Tool } from './lib/classes/tool'\nimport { Memory } from './lib/classes/memory'\nimport { TurnRunner } from './lib/turn_runner'\nimport { Message } from './lib/classes/message'\nimport { Thought } from './lib/classes/thought'\nimport { Registry } from './lib/classes/registry'\nimport { Identity } from './lib/classes/identity'\nimport { TurnGate } from './lib/classes/turn_gate'\nimport { ToolCall } from './lib/classes/tool_call'\nimport { DispatchRunner } from './lib/dispatch_runner'\nimport { Tokenizable } from './lib/classes/tokenizable'\nimport { ArtifactTool } from './lib/classes/artifact_tool'\nimport { ToolRegistry } from './lib/classes/tool_registry'\nimport { BaseException } from './lib/classes/base_exception'\nimport { SpooledArtifact } from './lib/classes/spooled_artifact'\nimport { TurnContext } from './lib/contracts/turn_runner_context'\nimport { DispatchContext } from './lib/contracts/dispatch_context'\nimport { SpooledJsonArtifact } from './lib/classes/spooled_json_artifact'\nimport { SpooledMarkdownArtifact } from './lib/classes/spooled_markdown_artifact'\nimport type { SpooledArtifactConstructor } from './lib/classes/spooled_artifact'\n\n/**\n * @primaryExport\n */\nexport { isInstanceOf, isError, isObject } from './lib/utils/guards'\nexport { implementsSpoolReader } from './lib/contracts/spool_reader'\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!BaseException} instance. */\nexport const isBaseException = (value: unknown): value is BaseException =>\n  BaseException.isBaseException(value)\n\n/** Returns `true` if `value` is an {@link @nhtio/adk!Identity} instance. */\nexport const isIdentity = (value: unknown): value is Identity => Identity.isIdentity(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!Memory} instance. */\nexport const isMemory = (value: unknown): value is Memory => Memory.isMemory(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!Message} instance. */\nexport const isMessage = (value: unknown): value is Message => Message.isMessage(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!Registry} instance. */\nexport const isRegistry = (value: unknown): value is Registry => Registry.isRegistry(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!Thought} instance. */\nexport const isThought = (value: unknown): value is Thought => Thought.isThought(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!Tokenizable} instance. */\nexport const isTokenizable = (value: unknown): value is Tokenizable =>\n  Tokenizable.isTokenizable(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!Tool} instance. */\nexport const isTool = (value: unknown): value is Tool => Tool.isTool(value)\n\n/** Returns `true` if `value` is an {@link @nhtio/adk!ArtifactTool} instance. */\nexport const isArtifactTool = (value: unknown): value is ArtifactTool =>\n  ArtifactTool.isArtifactTool(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!ToolCall} instance. */\nexport const isToolCall = (value: unknown): value is ToolCall => ToolCall.isToolCall(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!ToolRegistry} instance. */\nexport const isToolRegistry = (value: unknown): value is ToolRegistry =>\n  ToolRegistry.isToolRegistry(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!TurnGate} instance. */\nexport const isTurnGate = (value: unknown): value is TurnGate => TurnGate.isTurnGate(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!SpooledArtifact} instance. */\nexport const isSpooledArtifact = (value: unknown): value is SpooledArtifact =>\n  SpooledArtifact.isSpooledArtifact(value)\n\n/**\n * Returns `true` if `value` is a constructor function for {@link @nhtio/adk!SpooledArtifact} or any of\n * its subclasses (including `SpooledArtifact` itself).\n */\nexport const isSpooledArtifactConstructor = (\n  value: unknown\n): value is SpooledArtifactConstructor<SpooledArtifact> =>\n  SpooledArtifact.isSpooledArtifactConstructor(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!SpooledJsonArtifact} instance. */\nexport const isSpooledJsonArtifact = (value: unknown): value is SpooledJsonArtifact =>\n  SpooledJsonArtifact.isSpooledJsonArtifact(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!SpooledMarkdownArtifact} instance. */\nexport const isSpooledMarkdownArtifact = (value: unknown): value is SpooledMarkdownArtifact =>\n  SpooledMarkdownArtifact.isSpooledMarkdownArtifact(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!TurnContext} instance. */\nexport const isTurnContext = (value: unknown): value is TurnContext =>\n  TurnContext.isTurnContext(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!TurnRunner} instance. */\nexport const isTurnRunner = (value: unknown): value is TurnRunner => TurnRunner.isTurnRunner(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!DispatchContext} instance. */\nexport const isDispatchContext = (value: unknown): value is DispatchContext =>\n  DispatchContext.isDispatchContext(value)\n\n/** Returns `true` if `value` is a {@link @nhtio/adk!DispatchRunner} instance. */\nexport const isDispatchRunner = (value: unknown): value is DispatchRunner =>\n  DispatchRunner.isDispatchRunner(value)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,mBAAmB,UAC9B,cAAc,gBAAgB,KAAK;;AAGrC,IAAa,cAAc,UAAsC,SAAS,WAAW,KAAK;;AAG1F,IAAa,YAAY,UAAoC,OAAO,SAAS,KAAK;;AAGlF,IAAa,aAAa,UAAqC,QAAQ,UAAU,KAAK;;AAGtF,IAAa,cAAc,UAAsC,SAAS,WAAW,KAAK;;AAG1F,IAAa,aAAa,UAAqC,QAAQ,UAAU,KAAK;;AAGtF,IAAa,iBAAiB,UAC5B,YAAY,cAAc,KAAK;;AAGjC,IAAa,UAAU,UAAkC,KAAK,OAAO,KAAK;;AAG1E,IAAa,kBAAkB,UAC7B,aAAa,eAAe,KAAK;;AAGnC,IAAa,cAAc,UAAsC,SAAS,WAAW,KAAK;;AAG1F,IAAa,kBAAkB,UAC7B,aAAa,eAAe,KAAK;;AAGnC,IAAa,cAAc,UAAsC,SAAS,WAAW,KAAK;;AAG1F,IAAa,qBAAqB,UAChC,gBAAgB,kBAAkB,KAAK;;;;;AAMzC,IAAa,gCACX,UAEA,gBAAgB,6BAA6B,KAAK;;AAGpD,IAAa,yBAAyB,UACpC,oBAAoB,sBAAsB,KAAK;;AAGjD,IAAa,6BAA6B,UACxC,wBAAwB,0BAA0B,KAAK;;AAGzD,IAAa,iBAAiB,UAC5B,YAAY,cAAc,KAAK;;AAGjC,IAAa,gBAAgB,UAAwC,WAAW,aAAa,KAAK;;AAGlG,IAAa,qBAAqB,UAChC,gBAAgB,kBAAkB,KAAK;;AAGzC,IAAa,oBAAoB,UAC/B,eAAe,iBAAiB,KAAK"}