diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc9c4df..2c0dedb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,33 @@ on: - 'stl-preview-base/**' jobs: + build: + timeout-minutes: 10 + name: build + permissions: + contents: read + id-token: write + runs-on: ${{ github.repository == 'stainless-sdks/kernel-go' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: |- + github.repository == 'stainless-sdks/kernel-go' && + (github.event_name == 'push' || github.event.pull_request.head.repo.fork) + steps: + - uses: actions/checkout@v6 + + - name: Get GitHub OIDC Token + if: github.repository == 'stainless-sdks/kernel-go' + id: github-oidc + uses: actions/github-script@v8 + with: + script: core.setOutput('github_token', await core.getIDToken()); + + - name: Upload tarball + if: github.repository == 'stainless-sdks/kernel-go' + env: + URL: https://pkg.stainless.com/s + AUTH: ${{ steps.github-oidc.outputs.github_token }} + SHA: ${{ github.sha }} + run: ./scripts/utils/upload-artifact.sh lint: timeout-minutes: 10 name: lint diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 52afe05..dc28bb8 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.42.0" + ".": "0.42.1" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index d4eead9..e1ce185 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 101 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-a935c8aae21f8ddb83ea5e289034df12cbde88d432fa2b287629814bb3f58bb6.yml -openapi_spec_hash: df3189b9728372f01662a19c060bcbc5 -config_hash: 81f143f4bee47ae7b0b8357551babadf +configured_endpoints: 103 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ef24d4bf172555bcbe8e3b432c644a25a1c6afd99c958a2eda8c3b1ea9568113.yml +openapi_spec_hash: b603c5a983e837928fa7d1100ed64fc9 +config_hash: cff4d43372b6fa66b64e2d4150f6aa76 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8af6c4b..f0af8e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## 0.42.1 (2026-03-05) + +Full Changelog: [v0.42.0...v0.42.1](https://github.com/kernel/kernel-go-sdk/compare/v0.42.0...v0.42.1) + +### Features + +* [kernel-1028] add api clipboard support ([12e68a1](https://github.com/kernel/kernel-go-sdk/commit/12e68a109a129985f55d0660b858f9840c6c8c0d)) +* add force flag to viewport resize to bypass live view/recording check ([d387238](https://github.com/kernel/kernel-go-sdk/commit/d387238e5da1f24f8b54a4be84d484da90fe1226)) +* expose smooth mouse movement via public API ([0e0f2ac](https://github.com/kernel/kernel-go-sdk/commit/0e0f2ac548b6155a2e7af9825e16b6a5662ec8cf)) + + +### Bug Fixes + +* use indices:dots arrayFmt in MarshalRoot for correct multipart array encoding ([11a7720](https://github.com/kernel/kernel-go-sdk/commit/11a7720da7982b30d072d88f86d1c77db1d4902f)) + + +### Chores + +* **internal:** codegen related update ([3c706a4](https://github.com/kernel/kernel-go-sdk/commit/3c706a4e55213c5da4fdf256c77d716729c7f658)) + ## 0.42.0 (2026-03-02) Full Changelog: [v0.41.0...v0.42.0](https://github.com/kernel/kernel-go-sdk/compare/v0.41.0...v0.42.0) diff --git a/README.md b/README.md index 60ec6cb..cddd972 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Or to pin the version: ```sh -go get -u 'github.com/kernel/kernel-go-sdk@v0.42.0' +go get -u 'github.com/kernel/kernel-go-sdk@v0.42.1' ``` diff --git a/api.md b/api.md index 3838273..7b22092 100644 --- a/api.md +++ b/api.md @@ -175,6 +175,7 @@ Methods: Response Types: - kernel.BrowserComputerGetMousePositionResponse +- kernel.BrowserComputerReadClipboardResponse - kernel.BrowserComputerSetCursorVisibilityResponse Methods: @@ -186,9 +187,11 @@ Methods: - client.Browsers.Computer.GetMousePosition(ctx context.Context, id string) (\*kernel.BrowserComputerGetMousePositionResponse, error) - client.Browsers.Computer.MoveMouse(ctx context.Context, id string, body kernel.BrowserComputerMoveMouseParams) error - client.Browsers.Computer.PressKey(ctx context.Context, id string, body kernel.BrowserComputerPressKeyParams) error +- client.Browsers.Computer.ReadClipboard(ctx context.Context, id string) (\*kernel.BrowserComputerReadClipboardResponse, error) - client.Browsers.Computer.Scroll(ctx context.Context, id string, body kernel.BrowserComputerScrollParams) error - client.Browsers.Computer.SetCursorVisibility(ctx context.Context, id string, body kernel.BrowserComputerSetCursorVisibilityParams) (\*kernel.BrowserComputerSetCursorVisibilityResponse, error) - client.Browsers.Computer.TypeText(ctx context.Context, id string, body kernel.BrowserComputerTypeTextParams) error +- client.Browsers.Computer.WriteClipboard(ctx context.Context, id string, body kernel.BrowserComputerWriteClipboardParams) error ## Playwright diff --git a/app.go b/app.go index a204d12..d3f4230 100644 --- a/app.go +++ b/app.go @@ -19,6 +19,8 @@ import ( "github.com/kernel/kernel-go-sdk/shared/constant" ) +// List applications and versions. +// // AppService contains methods and other services that help with interacting with // the kernel API. // diff --git a/auth.go b/auth.go index 0469989..6475100 100644 --- a/auth.go +++ b/auth.go @@ -13,7 +13,8 @@ import ( // automatically. You should not instantiate this service directly, and instead use // the [NewAuthService] method instead. type AuthService struct { - Options []option.RequestOption + Options []option.RequestOption + // Create and manage auth connections for automated credential capture and login. Connections AuthConnectionService } diff --git a/authconnection.go b/authconnection.go index 041c7e1..f6e1d13 100644 --- a/authconnection.go +++ b/authconnection.go @@ -25,6 +25,8 @@ import ( "github.com/kernel/kernel-go-sdk/shared/constant" ) +// Create and manage auth connections for automated credential capture and login. +// // AuthConnectionService contains methods and other services that help with // interacting with the kernel API. // diff --git a/browser.go b/browser.go index 34ec4e8..dbfeeb8 100644 --- a/browser.go +++ b/browser.go @@ -26,6 +26,8 @@ import ( "github.com/kernel/kernel-go-sdk/shared" ) +// Create and manage browser sessions. +// // BrowserService contains methods and other services that help with interacting // with the kernel API. // @@ -33,12 +35,17 @@ import ( // automatically. You should not instantiate this service directly, and instead use // the [NewBrowserService] method instead. type BrowserService struct { - Options []option.RequestOption - Replays BrowserReplayService - Fs BrowserFService - Process BrowserProcessService - Logs BrowserLogService - Computer BrowserComputerService + Options []option.RequestOption + // Record and manage browser session video replays. + Replays BrowserReplayService + // Read, write, and manage files on the browser instance. + Fs BrowserFService + // Execute and manage processes on the browser instance. + Process BrowserProcessService + // Stream logs from the browser instance. + Logs BrowserLogService + Computer BrowserComputerService + // Execute Playwright code against the browser instance. Playwright BrowserPlaywrightService } @@ -632,7 +639,7 @@ type BrowserUpdateParams struct { // already have a profile loaded. Profile shared.BrowserProfileParam `json:"profile,omitzero"` // Viewport configuration to apply to the browser session. - Viewport shared.BrowserViewportParam `json:"viewport,omitzero"` + Viewport BrowserUpdateParamsViewport `json:"viewport,omitzero"` paramObj } @@ -644,6 +651,24 @@ func (r *BrowserUpdateParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } +// Viewport configuration to apply to the browser session. +type BrowserUpdateParamsViewport struct { + // If true, allow the viewport change even when a live view or recording/replay is + // active. Active recordings will be gracefully stopped and restarted at the new + // resolution as separate segments. If false (default), the resize is refused when + // a live view or recording is active. + Force param.Opt[bool] `json:"force,omitzero"` + shared.BrowserViewportParam +} + +func (r BrowserUpdateParamsViewport) MarshalJSON() (data []byte, err error) { + type shadow struct { + *BrowserUpdateParamsViewport + MarshalJSON bool `json:"-"` // Prevent inheriting [json.Marshaler] from the embedded field + } + return param.MarshalObject(r, shadow{&r, false}) +} + type BrowserListParams struct { // Deprecated: Use status=all instead. When true, includes soft-deleted browser // sessions in the results alongside active sessions. diff --git a/browser_test.go b/browser_test.go index 1b78a49..73876a3 100644 --- a/browser_test.go +++ b/browser_test.go @@ -116,10 +116,13 @@ func TestBrowserUpdateWithOptionalParams(t *testing.T) { SaveChanges: kernel.Bool(true), }, ProxyID: kernel.String("proxy_id"), - Viewport: shared.BrowserViewportParam{ - Height: 800, - Width: 1280, - RefreshRate: kernel.Int(60), + Viewport: kernel.BrowserUpdateParamsViewport{ + BrowserViewportParam: shared.BrowserViewportParam{ + Height: 800, + Width: 1280, + RefreshRate: kernel.Int(60), + }, + Force: kernel.Bool(true), }, }, ) diff --git a/browsercomputer.go b/browsercomputer.go index 4708f06..c2bf914 100644 --- a/browsercomputer.go +++ b/browsercomputer.go @@ -127,6 +127,18 @@ func (r *BrowserComputerService) PressKey(ctx context.Context, id string, body B return } +// Read text from the clipboard on the browser instance +func (r *BrowserComputerService) ReadClipboard(ctx context.Context, id string, opts ...option.RequestOption) (res *BrowserComputerReadClipboardResponse, err error) { + opts = slices.Concat(r.Options, opts) + if id == "" { + err = errors.New("missing required id parameter") + return + } + path := fmt.Sprintf("browsers/%s/computer/clipboard/read", id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...) + return +} + // Scroll the mouse wheel at a position on the host computer func (r *BrowserComputerService) Scroll(ctx context.Context, id string, body BrowserComputerScrollParams, opts ...option.RequestOption) (err error) { opts = slices.Concat(r.Options, opts) @@ -165,6 +177,19 @@ func (r *BrowserComputerService) TypeText(ctx context.Context, id string, body B return } +// Write text to the clipboard on the browser instance +func (r *BrowserComputerService) WriteClipboard(ctx context.Context, id string, body BrowserComputerWriteClipboardParams, opts ...option.RequestOption) (err error) { + opts = slices.Concat(r.Options, opts) + opts = append([]option.RequestOption{option.WithHeader("Accept", "*/*")}, opts...) + if id == "" { + err = errors.New("missing required id parameter") + return + } + path := fmt.Sprintf("browsers/%s/computer/clipboard/write", id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, nil, opts...) + return +} + type BrowserComputerGetMousePositionResponse struct { // X coordinate of the cursor X int64 `json:"x" api:"required"` @@ -185,6 +210,23 @@ func (r *BrowserComputerGetMousePositionResponse) UnmarshalJSON(data []byte) err return apijson.UnmarshalRoot(data, r) } +type BrowserComputerReadClipboardResponse struct { + // Current clipboard text content + Text string `json:"text" api:"required"` + // JSON contains metadata for fields, check presence with [respjson.Field.Valid]. + JSON struct { + Text respjson.Field + ExtraFields map[string]respjson.Field + raw string + } `json:"-"` +} + +// Returns the unmodified JSON received from the API +func (r BrowserComputerReadClipboardResponse) RawJSON() string { return r.JSON.raw } +func (r *BrowserComputerReadClipboardResponse) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} + // Generic OK response. type BrowserComputerSetCursorVisibilityResponse struct { // Indicates success. @@ -333,6 +375,11 @@ type BrowserComputerBatchParamsActionMoveMouse struct { X int64 `json:"x" api:"required"` // Y coordinate to move the cursor to Y int64 `json:"y" api:"required"` + // Target total duration in milliseconds for the mouse movement when smooth=true. + // Omit for automatic timing based on distance. + DurationMs param.Opt[int64] `json:"duration_ms,omitzero"` + // Use human-like Bezier curve path instead of instant mouse movement. + Smooth param.Opt[bool] `json:"smooth,omitzero"` // Modifier keys to hold during the move HoldKeys []string `json:"hold_keys,omitzero"` paramObj @@ -565,6 +612,11 @@ type BrowserComputerMoveMouseParams struct { X int64 `json:"x" api:"required"` // Y coordinate to move the cursor to Y int64 `json:"y" api:"required"` + // Target total duration in milliseconds for the mouse movement when smooth=true. + // Omit for automatic timing based on distance. + DurationMs param.Opt[int64] `json:"duration_ms,omitzero"` + // Use human-like Bezier curve path instead of instant mouse movement. + Smooth param.Opt[bool] `json:"smooth,omitzero"` // Modifier keys to hold during the move HoldKeys []string `json:"hold_keys,omitzero"` paramObj @@ -651,3 +703,17 @@ func (r BrowserComputerTypeTextParams) MarshalJSON() (data []byte, err error) { func (r *BrowserComputerTypeTextParams) UnmarshalJSON(data []byte) error { return apijson.UnmarshalRoot(data, r) } + +type BrowserComputerWriteClipboardParams struct { + // Text to write to the system clipboard + Text string `json:"text" api:"required"` + paramObj +} + +func (r BrowserComputerWriteClipboardParams) MarshalJSON() (data []byte, err error) { + type shadow BrowserComputerWriteClipboardParams + return param.MarshalObject(r, (*shadow)(&r)) +} +func (r *BrowserComputerWriteClipboardParams) UnmarshalJSON(data []byte) error { + return apijson.UnmarshalRoot(data, r) +} diff --git a/browsercomputer_test.go b/browsercomputer_test.go index a7d6966..fa2199a 100644 --- a/browsercomputer_test.go +++ b/browsercomputer_test.go @@ -53,9 +53,11 @@ func TestBrowserComputerBatch(t *testing.T) { StepsPerSegment: kernel.Int(1), }, MoveMouse: kernel.BrowserComputerBatchParamsActionMoveMouse{ - X: 0, - Y: 0, - HoldKeys: []string{"string"}, + X: 0, + Y: 0, + DurationMs: kernel.Int(50), + HoldKeys: []string{"string"}, + Smooth: kernel.Bool(true), }, PressKey: kernel.BrowserComputerBatchParamsActionPressKey{ Keys: []string{"string"}, @@ -244,9 +246,11 @@ func TestBrowserComputerMoveMouseWithOptionalParams(t *testing.T) { context.TODO(), "id", kernel.BrowserComputerMoveMouseParams{ - X: 0, - Y: 0, - HoldKeys: []string{"string"}, + X: 0, + Y: 0, + DurationMs: kernel.Int(50), + HoldKeys: []string{"string"}, + Smooth: kernel.Bool(true), }, ) if err != nil { @@ -289,6 +293,29 @@ func TestBrowserComputerPressKeyWithOptionalParams(t *testing.T) { } } +func TestBrowserComputerReadClipboard(t *testing.T) { + t.Skip("Mock server tests are disabled") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := kernel.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("My API Key"), + ) + _, err := client.Browsers.Computer.ReadClipboard(context.TODO(), "id") + if err != nil { + var apierr *kernel.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + func TestBrowserComputerScrollWithOptionalParams(t *testing.T) { t.Skip("Mock server tests are disabled") baseURL := "http://localhost:4010" @@ -380,3 +407,32 @@ func TestBrowserComputerTypeTextWithOptionalParams(t *testing.T) { t.Fatalf("err should be nil: %s", err.Error()) } } + +func TestBrowserComputerWriteClipboard(t *testing.T) { + t.Skip("Mock server tests are disabled") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := kernel.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("My API Key"), + ) + err := client.Browsers.Computer.WriteClipboard( + context.TODO(), + "id", + kernel.BrowserComputerWriteClipboardParams{ + Text: "text", + }, + ) + if err != nil { + var apierr *kernel.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} diff --git a/browserf.go b/browserf.go index 6005bc0..2365b08 100644 --- a/browserf.go +++ b/browserf.go @@ -23,6 +23,8 @@ import ( "github.com/kernel/kernel-go-sdk/packages/respjson" ) +// Read, write, and manage files on the browser instance. +// // BrowserFService contains methods and other services that help with interacting // with the kernel API. // @@ -31,7 +33,8 @@ import ( // the [NewBrowserFService] method instead. type BrowserFService struct { Options []option.RequestOption - Watch BrowserFWatchService + // Read, write, and manage files on the browser instance. + Watch BrowserFWatchService } // NewBrowserFService generates a new service that applies the given options to diff --git a/browserfwatch.go b/browserfwatch.go index 4d11c4e..1c000fa 100644 --- a/browserfwatch.go +++ b/browserfwatch.go @@ -17,6 +17,8 @@ import ( "github.com/kernel/kernel-go-sdk/packages/ssestream" ) +// Read, write, and manage files on the browser instance. +// // BrowserFWatchService contains methods and other services that help with // interacting with the kernel API. // diff --git a/browserlog.go b/browserlog.go index 21fd09f..ca06feb 100644 --- a/browserlog.go +++ b/browserlog.go @@ -18,6 +18,8 @@ import ( "github.com/kernel/kernel-go-sdk/shared" ) +// Stream logs from the browser instance. +// // BrowserLogService contains methods and other services that help with interacting // with the kernel API. // diff --git a/browserplaywright.go b/browserplaywright.go index bf3d10c..63abfb2 100644 --- a/browserplaywright.go +++ b/browserplaywright.go @@ -16,6 +16,8 @@ import ( "github.com/kernel/kernel-go-sdk/packages/respjson" ) +// Execute Playwright code against the browser instance. +// // BrowserPlaywrightService contains methods and other services that help with // interacting with the kernel API. // diff --git a/browserpool.go b/browserpool.go index 1359ba4..83a6088 100644 --- a/browserpool.go +++ b/browserpool.go @@ -18,6 +18,8 @@ import ( "github.com/kernel/kernel-go-sdk/shared" ) +// Create and manage browser pools for acquiring and releasing browsers. +// // BrowserPoolService contains methods and other services that help with // interacting with the kernel API. // diff --git a/browserprocess.go b/browserprocess.go index 68d3d72..2cda1b9 100644 --- a/browserprocess.go +++ b/browserprocess.go @@ -18,6 +18,8 @@ import ( "github.com/kernel/kernel-go-sdk/packages/ssestream" ) +// Execute and manage processes on the browser instance. +// // BrowserProcessService contains methods and other services that help with // interacting with the kernel API. // diff --git a/browserreplay.go b/browserreplay.go index 3b928af..c1f7eeb 100644 --- a/browserreplay.go +++ b/browserreplay.go @@ -17,6 +17,8 @@ import ( "github.com/kernel/kernel-go-sdk/packages/respjson" ) +// Record and manage browser session video replays. +// // BrowserReplayService contains methods and other services that help with // interacting with the kernel API. // diff --git a/client.go b/client.go index dab4e13..e3450b2 100644 --- a/client.go +++ b/client.go @@ -16,17 +16,27 @@ import ( // interacting with the kernel API. You should not instantiate this client // directly, and instead use the [NewClient] method instead. type Client struct { - Options []option.RequestOption - Deployments DeploymentService - Apps AppService - Invocations InvocationService - Browsers BrowserService - Profiles ProfileService - Auth AuthService - Proxies ProxyService - Extensions ExtensionService - BrowserPools BrowserPoolService - Credentials CredentialService + Options []option.RequestOption + // Create and manage app deployments and stream deployment events. + Deployments DeploymentService + // List applications and versions. + Apps AppService + // Invoke actions and stream or query invocation status and events. + Invocations InvocationService + // Create and manage browser sessions. + Browsers BrowserService + // Create, list, retrieve, and delete browser profiles. + Profiles ProfileService + Auth AuthService + // Create and manage proxy configurations for routing browser traffic. + Proxies ProxyService + // Create, list, retrieve, and delete browser extensions. + Extensions ExtensionService + // Create and manage browser pools for acquiring and releasing browsers. + BrowserPools BrowserPoolService + // Create and manage credentials for authentication. + Credentials CredentialService + // Configure external credential providers like 1Password. CredentialProviders CredentialProviderService } diff --git a/credential.go b/credential.go index e3d1606..8844e85 100644 --- a/credential.go +++ b/credential.go @@ -22,6 +22,8 @@ import ( "github.com/kernel/kernel-go-sdk/packages/respjson" ) +// Create and manage credentials for authentication. +// // CredentialService contains methods and other services that help with interacting // with the kernel API. // diff --git a/credentialprovider.go b/credentialprovider.go index 4b99d53..b1cdefb 100644 --- a/credentialprovider.go +++ b/credentialprovider.go @@ -19,6 +19,8 @@ import ( "github.com/kernel/kernel-go-sdk/packages/respjson" ) +// Configure external credential providers like 1Password. +// // CredentialProviderService contains methods and other services that help with // interacting with the kernel API. // diff --git a/deployment.go b/deployment.go index d49aa8a..c121ea1 100644 --- a/deployment.go +++ b/deployment.go @@ -28,6 +28,8 @@ import ( "github.com/kernel/kernel-go-sdk/shared/constant" ) +// Create and manage app deployments and stream deployment events. +// // DeploymentService contains methods and other services that help with interacting // with the kernel API. // diff --git a/extension.go b/extension.go index 4127432..f891772 100644 --- a/extension.go +++ b/extension.go @@ -23,6 +23,8 @@ import ( "github.com/kernel/kernel-go-sdk/packages/respjson" ) +// Create, list, retrieve, and delete browser extensions. +// // ExtensionService contains methods and other services that help with interacting // with the kernel API. // diff --git a/internal/version.go b/internal/version.go index d988399..a1165e2 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.42.0" // x-release-please-version +const PackageVersion = "0.42.1" // x-release-please-version diff --git a/invocation.go b/invocation.go index 140abb1..72768a2 100644 --- a/invocation.go +++ b/invocation.go @@ -24,6 +24,8 @@ import ( "github.com/kernel/kernel-go-sdk/shared/constant" ) +// Invoke actions and stream or query invocation status and events. +// // InvocationService contains methods and other services that help with interacting // with the kernel API. // diff --git a/profile.go b/profile.go index 15f9cec..9a36e16 100644 --- a/profile.go +++ b/profile.go @@ -18,6 +18,8 @@ import ( "github.com/kernel/kernel-go-sdk/packages/param" ) +// Create, list, retrieve, and delete browser profiles. +// // ProfileService contains methods and other services that help with interacting // with the kernel API. // diff --git a/proxy.go b/proxy.go index c3077b6..d193b06 100644 --- a/proxy.go +++ b/proxy.go @@ -18,6 +18,8 @@ import ( "github.com/kernel/kernel-go-sdk/packages/respjson" ) +// Create and manage proxy configurations for routing browser traffic. +// // ProxyService contains methods and other services that help with interacting with // the kernel API. // diff --git a/scripts/utils/upload-artifact.sh b/scripts/utils/upload-artifact.sh new file mode 100755 index 0000000..7bb71fb --- /dev/null +++ b/scripts/utils/upload-artifact.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +set -exuo pipefail + +DIST_DIR="dist" +FILENAME="source.zip" + +mapfile -d '' files < <( + find . -type f \ + \( -name '*.go' -o -name 'go.mod' -o -name 'go.sum' \) \ + ! -path "./${DIST_DIR}/*" \ + -print0 +) + +if [[ ${#files[@]} -eq 0 ]]; then + echo -e "\033[31mNo Go source files found for packaging.\033[0m" + exit 1 +fi + +mkdir -p "$DIST_DIR" +rm -f "${DIST_DIR}/${FILENAME}" + +relative_files=() +for file in "${files[@]}"; do + relative_files+=("${file#./}") +done + +zip "${DIST_DIR}/${FILENAME}" "${relative_files[@]}" + +RESPONSE=$(curl -X POST "$URL?filename=$FILENAME" \ + -H "Authorization: Bearer $AUTH" \ + -H "Content-Type: application/json") + +SIGNED_URL=$(echo "$RESPONSE" | jq -r '.url') + +if [[ "$SIGNED_URL" == "null" ]]; then + echo -e "\033[31mFailed to get signed URL.\033[0m" + exit 1 +fi + +UPLOAD_RESPONSE=$(curl -v -X PUT \ + -H "Content-Type: application/zip" \ + --data-binary "@${DIST_DIR}/${FILENAME}" "$SIGNED_URL" 2>&1) + +if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then + echo -e "\033[32mUploaded build to Stainless storage.\033[0m" + echo -e "\033[32mInstallation: Download and unzip: 'https://pkg.stainless.com/s/kernel-go/$SHA'. Run 'go mod edit -replace github.com/kernel/kernel-go-sdk=/path/to/unzipped_directory'.\033[0m" +else + echo -e "\033[31mFailed to upload artifact.\033[0m" + exit 1 +fi