Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Apr 8, 2024
0 parents commit 1cfcd79
Show file tree
Hide file tree
Showing 20 changed files with 473 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build-javascript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build Javascript/Typescript

on:
push:

release:
types: [published]

jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '21'
registry-url: 'https://npm.pkg.github.com'

- name: Build
run: bash build-javascript.sh

- name: Upload Javascript artifacts
uses: actions/upload-artifact@v2
with:
name: build-javascript
path: build/javascript/dist

- name: Upload Typescript artifacts
uses: actions/upload-artifact@v2
with:
name: build-typescript
path: build/javascript/src

- name: Upload dist
uses: actions/upload-artifact@v2
with:
name: dist-typescript-javascript
path: build/javascript/*.tgz

- name: Upload release asset
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: build/javascript/openagents-service-provider-proto-*.tgz

- name: Publish
if: github.event_name == 'release'
run: cd build/javascript && npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
31 changes: 31 additions & 0 deletions .github/workflows/build-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build PHP

on:
push:

release:
types: [published]

jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Build
run: bash build-php.sh

- name: Upload PHP artifacts
uses: actions/upload-artifact@v2
with:
name: build-php
path: build/php
46 changes: 46 additions & 0 deletions .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build Python

on:
push:

release:
types: [published]

jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Install dependencies
run: pip install -r requirements.txt

- name: Build
run: python build-python.py

- name: Upload Python artifacts
uses: actions/upload-artifact@v2
with:
name: build-python
path: build/python/openagents_service_provider_proto

- name: Upload Python dist
uses: actions/upload-artifact@v2
with:
name: dist-python
path: build/python/dist

- name: Upload release asset
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: build/python/dist/*.tar.gz
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tmp
build
/package-lock.json
/package.json
node_modules
16 changes: 16 additions & 0 deletions build-javascript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

mkdir -p build/javascript/src
mkdir -p build/javascript/dist

npm i --save-dev @grpc/grpc-js ts-protoc-gen @protobuf-ts/plugin typescript @types/node

npx protoc --ts_out build/javascript/src \
--experimental_allow_proto3_optional \
--ts_opt long_type_number,server_generic \
--proto_path proto proto/*.proto

cp -Rvf npm/* build/javascript/
cd build/javascript
npm run build
npm pack
10 changes: 10 additions & 0 deletions build-php.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

mkdir -p tmp
mkdir -p build/php
pecl install grpc
protoc --proto_path=proto \
--php_out=build/php \
--grpc_out=build/phpp \
--plugin=protoc-gen-grpc=bins/opt/grpc_php_plugin \
proto/*.proto
26 changes: 26 additions & 0 deletions build-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

mkdir -p tmp
python3 -m venv tmp/protobuild-venv
. tmp/protobuild-venv/bin/activate
pip install grpcio-tools

mkdir -p build/python/openagents_service_provider_proto
python -m grpc_tools.protoc -Iproto \
--python_out=build/python/openagents_service_provider_proto \
--pyi_out=build/python/openagents_service_provider_proto \
--grpc_python_out=build/python/openagents_service_provider_proto \
proto/*.proto

cp -Rvf python/* build/python/
cd build/python



if [ "$DEBUG" = "1" ] ;
then
deactivate
pip install -e .
else
python setup.py sdist
fi
21 changes: 21 additions & 0 deletions npm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "openagents-service-provider-proto",
"version": "1.0.0",
"description": "",
"scripts": {
"build": "tsc"
},
"author": "",
"license": "",
"dependencies": {
"@grpc/grpc-js": "^1.10.6",
"@protobuf-ts/plugin": "^2.9.4"
},
"devDependencies": {
"@types/node": "^20.12.5",
"typescript": "^5.4.4"
},
"files": [
"dist"
]
}
12 changes: 12 additions & 0 deletions npm/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"outDir": "dist",
"moduleResolution": "node",
"esModuleInterop": true,
"declaration": true
},
"include": ["src/*.ts"],
"exclude": ["node_modules"]
}
38 changes: 38 additions & 0 deletions proto/Job.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
syntax = "proto3";

import "JobParam.proto";
import "JobInput.proto";
import "JobState.proto";
import "JobResult.proto";



message Job {
string id = 1;
uint32 kind = 14;

string runOn = 2;
uint64 expiration = 3;
uint64 timestamp = 4;

repeated JobInput input = 5; // primary input
repeated JobParam param = 6; // additional parameters

string customerPublicKey = 7;
string description = 8;
string provider = 9;

repeated string relays = 10;

JobResult result = 12;
JobState state = 11;

uint64 maxExecutionTime = 13; // enforced by the provider
// map<string,JobResult> results = 12;

// map<string,JobState> states = 11;




}
9 changes: 9 additions & 0 deletions proto/JobInput.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

message JobInput {
optional string data = 1;
optional string ref = 2;
string type = 3;
string marker = 4;
optional string source = 5;
}
6 changes: 6 additions & 0 deletions proto/JobParam.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
syntax = "proto3";

message JobParam {
string key = 1;
repeated string value = 2;
}
8 changes: 8 additions & 0 deletions proto/JobResult.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

message JobResult {
string content = 1;
uint64 timestamp = 2;
string id = 3;
}

15 changes: 15 additions & 0 deletions proto/JobState.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";

import "Log.proto";
import "JobStatus.proto";




message JobState {
uint64 acceptedAt = 13;
string acceptedBy = 14;
JobStatus status = 15;
repeated Log logs = 17;
uint64 timestamp = 18;
}
12 changes: 12 additions & 0 deletions proto/JobStatus.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

syntax = "proto3";

enum JobStatus {
PENDING = 0;
PROCESSING = 1;
ERROR = 2;
SUCCESS = 3;
PARTIAL = 4;
PAYMENT_REQUIRED = 7;
UNKNOWN=99;
}
10 changes: 10 additions & 0 deletions proto/Log.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

syntax = "proto3";

message Log {
string id=1;
string log = 2;
string level = 3;
uint64 timestamp = 4;
string source = 5;
}
Loading

0 comments on commit 1cfcd79

Please sign in to comment.