このリファレンスでは、TypeSpec for Microsoft 365 Copilotで使用できる組み込みのデコレーターについて、主なユース ケース別に整理されています。
注:
このデコレーターリファレンスは、特に @microsoft/typespec-m365-copilot デコレーターに焦点を当てていますが、 組み込みのデコレーター や OpenAPI デコレーターなど、TypeSpec で定義されているすべてのデコレーターを使用できます。
| デコレータ | Target | 説明 |
|---|---|---|
| @agent | エージェント | 名前、説明、および省略可能な ID を持つエージェントを定義します。 |
| @behaviorOverrides | エージェント | エージェント オーケストレーションの動作設定を変更します。 |
| @conversationStarter | エージェント | ユーザーの会話スターター プロンプトを定義します。 |
| @customExtension | エージェント | 拡張のためにカスタム キーと値のペアを追加します。 |
| @disclaimer | エージェント | ユーザーに法的またはコンプライアンスに関する免責事項を表示します。 |
| @instructions | エージェント | エージェントの動作指示とガイドラインを定義します。 |
| @actions | プラグイン | 名前、説明、URL を含むアクション メタデータを定義します。 |
| @authReferenceId | プラグイン | API アクセスの認証参照 ID を指定します。 |
| @capabilities | プラグイン | 確認や応答の書式設定などの関数機能を構成します。 |
| @カード | プラグイン | 関数応答のアダプティブ カード テンプレートを定義します。 |
| @reasoning | プラグイン | 関数呼び出しの推論手順を指定します。 |
| @responding | プラグイン | 関数の応答書式指定命令を定義します。 |
宣言型エージェント デコレーター
これらのデコレーターは、エージェントの動作、会話フロー、およびユーザー エクスペリエンスを定義するために宣言型エージェントを構築するときに使用されます。
@agent
名前空間がエージェントを表していることを示します。
@agent(name: valueof string, description: valueof string, id?: valueof string)
Target
Namespace
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
description |
valueof string |
ローカライズ。 宣言型エージェントの説明。 空白以外の文字が少なくとも 1 つ含まれており、1,000 文字以下である必要があります。 |
id |
valueof string |
省略可能。 エージェントの一意識別子。 |
name |
valueof string |
ローカライズ。 宣言型エージェントの名前。 空白以外の文字が少なくとも 1 つ含まれており、100 文字以下である必要があります。 |
例
// Basic agent definition with simple name and description
@agent("IT Support Assistant", "An AI agent that helps with technical support and troubleshooting")
// Project management agent with more detailed description
@agent("Project Manager", "A helpful assistant for project management tasks and coordination")
// Agent with explicit ID for tracking and versioning
@agent("Data Analytics Helper", "An agent specialized in data analysis and reporting tasks", "data-analytics-v1")
@behaviorOverrides
エージェント オーケストレーションの動作を変更する設定を定義します。
@behaviorOverrides(behaviorOverrides: valueof BehaviorOverrides)
Target
Namespace
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
behaviorOverrides |
valueof BehaviorOverrides | エージェント オーケストレーションの動作を変更する設定を定義します。 |
モデル
BehaviorOverrides
エージェント オーケストレーションの動作を変更する設定を定義する
| 名前 | 型 | 説明 |
|---|---|---|
discourageModelKnowledge |
boolean |
応答の生成時に宣言型エージェントがモデルナレッジを使用しないようにするかどうかを示すブール値。 |
disableSuggestions |
boolean |
提案機能が無効かどうかを示すブール値。 |
例
// Conservative settings: discourage model knowledge but allow suggestions
@behaviorOverrides(#{
discourageModelKnowledge: true,
disableSuggestions: false
})
// Minimal interaction: disable suggestions to reduce prompting
@behaviorOverrides(#{
disableSuggestions: true
})
// Default behavior: allow both model knowledge and suggestions
@behaviorOverrides(#{
discourageModelKnowledge: false,
disableSuggestions: false
})
@conversationStarter
名前空間に会話スターターが含まれていることを示します。
@conversationStarter(conversationStarter: valueof ConversationStarter)
Target
Namespace
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
conversationStarter |
valueof ConversationStarter | 会話スターター情報。 |
モデル
ConversationStarter
ユーザーの会話スターターを定義する構成オブジェクト。
| 名前 | 型 | 説明 |
|---|---|---|
text |
string |
ローカライズ。 ユーザーが DC から目的の結果を取得するために使用できる提案。 空白以外の文字が少なくとも 1 つ含まれている必要があります。 |
title |
string |
ローカライズ。 会話スターターの一意のタイトル。 空白以外の文字が少なくとも 1 つ含まれている必要があります。 |
例
// Generic welcome prompt for new users
@conversationStarter(#{
title: "Get Started",
text: "How can I help you today?"
})
// Status check prompt for tracking ongoing work
@conversationStarter(#{
title: "Check Status",
text: "What's the status of my recent requests?"
})
// Issue reporting prompt for technical support scenarios
@conversationStarter(#{
text: "I need to report a technical problem"
})
@customExtension
拡張のキーと値のペアを持つカスタム拡張機能が名前空間に含まれていることを示します。
@customExtension(key: valueof string, value: valueof unknown)
Target
Namespace
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
key |
valueof string |
カスタム拡張機能のキー。 |
value |
valueof unknown |
カスタム拡張機能の値。 任意の有効な TypeSpec 値を指定できます。 |
例
// Adding a custom feature flag to an agent
@customExtension("featureFlag", "experimentalMode")
// Adding custom metadata with a structured value
@customExtension("metadata", #{
version: "1.0",
environment: "production"
})
// Adding a custom configuration setting
@customExtension("customConfig", #{
maxRetries: 3,
timeout: 30000
})
@disclaimer
指定された場合は、法的またはコンプライアンスの要件を満たすために、会話の開始時にユーザーに表示される免責事項メッセージを含む省略可能なオブジェクト。
@disclaimer(disclaimer: valueof Disclaimer)
Target
Namespace
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
disclaimer |
valueof 免責事項 | ユーザーに表示される免責事項情報。 |
モデル
免責事項
ユーザーに表示される免責事項情報。
| 名前 | 型 | 説明 |
|---|---|---|
text |
string |
免責事項メッセージを含む文字列。 空白以外の文字が少なくとも 1 つ含まれている必要があります。 500 文字を超える文字は無視できます。 |
例
// General disclaimer for informational agents
@disclaimer(#{
text: "This agent provides general information only and should not be considered professional advice."
})
// Financial advice disclaimer with professional consultation reminder
@disclaimer(#{
text: "All financial information provided is for educational purposes. Please consult with a qualified financial advisor before making investment decisions."
})
// Technical support disclaimer for critical systems
@disclaimer(#{
text: "This technical support agent provides general guidance. For critical systems, please contact your IT department directly."
})
@instructions
エージェントの動作を定義する命令を定義します。
@instructions(instructions: valueof string)
Target
Namespace
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
instructions |
valueof string |
ローカライズできません。 宣言型エージェントの動作方法、その関数、および回避する動作に関する詳細な手順またはガイドライン。 空白以外の文字が少なくとも 1 つ含まれており、8,000 文字以下である必要があります。 |
例
// Simple, concise instructions for positive interaction
@instructions("Always respond with a positive energy.")
// Detailed instructions for technical support with specific behaviors
@instructions("""
You are a customer support agent specializing in technical troubleshooting.
Always provide step-by-step solutions and ask clarifying questions when needed.
""")
// Comprehensive instructions with disclaimers and behavioral constraints
@instructions("""
You are a financial advisor assistant. Provide general financial information
but always remind users to consult with qualified professionals for specific advice.
Never provide specific investment recommendations.
""")
API プラグイン デコレーター
これらのデコレーターは、API プラグインをビルドして API 操作、認証、応答処理を定義するときに使用されます。
@actions
OpenAPI 仕様の info オブジェクトに対して定義できるアクションを定義します。
@actions(data: valueof ActionMetadata)
Target
Namespace
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
data |
valueof ActionMetadata | 人間が読み取り可能な名前、説明、URL を含むアクション メタデータ。 |
モデル
ActionMetadata
人間が読み取り可能な名前、説明、URL を含むアクション メタデータ。
| 名前 | 型 | 説明 |
|---|---|---|
descriptionForHuman |
string |
必須です。 プラグインの人間が判読できる説明。 100 文字を超える文字は無視できます。 このプロパティはローカライズ可能です。 |
nameForHuman |
string |
必須です。 プラグインの人間が判読できる短い名前。 空白以外の文字が少なくとも 1 つ含まれている必要があります。 20 文字を超える文字は無視できます。 このプロパティはローカライズ可能です。 |
contactEmail |
string |
省略可能。 安全性/モデレーション、サポート、非アクティブ化のための連絡先の電子メール アドレス。 |
descriptionForModel |
string |
省略可能。 モデルに提供されるプラグインの説明。 この説明では、プラグインの目的と、その機能が関連する状況について説明する必要があります。 2048 を超える文字は無視できます。 このプロパティはローカライズ可能です。 |
legalInfoUrl |
string |
省略可能。 プラグインのサービス条件を含むドキュメントを検索する絶対 URL。 このプロパティはローカライズ可能です。 |
logoUrl |
string |
省略可能。 オーケストレーターによって使用される可能性があるロゴをフェッチするために使用される URL。 実装では、視覚的な要件を満たすロゴを提供する別の方法が提供される場合があります。 このプロパティはローカライズ可能です。 |
privacyPolicyUrl |
string |
省略可能。 プラグインのプライバシー ポリシーを含むドキュメントを検索する絶対 URL。 このプロパティはローカライズ可能です。 |
例
// Complete action metadata with all contact and legal information
@actions(#{
nameForHuman: "Customer Support API",
descriptionForModel: "Provides customer support ticket management",
descriptionForHuman: "Manage and track customer support requests",
privacyPolicyUrl: "https://company.com/privacy",
legalInfoUrl: "https://company.com/legal",
contactEmail: "support@company.com"
})
// Enhanced action metadata with branding and comprehensive descriptions
@actions(#{
nameForHuman: "Project Management Suite",
descriptionForModel: "Comprehensive project management tools",
privacyPolicyUrl: "https://company.com/privacy",
legalInfoUrl: "https://company.com/terms",
contactEmail: "pm-support@company.com",
logoUrl: "https://company.com/logo.png",
descriptionForHuman: "A complete project management solution for teams"
})
// Minimal action metadata focusing on analytics functionality
@actions(#{
nameForHuman: "Analytics Dashboard",
descriptionForHuman: "Real-time analytics and reporting platform",
descriptionForModel: "Generate reports and analyze business data"
})
@authReferenceId
認証の種類の認証参照 ID を定義します。
@authReferenceId(value: valueof string)
Target
Model
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
value |
valueof string |
認証の種類のコンテナー参照 ID。 |
例
// Reference to the Developer Portal OAuth client registration ID (https://dev.teams.cloud.microsoft/oauth-configuration)
@authReferenceId("NzFmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3IyM5NzQ5Njc3Yi04NDk2LTRlODYtOTdmZS1kNDUzODllZjUxYjM=")
// Reference to the Developer Portal API key registration ID (https://dev.teams.cloud.microsoft/api-key-registration)
@authReferenceId("5f701b3e-bf18-40fb-badd-9ad0b60b31c0")
@capabilities
API プラグイン マニフェスト オブジェクトで定義されているアクション関数の capabilities オブジェクトをサポートします。 このデコレーターを使用すると、 confirmationのような小さな定義を持つ単純なアダプティブ カードを定義できます。 より複雑なアダプティブ カードの場合は、 @card デコレーターを使用できます。
@capabilities(capabilities: valueof FunctionCapabilitiesMetadata)
Target
Operation
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
capabilities |
valueof FunctionCapabilitiesMetadata | 関数の呼び出し中にオーケストレーターのオプション機能を構成するために使用されるデータのコレクションが含まれます。 |
モデル
FunctionCapabilitiesMetadata
関数の呼び出し中にオーケストレーターのオプション機能を構成するために使用されるデータのコレクションが含まれます。
| 名前 | 型 | 説明 |
|---|---|---|
confirmation |
確認 | 省略可能。 関数を呼び出す前にユーザーに表示する必要がある確認ダイアログについて説明します。 |
responseSemantics |
ResponseSemantics | 省略可能。 オーケストレーターが応答ペイロードを解釈し、視覚的なレンダリングを提供する方法について説明します。 |
securityInfo |
SecurityInfo | 省略可能。 関数を呼び出すリスクを評価するために、プラグインの動作に関する構成証明が含まれています。 このプロパティを省略した場合、関数は、含まれているエージェントの他のプラグインや機能と対話できません。 |
確認
オーケストレーターが、関数を呼び出す前にユーザーに確認を求める方法について説明します。
| 名前 | 型 | 説明 |
|---|---|---|
body |
string |
省略可能。 確認ダイアログのテキスト。 このプロパティはローカライズ可能です。 |
title |
string |
省略可能。 確認ダイアログのタイトル。 このプロパティはローカライズ可能です。 |
type |
string |
省略可能。 確認の種類を指定します。 使用可能な値は、なし、AdaptiveCard です。 |
ResponseSemantics
応答ペイロードのセマンティクスを識別し、アダプティブ カードを使用したリッチ ビジュアル エクスペリエンスでその情報のレンダリングを可能にする情報が含まれています。
| 名前 | 型 | 説明 |
|---|---|---|
dataPath |
string |
必須です。 JSONPath RFC9535クエリで、各項目で指定されたテンプレートを使用してレンダリングされる関数応答から要素のセットを識別します。 |
oauthCardPath |
string |
省略可能。 |
properties |
ResponseSemanticsProperties | 省略可能。 既知のデータ要素への JSONPath クエリのマッピングを許可します。 各 JSONPath クエリは、結果の値に対して相対的です。 |
staticTemplate |
Record<unknown> |
省略可能。 アダプティブ カード スキーマとテンプレート言語に準拠する JSON オブジェクト。 このアダプティブ カード インスタンスは、プラグイン応答の結果をレンダリングするために使用されます。 この値は、templateSelector が存在しないか、アダプティブ カードへの解決に失敗した場合に使用されます。 |
ResponseSemanticsProperties
既知のデータ要素への JSONPath クエリのマッピングを許可します。 各 JSONPath クエリは、結果の値に対して相対的です。
| 名前 | 型 | 説明 |
|---|---|---|
informationProtectionLabel |
string |
省略可能。 結果の内容のデータ秘密度インジケーター。 |
subTitle |
string |
省略可能。 結果の引用文献の字幕。 |
templateSelector |
string |
省略可能。 結果のレンダリングに使用するアダプティブ カード インスタンスへの JSONPath 式。 |
title |
string |
省略可能。 結果の引用文献のタイトル。 |
thumbnailUrl |
string |
省略可能。 結果のサムネイル画像の URL。 |
url |
string |
省略可能。 結果の引用文献の URL。 |
SecurityInfo
関数を呼び出す相対的なリスクを判断するために使用する情報が含まれています。
| 名前 | 型 | 説明 |
|---|---|---|
dataHandling |
string[] |
必須です。 関数のデータ処理動作を記述する文字列の配列。 有効な値は、 GetPublicData、 GetPrivateData、 DataTransform、 DataExport、および ResourceStateUpdateです。 |
例
// Simple confirmation dialog for destructive operations
@capabilities(#{
confirmation: #{
type: "AdaptiveCard",
title: "Delete Ticket",
body: "Are you sure you want to delete this support ticket? This action cannot be undone."
}
})
// Comprehensive capabilities with confirmation and response formatting
@capabilities(#{
confirmation: #{
type: "modal",
title: "Create Project",
body: """
Creating a new project with the following details:
* **Title**: {{ function.parameters.name }}
* **Description**: {{ function.parameters.description }}
* **Team Lead**: {{ function.parameters.teamLead }}
"""
},
responseSemantics: #{
dataPath: "$.projects",
properties: #{
title: "$.name",
subTitle: "$.description",
url: "$.projectUrl",
thumbnailUrl: "$.teamLogo"
},
staticTemplate: #{file: "adaptiveCards/dish.json"}
}
})
@card
関数のアダプティブ カード参照を定義します。
@card(cardPath: valueof CardMetadata)
Target
Operation
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
cardPath |
valueof CardMetadata | 関数のアダプティブ カード参照を定義します。
responseSemanticsの簡略化されたバージョン。 |
モデル
CardMetadata
アダプティブ カードに焦点を当てた簡略化された応答Semantics。
| 名前 | 型 | 説明 |
|---|---|---|
dataPath |
string |
必須です。 JSONPath RFC9535クエリで、各項目で指定されたテンプレートを使用してレンダリングされる関数応答から要素のセットを識別します。 |
file |
string |
必須です。 アダプティブ カード テンプレートへのパス。 appPackage ディレクトリを基準とする。 |
properties |
CardResponseSemanticProperties | 省略可能。 既知のデータ要素への JSONPath クエリのマッピングを許可します。 各 JSONPath クエリは、結果の値に対して相対的です。 |
CardResponseSemanticProperties
カードレンダリングのために、JSONPath クエリを既知のデータ要素にマッピングできます。 各 JSONPath クエリは、結果の値に対して相対的です。
| 名前 | 型 | 説明 |
|---|---|---|
informationProtectionLabel |
string |
省略可能。 結果の内容のデータ秘密度インジケーター。 |
subTitle |
string |
省略可能。 結果の引用文献の字幕。 |
thumbnailUrl |
string |
省略可能。 結果のサムネイル画像の URL。 |
title |
string |
省略可能。 結果の引用文献のタイトル。 |
url |
string |
省略可能。 結果の引用文献の URL。 |
例
// Basic card configuration with data binding
@card(#{
dataPath: "$.tickets",
file: "cards/ticketCard.json"
})
// Card with property mappings for citations and metadata
@card(#{
dataPath: "$.projects",
file: "cards/project.json",
properties: #{
title: "$.name",
url: "$.projectUrl",
subTitle: "$.description",
thumbnailUrl: "$.teamLogo"
}
})
@reasoning
アクション内の関数の推論命令を定義します。
@reasoning(value: valueof string)
Target
Operation
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
value |
valueof string |
操作の推論手順。 |
例
// Prioritization logic for ticket search operations
@reasoning("""
When searching for tickets, prioritize by severity level and creation date.
Always include ticket ID and status in the response.
""")
// Role-based access control reasoning for project operations
@reasoning("""
For project queries, consider the user's role and project permissions.
Filter results based on team membership and access levels.
""")
// Data validation reasoning for analytics requests
@reasoning("""
When processing analytics requests, validate date ranges and ensure
the requested metrics are available for the specified time period.
""")
@responding
アクション内の関数の応答命令を定義します。
@responding(value: valueof string)
Target
Operation
パラメーター
| 名前 | 型 | 説明 |
|---|---|---|
value |
valueof string |
操作の応答命令。 |
例
// Structured table format for support ticket responses
@responding("""
Present support tickets in a clear table format with columns: ID, Title, Priority, Status, Created Date.
Include summary statistics at the end showing total tickets by status.
""")
// Bullet point format for project information display
@responding("""
Display project information using bullet points for easy reading.
Always include project timeline and current phase information.
""")