From 7f6b196908f7bc8bdb39604099486609e401fbe8 Mon Sep 17 00:00:00 2001 From: Robert Gruen Date: Tue, 12 Nov 2024 20:50:44 -0800 Subject: [PATCH] ran prettier --- .../src/androidMobileActionHandler.ts | 32 +++++++++++++++---- .../androidMobile/src/androidMobileSchema.ts | 23 +++++++------ ts/packages/api/src/webServer.ts | 22 ++++++------- ts/packages/shell/src/renderer/index.html | 1 - .../shell/src/renderer/src/chatInput.ts | 5 ++- ts/packages/shell/src/renderer/src/main.ts | 4 ++- ts/packages/shell/src/renderer/src/speech.ts | 16 +++++++--- .../telemetry/src/profiler/profileLogger.ts | 2 +- ts/packages/telemetry/src/stopWatch.ts | 6 ++-- ts/pnpm-lock.yaml | 3 -- 10 files changed, 73 insertions(+), 41 deletions(-) diff --git a/ts/packages/agents/androidMobile/src/androidMobileActionHandler.ts b/ts/packages/agents/androidMobile/src/androidMobileActionHandler.ts index 59b1c5db8..7ec96140a 100644 --- a/ts/packages/agents/androidMobile/src/androidMobileActionHandler.ts +++ b/ts/packages/agents/androidMobile/src/androidMobileActionHandler.ts @@ -9,7 +9,14 @@ import { ActionResult, } from "@typeagent/agent-sdk"; import { createActionResult } from "@typeagent/agent-sdk/helpers/action"; -import { AndroidMobileAction, AutomatePhoneUIAction, CallPhoneNumberAction, SearchNearbyAction, SendSMSAction, SetAlarmAction } from "./androidMobileSchema.js"; +import { + AndroidMobileAction, + AutomatePhoneUIAction, + CallPhoneNumberAction, + SearchNearbyAction, + SendSMSAction, + SetAlarmAction, +} from "./androidMobileSchema.js"; export function instantiate(): AppAgent { return { @@ -56,14 +63,21 @@ async function handlePhotoAction( switch (action.actionName) { case "sendSMS": { let smsAction = action as SendSMSAction; - result = createActionResult(`Sending SMS to ${smsAction.parameters.phoneNumber} message '${smsAction.parameters.message}'`); + result = createActionResult( + `Sending SMS to ${smsAction.parameters.phoneNumber} message '${smsAction.parameters.message}'`, + ); context.actionIO.takeAction("send-sms", smsAction.parameters); break; } case "callPhoneNumber": { let callAction = action as CallPhoneNumberAction; - result = createActionResult(`Calling ${callAction.parameters.phoneNumber}`); - context.actionIO.takeAction("call-phonenumber", callAction.parameters); + result = createActionResult( + `Calling ${callAction.parameters.phoneNumber}`, + ); + context.actionIO.takeAction( + "call-phonenumber", + callAction.parameters, + ); break; } case "setAlarm": { @@ -75,13 +89,19 @@ async function handlePhotoAction( case "searchNearby": { let nearbySearchAction = action as SearchNearbyAction; result = createActionResult("Local search"); - context.actionIO.takeAction("search-nearby", nearbySearchAction.parameters); + context.actionIO.takeAction( + "search-nearby", + nearbySearchAction.parameters, + ); break; } case "automateUI": { let automateAction = action as AutomatePhoneUIAction; result = createActionResult("Automating phone UI"); - context.actionIO.takeAction("automate-phone-ui", automateAction.parameters); + context.actionIO.takeAction( + "automate-phone-ui", + automateAction.parameters, + ); break; } default: diff --git a/ts/packages/agents/androidMobile/src/androidMobileSchema.ts b/ts/packages/agents/androidMobile/src/androidMobileSchema.ts index e89542c2c..c21c80bfe 100644 --- a/ts/packages/agents/androidMobile/src/androidMobileSchema.ts +++ b/ts/packages/agents/androidMobile/src/androidMobileSchema.ts @@ -1,11 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export type AndroidMobileAction = SendSMSAction | CallPhoneNumberAction | SetAlarmAction | SearchNearbyAction | AutomatePhoneUIAction; +export type AndroidMobileAction = + | SendSMSAction + | CallPhoneNumberAction + | SetAlarmAction + | SearchNearbyAction + | AutomatePhoneUIAction; // sends a SMS to the supplied phone number export type SendSMSAction = { - actionName: "sendSMS", + actionName: "sendSMS"; parameters: { // the original request of the user originalRequest: string; @@ -13,19 +18,19 @@ export type SendSMSAction = { phoneNumber: string; // the sms message message: string; - } -} + }; +}; // calls a user's phone number but only if we know the phone number export type CallPhoneNumberAction = { - actionName: "callPhoneNumber", + actionName: "callPhoneNumber"; parameters: { // the original request of the user originalRequest: string; // the phone number to dial phoneNumber: string; - } -} + }; +}; // sets an alarm on the local mobile device export type SetAlarmAction = { @@ -47,7 +52,7 @@ export type SearchNearbyAction = { // the search term to use when searching nearby locations searchTerm: string; }; -} +}; // Automation agent on the phone that can perform UI tasks on behalf of the user export type AutomatePhoneUIAction = { @@ -56,4 +61,4 @@ export type AutomatePhoneUIAction = { // the original request of the user originalRequest: string; }; -} \ No newline at end of file +}; diff --git a/ts/packages/api/src/webServer.ts b/ts/packages/api/src/webServer.ts index 01dec5cbe..bb2e883af 100644 --- a/ts/packages/api/src/webServer.ts +++ b/ts/packages/api/src/webServer.ts @@ -4,7 +4,10 @@ import { getMimeType } from "common-utils"; import { existsSync, readFileSync, realpathSync } from "node:fs"; import { createServer, Server } from "node:http"; -import { createServer as createSecureServer, Server as SecureServer } from "node:https" +import { + createServer as createSecureServer, + Server as SecureServer, +} from "node:https"; import path from "node:path"; export type TypeAgentAPIServerConfig = { @@ -18,7 +21,6 @@ export class TypeAgentAPIWebServer { private secureServer: SecureServer; constructor(config: TypeAgentAPIServerConfig) { - // web server this.server = createServer((request: any, response: any) => { this.serve(config, request, response); @@ -27,14 +29,15 @@ export class TypeAgentAPIWebServer { // secure webserver this.secureServer = createSecureServer( { - key: readFileSync('.cert/localhost+2-key.pem'), // path to localhost+2-key.pem - cert: readFileSync('.cert/localhost+2.pem'), // path to localhost+2.pem + key: readFileSync(".cert/localhost+2-key.pem"), // path to localhost+2-key.pem + cert: readFileSync(".cert/localhost+2.pem"), // path to localhost+2.pem requestCert: false, rejectUnauthorized: false, }, (request: any, response: any) => { this.serve(config, request, response); - }); + }, + ); } serve(config: TypeAgentAPIServerConfig, request: any, response: any) { @@ -59,9 +62,7 @@ export class TypeAgentAPIWebServer { // serve requested file if (existsSync(requestedFile)) { response.writeHead(200, { - "Content-Type": getMimeType( - path.extname(requestedFile), - ), + "Content-Type": getMimeType(path.extname(requestedFile)), "Access-Control-Allow-Origin": "*", //"Permissions-Policy": "camera=(self)", // allow access to getUserMedia() for the camera }); @@ -74,17 +75,16 @@ export class TypeAgentAPIWebServer { response.end("File Not Found!\n"); console.log(`Unable to serve '${request.url}', 404. ${error}`); - } + } } start() { - this.server.listen(3000, () => { console.log("Listening on all local IPs at port 3000"); }); this.secureServer.listen(3443, () => { - console.log("Listening securely on all local IPs at port 3443") + console.log("Listening securely on all local IPs at port 3443"); }); } diff --git a/ts/packages/shell/src/renderer/index.html b/ts/packages/shell/src/renderer/index.html index ba7b79a9b..69257bf13 100644 --- a/ts/packages/shell/src/renderer/index.html +++ b/ts/packages/shell/src/renderer/index.html @@ -25,6 +25,5 @@
- diff --git a/ts/packages/shell/src/renderer/src/chatInput.ts b/ts/packages/shell/src/renderer/src/chatInput.ts index 15bcc6779..28952fb87 100644 --- a/ts/packages/shell/src/renderer/src/chatInput.ts +++ b/ts/packages/shell/src/renderer/src/chatInput.ts @@ -338,7 +338,10 @@ export class ChatInput { this.attachButton.className = "chat-input-button"; getSpeechToken().then((result) => { - if (result == undefined && !Android?.isSpeechRecognitionSupported()) { + if ( + result == undefined && + !Android?.isSpeechRecognitionSupported() + ) { const button = document.querySelector( `#${buttonId}`, )!; diff --git a/ts/packages/shell/src/renderer/src/main.ts b/ts/packages/shell/src/renderer/src/main.ts index 3b855dd2f..ec3ea6f28 100644 --- a/ts/packages/shell/src/renderer/src/main.ts +++ b/ts/packages/shell/src/renderer/src/main.ts @@ -374,6 +374,8 @@ document.addEventListener("DOMContentLoaded", async function () { } if (Android) { - Bridge.interfaces.Android.domReady((userMessage: string) => { chatView.addUserMessage(userMessage); }); + Bridge.interfaces.Android.domReady((userMessage: string) => { + chatView.addUserMessage(userMessage); + }); } }); diff --git a/ts/packages/shell/src/renderer/src/speech.ts b/ts/packages/shell/src/renderer/src/speech.ts index 1522a570f..b5a849fc6 100644 --- a/ts/packages/shell/src/renderer/src/speech.ts +++ b/ts/packages/shell/src/renderer/src/speech.ts @@ -177,12 +177,20 @@ export function recognizeOnce( let result: speechSDK.SpeechRecognitionResult | undefined; if (text === undefined || text === null) { - result = new speechSDK.SpeechRecognitionResult(undefined, speechSDK.ResultReason.NoMatch, text); - } else { - result = new speechSDK.SpeechRecognitionResult(undefined, speechSDK.ResultReason.RecognizedSpeech, text); + result = new speechSDK.SpeechRecognitionResult( + undefined, + speechSDK.ResultReason.NoMatch, + text, + ); + } else { + result = new speechSDK.SpeechRecognitionResult( + undefined, + speechSDK.ResultReason.RecognizedSpeech, + text, + ); } - onRecognizedResult(result, inputId, buttonId, messageHandler ) + onRecognizedResult(result, inputId, buttonId, messageHandler); }); } else { const audioConfig = getAudioConfig(); diff --git a/ts/packages/telemetry/src/profiler/profileLogger.ts b/ts/packages/telemetry/src/profiler/profileLogger.ts index 68776f095..9feb78c18 100644 --- a/ts/packages/telemetry/src/profiler/profileLogger.ts +++ b/ts/packages/telemetry/src/profiler/profileLogger.ts @@ -3,7 +3,7 @@ import { ProfileEntry, UnreadProfileEntries } from "./profileReader.js"; import registerDebug from "debug"; -import { Profiler } from "./profiler.js" +import { Profiler } from "./profiler.js"; const debug = registerDebug("typeagent:profiler"); diff --git a/ts/packages/telemetry/src/stopWatch.ts b/ts/packages/telemetry/src/stopWatch.ts index 1ea9f8b64..ddaf2a7b9 100644 --- a/ts/packages/telemetry/src/stopWatch.ts +++ b/ts/packages/telemetry/src/stopWatch.ts @@ -66,12 +66,10 @@ export class StopWatch { } public log(label: string, inSeconds: boolean = true): void { - import("chalk").then(chalk => { - + import("chalk").then((chalk) => { let elapsed = `[${this.elapsedString(inSeconds)}]`; let text = `${chalk.default.gray(label)} ${chalk.default.green(elapsed)}`; console.log(text); - - }) + }); } } diff --git a/ts/pnpm-lock.yaml b/ts/pnpm-lock.yaml index 97349bd7b..bed176668 100644 --- a/ts/pnpm-lock.yaml +++ b/ts/pnpm-lock.yaml @@ -1039,9 +1039,6 @@ importers: debug: specifier: ^4.3.4 version: 4.3.4(supports-color@8.1.1) - telemetry: - specifier: workspace:* - version: link:../telemetry typechat: specifier: ^0.1.1 version: 0.1.1(typescript@5.4.3)