Skip to content

Commit

Permalink
rebase(main): Pulled in new API changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzanecook committed Apr 16, 2024
2 parents 1d0161c + 3d9af83 commit e198b89
Show file tree
Hide file tree
Showing 39 changed files with 4,622 additions and 6,195 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,6 @@ cython_debug/
.idea/

# Testing Suite HTML Reports
report.html
report.html

**/.openapi-generator
2 changes: 1 addition & 1 deletion apps/agentprotocol.ai/src/app/sdks/python/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ from agent_protocol import Agent, Step, Task

async def plan(step: Step) -> Step:
task = await Agent.db.get_task(step.task_id)
steps = generete_steps(task.input)
steps = generate_steps(task.input)

last_step = steps[-1]
for step in steps[:-1]:
Expand Down
8,421 changes: 2,367 additions & 6,054 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"ci": "prettier . -c && eslint . --ext .ts,.tsx",
"prettier": "prettier . -w",
"lint": "eslint . --ext .ts,.tsx --fix",
"prepare": "husky install"
"prepare": "husky install",
"generate:client:js": "openapi-generator-cli generate --global-property apis,models,supportingFiles,modelDocs=false -i schemas/openapi.yml -g typescript-fetch -c packages/client/js/openapitools.json -o packages/client/js --additional-properties=generateSourceCodeOnly=true"
},
"husky": {
"hooks": {
Expand All @@ -15,12 +16,14 @@
"@types/express": "^4.17.21",
"@types/firebase": "^3.2.1",
"@types/redis": "^4.0.11",
"@openapitools/openapi-generator-cli": "^2.9.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard-with-typescript": "^36.1.0",
"husky": "^7.0.0",
"prettier": "^3.0.0",
"prettier-plugin-tailwindcss": "^0.5.11",
"typescript": "^5.1.6"
},
"optionalDependencies": {
Expand All @@ -34,6 +37,7 @@
},
"dependencies": {
"express": "^4.18.2",
"express-openapi-validator": "^5.1.5"
"express-openapi-validator": "^5.1.5",
"express-serve-static-core": "^0.1.1"
}
}
}
1 change: 1 addition & 0 deletions packages/client/js/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
23 changes: 23 additions & 0 deletions packages/client/js/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
56 changes: 56 additions & 0 deletions packages/client/js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## [email protected]

This generator creates TypeScript/JavaScript client that utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:

Environment

- Node.js
- Webpack
- Browserify

Language level

- ES5 - you must have a Promises/A+ library installed
- ES6

Module system

- CommonJS
- ES6 module system

It can be used in both TypeScript and JavaScript. In TypeScript, the definition should be automatically resolved via `package.json`. ([Reference](http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html))

### Building

To build and compile the typescript sources to javascript use:

```
npm install
npm run build
```

### Testing with the Minimal Example

- First set up the minimal example agent protocol server in the JS or Python SDK repositories.
- After the minimal SDK example is running, run the minimal example locally by changing the import to `..` and running `npm run build` in the package root.
- Run the minimal client example using `ts-node minimal.ts` once the package is built.

### Publishing

First build the package then run `npm publish`

### Consuming

navigate to the folder of your consuming project and run one of the following commands.

_published:_

```
npm install [email protected] --save
```

_unPublished (not recommended):_

```
npm install PATH_TO_GENERATED_PACKAGE --save
```
42 changes: 42 additions & 0 deletions packages/client/js/examples/minimal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Configuration, AgentApi, TaskRequestBody, StepRequestBody } from 'agent-protocol-client';

// Defining the host is optional and defaults to http://localhost
// See configuration.ts for a list of all supported configuration parameters.
const configuration = new Configuration({ basePath: "http://localhost:8000" });

async function main() {
// Create an instance of the API client
const apiInstance = new AgentApi(configuration);
// Create an instance of the API class
const taskRequestBody: TaskRequestBody = {
input: "Write 'Hello world!' to hi.txt."
};

const response = await apiInstance.createAgentTask({ taskRequestBody });
console.log("The response of AgentApi->createAgentTask:\n");
console.log(response);
console.log("\n\n");

const taskId = response.taskId;
let i = 1;

while (true) {
const stepRequestBody: StepRequestBody = {
input: String(i)
};
const step = await apiInstance.executeAgentTaskStep({ taskId, stepRequestBody });

if (!step || step.isLast) {
break;
}

console.log("The response of AgentApi->executeAgentTaskStep:\n");
console.log(step);
console.log("\n\n");
i += 1;
}

console.log("Agent finished its work!");
}

main().catch(console.error);
14 changes: 14 additions & 0 deletions packages/client/js/openapitools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "7.2.0",
"useDocker": true
},
"projectName": "agent-protocol-client",
"packageVersion": "1.0.0",
"additionalProperties": {
"npmName": "agent-protocol-client",
"typescriptThreePlus": true
}
}
28 changes: 28 additions & 0 deletions packages/client/js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions packages/client/js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "agent-protocol-client",
"version": "v1",
"description": "OpenAPI client for agent-protocol-client",
"author": "OpenAPI-Generator",
"repository": {
"type": "git",
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
},
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"scripts": {
"build": "tsc",
"prepare": "npm run build"
},
"devDependencies": {
"typescript": "^4.0"
}
}
Loading

0 comments on commit e198b89

Please sign in to comment.