Repository navigation
Conversation
One resolver decides, once per client, between production (the default, unchanged) and the project's dev environment: the `environment` option, then ARETE_ENVIRONMENT outside browsers; in dev mode the option's url/env, ARETE_DEV_URL, ARETE_DEV_ENV, then the nearest .arete/dev/session.json. Through the edge every surface (gateway chain and transactions, Program Read, stack socket and queries, protocol API) goes to the loopback edge with no Authorization, the installed identity in X-Arete-Dev-Identity, the well-known check before any socket, and devenv-edge-unreachable when an answer is not an edge's. Direct mode resolves the client's identities once with a secret key and mints environment tokens. Refusals from either envelope are DevEnvironmentError with code, message and fix; nothing falls back. In dev mode sends require a sign-only wallet adapter (submitsThrough: 'context'); the kit and web3js adapters declare it. client.environment on stack, session and protocol clients; <AreteProvider environment>, useAreteEnvironment and AreteEnvironmentBadge in React. Every dev-environment-switch/v1 vector runs in core tests.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
[Medium impact] The change adds an opt-in dev route across the TypeScript and React client workflows. Fix the endpoint checks before merging so dev clients can use endpoints supplied by the dev environment.
|
…figured apiUrl in direct dev mode; name unreadable session files
| const dev = devMode | ||
| ? await planDevClient(devMode, effectiveStack, programReadOverrides, options) | ||
| : undefined; | ||
| const socketUrl = dev && url !== null | ||
| ? (dev.stack instanceof Error ? REFUSED_STACK_SOCKET : dev.stack.websocketUrl) |
There was a problem hiding this comment.
Dev clients require production endpoints
Arete.connect checks the production endpoints before it calls planDevClient. A stack without a generated HTTP endpoint or independent program reads therefore fails with INVALID_CONFIG, even when the edge or resolve answer supplies its HTTP endpoint. A definition without either endpoint also fails the WebSocket check, and dev mode forbids supplying these endpoints through options.
Choose the dev endpoints before these checks, and keep the production endpoint requirements on the production path.
Prompt To Fix With AI
This is a comment left during a code review.
Path: typescript/core/src/client.ts
Line: 1374-1378
Comment:
**Dev clients require production endpoints**
`Arete.connect` checks the production endpoints before it calls `planDevClient`. A stack without a generated HTTP endpoint or independent program reads therefore fails with `INVALID_CONFIG`, even when the edge or resolve answer supplies its HTTP endpoint. A definition without either endpoint also fails the WebSocket check, and dev mode forbids supplying these endpoints through options.
Choose the dev endpoints before these checks, and keep the production endpoint requirements on the production path.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Implements the dev environment switch contract (
docs/internal/dev-environment-switch.md) in@usearete/sdkand@usearete/react. Stacked on #475 (the edge); it will be retargeted tomainonce #475 merges.What changes for apps
environment: { kind: 'dev' }(orARETE_ENVIRONMENT=devon servers) points the installed SDKs at the project's dev environment. The target is thea4 dev upedge (optionurl,ARETE_DEV_URL, or the running session'sedgeUrl), or the environment itself with a secret key (optionenv/ARETE_DEV_ENV).client.environment('production' | 'dev') is available on stack, session and protocol clients.<AreteProvider environment>(anAreteSessionProviderbelow it inherits it),useAreteEnvironment(), and<AreteEnvironmentBadge />, which renders only in dev mode.Design
core/src/dev-environment.ts):resolveEnvironmentSwitch(option, host)implements §2 exactly: grammar, precedence,INVALID_CONFIGanddevenv-not-configured. Everything it reads goes through anEnvironmentSwitchHost, so tests can record what was read. The.arete/dev/session.jsonlookup walks from the cwd upwards and only runs in Node, Bun or Deno.createEdgeFetch): sends noAuthorizationand mints nothing. It adds a per-surfaceX-Arete-Dev-Identityheader, refuses any URL that isn't on the edge, and fails withdevenv-edge-unreachablewhen nothing answers or the answer lacksX-Arete-Dev-Edge: 1.GET /.well-known/arete-dev-edgeruns once before any socket opens.core/src/dev-targets.ts): the stack client calls resolve once inArete.connect, with its gateway, Program Read and stack identities. The protocol client resolves lazily on its first request. Token requests carryenvironment, and.devstacksockets are treated as hosted. Program Read puts the served release in the path and authenticates with the installed one.createDevSolanaGatewayTransports. Program Read gets newdev-edgeandrefusedtransport kinds. The stack socket gets internalConnectionManageroptions (noCredentials,sessionEnvironment,hostedSession,beforeConnect). Stack queries get the edge path plusstackManifestHash. The protocol client gets edge and direct senders; before the first publish the path names the protocol aspackage:<pkg>.DevEnvironmentError, which carriescode,message,fixandrefusal(the other detail fields). A refused surface fails on its own and the others keep working. Nothing falls back to production.WalletAdapter.submitsThroughfield ('context' | 'adapter'). In dev modetransaction/executerefuse any adapter that doesn't declare'context', withdevenv-wallet-send-unsupported, before the wallet is asked to do anything. The kit and web3js adapters declare'context'unless they were given their owntransport.Contract change
Added
devenv-wallet-send-unsupported(raised by the SDK) to the §6 table. The SDK work item requires this code, but the table didn't list it.Vectors
core/src/dev-environment.vectors.test.tsruns all 100 cases acrossswitch.json,targets.jsonandrefusals.json. Targets and refusals run against real clients and a recording network: they check every request URL, header and identity, the resolve and mint bodies, socket URLs, and that no request reaches the other world. Nothing is skipped. Two comparisons differ from a literal reading of the files:tokenRequest: the SDK mints one scope per call, as it already does in production. The test checks that the minted scopes are a subset of the vector's list and compares every other field exactly.resolveRequest: the stack client and the protocol client are separate clients, so each sends its own resolve. The test merges the bodies and compares the result with the vector.Tests
npm run lintin core fails on the base commit too: the package has no ESLint config.vitest.config.tsin core pinsARETE_ENVIRONMENT='', so tests stay in production even when run undera4 dev run.Known gaps / not verified
a4 dev upedge or a real environment. Everything is checked against vectors and mocks only./api/protocol-deployments/*. Protocol calls on other paths are refused by the edge withdevenv-surface-unavailable: instance reads, non-create prepares, metadata, submit, intents and receipts. This needs an edge follow-up.deploymentId. Through the edge that is the installed one, so participant-writer proofs may not verify against the environment's deployment.ProtocolDefinition.deploymentis still typed non-null. Anulldeployment (before the first publish) is accepted at runtime in dev mode only. Generated clients get the type change with the protocol-client generator work.url/httpUrlwith dev mode (andapiUrl/sessionEndpoint/deploymentIdon protocol clients) throwINVALID_CONFIGinstead of being honoured.auth.secretKey,ARETE_API_KEYor thea4login. AtokenKind: 'api'credential is not used for resolve.