@agntn/tools 0.3.3 → 0.4.1

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/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, 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, EvaluatePropertyIntersect, EvaluatePropertyUnion, 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, 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, TEvaluatePropertyIntersect, TEvaluatePropertyUnion, 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, 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 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 EvaluatePropertyIntersect, type EvaluatePropertyUnion, 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 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 TEvaluatePropertyIntersect, type TEvaluatePropertyUnion, 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 };
2
+ import { Icon, InputCheck, InputIssue, ToolAnswer, ToolAsk, ToolCallContext, ToolCliHints, ToolContent, ToolDefinition, ToolDefinitionError, ToolEffect, ToolInputError, ToolProgress, ToolQuestion, ToolResult, defineTool, indexTools, invokeTool, lazy, 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 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 EvaluatePropertyIntersect, type EvaluatePropertyUnion, 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 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 TEvaluatePropertyIntersect, type TEvaluatePropertyUnion, 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, lazy, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import { type_exports } from "./_chunks/libs/typebox.mjs";
2
- import { ToolDefinitionError, ToolInputError, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema } from "./_chunks/src.mjs";
3
- export { ToolDefinitionError, ToolInputError, type_exports as Type, defineTool, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema };
2
+ import { ToolDefinitionError, ToolInputError, defineTool, indexTools, invokeTool, lazy, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema } from "./_chunks/src.mjs";
3
+ export { ToolDefinitionError, ToolInputError, type_exports as Type, defineTool, indexTools, invokeTool, lazy, resultText, sanitizeLine, sanitizeText, validateInput, wireSchema };
package/dist/mcp.d.mts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { ToolDefinition } from "./_chunks/index.mjs";
2
2
  import { McpHost, McpServerInfo, callTool, errorResult, listTools, toolAnnotations } from "./_chunks/mcp-answers.mjs";
3
3
  import { Server } from "@modelcontextprotocol/server";
4
+ /** Options for {@link createMcpServer}. */
5
+ export interface McpServerOptions {
6
+ /** Asked before and after each call: a reason or a throw turns it away, `undefined` doesn't. */
7
+ readonly refuse?: () => string | undefined | PromiseLike<string | undefined>;
8
+ }
4
9
  /**
5
10
  * Creates an unconnected MCP server exposing the tools.
6
11
  *
@@ -19,13 +24,17 @@ import { Server } from "@modelcontextprotocol/server";
19
24
  *
20
25
  * A client that declares `elicitation` gets `ask`, through `input_required` on both revisions.
21
26
  * A 2026 request carries its capabilities itself, a 2025 one declared them at `initialize`.
27
+ * ChatGPT on 2025 gets `openai/elicitation/create`, the only method it hears.
22
28
  *
23
29
  * `host` is an {@link McpHost}: the HTTP request on an HTTP transport, the call's `_meta` on any.
24
30
  *
25
- * @param info - Name, version and optional title, description, icons and website, sent as given.
31
+ * `refuse` turns calls away. Past a call that isn't idempotent, it says the call may have run.
32
+ *
33
+ * @param info - Name, version and optional title, description, icons, website and instructions.
26
34
  * @param tools - Tools to serve.
35
+ * @param options - The `refuse` guard.
27
36
  * @returns {Server} Unconnected MCP server.
28
37
  * @throws {ToolDefinitionError} When two tools share a name.
29
38
  */
30
- export declare function createMcpServer(info: McpServerInfo, tools: readonly ToolDefinition[]): Server;
39
+ export declare function createMcpServer(info: McpServerInfo, tools: readonly ToolDefinition[], options?: McpServerOptions): Server;
31
40
  export { type McpHost, type McpServerInfo, callTool, errorResult, listTools, toolAnnotations };
package/dist/mcp.mjs CHANGED
@@ -1,9 +1,12 @@
1
1
  import { indexTools } from "./_chunks/src.mjs";
2
- import { callAsking, callTool, canAsk, copyIcons, errorResult, listTools, mcpHost, progressSteps, questionRound, toolAnnotations } from "./_chunks/mcp-answers.mjs";
2
+ import { hostAsk } from "./_chunks/questions.mjs";
3
+ import { ANSWER_TIMEOUT, askForm, callAsking, callTool, canAsk, copyIcons, errorResult, fillsOpenaiForms, listTools, mcpHost, openaiElicitRequest, progressSteps, questionRound, toolAnnotations } from "./_chunks/mcp-answers.mjs";
3
4
  import { Server } from "@modelcontextprotocol/server";
4
- function createMcpServer(info, tools) {
5
- indexTools(tools);
6
- const { name, version, title, description, icons, websiteUrl } = info;
5
+ const DROPPED = "The call's answer was dropped, and it may have run. Check before retrying.";
6
+ function createMcpServer(info, tools, options = {}) {
7
+ const byName = indexTools(tools);
8
+ const { refuse } = options;
9
+ const { name, version, title, description, icons, websiteUrl, instructions } = info;
7
10
  const server = new Server({
8
11
  name,
9
12
  version,
@@ -11,9 +14,12 @@ function createMcpServer(info, tools) {
11
14
  description,
12
15
  ...icons === void 0 ? {} : { icons: copyIcons(icons) },
13
16
  websiteUrl
14
- }, { capabilities: { tools: {} } });
17
+ }, {
18
+ capabilities: { tools: {} },
19
+ instructions
20
+ });
15
21
  server.setRequestHandler("tools/list", () => ({ tools: listTools(tools) }));
16
- server.setRequestHandler("tools/call", async (request, ctx) => {
22
+ server.setRequestHandler("tools/call", async (request, ctx) => guarded(refuse, byName.get(request.params.name), async () => {
17
23
  const meta = ctx.mcpReq._meta;
18
24
  const progressToken = meta?.progressToken;
19
25
  const notify = (params) => {
@@ -27,21 +33,60 @@ function createMcpServer(info, tools) {
27
33
  server.onerror?.(error instanceof Error ? error : new Error(String(error)));
28
34
  });
29
35
  };
30
- const capabilities = ctx.mcpReq.envelope?.["io.modelcontextprotocol/clientCapabilities"] ?? server.getClientCapabilities();
31
- const round = canAsk(capabilities) ? questionRound(ctx.mcpReq.inputResponses, stateOf(ctx.mcpReq.requestState())) : void 0;
36
+ const modern = ctx.mcpReq.envelope?.["io.modelcontextprotocol/clientCapabilities"];
37
+ const capabilities = modern ?? server.getClientCapabilities();
38
+ const { signal } = ctx.mcpReq;
39
+ const way = askWay(modern, capabilities);
40
+ const retry = {
41
+ responses: ctx.mcpReq.inputResponses,
42
+ state: stateOf(ctx.mcpReq.requestState())
43
+ };
44
+ const round = way === "round" ? questionRound(retry, askForm(modern)) : void 0;
32
45
  const context = {
33
- signal: ctx.mcpReq.signal,
46
+ signal,
34
47
  ...mcpHost({
35
48
  request: ctx.http?.req,
36
49
  meta
37
50
  }),
38
- ...progressToken === void 0 ? {} : { progress: progressSteps(notify) }
51
+ ...progressToken === void 0 ? {} : { progress: progressSteps(notify) },
52
+ ...way === "openai" ? { ask: hostAsk(async (question) => await ctx.mcpReq.send(openaiElicitRequest(question), ANY_RESULT, {
53
+ signal,
54
+ timeout: ANSWER_TIMEOUT
55
+ })) } : {}
39
56
  };
40
57
  const { name, arguments: args } = request.params;
41
58
  return await callAsking(info, tools, name, args, context, round);
42
- });
59
+ }));
43
60
  return server;
44
61
  }
