-
Notifications
You must be signed in to change notification settings - Fork 3.9k
chore(pi): upgrade agent to 1.0.0 #8585
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import { execFile } from 'node:child_process' | ||
| import { mkdir, mkdtemp, readdir, readFile, rm, writeFile } from 'node:fs/promises' | ||
| import { tmpdir } from 'node:os' | ||
| import { join } from 'node:path' | ||
| import { promisify } from 'node:util' | ||
| import { describe, expect, it } from 'vitest' | ||
| import { PI_EVENT_FILTER_SOURCE } from '@/executor/handlers/pi/cloud/event-filter-source' | ||
| import { buildPiScript } from '@/executor/handlers/pi/cloud/shared' | ||
| import { PI_PACKAGE_VERSION } from '@/scripts/pi-sandbox-packages' | ||
|
|
||
| const exec = promisify(execFile) | ||
|
|
||
| async function invokeSandbox(version: string) { | ||
| const root = await mkdtemp(join(tmpdir(), 'sim-pi-cli-')) | ||
| const workspace = join(root, 'workspace') | ||
| const repo = join(workspace, 'repo') | ||
| const bin = join(root, 'bin') | ||
| await mkdir(repo, { recursive: true }) | ||
| await mkdir(bin) | ||
| await writeFile(join(workspace, 'pi-prompt.txt'), 'fixture prompt') | ||
| await writeFile(join(workspace, 'sim-pi-event-filter.mjs'), PI_EVENT_FILTER_SOURCE) | ||
| await writeFile( | ||
| join(bin, 'pi'), | ||
| `#!/bin/bash | ||
| if [ "$1" = "--version" ]; then | ||
| printf "%s\\n" "${version}" | ||
| exit 0 | ||
| fi | ||
| printf "%s" "$PI_CODING_AGENT_DIR" > "${root}/invoked" | ||
| printf "%s\\n" '{"type":"message_update","assistantMessageEvent":{"type":"text_delta","delta":"ok"}}' | ||
| exit 0 | ||
| `, | ||
| { mode: 0o700 } | ||
| ) | ||
| const script = buildPiScript().replaceAll('/workspace', workspace) | ||
| try { | ||
| const result = await exec('/bin/bash', ['-c', script], { | ||
| env: { | ||
| ...process.env, | ||
| PATH: `${bin}:${process.env.PATH}`, | ||
| PI_PROVIDER: 'fixture', | ||
| PI_MODEL: 'fixture', | ||
| PI_THINKING: 'off', | ||
| }, | ||
| }).then( | ||
| ({ stdout, stderr }) => ({ code: 0, stdout, stderr }), | ||
| (error: { code: number; stdout: string; stderr: string }) => error | ||
| ) | ||
| const invoked = await readFile(join(root, 'invoked'), 'utf8').catch(() => null) | ||
| const settings = invoked | ||
| ? await readFile(join(invoked, 'settings.json'), 'utf8').catch(() => null) | ||
| : null | ||
| const storedFiles = invoked ? await readdir(invoked).catch(() => []) : [] | ||
| return { ...result, invoked, settings, storedFiles, repo } | ||
| } finally { | ||
| await rm(root, { recursive: true, force: true }) | ||
| } | ||
| } | ||
|
|
||
| describe('sandbox Pi runtime boundary', () => { | ||
| it.each(['0.80.10', 'unexpected-version'])( | ||
| 'rejects %s before starting the agent', | ||
| async (version) => { | ||
| const result = await invokeSandbox(version) | ||
| expect(result.code).not.toBe(0) | ||
| expect(result.invoked).toBeNull() | ||
| expect(result.stderr).toMatch(/rebuild|update/i) | ||
| expect(result.stderr).toContain(PI_PACKAGE_VERSION) | ||
| } | ||
| ) | ||
|
|
||
| it('uses private settings outside the repository with warming off and no saved credentials', async () => { | ||
| const result = await invokeSandbox(PI_PACKAGE_VERSION) | ||
| expect(result.code).toBe(0) | ||
| expect(result.invoked).toBeTruthy() | ||
| expect(result.invoked?.startsWith(result.repo)).toBe(false) | ||
| expect(JSON.parse(result.settings ?? '{}')).toEqual({ cacheWarming: 'off' }) | ||
| expect(result.storedFiles).toEqual(['settings.json']) | ||
| expect(JSON.parse(result.stdout.trim())).toEqual({ | ||
| type: 'message_update', | ||
| assistantMessageEvent: { type: 'text_delta', delta: 'ok' }, | ||
| }) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.