@agntn/tools 0.2.1 → 0.2.3

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.
Files changed (43) hide show
  1. package/README.md +11 -9
  2. package/dist/_chunks/index.d.mts +50 -6
  3. package/dist/_chunks/libs/typebox.d.mts +1 -2
  4. package/dist/_chunks/libs/typebox.mjs +0 -2
  5. package/dist/_chunks/mcp-answers.d.mts +52 -0
  6. package/dist/_chunks/mcp-answers.mjs +125 -9
  7. package/dist/_chunks/questions.mjs +93 -0
  8. package/dist/_chunks/src.mjs +78 -27
  9. package/dist/_chunks/updates.mjs +131 -2
  10. package/dist/ai.d.mts +4 -4
  11. package/dist/ai.mjs +12 -3
  12. package/dist/cli.d.mts +14 -6
  13. package/dist/cli.mjs +145 -21
  14. package/dist/h3.d.mts +3 -2
  15. package/dist/h3.mjs +15 -6
  16. package/dist/index.d.mts +2 -2
  17. package/dist/mcp.d.mts +8 -55
  18. package/dist/mcp.mjs +11 -6
  19. package/dist/omp.d.mts +1 -2
  20. package/dist/omp.mjs +0 -2
  21. package/dist/pi.d.mts +1 -2
  22. package/dist/pi.mjs +1 -3
  23. package/dist/toolkit.d.mts +78 -0
  24. package/dist/toolkit.mjs +62 -0
  25. package/package.json +13 -3
  26. package/dist/_chunks/index.d.mts.map +0 -1
  27. package/dist/_chunks/libs/typebox.d.mts.map +0 -1
  28. package/dist/_chunks/libs/typebox.mjs.map +0 -1
  29. package/dist/_chunks/mcp-answers.mjs.map +0 -1
  30. package/dist/_chunks/src.mjs.map +0 -1
  31. package/dist/_chunks/updates.mjs.map +0 -1
  32. package/dist/ai.d.mts.map +0 -1
  33. package/dist/ai.mjs.map +0 -1
  34. package/dist/cli.d.mts.map +0 -1
  35. package/dist/cli.mjs.map +0 -1
  36. package/dist/h3.d.mts.map +0 -1
  37. package/dist/h3.mjs.map +0 -1
  38. package/dist/mcp.d.mts.map +0 -1
  39. package/dist/mcp.mjs.map +0 -1
  40. package/dist/omp.d.mts.map +0 -1
  41. package/dist/omp.mjs.map +0 -1
  42. package/dist/pi.d.mts.map +0 -1
  43. package/dist/pi.mjs.map +0 -1
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { AddImmutable, AddImmutableDeferred, AddOptional, AddOptionalDeferred, AddReadonly, AddReadonlyDeferred, Any, ArrayOptions, BigInt, BigIntPattern, Boolean, Broaden, Call, CallConstruct, CanComposite, Capitalize, CapitalizeAction, CapitalizeDeferred, CapitalizeInstantiate, Codec, CollapseToObject, Compare, CompareResultDisjoint, CompareResultEqual, CompareResultLeftInside, CompareResultRightInside, Composite, Conditional, ConditionalAction, ConditionalDeferred, ConditionalInstantiate, Constructor, ConstructorOptions, ConstructorParameters, ConstructorParametersAction, ConstructorParametersDeferred, ConstructorParametersInstantiate, ConvertToIntegerKey, Cyclic, CyclicCandidates, CyclicCheck, CyclicDependencies, CyclicExtends, CyclicOptions, CyclicTarget, Decode, DecodeBuilder, Deferred, Dependent, DependentOptions, Distribute, Encode, EncodeBuilder, Enum, Evaluate, EvaluateAction, EvaluateDeferred, EvaluateDependent, EvaluateEnum, EvaluateInstantiate, EvaluateIntersect, EvaluateTemplateLiteral, EvaluateType, EvaluateUnion, EvaluateUnionFast, Exclude, ExcludeAction, ExcludeDeferred, ExcludeInstantiate, Extends, Extract, ExtractAction, ExtractDeferred, ExtractInstantiate, Flatten, FunctionOptions, Generic, Identifier, Immutable, Index, IndexAction, IndexDeferred, IndexInstantiate, Infer, InstanceType, InstanceTypeAction, InstanceTypeDeferred, InstanceTypeInstantiate, Instantiate, InstantiateCyclic, Integer, IntegerKey, IntegerPattern, Interface, InterfaceAction, InterfaceDeferred, InterfaceInstantiate, Intersect, IntersectOptions, InvalidLiteralValue, IsAny, IsArray, IsBigInt, IsBoolean, IsCall, IsCodec, IsConstructor, IsCyclic, IsDeferred, IsDependent, IsEnum, IsEnumValue, IsFunction, IsGeneric, IsIdentifier, IsImmutable, IsInfer, IsInteger, IsInterfaceDeferred, IsIntersect, IsKind, IsLiteral, IsLiteralBigInt, IsLiteralBoolean, IsLiteralNumber, IsLiteralString, IsLiteralValue, IsNever, IsNull, IsNumber, IsObject, IsOptional, IsParameter, IsReadonly, IsRecord, IsRef, IsRefine, IsRefinement, IsRest, IsSchema, IsString, IsSymbol, IsTemplateLiteral, IsTemplateLiteralDeferred, IsTemplateLiteralFinite, IsTemplateLiteralPattern, IsThis, IsTuple, IsTypeScriptEnumLike, IsUndefined, IsUnion, IsUnknown, IsUnsafe, IsVoid, KeyOf, KeyOfAction, KeyOfDeferred, KeyOfInstantiate, KeysToIndexer, Literal, LiteralTypeName, Lowercase, LowercaseAction, LowercaseDeferred, LowercaseInstantiate, Mapped, MappedAction, MappedDeferred, MappedInstantiate, Module, ModuleDeferred, ModuleInstantiate, Narrow, Never, NeverPattern, NonNullable, NonNullableAction, NonNullableDeferred, NonNullableInstantiate, Null, Number, NumberKey, NumberPattern, ObjectOptions, Omit, OmitAction, OmitDeferred, OmitInstantiate, Optional, Parameter, Parameters, ParametersAction, ParametersDeferred, ParametersInstantiate, ParsePatternIntoTypes, ParseTemplateIntoTypes, Partial, PartialAction, PartialDeferred, PartialInstantiate, Pick, PickAction, PickDeferred, PickInstantiate, Priority, PropertyKeys, PropertyValues, Readonly, ReadonlyObject, ReadonlyObjectAction, ReadonlyObjectDeferred, ReadonlyObjectInstantiate, ReadonlyType, Record, RecordAction, RecordDeferred, RecordFromPattern, RecordInstantiate, RecordKey, RecordOptions, RecordPattern, RecordPatternToType, RecordValue, Ref, RefInstantiate, Refine, RefineAdd, RemoveImmutable, RemoveImmutableDeferred, RemoveOptional, RemoveOptionalDeferred, RemoveReadonly, RemoveReadonlyDeferred, Required, RequiredAction, RequiredArray, RequiredDeferred, RequiredInstantiate, Rest, ReturnType, ReturnTypeAction, ReturnTypeDeferred, ReturnTypeInstantiate, Script, Static, StaticAny, StaticArray, StaticBigInt, StaticBoolean, StaticCodec, StaticConstructor, StaticCyclic, StaticDecode, StaticDependent, StaticDirection, StaticEncode, StaticEnum, StaticEvaluate, StaticFunction, StaticInstantiatedParameters, StaticInteger, StaticIntersect, StaticLiteral, StaticNever, StaticNull, StaticNumber, StaticObject, StaticParse, StaticProperties, StaticRecord, StaticRef, StaticString, StaticSymbol, StaticTemplateLiteral, StaticThis, StaticTuple, StaticType, StaticUndefined, StaticUnion, StaticUnknown, StaticUnsafe, StaticVoid, String, StringKey, StringPattern, Symbol, TAddImmutable, TAddImmutableDeferred, TAddOptional, TAddOptionalDeferred, TAddReadonly, TAddReadonlyDeferred, TAny, TArray, TArrayOptions, TBigInt, TBoolean, TBroaden, TCall, TCallConstruct, TCanComposite, TCapitalize, TCapitalizeAction, TCapitalizeDeferred, TCapitalizeInstantiate, TCodec, TCollapseToObject, TCompare, TCompareResult, TComposite, TConditional, TConditionalAction, TConditionalDeferred, TConditionalInstantiate, TConstructor, TConstructorParameters, TConstructorParametersAction, TConstructorParametersDeferred, TConstructorParametersInstantiate, TConvertToIntegerKey, TCyclic, TCyclicCandidates, TCyclicCheck, TCyclicDependencies, TCyclicExtends, TCyclicTarget, TDecodeCallback, TDeferred, TDependent, TDistribute, TEncodeCallback, TEnum, TEnumValue, TEvaluate, TEvaluateAction, TEvaluateDeferred, TEvaluateDependent, TEvaluateEnum, TEvaluateInstantiate, TEvaluateIntersect, TEvaluateTemplateLiteral, TEvaluateType, TEvaluateUnion, TEvaluateUnionFast, TExclude, TExcludeAction, TExcludeDeferred, TExcludeInstantiate, TExtends, TExtract, TExtractAction, TExtractDeferred, TExtractInstantiate, TFlatten, TFormat, TFunction, TGeneric, TIdentifier, TImmutable, TIndex, TIndexAction, TIndexDeferred, TIndexInstantiate, TInfer, TInstanceType, TInstanceTypeAction, TInstanceTypeDeferred, TInstanceTypeInstantiate, TInstantiate, TInstantiateCyclic, TInteger, TIntegerKey, TInterface, TInterfaceAction, TInterfaceDeferred, TInterfaceInstantiate, TIntersect, TIntersectOptions, TIsTemplateLiteralFinite, TIsTemplateLiteralPattern, TKeyOf, TKeyOfAction, TKeyOfDeferred, TKeyOfInstantiate, TKeysToIndexer, TLiteral, TLiteralTypeName, TLiteralValue, TLowercase, TLowercaseAction, TLowercaseDeferred, TLowercaseInstantiate, TMapped, TMappedAction, TMappedDeferred, TMappedInstantiate, TModule, TModuleDeferred, TModuleInstantiate, TNarrow, TNever, TNonNullable, TNonNullableAction, TNonNullableDeferred, TNonNullableInstantiate, TNull, TNumber, TNumberKey, TNumberOptions, TObject, TObjectOptions, TOmit, TOmitAction, TOmitDeferred, TOmitInstantiate, TOptional, TParameter, TParameters, TParametersAction, TParametersDeferred, TParametersInstantiate, TParsePatternIntoTypes, TParseTemplateIntoTypes, TPartial, TPartialAction, TPartialDeferred, TPartialInstantiate, TPick, TPickAction, TPickDeferred, TPickInstantiate, TPriority, TProperties, TPropertyKeys, TPropertyValues, TReadonly, TReadonlyObject, TReadonlyObjectAction, TReadonlyObjectDeferred, TReadonlyObjectInstantiate, TRecord, TRecordAction, TRecordDeferred, TRecordInstantiate, TRecordKey, TRecordPattern, TRecordPatternToType, TRecordValue, TRef, TRefInstantiate, TRefine, TRefineAdd, TRefineCheckCallback, TRefineErrorCallback, TRefinement, TRemoveImmutable, TRemoveImmutableDeferred, TRemoveOptional, TRemoveOptionalDeferred, TRemoveReadonly, TRemoveReadonlyDeferred, TRequired, TRequiredAction, TRequiredArray, TRequiredDeferred, TRequiredInstantiate, TRest, TReturnType, TReturnTypeAction, TReturnTypeDeferred, TReturnTypeInstantiate, TSchema, TSchemaOptions, TScript, TScriptOptions, TStaticElements, TString, TStringKey, TStringOptions, TSymbol, TTemplateLiteral, TTemplateLiteralDecode, TTemplateLiteralDecodeUnsafe, TTemplateLiteralDeferred, TTemplateLiteralEncode, TTemplateLiteralFromString, TTemplateLiteralFromTypes, TTemplateLiteralStatic, TThis, TTuple, TTupleOptions, TTupleToIntersect, TTupleToUnion, TTypeScriptEnumLike, TTypeScriptEnumToEnumValues, TUncapitalize, TUncapitalizeAction, TUncapitalizeDeferred, TUncapitalizeInstantiate, TUndefined, TUnion, TUnionLast, TUnionToIntersect, TUnionToTuple, TUnknown, TUnsafe, TUppercase, TUppercaseAction, TUppercaseDeferred, TUppercaseInstantiate, TVoid, TWith, TWithAction, TWithDeferred, TWithInstantiate, TemplateLiteral, TemplateLiteralCreate, TemplateLiteralDecode, TemplateLiteralDecodeUnsafe, TemplateLiteralDeferred, TemplateLiteralEncode, TemplateLiteralFromString, TemplateLiteralFromTypes, This, Tuple, TupleOptions, TypeScriptEnumToEnumValues, Uncapitalize, UncapitalizeAction, UncapitalizeDeferred, UncapitalizeInstantiate, Undefined, Union, UnionOptions, Unknown, Unsafe, Uppercase, UppercaseAction, UppercaseDeferred, UppercaseInstantiate, Void, With, WithAction, WithDeferred, WithInstantiate, _Array_, _Function_, _Object_, index_d_exports, result_d_exports } from "./_chunks/libs/typebox.mjs";
2
- import { Icon, InputCheck, ToolCallContext, ToolCliHints, ToolContent, ToolDefinition, ToolDefinitionError, ToolEffect, ToolInputError, ToolProgress, ToolResult, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema } from "./_chunks/index.mjs";
3
- export { type AddImmutable, type AddImmutableDeferred, type AddOptional, type AddOptionalDeferred, type AddReadonly, type AddReadonlyDeferred, type Any, type _Array_ as Array, type _Array_, type ArrayOptions, type BigInt, type BigIntPattern, type Boolean, type Broaden, type Call, type CallConstruct, type CanComposite, type Capitalize, type CapitalizeAction, type CapitalizeDeferred, type CapitalizeInstantiate, type Codec, type CollapseToObject, type Compare, type CompareResultDisjoint, type CompareResultEqual, type CompareResultLeftInside, type CompareResultRightInside, type Composite, type Conditional, type ConditionalAction, type ConditionalDeferred, type ConditionalInstantiate, type Constructor, type ConstructorOptions, type ConstructorParameters, type ConstructorParametersAction, type ConstructorParametersDeferred, type ConstructorParametersInstantiate, type ConvertToIntegerKey, type Cyclic, type CyclicCandidates, type CyclicCheck, type CyclicDependencies, type CyclicExtends, type CyclicOptions, type CyclicTarget, type Decode, type DecodeBuilder, type Deferred, type Dependent, type DependentOptions, type Distribute, type Encode, type EncodeBuilder, type Enum, type Evaluate, type EvaluateAction, type EvaluateDeferred, type EvaluateDependent, type EvaluateEnum, type EvaluateInstantiate, type EvaluateIntersect, type EvaluateTemplateLiteral, type EvaluateType, type EvaluateUnion, type EvaluateUnionFast, type Exclude, type ExcludeAction, type ExcludeDeferred, type ExcludeInstantiate, type Extends, type result_d_exports as ExtendsResult, type Extract, type ExtractAction, type ExtractDeferred, type ExtractInstantiate, type Flatten, type _Function_ as Function, type _Function_, type FunctionOptions, type Generic, Icon, type Identifier, type Immutable, type Index, type IndexAction, type IndexDeferred, type IndexInstantiate, type Infer, InputCheck, type InstanceType, type InstanceTypeAction, type InstanceTypeDeferred, type InstanceTypeInstantiate, type Instantiate, type InstantiateCyclic, type Integer, type IntegerKey, type IntegerPattern, type Interface, type InterfaceAction, type InterfaceDeferred, type InterfaceInstantiate, type Intersect, type IntersectOptions, type InvalidLiteralValue, type IsAny, type IsArray, type IsBigInt, type IsBoolean, type IsCall, type IsCodec, type IsConstructor, type IsCyclic, type IsDeferred, type IsDependent, type IsEnum, type IsEnumValue, type IsFunction, type IsGeneric, type IsIdentifier, type IsImmutable, type IsInfer, type IsInteger, type IsInterfaceDeferred, type IsIntersect, type IsKind, type IsLiteral, type IsLiteralBigInt, type IsLiteralBoolean, type IsLiteralNumber, type IsLiteralString, type IsLiteralValue, type IsNever, type IsNull, type IsNumber, type IsObject, type IsOptional, type IsParameter, type IsReadonly, type IsRecord, type IsRef, type IsRefine, type IsRefinement, type IsRest, type IsSchema, type IsString, type IsSymbol, type IsTemplateLiteral, type IsTemplateLiteralDeferred, type IsTemplateLiteralFinite, type IsTemplateLiteralPattern, type IsThis, type IsTuple, type IsTypeScriptEnumLike, type IsUndefined, type IsUnion, type IsUnknown, type IsUnsafe, type IsVoid, type KeyOf, type KeyOfAction, type KeyOfDeferred, type KeyOfInstantiate, type KeysToIndexer, type Literal, type LiteralTypeName, type Lowercase, type LowercaseAction, type LowercaseDeferred, type LowercaseInstantiate, type Mapped, type MappedAction, type MappedDeferred, type MappedInstantiate, type Module, type ModuleDeferred, type ModuleInstantiate, type Narrow, type Never, type NeverPattern, type NonNullable, type NonNullableAction, type NonNullableDeferred, type NonNullableInstantiate, type Null, type Number, type NumberKey, type NumberPattern, type _Object_ as Object, type _Object_, type ObjectOptions, type Omit, type OmitAction, type OmitDeferred, type OmitInstantiate, type Optional, type Parameter, type Parameters, type ParametersAction, type ParametersDeferred, type ParametersInstantiate, type ParsePatternIntoTypes, type ParseTemplateIntoTypes, type Partial, type PartialAction, type PartialDeferred, type PartialInstantiate, type Pick, type PickAction, type PickDeferred, type PickInstantiate, type Priority, type PropertyKeys, type PropertyValues, type Readonly, type ReadonlyObject, type ReadonlyObjectAction, type ReadonlyObjectDeferred, type ReadonlyObjectInstantiate, type ReadonlyType, type Record, type RecordAction, type RecordDeferred, type RecordFromPattern, type RecordInstantiate, type RecordKey, type RecordOptions, type RecordPattern, type RecordPatternToType, type RecordValue, type Ref, type RefInstantiate, type Refine, type RefineAdd, type RemoveImmutable, type RemoveImmutableDeferred, type RemoveOptional, type RemoveOptionalDeferred, type RemoveReadonly, type RemoveReadonlyDeferred, type Required, type RequiredAction, type RequiredArray, type RequiredDeferred, type RequiredInstantiate, type Rest, type ReturnType, type ReturnTypeAction, type ReturnTypeDeferred, type ReturnTypeInstantiate, type Script, type Static, type StaticAny, type StaticArray, type StaticBigInt, type StaticBoolean, type StaticCodec, type StaticConstructor, type StaticCyclic, type StaticDecode, type StaticDependent, type StaticDirection, type StaticEncode, type StaticEnum, type StaticEvaluate, type StaticFunction, type StaticInstantiatedParameters, type StaticInteger, type StaticIntersect, type StaticLiteral, type StaticNever, type StaticNull, type StaticNumber, type StaticObject, type StaticParse, type StaticProperties, type StaticRecord, type StaticRef, type StaticString, type StaticSymbol, type StaticTemplateLiteral, type StaticThis, type StaticTuple, type StaticType, type StaticUndefined, type StaticUnion, type StaticUnknown, type StaticUnsafe, type StaticVoid, type String, type StringKey, type StringPattern, type Symbol, type TAddImmutable, type TAddImmutableDeferred, type TAddOptional, type TAddOptionalDeferred, type TAddReadonly, type TAddReadonlyDeferred, type TAny, type TArray, type TArrayOptions, type TBigInt, type TBoolean, type TBroaden, type TCall, type TCallConstruct, type TCanComposite, type TCapitalize, type TCapitalizeAction, type TCapitalizeDeferred, type TCapitalizeInstantiate, type TCodec, type TCollapseToObject, type TCompare, type TCompareResult, type TComposite, type TConditional, type TConditionalAction, type TConditionalDeferred, type TConditionalInstantiate, type TConstructor, type TConstructorParameters, type TConstructorParametersAction, type TConstructorParametersDeferred, type TConstructorParametersInstantiate, type TConvertToIntegerKey, type TCyclic, type TCyclicCandidates, type TCyclicCheck, type TCyclicDependencies, type TCyclicExtends, type TCyclicTarget, type TDecodeCallback, type TDeferred, type TDependent, type TDistribute, type TEncodeCallback, type TEnum, type TEnumValue, type TEvaluate, type TEvaluateAction, type TEvaluateDeferred, type TEvaluateDependent, type TEvaluateEnum, type TEvaluateInstantiate, type TEvaluateIntersect, type TEvaluateTemplateLiteral, type TEvaluateType, type TEvaluateUnion, type TEvaluateUnionFast, type TExclude, type TExcludeAction, type TExcludeDeferred, type TExcludeInstantiate, type TExtends, type TExtract, type TExtractAction, type TExtractDeferred, type TExtractInstantiate, type TFlatten, type TFormat, type TFunction, type TGeneric, type TIdentifier, type TImmutable, type TIndex, type TIndexAction, type TIndexDeferred, type TIndexInstantiate, type TInfer, type TInstanceType, type TInstanceTypeAction, type TInstanceTypeDeferred, type TInstanceTypeInstantiate, type TInstantiate, type TInstantiateCyclic, type TInteger, type TIntegerKey, type TInterface, type TInterfaceAction, type TInterfaceDeferred, type TInterfaceInstantiate, type TIntersect, type TIntersectOptions, type TIsTemplateLiteralFinite, type TIsTemplateLiteralPattern, type TKeyOf, type TKeyOfAction, type TKeyOfDeferred, type TKeyOfInstantiate, type TKeysToIndexer, type TLiteral, type TLiteralTypeName, type TLiteralValue, type TLowercase, type TLowercaseAction, type TLowercaseDeferred, type TLowercaseInstantiate, type TMapped, type TMappedAction, type TMappedDeferred, type TMappedInstantiate, type TModule, type TModuleDeferred, type TModuleInstantiate, type TNarrow, type TNever, type TNonNullable, type TNonNullableAction, type TNonNullableDeferred, type TNonNullableInstantiate, type TNull, type TNumber, type TNumberKey, type TNumberOptions, type TObject, type TObjectOptions, type TOmit, type TOmitAction, type TOmitDeferred, type TOmitInstantiate, type TOptional, type TParameter, type TParameters, type TParametersAction, type TParametersDeferred, type TParametersInstantiate, type TParsePatternIntoTypes, type TParseTemplateIntoTypes, type TPartial, type TPartialAction, type TPartialDeferred, type TPartialInstantiate, type TPick, type TPickAction, type TPickDeferred, type TPickInstantiate, type TPriority, type TProperties, type TPropertyKeys, type TPropertyValues, type TReadonly, type TReadonlyObject, type TReadonlyObjectAction, type TReadonlyObjectDeferred, type TReadonlyObjectInstantiate, type TRecord, type TRecordAction, type TRecordDeferred, type TRecordInstantiate, type TRecordKey, type TRecordPattern, type TRecordPatternToType, type TRecordValue, type TRef, type TRefInstantiate, type TRefine, type TRefineAdd, type TRefineCheckCallback, type TRefineErrorCallback, type TRefinement, type TRemoveImmutable, type TRemoveImmutableDeferred, type TRemoveOptional, type TRemoveOptionalDeferred, type TRemoveReadonly, type TRemoveReadonlyDeferred, type TRequired, type TRequiredAction, type TRequiredArray, type TRequiredDeferred, type TRequiredInstantiate, type TRest, type TReturnType, type TReturnTypeAction, type TReturnTypeDeferred, type TReturnTypeInstantiate, type TSchema, type TSchemaOptions, type TScript, type TScriptOptions, type TStaticElements, type TString, type TStringKey, type TStringOptions, type TSymbol, type TTemplateLiteral, type TTemplateLiteralDecode, type TTemplateLiteralDecodeUnsafe, type TTemplateLiteralDeferred, type TTemplateLiteralEncode, type TTemplateLiteralFromString, type TTemplateLiteralFromTypes, type TTemplateLiteralStatic, type TThis, type TTuple, type TTupleOptions, type TTupleToIntersect, type TTupleToUnion, type TTypeScriptEnumLike, type TTypeScriptEnumToEnumValues, type TUncapitalize, type TUncapitalizeAction, type TUncapitalizeDeferred, type TUncapitalizeInstantiate, type TUndefined, type TUnion, type TUnionLast, type TUnionToIntersect, type TUnionToTuple, type TUnknown, type TUnsafe, type TUppercase, type TUppercaseAction, type TUppercaseDeferred, type TUppercaseInstantiate, type TVoid, type TWith, type TWithAction, type TWithDeferred, type TWithInstantiate, type TemplateLiteral, type TemplateLiteralCreate, type TemplateLiteralDecode, type TemplateLiteralDecodeUnsafe, type TemplateLiteralDeferred, type TemplateLiteralEncode, type TemplateLiteralFromString, type TemplateLiteralFromTypes, type This, ToolCallContext, ToolCliHints, ToolContent, ToolDefinition, ToolDefinitionError, ToolEffect, ToolInputError, ToolProgress, ToolResult, type Tuple, type TupleOptions, index_d_exports as Type, type TypeScriptEnumToEnumValues, type Uncapitalize, type UncapitalizeAction, type UncapitalizeDeferred, type UncapitalizeInstantiate, type Undefined, type Union, type UnionOptions, type Unknown, type Unsafe, type Uppercase, type UppercaseAction, type UppercaseDeferred, type UppercaseInstantiate, type Void, type With, type WithAction, type WithDeferred, type WithInstantiate, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema };
2
+ import { Icon, InputCheck, InputIssue, ToolAnswer, ToolAsk, ToolCallContext, ToolCliHints, ToolContent, ToolDefinition, ToolDefinitionError, ToolEffect, ToolInputError, ToolProgress, ToolQuestion, ToolResult, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema } from "./_chunks/index.mjs";
3
+ export { type AddImmutable, type AddImmutableDeferred, type AddOptional, type AddOptionalDeferred, type AddReadonly, type AddReadonlyDeferred, type Any, type _Array_ as Array, type _Array_, type ArrayOptions, type BigInt, type BigIntPattern, type Boolean, type Broaden, type Call, type CallConstruct, type CanComposite, type Capitalize, type CapitalizeAction, type CapitalizeDeferred, type CapitalizeInstantiate, type Codec, type CollapseToObject, type Compare, type CompareResultDisjoint, type CompareResultEqual, type CompareResultLeftInside, type CompareResultRightInside, type Composite, type Conditional, type ConditionalAction, type ConditionalDeferred, type ConditionalInstantiate, type Constructor, type ConstructorOptions, type ConstructorParameters, type ConstructorParametersAction, type ConstructorParametersDeferred, type ConstructorParametersInstantiate, type ConvertToIntegerKey, type Cyclic, type CyclicCandidates, type CyclicCheck, type CyclicDependencies, type CyclicExtends, type CyclicOptions, type CyclicTarget, type Decode, type DecodeBuilder, type Deferred, type Dependent, type DependentOptions, type Distribute, type Encode, type EncodeBuilder, type Enum, type Evaluate, type EvaluateAction, type EvaluateDeferred, type EvaluateDependent, type EvaluateEnum, type EvaluateInstantiate, type EvaluateIntersect, type EvaluateTemplateLiteral, type EvaluateType, type EvaluateUnion, type EvaluateUnionFast, type Exclude, type ExcludeAction, type ExcludeDeferred, type ExcludeInstantiate, type Extends, type result_d_exports as ExtendsResult, type Extract, type ExtractAction, type ExtractDeferred, type ExtractInstantiate, type Flatten, type _Function_ as Function, type _Function_, type FunctionOptions, type Generic, Icon, type Identifier, type Immutable, type Index, type IndexAction, type IndexDeferred, type IndexInstantiate, type Infer, InputCheck, InputIssue, type InstanceType, type InstanceTypeAction, type InstanceTypeDeferred, type InstanceTypeInstantiate, type Instantiate, type InstantiateCyclic, type Integer, type IntegerKey, type IntegerPattern, type Interface, type InterfaceAction, type InterfaceDeferred, type InterfaceInstantiate, type Intersect, type IntersectOptions, type InvalidLiteralValue, type IsAny, type IsArray, type IsBigInt, type IsBoolean, type IsCall, type IsCodec, type IsConstructor, type IsCyclic, type IsDeferred, type IsDependent, type IsEnum, type IsEnumValue, type IsFunction, type IsGeneric, type IsIdentifier, type IsImmutable, type IsInfer, type IsInteger, type IsInterfaceDeferred, type IsIntersect, type IsKind, type IsLiteral, type IsLiteralBigInt, type IsLiteralBoolean, type IsLiteralNumber, type IsLiteralString, type IsLiteralValue, type IsNever, type IsNull, type IsNumber, type IsObject, type IsOptional, type IsParameter, type IsReadonly, type IsRecord, type IsRef, type IsRefine, type IsRefinement, type IsRest, type IsSchema, type IsString, type IsSymbol, type IsTemplateLiteral, type IsTemplateLiteralDeferred, type IsTemplateLiteralFinite, type IsTemplateLiteralPattern, type IsThis, type IsTuple, type IsTypeScriptEnumLike, type IsUndefined, type IsUnion, type IsUnknown, type IsUnsafe, type IsVoid, type KeyOf, type KeyOfAction, type KeyOfDeferred, type KeyOfInstantiate, type KeysToIndexer, type Literal, type LiteralTypeName, type Lowercase, type LowercaseAction, type LowercaseDeferred, type LowercaseInstantiate, type Mapped, type MappedAction, type MappedDeferred, type MappedInstantiate, type Module, type ModuleDeferred, type ModuleInstantiate, type Narrow, type Never, type NeverPattern, type NonNullable, type NonNullableAction, type NonNullableDeferred, type NonNullableInstantiate, type Null, type Number, type NumberKey, type NumberPattern, type _Object_ as Object, type _Object_, type ObjectOptions, type Omit, type OmitAction, type OmitDeferred, type OmitInstantiate, type Optional, type Parameter, type Parameters, type ParametersAction, type ParametersDeferred, type ParametersInstantiate, type ParsePatternIntoTypes, type ParseTemplateIntoTypes, type Partial, type PartialAction, type PartialDeferred, type PartialInstantiate, type Pick, type PickAction, type PickDeferred, type PickInstantiate, type Priority, type PropertyKeys, type PropertyValues, type Readonly, type ReadonlyObject, type ReadonlyObjectAction, type ReadonlyObjectDeferred, type ReadonlyObjectInstantiate, type ReadonlyType, type Record, type RecordAction, type RecordDeferred, type RecordFromPattern, type RecordInstantiate, type RecordKey, type RecordOptions, type RecordPattern, type RecordPatternToType, type RecordValue, type Ref, type RefInstantiate, type Refine, type RefineAdd, type RemoveImmutable, type RemoveImmutableDeferred, type RemoveOptional, type RemoveOptionalDeferred, type RemoveReadonly, type RemoveReadonlyDeferred, type Required, type RequiredAction, type RequiredArray, type RequiredDeferred, type RequiredInstantiate, type Rest, type ReturnType, type ReturnTypeAction, type ReturnTypeDeferred, type ReturnTypeInstantiate, type Script, type Static, type StaticAny, type StaticArray, type StaticBigInt, type StaticBoolean, type StaticCodec, type StaticConstructor, type StaticCyclic, type StaticDecode, type StaticDependent, type StaticDirection, type StaticEncode, type StaticEnum, type StaticEvaluate, type StaticFunction, type StaticInstantiatedParameters, type StaticInteger, type StaticIntersect, type StaticLiteral, type StaticNever, type StaticNull, type StaticNumber, type StaticObject, type StaticParse, type StaticProperties, type StaticRecord, type StaticRef, type StaticString, type StaticSymbol, type StaticTemplateLiteral, type StaticThis, type StaticTuple, type StaticType, type StaticUndefined, type StaticUnion, type StaticUnknown, type StaticUnsafe, type StaticVoid, type String, type StringKey, type StringPattern, type Symbol, type TAddImmutable, type TAddImmutableDeferred, type TAddOptional, type TAddOptionalDeferred, type TAddReadonly, type TAddReadonlyDeferred, type TAny, type TArray, type TArrayOptions, type TBigInt, type TBoolean, type TBroaden, type TCall, type TCallConstruct, type TCanComposite, type TCapitalize, type TCapitalizeAction, type TCapitalizeDeferred, type TCapitalizeInstantiate, type TCodec, type TCollapseToObject, type TCompare, type TCompareResult, type TComposite, type TConditional, type TConditionalAction, type TConditionalDeferred, type TConditionalInstantiate, type TConstructor, type TConstructorParameters, type TConstructorParametersAction, type TConstructorParametersDeferred, type TConstructorParametersInstantiate, type TConvertToIntegerKey, type TCyclic, type TCyclicCandidates, type TCyclicCheck, type TCyclicDependencies, type TCyclicExtends, type TCyclicTarget, type TDecodeCallback, type TDeferred, type TDependent, type TDistribute, type TEncodeCallback, type TEnum, type TEnumValue, type TEvaluate, type TEvaluateAction, type TEvaluateDeferred, type TEvaluateDependent, type TEvaluateEnum, type TEvaluateInstantiate, type TEvaluateIntersect, type TEvaluateTemplateLiteral, type TEvaluateType, type TEvaluateUnion, type TEvaluateUnionFast, type TExclude, type TExcludeAction, type TExcludeDeferred, type TExcludeInstantiate, type TExtends, type TExtract, type TExtractAction, type TExtractDeferred, type TExtractInstantiate, type TFlatten, type TFormat, type TFunction, type TGeneric, type TIdentifier, type TImmutable, type TIndex, type TIndexAction, type TIndexDeferred, type TIndexInstantiate, type TInfer, type TInstanceType, type TInstanceTypeAction, type TInstanceTypeDeferred, type TInstanceTypeInstantiate, type TInstantiate, type TInstantiateCyclic, type TInteger, type TIntegerKey, type TInterface, type TInterfaceAction, type TInterfaceDeferred, type TInterfaceInstantiate, type TIntersect, type TIntersectOptions, type TIsTemplateLiteralFinite, type TIsTemplateLiteralPattern, type TKeyOf, type TKeyOfAction, type TKeyOfDeferred, type TKeyOfInstantiate, type TKeysToIndexer, type TLiteral, type TLiteralTypeName, type TLiteralValue, type TLowercase, type TLowercaseAction, type TLowercaseDeferred, type TLowercaseInstantiate, type TMapped, type TMappedAction, type TMappedDeferred, type TMappedInstantiate, type TModule, type TModuleDeferred, type TModuleInstantiate, type TNarrow, type TNever, type TNonNullable, type TNonNullableAction, type TNonNullableDeferred, type TNonNullableInstantiate, type TNull, type TNumber, type TNumberKey, type TNumberOptions, type TObject, type TObjectOptions, type TOmit, type TOmitAction, type TOmitDeferred, type TOmitInstantiate, type TOptional, type TParameter, type TParameters, type TParametersAction, type TParametersDeferred, type TParametersInstantiate, type TParsePatternIntoTypes, type TParseTemplateIntoTypes, type TPartial, type TPartialAction, type TPartialDeferred, type TPartialInstantiate, type TPick, type TPickAction, type TPickDeferred, type TPickInstantiate, type TPriority, type TProperties, type TPropertyKeys, type TPropertyValues, type TReadonly, type TReadonlyObject, type TReadonlyObjectAction, type TReadonlyObjectDeferred, type TReadonlyObjectInstantiate, type TRecord, type TRecordAction, type TRecordDeferred, type TRecordInstantiate, type TRecordKey, type TRecordPattern, type TRecordPatternToType, type TRecordValue, type TRef, type TRefInstantiate, type TRefine, type TRefineAdd, type TRefineCheckCallback, type TRefineErrorCallback, type TRefinement, type TRemoveImmutable, type TRemoveImmutableDeferred, type TRemoveOptional, type TRemoveOptionalDeferred, type TRemoveReadonly, type TRemoveReadonlyDeferred, type TRequired, type TRequiredAction, type TRequiredArray, type TRequiredDeferred, type TRequiredInstantiate, type TRest, type TReturnType, type TReturnTypeAction, type TReturnTypeDeferred, type TReturnTypeInstantiate, type TSchema, type TSchemaOptions, type TScript, type TScriptOptions, type TStaticElements, type TString, type TStringKey, type TStringOptions, type TSymbol, type TTemplateLiteral, type TTemplateLiteralDecode, type TTemplateLiteralDecodeUnsafe, type TTemplateLiteralDeferred, type TTemplateLiteralEncode, type TTemplateLiteralFromString, type TTemplateLiteralFromTypes, type TTemplateLiteralStatic, type TThis, type TTuple, type TTupleOptions, type TTupleToIntersect, type TTupleToUnion, type TTypeScriptEnumLike, type TTypeScriptEnumToEnumValues, type TUncapitalize, type TUncapitalizeAction, type TUncapitalizeDeferred, type TUncapitalizeInstantiate, type TUndefined, type TUnion, type TUnionLast, type TUnionToIntersect, type TUnionToTuple, type TUnknown, type TUnsafe, type TUppercase, type TUppercaseAction, type TUppercaseDeferred, type TUppercaseInstantiate, type TVoid, type TWith, type TWithAction, type TWithDeferred, type TWithInstantiate, type TemplateLiteral, type TemplateLiteralCreate, type TemplateLiteralDecode, type TemplateLiteralDecodeUnsafe, type TemplateLiteralDeferred, type TemplateLiteralEncode, type TemplateLiteralFromString, type TemplateLiteralFromTypes, type This, ToolAnswer, ToolAsk, ToolCallContext, ToolCliHints, ToolContent, ToolDefinition, ToolDefinitionError, ToolEffect, ToolInputError, ToolProgress, ToolQuestion, ToolResult, type Tuple, type TupleOptions, index_d_exports as Type, type TypeScriptEnumToEnumValues, type Uncapitalize, type UncapitalizeAction, type UncapitalizeDeferred, type UncapitalizeInstantiate, type Undefined, type Union, type UnionOptions, type Unknown, type Unsafe, type Uppercase, type UppercaseAction, type UppercaseDeferred, type UppercaseInstantiate, type Void, type With, type WithAction, type WithDeferred, type WithInstantiate, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema };
package/dist/mcp.d.mts CHANGED
@@ -1,55 +1,6 @@
1
- import { Icon, ToolCallContext, ToolDefinition } from "./_chunks/index.mjs";
2
- import { CallToolResult, Server, Tool, ToolAnnotations } from "@modelcontextprotocol/server";
3
- interface McpServerInfo {
4
- /** Server name, also used in the unknown-tool message. */
5
- readonly name: string;
6
- readonly version: string;
7
- /** Display name for clients that show one, such as `Forges`. */
8
- readonly title?: string;
9
- /** One line under the name on a connector card or in a registry. */
10
- readonly description?: string;
11
- readonly icons?: readonly Icon[];
12
- /** Project home a client can link to. */
13
- readonly websiteUrl?: string;
14
- }
15
- /**
16
- * Maps a tool's title and declared effect to MCP annotations. Claude Code reads its label here.
17
- *
18
- * @param tool - Tool to describe.
19
- * @returns {ToolAnnotations} Title and hints for the MCP client.
20
- */
21
- export declare function toolAnnotations(tool: ToolDefinition): ToolAnnotations;
22
- /**
23
- * Error result with every line-forging character replaced.
24
- *
25
- * The messages echo client-controlled values (a tool name, an argument) and
26
- * downstream error text, so they pass through here on every branch. Each line
27
- * is cleaned on its own, so only the breaks between the lines passed in
28
- * survive; a newline inside one line becomes a space.
29
- *
30
- * @param lines - Error lines.
31
- * @returns {CallToolResult} MCP error result.
32
- */
33
- export declare function errorResult(...lines: readonly string[]): CallToolResult;
34
- /**
35
- * The entries `tools/list` answers with, in the order given.
36
- *
37
- * @param tools - Tools to list.
38
- * @returns {Tool[]} Name, title, description, icons, schema and annotations of each tool.
39
- * @throws {ToolDefinitionError} When two tools share a name.
40
- */
41
- export declare function listTools(tools: readonly ToolDefinition[]): Tool[];
42
- /**
43
- * Answers one call as `tools/call` does and never throws, so every transport gives the same text.
44
- *
45
- * @param info - Server info; `name` is the word in the message for an unknown tool.
46
- * @param tools - Tools to look the name up in.
47
- * @param name - Tool name as the client sent it.
48
- * @param args - Arguments as the client sent them; missing ones count as `{}`.
49
- * @param context - Context for this call, such as the request's abort signal.
50
- * @returns {Promise<CallToolResult>} The tool's text, or the sanitized error.
51
- */
52
- export declare function callTool(info: Pick<McpServerInfo, "name">, tools: readonly ToolDefinition[], name: string, args?: unknown, context?: ToolCallContext): Promise<CallToolResult>;
1
+ import { ToolDefinition } from "./_chunks/index.mjs";
2
+ import { McpServerInfo, callTool, errorResult, listTools, toolAnnotations } from "./_chunks/mcp-answers.mjs";
3
+ import { Server } from "@modelcontextprotocol/server";
53
4
  /**
54
5
  * Creates an unconnected MCP server exposing the tools.
55
6
  *
@@ -60,17 +11,19 @@ export declare function callTool(info: Pick<McpServerInfo, "name">, tools: reado
60
11
  * raw tool name with newlines and escapes into its error, joins validation
61
12
  * failures into one line and passes a thrown message through unsanitized.
62
13
  *
63
- * `details` never reaches the client and `structuredContent` is never set:
14
+ * `details` reach the client only from a tool with `output`, as `structuredContent`:
64
15
  * clients that see structured output prefer it over `content` and would hide
65
16
  * the readable answer. Every fact a follow-up call needs belongs in the text.
66
17
  *
67
18
  * A progress notification that fails to send goes to `onerror`, never to the tool.
68
19
  *
20
+ * A client that declares `elicitation` gets `ask`, through `input_required` on both revisions.
21
+ * A 2026 request carries its capabilities itself, a 2025 one declared them at `initialize`.
22
+ *
69
23
  * @param info - Name, version and optional title, description, icons and website, sent as given.
70
24
  * @param tools - Tools to serve.
71
25
  * @returns {Server} Unconnected MCP server.
72
26
  * @throws {ToolDefinitionError} When two tools share a name.
73
27
  */
