@casual-simulation/aux-runtime 3.3.3 → 3.3.4-alpha.9225751827
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/package.json +5 -5
- package/runtime/AuxGlobalContext.d.ts +86 -3
- package/runtime/AuxGlobalContext.js +76 -1
- package/runtime/AuxGlobalContext.js.map +1 -1
- package/runtime/AuxLibrary.d.ts +8 -0
- package/runtime/AuxLibrary.js +123 -2
- package/runtime/AuxLibrary.js.map +1 -1
- package/runtime/AuxLibraryDefinitions.def +186 -0
- package/runtime/AuxRuntime.js +24 -0
- package/runtime/AuxRuntime.js.map +1 -1
- package/runtime/RecordsEvents.d.ts +23 -1
- package/runtime/RecordsEvents.js +15 -0
- package/runtime/RecordsEvents.js.map +1 -1
|
@@ -10589,6 +10589,177 @@ interface Ai {
|
|
|
10589
10589
|
negativePrompt?: string | RecordActionOptions,
|
|
10590
10590
|
options?: RecordActionOptions
|
|
10591
10591
|
): Promise<string | AIGenerateImageSuccess>;
|
|
10592
|
+
|
|
10593
|
+
stream: {
|
|
10594
|
+
/**
|
|
10595
|
+
* Sends a chat message to the AI and streams the response back.
|
|
10596
|
+
* Returns a promise that resolves with an [async iterable](https://javascript.info/async-iterators-generators#async-iterables) that contains the responses from the AI.
|
|
10597
|
+
*
|
|
10598
|
+
* Throws a {@link CasualOSError} if an error occurs while sending the message.
|
|
10599
|
+
*
|
|
10600
|
+
* This function can be useful for creating chat bots, or for using an Artificial Intelligence (AI) to process a message.
|
|
10601
|
+
*
|
|
10602
|
+
* @param message The message that should be sent to the AI.
|
|
10603
|
+
* @param options The options that should be used.
|
|
10604
|
+
*
|
|
10605
|
+
* @example Send a message to the AI and log the response.
|
|
10606
|
+
* const response = await ai.stream.chat("Hello!");
|
|
10607
|
+
*
|
|
10608
|
+
* for await (let message of response) {
|
|
10609
|
+
* console.log(message);
|
|
10610
|
+
* }
|
|
10611
|
+
*
|
|
10612
|
+
* @dochash actions/ai
|
|
10613
|
+
* @doctitle AI Actions
|
|
10614
|
+
* @docsidebar AI
|
|
10615
|
+
* @docdescription AI actions are functions that make it easier to work with the AI.
|
|
10616
|
+
* @docname ai.stream.chat
|
|
10617
|
+
* @docid ai.stream.chat-string
|
|
10618
|
+
*/
|
|
10619
|
+
chat(message: string, options?: AIChatOptions): Promise<AsyncIterable<string>>;
|
|
10620
|
+
|
|
10621
|
+
/**
|
|
10622
|
+
* Sends a chat message to the AI and streams the response back.
|
|
10623
|
+
* Returns a promise that resolves with an [async iterable](https://javascript.info/async-iterators-generators#async-iterables) that contains the responses from the AI.
|
|
10624
|
+
*
|
|
10625
|
+
* Throws a {@link CasualOSError} if an error occurs while sending the message.
|
|
10626
|
+
*
|
|
10627
|
+
* This function can be useful for creating chat bots, or for using an Artificial Intelligence (AI) to process a message.
|
|
10628
|
+
*
|
|
10629
|
+
* @param message The message that should be sent to the AI.
|
|
10630
|
+
* @param options The options that should be used.
|
|
10631
|
+
*
|
|
10632
|
+
* @example Send a message to the AI and log the response.
|
|
10633
|
+
* const response = await ai.chat({
|
|
10634
|
+
* role: "user",
|
|
10635
|
+
* content: "Hello!"
|
|
10636
|
+
* });
|
|
10637
|
+
* console.log(`${response.role}: ${response.content}`);
|
|
10638
|
+
*
|
|
10639
|
+
* @example Ask the AI to describe an uploaded image.
|
|
10640
|
+
* const files = await os.showUploadFiles();
|
|
10641
|
+
* const firstFile = files[0];
|
|
10642
|
+
* const base64 = bytes.toBase64String(new Uint8Array(firstFile.data));
|
|
10643
|
+
* const response = await ai.stream.chat({
|
|
10644
|
+
* role: 'user',
|
|
10645
|
+
* content: [
|
|
10646
|
+
* {
|
|
10647
|
+
* base64: base64,
|
|
10648
|
+
* mimeType: firstFile.mimeType,
|
|
10649
|
+
* },
|
|
10650
|
+
* {
|
|
10651
|
+
* text: 'please describe the image'
|
|
10652
|
+
* }
|
|
10653
|
+
* ]
|
|
10654
|
+
* }, {
|
|
10655
|
+
* preferredModel: 'gemini-pro-vision'
|
|
10656
|
+
* });
|
|
10657
|
+
*
|
|
10658
|
+
* for await (let message of response) {
|
|
10659
|
+
os.toast(message.content);
|
|
10660
|
+
* }
|
|
10661
|
+
*
|
|
10662
|
+
* @dochash actions/ai
|
|
10663
|
+
* @docname ai.stream.chat
|
|
10664
|
+
* @docid ai.stream.chat-message
|
|
10665
|
+
*/
|
|
10666
|
+
chat(
|
|
10667
|
+
message: AIChatMessage,
|
|
10668
|
+
options?: AIChatOptions
|
|
10669
|
+
): Promise<AsyncIterable<AIChatMessage>>;
|
|
10670
|
+
|
|
10671
|
+
/**
|
|
10672
|
+
* Sends a chat message to the AI.
|
|
10673
|
+
* Returns a promise that resolves with an [async iterable](https://javascript.info/async-iterators-generators#async-iterables) that contains the responses from the AI.
|
|
10674
|
+
*
|
|
10675
|
+
* Throws a {@link CasualOSError} if an error occurs while sending the message.
|
|
10676
|
+
*
|
|
10677
|
+
* This function can be useful for creating chat bots, or for using an Artificial Intelligence (AI) to process a message.
|
|
10678
|
+
*
|
|
10679
|
+
* @param message The message that should be sent to the AI.
|
|
10680
|
+
* @param options The options that should be used.
|
|
10681
|
+
*
|
|
10682
|
+
* @example Send a message to the AI and log the response.
|
|
10683
|
+
* const response = await ai.stream.chat([
|
|
10684
|
+
* {
|
|
10685
|
+
* role: "system",
|
|
10686
|
+
* content: "You are a helpful assistant."
|
|
10687
|
+
* },
|
|
10688
|
+
* {
|
|
10689
|
+
* role: "user",
|
|
10690
|
+
* content: "Hello!"
|
|
10691
|
+
* }
|
|
10692
|
+
* ]);
|
|
10693
|
+
*
|
|
10694
|
+
* for await (let message of response) {
|
|
10695
|
+
* console.log(`${message.role}: ${message.content}`);
|
|
10696
|
+
* }
|
|
10697
|
+
*
|
|
10698
|
+
* @example Build a basic chat bot.
|
|
10699
|
+
* const messages = [
|
|
10700
|
+
* {
|
|
10701
|
+
* role: "system",
|
|
10702
|
+
* content: "You are a helpful assistant."
|
|
10703
|
+
* },
|
|
10704
|
+
* ];
|
|
10705
|
+
*
|
|
10706
|
+
* while(true) {
|
|
10707
|
+
* const userInput = await os.showInput();
|
|
10708
|
+
* if (!userInput) {
|
|
10709
|
+
* break;
|
|
10710
|
+
* }
|
|
10711
|
+
* messages.push({
|
|
10712
|
+
* role: "user",
|
|
10713
|
+
* content: userInput
|
|
10714
|
+
* });
|
|
10715
|
+
*
|
|
10716
|
+
* const response = await ai.stream.chat(messages);
|
|
10717
|
+
*
|
|
10718
|
+
* for await (let message of response) {
|
|
10719
|
+
* messages.push(message);
|
|
10720
|
+
* os.toast(message.content);
|
|
10721
|
+
* }
|
|
10722
|
+
* }
|
|
10723
|
+
*
|
|
10724
|
+
* os.toast("Goodbye!");
|
|
10725
|
+
*
|
|
10726
|
+
* @example Ask the AI to describe an uploaded image.
|
|
10727
|
+
* const files = await os.showUploadFiles();
|
|
10728
|
+
* const firstFile = files[0];
|
|
10729
|
+
* const base64 = bytes.toBase64String(new Uint8Array(firstFile.data));
|
|
10730
|
+
* const response = await ai.stream.chat([{
|
|
10731
|
+
* role: 'user',
|
|
10732
|
+
* content: [
|
|
10733
|
+
* {
|
|
10734
|
+
* base64: base64,
|
|
10735
|
+
* mimeType: firstFile.mimeType,
|
|
10736
|
+
* },
|
|
10737
|
+
* {
|
|
10738
|
+
* text: 'please describe the image'
|
|
10739
|
+
* }
|
|
10740
|
+
* ]
|
|
10741
|
+
* }], {
|
|
10742
|
+
* preferredModel: 'gemini-pro-vision'
|
|
10743
|
+
* });
|
|
10744
|
+
*
|
|
10745
|
+
* for await (let message of response) {
|
|
10746
|
+
os.toast(message.content);
|
|
10747
|
+
* }
|
|
10748
|
+
*
|
|
10749
|
+
* @dochash actions/ai
|
|
10750
|
+
* @docname ai.stream.chat
|
|
10751
|
+
* @docid ai.stream.chat-messages
|
|
10752
|
+
*/
|
|
10753
|
+
chat(
|
|
10754
|
+
messages: AIChatMessage[],
|
|
10755
|
+
options?: AIChatOptions
|
|
10756
|
+
): Promise<AsyncIterable<AIChatMessage>>;
|
|
10757
|
+
|
|
10758
|
+
chat(
|
|
10759
|
+
messages: string | AIChatMessage | AIChatMessage[],
|
|
10760
|
+
options?: AIChatOptions
|
|
10761
|
+
): Promise<AsyncIterable<AIChatMessage | string>>;
|
|
10762
|
+
}
|
|
10592
10763
|
}
|
|
10593
10764
|
|
|
10594
10765
|
interface Os {
|
|
@@ -11167,6 +11338,21 @@ interface Os {
|
|
|
11167
11338
|
*/
|
|
11168
11339
|
capturePhoto(options?: OpenPhotoCameraOptions): Promise<Photo>;
|
|
11169
11340
|
|
|
11341
|
+
/**
|
|
11342
|
+
* Captures a screenshot (i.e. photo/picture) from the grid portal.
|
|
11343
|
+
*
|
|
11344
|
+
* Returns a promise that resolves with the captured photo.
|
|
11345
|
+
*
|
|
11346
|
+
* @param portal the portal to capture the screenshot from. Defaults to the grid portal.
|
|
11347
|
+
*
|
|
11348
|
+
* @example Capture a screenshot from the grid portal.
|
|
11349
|
+
* const screenshot = await os.capturePortalScreenshot();
|
|
11350
|
+
*
|
|
11351
|
+
* @dochash actions/os/portals
|
|
11352
|
+
* @docname os.capturePortalScreenshot
|
|
11353
|
+
*/
|
|
11354
|
+
capturePortalScreenshot(): Promise<Photo>;
|
|
11355
|
+
|
|
11170
11356
|
/**
|
|
11171
11357
|
* Shows the given barcode.
|
|
11172
11358
|
* @param code The code that should be shown.
|
package/runtime/AuxRuntime.js
CHANGED
|
@@ -1119,6 +1119,30 @@ export class AuxRuntime {
|
|
|
1119
1119
|
this._scheduleJobQueueCheck();
|
|
1120
1120
|
}
|
|
1121
1121
|
}
|
|
1122
|
+
else if (action.type === 'iterable_next') {
|
|
1123
|
+
if (!this._globalContext.iterableNext(action.taskId, action.value, false)) {
|
|
1124
|
+
this._actionBatch.push(action);
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
this._scheduleJobQueueCheck();
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
else if (action.type === 'iterable_complete') {
|
|
1131
|
+
if (!this._globalContext.iterableComplete(action.taskId, false)) {
|
|
1132
|
+
this._actionBatch.push(action);
|
|
1133
|
+
}
|
|
1134
|
+
else {
|
|
1135
|
+
this._scheduleJobQueueCheck();
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
else if (action.type === 'iterable_throw') {
|
|
1139
|
+
if (!this._globalContext.iterableThrow(action.taskId, action.error, false)) {
|
|
1140
|
+
this._actionBatch.push(action);
|
|
1141
|
+
}
|
|
1142
|
+
else {
|
|
1143
|
+
this._scheduleJobQueueCheck();
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1122
1146
|
else if (action.type === 'register_custom_app') {
|
|
1123
1147
|
this._registerPortalBot(action.appId, action.botId);
|
|
1124
1148
|
this._actionBatch.push(action);
|