Skip to content

Commit 20e76ac

Browse files
committed
fix: ci
1 parent a065fd5 commit 20e76ac

11 files changed

Lines changed: 192 additions & 130 deletions

File tree

.docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ RUN case "${TARGETARCH}" in \
3333
yarn workspace @afk/server-native build; \
3434
fi
3535

36-
FROM node:22-bookworm AS builder
36+
FROM node:22-bookworm-slim AS builder
3737

3838
WORKDIR /app
3939
COPY . .

.docker/schema.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,10 +789,11 @@
789789
},
790790
"cloudsway": {
791791
"type": "object",
792-
"description": "The config for the Cloudsway web search and reader.\n@default {\"basePath\":\"https://searchapi.cloudsway.net\",\"endpointPath\":\"\",\"accessKey\":\"\"}",
792+
"description": "The config for the Cloudsway web search and reader.\n@default {\"basePath\":\"https://searchapi.cloudsway.net\",\"readEndpoint\":\"\",\"searchEndpoint\":\"\",\"accessKey\":\"\"}",
793793
"default": {
794794
"basePath": "https://searchapi.cloudsway.net",
795-
"endpointPath": "",
795+
"readEndpoint": "",
796+
"searchEndpoint": "",
796797
"accessKey": ""
797798
}
798799
},

.dockerignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pnpm-lock.yaml
6464
target/
6565
Cargo.lock
6666

67-
# other
68-
.dockerignore
69-
Dockerfile*
70-
docker-compose*
67+
# exclude heavy directories not needed for image build
68+
blocksuite/
69+
tools/
70+
scripts/

.github/workflows/build-images.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ jobs:
158158
mv ./node_modules ./packages/backend/server
159159
rm -rf ./packages/backend/server/node_modules/@afk
160160
mv ./@afk ./packages/backend/server/node_modules
161+
# clean caches to save disk space
162+
yarn cache clean --all || true
163+
rm -rf ./packages/backend/server/node_modules/.cache || true
161164
ls -alh ./packages/backend/server/node_modules/@napi-rs
162165
163166
- name: Login to GitHub Container Registry
@@ -180,4 +183,7 @@ jobs:
180183
platforms: linux/amd64,linux/arm64,linux/arm/v7
181184
provenance: true
182185
file: .docker/Dockerfile
186+
# Use GitHub Actions cache backend to reduce local disk usage
187+
cache-from: type=gha
188+
cache-to: type=gha,mode=max
183189
tags: ghcr.io/afk-surf/open-agent:${{inputs.build-type}}-${{ inputs.git-short-hash }},ghcr.io/afk-surf/open-agent:${{inputs.build-type}}

.github/workflows/build-test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,6 @@ jobs:
425425
- check-git-status
426426
- check-yarn-binary
427427
- build-server-native
428-
- native-unit-test
429428
- server-test
430429
- server-e2e-test
431430
- rust-test