62
+ async function guarded(refuse, tool, call) {
63
+ const before = await reasonOf(refuse);
64
+ if (before !== void 0) return errorResult(before);
65
+ const answer = await call();
66
+ const after = await reasonOf(refuse);
67
+ if (after === void 0) return answer;
68
+ return mayHaveRun(tool, answer) ? errorResult(after, DROPPED) : errorResult(after);
69
+ }
70
+ async function reasonOf(refuse) {
71
+ try {
72
+ return await refuse?.();
73
+ } catch (error) {
74
+ return `refuse failed: ${error instanceof Error ? error.message : String(error)}`;
75
+ }
76
+ }
77
+ function mayHaveRun(tool, answer) {
78
+ if (tool === void 0 || "resultType" in answer) return false;
79
+ return !(tool.idempotent ?? tool.effect === "read");
80
+ }
81
+ const ANY_RESULT = { "~standard": {
82
+ version: 1,
83
+ vendor: "@agntn/tools",
84
+ validate: (value) => ({ value })
85
+ } };
86
+ function askWay(modern, capabilities) {
87
+ if (modern === void 0 && fillsOpenaiForms(capabilities)) return "openai";
88
+ return canAsk(capabilities) ? "round" : void 0;
89
+ }
45
90
  function stateOf(state) {
46
91
  return typeof state === "string" ? state : void 0;
47
92
  }
