Skip to content
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
46 changes: 46 additions & 0 deletions .github/workflows/auto-typescript-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Zero-code agent (@traceai/auto) tests

# The registry test reads every typescript/packages/traceai_* manifest, and the
# integration tests load the built instrumentors, so the whole workspace is built.
on:
pull_request:
branches: [dev, main]
paths:
- 'typescript/packages/traceai_auto/**'
- 'typescript/packages/fi-core/**'
- 'typescript/packages/fi-semantic-conventions/**'
- 'typescript/packages/traceai_*/package.json'
- 'spec/auto-instrumentation/**'
- 'typescript/pnpm-lock.yaml'
- 'typescript/package.json'
- 'typescript/tsconfig*'
- '.github/workflows/auto-typescript-tests.yml'
push:
branches: [dev]
workflow_dispatch:

permissions:
contents: read

jobs:
auto:
name: '@traceai/auto suite'
runs-on: ubuntu-24.04
timeout-minutes: 45
defaults:
run:
working-directory: typescript
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '22'
- run: corepack enable
- name: Install the workspace
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Build every package in dependency order
run: pnpm run build:ordered
- name: Run the @traceai/auto suite
run: pnpm --filter @traceai/auto test
2 changes: 2 additions & 0 deletions typescript/packages/fi-core/scripts/postbuild.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const fs = require('node:fs');
// tsc does not emit privacy.json (it is not in any tsconfig include), so these byte-exact copies are
// the only ones: a consumer's `tsc --build` reference to fi-core cannot reserialize them.
for (const dir of ['dist/src', 'dist/esm', 'dist/esnext']) {
fs.copyFileSync('src/privacy.json', `${dir}/privacy.json`);
}
Expand Down
3 changes: 1 addition & 2 deletions typescript/packages/fi-core/tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"resolveJsonModule": true
},
"include": [
"src/**/*.ts",
"src/**/*.json"
"src/**/*.ts"
],
"references": [],
"exclude": [
Expand Down
3 changes: 1 addition & 2 deletions typescript/packages/fi-core/tsconfig.esnext.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"resolveJsonModule": true
},
"include": [
"src/**/*.ts",
"src/**/*.json"
"src/**/*.ts"
],
"references": [],
"exclude": [
Expand Down
2 changes: 1 addition & 1 deletion typescript/packages/fi-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"baseUrl": "./src",
"resolveJsonModule": true
},
"include": ["src/**/*.ts", "src/**/*.json", "test/**/*.ts"],
"include": ["src/**/*.ts", "test/**/*.ts"],
"exclude": ["src/**/*.test.ts", "src/**/__tests__/**", "test/**/*.ts"],
"references": []
}
8 changes: 7 additions & 1 deletion typescript/packages/traceai_auto/test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ test.each(["api_key", "secret_key"])("S7 ignored %s from every config/profile so
});
test("registry covers every instrumentation package and records exported class and targets", () => {
const packages = resolve(__dirname, "../..");
const paths = readdirSync(packages).filter(p => p.startsWith("traceai_") && p !== "traceai_auto");
// Coding-agent tracers (@traceai/agent-core and the hook plugins built on it) are set up
// with `npx @traceai/agents`, not loaded by the zero-code agent, so they are not listed here.
const codingAgent = (path: string) => {
const manifest = JSON.parse(readFileSync(join(packages, path, "package.json"), "utf8"));
return manifest.name === "@traceai/agent-core" || "@traceai/agent-core" in (manifest.dependencies ?? {});
};
const paths = readdirSync(packages).filter(p => p.startsWith("traceai_") && p !== "traceai_auto" && !codingAgent(p));
expect(integrations).toHaveLength(paths.length);
for (const path of paths) {
const manifest = JSON.parse(readFileSync(join(packages, path, "package.json"), "utf8"));
Expand Down
6 changes: 3 additions & 3 deletions typescript/packages/traceai_auto/test/safety.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ test("consumer cancellation is OK with partial output and incomplete marker", as
expect(spans[0].attributes["error.type"]).toBeUndefined();
});
test.each([["gzip", gzipSync], ["deflate", deflateSync]] as const)("encoded %s responses decode before parsing but retain application bytes", async (encoding, compress) => {
const bytes = compress(partial); globalThis.fetch = jest.fn(async () => new Response(bytes, { headers: { "content-type": "text/event-stream", "content-encoding": encoding } })); const h = hook();
const bytes = compress(partial); globalThis.fetch = jest.fn(async () => new Response(new Uint8Array(bytes), { headers: { "content-type": "text/event-stream", "content-encoding": encoding } })); const h = hook();
expect(Buffer.from(await (await fetch(url, init)).arrayBuffer())).toEqual(bytes); await Promise.all([...h.pending]);
expect(spans[0].attributes["output.value"]).toBe("partial"); expect(spans[0].attributes["traceai.wire.undecoded_encoding"]).toBeUndefined();
});
Expand Down Expand Up @@ -93,7 +93,7 @@ test("native fetch response metadata prevents re-decoding plain-text transcripti
});
test("decompressed output is bounded independently of compressed size", async () => {
const bytes = gzipSync('data: {"choices":[{"delta":{"content":"' + "x".repeat(10000) + '"}}]}\n\n');
globalThis.fetch = jest.fn(async () => new Response(bytes, { headers: { "content-type": "text/event-stream", "content-encoding": "gzip" } })); const h = hook(512);
globalThis.fetch = jest.fn(async () => new Response(new Uint8Array(bytes), { headers: { "content-type": "text/event-stream", "content-encoding": "gzip" } })); const h = hook(512);
await (await fetch(url, init)).arrayBuffer(); await Promise.all([...h.pending]);
expect(spans[0].attributes["traceai.wire.truncated"]).toBe(true); expect(spans[0].attributes["output.value"]).toBeUndefined();
});
Expand Down Expand Up @@ -164,7 +164,7 @@ test("cloning a mutable custom Response preserves metadata and independent heade
});
test.each([["gzip", gzipSync], ["deflate", deflateSync], ["br", brotliCompressSync]] as const)("%s ElevenLabs JSON audio decodes before base64 counting", async (encoding, compress) => {
const text = JSON.stringify({ audio_base64: Buffer.alloc(128).toString("base64") }), bytes = compress(text);
globalThis.fetch = jest.fn(async () => new Response(bytes, { headers: { "content-type": "application/json", "content-encoding": encoding } })); const h = hook();
globalThis.fetch = jest.fn(async () => new Response(new Uint8Array(bytes), { headers: { "content-type": "application/json", "content-encoding": encoding } })); const h = hook();
const target = "https://api.elevenlabs.io/v1/text-to-speech/voice/with-timestamps";
expect(Buffer.from(await (await fetch(target, { ...init, body: '{"text":"hello","model_id":"tts"}' })).arrayBuffer())).toEqual(bytes);
await Promise.all([...h.pending]); expect(spans).toHaveLength(1);
Expand Down
Loading