@hollis-labs/surface-page 0.3.0 → 0.4.1
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/dist/chunks/chunk-LODRWYOW.js +2060 -0
- package/dist/gallery.js +491 -310
- package/dist/index.js +385 -387
- package/dist/registry-items.json +3 -0
- package/dist/sdk.js +13 -1
- package/dist/types/agent/api.d.ts +34 -2
- package/dist/types/agent/session.d.ts +2 -5
- package/dist/types/cards/store.d.ts +13 -1
- package/dist/types/cards/views.d.ts +3 -2
- package/dist/types/cite/core/detect.d.ts +26 -0
- package/dist/types/cite/core/index.d.ts +17 -0
- package/dist/types/cite/core/kinds/caster.d.ts +3 -0
- package/dist/types/cite/core/kinds/fragment.d.ts +3 -0
- package/dist/types/cite/core/kinds/ops.d.ts +3 -0
- package/dist/types/cite/core/kinds/path.d.ts +8 -0
- package/dist/types/cite/core/kinds/registry.d.ts +3 -0
- package/dist/types/cite/core/kinds/tesseract.d.ts +11 -0
- package/dist/types/cite/core/kinds/tether.d.ts +4 -0
- package/dist/types/cite/core/kinds/torque.d.ts +11 -0
- package/dist/types/cite/core/kinds/url.d.ts +2 -0
- package/dist/types/cite/core/kinds/work.d.ts +3 -0
- package/dist/types/cite/core/preview.d.ts +8 -0
- package/dist/types/cite/core/registry.d.ts +19 -0
- package/dist/types/cite/core/resolver.d.ts +34 -0
- package/dist/types/cite/core/scan-utils.d.ts +9 -0
- package/dist/types/cite/core/tach.d.ts +3 -0
- package/dist/types/cite/core/types.d.ts +161 -0
- package/dist/types/cite/record.d.ts +11 -0
- package/dist/types/cite/remark.d.ts +32 -0
- package/dist/types/cite/store.d.ts +35 -0
- package/dist/types/cite/structured-view.d.ts +9 -0
- package/dist/types/cite/structured.d.ts +90 -0
- package/dist/types/cite/terminal.d.ts +15 -0
- package/dist/types/cite/ui.d.ts +52 -0
- package/dist/types/gallery/Gallery.d.ts +5 -0
- package/dist/types/gallery/cite.d.ts +1 -0
- package/dist/types/sdk/index.d.ts +3 -0
- package/dist/types/sdk/types.d.ts +37 -0
- package/package.json +5 -5
- package/dist/chunks/chunk-ZT6LTRMY.js +0 -220
package/dist/registry-items.json
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
"card-plan",
|
|
15
15
|
"card-progress",
|
|
16
16
|
"card-prompt",
|
|
17
|
+
"cite-card",
|
|
18
|
+
"cite-chip",
|
|
17
19
|
"command",
|
|
18
20
|
"conversation",
|
|
19
21
|
"dialog",
|
|
@@ -21,6 +23,7 @@
|
|
|
21
23
|
"empty",
|
|
22
24
|
"genui-surface",
|
|
23
25
|
"guide-bar",
|
|
26
|
+
"hover-card",
|
|
24
27
|
"input",
|
|
25
28
|
"item",
|
|
26
29
|
"kbd",
|
package/dist/sdk.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApiError,
|
|
3
|
+
CiteRef,
|
|
4
|
+
CiteText,
|
|
3
5
|
Icon,
|
|
6
|
+
RecordBody,
|
|
4
7
|
addMark,
|
|
8
|
+
citeMarkdownExtensions,
|
|
9
|
+
citeTerminalLinks,
|
|
10
|
+
remarkCite,
|
|
5
11
|
replyMark,
|
|
6
12
|
resolveMark,
|
|
7
13
|
setSetting,
|
|
@@ -9,11 +15,17 @@ import {
|
|
|
9
15
|
useEvent,
|
|
10
16
|
useMarks,
|
|
11
17
|
useSetting
|
|
12
|
-
} from "./chunks/chunk-
|
|
18
|
+
} from "./chunks/chunk-LODRWYOW.js";
|
|
13
19
|
export {
|
|
14
20
|
ApiError,
|
|
21
|
+
CiteRef,
|
|
22
|
+
CiteText,
|
|
15
23
|
Icon,
|
|
24
|
+
RecordBody,
|
|
16
25
|
addMark,
|
|
26
|
+
citeMarkdownExtensions,
|
|
27
|
+
citeTerminalLinks,
|
|
28
|
+
remarkCite,
|
|
17
29
|
replyMark,
|
|
18
30
|
resolveMark,
|
|
19
31
|
setSetting,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The agent's own routes beside the
|
|
2
|
+
* The agent's own routes beside the conversation wire (core/internal/agent/http.go).
|
|
3
3
|
*/
|
|
4
4
|
/** One active slot (slots.SlotView). */
|
|
5
5
|
export interface SlotView {
|
|
@@ -30,6 +30,8 @@ export interface Assembly {
|
|
|
30
30
|
layout?: string;
|
|
31
31
|
reminders?: string[];
|
|
32
32
|
block: string;
|
|
33
|
+
/** The module whose agent profile the next turn runs as; absent: the app's own. */
|
|
34
|
+
profile?: string;
|
|
33
35
|
}
|
|
34
36
|
/** One slot in the app (agent.SlotInfo). */
|
|
35
37
|
export interface SlotInfo {
|
|
@@ -41,14 +43,41 @@ export interface SlotInfo {
|
|
|
41
43
|
note?: string;
|
|
42
44
|
active: boolean;
|
|
43
45
|
}
|
|
46
|
+
/** One module agent profile (agent.ProfileInfo). */
|
|
47
|
+
export interface ProfileInfo {
|
|
48
|
+
id: string;
|
|
49
|
+
title: string;
|
|
50
|
+
name: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
skills: string[];
|
|
53
|
+
variants: string[];
|
|
54
|
+
tools: string[];
|
|
55
|
+
active: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** The profiles and the one in play (agent.ProfileState). */
|
|
58
|
+
export interface ProfileState {
|
|
59
|
+
/** Turns run as profiles (the Nanite runner); off, every turn is the app's own agent. */
|
|
60
|
+
on: boolean;
|
|
61
|
+
runner?: string;
|
|
62
|
+
/** id "" is the app's own; why is pinned, focus, default or off. */
|
|
63
|
+
active: {
|
|
64
|
+
id: string;
|
|
65
|
+
why: string;
|
|
66
|
+
};
|
|
67
|
+
/** A module id, "default", or absent. */
|
|
68
|
+
pinned?: string;
|
|
69
|
+
profiles: ProfileInfo[];
|
|
70
|
+
}
|
|
44
71
|
export interface Setup {
|
|
45
72
|
ready: boolean;
|
|
46
73
|
model: string;
|
|
47
74
|
config_path: string;
|
|
48
75
|
/** Why the agent cannot answer, in a sentence, when it cannot. */
|
|
49
76
|
reason?: string;
|
|
50
|
-
/** "conversation" when
|
|
77
|
+
/** "conversation" when a configured agent is available. */
|
|
51
78
|
wire?: string;
|
|
79
|
+
/** Same-origin attachment endpoint when the runner lives in Tether. */
|
|
80
|
+
wire_base?: string;
|
|
52
81
|
/** The agent's name on the conversation wire. */
|
|
53
82
|
agent?: string;
|
|
54
83
|
}
|
|
@@ -58,4 +87,7 @@ export declare const agentApi: {
|
|
|
58
87
|
slots: () => Promise<SlotInfo[]>;
|
|
59
88
|
/** Pin a slot; "" lets the window in front choose again. */
|
|
60
89
|
pin: (slot: string) => Promise<Assembly>;
|
|
90
|
+
profiles: () => Promise<ProfileState>;
|
|
91
|
+
/** Pin a profile: a module id, "default" (the app's own), or "auto" to let the window in front choose. */
|
|
92
|
+
pinProfile: (profile: string) => Promise<ProfileState>;
|
|
61
93
|
};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The page's
|
|
3
|
-
*
|
|
4
|
-
* attaches to, shared with other tabs) or the run-at-a-time one. Both stores offer the same
|
|
5
|
-
* surface, so the panel draws either; this wrapper exists because the answer arrives after
|
|
6
|
-
* the page has started, and callers want the session at once.
|
|
2
|
+
* The page's durable conversation. Setup supplies the agent and endpoint;
|
|
3
|
+
* an unconfigured app keeps the composer unavailable without opening a transport.
|
|
7
4
|
*
|
|
8
5
|
* Two address-bar switches, for looking at the conversation wire's other modes:
|
|
9
6
|
* `?chat=viewer` attaches this page as a viewer (it watches and can take over), and
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* changes; the page keeps the latest of each, and the engine from @hollis-labs/surface-cards decides
|
|
4
4
|
* where each one shows, from rules that are data.
|
|
5
5
|
*/
|
|
6
|
-
import { type CardOutcome, type CardViewModel, type Surface } from "@hollis-labs/surface-cards";
|
|
6
|
+
import { type CardDraft, type CardOutcome, type CardViewModel, type Surface } from "@hollis-labs/surface-cards";
|
|
7
7
|
/** A card as the server sends it. */
|
|
8
8
|
export interface ServerCard {
|
|
9
9
|
id: string;
|
|
@@ -22,7 +22,19 @@ export interface ServerCard {
|
|
|
22
22
|
created?: string;
|
|
23
23
|
responded?: string;
|
|
24
24
|
expires_at?: string;
|
|
25
|
+
/** Answered after its sender stopped waiting (an agent's question, abandoned or expired). */
|
|
26
|
+
late?: boolean;
|
|
27
|
+
/** When a late answer reached the agent. */
|
|
28
|
+
delivered?: string;
|
|
25
29
|
}
|
|
30
|
+
/** A closed card that still takes one late answer: the agent's question, which the agent
|
|
31
|
+
* stopped waiting for (its run ended, or its wait ran out), not long ago. */
|
|
32
|
+
export declare function lateOpen(c: ServerCard): boolean;
|
|
33
|
+
/** The card still takes an answer: it is open, or it takes a late one. */
|
|
34
|
+
export declare const isLive: (c: ServerCard) => boolean;
|
|
35
|
+
export declare const loadDraft: (id: string) => CardDraft | undefined;
|
|
36
|
+
export declare function saveDraft(id: string, draft: CardDraft): void;
|
|
37
|
+
export declare const recentlyAnsweredLate: (c: ServerCard) => boolean;
|
|
26
38
|
export declare const ANSWERABLE: string[];
|
|
27
39
|
/** Reads the open cards once and follows changes from then on. */
|
|
28
40
|
export declare function startCards(): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ViewProps } from "../sdk";
|
|
2
|
-
/** The agent's open cards, above its composer
|
|
3
|
-
*
|
|
2
|
+
/** The agent's open cards, above its composer, and its questions it stopped waiting for,
|
|
3
|
+
* which still take a late answer. A closed one leaves the dock: the conversation carries
|
|
4
|
+
* what was answered. A late answer stays a moment, to show it was sent. */
|
|
4
5
|
export declare function CardDock(): import("react").JSX.Element | null;
|
|
5
6
|
/** Cards from anything but the agent: pop-ups in the corner, and the one its sender is
|
|
6
7
|
* waiting on in the middle. Mounted once, over the whole page. */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RefRegistry } from "./registry.ts";
|
|
2
|
+
import type { RefSegment, Segment } from "./types.ts";
|
|
3
|
+
export interface DetectOptions {
|
|
4
|
+
/** Leave fenced blocks and `inline code` alone. Default true. */
|
|
5
|
+
skipCode?: boolean;
|
|
6
|
+
/** Only run these kinds. Default: all registered. */
|
|
7
|
+
kinds?: readonly string[];
|
|
8
|
+
/** Called when a kind throws or returns a malformed hit; the kind is skipped, detection continues. */
|
|
9
|
+
onError?: (kind: string, err: unknown) => void;
|
|
10
|
+
}
|
|
11
|
+
export type Range = readonly [start: number, end: number];
|
|
12
|
+
/** Ranges of code in the text, sorted and disjoint. */
|
|
13
|
+
export declare function codeRanges(text: string): Range[];
|
|
14
|
+
/** All non-overlapping reference matches, in text order. */
|
|
15
|
+
export declare function detectRefs(text: string, registry: RefRegistry, opts?: DetectOptions): RefSegment[];
|
|
16
|
+
/**
|
|
17
|
+
* Split text into alternating text and ref segments that concatenate back to
|
|
18
|
+
* the input exactly (`segments.map(s => text.slice(s.start, s.end)).join('') === text`).
|
|
19
|
+
*/
|
|
20
|
+
export declare function detect(text: string, registry: RefRegistry, opts?: DetectOptions): Segment[];
|
|
21
|
+
/** Distinct references in a set of segments, for prefetching: first occurrence order. */
|
|
22
|
+
export declare function uniqueRefs(segments: readonly Segment[]): {
|
|
23
|
+
kind: string;
|
|
24
|
+
canonical: string;
|
|
25
|
+
}[];
|
|
26
|
+
export declare function refKey(kind: string, canonical: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type RefRegistry } from "./registry.ts";
|
|
2
|
+
export { codeRanges, detect, detectRefs, refKey, uniqueRefs } from "./detect.ts";
|
|
3
|
+
export { CASTER_KIND } from "./kinds/caster.ts";
|
|
4
|
+
export { FRAGMENT_KIND } from "./kinds/fragment.ts";
|
|
5
|
+
export { OPS_WORKSTREAM_KIND } from "./kinds/ops.ts";
|
|
6
|
+
export { PATH_KIND, RELATIVE_PATH_KIND } from "./kinds/path.ts";
|
|
7
|
+
export { REGISTRY_RECORD_KIND } from "./kinds/registry.ts";
|
|
8
|
+
export { TESSERACT_ITEM_KIND, TESSERACT_KEY_KIND } from "./kinds/tesseract.ts";
|
|
9
|
+
export { TETHER_AGENT_KIND, TETHER_MESSAGE_KIND } from "./kinds/tether.ts";
|
|
10
|
+
export { WORK_ITEM_KIND } from "./kinds/work.ts";
|
|
11
|
+
export { buildPreviewCard } from "./preview.ts";
|
|
12
|
+
export { createRefRegistry, type RefRegistry } from "./registry.ts";
|
|
13
|
+
export { createRefResolverClient, type RefResolverClient, type ResolverClientOptions } from "./resolver.ts";
|
|
14
|
+
export { parseTachHref } from "./tach.ts";
|
|
15
|
+
export type * from "./types.ts";
|
|
16
|
+
/** A registry with every kind Surface knows. */
|
|
17
|
+
export declare function createDefaultRefRegistry(): RefRegistry;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RefKind } from "../types.ts";
|
|
2
|
+
export type PathStyle = "home" | "absolute" | "relative" | "repo" | "remote";
|
|
3
|
+
/** A path on this machine or a remote place: the Files module resolves it. */
|
|
4
|
+
export declare const PATH_KIND = "path";
|
|
5
|
+
/** A path relative to somewhere unknown (a repository): detected and copied, not resolved. */
|
|
6
|
+
export declare const RELATIVE_PATH_KIND = "path.relative";
|
|
7
|
+
/** Two kinds from one scan: paths Files can look up, and relative ones it cannot. */
|
|
8
|
+
export declare function createPathKinds(): RefKind[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RefKind } from "../types.ts";
|
|
2
|
+
export declare const TESSERACT_ITEM_KIND = "tesseract.item";
|
|
3
|
+
export declare const TESSERACT_KEY_KIND = "tesseract.key";
|
|
4
|
+
/** `[domain@]namespace#key`: the canonical form for a memory key. */
|
|
5
|
+
export declare function tesseractKeyCanonical(namespace: string, key: string, domain?: string): string;
|
|
6
|
+
export declare function parseTesseractKey(canonical: string): {
|
|
7
|
+
domain?: string;
|
|
8
|
+
namespace: string;
|
|
9
|
+
key: string;
|
|
10
|
+
} | null;
|
|
11
|
+
export declare function createTesseractKinds(): RefKind[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RefKind } from "../types.ts";
|
|
2
|
+
interface TorqueEntity {
|
|
3
|
+
id: string;
|
|
4
|
+
prefix: string;
|
|
5
|
+
label: string;
|
|
6
|
+
icon: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const TORQUE_ENTITIES: TorqueEntity[];
|
|
9
|
+
/** One kind per Torque entity so each resolves and caches on its own. */
|
|
10
|
+
export declare function createTorqueKinds(): RefKind[];
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RefRegistry } from "./registry.ts";
|
|
2
|
+
import type { PreviewCard, RefIdentity, RefState } from "./types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The hovercard descriptor for a reference in any state. Loading and
|
|
5
|
+
* not-found cards still carry the kind, id and open target, so the card is
|
|
6
|
+
* useful before (or without) the backend.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildPreviewCard(registry: RefRegistry, ref: RefIdentity, state: RefState): PreviewCard;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RefKind, RefKindId } from "./types.ts";
|
|
2
|
+
export interface RefRegistry {
|
|
3
|
+
/**
|
|
4
|
+
* Add a kind. Throws on a malformed or duplicate id (pass `replace: true`
|
|
5
|
+
* to swap a kind, e.g. a live scanner for a stub). Returns an unregister
|
|
6
|
+
* function so a feature can clean up after itself.
|
|
7
|
+
*/
|
|
8
|
+
register(kind: RefKind, opts?: {
|
|
9
|
+
replace?: boolean;
|
|
10
|
+
}): () => void;
|
|
11
|
+
unregister(id: RefKindId): boolean;
|
|
12
|
+
get(id: RefKindId): RefKind | undefined;
|
|
13
|
+
has(id: RefKindId): boolean;
|
|
14
|
+
/** Kinds in scan order: priority descending, then registration order. */
|
|
15
|
+
list(): RefKind[];
|
|
16
|
+
/** Bumps on every change, so memoised detectors can invalidate. */
|
|
17
|
+
readonly version: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function createRefRegistry(): RefRegistry;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { KindResolver, RefState } from "./types.ts";
|
|
2
|
+
export interface ResolverClientOptions {
|
|
3
|
+
resolvers: Record<string, KindResolver | undefined>;
|
|
4
|
+
/** Fresh time for a found entity. Default 60s. */
|
|
5
|
+
ttlMs?: number;
|
|
6
|
+
/** Fresh time for not-found (shorter: the thing may be created next). Default 15s. */
|
|
7
|
+
notFoundTtlMs?: number;
|
|
8
|
+
/** Wait before retrying after an error. Default 5s. */
|
|
9
|
+
errorRetryMs?: number;
|
|
10
|
+
/** Requests landing within this window share one call per kind. Default 10ms. */
|
|
11
|
+
batchWindowMs?: number;
|
|
12
|
+
/** Max canonicals per resolveMany call. Default 50. */
|
|
13
|
+
maxBatch?: number;
|
|
14
|
+
now?: () => number;
|
|
15
|
+
}
|
|
16
|
+
export interface RefResolverClient {
|
|
17
|
+
/** Current state; never triggers a fetch. Snapshot identity is stable until the state changes. */
|
|
18
|
+
get(kind: string, canonical: string): RefState;
|
|
19
|
+
/** Ask for refs to be resolved. Fresh, in-flight and unsupported refs are skipped. */
|
|
20
|
+
request(refs: readonly {
|
|
21
|
+
kind: string;
|
|
22
|
+
canonical: string;
|
|
23
|
+
}[]): void;
|
|
24
|
+
/** Drop cached state (one ref, one kind, or all) and re-request anything that was resolved. */
|
|
25
|
+
invalidate(kind?: string, canonical?: string): void;
|
|
26
|
+
/** useSyncExternalStore-compatible. */
|
|
27
|
+
subscribe(listener: () => void): () => void;
|
|
28
|
+
dispose(): void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Cached, batched, deduplicated resolution with explicit loading / not-found /
|
|
32
|
+
* error states. Framework-free: R1 wraps it in a hook with useSyncExternalStore.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createRefResolverClient(opts: ResolverClientOptions): RefResolverClient;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a match ending at `end` really ends once sentence punctuation and
|
|
3
|
+
* unbalanced closers are dropped: "see src/a.ts." and "(see https://x.io/a)"
|
|
4
|
+
* stop before the "." and the ")", while "https://x.io/a_(b)" keeps its pair.
|
|
5
|
+
*/
|
|
6
|
+
export declare function trimTrailing(text: string, start: number, end: number): number;
|
|
7
|
+
export declare function isWordChar(c: string | undefined): boolean;
|
|
8
|
+
/** Run a global regex over text, yielding exec results. Guards against zero-width loops. */
|
|
9
|
+
export declare function matches(re: RegExp, text: string): Generator<RegExpExecArray>;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/** Dotted lowercase id, e.g. `torque.task`, `tesseract.key`, `forge.pr`. */
|
|
2
|
+
export type RefKindId = string;
|
|
3
|
+
export type RefMeta = Readonly<Record<string, string | number>>;
|
|
4
|
+
/** A candidate match a kind found in the text, as offsets into that exact string. */
|
|
5
|
+
export interface RefHit {
|
|
6
|
+
start: number;
|
|
7
|
+
/** Exclusive. */
|
|
8
|
+
end: number;
|
|
9
|
+
/** Stable identity of the referenced thing: what resolvers and caches are keyed by. */
|
|
10
|
+
canonical: string;
|
|
11
|
+
meta?: RefMeta;
|
|
12
|
+
}
|
|
13
|
+
/** Where activating a reference goes. `copy` is for things with no destination (a file path). */
|
|
14
|
+
export type OpenTarget = {
|
|
15
|
+
type: "route";
|
|
16
|
+
to: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "external";
|
|
19
|
+
href: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "copy";
|
|
22
|
+
text: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "none";
|
|
25
|
+
};
|
|
26
|
+
export interface RefIdentity {
|
|
27
|
+
kind: RefKindId;
|
|
28
|
+
canonical: string;
|
|
29
|
+
meta?: RefMeta;
|
|
30
|
+
}
|
|
31
|
+
export interface RefKind {
|
|
32
|
+
id: RefKindId;
|
|
33
|
+
/** Human name for legends and settings ("Torque task"). */
|
|
34
|
+
label: string;
|
|
35
|
+
/** Icon token the renderer maps to a glyph. A string, so this module stays UI-free. */
|
|
36
|
+
icon: string;
|
|
37
|
+
/**
|
|
38
|
+
* Overlap tie-break: the higher priority wins a contested span; equal
|
|
39
|
+
* priority falls back to the longer match, then the earlier one. Built-ins
|
|
40
|
+
* use 40 (path) to 100 (url); see builtin.ts.
|
|
41
|
+
*/
|
|
42
|
+
priority: number;
|
|
43
|
+
/**
|
|
44
|
+
* Find candidates. Must be pure and linear in the text (no nested
|
|
45
|
+
* quantifiers), may over-report (the detector resolves overlaps and code
|
|
46
|
+
* spans), and must not throw on any input.
|
|
47
|
+
*/
|
|
48
|
+
scan(text: string): RefHit[];
|
|
49
|
+
/** Short text for the inline chip. Defaults to the matched text. */
|
|
50
|
+
chipLabel?(ref: RefIdentity, raw: string): string;
|
|
51
|
+
open(ref: RefIdentity): OpenTarget;
|
|
52
|
+
/** Label for the open action when the target is a route. Defaults to "Open page". */
|
|
53
|
+
openLabel?: string;
|
|
54
|
+
/**
|
|
55
|
+
* `hover` holds the lookup until the chip is hovered, focused or opened, for kinds
|
|
56
|
+
* whose read is not free (operator-gated or one request per id). Default: on mount.
|
|
57
|
+
*/
|
|
58
|
+
resolveOn?: "hover";
|
|
59
|
+
}
|
|
60
|
+
export type Segment = {
|
|
61
|
+
type: "text";
|
|
62
|
+
text: string;
|
|
63
|
+
start: number;
|
|
64
|
+
end: number;
|
|
65
|
+
} | {
|
|
66
|
+
type: "ref";
|
|
67
|
+
kind: RefKindId;
|
|
68
|
+
canonical: string;
|
|
69
|
+
/** The matched source text, exactly as written. */
|
|
70
|
+
raw: string;
|
|
71
|
+
start: number;
|
|
72
|
+
end: number;
|
|
73
|
+
meta?: RefMeta;
|
|
74
|
+
};
|
|
75
|
+
export type RefSegment = Extract<Segment, {
|
|
76
|
+
type: "ref";
|
|
77
|
+
}>;
|
|
78
|
+
export type StatusTone = "neutral" | "info" | "success" | "warning" | "danger";
|
|
79
|
+
/** What a resolver knows about a reference: the data a hovercard or chip needs, in a UI-neutral shape. */
|
|
80
|
+
export interface RefEntity {
|
|
81
|
+
title: string;
|
|
82
|
+
subtitle?: string;
|
|
83
|
+
description?: string;
|
|
84
|
+
status?: {
|
|
85
|
+
label: string;
|
|
86
|
+
tone: StatusTone;
|
|
87
|
+
};
|
|
88
|
+
fields?: {
|
|
89
|
+
label: string;
|
|
90
|
+
value: string;
|
|
91
|
+
mono?: boolean;
|
|
92
|
+
}[];
|
|
93
|
+
/** ISO timestamp of the thing's last change, for "updated 3m ago". */
|
|
94
|
+
updatedAt?: string;
|
|
95
|
+
/** What the inline chip says once resolved, untruncated: "Handoff: Approval execution". Defaults to the matched text. */
|
|
96
|
+
chipLabel?: string;
|
|
97
|
+
/** Where the thing lives outside the app. */
|
|
98
|
+
url?: string;
|
|
99
|
+
/** What opening it does in the app: a command and its arguments. Absent: the record window. */
|
|
100
|
+
open?: {
|
|
101
|
+
command: string;
|
|
102
|
+
args?: Record<string, unknown>;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export type ResolveOutcome = {
|
|
106
|
+
status: "found";
|
|
107
|
+
entity: RefEntity;
|
|
108
|
+
} | {
|
|
109
|
+
status: "not-found";
|
|
110
|
+
};
|
|
111
|
+
export interface ResolveContext {
|
|
112
|
+
signal: AbortSignal;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Backend seam for one kind. One call resolves a batch; a canonical missing
|
|
116
|
+
* from the result counts as not-found; a thrown error marks the whole batch
|
|
117
|
+
* as failed (retryable).
|
|
118
|
+
*/
|
|
119
|
+
export interface KindResolver {
|
|
120
|
+
resolveMany(canonicals: string[], ctx: ResolveContext): Promise<Record<string, ResolveOutcome | undefined>>;
|
|
121
|
+
}
|
|
122
|
+
export type RefState = {
|
|
123
|
+
status: "idle";
|
|
124
|
+
} | {
|
|
125
|
+
status: "loading";
|
|
126
|
+
stale?: RefEntity;
|
|
127
|
+
} | {
|
|
128
|
+
status: "found";
|
|
129
|
+
entity: RefEntity;
|
|
130
|
+
fetchedAt: number;
|
|
131
|
+
} | {
|
|
132
|
+
status: "not-found";
|
|
133
|
+
fetchedAt: number;
|
|
134
|
+
} | {
|
|
135
|
+
status: "error";
|
|
136
|
+
message: string;
|
|
137
|
+
fetchedAt: number;
|
|
138
|
+
stale?: RefEntity;
|
|
139
|
+
}
|
|
140
|
+
/** No resolver registered for this kind: detection and linking only. */
|
|
141
|
+
| {
|
|
142
|
+
status: "unsupported";
|
|
143
|
+
};
|
|
144
|
+
export type RefCardPhase = "loading" | "ready" | "not-found" | "error" | "unresolved";
|
|
145
|
+
/** Everything a hovercard renders, derived from a RefState. */
|
|
146
|
+
export interface PreviewCard {
|
|
147
|
+
kind: RefKindId;
|
|
148
|
+
kindLabel: string;
|
|
149
|
+
icon: string;
|
|
150
|
+
canonical: string;
|
|
151
|
+
phase: RefCardPhase;
|
|
152
|
+
title: string;
|
|
153
|
+
subtitle?: string;
|
|
154
|
+
description?: string;
|
|
155
|
+
status?: RefEntity["status"];
|
|
156
|
+
fields: NonNullable<RefEntity["fields"]>;
|
|
157
|
+
updatedAt?: string;
|
|
158
|
+
error?: string;
|
|
159
|
+
open: OpenTarget;
|
|
160
|
+
openLabel?: string;
|
|
161
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ViewProps } from "../sdk/types";
|
|
2
|
+
/**
|
|
3
|
+
* A record's text: Markdown (its front matter, if any, as fields above it), or, when it is a
|
|
4
|
+
* JSON document (a collab/v1 one has front matter over it), its fields laid out to be read,
|
|
5
|
+
* with the JSON a toggle away, shown as it was written. A document too large to lay out is
|
|
6
|
+
* shown as its text.
|
|
7
|
+
*/
|
|
8
|
+
export declare function RecordBody({ body }: {
|
|
9
|
+
body: string;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export declare function CiteRecordView({ win, desk }: ViewProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* remarkCite: references in Markdown become cite elements, which the Markdown component's
|
|
3
|
+
* `cite` entry draws as chips (./markdown.tsx). Dependency-free: it walks mdast as plain
|
|
4
|
+
* objects, so it is tested with node:test and needs no unified types.
|
|
5
|
+
*
|
|
6
|
+
* - Prose: each text node is split into text and references. Text inside a link stays as it is.
|
|
7
|
+
* - Links: `[label](tach:<service>/<id>)` becomes a chip with that label; a bare URL (an autolink,
|
|
8
|
+
* its text the URL itself) becomes a chip, and so does a link that is a reference of another
|
|
9
|
+
* kind (a fragment's reader link). A labelled link to a web page stays a link.
|
|
10
|
+
* - Code, fenced or inline, is left alone: what is in code is shown as written.
|
|
11
|
+
*/
|
|
12
|
+
import { type RefRegistry } from "./core/index.ts";
|
|
13
|
+
interface MdNode {
|
|
14
|
+
type: string;
|
|
15
|
+
value?: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
children?: MdNode[];
|
|
18
|
+
data?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** The element the plugin makes, and the attributes it carries. */
|
|
21
|
+
export declare const CITE_ELEMENT = "cite";
|
|
22
|
+
export declare const CITE_ATTR: {
|
|
23
|
+
readonly kind: "data-cite-kind";
|
|
24
|
+
readonly id: "data-cite-id";
|
|
25
|
+
readonly label: "data-cite-label";
|
|
26
|
+
readonly mono: "data-cite-mono";
|
|
27
|
+
};
|
|
28
|
+
/** The transform, over a registry of kinds. */
|
|
29
|
+
export declare function citeTransform(registry: RefRegistry, tree: MdNode): void;
|
|
30
|
+
/** A remark plugin over a registry: `remarkPlugins={[createRemarkCite(registry)]}`. */
|
|
31
|
+
export declare function createRemarkCite(registry: RefRegistry): () => (tree: unknown) => void;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type RefEntity, type RefIdentity, type RefState, type Segment } from "./core/index.ts";
|
|
2
|
+
export type { RefEntity, RefIdentity, RefState, Segment };
|
|
3
|
+
/** A record as /api/cite/record returns it: the preview and the whole text. */
|
|
4
|
+
export interface CiteRecord extends RefEntity {
|
|
5
|
+
body?: string;
|
|
6
|
+
}
|
|
7
|
+
/** A kind the app's server resolves (GET /api/cite). */
|
|
8
|
+
export interface ServerKind {
|
|
9
|
+
kind: string;
|
|
10
|
+
label: string;
|
|
11
|
+
module: string;
|
|
12
|
+
record?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const registry: import("./core/registry.ts").RefRegistry;
|
|
15
|
+
/** Ask the server what it resolves. Called once when the page is ready; safe to call again. */
|
|
16
|
+
export declare function initCite(): Promise<void>;
|
|
17
|
+
/** Whether a kind has a record behind it that this app can look up. */
|
|
18
|
+
export declare const canResolve: (kind: string) => boolean;
|
|
19
|
+
export declare const kindLabel: (kind: string) => string;
|
|
20
|
+
/** The state of one reference; with fetch, asks for it to be looked up. */
|
|
21
|
+
export declare function useRefState(kind: string, canonical: string, fetch: boolean): RefState;
|
|
22
|
+
/** Ask for a reference now (the card opened before the chip asked). */
|
|
23
|
+
export declare const requestRef: (ref: RefIdentity) => void;
|
|
24
|
+
/** Text split into plain and reference segments. */
|
|
25
|
+
export declare const segments: (text: string) => Segment[];
|
|
26
|
+
export declare const loadRecord: (ref: RefIdentity) => Promise<CiteRecord>;
|
|
27
|
+
/** Open a URL: in the app's Browser when it has one, else in a new tab. */
|
|
28
|
+
export declare function openURL(url: string): void;
|
|
29
|
+
/** The record window for a reference. */
|
|
30
|
+
export declare const openRecord: (ref: RefIdentity) => Promise<import("../sdk/types.ts").Win>;
|
|
31
|
+
/**
|
|
32
|
+
* Open a reference: the window its module names (a Planner item in Work, a path in Files), a
|
|
33
|
+
* URL in the Browser, else the record window; a reference nothing here resolves is copied.
|
|
34
|
+
*/
|
|
35
|
+
export declare function openCite(ref: RefIdentity): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type DocField, type DocNode } from "./structured.ts";
|
|
2
|
+
/** Fields: the one-line ones in a grid, then each longer one as a section under its label. */
|
|
3
|
+
export declare function DocFields({ fields }: {
|
|
4
|
+
fields: DocField[];
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
/** One value, whatever its shape. */
|
|
7
|
+
export declare function DocValue({ node }: {
|
|
8
|
+
node: DocNode;
|
|
9
|
+
}): import("react").JSX.Element;
|