@@ -0,0 +1,14 @@
1
+ import { ToolDefinition } from "./_chunks/index.mjs";
2
+ import { Plugin } from "@opencode/plugin";
3
+ /**
4
+ * Registers every tool on the plugin's context.
5
+ *
6
+ * A tool that isn't a `read` meets OpenCode's permission rules under its own name, like an MCP
7
+ * tool, so `"<name>": "ask"` in `opencode.json` asks every time. An `isError` result throws.
8
+ *
9
+ * @param ctx - The context `setup` gets.
10
+ * @param tools - Tools to register.
11
+ * @returns {Promise<void>} Once OpenCode has the tools.
12
+ * @throws {ToolDefinitionError} When two tools share a name.
13
+ */
14
+ export declare function registerOpencodeTools(ctx: Plugin.Context, tools: readonly ToolDefinition[]): Promise<void>;
@@ -0,0 +1,73 @@
1
+ import { ToolInputError, indexTools, invokeTool, resultText, validateInput, wireSchema } from "./_chunks/src.mjs";
2
+ import { throwWithCauses } from "./_chunks/causes.mjs";
3
+ async function registerOpencodeTools(ctx, tools) {
4
+ indexTools(tools);
5
+ await ctx.tool.transform((editor) => {
6
+ for (const tool of tools) editor.add(opencodeTool(ctx, tool));
7
+ });
8
+ }
9
+ function opencodeTool(ctx, tool) {
10
+ return {
11
+ name: tool.name,
12
+ description: tool.description,
13
+ input: wireSchema(tool),
14
+ async execute(input, context) {
15
+ if (tool.effect !== "read") await approve(ctx, tool, input, context);
16
+ const result = await invokeTool(tool, input, callContext(context)).catch(throwWithCauses);
17
+ if (result.isError) throw new Error(resultText(result));
18
+ return opencodeResult(result);
19
+ }
20
+ };
21
+ }
22
+ async function approve(ctx, tool, input, context) {
23
+ const checked = validateInput(tool, input);
24
+ if (!checked.ok) throw new ToolInputError(checked.lines, checked.issues, tool.name);
25
+ await ctx.permission.assert({
26
+ sessionID: context.sessionID,
27
+ agent: context.agent,
28
+ action: tool.name,
29
+ resources: ["*"],
30
+ save: ["*"],
31
+ metadata: { input: checked.value },
32
+ source: {
33
+ type: "tool",
34
+ messageID: context.messageID,
35
+ id: context.id
36
+ }
37
+ });
38
+ }
39
+ function callContext(context) {
40
+ return {
41
+ signal: context.signal,
42
+ host: context,
43
+ progress(message, amount) {
44
+ context.progress({
45
+ message,
46
+ ...amount
47
+ }).catch(() => void 0);
48
+ }
49
+ };
50
+ }
51
+ function opencodeResult(result) {
52
+ const content = result.content.map(opencodeContent);
53
+ return {
54
+ content: content.length > 0 ? content : "",
55
+ ...metadata(result.details)
56
+ };
57
+ }
58
+ function opencodeContent(block) {
59
+ if (block.type === "text") return {
60
+ type: "text",
61
+ text: block.text
62
+ };
63
+ return {
64
+ type: "file",
65
+ uri: `data:${block.mimeType};base64,${block.data}`,
66
+ mime: block.mimeType
67
+ };
68
+ }
69
+ function metadata(details) {
70
+ if (details === void 0) return {};
71
+ return { metadata: typeof details === "object" && details !== null && !Array.isArray(details) ? details : { details } };
72
+ }
73
+ export { registerOpencodeTools };
package/dist/pi.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Check } from "./_chunks/libs/typebox.mjs";
2
2
  import { ToolDefinitionError, ToolInputError, indexTools, invokeTool, resultText, sanitizeLine, sanitizeText, validateInput } from "./_chunks/src.mjs";
