-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(integrations): add shared harness contract module to core #2746
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
3 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 |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| .browserbase/ | ||
| .trajectories/ | ||
| .rubric-cache/ | ||
| packages/ |
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 was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| type LogLine = { | ||
| id?: string; | ||
| category?: string; | ||
| message: string; | ||
| level?: 0 | 1 | 2; | ||
| timestamp?: string; | ||
| auxiliary?: Record< | ||
| string, | ||
| { | ||
| value: string; | ||
| type: "object" | "string" | "html" | "integer" | "float" | "boolean"; | ||
| } | ||
| >; | ||
| }; | ||
|
|
||
| /** Logger surface required by agent harness adapters. */ | ||
| export type HarnessLogger = { | ||
| log(line: LogLine): void; | ||
| warn(line: LogLine): void; | ||
| error(line: LogLine): void; | ||
| }; | ||
|
|
||
| /** Error raised when a harness adapter cannot complete its work. */ | ||
| export class HarnessAdapterError extends Error { | ||
| constructor(message: string, options?: { cause?: unknown }) { | ||
| super(message, options); | ||
| this.name = "HarnessAdapterError"; | ||
| } | ||
| } | ||
2 changes: 1 addition & 1 deletion
2
packages/integrations/claude-code/src/env.ts → ...ages/integrations/core/src/harness/env.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from "./contract.js"; | ||
| export * from "./env.js"; | ||
| export * from "./redact.js"; | ||
|
miguelg719 marked this conversation as resolved.
|
||
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,19 @@ | ||
| export function sanitizeErrorMessage(message: string): string { | ||
| let sanitized = message; | ||
| // stdio-server and codexCodeBridge: credential-bearing URL query parameters. | ||
| sanitized = sanitized.replace( | ||
| /([?&](?:signingKey|apiKey|api_key|token|key)=)[^&\s"']+/gi, | ||
| "$1[redacted]", | ||
| ); | ||
| // stdio-server and codexCodeBridge: OpenAI-style secret keys. | ||
| sanitized = sanitized.replace(/\b(sk-[A-Za-z0-9_-]{6})[A-Za-z0-9_-]+/g, "$1[redacted]"); | ||
| // stdio-server: Browserbase live and test keys. | ||
| sanitized = sanitized.replace( | ||
| /\b(bb_(?:live|test)_[A-Za-z0-9]{4})[A-Za-z0-9_-]+/g, | ||
| "$1[redacted]", | ||
| ); | ||
| // stdio-server: Google API keys. | ||
| sanitized = sanitized.replace(/\bAIza[0-9A-Za-z_-]{30,}/g, "AIza[redacted]"); | ||
| // stdio-server: bearer authorization values. | ||
| return sanitized.replace(/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi, "$1[redacted]"); | ||
| } |
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,46 @@ | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
| import { buildAllowlistedEnv, sanitizeErrorMessage } from "../src/harness/index.js"; | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
|
||
|
|
||
| describe("harness contract", () => { | ||
| afterEach(() => { | ||
| vi.unstubAllEnvs(); | ||
| }); | ||
|
|
||
| it("redacts credential-bearing URL query parameters", () => { | ||
| expect(sanitizeErrorMessage("wss://example.test?signingKey=top-secret&foo=bar")).toBe( | ||
| "wss://example.test?signingKey=[redacted]&foo=bar", | ||
| ); | ||
| }); | ||
|
|
||
| it("redacts OpenAI-style secret keys", () => { | ||
| expect(sanitizeErrorMessage("key sk-abcdef1234567890")).toBe("key sk-abcdef[redacted]"); | ||
| }); | ||
|
|
||
| it("redacts Browserbase keys", () => { | ||
| expect(sanitizeErrorMessage("key bb_live_abcd1234567890")).toBe("key bb_live_abcd[redacted]"); | ||
| }); | ||
|
|
||
| it("redacts Google API keys", () => { | ||
| expect(sanitizeErrorMessage(`key AIza${"a".repeat(32)}`)).toBe("key AIza[redacted]"); | ||
| }); | ||
|
|
||
| it("redacts bearer authorization values", () => { | ||
| expect(sanitizeErrorMessage("Authorization: Bearer abcdefgh123456")).toBe( | ||
| "Authorization: Bearer [redacted]", | ||
| ); | ||
| }); | ||
|
|
||
| it("allows Stagehand and Browserbase env vars while excluding other and empty values", () => { | ||
| vi.stubEnv("STAGEHAND_MODEL", "model"); | ||
| vi.stubEnv("BROWSERBASE_API_KEY", "browserbase-key"); | ||
| vi.stubEnv("STAGEHAND_EMPTY", ""); | ||
| vi.stubEnv("NOT_ALLOWLISTED_SECRET", "secret"); | ||
|
|
||
| const env = buildAllowlistedEnv(); | ||
|
|
||
| expect(env.STAGEHAND_MODEL).toBe("model"); | ||
| expect(env.BROWSERBASE_API_KEY).toBe("browserbase-key"); | ||
| expect(env).not.toHaveProperty("STAGEHAND_EMPTY"); | ||
| expect(env).not.toHaveProperty("NOT_ALLOWLISTED_SECRET"); | ||
| }); | ||
| }); | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.