Skip to content

Commit 47dd54a

Browse files
committed
fix execution states for long running async tasks
1 parent bf7cf65 commit 47dd54a

File tree

12 files changed

+185
-120
lines changed

12 files changed

+185
-120
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ https://github.com/ThousandBirdsInc/chidori/assets/515757/6b088f7d-d8f7-4c7e-900
1919
Star us on Github! Join us on [Discord](https://discord.gg/CJwKsPSgew).
2020

2121
## Contents
22-
- [📖 Chidori](#-chidori)
22+
- [📖 Chidori V2](#-chidori-v2)
2323
- [⚡️ Getting Started](#️-getting-started)
2424
- [Installation](#installation)
2525
- [Environment Variables](#environment-variables)

media/ChidoriPanel.png

20.8 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,52 @@
11
# This agent demonstrates how to traverse multiple parts of a website, extract data, and produce a structured report.
22

3+
We use Astral rather than Playwright for Deno support
4+
https://astral.deno.dev/guides/navigation/
35

6+
```ts
7+
import { launch } from "https://deno.land/x/astral/mod.ts";
8+
9+
10+
// Connect to remote endpoint
11+
const browser = await launch({
12+
wsEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`
13+
});
14+
15+
// Do stuff
16+
// Open the webpage
17+
const page = await browser.newPage("https://deno.land");
18+
19+
// Click the search button
20+
const button = await page.$("button");
21+
await button!.click();
22+
23+
// Type in the search input
24+
const input = await page.$("#search-input");
25+
await input!.type("pyro", { delay: 1000 });
26+
27+
// Wait for the search results to come back
28+
await page.waitForNetworkIdle({ idleConnections: 0, idleTime: 1000 });
29+
30+
// Click the 'pyro' link
31+
const xLink = await page.$("a.justify-between:nth-child(1)");
32+
await Promise.all([
33+
xLink!.click(),
34+
page.waitForNavigation(),
35+
]);
36+
37+
// Click the link to 'pyro.deno.dev'
38+
const dLink = await page.$(
39+
".markdown-body > p:nth-child(8) > a:nth-child(1)",
40+
);
41+
await Promise.all([
42+
dLink!.click(),
43+
page.waitForNavigation(),
44+
]);
45+
46+
47+
// Close connection
48+
await browser.close();
49+
```
450

551

652

toolchain/chidori-core/examples/demo1_business_analyst/pyproject.toml

-14
This file was deleted.

toolchain/chidori-core/src/library/std/code/runtime_deno.rs

+20-18
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ pub async fn source_code_run_deno(
552552
let mut flags = deno::args::Flags::default();
553553
// TODO: give user control over this in configuration
554554
// TODO: allow_net is causing this to block our execution entirely
555-
// flags.allow_net = Some(vec![]);
555+
flags.allow_net = Some(vec![]);
556+
flags.allow_env = Some(vec![]);
556557
let factory = deno::factory::CliFactory::from_flags(flags)?;
557558
let cli_options = factory.cli_options();
558559
let file_fetcher = factory.file_fetcher()?;
@@ -594,6 +595,7 @@ pub async fn source_code_run_deno(
594595
dbg!(&e);
595596
e
596597
})?;
598+
println!("After the runtime block on in source_code_run_deno");
597599
// TODO: map error
598600

599601
let mut my_op_state = my_op_state.lock().unwrap();
@@ -656,7 +658,7 @@ mod tests {
656658
assert_eq!(
657659
result.unwrap(),
658660
(
659-
RkyvObjectBuilder::new().insert_number("y", 10).build(),
661+
Ok(RkyvObjectBuilder::new().insert_number("y", 10).build()),
660662
vec![],
661663
vec![],
662664
)
@@ -683,7 +685,7 @@ mod tests {
683685
assert_eq!(
684686
result.unwrap(),
685687
(
686-
RkyvObjectBuilder::new().insert_number("z", 25).build(),
688+
Ok(RkyvObjectBuilder::new().insert_number("z", 25).build()),
687689
vec![],
688690
vec![],
689691
)
@@ -697,7 +699,7 @@ mod tests {
697699
assert_eq!(
698700
result.unwrap(),
699701
(
700-
RkyvObjectBuilder::new().insert_number("x", 42).build(),
702+
Ok(RkyvObjectBuilder::new().insert_number("x", 42).build()),
701703
vec![],
702704
vec![],
703705
)
@@ -718,12 +720,12 @@ mod tests {
718720
assert_eq!(
719721
result.unwrap(),
720722
(
721-
RkyvObjectBuilder::new()
723+
Ok(RkyvObjectBuilder::new()
722724
.insert_object(
723725
"obj",
724726
RkyvObjectBuilder::new().insert_string("foo", "bar".to_string())
725727
)
726-
.build(),
728+
.build()),
727729
vec![],
728730
vec![],
729731
)
@@ -736,7 +738,7 @@ mod tests {
736738
assert_eq!(
737739
result.unwrap(),
738740
(
739-
RkyvObjectBuilder::new().insert_number("x", 30).build(),
741+
Ok(RkyvObjectBuilder::new().insert_number("x", 30).build()),
740742
vec![],
741743
vec![],
742744
)
@@ -753,7 +755,7 @@ mod tests {
753755
assert_eq!(
754756
result.unwrap(),
755757
(
756-
RkyvSerializedValue::Number(30),
758+
Ok(RkyvSerializedValue::Number(30)),
757759
vec![],
758760
vec![],
759761
)
@@ -773,7 +775,7 @@ mod tests {
773775
assert_eq!(
774776
result.unwrap(),
775777
(
776-
RkyvObjectBuilder::new().build(),
778+
Ok(RkyvObjectBuilder::new().build()),
777779
vec![String::from("[out]: \"testing, output\"\n")],
778780
vec![String::from("[out]: \"testing, stderr\"\n")],
779781
)
@@ -813,7 +815,7 @@ mod tests {
813815
assert_eq!(
814816
result.unwrap(),
815817
(
816-
RkyvObjectBuilder::new().insert_number("x", 42).build(),
818+
Ok(RkyvObjectBuilder::new().insert_number("x", 42).build()),
817819
vec![],
818820
vec![],
819821
)
@@ -833,14 +835,14 @@ mod tests {
833835
assert_eq!(
834836
result.unwrap(),
835837
(
836-
RkyvObjectBuilder::new()
838+
Ok(RkyvObjectBuilder::new()
837839
.insert_object(
838840
"person",
839841
RkyvObjectBuilder::new()
840842
.insert_string("name", "Alice".to_string())
841843
.insert_number("age", 30)
842844
)
843-
.build(),
845+
.build()),
844846
vec![],
845847
vec![],
846848
)
@@ -859,10 +861,10 @@ mod tests {
859861
assert_eq!(
860862
result.unwrap(),
861863
(
862-
RkyvObjectBuilder::new()
864+
Ok(RkyvObjectBuilder::new()
863865
.insert_string("identity", "function".to_string())
864866
.insert_string("result", "TypeScript".to_string())
865-
.build(),
867+
.build()),
866868
vec![],
867869
vec![],
868870
)
@@ -881,10 +883,10 @@ mod tests {
881883
assert_eq!(
882884
result.unwrap(),
883885
(
884-
RkyvObjectBuilder::new()
886+
Ok(RkyvObjectBuilder::new()
885887
.insert_string("data", "Data".to_string())
886888
.insert_string("fetchData", "function".to_string())
887-
.build(),
889+
.build()),
888890
vec![],
889891
vec![],
890892
)
@@ -905,9 +907,9 @@ mod tests {
905907
assert_eq!(
906908
result.unwrap(),
907909
(
908-
RkyvObjectBuilder::new()
910+
Ok(RkyvObjectBuilder::new()
909911
.insert_number("selectedColor", 1)
910-
.build(),
912+
.build()),
911913
vec![],
912914
vec![],
913915
)

0 commit comments

Comments
 (0)