Skip to content

Commit 2760899

Browse files
authored
fix: support DA local env and shared scope (#14638)
* fix: support da local env and shared scope * fix: yml file detection * fix: build error
1 parent 26642d1 commit 2760899

File tree

16 files changed

+241
-14
lines changed

16 files changed

+241
-14
lines changed

packages/vscode-extension/src/utils/autoOpenHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export async function showLocalDebugMessage() {
5151

5252
const hasLocalEnv =
5353
(await fs.pathExists(path.join(workspaceUri!.fsPath, "teamsapp.local.yml"))) ||
54-
(await fs.pathExists(path.join(workspaceUri!.fsPath, "m365agents.local.json")));
54+
(await fs.pathExists(path.join(workspaceUri!.fsPath, "m365agents.local.yml")));
5555
const hasKeyGenJsFile = await fs.pathExists(path.join(workspaceUri!.fsPath, "/src/keyGen.js"));
5656
const hasKeyGenTsFile = await fs.pathExists(path.join(workspaceUri!.fsPath, "/src/keyGen.ts"));
5757

@@ -102,7 +102,7 @@ export async function showLocalDebugMessage() {
102102
};
103103
ExtTelemetry.sendTelemetryEvent(TelemetryEvent.ShowLocalDebugNotification);
104104

105-
const messageTemplate = await getLocalDebugMessageTemplate(isWindows);
105+
const messageTemplate = getLocalDebugMessageTemplate(isWindows);
106106

107107
let message = util.format(messageTemplate, appName, workspaceUri?.fsPath);
108108
if (isWindows) {

templates/vsc/common/declarative-agent-basic/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ With the declarative agent, you can build a custom version of Copilot that can b
1717

1818
1. First, select the Microsoft 365 Agents Toolkit icon on the left in the VS Code toolbar.
1919
2. In the Account section, sign in with your [Microsoft 365 account](https://docs.microsoft.com/microsoftteams/platform/toolkit/accounts) if you haven't already.
20-
3. Create app by clicking `Provision` in "Lifecycle" section.
21-
4. Select `Preview in Copilot (Edge)` or `Preview in Copilot (Chrome)` from the launch configuration dropdown.
22-
5. Once the Copilot agent is loaded in the browser, click on the "…" menu and select "Copilot chats". You will see your declarative agent on the right rail. Clicking on it will change the experience to showcase the logo and name of your declarative agent.
23-
6. Ask a question to your declarative agent and it should respond based on the instructions provided.
20+
3. Select `Preview Local in Copilot (Edge)` or `Preview Local in Copilot (Chrome)` from the launch configuration dropdown.
21+
4. Select your declarative agent from the `Copilot` app.
22+
5. Ask a question to your declarative agent and it should respond based on the instructions provided.
2423

2524
## What's included in the template
2625

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file includes environment variables that will be committed to git by default.
2+
3+
# Built-in environment variables
4+
TEAMSFX_ENV=local
5+
APP_NAME_SUFFIX=local
6+
7+
# Generated during provision, you can also add your own variables.
8+
TEAMS_APP_ID=
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.10/yaml.schema.json
2+
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
3+
# Visit https://aka.ms/teamsfx-actions for details on actions
4+
version: v1.10
5+
6+
provision:
7+
# Creates an app
8+
- uses: teamsApp/create
9+
with:
10+
# app name
11+
name: {{appName}}${{APP_NAME_SUFFIX}}
12+
# Write the information of created resources into environment file for
13+
# the specified environment variable(s).
14+
writeToEnvironmentFile:
15+
teamsAppId: TEAMS_APP_ID
16+
17+
# Build app package with latest env value
18+
- uses: teamsApp/zipAppPackage
19+
with:
20+
# Path to manifest template
21+
manifestPath: ./appPackage/manifest.json
22+
outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
23+
outputFolder: ./appPackage/build
24+
25+
{{^EmbeddedKnowledgeEnabled}}
26+
# Validate app package using validation rules
27+
- uses: teamsApp/validateAppPackage
28+
with:
29+
# Relative path to this file. This is the path for built zip file.
30+
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
31+
{{/EmbeddedKnowledgeEnabled}}
32+
33+
# Apply the app manifest to an existing app in
34+
# Developer Portal.
35+
# Will use the app id in manifest file to determine which app to update.
36+
- uses: teamsApp/update
37+
with:
38+
# Relative path to this file. This is the path for built zip file.
39+
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
40+
41+
# Extend your app to Outlook and the Microsoft 365 app
42+
- uses: teamsApp/extendToM365
43+
with:
44+
# Relative path to the build app package.
45+
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
46+
# Write the information of created resources into environment file for
47+
# the specified environment variable(s).
48+
writeToEnvironmentFile:
49+
titleId: M365_TITLE_ID
50+
appId: M365_APP_ID

templates/vsc/common/declarative-agent-typespec/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ With the declarative agent, you can build a custom version of Copilot that can b
1919
2. In the Account section, sign in with your [Microsoft 365 account](https://docs.microsoft.com/microsoftteams/platform/toolkit/accounts) if you haven't already.
2020
3. Run `npm install` to install dependencies before working with TypeSpec files.
2121
4. Update the [`main.tsp`](./main.tsp) to configure your agent and its plugins. This is the default entry point for TypeSpec files.
22-
5. Create app by clicking `Provision` in "Lifecycle" section.
23-
6. Select `Preview in Copilot (Edge)` or `Preview in Copilot (Chrome)` from the launch configuration dropdown.
24-
7. Once the Copilot agent is loaded in the browser, click on the "…" menu and select "Copilot chats". You will see your declarative agent on the right rail. Clicking on it will change the experience to showcase the logo and name of your declarative agent.
25-
8. Ask a question to your declarative agent and it should respond based on the instructions provided.
22+
5. Select `Preview Local in Copilot (Edge)` or `Preview Local in Copilot (Chrome)` from the launch configuration dropdown.
23+
6. Select your declarative agent from the `Copilot` app.
24+
7. Ask a question to your declarative agent and it should respond based on the instructions provided.
2625

2726
## What's included in the template
2827

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file includes environment variables that will be committed to git by default.
2+
3+
# Built-in environment variables
4+
TEAMSFX_ENV=local
5+
APP_NAME_SUFFIX=local
6+
7+
# Generated during provision, you can also add your own variables.
8+
TEAMS_APP_ID=
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.10/yaml.schema.json
2+
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
3+
# Visit https://aka.ms/teamsfx-actions for details on actions
4+
version: v1.10
5+
6+
provision:
7+
# Creates an app
8+
- uses: teamsApp/create
9+
with:
10+
# app name
11+
name: {{appName}}${{APP_NAME_SUFFIX}}
12+
# Write the information of created resources into environment file for
13+
# the specified environment variable(s).
14+
writeToEnvironmentFile:
15+
teamsAppId: TEAMS_APP_ID
16+
17+
- uses: cli/runNpmCommand
18+
name: install dependencies
19+
with:
20+
args: install --no-audit --progress=false
21+
22+
# Compile typespec files and generate necessary files for agent.
23+
# If you want to update the outputDir, please make sure the following paths are also updated.
24+
# 1. File paths in tspconfig.yaml.
25+
# 2. manifestPath in this action. Please make sure there is manifest.json under root folder of your outputDir and set the value to the path of this manifest.json.
26+
# 3. manifestPath in teamsApp/zipAppPackage action. Please set the value to the same as manifestPath in this action.
27+
- uses: typeSpec/compile
28+
with:
29+
path: ./main.tsp
30+
manifestPath: ./appPackage/manifest.json
31+
outputDir: ./appPackage/.generated
32+
typeSpecConfigPath: ./tspconfig.yaml
33+
34+
# Build app package with latest env value
35+
- uses: teamsApp/zipAppPackage
36+
with:
37+
# Path to manifest template
38+
manifestPath: ./appPackage/manifest.json
39+
outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
40+
outputFolder: ./appPackage/build
41+
42+
{{^EmbeddedKnowledgeEnabled}}
43+
# Validate app package using validation rules
44+
- uses: teamsApp/validateAppPackage
45+
with:
46+
# Relative path to this file. This is the path for built zip file.
47+
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
48+
{{/EmbeddedKnowledgeEnabled}}
49+
50+
# Apply the app manifest to an existing app in
51+
# Developer Portal.
52+
# Will use the app id in manifest file to determine which app to update.
53+
- uses: teamsApp/update
54+
with:
55+
# Relative path to this file. This is the path for built zip file.
56+
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
57+
58+
# Extend your app to Outlook and the Microsoft 365 app
59+
- uses: teamsApp/extendToM365
60+
with:
61+
# Relative path to the build app package.
62+
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
63+
# Write the information of created resources into environment file for
64+
# the specified environment variable(s).
65+
writeToEnvironmentFile:
66+
titleId: M365_TITLE_ID
67+
appId: M365_APP_ID

templates/vsc/common/declarative-agent-with-action-from-existing-api/README.md.tpl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ You can extend declarative agents using plugins to retrieve data and execute tas
2222

2323
1. First, select the Microsoft 365 Agents Toolkit icon on the left in the VS Code toolbar.
2424
2. In the Account section, sign in with your [Microsoft 365 account](https://docs.microsoft.com/microsoftteams/platform/toolkit/accounts) if you haven't already.
25-
3. Create app by clicking `Provision` in "Lifecycle" section.
26-
4. Select `Preview in Copilot (Edge)` or `Preview in Copilot (Chrome)` from the launch configuration dropdown.
27-
5. Select your declarative agent from the `Copilot` app.
28-
6. Send a prompt.
25+
3. Select `Preview Local in Copilot (Edge)` or `Preview Local in Copilot (Chrome)` from the launch configuration dropdown.
26+
4. Select your declarative agent from the `Copilot` app.
27+
5. Send a prompt.
2928

3029
{{#ApiKey}}
3130
> [!NOTE]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file includes environment variables that will be committed to git by default.
2+
3+
# Built-in environment variables
4+
TEAMSFX_ENV=local
5+
APP_NAME_SUFFIX=local
6+
7+
# Generated during provision, you can also add your own variables.
8+
TEAMS_APP_ID=
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.10/yaml.schema.json
2+
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
3+
# Visit https://aka.ms/teamsfx-actions for details on actions
4+
version: v1.10
5+
6+
provision:
7+
# Creates an app
8+
- uses: teamsApp/create
9+
with:
10+
# app name
11+
name: {{appName}}${{APP_NAME_SUFFIX}}
12+
# Write the information of created resources into environment file for
13+
# the specified environment variable(s).
14+
writeToEnvironmentFile:
15+
teamsAppId: TEAMS_APP_ID
16+
17+
{{#ApiKey}}
18+
# Register API KEY
19+
- uses: apiKey/register
20+
with:
21+
# Name of the API Key
22+
name: {{ApiSpecAuthName}}
23+
# app ID
24+
appId: ${{TEAMS_APP_ID}}
25+
# Path to OpenAPI description document
26+
apiSpecPath: {{{ApiSpecPath}}}
27+
# Write the registration information of API Key into environment file for
28+
# the specified environment variable(s).
29+
writeToEnvironmentFile:
30+
registrationId: {{ApiSpecAuthRegistrationIdEnvName}}
31+
{{/ApiKey}}
32+
33+
{{#OAuth}}
34+
- uses: oauth/register
35+
with:
36+
name: {{ApiSpecAuthName}}
37+
flow: authorizationCode
38+
# app ID
39+
appId: ${{TEAMS_APP_ID}}
40+
# Path to OpenAPI description document
41+
apiSpecPath: {{{ApiSpecPath}}}
42+
# Use below property to change token exchange behaviour, BasicAuthorizationHeader: token exchange is done via HTTP headers. PostRequestBody: token exchange is done via request body
43+
# tokenExchangeMethodType: BasicAuthorizationHeader
44+
# Uncomment below property to use proof key for code exchange (PKCE)
45+
# isPKCEEnabled: true
46+
writeToEnvironmentFile:
47+
configurationId: {{ApiSpecAuthRegistrationIdEnvName}}
48+
{{/OAuth}}
49+
50+
# Build app package with latest env value
51+
- uses: teamsApp/zipAppPackage
52+
with:
53+
# Path to manifest template
54+
manifestPath: ./appPackage/manifest.json
55+
outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
56+
outputFolder: ./appPackage/build
57+
58+
{{^EmbeddedKnowledgeEnabled}}
59+
# Validate app package using validation rules
60+
- uses: teamsApp/validateAppPackage
61+
with:
62+
# Relative path to this file. This is the path for built zip file.
63+
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
64+
{{/EmbeddedKnowledgeEnabled}}
65+
66+
# Apply the app manifest to an existing app in
67+
# Developer Portal.
68+
# Will use the app id in manifest file to determine which app to update.
69+
- uses: teamsApp/update
70+
with:
71+
# Relative path to this file. This is the path for built zip file.
72+
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
73+
74+
# Extend your app to Outlook and the Microsoft 365 app
75+
- uses: teamsApp/extendToM365
76+
with:
77+
# Relative path to the build app package.
78+
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
79+
# Write the information of created resources into environment file for
80+
# the specified environment variable(s).
81+
writeToEnvironmentFile:
82+
titleId: M365_TITLE_ID
83+
appId: M365_APP_ID

0 commit comments

Comments
 (0)