Skip to content
21 changes: 21 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Pull Request

on:
pull_request:

permissions:
contents: read

concurrency:
group: pull-request-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
verify:
name: Verify
uses: ./.github/workflows/verify.yml
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Comment thread
cursor[bot] marked this conversation as resolved.

test:
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
name: Tests
uses: ./.github/workflows/tests.yml
secrets: inherit
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
28 changes: 14 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: Release

on:
workflow_dispatch:
workflow_run:
workflows:
- Verify
types:
- completed
push:
branches:
- main
Comment thread
cesarenaldi marked this conversation as resolved.

permissions:
contents: read
Expand All @@ -17,21 +14,24 @@ concurrency:
cancel-in-progress: true

jobs:
verify:
name: Verify
uses: ./.github/workflows/verify.yml

test:
name: Tests
needs: verify
uses: ./.github/workflows/tests.yml
secrets: inherit

release:
name: Publish Canary
runs-on: ubuntu-latest
if: >
github.event_name == 'workflow_dispatch' ||
(
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'main'
)
needs: verify
Comment thread
cesarenaldi marked this conversation as resolved.

steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha || github.sha }}

- name: Set Up Repository
uses: ./.github/actions/setup
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
name: Tests

on:
workflow_call:
workflow_dispatch:
pull_request:
Comment thread
cesarenaldi marked this conversation as resolved.
push:
branches:
- main

permissions:
contents: read

concurrency:
group: tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
name: Tests
run:
name: Run
runs-on: ubuntu-latest

steps:
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
name: Verify

on:
workflow_call:
Comment thread
cursor[bot] marked this conversation as resolved.
workflow_dispatch:
pull_request:
push:
branches:
- main

permissions:
contents: read

concurrency:
group: verify-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
verify:
name: Verify
run:
name: Run
runs-on: ubuntu-latest

steps:
Expand Down
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- The SDK should present one cohesive consumer interface, follow developer workflows, and hide service boundaries where possible.
- When you discover a real boundary inconsistency between underlying CLOB, Gamma, Data, and relayer APIs, append a concise note to `docs/api-boundary-notes.md`.
- Future work includes `@polymarket/react`, which should build on the same core model with a higher-level frontend-oriented surface.
- Each action in `packages/client/src/actions/` has a corresponding bound method in a decorator under `packages/client/src/decorators/`. When you change an action — its signature, parameter types, TSDoc, or examples — verify the matching decorator method is also updated. The decorator method is the public surface most consumers see.
- Do not leak `ky` details outside of `ServiceClient`. Keep `ky` instances, types, and option shapes internal, and expose Polymarket-specific abstractions instead.
- Wallet-library integrations must stay isolated to their entry points and optional peer dependencies. If `viem` is an optional peer tied to the `viem` entry point, non-`viem` code paths must not import `viem`. Apply the same rule to future entry points for other wallet libraries such as Ethers, Privy, Safe SDK, or Turnkey.

Expand All @@ -45,6 +46,7 @@
- Introduce helpers only when they meaningfully improve reuse, safety, or readability. Helper names should reflect their real behavior; otherwise inline or rename them.
- Shape abstractions around real supported workflows and current platform behavior, not generic completeness. Add breadth only when a concrete use case requires it.
- When translating one public error into another at an action boundary, prefer `ResultAsync.mapErr(...)` on the request pipeline over `try`/`catch` around `unwrap(...)` when the remap can stay inside the result chain.
- Prefer TypeScript enums with `z.enum(MyEnum)` over `z.union([z.literal(...), ...])` for string-valued sets. This gives consumers dot-notation access, keeps the schema and type in sync, and avoids `z.nativeEnum` which is deprecated in Zod v4.
- In TSDoc `@example` blocks, do not include import statements. Keep examples focused on usage only.
- Public TSDoc must not mention underlying service boundaries such as Gamma, CLOB, Data API, or relayer. Public docs should describe the unified SDK surface, while tests may mention the underlying services when useful.
- For any public SDK function export, including actions and client methods, document the public thrown-error surface explicitly. Export a flattened `...Error` union of the concrete public error types the function can throw through its public contract, dedupe the union, and do not include internal assertion-style errors such as `InvariantError` in that union.
Expand All @@ -55,6 +57,7 @@
- Default client tests to integration-style coverage.
- Do not mock API responses unless explicitly requested or unless mocking is necessary to isolate a boundary under test.


## Response contract

Be concise.
Loading