import type { HttpClient, RequestOptions } from "../http.js"; import { Paginated } from "../pagination.js"; import type { CreateSpaceParams, ListSpacesParams, Memory, ShareSpaceParams, Space, SpaceCollaborator, GrantableSpaceRole, UpdateSpaceParams, WorkingSpace } from "../types.js"; /** * Spaces: a boundary around a set of memories. * * They exist because "everything I know" is the wrong scope for most * questions. Work and personal contexts hold contradictory truths - two * different "my manager" - and answering from both at once is wrong in a way * that is hard to notice. * * Membership is a LINK, not ownership. `removeMemories` takes a memory out of * a Space; it does not delete it, and the same memory can belong to several. */ export declare class Spaces { #private; constructor(http: HttpClient); list(params?: ListSpacesParams, options?: RequestOptions): Paginated; get(id: string, options?: RequestOptions): Promise; /** * Creates a Space. Answers 201. * * Worth an idempotency key when a person is behind it: a double-clicked * "create Space" button makes two Spaces called Work, and nothing later can * tell which of them memories should have gone into. */ create(params: CreateSpaceParams, options?: RequestOptions): Promise; /** * Deletes a Space. You must say what happens to what is in it. * * There is no default, here or in the API, and that is deliberate: "delete * this Space" means the label to some people and everything inside it to * others, and a client that guessed would destroy or keep somebody's * material without being asked. * * `delete` never destroys a memory that is filed in another Space as well — * that one is detached and left alone. `deleted` and `kept` come back so you * can say what actually happened. * * `moveTo` NAMES WHERE THE STRANDED ONES GO, and is refused-into rather than * required: most deletions strand nothing, because everything in the Space * is also filed elsewhere, and demanding a destination for those would be a * question about nothing. When something WOULD be left in no Space at all, * the server answers 400 naming this field. It used to file them into the * account's default, which no longer exists — nothing picks a Space on * anybody's behalf, so "keep these" has no answer unless you say where. */ delete(id: string, params: { readonly memories: "keep" | "delete"; readonly moveTo?: string; }, options?: RequestOptions): Promise<{ deleted: number; kept: number; rehomed?: number; }>; /** * Merges Spaces into a NEW one, leaving every source exactly as it was. * * Additive, not destructive: a memory ends up in the sources AND the result, * every existing search over a source returns what it did before, and * undoing it is deleting the Space this returns. A memory in two sources is * filed once. */ merge(params: { readonly sourceIds: readonly string[]; readonly name: string; readonly description?: string; }, options?: RequestOptions): Promise<{ space: Space; added: number; }>; /** * Which Space a context is working in. * * `chosen` absent means NOTHING sent from that context is kept — there is no * default behind it and nothing picks one. The reply used to carry a * `fallback` for that case and no longer can. * * `profile` is the command line's own profile name, and `surface` says which * context is being asked about: `cli` for this profile, `email` for the * account's ingest address. Between them they are the whole of what a caller * may say about where it is working — the server builds the scope key * itself, so this can never read or move where a chat is filing. */ working(params?: { readonly profile?: string; readonly surface?: "cli" | "email"; }, options?: RequestOptions): Promise; /** * Works in one from here on. `null` stops working in any. * * Takes an id or a NAME, because that is how a person says it. `null` rather * than an omitted field: "clear this" and "I did not mention it" are * different instructions, and clearing means this context keeps nothing * until a Space is chosen again. */ chooseWorking(space: string | null, params?: { readonly profile?: string; readonly surface?: "cli" | "email"; }, options?: RequestOptions): Promise; /** Renaming, retention, and archiving - `archived` is a field, not a verb. */ update(id: string, params: UpdateSpaceParams, options?: RequestOptions): Promise; /** * The memories filed in a Space. * * The cursor is PASSED. This fetch used to ignore the paginator's cursor * on the stale belief that the endpoint had none — the server has minted * `pagination.nextCursor` since it started paging, and its own comment * says "both SDKs iterate by reading pagination". Ignoring it meant every * page request was identical: the loop guard saw a non-advancing fetch and * stopped silently, so `all()` returned the first page twice and dropped * everything after it — duplicated AND truncated data, with no error. */ memories(id: string, params?: { readonly limit?: number; }, options?: RequestOptions): Paginated; addMemories(id: string, memoryIds: readonly string[], options?: RequestOptions): Promise<{ added: number; }>; /** * Removes memberships. The memories themselves are untouched. * * A body on a DELETE, which is unusual and is what the API takes: the * alternative is five hundred ids in a query string, and every proxy in * between has its own limit on how long a URL may be. */ removeMemories(id: string, memoryIds: readonly string[], options?: RequestOptions): Promise<{ removed: number; }>; /** * Who can see this Space, including invitations nobody has accepted. * * A DIFFERENT EDGE from `memories()` next door, and the difference is worth * holding on to: that one maps a MEMORY to a Space, this one maps a PERSON * to a Space. The server keeps them in two tables with two names for exactly * that reason. * * Read `acceptedAt` before you render a row. An invitation grants nothing * until it is accepted, so a list that draws invited and accepted people the * same way tells its user somebody is reading their memories when nobody is. * * Paginated like every other list here. A Space has a handful of * collaborators rather than thousands, so this will usually be one page - * which costs a caller nothing and means the shape does not change if a * Space ever has an organisation on it. */ collaborators(id: string, params?: { readonly limit?: number; }, options?: RequestOptions): Paginated; /** * Offers somebody sight of a Space. Answers with the invitation. * * AN OFFER, NOT A GRANT, and the returned `acceptedAt` will be absent to * prove it. The recipient has to accept before they can see anything, which * is the property that keeps "nothing enters your memory without you" true * even when somebody else starts the sharing. Do not tell your user their * Space "has been shared" on the strength of a 2xx here. * * WHAT THEY GET IS THE WHOLE SPACE: every memory already filed in it and * every memory that lands in it afterwards. There is no narrower grant, and * `role` does not make one - it decides what they may do BESIDES read. * * Worth an idempotency key when a person is behind it. A double-clicked * "share" is two invitations to the same address, and the second one is a * second email arriving at somebody who has already been asked. */ share(id: string, params: ShareSpaceParams, options?: RequestOptions): Promise; /** * Ends somebody's access, or withdraws an invitation they never accepted. * * Nothing was ever copied into their account - a collaborator SEES the * owner's memories rather than holding a duplicate - so this is one write * and not a cascade, and there is no orphaned copy left behind. * * A body on a DELETE, matching `removeMemories` above. The alternative is an * address in a path segment, where every `.`, `+` and `@` is a chance for a * proxy or a router to normalise somebody else's email into the one that * gets revoked. */ unshare(id: string, email: string, options?: RequestOptions): Promise<{ email: string; }>; /** * Changes what an existing collaborator may do. Never invites anybody. * * The quiet one. Moving somebody from `viewer` to `owner` sends no * invitation and needs no acceptance, and afterwards they can share the * Space onward and revoke the person who promoted them. Show your user what * `owner` means before you send this, not after. */ setRole(id: string, params: { readonly email: string; readonly role: GrantableSpaceRole; }, options?: RequestOptions): Promise; }