74
28
  export declare function createMcpServer(info: McpServerInfo, tools: readonly ToolDefinition[]): Server;
75
- export type { McpServerInfo };
76
- //# sourceMappingURL=mcp.d.mts.map
29
+ export { type McpServerInfo, callTool, errorResult, listTools, toolAnnotations };
package/dist/mcp.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { indexTools } from "./_chunks/src.mjs";
2
- import { callTool, copyIcons, errorResult, listTools, progressSteps, toolAnnotations } from "./_chunks/mcp-answers.mjs";
2
+ import { callAsking, callTool, canAsk, copyIcons, errorResult, listTools, progressSteps, questionRound, toolAnnotations } from "./_chunks/mcp-answers.mjs";
3
3
  import { Server } from "@modelcontextprotocol/server";
4
4
  function createMcpServer(info, tools) {
5
5
  indexTools(tools);
@@ -13,7 +13,7 @@ function createMcpServer(info, tools) {
13
13
  websiteUrl
14
14
  }, { capabilities: { tools: {} } });
15
15
  server.setRequestHandler("tools/list", () => ({ tools: listTools(tools) }));
16
- server.setRequestHandler("tools/call", (request, ctx) => {
16
+ server.setRequestHandler("tools/call", async (request, ctx) => {
17
17
  const progressToken = ctx.mcpReq._meta?.progressToken;
18
18
  const notify = (params) => {
19
19
  ctx.mcpReq.notify({
@@ -26,13 +26,18 @@ function createMcpServer(info, tools) {
26
26
  server.onerror?.(error instanceof Error ? error : new Error(String(error)));
27
27
  });
28
28
  };
29
- return callTool(info, tools, request.params.name, request.params.arguments, {
29
+ const capabilities = ctx.mcpReq.envelope?.["io.modelcontextprotocol/clientCapabilities"] ?? server.getClientCapabilities();
30
+ const round = canAsk(capabilities) ? questionRound(ctx.mcpReq.inputResponses, stateOf(ctx.mcpReq.requestState())) : void 0;
31
+ const context = {
30
32
  signal: ctx.mcpReq.signal,
31
33
  ...progressToken === void 0 ? {} : { progress: progressSteps(notify) }
32
- });
34
+ };
35
+ const { name, arguments: args } = request.params;
36
+ return await callAsking(info, tools, name, args, context, round);
33
37
  });
34
38
  return server;
35
39
  }
40
+ function stateOf(state) {
41
+ return typeof state === "string" ? state : void 0;
42
+ }
36
43
  export { callTool, createMcpServer, errorResult, listTools, toolAnnotations };
37
-
38
- //# sourceMappingURL=mcp.mjs.map
package/dist/omp.d.mts CHANGED
@@ -41,5 +41,4 @@ export interface OmpToolOptions {
41
41
  * @param options - Host `Text`, optional load mode and renderers.
42
42
  * @throws {ToolDefinitionError} When two tools share a name.
43
43
  */
44
- export declare function registerOmpTools(pi: ExtensionAPI, tools: readonly ToolDefinition$1[], options: OmpToolOptions): void;
45
- //# sourceMappingURL=omp.d.mts.map
44
+ export declare function registerOmpTools(pi: ExtensionAPI, tools: readonly ToolDefinition$1[], options: OmpToolOptions): void;
package/dist/omp.mjs CHANGED
@@ -54,5 +54,3 @@ function callIcon(options, theme) {
54
54
  return theme.spinnerFrames[options.spinnerFrame % theme.spinnerFrames.length] ?? theme.styledSymbol("status.running", "accent");
55
55
  }
56
56
  export { registerOmpTools };
57
-
58
- //# sourceMappingURL=omp.mjs.map
package/dist/pi.d.mts CHANGED
@@ -41,5 +41,4 @@ export interface PiRenderers extends Readonly<Pick<ToolDefinition, "renderCall"
41
41
  * @throws {ToolDefinitionError} When two tools share a name, a tool has `describeCall` but no
42
42
  * `Text` came with it, or `confirm` names a tool that isn't in the list.
43
43
  */
44
- export declare function registerPiTools(pi: ExtensionAPI, tools: readonly ToolDefinition$1[], options?: PiToolOptions): void;
45
- //# sourceMappingURL=pi.d.mts.map
44
+ export declare function registerPiTools(pi: ExtensionAPI, tools: readonly ToolDefinition$1[], options?: PiToolOptions): void;
package/dist/pi.mjs CHANGED
@@ -30,7 +30,7 @@ function byName(entries, name) {
30
30
  }
31
31
  async function approve(tool, ask, params, signal, ctx) {
32
32
  const checked = validateInput(tool, params);
33
- if (!checked.ok) throw new ToolInputError(checked.lines);
33
+ if (!checked.ok) throw new ToolInputError(checked.lines, checked.issues);
34
34
  const question = await ask(checked.value);
35
35
  if (question === void 0) return;
36
36
  if (!ctx.hasUI) throw new Error(`${tool.name} needs interactive approval in Pi TUI or RPC mode`);
@@ -54,5 +54,3 @@ function hostRenderers(tool, renderers, Text) {
54
54
  };
55
55
  }
56
56
  export { registerPiTools };
57
-
58
- //# sourceMappingURL=pi.mjs.map
@@ -0,0 +1,78 @@
1
+ import { ToolDefinition } from "./_chunks/index.mjs";
2
+ /** The part of the SDK v1 request `extra` a handler reads: abort signal, progress and questions. */
3
+ export interface ToolkitExtra {
4
+ readonly signal?: AbortSignal;
5
+ readonly _meta?: {
6
+ readonly progressToken?: string | number;
7
+ };
8
+ readonly sendNotification?: (notification: {
9
+ readonly method: "notifications/progress";
10
+ readonly params: {
11
+ readonly progressToken: string | number;
12
+ readonly progress: number;
13
+ readonly total?: number;
14
+ readonly message: string;
15
+ };
16
+ }) => Promise<void>;
17
+ /** Both schemas are `never`, so SDK v1's method fits whatever Zod and schema types it carries. */
18
+ readonly sendRequest?: (request: {
19
+ readonly method: "elicitation/create";
20
+ readonly params: {
21
+ readonly mode: "form";
22
+ readonly message: string;
23
+ readonly requestedSchema: never;
24
+ };
25
+ }, resultSchema: never, options?: {
26
+ readonly signal?: AbortSignal;
27
+ }) => Promise<unknown>;
28
+ }
29
+ /** The toolkit's `useMcpElicitation`, or anything that knows if the client fills forms. */
30
+ export type ToolkitElicitation = () => {
31
+ readonly supports: (mode?: "form") => boolean;
32
+ };
33
+ /** How `toToolkitTools` reaches the person behind the client. */
34
+ export interface ToolkitOptions {
35
+ /** Pass `useMcpElicitation` to give `execute` an `ask`. It runs in every handler. */
36
+ readonly elicitation?: ToolkitElicitation;
37
+ }
38
+ /** What a handler answers. The toolkit runs SDK v1, so these types never name the v2 package. */
39
+ export interface ToolkitResult {
40
+ [key: string]: unknown;
41
+ content: Array<{
42
+ [key: string]: unknown;
43
+ type: string;
44
+ }>;
45
+ isError?: boolean;
46
+ }
47
+ /** One toolkit tool. Schemas stay `unknown`, since pnpm gives the toolkit its own `zod` copy. */
48
+ export interface ToolkitTool {
49
+ readonly name: string;
50
+ readonly title?: string;
51
+ readonly description?: string;
52
+ readonly annotations?: {
53
+ readonly title?: string;
54
+ readonly readOnlyHint?: boolean;
55
+ readonly destructiveHint?: boolean;
56
+ readonly idempotentHint?: boolean;
57
+ readonly openWorldHint?: boolean;
58
+ };
59
+ readonly inputSchema: unknown;
60
+ readonly outputSchema?: unknown;
61
+ readonly _meta?: Record<string, unknown>;
62
+ readonly handler: (args: unknown, extra?: ToolkitExtra) => Promise<ToolkitResult>;
63
+ }
64
+ /**
65
+ * Turns tools into toolkit entries that list what `listTools` lists and answer via `callTool`.
66
+ *
67
+ * Progress and questions need the toolkit's sessions: its stateless default answers in plain JSON.
68
+ * `useMcpElicitation` also needs Nitro's `asyncContext`, since it finds the server in the request.
69
+ *
70
+ * @param info - Server info; `name` is the word in the message for an unknown tool.
71
+ * @param tools - Tools to serve.
72
+ * @param options - Where `ask` comes from; without it there is none.
73
+ * @returns {ToolkitTool[]} Tool definitions in the order given.
74
+ * @throws {ToolDefinitionError} When two tools share a name.
75
+ */
76
+ export declare function toToolkitTools(info: {
77
+ readonly name: string;
78
+ }, tools: readonly ToolDefinition[], options?: ToolkitOptions): ToolkitTool[];
@@ -0,0 +1,62 @@
1
+ import "./_chunks/src.mjs";
2
+ import { hostAsk } from "./_chunks/questions.mjs";
3
+ import { callTool, listTools, progressSteps } from "./_chunks/mcp-answers.mjs";
4
+ import { z } from "zod";
5
+ function toToolkitTools(info, tools, options = {}) {
6
+ return listTools(tools).map((entry) => ({
7
+ name: entry.name,
8
+ title: entry.title,
9
+ description: entry.description,
10
+ annotations: entry.annotations,
11
+ inputSchema: wireObject(entry.inputSchema, true),
12
+ ...entry.outputSchema === void 0 ? {} : { outputSchema: wireObject(entry.outputSchema, false) },
13
+ ...entry._meta === void 0 ? {} : { _meta: entry._meta },
14
+ handler: async (args, extra) => callTool(info, tools, entry.name, args, {
15
+ ...callContext(extra),
16
+ ...formAsk(extra, options.elicitation)
17
+ })
18
+ }));
19
+ }
20
+ function wireObject(schema, input) {
21
+ const object = z.looseObject({});
22
+ object._zod.toJSONSchema = () => ({ ...schema });
23
+ if (!input) return object;
24
+ object._zod.run = missingAsEmpty(object._zod.run.bind(object._zod));
25
+ return object;
26
+ }
27
+ function missingAsEmpty(run) {
28
+ return (payload, context) => run(payload.value === void 0 ? {
29
+ ...payload,
30
+ value: {}
31
+ } : payload, context);
32
+ }
33
+ function callContext(extra) {
34
+ const progressToken = extra?._meta?.progressToken;
35
+ const send = extra?.sendNotification;
36
+ return {
37
+ signal: extra?.signal,
38
+ ...progressToken === void 0 || send === void 0 ? {} : { progress: progressSteps((params) => {
39
+ send({
40
+ method: "notifications/progress",
41
+ params: {
42
+ progressToken,
43
+ ...params
44
+ }
45
+ }).catch(() => void 0);
46
+ }) }
47
+ };
48
+ }
49
+ function formAsk(extra, elicitation) {
50
+ const send = extra?.sendRequest;
51
+ if (send === void 0 || elicitation?.().supports("form") !== true) return {};
52
+ const reply = z.looseObject({});
53
+ return { ask: hostAsk(async ({ message, requested }) => await send({
54
+ method: "elicitation/create",
55
+ params: {
56
+ mode: "form",
57
+ message,
58
+ requestedSchema: requested
59
+ }
60
+ }, reply, { signal: extra?.signal })) };
61
+ }
62
+ export { toToolkitTools };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agntn/tools",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "One tool definition for MCP, Pi, OMP and the AI SDK",
5
5
  "homepage": "https://github.com/agntn/tools#readme",
6
6
  "bugs": "https://github.com/agntn/tools/issues",
@@ -28,6 +28,10 @@
28
28
  "types": "./dist/h3.d.mts",
29
29
  "import": "./dist/h3.mjs"
30
30
  },
31
+ "./toolkit": {
32
+ "types": "./dist/toolkit.d.mts",
33
+ "import": "./dist/toolkit.mjs"
34
+ },
31
35
  "./pi": {
32
36
  "types": "./dist/pi.d.mts",
33
37
  "import": "./dist/pi.mjs"
@@ -52,6 +56,7 @@
52
56
  "@agntn/ox": "0.1.0",
53
57
  "@earendil-works/pi-coding-agent": "1.0.1",
54
58
  "@modelcontextprotocol/client": "2.2.0",
59
+ "@modelcontextprotocol/sdk": "1.32.1",
55
60
  "@modelcontextprotocol/server": "2.2.0",
56
61
  "@oh-my-pi/pi-coding-agent": "18.0.0",
57
62
  "@types/node": "26.2.0",
@@ -63,14 +68,16 @@
63
68
  "typebox": "1.3.34",
64
69
  "typescript": "7.0.2",
65
70
  "vite": "npm:@voidzero-dev/vite-plus-core@1.0.0",
66
- "vite-plus": "1.0.0"
71
+ "vite-plus": "1.0.0",
72
+ "zod": "4.6.5"
67
73
  },
68
74
  "peerDependencies": {
69
75
  "@earendil-works/pi-coding-agent": ">=0.84.2 <2",
70
76
  "@modelcontextprotocol/server": ">=2.2.0 <3",
71
77
  "@oh-my-pi/pi-coding-agent": ">=18.0.0 <19",
72
78
  "ai": ">=7.0.0 <8",
73
- "h3-mcp": ">=0.2.0 <0.3"
79
+ "h3-mcp": ">=0.2.0 <0.3",
80
+ "zod": ">=4.1.13 <5"
74
81
  },
75
82
  "peerDependenciesMeta": {
76
83
  "@earendil-works/pi-coding-agent": {
@@ -87,6 +94,9 @@
87
94
  },
88
95
  "h3-mcp": {
89
96
  "optional": true
97
+ },
98
+ "zod": {
99
+ "optional": true
90
100
  }
91
101
  },
92
102
  "engines": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/escapes.ts","../../src/index.ts"],"mappings":";;;;;;;;;;wBAwDgB,aAAa;;YCtBjB;EACN;EAAc;;EACd;EAAe;EAAc;;;iBAGlB,WAAW;EAC1B,SAAS;EACT,SAAS;;EAET;;;;;;;;;YAUU;;;;;iBAMK;;WAEN;WACA;;WAEA;;WAEA;;WAEA;;WAEA,QAAQ,SAAS;;WAEjB;;WAEA;;;iBAIM;;WAEN;;WAEA;;;iBAIM;WACN;WACA;;WAEA;;WAEA;;;iBAIM;EACf,SAAS;;EAET,YAAY,iBAAiB,SAAS;;EAEtC;;iBAGe,eAAe,cAAc,UAAU,SAAS;;WAEtD;;WAEA;;WAEA;;WAEA,iBAAiB;;WAEjB;;WAEA;WACA,QAAQ;;WAER;;WAEA;WACA,OAAO;;WAEP,MAAM;;;;;;;EAOf,QACE,OAAO,OAAO,QACd,SAAS,kBACR,WAAW,WAAW,QAAQ,WAAW;;;qBAIjC,4BAA4B;EAC9B;;;qBAIE,uBAAuB;EACzB;;WAEA;;;;EAKT,YAAY;;;;;;;;wBAcE,iBAAiB,cAAc,SAAS,SACtD,MAAM,eAAe,OAAO,WAC3B,eAAe,OAAO;;;;;;;;;;wBA+GT,WAAW,MAAM,iBAAiB;;;;;;;;;;wBAalC,WAAW,gBAAgB,mBAAmB,oBAAoB;YAStE,WAAW,cAAc;EAC/B;EAAU,OAAO,OAAO;;EACxB;EAAW;;;;;;;;;;;;;;;;wBAgBD,cAAc,cAAc,SAC1C,MAAM,eAAe,iBACrB,gBACC,WAAW;;;;;;;;;;;;;wBA4JQ,WACpB,MAAM,gBACN,eACA,UAAS,kBACR,QAAQ;;;;;;;;;;;;wBAmCK,aAAa;;;;;;;wBAab,WAAW,QAAQ"}