import type { kRPCClient } from './krpc_client'; export declare const AIWORKSPACE_SERVICE_NAME = "aiworkspace"; /** Business results of the AI Workspace service: `{ ok, ... }`, `{ ok: false, error }`, or a three-state commit result. */ export interface AiwsError { code: string; retryable: boolean; detail: string; sub_code?: string; data?: unknown; } export type AiwsResult = (T & { ok: true; }) | { ok: false; error: AiwsError; }; export declare class AiwsFailure extends Error { readonly code: string; readonly subCode?: string; readonly data?: unknown; constructor(error: AiwsError); } /** A reference object (内核架构改进 D10): where, and which version. */ export interface AiwsReference { zone?: string; workspace_id?: string; entity_id: string; selector?: Record; mode: 'live' | 'fixed'; version?: { epoch: string; seq: number; } | { content_root: string; path?: string; }; } /** * The Object URL of a Reference (buckyos doc/key url.md §6): the default * `obj://aiworkspace//entities/` for a live reference without * selector; `mode=fixed`, `selector` and `version` go into the query as canonical * JSON, so one Reference has exactly one URL. Same rules as buckyos-api `aiws_reference_url`. */ export declare function aiwsReferenceUrl(reference: AiwsReference, workspaceId?: string): string; /** The Reference an `obj://aiworkspace//entities/[?...]` URL projects. */ export declare function parseAiwsReferenceUrl(url: string): AiwsReference; /** What `ext.upgrade` / `ext.build` rewrite on the instances of a definition whose new version narrows what they rely * on (schemas/migration.schema.json, Q30). */ export interface AiwsMigration { config?: { rename?: Record; drop?: string[]; fill?: Record; }; bindings?: { rename?: Record; drop?: string[]; fill?: Record; }; slots?: { rename?: Record; move?: Record; }; events?: { rename?: Record; drop?: string[]; }; } export interface AiwsExtBuildParams { files: ({ name: string; obj_id: string; } | { name: string; base64: string; })[]; folder_id?: string; expect?: { def_rev: number; dir_rev: number; }; force?: boolean; dry_run?: boolean; provenance?: { pkg_id?: string; version?: string; digest?: string; }; /** With `provenance`: rebuild an identity the folder holds from another source (an upgrade across Zones, Q30). */ upgrade?: boolean; /** `{ : Migration }` for a build that narrows what instances rely on. */ migration?: Record; idempotency_key?: string; } export interface AiwsExtUpgradeParams { workspace_id: string; /** `pkg_id` default: the package the definition was imported from (`provenance.pkg_id`). */ items: { def_entity_id: string; pkg_id?: string; }[]; migration?: Record; force?: boolean; dry_run?: boolean; idempotency_key?: string; } export interface AiwsExtUpgradeResult { status: 'accepted' | 'unchanged' | 'checked'; commit_id?: string; seq?: number; controls: { ident: string; def_entity_id: string; action: 'upgraded' | 'unchanged'; from?: string; to?: string; migrated?: string[]; }[]; /** `dry_run`: what the migration writes on each instance. */ plan?: { instance: string; ops: Record[]; }[]; } export interface AiwsTemplateParam { type: 'string' | 'number' | 'boolean'; title?: string; default?: string | number | boolean; } /** A Workspace template of a control package (aiws-manifest.json `workspace_templates`, schemas/template.schema.json, * Q32): a snapshot under `templates//` and the controls of the same package it needs. */ export interface AiwsTemplateItem { id: string; title: string; description?: string; snapshot: string; digest: string; requires: { host_api?: { html?: number; declarative?: number; }; controls: string[]; }; params?: Record; reset?: { tables?: string[]; }; } /** One template to export (`ext.export_template`, `ext.pack` / `ext.install` `templates`): chosen Surfaces (and data * entities) of the Workspace. */ export interface AiwsTemplateExport { surfaces: string[]; data?: string[]; template: { id: string; title: string; description?: string; params?: Record; reset?: { tables: string[]; }; }; } /** `ext.build` / `ext.import`: one entry per control (`created | rebuilt | unchanged | satisfied`), the first also at the top. */ export interface AiwsExtBuildResult { status: 'accepted' | 'unchanged' | 'checked'; commit_id?: string; seq?: number; unchanged?: boolean; ident?: string; def_entity_id?: string; dir_entity_id?: string; version?: number; def_rev?: number; dir_rev?: number; action?: string; build?: { input_digest: string; builder_version: string; built_at: string; }; controls: Record[]; diagnostics: Record[]; } export interface AiwsLibraryPackage { pkg_id: string; version: string; title: string; author: string; mode: string; installed_at: string; /** The package's manifest_version is above what the service reads: listed, not importable. */ needs_newer?: boolean; controls: { ident: string; name: string; kind: string; version: number; digest: string; dir: string; title?: string; description?: string; catalog?: Record; deps?: string[]; }[]; templates?: { id: string; title: string; description?: string; params?: Record; requires: AiwsTemplateItem['requires']; }[]; } /** `ext.pack`: the `.pikg` the service wrote into the caller's `exports` bucket. */ export interface AiwsExtPackResult { bucket_id: string; key: string; obj_id: string; size: number; digest: string; app_doc_object_id: string; app_did: string; pkg_id: string; version: string; /** The bucket binding with a read token (as `doc.export`'s `download`). */ download: { bucket_id: string; key: string; version: number; obj_id: string; token: string; }; } /** What an executor outside the service reports for a run (M3): results in the Mock executor's shape, or an analysis. */ export interface AiwsRunReport { run_id: string; attempt: number; progress?: Record; error?: { code: string; detail: string; }; results?: Record[]; read_set?: Record[]; summary?: string; warnings?: string[]; assumptions?: string[]; analysis?: Record; } /** * kRPC client of the AI Workspace service (`/kapi/aiworkspace`). Every method takes the business result out of * `result` and throws `AiwsFailure` on `{ ok: false }`; commits return the three-state result as it is. * Stable methods: see `src/frame/aiworkspace/README.md` (Protocol, method levels). */ export declare class AiWorkspaceClient { private rpcClient; constructor(rpcClient: kRPCClient); call>(method: string, params: Record): Promise; list(): Promise>; info(workspace_id: string): Promise>; getUserState(workspace_id: string): Promise>; setUserState(workspace_id: string, entries: Record, expect?: Record): Promise>; resolve(workspace_id: string, reference: AiwsReference | Record): Promise>; resolvePath(workspace_id: string, path: string): Promise>; read(workspace_id: string, entity_id: string, selector?: Record): Promise>; query(workspace_id: string, params: Record): Promise>; outline(workspace_id: string): Promise>; prepare(workspace_id: string, request: Record): Promise>; /** The three-state commit result (`status: accepted | conflict | rejected`), never thrown. */ commit(workspace_id: string, request: Record): Promise>; getSubmission(workspace_id: string, epoch: string, idempotency_key: string): Promise>; /** Changes after `after_seq` (`filter.detail: "touched"` for the touched entities only). */ getChanges(workspace_id: string, epoch: string, after_seq: number, opts?: { limit?: number; touchedOnly?: boolean; }): Promise>; /** Long poll until the head passes `after_seq` (or `timeout_ms`). */ waitChanges(workspace_id: string, after_seq: number, opts?: { epoch?: string; timeout_ms?: number; }): Promise<{ epoch: string; head_seq: number; timed_out: boolean; }>; /** A whole-Workspace package (`.bcanvas`): `download` names it in the owner's exports bucket. */ exportDoc(workspace_id: string, mode: 'share' | 'personal_backup', self_contained: boolean, include_notes?: boolean): Promise>; /** Register a FileObject as a staged asset: `{ bucket_id, key }` (the uploader's binding) or `{ obj_id }`. */ assetImportObject(workspace_id: string, source: { bucket_id: string; key: string; } | { obj_id: string; }): Promise<{ object_id: string; media_type: string; size: number; }>; controlsList(): Promise>; controlsDescribe(kind: string): Promise>; controlsImport(workspace_id: string, params: Record): Promise>; controlsExport(workspace_id: string, entity_id: string, format?: 'markdown' | 'opml'): Promise>; /** Build one control's source files into the Workspace; `BUILD_FAILED` carries `data.diagnostics`. */ extBuild(workspace_id: string, params: AiwsExtBuildParams): Promise; /** The bundle of definitions (`purpose: pull` needs read only and synthesizes the source of never-built ones). */ extExport(workspace_id: string, entity_ids: string[], purpose?: 'package' | 'pull'): Promise<{ manifest: Record; controls: Record[]; files: { path: string; obj_id?: string; size: number; text?: string; }[]; }>; /** Into the caller's library: a `.pikg` object or one bound into the caller's `exports` bucket (consumed), or * definitions of a Workspace (`from` + `package`). */ extInstall(params: { pikg?: { obj_id: string; } | { bucket_id: string; key: string; }; from?: { workspace_id: string; entity_ids: string[]; templates?: AiwsTemplateExport[]; }; package?: { name: string; version?: string; title?: string; }; mode?: 'dev'; }): Promise<{ pkg_id: string; version: string; action: string; controls: Record[]; }>; /** Pack definitions (and what they build on, and templates of the Workspace) as an `aiws` `.pikg` into the caller's * `exports` bucket (unsigned). */ extPack(workspace_id: string, entity_ids: string[], pkg: { name: string; version?: string; title?: string; }, templates?: AiwsTemplateExport[]): Promise; /** Rebuild imported definitions from the caller's library (same Zone; across Zones `ext.build { provenance, upgrade }`): * `EXT_LOCAL_CHANGES` when the snapshot was built locally since, unless `force`. */ extUpgrade(params: AiwsExtUpgradeParams): Promise; /** Chosen Surfaces as a template snapshot: the manifest item, the definitions it needs and the files (base64) of * `templates//`. */ extExportTemplate(params: { workspace_id: string; } & AiwsTemplateExport): Promise<{ template: AiwsTemplateItem; controls: Record[]; files: { path: string; base64: string; }[]; }>; /** A new Workspace from a template of the caller's library (installing a template never creates one). */ extCreateFromTemplate(params: { pkg_id: string; template_id: string; title?: string; params?: Record; }): Promise<{ workspace_id: string; }>; extListLibrary(): Promise<{ packages: AiwsLibraryPackage[]; }>; extUninstall(pkg_id: string): Promise>; /** A library package's controls with their bytes (base64): what a client relays into a Workspace of another Zone. */ extLibraryBundle(pkg_id: string, idents?: string[]): Promise<{ pkg_id: string; controls: Record[]; }>; /** Bring library controls into a Workspace of this Zone (one Commit). */ extImport(workspace_id: string, items: { pkg_id: string; ident: string; }[], opts?: { folder_id?: string; }): Promise; runStart(workspace_id: string, program: string, params: Record, idempotency_key: string): Promise>; runGet(workspace_id: string, run_id: string, choices?: Record): Promise>; runList(workspace_id: string, wish_id?: string, limit?: number): Promise>; runClaim(workspace_id: string, run_id: string, claim_token: string, executor?: Record): Promise<{ run_id: string; attempt: number; run_token: string; lease_until: string; lease_ms: number; }>; runHeartbeat(workspace_id: string, run_id: string, attempt: number, progress?: Record): Promise>; runReport(workspace_id: string, report: AiwsRunReport): Promise>; runApply(workspace_id: string, run_id: string, plan_digest: string, session_id?: string): Promise>; runCancel(workspace_id: string, run_id: string): Promise>; } //# sourceMappingURL=aiworkspace_client.d.ts.map