//#region src/artifacts/types.d.ts /** * Token scope. `write` grants push; `read` is fetch-only. Mirrors * the binding's `"read" | "write"` literal; named here so the * wrapper and CLI can refer to it by a single alias. */ type ArtifactScope = "read" | "write"; //#endregion //#region src/artifacts/client.d.ts /** Source spec for `import`. Mirrors the binding's `source` block. */ interface ArtifactImportSource { url: string; branch?: string; depth?: number; } /** Options for `import`'s target repo. */ interface ArtifactImportOptions { description?: string; readOnly?: boolean; } /** * A repo summary as returned by `list`: the binding's * `ArtifactsRepoInfo` without the `remote` field, with the `name` * rewritten to its local (unscoped) form. */ type ArtifactRepoSummary = Omit; /** The client, session-scoped or namespace-wide. */ interface ArtifactClient { /** * The session id every operation is scoped under, or undefined * when the client spans the whole namespace. */ readonly sessionId: string | undefined; /** Create a repo. The returned `name` is local (unscoped). */ create(name: string, opts?: { readOnly?: boolean; description?: string; setDefaultBranch?: string; }): Promise; /** * Resolve repository metadata. The returned `name` is local. * Throws `ArtifactsError` (code `NOT_FOUND`) if it does not exist. */ get(name: string): Promise; /** * List the session's repos, walking every page. Names are local. * Without a session id this is every repo in the namespace, each * under its stored name. */ list(): Promise; /** Import an external git remote into a session repo. */ import(name: string, source: ArtifactImportSource, opts?: ArtifactImportOptions): Promise; /** Delete a repo. Returns false when it does not exist. */ delete(name: string): Promise; /** Mint a git token for a session repo. */ createToken(name: string, scope?: ArtifactScope, ttl?: number): Promise; /** List a session repo's token page (metadata only — no plaintext). */ listTokens(name: string): Promise; /** * Get a single token's metadata by id. The binding has no direct * accessor and no token-list cursor, so this filters the page * returned by `listTokens()` and throws `NotFoundError` on a miss. */ getToken(name: string, id: string): Promise; /** Revoke a token by id or plaintext. Returns false on a miss. */ revokeToken(name: string, tokenOrId: string): Promise; /** * Argv-driven entry point. The worker-backend's `artifacts` * custom command dispatches through this; in-process callers can * use it too when they want CLI-shaped output. */ cli(input: ArtifactsCLIInput): Promise; } /** * Build an artifacts client over a namespace binding. Pass a * session id to scope every operation to that session; omit it for * a client over the whole namespace. */ declare function createArtifact(binding: Artifacts, sessionId?: string | null): ArtifactClient; //#endregion //#region src/artifacts/cli.d.ts /** * Git seam for the `create` shorthand. The artifacts package owns no * git; the worker backend supplies this closure, bound to the same * `workspace.git.cli(...)` the `git` shell command uses, so `create` * can register the remote without the package depending on git. * * Returns `ok` on success. On failure, `exists: true` distinguishes a * remote-name collision (recoverable with `--force`) from any other * git error, so the dispatcher can point the caller at the right fix. * When `force` is set the implementation updates the existing remote * (the moral equivalent of `git remote set-url`) rather than failing. */ type RemoteAddFn = (opts: { name: string; url: string; force?: boolean; }) => Promise<{ ok: boolean; exists?: boolean; message?: string; }>; interface ArtifactsCLIInput { /** Argv as seen by the shell command. `argv[0]` is the group. */ argv: string[]; /** Environment variables. Reserved for future use. */ env?: Record; /** * Optional git seam used only by the `create` shorthand to register * the remote. When absent, `create` skips the git step and instead * reports a ready-to-run `git remote add` line. */ remoteAdd?: RemoteAddFn; } interface ArtifactsCLIResult { stdout: string; stderr: string; exitCode: number; } declare function runArtifactsCLI(client: ArtifactClient, input: ArtifactsCLIInput, bindingConfigured?: boolean): Promise; //#endregion //#region src/artifacts/errors.d.ts /** * Base class for every artifacts error. The `code` field is the * contract: CLI dispatchers and external callers branch on it. */ declare class ArtifactError extends Error { readonly code: string; constructor(code: string, message: string, options?: { cause?: unknown; }); } /** * Raised when a repo name is empty, contains a path separator, or * is otherwise unusable as the trailing segment of a scoped name. */ declare class InvalidRepoNameError extends ArtifactError { constructor(name: string, reason: string, options?: { cause?: unknown; }); } /** * Raised when a session id is empty or contains a path separator. * A session id becomes the leading segment of every scoped name, * so it has the same shape constraints as a repo name. * * An empty id is an error rather than a way to ask for a client * without a session. That is what omitting the id does, and an id * that came out empty by accident should not silently widen a * client from one session to the whole namespace. */ declare class InvalidSessionIdError extends ArtifactError { constructor(sessionId: string, reason: string, options?: { cause?: unknown; }); } /** * Raised when a repo lookup misses or a token id can't be found * within a repo's token list. */ declare class NotFoundError extends ArtifactError { constructor(message: string, options?: { cause?: unknown; }); } //#endregion export { ArtifactsCLIInput as a, runArtifactsCLI as c, ArtifactImportSource as d, ArtifactRepoSummary as f, NotFoundError as i, ArtifactClient as l, ArtifactScope as m, InvalidRepoNameError as n, ArtifactsCLIResult as o, createArtifact as p, InvalidSessionIdError as r, RemoteAddFn as s, ArtifactError as t, ArtifactImportOptions as u }; //# sourceMappingURL=shared-C9CTqSgh.d.ts.map