-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
78 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
org.gradle.jvmargs=-Xmx4G | ||
android.useAndroidX=true | ||
android.enableJetifier=true | ||
android.defaults.buildfeatures.buildconfig=true | ||
android.nonTransitiveRClass=false | ||
android.nonFinalResIds=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip | ||
distributionSha256Sum=6001aba9b2204d26fa25a5800bb9382cf3ee01ccb78fe77317b2872336eb2f80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,72 @@ | ||
part of '../tool.dart'; | ||
// part of '../tool.dart'; | ||
|
||
final class TfJs extends ToolFunc { | ||
static const instance = TfJs(); | ||
const TfJs() | ||
: super( | ||
name: 'js', | ||
parametersSchema: const { | ||
'type': 'object', | ||
'properties': { | ||
'code': { | ||
'type': 'string', | ||
'description': 'The code to run', | ||
}, | ||
'scriptName': { | ||
'type': 'string', | ||
'description': 'The stored js script to run', | ||
}, | ||
}, | ||
}, | ||
); | ||
// final class TfJs extends ToolFunc { | ||
// static const instance = TfJs(); | ||
// const TfJs() | ||
// : super( | ||
// name: 'js', | ||
// parametersSchema: const { | ||
// 'type': 'object', | ||
// 'properties': { | ||
// 'code': { | ||
// 'type': 'string', | ||
// 'description': 'The code to run', | ||
// }, | ||
// 'scriptName': { | ||
// 'type': 'string', | ||
// 'description': 'The stored js script to run', | ||
// }, | ||
// }, | ||
// }, | ||
// ); | ||
|
||
@override | ||
String get description { | ||
final scripts = Stores.tool.jsScripts; | ||
final names = scripts.keys.join('\n'); | ||
return ''' | ||
This tool has a quickjs runtime, you can generate some JS code to run, | ||
like calculation and etc. | ||
// @override | ||
// String get description { | ||
// final scripts = Stores.tool.jsScripts; | ||
// final names = scripts.keys.join('\n'); | ||
// return ''' | ||
// This tool has a quickjs runtime, you can generate some JS code to run, | ||
// like calculation and etc. | ||
|
||
${names.isEmpty ? '' : "Also, there are some users' scripts that can be run in this tool:\n$names"} | ||
// ${names.isEmpty ? '' : "Also, there are some users' scripts that can be run in this tool:\n$names"} | ||
|
||
You need to return the value user wanted at end. | ||
'''; | ||
} | ||
// You need to return the value user wanted at end. | ||
// '''; | ||
// } | ||
|
||
@override | ||
String get l10nName => '${libL10n.execute} JavaScript'; | ||
// @override | ||
// String get l10nName => '${libL10n.execute} JavaScript'; | ||
|
||
@override | ||
String help(_CallResp call, _Map args) { | ||
final code = args['code'] as String? ?? '<?>'; | ||
return ''' | ||
${libL10n.execute} ? | ||
```js | ||
$code | ||
``` | ||
'''; | ||
} | ||
// @override | ||
// String help(_CallResp call, _Map args) { | ||
// final code = args['code'] as String? ?? '<?>'; | ||
// return ''' | ||
// ${libL10n.execute} ? | ||
// ```js | ||
// $code | ||
// ``` | ||
// '''; | ||
// } | ||
|
||
@override | ||
Future<_Ret?> run(_CallResp call, _Map args, OnToolLog log) async { | ||
final code = args['code'] as String?; | ||
if (code == null) return null; | ||
// @override | ||
// Future<_Ret?> run(_CallResp call, _Map args, OnToolLog log) async { | ||
// final code = args['code'] as String?; | ||
// if (code == null) return null; | ||
|
||
final rt = getJavascriptRuntime(); | ||
await rt.enableFetch(); | ||
log('${libL10n.execute} JavaScript: $code'); | ||
await Future.delayed(Durations.short1); | ||
var result = await rt.evaluateAsync(code); | ||
final raw = result.rawResult; | ||
if (raw is Future) { | ||
result = await raw; | ||
} | ||
rt.dispose(); | ||
log(result.stringResult); | ||
await Future.delayed(Durations.short1); | ||
return [ | ||
ChatContent.text(result.stringResult), | ||
]; | ||
} | ||
} | ||
// final rt = getJavascriptRuntime(); | ||
// await rt.enableFetch(); | ||
// log('${libL10n.execute} JavaScript: $code'); | ||
// await Future.delayed(Durations.short1); | ||
// var result = await rt.evaluateAsync(code); | ||
// final raw = result.rawResult; | ||
// if (raw is Future) { | ||
// result = await raw; | ||
// } | ||
// rt.dispose(); | ||
// log(result.stringResult); | ||
// await Future.delayed(Durations.short1); | ||
// return [ | ||
// ChatContent.text(result.stringResult), | ||
// ]; | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters