Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authorise against X-API-KEY or Auth Bearer token #103

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
more reverting prettier changes to reduce noise in PR
  • Loading branch information
nalbion committed Feb 10, 2024
commit 0dd9d72cdb81cc46bef87e2ecfed335cf2760d8e
6 changes: 3 additions & 3 deletions .github/workflows/update-docs.yaml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ name: Regenerate Endpoints docs on change
on:
push:
paths:
- "schemas/openapi.yml"
- 'schemas/openapi.yml'

permissions:
contents: write
@@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v3
- uses: actions/setup-node@v1
with:
node-version: "16.x"
node-version: '16.x'
- run: npm i
- run: npm run generateEndpoints

@@ -31,7 +31,7 @@ jobs:
git commit -am "Update endpoint docs" || echo "No changes to commit"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install swagger-cli
run: |
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# npm run ci
npm run ci
10 changes: 1 addition & 9 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -2,13 +2,5 @@
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"overrides": [
{
"files": "*.yaml",
"options": {
"singleQuote": false
}
}
]
"singleQuote": true
}
1 change: 0 additions & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people

* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
"scripts": {
"ci": "prettier . -c && eslint . --ext .ts,.tsx",
"prettier": "prettier . -w",
"prettier:fix": "prettier --write .",
"lint": "eslint . --ext .ts,.tsx --fix",
"prepare": "husky install"
},
38 changes: 19 additions & 19 deletions packages/sdk/js/src/agent.ts
Original file line number Diff line number Diff line change
@@ -17,11 +17,11 @@ import {
import {
createApi,
ApiApp,
type ApiConfig,
type RouteRegisterFn,
type RouteContext,
} from './api'
import { type Router } from 'express'
ApiConfig,
RouteRegisterFn,
RouteContext,
} from "./api";
import { type Router } from 'express';

