aimyapi 1.0.9 → 1.0.10

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.
@@ -1,14 +1,27 @@
1
+ import z from "zod";
1
2
  import { delay } from "../src/utils";
2
3
  import { APIInterface, SalesData } from "./sales_api";
3
4
 
4
5
  export class API implements APIInterface {
5
6
 
7
+ // Schema validation for function parameters. Will throw if parameters are invalid to prevent silent failures and surface info to the agent.
8
+ public _params_sendEmail = z.object({
9
+ to: z.string(),
10
+ subject: z.string(),
11
+ body: z.string().min(5)
12
+ })
13
+
6
14
  // Mock implementation, doesn't actually send an email
7
- sendEmail(to: string, subject: string, body: string): Promise<void> {
8
- console.log(`Sending email to "${to}" with subject "${subject}" and body\n"${body}"`);
15
+ // fields should be defined in the same order that they occur in the function
16
+ async sendEmail(to: string, subject: string, body: string): Promise<void> {
17
+ console.log(`Successfully sent email to "${to}" with subject "${subject}" and body\n"${body}"`);
9
18
  return delay(1000);
10
19
  }
11
20
 
21
+ getDate() {
22
+ return new Date();
23
+ }
24
+
12
25
  getSalesData(): SalesData[] {
13
26
  return [
14
27
  { sales: 100, month: 1, year: 2020, businessUnit: "Advertising" },
@@ -50,9 +63,10 @@ export class API implements APIInterface {
50
63
  ]
51
64
  };
52
65
 
53
- print(text: string): void {
54
- console.log(`[API]: ${text}`);
66
+ display(): void {
67
+ console.log(`[API]:`, ...arguments);
55
68
  }
69
+
56
70
  delay(milliseconds: number): Promise<void> {
57
71
  return delay(milliseconds);
58
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aimyapi",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "AI My API! Typescript sandbox for AI agents to interact with your API in a safe way.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -38,8 +38,7 @@
38
38
  "openai": "^6.33.0",
39
39
  "quickjs-emscripten": "^0.22.0",
40
40
  "typescript": "^5.0.3",
41
- "zod": "^3.23.8",
42
- "zod-to-json-schema": "^3.23.3"
41
+ "zod": "^4.6.7"
43
42
  },
44
43
  "author": "David Wallin",
45
44
  "license": "MIT",
@@ -0,0 +1,37 @@
1
+
2
+ Most recent user query:
3
+ {{USER_QUERY}}
4
+
5
+ ---
6
+
7
+ Based on the prior conversation, write a typescript script that performs the operation requested by the user and call the `submitCode` tool with the script.
8
+
9
+ ## API documentation
10
+
11
+ You can make use of this api:
12
+
13
+ `api.ts`:
14
+ ```ts
15
+ {{API}}
16
+ ```
17
+
18
+ ## Instructions
19
+
20
+ Use the global object defined above to make calls to the API. The API runs in a development environment using mocked data.
21
+
22
+ The provided tools will execute code in a sandbox and you will only have access to the API provided above and the standard javascript api's.
23
+
24
+ You may use top level `await` since your code will be wrapped in an async function before being run.
25
+ You should write safe code and catch exceptions. For errors, use `console.error` with a helpful message.
26
+ Avoid logging PII or sensitive information.
27
+
28
+ You may use `runCode` to experiment or test. Console logs will be returned with the tool results, including 'traces' which show calls to the API.
29
+
30
+ When finished, you must call `submitCode` to check and run the code. Examine the log traces that get returned to confirm that the expected calls were made and the code is running as expected. If not, you may call submit code again. Once finished, respond with "Successfully submitted code".
31
+
32
+ ---
33
+
34
+ {{DOCUMENTATION}}
35
+
36
+ {{CONTEXT}}
37
+