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

fix(js-sdk): Resolve build error #88

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/js-sdk-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build JS SDK

on:
pull_request:
types:
- opened
- synchronize
- reopened
paths:
- 'packages/sdk/js/**'

jobs:
build:
uses: ./.github/workflows/js-sdk-shared.yaml
with:
should-publish: false
33 changes: 3 additions & 30 deletions .github/workflows/js-sdk-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,6 @@ permissions:

jobs:
publish:
name: Build and publish SDK to NPM
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
cache: npm
cache-dependency-path: package-lock.json

- name: Install dependencies
working-directory: ./packages/sdk/js/
run: npm ci

- name: Publish package
run: npm publish --access=public
working-directory: ./packages/sdk/js/
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
uses: ./.github/workflows/js-sdk-shared.yaml
with:
should-publish: true
46 changes: 46 additions & 0 deletions .github/workflows/js-sdk-shared.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Publish JS SDK Package

on:
workflow_call:
inputs:
should-publish:
required: false
type: boolean
default: false

jobs:
build:
name: Build and optionally publish SDK to NPM
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
cache: npm
cache-dependency-path: package-lock.json

- name: Install dependencies
working-directory: ./packages/sdk/js/
run: npm ci

- name: Build package
working-directory: ./packages/sdk/js/
run: npm run build

- name: Publish package
if: ${{ inputs.should-publish }}
run: npm publish --access=public
working-directory: ./packages/sdk/js/
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Release
if: ${{ inputs.should-publish }}
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
2 changes: 1 addition & 1 deletion packages/sdk/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ You can find more info and examples in the [docs](https://agentprotocol.ai/sdks/

```bash
git clone https://github.com/AI-Engineers-Foundation/agent-protocol
cd agent-protocol/sdk/js
cd agent-protocol/packages/sdk/js
npm install
npm run build
```
5 changes: 4 additions & 1 deletion packages/sdk/js/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ export const createArtifact = async (
relative_path: relativePath ?? null,
created_at: Date.now().toString(),
}
task.artifacts = task.artifacts != null ?? []
task.artifacts =
task.artifacts !== null && task.artifacts !== undefined
? task.artifacts
: []
task.artifacts.push(artifact)

const artifactFolderPath = getArtifactPath(task.task_id, workspace, artifact)
Expand Down