/**
* A function that handles a step in a task.
@@ -83,7 +83,7 @@ const registerCreateAgentTask: RouteRegisterFn = (router: Router) => {
res.status(500).json({ error: err.message })
}
})()
})
});
}

/**
@@ -189,7 +189,7 @@ export const executeAgentTaskStep = async (
}

// If there are artifacts in the step, append them to the task's artifacts array (or initialize it if necessary)
if (step.artifacts != null && step.artifacts.length > 0) {
if (step.artifacts && step.artifacts.length > 0) {
task[0].artifacts = task[0].artifacts ?? []
task[0].artifacts.push(...step.artifacts)
}
@@ -250,7 +250,7 @@ const registerGetAgentTaskStep: RouteRegisterFn = (router: Router) => {
export const getArtifacts = async (
taskId: string
): Promise<Artifact[] | undefined> => {
const task = await getAgentTask(taskId)
const task = await getAgentTask(taskId);
return task.artifacts;
}
const registerGetArtifacts: RouteRegisterFn = (router: Router) => {
@@ -259,10 +259,10 @@ const registerGetArtifacts: RouteRegisterFn = (router: Router) => {
const taskId = req.params.task_id
try {
const artifacts = await getArtifacts(taskId)
const current_page = Number(req.query.current_page) || 1
const page_size = Number(req.query.page_size) || 10
const current_page = Number(req.query['current_page']) || 1
const page_size = Number(req.query['page_size']) || 10

if (artifacts == null) {
if (!artifacts) {
res.status(200).send({
artifacts: [],
pagination: {
@@ -311,7 +311,7 @@ export const getArtifactPath = (
): string => {
const rootDir = path.isAbsolute(workspace) ?
workspace :
path.join(process.cwd(), workspace)
path.join(process.cwd(), workspace);

return path.join(
rootDir,
@@ -341,7 +341,7 @@ export const createArtifact = async (
relative_path: relativePath || null,
created_at: Date.now().toString(),
}
task.artifacts = task.artifacts != null || []
task.artifacts = task.artifacts || []
task.artifacts.push(artifact)

const artifactFolderPath = getArtifactPath(
@@ -363,14 +363,14 @@ const registerCreateArtifact: RouteRegisterFn = (router: Router, context: RouteC
const relativePath = req.body.relative_path

const task = tasks.find(([{ task_id }]) => task_id == taskId)
if (task == null) {
if (!task) {
res
.status(404)
.json({ message: 'Unable to find task with the provided id' })
}

const files = req.files as Express.Multer.File[]
const file = files.find(({ fieldname }) => fieldname == 'file')
const files = req.files as Array<Express.Multer.File>
let file = files.find(({ fieldname }) => fieldname == 'file')
const artifact = await createArtifact(
context.workspace,
task[0],
@@ -398,7 +398,7 @@ export const getTaskArtifact = async (
): Promise<Artifact> => {
const task = await getAgentTask(taskId)
const artifact = task.artifacts?.find((a) => a.artifact_id === artifactId)
if (artifact == null) {
if (!artifact) {
throw new Error(
`Artifact with id ${artifactId} in task with id ${taskId} was not found`
)
@@ -430,7 +430,7 @@ export interface AgentConfig {
export const defaultAgentConfig: AgentConfig = {
port: 8000,
workspace: "./workspace",
}
};

export class Agent {
constructor(
@@ -445,7 +445,7 @@ export class Agent {
taskHandler = _taskHandler
return new Agent(_taskHandler, {
workspace: config.workspace || defaultAgentConfig.workspace,
port: config.port || defaultAgentConfig.port,
port: config.port || defaultAgentConfig.port
});
}

2 changes: 1 addition & 1 deletion packages/sdk/js/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as OpenApiValidator from "express-openapi-validator";
import yaml from "js-yaml";
import express, { Router } from "express"; // <-- Import Router
import express, { Router } from "express"; // <-- Import Router
import * as core from "express-serve-static-core";

import spec from "../agent-protocol/schemas/openapi.yml";
2 changes: 1 addition & 1 deletion packages/sdk/js/src/models.ts
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ export type StepOutput = any
export enum StepStatus {
CREATED = "created",
RUNNING = "running",
COMPLETED = "completed",
COMPLETED = "completed"
}

export interface Step {
2 changes: 1 addition & 1 deletion rfcs/2023-08-28-Pagination-RFC.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
| **Author(s)** | Merwane Hamadi (merwanehamadi@gmail.com) Craig Swift (craigswift13@gmail.com)|
| **RFC PR:** | [PR 53](https://github.com/e2b-dev/agent-protocol/pull/53) |
| **Updated** | 2023-08-28 |
| **Obsoletes** |
| **Obsoletes** | |

## Summary

3 changes: 2 additions & 1 deletion rfcs/2023-08-28-agent-created-RFC-.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
| **Author(s)** | Merwane Hamadi (merwanehamadi@gmail.com) Craig Swift (craigswift13@gmail.com) |
| **RFC PR:** | |
| **Created** | 2023-08-28 |
| **Obsoletes** | |
| **Obsoletes** | |

## Summary

@@ -14,6 +14,7 @@ Add agent_created to the artifact response body.
## Motivation
If we don't know whether an artifact is generated by the agent or not, it's hard to know what the agent did or did not do.


## Agent Builders Benefit

- They can tell their users what their agent did.
4 changes: 2 additions & 2 deletions rfcs/2023-08-28-list-entities-RFC.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
| **Author(s)** | Merwane Hamadi (merwanehamadi@gmail.com) Craig Swift (craigswift13@gmail.com)|
| **RFC PR:** | |
| **Updated** | 2023-08-28 |
| **Obsoletes** | |
| **Obsoletes** | |

## Summary

@@ -18,6 +18,7 @@ It's like a table.

Currently to build that you need to get the list of task ids. And if you want to display 20 tasks. You will make 20 GET calls to show them.


## Agent Builders Benefit

- They can allow their users to list things: Currently they get a list of ids, that's not useful.
@@ -27,7 +28,6 @@ Currently to build that you need to get the list of task ids. And if you want to
Just do what everyone does: return an array of objects that represent the resource

### Alternatives Considered

- Just make 26 calls when you need to display a table of 25 tasks (1 call to get an id and then 25 calls to get the information of each task)

### Compatibility
1 change: 0 additions & 1 deletion rfcs/2023-09-15-endpoint-schema.md
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ Change the current `/agent/` endpoint schema to `/ap/v1/agent/`. This brings cla

### Compatibility
These changes are not backwards compatible for the following reasons:

- The change in the endpoint schema will break existing client implementations tied to the old URL structure.

Clients will need to update their integrations to accomodate these changes, necessitating a major version bump.
Loading
Oops, something went wrong.