Skip to content

OnlyWorlds Unity SDK 0.28.0

Choose a tag to compare

@tmoosting tmoosting released this 31 Oct 06:29
· 248 commits to main since this release

The rest of the TypeScript SDK's client in Unity: sign-in by password and by Sign in with OnlyWorlds (PKCE), the AI
routes, a public RequestAsync that keeps the client's own rules, and DraughtAsync, read from a world key, an
account token or no key. A client with no key and no World is now built, as new OwV2Client() is, so a signed-out
person can call health and sign in. ListAllAsync stops on a page that answers the cursor it was sent. A minor release
because it adds public API (below).

Added

  • The AI routes, on an account token: OWClient.AskAsync(worldId, question, context) (POST /account/ask
    {world_id, question, context}), a question answered by keel's AI proxy from the context lines alone, as an
    OWAskAnswer (Answer, Model, StopReason, Usage with InputTokens and OutputTokens, Remaining,
    TokensRemaining, TokenRating); SortAsync(worldId, notes, slice) (POST /account/sort {world_id, notes, slice}), the user's notes sorted against the elements the app found for them into rows to review, as an
    OWSortAnswer (Rows, each an OWSortRow of kind make, add_to, link or ask with its Proposal, Target,
    Field, Op, Value, ValueId, ValueName, Question, Candidates and Then; NotProposed; and the meter);
    and AllowanceAsync() (GET /account/allowance), the account's daily token rating as an OWAllowance
    (TokenRating, TokensUsedToday, TokensRemaining, ResetsAt as served). A note (OWSortNote, a string converts
    to one) goes as its words alone, a string, or with a picture as {text?, image_url}; a slice row (OWSortRef) sends
    its anchor only when given. Each sends its Bearer alone, no PIN and no write header. Any other key, no world, no
    question, context, notes or slice, and a note with neither words nor a picture are refused before sending.
    OWApiError.IsAskUnavailable (503 ask_unavailable) and IsAskFailed (502 ask_failed) are new. Mirrors the
    TypeScript SDK's ask() (4.13.0), sort() (4.18.0) and allowance() (4.21.0).
  • The draught: OWClient.DraughtAsync(characterId, policy) (GET /character/{id}/context), one Character's context in
    one read, answered as the packet keel serves (a JObject, as GetMeAsync answers; no reader of the packet is
    added). OWDraughtPolicy carries the policy's nine keys, each sent only when given, in the TypeScript SDK's order
    under keel's names: Components (joined by commas), Mode, AsOf (as_of), Undated, Since, Budget,
    Depth, Compact (false sent as given) and Lens. A read: the key without its PIN, no write header; the
    Character's id is escaped. No Character, or a component that is empty or holds a comma, is refused before sending.
    A world read, as the list and get reads are (see Changed). Mirrors the TypeScript SDK's draught() (4.47.0; compact from 4.69.0,
    lens from 4.92.0). The 0.24.0 "Not added" line about the draught's lens no longer holds: this is that client.
  • The escape hatch: OWClient.RequestAsync(method, path, options), any route of keel's on the client's own rules,
    answering the body as served (a JToken, null for a 204 or an empty body). OWRequestOptions carries the Query
    (as given), the Body (any JSON value, sent exactly as given: nothing is cleaned, unlike the typed writes),
    IdempotencyKey, IfMatch, and the rules a route asks for: Write (X-OW-Agent on an agent client),
    ElementWrite (X-OW-Client), Proposable (a 202 is an OWProposedError), WorldRead (world= on a GET of a
    client with World set), AccountToken (a new public OWAccountTokenRoute: None, Path, World) and Auth
    (false: no credential). The key, the PIN where keel checks it, the Bearer, and the refusals of an account token or a
    keyless client are the typed calls' own. A method other than keel's five in capitals, a path that does not start
    with / or carries ? or #, a body on a GET and a negative IfMatch are refused before sending. Mirrors the
    TypeScript SDK's request() (public from 4.0.0).
  • Signing in, to an account token (ow_a_), on any client and with no credential of the client's. A password:
    OWClient.SignInWithPasswordAsync(email, username, password, ct, tokenName) (exactly one of the first two) signs
    in at keel's sign-in service (POST {BaseUrl}/auth/app/v1/auth/login, the password's one destination), mints the
    token (POST /account/tokens with the session as X-Session-Token, and {name} when tokenName is given) and ends
    the session (DELETE {BaseUrl}/auth/app/v1/auth/session, given five seconds at most, its failure ignored) whether
    the mint worked or not, answering an OWSignedIn (Token, Id, Name, Last4; Name falls back to the name
    sent). tokenName is the name the account's tokens page lists the token under, sent as given; without it the mint
    goes with no body and the token has no name (the TypeScript SDK requires its tokenName). A blank name, or one past
    keel's 255 characters (counted as keel counts, in code points, untrimmed), is refused before sending. The wire
    fixture follows the API document that declares the mint's body. Sign in with
    OnlyWorlds: SignInWithOnlyWorlds(clientId, redirectUri) sends nothing and answers an OWSignInBegun (Url, the
    site's authorize URL with the S256 challenge, to open in the system browser; State, ClientId, RedirectUri,
    the secret Verifier, Pending); CompleteSignInAsync(pending, url) checks the return's state and page (scheme,
    host with port, path) and trades its code once at POST /auth/token {grant_type, code, code_verifier, client_id, redirect_uri}, answering an OWSignInResult (Token, TokenId, ExpiresAt as served or null, TokenType,
    Account with Id and Username); a return with another state leaves the sign-in pending, a matching one spends
    it. A return address keel cannot match (localhost, a loopback without its port, userinfo, a query, a fragment, a dot
    segment, a reserved scheme) is refused saying why, in the TypeScript SDK's words. OWSignIn.PkceChallenge and
    Base64Url are public (RFC 7636's vector holds). Every refusal after the call is an OWSignInError (Reason, one
    of OWSignInReason's words: invalid_credentials, invalid_grant, state_mismatch, email_unverified,
    rate_limited, offline, mint_failed, failed; Status, Code, RetryAfter), which holds no password,
    session, verifier, code or token and no inner exception. Mirrors the TypeScript SDK's signInWithPassword()
    (4.31.0), signInWithOnlyWorlds() and completeSignIn() (4.46.0; expiresAt from 4.94.0), pkceChallenge and
    base64url. The 0.24.0 "Not added" line about completeSignIn's expiresAt no longer holds: ExpiresAt is it.