3
3
  import { throwWithCauses } from "./_chunks/causes.mjs";
4
+ import { checkDetails, toolHints } from "./_chunks/outputs.mjs";
4
5
  import { hostContext } from "./_chunks/updates.mjs";
5
6
  const EXPOSURES = [
6
7
  "direct",
@@ -31,17 +32,35 @@ function registerPiTools(pi, tools, options = {}) {
31
32
  ...tool.snippet === void 0 ? {} : { promptSnippet: tool.snippet },
32
33
  ...tool.guidelines === void 0 ? {} : { promptGuidelines: [...tool.guidelines] },
33
34
  parameters: tool.input,
35
+ annotations: toolHints(tool),
36
+ ...tool.output === void 0 ? {} : { outputSchema: tool.output },
34
37
  ...reach(exposures.get(tool.name), options.namespace),
35
38
  async execute(_toolCallId, params, signal, onUpdate, ctx) {
36
39
  if (ask) await approve(tool, ask, params, signal, ctx);
37
40
  const context = hostContext(signal, onUpdate, ctx);
38
- const result = await invokeTool(tool, params, context).catch(throwWithCauses);
41
+ const result = structured(tool, await invokeTool(tool, params, context).catch(throwWithCauses));
39
42
  if (result.isError && failures === "throw") throw new Error(resultText(result));
40
43
  return result;
41
44
  }
42
45
  });
43
46
  }
44
47
  }