packages/backend/server/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@google-cloud/opentelemetry-cloud-trace-exporter": "^2.4.1",
4343
"@google-cloud/opentelemetry-resource-util": "^2.4.0",
4444
"@nestjs-cls/transactional": "^2.7.0",
45-
"@nestjs-cls/transactional-adapter-prisma": "^1.2.19",
45+
"@nestjs-cls/transactional-adapter-prisma": "^1.3.0",
4646
"@nestjs/apollo": "^13.0.4",
4747
"@nestjs/bullmq": "^11.0.2",
4848
"@nestjs/common": "^11.0.12",
@@ -71,8 +71,8 @@
7171
"@opentelemetry/sdk-node": "^0.57.0",
7272
"@opentelemetry/sdk-trace-node": "^1.29.0",
7373
"@opentelemetry/semantic-conventions": "^1.28.0",
74-
"@prisma/client": "^6.6.0",
75-
"@prisma/instrumentation": "^6.7.0",
74+
"@prisma/client": "^6.15.0",
75+
"@prisma/instrumentation": "^6.15.0",
7676
"@react-email/components": "^0.0.42",
7777
"@socket.io/redis-adapter": "^8.3.0",
7878
"ai": "^5.0.10",
@@ -105,17 +105,16 @@
105105
"nodemailer": "^7.0.0",
106106
"oci-common": "^2.116.1",
107107
"oci-generativeaiinference": "^2.116.1",
108-
"on-headers": "^1.0.2",
109-
"piscina": "^5.0.0-alpha.0",
110-
"prisma": "^6.6.0",
108+
"on-headers": "^1.1.0",
109+
"piscina": "^5.1.3",
110+
"prisma": "^6.15.0",
111111
"react": "19.1.0",
112112
"react-dom": "19.1.0",
113113
"reflect-metadata": "^0.2.2",
114114
"rxjs": "^7.8.1",
115115
"semver": "^7.6.3",
116116
"ses": "^1.10.0",
117117
"socket.io": "^4.8.1",
118-
"stripe": "^17.4.0",
119118
"tldts": "^7.0.0",
120119
"ts-node": "^10.9.2",
121120
"typescript": "^5.7.2",