Changed

  • The bare client: new OWClient(new OWClientConfig { Transport = ... }), with no key and no World, is built,
    where it threw an ArgumentException ("An API key is required, or World ..."); it is the TypeScript SDK's new OwV2Client(), the client a person signing in has. On it, HealthAsync, SignInWithPasswordAsync,
    SignInWithOnlyWorlds and CompleteSignInAsync work, with no credential (OWJoin's keyless calls take no
    client); every other call is refused before sending with an InvalidOperationException naming the request and
    what works without a key, in the TypeScript SDK's words: "GET /location/ needs a key, and this client holds none:
    without one, only HealthAsync, SignInWithPasswordAsync, SignInWithOnlyWorlds and CompleteSignInAsync work (and
    OWJoin's PreviewAsync and RedeemAsync, which take no client), and ListAsync, ListAllAsync, GetAsync, GetWorldAsync
    and DraughtAsync with World set. Nothing was sent." A keyless client with World set refuses with the same words, and
    a transport is still required. Code that relied on the constructor to catch an empty key (an Editor settings
    field, say) now gets that refusal from its first call instead.
  • OWClient.ListAllAsync stops when a page hands back the cursor it was sent (the caller's starting cursor
    included) with more to come: an OWTransportError ("answered the cursor it was sent, with more to come; the walk
    stopped rather than read the same page again"), where it read the same page forever. The elements read before are
    not returned. A last page (has_more false) that repeats its cursor still ends the walk as before. Mirrors the
    TypeScript SDK's listAll guard (4.88.0, its OwNetworkError).
  • OWClient.DraughtAsync reads with World set, as ListAsync, ListAllAsync, GetAsync and GetWorldAsync do:
    an account token sends its Bearer and world=<id> (the account's own access there), and no key sends world=<id>
    alone (the public's read of a world open to it), where both were refused before sending. keel's document opens the
    draught to both and declares world there. The refusals that name the world reads now name DraughtAsync too
    ("... ListAsync, ListAllAsync, GetAsync, GetWorldAsync and DraughtAsync ..."). A new test drives every call again
    from an account-token client and a keyless one and fails a read whose operation declares world that either never
    sends (the roster, GetMembersAsync, is the account token's alone, as the document's security has it). Mirrors the
    TypeScript SDK's draught (4.121.1).
  • OWClient.CreateAccountWorldAsync holds OWAccountWorldCreate.KeyName to keel's rule for the key's name
    (_clean_key_name, the key mint's too): trimmed as Python's str.strip() trims, then 1 to 80
    characters counted in code points. A name blank or past 80 once trimmed is refused before sending with an
    ArgumentException ("KeyName is 1 to 80 characters once trimmed, as keel holds it; null for a key with no name.
    Nothing was sent."), where it was sent and answered 422 key_name. Blank is refused here because keel refuses it
    on this route; the mint reads a blank name as none. The name still goes as given and null still sends no
    key_name. The check is MintWorldKeyAsync's own (0.27.0). The TypeScript SDK's createAccountWorld checks
    neither and leaves both to keel.