48
+ function structured(tool, result) {
49
+ const checked = result.isError === true ? void 0 : checkDetails(tool, result.details);
50
+ if (checked === void 0) return result;
51
+ if (checked.ok) return {
52
+ ...result,
53
+ structuredContent: checked.value
54
+ };
55
+ return {
56
+ content: [{
57
+ type: "text",
58
+ text: checked.lines.map(sanitizeLine).join("\n")
59
+ }],
60
+ details: result.details,
61
+ isError: true
62
+ };
63
+ }
45
64
  function parseJsonText(tool, own) {
46
65
  if (own === void 0) return (args) => repairJsonText(tool, args);
47
66
  return (args) => own(repairJsonText(tool, args));
@@ -0,0 +1,11 @@
1
+ import { McpServerFactory } from "@modelcontextprotocol/server";
2
+ import { ServeStdioOptions, ServeStdioOptions as ServeStdioOptions$1, StdioServerHandle, StdioServerHandle as StdioServerHandle$1 } from "@modelcontextprotocol/server/stdio";
3
+ /**
4
+ * The SDK's `serveStdio`, except a bare notification borrows the last 2026 envelope.
5
+ *
6
+ * @param factory - A fresh server per connection and per discover probe.
7
+ * @param options - The SDK's options; a given `transport` gets wrapped too.
8
+ * @returns {StdioServerHandle} What closes the connection.
9
+ */
10
+ export declare function serveStdio(factory: McpServerFactory, options?: ServeStdioOptions$1): StdioServerHandle$1;
11
+ export type { ServeStdioOptions, StdioServerHandle };
package/dist/stdio.mjs ADDED
@@ -0,0 +1,64 @@
1
+ import { CLIENT_CAPABILITIES_META_KEY, CLIENT_INFO_META_KEY, PROTOCOL_VERSION_META_KEY } from "@modelcontextprotocol/server";
2
+ import { StdioServerTransport, serveStdio as serveStdio$1 } from "@modelcontextprotocol/server/stdio";
3
+ const ENVELOPE = [
4
+ PROTOCOL_VERSION_META_KEY,
5
+ CLIENT_INFO_META_KEY,
6
+ CLIENT_CAPABILITIES_META_KEY
7
+ ];
8
+ function serveStdio(factory, options = {}) {
9
+ const transport = keepEnvelope(options.transport ?? new StdioServerTransport());
10
+ return serveStdio$1(factory, {
11
+ ...options,
12
+ transport
13
+ });
14
+ }
15
+ function keepEnvelope(inner) {
16
+ const envelopes = new Envelopes();
17
+ const outer = {
18
+ start: async () => inner.start(),
19
+ send: async (message, options) => inner.send(message, options),
20
+ close: async () => inner.close(),
21
+ setProtocolVersion: (version) => inner.setProtocolVersion?.(version)
22
+ };
23
+ const relay = (message, extra) => {
24
+ if ("method" in message) {
25
+ const params = envelopes.stamp(message.params, !("id" in message));
26
+ if (params !== void 0) {
27
+ outer.onmessage?.({
28
+ ...message,
29
+ params
30
+ }, extra);
31
+ return;
32
+ }
33
+ }
34
+ outer.onmessage?.(message, extra);
35
+ };
36
+ const fail = (error) => outer.onerror?.(error);
37
+ inner.onmessage = relay;
38
+ inner.onerror = fail;
39
+ inner.onclose = () => outer.onclose?.();
40
+ return outer;
41
+ }
42
+ var Envelopes = class {
43
+ #last;
44
+ stamp(params, notification) {
45
+ const fields = objectOf(params);
46
+ const meta = objectOf(fields._meta);
47
+ if (typeof meta[PROTOCOL_VERSION_META_KEY] === "string") {
48
+ this.#last = Object.fromEntries(ENVELOPE.filter((key) => key in meta).map((key) => [key, meta[key]]));
49
+ return;
50
+ }
51
+ if (!notification || this.#last === void 0) return void 0;
52
+ return {
53
+ ...fields,
54
+ _meta: {
55
+ ...meta,
56
+ ...this.#last
57
+ }
58
+ };
59
+ }
60
+ };
61
+ function objectOf(value) {
62
+ return typeof value === "object" && value !== null ? value : {};
63
+ }
64
+ export { serveStdio };
@@ -1,4 +1,4 @@
1
- import { ToolDefinition } from "./_chunks/index.mjs";
1
+ import { Icon, ToolDefinition } from "./_chunks/index.mjs";
2
2
  import { McpHost } from "./_chunks/mcp-answers.mjs";
3
3
  /** What SDK v1 keeps of the HTTP request. */
4
4
  export interface ToolkitRequestInfo {
@@ -25,16 +25,10 @@ export interface ToolkitExtra {
25
25
  readonly message: string;
26
26
  };
27
27
  }) => Promise<void>;
28
- /** Both schemas are `never`, so SDK v1's method fits whatever Zod and schema types it carries. */
29
- readonly sendRequest?: (request: {
30
- readonly method: "elicitation/create";
31
- readonly params: {
32
- readonly mode: "form";
33
- readonly message: string;
34
- readonly requestedSchema: never;
35
- };
36
- }, resultSchema: never, options?: {
28
+ /** All `never`: SDK v1 has never heard of ChatGPT's method. */
29
+ readonly sendRequest?: (request: never, resultSchema: never, options?: {
37
30
  readonly signal?: AbortSignal;
31
+ readonly timeout?: number;
38
32
  }) => Promise<unknown>;
39
33
  }
40
34
  /** The toolkit's `useMcpElicitation`, or anything that knows if the client fills forms. */
@@ -45,6 +39,11 @@ export type ToolkitElicitation = () => {
45
39
  export interface ToolkitOptions {
46
40
  /** Pass `useMcpElicitation` to give `execute` an `ask`. It runs in every handler. */
47
41
  readonly elicitation?: ToolkitElicitation;
42
+ /**
43
+ * The client capabilities, so ChatGPT gets its own method.
44
+ * Pass `() => useMcpServer().server.server.getClientCapabilities()`.
45
+ */
46
+ readonly capabilities?: () => unknown;
48
47
  }
49
48
  /** What a handler answers. The toolkit runs SDK v1, so these types never name the v2 package. */
50
49
  export interface ToolkitResult {
@@ -90,4 +89,28 @@ export interface ToolkitTool {
90
89
  export declare function toToolkitTools(info: {
91
90
  readonly name: string;
92
91
  }, tools: readonly ToolDefinition[], options?: ToolkitOptions): ToolkitTool[];
92
+ /** The server as the card shows it. An `McpServerInfo` fits, and so does a bare `{ name }`. */
93
+ export interface ToolkitServerInfo {
94
+ readonly name: string;
95
+ readonly version?: string;
96
+ readonly title?: string;
97
+ readonly description?: string;
98
+ readonly icons?: readonly Icon[];
99
+ readonly websiteUrl?: string;
100
+ /** Stays off the card: `initialize` sends it beside `serverInfo`, never inside. */
101
+ readonly instructions?: string;
102
+ }
103
+ /** The card nuxt-agent-discovery serves at `/.well-known/mcp/server-card.json`, filled in place. */
104
+ export interface ToolkitServerCard {
105
+ [key: string]: unknown;
106
+ }
107
+ /**
108
+ * Hook for `agent-discovery:mcp-server-card`: our `serverInfo`, then our tools after the rest.
109
+ *
110
+ * @param info - Server info, given as to `defineMcpHandler`.
111
+ * @param tools - Tools the `/mcp` route serves.
112
+ * @returns {(event: unknown, card: ToolkitServerCard) => void} The hook, which ignores the event.
113
+ * @throws {ToolDefinitionError} When two tools share a name.
114
+ */
115
+ export declare function serverCardHook(info: ToolkitServerInfo, tools: readonly ToolDefinition[]): (event: unknown, card: ToolkitServerCard) => void;
93
116
  export type { McpHost };
package/dist/toolkit.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./_chunks/src.mjs";
2
2
  import { hostAsk } from "./_chunks/questions.mjs";
3
- import { callTool, listTools, mcpHost, progressSteps } from "./_chunks/mcp-answers.mjs";
3
+ import { ANSWER_TIMEOUT, OPENAI_ELICIT, callTool, copyIcons, fillsOpenaiForms, listTools, mcpHost, progressSteps } from "./_chunks/mcp-answers.mjs";
4
4
  import { z } from "zod";
5
5
  function toToolkitTools(info, tools, options = {}) {
6
6
  return listTools(tools).map((entry) => ({
@@ -13,10 +13,36 @@ function toToolkitTools(info, tools, options = {}) {
13
13
  ...entry._meta === void 0 ? {} : { _meta: entry._meta },
14
14
  handler: async (args, extra) => callTool(info, tools, entry.name, args, {
15
15
  ...callContext(extra),
16
- ...formAsk(extra, options.elicitation)
16
+ ...formAsk(extra, options)
17
17
  })
18
18
  }));
19
19
  }
20
+ function serverCardHook(info, tools) {
21
+ const listed = listTools(tools).map(({ name, description = "" }) => ({
22
+ name,
23
+ description
24
+ }));
25
+ const ours = new Set(listed.map(({ name }) => name));
26
+ const { instructions: _instructions, ...shown } = info;
27
+ const serverInfo = {
28
+ ...shown,
29
+ ...info.icons === void 0 ? {} : { icons: copyIcons(info.icons) }
30
+ };
31
+ const theirs = (entry) => {
32
+ const { name } = plainObject(entry);
33
+ return typeof name !== "string" || !ours.has(name);
34
+ };
35
+ return (_event, card) => {
36
+ card.serverInfo = {
37
+ ...plainObject(card.serverInfo),
38
+ ...serverInfo
39
+ };
40
+ card.tools = [...(Array.isArray(card.tools) ? card.tools : []).filter(theirs), ...listed.map((tool) => ({ ...tool }))];
41
+ };
42
+ }
43
+ function plainObject(value) {
44
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
45
+ }
20
46
  function wireObject(schema, input) {
21
47
  const object = z.looseObject({});
22
48
  object._zod.toJSONSchema = () => ({ ...schema });
@@ -67,17 +93,23 @@ function isHeader(name, value) {
67
93
  return false;
68
94
  }
69
95
  }
70
- function formAsk(extra, elicitation) {
96
+ function formAsk(extra, options) {
71
97
  const send = extra?.sendRequest;
72
- if (send === void 0 || elicitation?.().supports("form") !== true) return {};
98
+ if (send === void 0) return {};
99
+ const openai = fillsOpenaiForms(options.capabilities?.());
100
+ if (!openai && options.elicitation?.().supports("form") !== true) return {};
101
+ const method = openai ? OPENAI_ELICIT : "elicitation/create";
73
102
  const reply = z.looseObject({});
74
- return { ask: hostAsk(async ({ message, requested }) => await send({
75
- method: "elicitation/create",
103
+ return { ask: hostAsk(async ({ message, ...forms }) => await send({
104
+ method,
76
105
  params: {
77
106
  mode: "form",
78
107
  message,
79
- requestedSchema: requested
108
+ requestedSchema: openai ? forms.openai : forms.requested()
80
109
  }
81
- }, reply, { signal: extra?.signal })) };
110
+ }, reply, {
111
+ signal: extra?.signal,
112
+ timeout: ANSWER_TIMEOUT
113
+ })) };
82
114
  }
83
- export { toToolkitTools };
115
+ export { serverCardHook, toToolkitTools };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agntn/tools",
3
- "version": "0.3.3",
4
- "description": "One tool definition for MCP, Pi, OMP and the AI SDK",
3
+ "version": "0.4.1",
4
+ "description": "One tool definition for MCP, Pi, OMP, OpenCode and the AI SDK",
5
5
  "homepage": "https://github.com/agntn/tools#readme",
6
6
  "bugs": "https://github.com/agntn/tools/issues",
7
7
  "license": "MIT",
@@ -28,6 +28,14 @@
28
28
  "types": "./dist/h3.d.mts",
29
29
  "import": "./dist/h3.mjs"
30
30
  },
31
+ "./stdio": {
32
+ "types": "./dist/stdio.d.mts",
33
+ "import": "./dist/stdio.mjs"
34
+ },
35
+ "./http": {
36
+ "types": "./dist/http.d.mts",
37
+ "import": "./dist/http.mjs"
38
+ },
31
39
  "./toolkit": {
32
40
  "types": "./dist/toolkit.d.mts",
33
41
  "import": "./dist/toolkit.mjs"
@@ -40,6 +48,10 @@
40
48
  "types": "./dist/omp.d.mts",
41
49
  "import": "./dist/omp.mjs"
42
50
  },
51
+ "./opencode": {
52
+ "types": "./dist/opencode.d.mts",
53
+ "import": "./dist/opencode.mjs"
54
+ },
43
55
  "./ai": {
44
56
  "types": "./dist/ai.d.mts",
45
57
  "import": "./dist/ai.mjs"
@@ -58,7 +70,8 @@
58
70
  "@modelcontextprotocol/client": "2.4.0",
59
71
  "@modelcontextprotocol/sdk": "1.32.1",
60
72
  "@modelcontextprotocol/server": "2.4.0",
61
- "@oh-my-pi/pi-coding-agent": "18.0.11",
73
+ "@oh-my-pi/pi-coding-agent": "19.1.1",
74
+ "@opencode/plugin": "2.3.2",
62
75
  "@types/node": "26.6.6",
63
76
  "ai": "7.0.127",
64
77
  "h3": "2.0.1",
@@ -73,7 +86,8 @@
73
86
  "peerDependencies": {
74
87
  "@earendil-works/pi-coding-agent": ">=0.84.2 <2",
75
88
  "@modelcontextprotocol/server": ">=2.2.0 <3",
76
- "@oh-my-pi/pi-coding-agent": ">=18.0.0 <19",
89
+ "@oh-my-pi/pi-coding-agent": ">=18.0.0 <20",
90
+ "@opencode/plugin": ">=2.3.0 <3",
77
91
  "ai": ">=7.0.0 <8",
78
92
  "h3-mcp": ">=0.2.0 <0.3",
79
93
  "zod": ">=4.1.13 <5"
@@ -88,6 +102,9 @@
88
102
  "@oh-my-pi/pi-coding-agent": {
89
103
  "optional": true
90
104
  },
105
+ "@opencode/plugin": {
106
+ "optional": true
107
+ },
91
108
  "ai": {
92
109
  "optional": true
93
110
  },