packages/backend/server/src/plugins/copilot/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ declare global {
2727
}>;
2828
cloudsway: ConfigItem<{
2929
basePath: string;
30-
endpointPath: string;
30+
readEndpoint: string;
31+
searchEndpoint: string;
3132
accessKey: string;
3233
}>;
3334
e2b: ConfigItem<{
@@ -145,7 +146,8 @@ defineModuleConfig('copilot', {
145146
desc: 'The config for the Cloudsway web search and reader.',
146147
default: {
147148
basePath: 'https://searchapi.cloudsway.net',
148-
endpointPath: '',
149+
readEndpoint: '',
150+
searchEndpoint: '',
149151
accessKey: '',
150152
},
151153
},

packages/backend/server/src/plugins/copilot/providers/oracle.ts

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import {
88
RegionProvider,
99
SimpleAuthenticationDetailsProvider,
1010
} from 'oci-common';
11-
import { checkNotNull } from 'oci-common/lib/utils';
1211
import { GenerativeAiInferenceClient } from 'oci-generativeaiinference';
13-
import { ImageContent, TextContent } from 'oci-generativeaiinference/lib/model';
14-
import { ChatRequest } from 'oci-generativeaiinference/lib/request';
12+
import type {
13+
ImageContent,
14+
TextContent,
15+
} from 'oci-generativeaiinference/lib/model';
16+
import type { ChatRequest } from 'oci-generativeaiinference/lib/request';
1517

1618
import { metrics } from '../../../base';
1719
import type { CustomAITools } from '../tools';
@@ -83,7 +85,7 @@ export class OracleProvider extends CopilotProvider<OracleConfig> {
8385
super.setup();
8486
if (this.configured()) {
8587
const { config, endpoint, privateKey } = this.config;
86-
const provider = SessionAuthDetailProvider.init(config!, privateKey!);
88+
const provider = OracleAuthProvider.init(config!, privateKey!);
8789
const client = new GenerativeAiInferenceClient({
8890
authenticationDetailsProvider: provider,
8991
});
@@ -288,32 +290,55 @@ export class OracleProvider extends CopilotProvider<OracleConfig> {
288290
}
289291
}
290292

291-
export class SessionAuthDetailProvider
293+
export class OracleAuthProvider
292294
extends SimpleAuthenticationDetailsProvider
293295
implements AuthenticationDetailsProvider, RegionProvider
294296
{
297+
// Lightweight local replacement for oci-common's checkNotNull to avoid deep runtime imports in ESM
298+
private static checkNotNull<T>(
299+
value: T | null | undefined,
300+
message: string
301+
): T {
302+
if (value === null || value === undefined) {
303+
throw new Error(message);
304+
}
305+
return value as T;
306+
}
307+
295308
static init(
296309
config: NonNullable<OracleConfig['config']>,
297310
privateKeyContent: string,
298311
sessionToken?: string
299-
): SessionAuthDetailProvider {
312+
): OracleAuthProvider {
300313
const file = ConfigFileReader.parse(
301314
`[DEFAULT]\n${Object.entries(config)
302315
.map(([k, v]) => `${k}=${v}`)
303316
.join('\n')}`,
304317
ConfigFileReader.DEFAULT_PROFILE_NAME
305318
);
306319

307-
return new SessionAuthDetailProvider(
308-
checkNotNull(file.get('tenancy'), 'missing tenancy in config'),
320+
return new OracleAuthProvider(
321+
OracleAuthProvider.checkNotNull(
322+
file.get('tenancy'),
323+
'missing tenancy in config'
324+
),
309325
sessionToken
310326
? ''
311-
: checkNotNull(file.get('user'), 'missing user in config'),
312-
checkNotNull(file.get('fingerprint'), 'missing fingerprint in config'),
327+
: OracleAuthProvider.checkNotNull(
328+
file.get('user'),
329+
'missing user in config'
330+
),
331+
OracleAuthProvider.checkNotNull(
332+
file.get('fingerprint'),
333+
'missing fingerprint in config'
334+
),
313335
privateKeyContent,
314336
file.get('pass_phrase'),
315-
SessionAuthDetailProvider.retrieveRegionFromRegionId(
316-
checkNotNull(file.get('region'), 'missing region in config')
337+
OracleAuthProvider.retrieveRegionFromRegionId(
338+
OracleAuthProvider.checkNotNull(
339+
file.get('region'),
340+
'missing region in config'
341+
)
317342
),
318343
undefined,
319344
undefined,
@@ -328,7 +353,7 @@ export class SessionAuthDetailProvider
328353
region = Region.fromRegionId(regionId);
329354
if (!region) {
330355
// Proceed by assuming the region id in the config file belongs to OC1 realm.
331-
new Logger(SessionAuthDetailProvider.name).warn(
356+
new Logger(OracleAuthProvider.name).warn(
332357
`Falling back to using OC1 realm.`
333358
);
334359
region = Region.register(regionId, Realm.OC1);
@@ -343,8 +368,6 @@ export class SessionAuthDetailProvider
343368

344369
// @ts-expect-error
345370
public override setRegion(regionId: string): void {
346-
super.setRegion(
347-
SessionAuthDetailProvider.retrieveRegionFromRegionId(regionId)
348-
);
371+
super.setRegion(OracleAuthProvider.retrieveRegionFromRegionId(regionId));
349372
}
350373
}

packages/backend/server/src/plugins/copilot/tools/cloudsway-read.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ export const createCloudswayReadTool = (config: Config) => {
2929
}),
3030
execute: async ({ url, formats, mode }) => {
3131
try {
32-
const { basePath, endpointPath, accessKey } =
32+
const { basePath, readEndpoint, accessKey } =
3333
config.copilot.cloudsway;
3434

35-
const endpoint = new URL(`search/${endpointPath}/read`, basePath);
35+
const endpoint = new URL(`search/${readEndpoint}/read`, basePath);
3636
const body = {
3737
url,
3838
formats: (formats?.length ? formats : ['TEXT']) as Format[],

packages/backend/server/src/plugins/copilot/tools/cloudsway-search.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ export const createCloudswaySearchTool = (config: Config) => {
4747
cc,
4848
}) => {
4949
try {
50-
const { basePath, endpointPath, accessKey } =
50+
const { basePath, searchEndpoint, accessKey } =
5151
config.copilot.cloudsway;
5252

53-
const url = new URL(`search/${endpointPath}/smart`, basePath);
53+
const url = new URL(`search/${searchEndpoint}/smart`, basePath);
5454
url.searchParams.set('q', query);
5555
if (count !== undefined) url.searchParams.set('count', String(count));
5656
if (offset !== undefined)

0 commit comments

Comments
 (0)