@kitionstage/sdk 0.0.0-stage → 0.5.2-stage.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -2
- package/dist/LICENSE +177 -0
- package/dist/THIRD_PARTY_NOTICES +28 -0
- package/dist/lib/assets/kitEngine.worker-3iMvwtlI.js +12732 -0
- package/dist/lib/assets/loro_wasm_bg-Gulzks_0.wasm +0 -0
- package/dist/lib/chunks/batch-BWpAyHvP.js +789 -0
- package/dist/lib/chunks/canonical-BIWfVCL-.js +87 -0
- package/dist/lib/chunks/envelope-D6MGY-ZN.js +61 -0
- package/dist/lib/chunks/replica-D8w3I4sn.js +2472 -0
- package/dist/lib/chunks/runtime-BVJHE1Pg.js +997 -0
- package/dist/lib/chunks/session-BqXC9a1-.js +281 -0
- package/dist/lib/chunks/toolIds-BCeSGHpV.js +821 -0
- package/dist/lib/chunks/workspaceTree-Destqupf.js +23 -0
- package/dist/lib/convergence/index.js +1035 -0
- package/dist/lib/convergence/node.js +8 -0
- package/dist/lib/embed-server/callbacks.js +37 -0
- package/dist/lib/embed-server/cli.js +19 -0
- package/dist/lib/embed-server/index.js +272 -0
- package/dist/lib/extensions/index.js +439 -0
- package/dist/lib/extensions/panel.html +208 -0
- package/dist/lib/extensions/runtime.js +198 -0
- package/dist/lib/extensions/sandbox.html +35 -0
- package/dist/lib/kdm/index.js +437 -0
- package/dist/lib/kit-dev-host/checkUiIds.mjs +44 -0
- package/dist/lib/kit-dev-host/index.js +308 -0
- package/dist/lib/kit-dev-host/lineRow.mjs +47 -0
- package/dist/lib/kit-dev-host/modeSmoke.mjs +178 -0
- package/dist/lib/kit-editor/index.js +6481 -0
- package/dist/lib/kit-editor/styles.css +807 -0
- package/dist/lib/kit-editor/workspaceTree.js +1 -0
- package/dist/lib/kit-engine/index.js +7 -0
- package/dist/lib/kit-host/index.js +530 -0
- package/dist/lib/kit-ui-protocol/index.js +336 -0
- package/dist/lib/node-only/embed-server-callbacks.js +2 -0
- package/dist/lib/node-only/embed-server.js +2 -0
- package/dist/lib/sync/index.js +1008 -0
- package/dist/lib/sync/openToken.js +201 -0
- package/dist/lib/sync/replicaVersions.js +51 -0
- package/dist/standalone/chunks/batch-CAGYk6m4.js +789 -0
- package/dist/standalone/chunks/client-B9xkOcvf.js +772 -0
- package/dist/standalone/chunks/collab-CTQZ9h7J.js +1022 -0
- package/dist/standalone/chunks/comment-Ds9t8xSE.js +94 -0
- package/dist/standalone/chunks/comments-uVDS8Wxp.js +41 -0
- package/dist/standalone/chunks/document-B5MMuYyN.js +324 -0
- package/dist/standalone/chunks/envelope-GX4Cynkx.js +7612 -0
- package/dist/standalone/chunks/index-BEgEEnhU.js +287 -0
- package/dist/standalone/chunks/index-EEl8hGbP.js +1967 -0
- package/dist/standalone/chunks/kits-Cp51mDlw.js +9 -0
- package/dist/standalone/chunks/replica-Di2iCPiD.js +3281 -0
- package/dist/standalone/chunks/replicaVersions-C3rJxnk9.js +50 -0
- package/dist/standalone/chunks/touched-T9jKJjxn.js +78 -0
- package/dist/standalone/index.js +12 -0
- package/dist/standalone/script/index.js +339 -0
- package/dist/standalone/script/kits/board.js +5 -0
- package/dist/standalone/script/kits/cad.js +5 -0
- package/dist/standalone/script/kits/design.js +5 -0
- package/dist/standalone/script/kits/doc.js +5 -0
- package/dist/standalone/script/kits/film.js +5 -0
- package/dist/standalone/script/kits/html.js +5 -0
- package/dist/standalone/script/kits/index.js +38 -0
- package/dist/standalone/script/kits/layout.js +5 -0
- package/dist/standalone/script/kits/motion.js +5 -0
- package/dist/standalone/script/kits/note.js +5 -0
- package/dist/standalone/script/kits/pdf.js +5 -0
- package/dist/standalone/script/kits/photo.js +5 -0
- package/dist/standalone/script/kits/scene.js +5 -0
- package/dist/standalone/script/kits/sheet.js +5 -0
- package/dist/standalone/script/kits/slide.js +5 -0
- package/dist/standalone/script/kits/table.js +5 -0
- package/dist/standalone/script/kits/vector.js +5 -0
- package/dist/standalone/script/node.js +401 -0
- package/dist/standalone/script/proxy.js +254 -0
- package/dist/types/convergence/src/adapter.d.ts +131 -0
- package/dist/types/convergence/src/engine.d.ts +66 -0
- package/dist/types/convergence/src/index.d.ts +21 -0
- package/dist/types/convergence/src/net.d.ts +52 -0
- package/dist/types/convergence/src/node.d.ts +6 -0
- package/dist/types/convergence/src/report.d.ts +56 -0
- package/dist/types/convergence/src/rng.d.ts +12 -0
- package/dist/types/convergence/src/scenarios.d.ts +15 -0
- package/dist/types/convergence/src/state.d.ts +67 -0
- package/dist/types/embed/src/agent.d.ts +88 -0
- package/dist/types/embed/src/blobs.d.ts +2 -0
- package/dist/types/embed/src/collab.d.ts +250 -0
- package/dist/types/embed/src/comments.d.ts +30 -0
- package/dist/types/embed/src/errors.d.ts +24 -0
- package/dist/types/embed/src/handlers.d.ts +92 -0
- package/dist/types/embed/src/index.d.ts +20 -0
- package/dist/types/embed/src/mount.d.ts +39 -0
- package/dist/types/embed/src/replicaStore.d.ts +3 -0
- package/dist/types/embed/src/rooms.d.ts +40 -0
- package/dist/types/embed/src/schemas.d.ts +7 -0
- package/dist/types/embed/src/syncClients.d.ts +28 -0
- package/dist/types/embed/src/theme.d.ts +7 -0
- package/dist/types/embed/src/types.d.ts +596 -0
- package/dist/types/embed/src/ui.d.ts +33 -0
- package/dist/types/embed/src/version.d.ts +2 -0
- package/dist/types/embed-server/src/callbacks.d.ts +30 -0
- package/dist/types/embed-server/src/cli.d.ts +1 -0
- package/dist/types/embed-server/src/index.d.ts +19 -0
- package/dist/types/embed-server/src/page.d.ts +15 -0
- package/dist/types/embed-server/src/server.d.ts +39 -0
- package/dist/types/embed-server/src/session.d.ts +22 -0
- package/dist/types/extensions/src/gate.d.ts +17 -0
- package/dist/types/extensions/src/generated/runtime.d.ts +8 -0
- package/dist/types/extensions/src/host.d.ts +135 -0
- package/dist/types/extensions/src/index.d.ts +13 -0
- package/dist/types/extensions/src/manifest.d.ts +82 -0
- package/dist/types/extensions/src/protocol.d.ts +159 -0
- package/dist/types/extensions/src/rpc.d.ts +52 -0
- package/dist/types/extensions/src/runtime/document.d.ts +40 -0
- package/dist/types/extensions/src/runtime/index.d.ts +10 -0
- package/dist/types/extensions/src/runtime/panel.d.ts +19 -0
- package/dist/types/extensions/src/runtime/runtime.d.ts +54 -0
- package/dist/types/extensions/src/runtime/worker.d.ts +1 -0
- package/dist/types/extensions/src/sandbox.d.ts +41 -0
- package/dist/types/kdm/src/args.d.ts +12 -0
- package/dist/types/kdm/src/batch.d.ts +118 -0
- package/dist/types/kdm/src/canonical.d.ts +25 -0
- package/dist/types/kdm/src/comment.d.ts +114 -0
- package/dist/types/kdm/src/diff.d.ts +125 -0
- package/dist/types/kdm/src/envelope.d.ts +27 -0
- package/dist/types/kdm/src/errors.d.ts +28 -0
- package/dist/types/kdm/src/footprint.d.ts +21 -0
- package/dist/types/kdm/src/ids.d.ts +57 -0
- package/dist/types/kdm/src/index.d.ts +18 -0
- package/dist/types/kdm/src/marks.d.ts +32 -0
- package/dist/types/kdm/src/op.d.ts +124 -0
- package/dist/types/kdm/src/origin.d.ts +41 -0
- package/dist/types/kdm/src/overlay.d.ts +92 -0
- package/dist/types/kdm/src/projection.d.ts +29 -0
- package/dist/types/kdm/src/read.d.ts +90 -0
- package/dist/types/kdm/src/replica.d.ts +403 -0
- package/dist/types/kdm/src/schema.d.ts +185 -0
- package/dist/types/kdm/src/testing.d.ts +28 -0
- package/dist/types/kdm/src/toolIds.d.ts +61 -0
- package/dist/types/kdm/src/touched.d.ts +24 -0
- package/dist/types/kdm/src/tx.d.ts +215 -0
- package/dist/types/kdm/src/value.d.ts +23 -0
- package/dist/types/kit-dev-host/src/checkNoPaths.d.ts +19 -0
- package/dist/types/kit-dev-host/src/checkUiIds.d.mts +2 -0
- package/dist/types/kit-dev-host/src/index.d.ts +179 -0
- package/dist/types/kit-dev-host/src/lineRow.d.mts +14 -0
- package/dist/types/kit-dev-host/src/memoryFiles.d.ts +15 -0
- package/dist/types/kit-dev-host/src/modeSmoke.d.mts +8 -0
- package/dist/types/kit-editor/src/CommandDialog.d.ts +22 -0
- package/dist/types/kit-editor/src/CommentsPanel.d.ts +45 -0
- package/dist/types/kit-editor/src/CustomizeDialog.d.ts +32 -0
- package/dist/types/kit-editor/src/HostButtons.d.ts +11 -0
- package/dist/types/kit-editor/src/RenderFailure.d.ts +7 -0
- package/dist/types/kit-editor/src/TextSink.d.ts +6 -0
- package/dist/types/kit-editor/src/brand.d.ts +2 -0
- package/dist/types/kit-editor/src/catalogMenus.d.ts +27 -0
- package/dist/types/kit-editor/src/chart.d.ts +138 -0
- package/dist/types/kit-editor/src/conflicts.d.ts +12 -0
- package/dist/types/kit-editor/src/drawing.d.ts +83 -0
- package/dist/types/kit-editor/src/editor.d.ts +544 -0
- package/dist/types/kit-editor/src/engine/KitCanvas.d.ts +70 -0
- package/dist/types/kit-editor/src/engine/backdrop.d.ts +32 -0
- package/dist/types/kit-editor/src/engine/createKitFile.d.ts +12 -0
- package/dist/types/kit-editor/src/engine/decorations.d.ts +14 -0
- package/dist/types/kit-editor/src/engine/engineOverlays.d.ts +197 -0
- package/dist/types/kit-editor/src/engine/engineTools.d.ts +116 -0
- package/dist/types/kit-editor/src/engine/kitDraft.d.ts +70 -0
- package/dist/types/kit-editor/src/engine/kitEngine.d.ts +390 -0
- package/dist/types/kit-editor/src/engine/kitEngine.worker.d.ts +30 -0
- package/dist/types/kit-editor/src/engine/kitHost.d.ts +41 -0
- package/dist/types/kit-editor/src/engine/kitModel.d.ts +32 -0
- package/dist/types/kit-editor/src/engine/kitModelRunner.d.ts +99 -0
- package/dist/types/kit-editor/src/engine/kitModule.d.ts +185 -0
- package/dist/types/kit-editor/src/engine/kitShortcuts.d.ts +32 -0
- package/dist/types/kit-editor/src/engine/kitTools.d.ts +79 -0
- package/dist/types/kit-editor/src/engine/lazyFonts.d.ts +34 -0
- package/dist/types/kit-editor/src/engine/lentFiles.d.ts +29 -0
- package/dist/types/kit-editor/src/engine/rasterViewport.d.ts +178 -0
- package/dist/types/kit-editor/src/engine/readOnly.d.ts +78 -0
- package/dist/types/kit-editor/src/engine/refusal.d.ts +39 -0
- package/dist/types/kit-editor/src/engine/replica.d.ts +23 -0
- package/dist/types/kit-editor/src/engine/useKitDocument.d.ts +154 -0
- package/dist/types/kit-editor/src/engine/workerRelay.d.ts +62 -0
- package/dist/types/kit-editor/src/files.d.ts +74 -0
- package/dist/types/kit-editor/src/frame/EditorFrame.d.ts +74 -0
- package/dist/types/kit-editor/src/frame/FocusBar.d.ts +10 -0
- package/dist/types/kit-editor/src/frame/MenuNodes.d.ts +20 -0
- package/dist/types/kit-editor/src/frame/MenuRibbon.d.ts +8 -0
- package/dist/types/kit-editor/src/frame/ModeButton.d.ts +7 -0
- package/dist/types/kit-editor/src/frame/menus.d.ts +64 -0
- package/dist/types/kit-editor/src/frame/modes.d.ts +51 -0
- package/dist/types/kit-editor/src/frame/useFrameLayout.d.ts +34 -0
- package/dist/types/kit-editor/src/host.d.ts +127 -0
- package/dist/types/kit-editor/src/index.d.ts +85 -0
- package/dist/types/kit-editor/src/ink.d.ts +26 -0
- package/dist/types/kit-editor/src/lease.d.ts +53 -0
- package/dist/types/kit-editor/src/oneInFlight.d.ts +7 -0
- package/dist/types/kit-editor/src/phrases.d.ts +25 -0
- package/dist/types/kit-editor/src/presence.d.ts +79 -0
- package/dist/types/kit-editor/src/strings.d.ts +6 -0
- package/dist/types/kit-editor/src/toolIcons.d.ts +32 -0
- package/dist/types/kit-editor/src/uiCatalog.d.ts +59 -0
- package/dist/types/kit-editor/src/uiConfig.d.ts +53 -0
- package/dist/types/kit-editor/src/uiContext.d.ts +65 -0
- package/dist/types/kit-editor/src/uiStore.d.ts +20 -0
- package/dist/types/kit-editor/src/useCommentAnchors.d.ts +29 -0
- package/dist/types/kit-editor/src/useKitSession.d.ts +115 -0
- package/dist/types/kit-editor/src/workspaceTree.d.ts +5 -0
- package/dist/types/kit-engine/src/contract.d.ts +154 -0
- package/dist/types/kit-engine/src/index.d.ts +2 -0
- package/dist/types/kit-engine/src/session.d.ts +133 -0
- package/dist/types/kit-host/src/files.d.ts +163 -0
- package/dist/types/kit-host/src/index.d.ts +315 -0
- package/dist/types/kit-ui-protocol/src/index.d.ts +1145 -0
- package/dist/types/loro-crdt.d.ts +9 -0
- package/dist/types/script/kits/board.d.ts +534 -0
- package/dist/types/script/kits/cad.d.ts +2937 -0
- package/dist/types/script/kits/design.d.ts +3213 -0
- package/dist/types/script/kits/doc.d.ts +2575 -0
- package/dist/types/script/kits/film.d.ts +4067 -0
- package/dist/types/script/kits/html.d.ts +38 -0
- package/dist/types/script/kits/index.d.ts +20 -0
- package/dist/types/script/kits/layout.d.ts +3483 -0
- package/dist/types/script/kits/motion.d.ts +4826 -0
- package/dist/types/script/kits/note.d.ts +631 -0
- package/dist/types/script/kits/pdf.d.ts +829 -0
- package/dist/types/script/kits/photo.d.ts +7574 -0
- package/dist/types/script/kits/scene.d.ts +2962 -0
- package/dist/types/script/kits/sheet.d.ts +2419 -0
- package/dist/types/script/kits/slide.d.ts +1894 -0
- package/dist/types/script/kits/table.d.ts +654 -0
- package/dist/types/script/kits/vector.d.ts +5167 -0
- package/dist/types/script/src/agentRelay.d.ts +48 -0
- package/dist/types/script/src/capabilities.d.ts +21 -0
- package/dist/types/script/src/document.d.ts +87 -0
- package/dist/types/script/src/drafts.d.ts +141 -0
- package/dist/types/script/src/exchange.d.ts +30 -0
- package/dist/types/script/src/headless.d.ts +190 -0
- package/dist/types/script/src/index.d.ts +15 -0
- package/dist/types/script/src/kitModel.d.ts +17 -0
- package/dist/types/script/src/kits.d.ts +8 -0
- package/dist/types/script/src/node.d.ts +42 -0
- package/dist/types/script/src/port.d.ts +89 -0
- package/dist/types/script/src/proxy.d.ts +132 -0
- package/dist/types/script/src/room.d.ts +162 -0
- package/dist/types/script/src/sources.d.ts +73 -0
- package/dist/types/sync/src/backoff.d.ts +9 -0
- package/dist/types/sync/src/blobSection.d.ts +23 -0
- package/dist/types/sync/src/capabilities.d.ts +20 -0
- package/dist/types/sync/src/client.d.ts +253 -0
- package/dist/types/sync/src/framing.d.ts +35 -0
- package/dist/types/sync/src/hash.d.ts +2 -0
- package/dist/types/sync/src/index.d.ts +19 -0
- package/dist/types/sync/src/leases.d.ts +82 -0
- package/dist/types/sync/src/openToken.d.ts +104 -0
- package/dist/types/sync/src/protocol.d.ts +484 -0
- package/dist/types/sync/src/relay.d.ts +52 -0
- package/dist/types/sync/src/replicaVersions.d.ts +17 -0
- package/dist/types/sync/src/saveMachine.d.ts +83 -0
- package/dist/types/sync/src/saveRun.d.ts +52 -0
- package/dist/types/sync/src/transport.d.ts +19 -0
- package/package.json +229 -4
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host's side of the Kit UI protocol (Kition platform docs/platform/reference/ui-protocol.md): mount an embedded kit UI in an
|
|
3
|
+
* iframe, hand it its port, initialize it with the document, theme, and locale, and serve its
|
|
4
|
+
* file calls with the host's own handlers. Framework-free.
|
|
5
|
+
*/
|
|
6
|
+
import { KIT_UI_PROTOCOL, KitRpcError, LEASE_HELD_REASON, type AiRunParams, type AiRunResult, type AiStep, type DocumentState, type InitializeResult, type KitConflict, type KitDocumentInit, type KitLease, type KitLinksPickParams, type KitNotifications, type KitPeerPresence, type KitPresence, type KitPresenceCaret, type KitSchemaReport, type KitTheme, type KitToHost, type KitUiConfig, type KitUiElement, type KitView, type DraftComparison, type DraftInfo, type DraftOrigin, type DraftSummary, type ModelBatchParams, type ModelBatchResult, type StoredReplica, type KitDiagnostic, type KitCommentAnchor, type KitHostService, type KitHostServices, type KitShownThread } from '../../kit-ui-protocol/src/index.js';
|
|
7
|
+
import { type KitFileSession, type KitFilesOptions } from './files.js';
|
|
8
|
+
export { KIT_UI_PROTOCOL, KitRpcError, LEASE_HELD_REASON };
|
|
9
|
+
export { fileErrorReason, hostRequestErrorReason, isGeneratePurpose, ACTION_ERROR_REASONS, GENERATE_ERROR_REASONS, GENERATE_PURPOSES } from '../../kit-ui-protocol/src/index.js';
|
|
10
|
+
export { extensionOf, fileError, openFileSession, sanitizeFileName, unusedName, FILES_METHODS } from './files.js';
|
|
11
|
+
export type { FilesMethod, KitFileCommitMode, KitFileEntry, KitFileGrant, KitFileGrantFlow, KitFileRef, KitFileSession, KitFileStaging, KitFilesManifest, KitFilesOptions, KitFilesStorage } from './files.js';
|
|
12
|
+
export type { KitFileErrorReason, KitFileRight, KitFileStat, KitFilesPickParams } from '../../kit-ui-protocol/src/index.js';
|
|
13
|
+
export type { KitActionErrorReason, KitActionParams, KitActionResult, KitDefinedGeneratePurpose, KitGenerateErrorReason, KitGenerateMessage, KitGenerateParams, KitGeneratePart, KitGeneratePurpose, KitGenerateResult } from '../../kit-ui-protocol/src/index.js';
|
|
14
|
+
export type { KitView } from '../../kit-ui-protocol/src/index.js';
|
|
15
|
+
export { parseKitView } from '../../kit-ui-protocol/src/index.js';
|
|
16
|
+
export { HOST_SERVICES, SERVICE_ERROR_REASONS, parseCommentAnchor, parseServiceParams, serviceAllowed } from '../../kit-ui-protocol/src/index.js';
|
|
17
|
+
export type { KitCommentAnchor, KitHostService, KitHostServices, KitPerson, KitServiceErrorReason, KitServiceParams, KitServiceResult, KitShownThread } from '../../kit-ui-protocol/src/index.js';
|
|
18
|
+
export type { KitLinkRef, KitLinksPickParams, KitOpenErrorReason, KitOpenParams, KitOpenResult, KitPickedLink } from '../../kit-ui-protocol/src/index.js';
|
|
19
|
+
export { isOpenableUrl, linkPathFrom, openErrorReason, parseLinkRef, parseLinksPickParams, parseOpenParams, OPEN_ERROR_REASONS, OPEN_URL_SCHEMES } from '../../kit-ui-protocol/src/index.js';
|
|
20
|
+
export type { KitFetchImageErrorReason, KitFetchImageResult, KitFetchImageType } from '../../kit-ui-protocol/src/index.js';
|
|
21
|
+
export { FETCH_IMAGE_ERROR_REASONS, FETCH_IMAGE_TYPES, fetchImageErrorReason, isFetchableUrl } from '../../kit-ui-protocol/src/index.js';
|
|
22
|
+
export type { DocumentState, DraftComparison, DraftInfo, DraftOrigin, DraftSummary, InitializeResult, KitConflict, KitDocumentInit, KitLease, KitPeerPresence, KitPresence, KitPresenceCaret, KitSchemaReport, KitTheme, KitUiConfig, KitUiElement, ModelBatchParams, ModelBatchResult, StoredReplica };
|
|
23
|
+
type Params<M extends keyof KitToHost> = KitToHost[M][0];
|
|
24
|
+
type Result<M extends keyof KitToHost> = KitToHost[M][1] | Promise<KitToHost[M][1]>;
|
|
25
|
+
/** What the host does for the kit. Every path is workspace-relative; the host checks it (UI-H2). */
|
|
26
|
+
export type KitHostHandlers = {
|
|
27
|
+
read: (params: Params<'host/read'>) => Result<'host/read'>;
|
|
28
|
+
stamp: (params: Params<'host/stamp'>) => Result<'host/stamp'>;
|
|
29
|
+
write: (params: Params<'host/write'>) => Result<'host/write'>;
|
|
30
|
+
pick?: (params: Params<'host/pick'>) => Result<'host/pick'>;
|
|
31
|
+
openAgent?: (params: Params<'host/openAgent'>) => void | Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* The document's stored replica and its keeping (capability `replica`, with `replicaWrite`):
|
|
34
|
+
* `null` when none is stored. The kit decides whether it still belongs to the file.
|
|
35
|
+
*/
|
|
36
|
+
replicaRead?: (params: Params<'host/replicaRead'>) => Result<'host/replicaRead'>;
|
|
37
|
+
replicaWrite?: (params: Params<'host/replicaWrite'>) => void | Promise<void>;
|
|
38
|
+
/** `replica/changed`: the replica's version after an edit, for collaboration. */
|
|
39
|
+
replicaChanged?: (params: KitNotifications['replica/changed']) => void;
|
|
40
|
+
/** `document/changed`: show the unsaved mark, tell the agent. */
|
|
41
|
+
changed: (state: KitNotifications['document/changed']) => void;
|
|
42
|
+
notify?: (notice: KitNotifications['host/notify']) => void;
|
|
43
|
+
/** A host shortcut pressed inside the kit (UI-K5). */
|
|
44
|
+
shortcut?: (key: KitNotifications['host/shortcut']) => void;
|
|
45
|
+
/** `host/customize`: keep the person's hides for this kit (capability `customize`, section 9). */
|
|
46
|
+
customize?: (params: Params<'host/customize'>) => void | Promise<void>;
|
|
47
|
+
/** `ui/action`: one of the host's buttons was pressed. */
|
|
48
|
+
action?: (params: KitNotifications['ui/action']) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Leases on the document's scopes (capability `lease`, section 7b): `acquire` takes or renews
|
|
51
|
+
* one and keeps it until `release` (or the kit closes, when the host releases what it still
|
|
52
|
+
* holds for it); answers `{ lease: null }` when nobody is there to coordinate with. A refusal
|
|
53
|
+
* throws a `KitRpcError` whose `data` is `{ reason: 'held', lease }` (or `{ reason: 'read-only' }`).
|
|
54
|
+
* `list` is the document's leases now; `KitConnection.leasesChanged` tells the kit of changes.
|
|
55
|
+
*/
|
|
56
|
+
leases?: {
|
|
57
|
+
acquire: (params: Params<'host/leaseAcquire'>) => Result<'host/leaseAcquire'>;
|
|
58
|
+
release: (params: Params<'host/leaseRelease'>) => void | Promise<void>;
|
|
59
|
+
list: () => KitLease[] | Promise<KitLease[]>;
|
|
60
|
+
};
|
|
61
|
+
/** `document/conflicts`: the document's unresolved conflict objects (section 7c). */
|
|
62
|
+
conflicts?: (params: KitNotifications['document/conflicts']) => void;
|
|
63
|
+
/**
|
|
64
|
+
* `document/schema`: a newer kit edited the document (section 7f; KitModel rule M5a),
|
|
65
|
+
* checked. The host tells the person and offers the update, without blocking editing.
|
|
66
|
+
*/
|
|
67
|
+
schema?: (params: KitNotifications['document/schema']) => void;
|
|
68
|
+
/** `draft/changed`: the agent's draft opened, changed, became ready, or closed (section 7d). */
|
|
69
|
+
draftChanged?: (params: KitNotifications['draft/changed']) => void;
|
|
70
|
+
/**
|
|
71
|
+
* `presence/set`: what the person shares with the other people in the document (capability
|
|
72
|
+
* `presence`, section 7e), checked; the host relays it to them. `KitConnection.peersChanged`
|
|
73
|
+
* tells the kit what they share.
|
|
74
|
+
*/
|
|
75
|
+
presence?: (presence: KitPresence) => void;
|
|
76
|
+
/**
|
|
77
|
+
* `host/generate`: run a model for the kit with the person's settings (capability `generate`,
|
|
78
|
+
* section 7j). Refuse with a `KitRpcError(-32000, …, { reason })`, `reason` one of
|
|
79
|
+
* `GENERATE_ERROR_REASONS`. Never give the kit a key or an endpoint (UI-G2). A purpose that is
|
|
80
|
+
* neither defined nor the kit's own (`isGeneratePurpose`) is refused as `not-allowed` before
|
|
81
|
+
* it gets here; the host MAY refuse a kit's own purpose too, and serves every defined one.
|
|
82
|
+
*/
|
|
83
|
+
generate?: (params: Params<'host/generate'>) => Result<'host/generate'>;
|
|
84
|
+
/**
|
|
85
|
+
* `host/action`: the host's actions by id, each listed as capability `action:<id>` (section
|
|
86
|
+
* 7j), such as `workflow.run` and `design.fromRecord`. An id the host does not serve is refused
|
|
87
|
+
* with reason `not-allowed`.
|
|
88
|
+
*/
|
|
89
|
+
actions?: Record<string, (params: Record<string, unknown>) => Result<'host/action'>>;
|
|
90
|
+
/**
|
|
91
|
+
* `host/service`: the host's services by id (section 7k; managed co-editing
|
|
92
|
+
* D4), each listed as capability `service:<id>`. Params arrive checked (`parseServiceParams`,
|
|
93
|
+
* UI-V3); a service not served is refused `not-allowed`.
|
|
94
|
+
*/
|
|
95
|
+
services?: {
|
|
96
|
+
[S in KitHostService]?: (params: KitHostServices[S][0]) => KitHostServices[S][1] | Promise<KitHostServices[S][1]>;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* The host keeps comment threads itself (capability `comment-anchors`, section 7k):
|
|
100
|
+
* `activated` hears the person click a thread's marker in the kit. Show threads with
|
|
101
|
+
* `KitConnection.showComments`.
|
|
102
|
+
*/
|
|
103
|
+
comments?: {
|
|
104
|
+
activated: (id: string) => void;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* `host/open`: open a workspace file in the host (capability `open-file`, section 7i; KitLinks
|
|
108
|
+
* 1.0 OP1 to OP5), with its `view` (OP3), creating a missing one when asked (OP4). The params
|
|
109
|
+
* arrive checked (`parseOpenParams`); the host resolves the link against the document's folder,
|
|
110
|
+
* keeps it inside the workspace (UI-H2), and refuses with a `KitRpcError(-32000, …, { reason })`,
|
|
111
|
+
* `reason` one of `OPEN_ERROR_REASONS`.
|
|
112
|
+
*/
|
|
113
|
+
open?: (params: Params<'host/open'>) => Result<'host/open'>;
|
|
114
|
+
/**
|
|
115
|
+
* `host/openUrl`: open a web address in the system's browser or mail client after the person
|
|
116
|
+
* confirmed it (capability `open-url`; OP6 to OP9). Only `https:`, `http:`, and `mailto:` reach
|
|
117
|
+
* it: others are refused as `not-allowed` before (OP7).
|
|
118
|
+
*/
|
|
119
|
+
openUrl?: (params: Params<'host/openUrl'>) => Result<'host/openUrl'>;
|
|
120
|
+
/**
|
|
121
|
+
* `host/fetchImage`: download a picture the person pasted or dropped by its web address
|
|
122
|
+
* (capability `fetch-image`, section 7l), from public addresses only: never the person's
|
|
123
|
+
* computer or local network, at every redirect. Only `https:` and `http:` reach it, and only
|
|
124
|
+
* for a document the kit may edit; an answer whose `mime` is not in `FETCH_IMAGE_TYPES` is
|
|
125
|
+
* refused as `unsupported`. Refuse with `KitRpcError(-32000, …, { reason })`, `reason` one of
|
|
126
|
+
* `FETCH_IMAGE_ERROR_REASONS`.
|
|
127
|
+
*/
|
|
128
|
+
fetchImage?: (params: Params<'host/fetchImage'>) => Result<'host/fetchImage'>;
|
|
129
|
+
/**
|
|
130
|
+
* `links/pick`: the host's chooser of existing workspace files to link (capability `links-pick`,
|
|
131
|
+
* section 7i; UI-N2 to UI-N4), never copied. The params arrive checked (`parseLinksPickParams`);
|
|
132
|
+
* the handler answers the chosen files' workspace paths and versions (none when the person
|
|
133
|
+
* cancels), and `mountKit` turns them into document-relative links, leaving out hidden paths,
|
|
134
|
+
* the document itself, and files outside `accept`. Not listed, and refused as `read-only`, for
|
|
135
|
+
* a read-only document. The host serves `host/read` and `host/stamp` of the paths it answers (UI-N3).
|
|
136
|
+
*/
|
|
137
|
+
pickLinks?: (params: KitLinksPickParams) => PickedWorkspaceFile[] | Promise<PickedWorkspaceFile[]>;
|
|
138
|
+
};
|
|
139
|
+
/** A file the person chose in the host's `links/pick` chooser: its workspace path and version stamp. */
|
|
140
|
+
export type PickedWorkspaceFile = {
|
|
141
|
+
path: string;
|
|
142
|
+
version: string | null;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* The links `links/pick` answers for the files a host's chooser returned (UI-N2): each in the
|
|
146
|
+
* document-relative form, once, without hidden paths (LR2), the document itself, or a file whose
|
|
147
|
+
* extension is not in `accept`; only the first unless `multiple`.
|
|
148
|
+
*/
|
|
149
|
+
export declare function pickedLinks(documentPath: string, params: KitLinksPickParams, chosen: PickedWorkspaceFile[]): {
|
|
150
|
+
path: string;
|
|
151
|
+
name: string;
|
|
152
|
+
version: string | null;
|
|
153
|
+
}[];
|
|
154
|
+
export type MountOptions = {
|
|
155
|
+
/** The kit UI's origin, for the handshake (`location.origin` for a kit served by the host). */
|
|
156
|
+
origin: string;
|
|
157
|
+
host: {
|
|
158
|
+
name: string;
|
|
159
|
+
version: string;
|
|
160
|
+
};
|
|
161
|
+
document: KitDocumentInit;
|
|
162
|
+
theme: KitTheme;
|
|
163
|
+
locale: string;
|
|
164
|
+
shortcuts: string[];
|
|
165
|
+
/** The UI configuration (protocol section 9). */
|
|
166
|
+
ui?: KitUiConfig;
|
|
167
|
+
/** The capability sets the host serves (`ui/initialize` `capabilitySets`), such as `KitCollab 1.0`. */
|
|
168
|
+
capabilitySets?: string[];
|
|
169
|
+
handlers: KitHostHandlers;
|
|
170
|
+
/**
|
|
171
|
+
* Serves KitFiles 1.0 (`files/*`, protocol section 7g): the host's storage, the kit manifest's
|
|
172
|
+
* `files` lists, its picker and printer. Lists `files`, and `files-pick` and `print` when it
|
|
173
|
+
* has them. Each kit document the frame loads gets its own grant table, ended with it.
|
|
174
|
+
*/
|
|
175
|
+
files?: KitFilesOptions;
|
|
176
|
+
/** How long the kit may take to open the document. */
|
|
177
|
+
timeoutMs?: number;
|
|
178
|
+
/** Abandons the mount (the frame went away first): stops listening and rejects. */
|
|
179
|
+
signal?: AbortSignal;
|
|
180
|
+
};
|
|
181
|
+
/** A mounted kit UI. */
|
|
182
|
+
export type KitConnection = {
|
|
183
|
+
kit: InitializeResult['kit'];
|
|
184
|
+
capabilities: string[];
|
|
185
|
+
state: () => Promise<DocumentState>;
|
|
186
|
+
save: () => Promise<{
|
|
187
|
+
saved: boolean;
|
|
188
|
+
version: string | null;
|
|
189
|
+
}>;
|
|
190
|
+
fileChanged: (version: string) => void;
|
|
191
|
+
/** Tells the kit the file is now `version` and its document already holds it (`document/held`): no conflict. */
|
|
192
|
+
fileHeld: (version: string) => void;
|
|
193
|
+
setTheme: (theme: KitTheme) => void;
|
|
194
|
+
setLocale: (locale: string) => void;
|
|
195
|
+
focus: () => void;
|
|
196
|
+
/**
|
|
197
|
+
* Replaces the UI configuration (`ui/configure`). A host that mounts the kit again passes its
|
|
198
|
+
* latest configuration as the `ui` option.
|
|
199
|
+
*/
|
|
200
|
+
configure: (ui: KitUiConfig) => void;
|
|
201
|
+
/** Tells the kit the document's leases changed (`lease/changed`, capability `lease`). */
|
|
202
|
+
leasesChanged: (leases: KitLease[]) => void;
|
|
203
|
+
/** Tells the kit who else is in the document and what they share (`presence/peers`, capability `presence`): the whole list. */
|
|
204
|
+
peersChanged: (peers: KitPeerPresence[]) => void;
|
|
205
|
+
/**
|
|
206
|
+
* Shows `view` in the open document (`document/reveal`, section 7i, OP3), as the `document.view`
|
|
207
|
+
* a new editor opens at. A kit that cannot show it ignores it.
|
|
208
|
+
*/
|
|
209
|
+
reveal: (view: KitView) => void;
|
|
210
|
+
/** Tells the kit the host's threads to mark (`comments/show`, capability `comment-anchors`): the whole list; malformed anchors are left out. */
|
|
211
|
+
showComments: (threads: KitShownThread[]) => void;
|
|
212
|
+
/** Whether the kit finds each anchor now (`comments/locate`); all `false` from a kit without `comment-anchors`. */
|
|
213
|
+
locateComments: (anchors: KitCommentAnchor[]) => Promise<boolean[]>;
|
|
214
|
+
/**
|
|
215
|
+
* Hears every `presence/set` the kit sends (what the person selected, where their caret is),
|
|
216
|
+
* checked; answers an unsubscribe. The object model's `selection` event follows it.
|
|
217
|
+
*/
|
|
218
|
+
onPresence: (listener: (presence: KitPresence) => void) => () => void;
|
|
219
|
+
/** The editor's elements (`ui/elements`). Rejects with -32601 when the kit did not declare its UI. */
|
|
220
|
+
elements: () => Promise<KitUiElement[]>;
|
|
221
|
+
/**
|
|
222
|
+
* The engine's diagnostics on the document (`document/check`, capability `check`), errors first;
|
|
223
|
+
* `draft` checks the agent's draft. A kit without the capability answers no diagnostics here.
|
|
224
|
+
*/
|
|
225
|
+
check: (options?: {
|
|
226
|
+
draft?: boolean;
|
|
227
|
+
}) => Promise<KitDiagnostic[]>;
|
|
228
|
+
/**
|
|
229
|
+
* The Kit AI bridge; `draft` (capability `draft`) works on the agent's draft instead of the live
|
|
230
|
+
* document. `run`'s steps are the agent's, or with `origin: 'system'` the host's
|
|
231
|
+
* own change, recorded with `originLabel` (`host` when absent) and no undo step in any history.
|
|
232
|
+
* Only the host's own features send `origin`, never a model's call.
|
|
233
|
+
*/
|
|
234
|
+
ai: {
|
|
235
|
+
inspect: (options?: {
|
|
236
|
+
draft?: boolean;
|
|
237
|
+
context?: AiStep['context'];
|
|
238
|
+
part?: number;
|
|
239
|
+
}) => Promise<Record<string, unknown>>;
|
|
240
|
+
commands: (query: string) => Promise<Array<Record<string, unknown>>>;
|
|
241
|
+
run: (steps: AiStep[], save: boolean, options?: Pick<AiRunParams, 'draft' | 'origin' | 'originLabel'>) => Promise<AiRunResult>;
|
|
242
|
+
preview: (maxSize: number, options?: {
|
|
243
|
+
draft?: boolean;
|
|
244
|
+
}) => Promise<{
|
|
245
|
+
png: string;
|
|
246
|
+
}>;
|
|
247
|
+
/** (2.9, capability `changes`) The replica's version, base64: what `changes` takes back. */
|
|
248
|
+
version: () => Promise<string>;
|
|
249
|
+
/** Read-only callbacks for the SDK premise guard (capability `premises`). */
|
|
250
|
+
premise: (method: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
251
|
+
/**
|
|
252
|
+
* (2.9, capability `changes`) What changed since the version `since`: the change set and the
|
|
253
|
+
* version now, or `changes: null` and why. `schema` is the kit's, as for `model.describe`.
|
|
254
|
+
*/
|
|
255
|
+
changes: (since: string, schema?: object) => Promise<{
|
|
256
|
+
changes: Record<string, unknown> | null;
|
|
257
|
+
unavailable?: string;
|
|
258
|
+
version: string;
|
|
259
|
+
}>;
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* The agent's draft, when the kit lists the `draft` capability (section 7d). `ready` and
|
|
263
|
+
* `reopen` may be the agent's; `merge` and `discard` MUST come from the person's explicit
|
|
264
|
+
* approval, never from a model.
|
|
265
|
+
*/
|
|
266
|
+
draft: {
|
|
267
|
+
state: () => Promise<DraftInfo>;
|
|
268
|
+
ready: () => Promise<DraftInfo>;
|
|
269
|
+
reopen: () => Promise<DraftInfo>;
|
|
270
|
+
compare: (options?: {
|
|
271
|
+
maxSize?: number;
|
|
272
|
+
schema?: object;
|
|
273
|
+
}) => Promise<DraftComparison>;
|
|
274
|
+
merge: (origin: DraftOrigin, schema?: object) => Promise<{
|
|
275
|
+
merged: boolean;
|
|
276
|
+
summary: DraftSummary;
|
|
277
|
+
}>;
|
|
278
|
+
discard: () => Promise<DraftInfo>;
|
|
279
|
+
};
|
|
280
|
+
/** The document's KDM replica, when the kit declares the `replica` capability. */
|
|
281
|
+
replica: {
|
|
282
|
+
version: () => Promise<ArrayBuffer>;
|
|
283
|
+
exportChanges: (since: ArrayBuffer) => Promise<{
|
|
284
|
+
changes: ArrayBuffer;
|
|
285
|
+
blobs: ArrayBuffer;
|
|
286
|
+
}>;
|
|
287
|
+
importChanges: (changes: ArrayBuffer, blobs: ArrayBuffer) => Promise<{
|
|
288
|
+
damage: unknown;
|
|
289
|
+
}>;
|
|
290
|
+
/** The replica's own id, when the kit's engine has one; `null` otherwise. */
|
|
291
|
+
info: () => Promise<string | null>;
|
|
292
|
+
/** Hears every `replica/changed` (the replica's version after an edit); answers an unsubscribe. */
|
|
293
|
+
onChanged: (listener: (version: ArrayBuffer) => void) => () => void;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* The object model answered by the kit itself, when it lists the `model` capability (section
|
|
297
|
+
* 7a): a batch is one undo step of the kit's own history. A refused batch rejects with a
|
|
298
|
+
* `KitRpcError` whose `data` is `{ code, index, message }`.
|
|
299
|
+
*/
|
|
300
|
+
model: {
|
|
301
|
+
describe: (schema?: object) => Promise<Record<string, unknown>>;
|
|
302
|
+
batch: (params: ModelBatchParams) => Promise<ModelBatchResult>;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* The session's file grants, when the host serves `files` (KitFiles 1.0): grant a handle for an
|
|
306
|
+
* agent's `file` parameter or a drop, revoke handles, list what the kit holds (FA16).
|
|
307
|
+
*/
|
|
308
|
+
files: Pick<KitFileSession, 'grant' | 'revoke' | 'grants'> | null;
|
|
309
|
+
close: () => void;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Hands `frame` (already loaded with the kit's UI entry) its port and initializes it. Resolves
|
|
313
|
+
* when the kit has opened the document; rejects with the kit's error otherwise.
|
|
314
|
+
*/
|
|
315
|
+
export declare function mountKit(frame: HTMLIFrameElement, options: MountOptions): Promise<KitConnection>;
|