@unieai/rabi-session-log-export 0.0.0-stage → 0.2.2-rc.5
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/LICENSE +21 -0
- package/README.md +7 -2
- package/lib/client.js +2 -0
- package/lib/index.js +980 -0
- package/lib/types/archive.d.ts +132 -0
- package/lib/types/client/CopyToast.d.ts +21 -0
- package/lib/types/client/Dialog.d.ts +22 -0
- package/lib/types/client/controller.d.ts +69 -0
- package/lib/types/client/copy-controller.d.ts +76 -0
- package/lib/types/client/index.d.ts +24 -0
- package/lib/types/client/locales.d.ts +126 -0
- package/lib/types/index.d.ts +24 -0
- package/lib/types/markdown.d.ts +22 -0
- package/lib/types/routes.d.ts +14 -0
- package/locale/de.json +6 -0
- package/locale/en.json +5 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +57 -4
- package/src/archive.ts +706 -0
- package/src/client/CopyToast.tsx +40 -0
- package/src/client/Dialog.tsx +55 -0
- package/src/client/controller.ts +139 -0
- package/src/client/copy-controller.ts +201 -0
- package/src/client/index.ts +105 -0
- package/src/client/locales.ts +149 -0
- package/src/index.ts +234 -0
- package/src/markdown.ts +367 -0
- package/src/routes.ts +17 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-side session-log download: streams one ZIP archive whose files are the
|
|
3
|
+
* sessions' logical session logs plus every referenced attachment. Each log
|
|
4
|
+
* is read through a persistence read handle and serialized here as canonical
|
|
5
|
+
* JSONL — one header line, then one line per validated event — so every
|
|
6
|
+
* backend (JSONL, SQLite, future) exports identically. The root log uses the
|
|
7
|
+
* current generation's canonical `session[.vN].jsonl` name; each subagent
|
|
8
|
+
* descendant uses `subagents/<id>/session[.vN].jsonl`; each image referenced by any included log
|
|
9
|
+
* under `media/<attachmentId>.<ext>` (content-addressed, so one archive never
|
|
10
|
+
* duplicates a shared image); each generic file sits under
|
|
11
|
+
* `files/<prefix>/<digest>/<name>` and streams from the attachment store. No
|
|
12
|
+
* manifest is written. Before each live session's log read, the SessionStore
|
|
13
|
+
* flush barrier makes the current in-memory log durable; cold sessions need no
|
|
14
|
+
* barrier. Request abort and response-consumer cancellation share one producer
|
|
15
|
+
* signal and terminate the active compressor.
|
|
16
|
+
* Compression runs on the host with fflate's streaming Zip API, so the archive
|
|
17
|
+
* bytes are produced incrementally and the host never holds the whole archive
|
|
18
|
+
* in one buffer; production waits for consumer pull whenever the response queue
|
|
19
|
+
* reaches its byte high-water mark, so a slow consumer bounds accumulation to
|
|
20
|
+
* the fixed 64 KiB response queue plus one synchronous fflate push.
|
|
21
|
+
* @module
|
|
22
|
+
*/
|
|
23
|
+
import type { Context } from '@unieai/cordis';
|
|
24
|
+
import type { AttachmentStore } from '@unieai/rabi-attachment';
|
|
25
|
+
import type { SessionQueryEngine } from '@unieai/rabi-session-query';
|
|
26
|
+
import type { SessionEvent, SessionHeader, SessionId, SessionStore } from '@unieai/rabi-session';
|
|
27
|
+
import type { SessionPersistence } from '@unieai/rabi-session-persistence';
|
|
28
|
+
/** Valid fflate DEFLATE levels accepted by session-log export. */
|
|
29
|
+
export type SessionLogCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
30
|
+
/** Balanced default used when Session export configuration omits a compression level. */
|
|
31
|
+
export declare const DEFAULT_SESSION_LOG_COMPRESSION_LEVEL: SessionLogCompressionLevel;
|
|
32
|
+
/** The services a session-log export needs (the live-session store is optional). */
|
|
33
|
+
export interface SessionLogExportDeps {
|
|
34
|
+
readonly sessionQuery: SessionQueryEngine | undefined;
|
|
35
|
+
readonly sessionPersistence: SessionPersistence | undefined;
|
|
36
|
+
readonly attachments: AttachmentStore | undefined;
|
|
37
|
+
readonly sessions: SessionStore | undefined;
|
|
38
|
+
}
|
|
39
|
+
/** The export services narrowed to the mounted ones streaming actually reads. */
|
|
40
|
+
export interface SessionLogExportReady {
|
|
41
|
+
readonly sessionQuery: SessionQueryEngine;
|
|
42
|
+
readonly sessionPersistence: SessionPersistence;
|
|
43
|
+
readonly attachments: AttachmentStore;
|
|
44
|
+
readonly sessions: SessionStore | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the persistence, session-query, and attachment services a log export needs.
|
|
48
|
+
* @param ctx - the composed host context.
|
|
49
|
+
* @returns the export services (absent when the deployment does not mount them).
|
|
50
|
+
*/
|
|
51
|
+
export declare function sessionLogExportDeps(ctx: Context): SessionLogExportDeps;
|
|
52
|
+
/**
|
|
53
|
+
* Flush one currently live session through the store's authoritative durability
|
|
54
|
+
* barrier immediately before its logical log is read. A cold or absent id has
|
|
55
|
+
* no in-memory work to flush.
|
|
56
|
+
* @param deps - export services, including the optional live-session store.
|
|
57
|
+
* @param id - the session whose artifact is about to be read.
|
|
58
|
+
* @param signal - optional cancellation observed around the flush barrier.
|
|
59
|
+
*/
|
|
60
|
+
export declare function flushLiveSessionLog(deps: Pick<SessionLogExportDeps, 'sessions'>, id: SessionId, signal?: AbortSignal): Promise<void>;
|
|
61
|
+
/** One exported file: a serialized session log or one referenced attachment object. */
|
|
62
|
+
export type SessionLogZipEntry = {
|
|
63
|
+
readonly path: string;
|
|
64
|
+
readonly content: string;
|
|
65
|
+
} | {
|
|
66
|
+
readonly path: string;
|
|
67
|
+
readonly data: Uint8Array;
|
|
68
|
+
} | {
|
|
69
|
+
readonly path: string;
|
|
70
|
+
readonly chunks: AsyncIterable<Uint8Array>;
|
|
71
|
+
};
|
|
72
|
+
/** The current generation's canonical base filename for every exported session log. */
|
|
73
|
+
export declare const SESSION_LOG_FILENAME: string;
|
|
74
|
+
/**
|
|
75
|
+
* Serialize one session's logical log as canonical JSONL text: the header
|
|
76
|
+
* line, then one line per event, with a trailing newline.
|
|
77
|
+
* @param header - the session's immutable header.
|
|
78
|
+
* @param events - the validated committed events in seq order.
|
|
79
|
+
* @returns the JSONL text.
|
|
80
|
+
*/
|
|
81
|
+
export declare function serializeSessionLog(header: SessionHeader, events: readonly SessionEvent[]): string;
|
|
82
|
+
/**
|
|
83
|
+
* Read one session's complete logical log through a read handle and serialize
|
|
84
|
+
* it. The read observes the committed log only — persistence never returns a
|
|
85
|
+
* torn tail — and a handle read after a resolved flush observes at least the
|
|
86
|
+
* flushed prefix.
|
|
87
|
+
* @param persistence - the mounted persistence backend.
|
|
88
|
+
* @param id - the session to read.
|
|
89
|
+
* @param signal - optional cancellation forwarded to the open and read.
|
|
90
|
+
* @returns the serialized JSONL text, or `undefined` when the session does not exist.
|
|
91
|
+
*/
|
|
92
|
+
export declare function readSessionLogText(persistence: SessionPersistence, id: SessionId, signal?: AbortSignal): Promise<string | undefined>;
|
|
93
|
+
/**
|
|
94
|
+
* The export archive filename for one root session.
|
|
95
|
+
* @param sessionId - the root session id (sanitized to one safe path segment).
|
|
96
|
+
* @returns the attachment filename for the session's export archive.
|
|
97
|
+
*/
|
|
98
|
+
export declare function sessionLogZipFilename(sessionId: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Yield the export entries in zip order: the preloaded root log first, then
|
|
101
|
+
* every subagent descendant in lineage order (each flushed when live, read
|
|
102
|
+
* through a persistence read handle right before it is yielded, and dropped
|
|
103
|
+
* after the consumer moves on), then every distinct attachment referenced by
|
|
104
|
+
* the included logs. Images are read and verified as bounded stored objects;
|
|
105
|
+
* generic files remain streamed through the ZIP writer. The host holds at most
|
|
106
|
+
* one descendant log, one image, and one file chunk beyond the root.
|
|
107
|
+
* @param deps - the mounted export services (the caller answered 500 before this runs).
|
|
108
|
+
* @param rootContent - the already-serialized root log (read by the caller so
|
|
109
|
+
* the missing-session path can answer cleanly before streaming starts).
|
|
110
|
+
* @param sessionId - the root session id.
|
|
111
|
+
* @param includeDescendants - whether to include every subagent descendant.
|
|
112
|
+
* @param signal - optional cancellation forwarded to lineage, persistence, and attachment reads.
|
|
113
|
+
* @returns the export entries in zip order.
|
|
114
|
+
*/
|
|
115
|
+
export declare function sessionLogZipEntries(deps: SessionLogExportReady, rootContent: string, sessionId: SessionId, includeDescendants: boolean, signal?: AbortSignal): AsyncGenerator<SessionLogZipEntry>;
|
|
116
|
+
/**
|
|
117
|
+
* Stream one session-log ZIP as a WHATWG ReadableStream. The root log is read
|
|
118
|
+
* and serialized by the caller before this is called (a missing root or
|
|
119
|
+
* missing services answer cleanly before any byte is produced); each entry is
|
|
120
|
+
* then encoded and deflated in bounded chunks as it is produced, so the
|
|
121
|
+
* archive bytes arrive incrementally. A descendant that fails to read errors
|
|
122
|
+
* the stream (fail-loud, never silent under-export).
|
|
123
|
+
* @param deps - the mounted export services (the caller answered 500 before this runs).
|
|
124
|
+
* @param rootContent - the already-serialized root log (first zip entry).
|
|
125
|
+
* @param sessionId - the root session id.
|
|
126
|
+
* @param includeDescendants - whether to include every subagent descendant.
|
|
127
|
+
* @param compressionLevel - validated fflate DEFLATE level for every ZIP entry.
|
|
128
|
+
* @param signal - request cancellation combined with response-consumer cancellation.
|
|
129
|
+
* @returns the zip byte stream.
|
|
130
|
+
*/
|
|
131
|
+
export declare function streamSessionLogZip(deps: SessionLogExportReady, rootContent: string, sessionId: SessionId, includeDescendants: boolean, compressionLevel: SessionLogCompressionLevel, signal: AbortSignal): ReadableStream<Uint8Array>;
|
|
132
|
+
//# sourceMappingURL=archive.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ObservableSnapshot } from '@unieai/rabi-client-store';
|
|
3
|
+
import type { InjectFace, PropsLocale, PropsRuntime } from '@unieai/rabi-client-ui-slots';
|
|
4
|
+
import type { SessionMarkdownCopyState } from './copy-controller.ts';
|
|
5
|
+
import { NS } from './locales.ts';
|
|
6
|
+
/** Copy state and dismissal bound into the root overlay entry. */
|
|
7
|
+
export interface SessionMarkdownCopyToastInjected {
|
|
8
|
+
hooks: {
|
|
9
|
+
sessionMarkdownCopy: ObservableSnapshot<SessionMarkdownCopyState>;
|
|
10
|
+
};
|
|
11
|
+
dismiss: () => void;
|
|
12
|
+
}
|
|
13
|
+
/** Props of the root overlay copy notice. */
|
|
14
|
+
export type SessionMarkdownCopyToastProps = PropsRuntime<'shell.overlay'> & PropsLocale<typeof NS> & InjectFace<SessionMarkdownCopyToastInjected>;
|
|
15
|
+
/**
|
|
16
|
+
* Show the settled copy outcome outside the Session Header and menu lifetime.
|
|
17
|
+
* @param props - copy notice hook, dismissal action, and localized copy.
|
|
18
|
+
* @returns the success or failure toast, or null while no notice shows.
|
|
19
|
+
*/
|
|
20
|
+
export declare function SessionMarkdownCopyToast({ useSessionMarkdownCopy, dismiss, t, }: SessionMarkdownCopyToastProps): ReactNode;
|
|
21
|
+
//# sourceMappingURL=CopyToast.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Root overlay showing one Session export at a time in initiation order. */
|
|
2
|
+
import type { ObservableSnapshot } from '@unieai/rabi-client-store';
|
|
3
|
+
import type { SessionId } from '@unieai/rabi-session/types';
|
|
4
|
+
import type { InjectFace, PropsLocale, PropsRuntime } from '@unieai/rabi-client-ui-slots';
|
|
5
|
+
import type { SessionLogDownloadState } from './controller.ts';
|
|
6
|
+
import { NS } from './locales.ts';
|
|
7
|
+
/** Download state and dismissal bound into the root overlay entry. */
|
|
8
|
+
export interface SessionLogDownloadDialogInjected {
|
|
9
|
+
hooks: {
|
|
10
|
+
sessionLogDownload: ObservableSnapshot<SessionLogDownloadState>;
|
|
11
|
+
};
|
|
12
|
+
dismiss: (sessionId: SessionId) => void;
|
|
13
|
+
}
|
|
14
|
+
/** Root runtime, localized copy, and injected download state and actions. */
|
|
15
|
+
export type SessionLogDownloadDialogProps = PropsRuntime<'shell.overlay'> & PropsLocale<typeof NS> & InjectFace<SessionLogDownloadDialogInjected>;
|
|
16
|
+
/**
|
|
17
|
+
* Show the earliest open export independently of the displayed conversation.
|
|
18
|
+
* @param props - root runtime, bound controller state, dismissal, and localized copy.
|
|
19
|
+
* @returns one modal, or null when all exports are dismissed.
|
|
20
|
+
*/
|
|
21
|
+
export declare function SessionLogDownloadDialog({ useSessionLogDownload, dismiss, t, }: SessionLogDownloadDialogProps): import("react").JSX.Element | null;
|
|
22
|
+
//# sourceMappingURL=Dialog.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Browser download operations and FIFO modal state shared by menu actions and `/export`. */
|
|
2
|
+
import { type SnapshotStore } from '@unieai/rabi-client-store';
|
|
3
|
+
import type { SessionId } from '@unieai/rabi-session/types';
|
|
4
|
+
/** Download phases presented by the shared modal. */
|
|
5
|
+
export type SessionLogDownloadStatus = 'downloading' | 'success' | 'error';
|
|
6
|
+
/** One Session's current download-dialog state. */
|
|
7
|
+
export interface SessionLogDownloadEntry {
|
|
8
|
+
/** Initiation order of this operation; repeated in-flight requests keep it. */
|
|
9
|
+
readonly order: number;
|
|
10
|
+
readonly open: boolean;
|
|
11
|
+
readonly status: SessionLogDownloadStatus;
|
|
12
|
+
readonly error: string | null;
|
|
13
|
+
}
|
|
14
|
+
/** Authoritative download states; open entries display in initiation order across Sessions. */
|
|
15
|
+
export interface SessionLogDownloadState {
|
|
16
|
+
bySession: Record<string, SessionLogDownloadEntry | undefined>;
|
|
17
|
+
}
|
|
18
|
+
/** HTTP carrier for the export route. */
|
|
19
|
+
type Fetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
20
|
+
type Save = (url: string, filename: string) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Collapse an untrusted Session id into the filename convention owned by the host endpoint.
|
|
23
|
+
* @param sessionId - Session whose archive is downloaded.
|
|
24
|
+
* @returns one safe browser download filename.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sessionLogZipFilename(sessionId: SessionId): string;
|
|
27
|
+
/**
|
|
28
|
+
* Hand a Host download route to the browser download manager, which resolves it
|
|
29
|
+
* against the document's own base.
|
|
30
|
+
* @param url - document-relative Host download route.
|
|
31
|
+
* @param filename - browser download filename.
|
|
32
|
+
*/
|
|
33
|
+
export declare function downloadUrl(url: string, filename: string): void;
|
|
34
|
+
/** Owns one in-flight browser download per Session and publishes modal state. */
|
|
35
|
+
export declare class SessionLogDownloadController {
|
|
36
|
+
private readonly fetcher;
|
|
37
|
+
private readonly save;
|
|
38
|
+
/** Stable snapshot source for the root modal and menu availability. */
|
|
39
|
+
readonly store: SnapshotStore<SessionLogDownloadState>;
|
|
40
|
+
private readonly active;
|
|
41
|
+
private disposed;
|
|
42
|
+
private nextOrder;
|
|
43
|
+
/**
|
|
44
|
+
* @param fetcher - HTTP carrier used to read the host-streamed ZIP.
|
|
45
|
+
* @param save - browser save operation.
|
|
46
|
+
*/
|
|
47
|
+
constructor(fetcher?: Fetch, save?: Save);
|
|
48
|
+
/**
|
|
49
|
+
* Download one Session tree; concurrent gestures for the same Session share one operation.
|
|
50
|
+
* Different Sessions run concurrently; each new operation joins the modal FIFO.
|
|
51
|
+
* @param sessionId - root Session whose ZIP includes descendants and attachments.
|
|
52
|
+
* @returns after the browser save starts, an error state is published, or a late post-disposal request is ignored.
|
|
53
|
+
*/
|
|
54
|
+
download(sessionId: SessionId): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Close one Session's dialog without cancelling an in-flight browser download.
|
|
57
|
+
* @param sessionId - Session whose modal closes.
|
|
58
|
+
*/
|
|
59
|
+
dismiss(sessionId: SessionId): void;
|
|
60
|
+
/**
|
|
61
|
+
* Abort active fetches and reach quiescence.
|
|
62
|
+
* @returns after every active operation settles.
|
|
63
|
+
*/
|
|
64
|
+
dispose(): Promise<void>;
|
|
65
|
+
private run;
|
|
66
|
+
private publish;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser controller for the Session Header's "Copy Session as Markdown" action. One
|
|
3
|
+
* plugin instance owns one pending copy: the clipboard is a browser-wide
|
|
4
|
+
* destination, so a second request joins the pending operation instead of
|
|
5
|
+
* racing it.
|
|
6
|
+
*
|
|
7
|
+
* On hosts with `ClipboardItem` and `navigator.clipboard.write`, the controller
|
|
8
|
+
* starts that write synchronously from the click with a promised text Blob, so
|
|
9
|
+
* the browser keeps the user activation while the Host prepares the
|
|
10
|
+
* transcript. Other hosts fall back to `writeClipboard` after preparation. A
|
|
11
|
+
* disposal aborts the read and prevents later text from reaching the Blob, but
|
|
12
|
+
* an accepted operating-system clipboard write cannot be rolled back.
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import { type SnapshotStore } from '@unieai/rabi-client-store';
|
|
16
|
+
import type { SessionId } from '@unieai/rabi-session/types';
|
|
17
|
+
/** Whether the latest copy attempt succeeded, prepared no transcript, or could not write. */
|
|
18
|
+
export type SessionMarkdownCopyNoticeKind = 'success' | 'preparationFailed' | 'clipboardFailed';
|
|
19
|
+
/** One settled copy notice; `seq` keys the toast so a repeat copy restarts it. */
|
|
20
|
+
export interface SessionMarkdownCopyNotice {
|
|
21
|
+
readonly kind: SessionMarkdownCopyNoticeKind;
|
|
22
|
+
readonly seq: number;
|
|
23
|
+
}
|
|
24
|
+
/** Copy state shared by every Header row and the root overlay toast. */
|
|
25
|
+
export interface SessionMarkdownCopyState {
|
|
26
|
+
/** Whether this plugin instance has a copy operation still pending. */
|
|
27
|
+
copying: boolean;
|
|
28
|
+
/** Latest settled copy notice, or null while none shows. */
|
|
29
|
+
notice: SessionMarkdownCopyNotice | null;
|
|
30
|
+
}
|
|
31
|
+
/** Browser clipboard operations used by one copy attempt. */
|
|
32
|
+
export interface SessionMarkdownClipboard {
|
|
33
|
+
/** Whether a deferred write can start inside the click's activation window. */
|
|
34
|
+
supportsDeferredWrite(): boolean;
|
|
35
|
+
/** Start one deferred text write; the browser observes the data promise as it settles. */
|
|
36
|
+
writeDeferred(data: Promise<Blob>): Promise<void>;
|
|
37
|
+
/** Write prepared text on hosts without the deferred API; false means the browser rejected it. */
|
|
38
|
+
writeText(text: string): Promise<boolean>;
|
|
39
|
+
}
|
|
40
|
+
/** HTTP carrier for the Markdown route. */
|
|
41
|
+
type Fetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
42
|
+
/** Owns the one pending Markdown copy for this plugin instance. */
|
|
43
|
+
export declare class SessionMarkdownCopyController {
|
|
44
|
+
private readonly fetcher;
|
|
45
|
+
private readonly clipboard;
|
|
46
|
+
/** uSES-safe state source shared by every Header row and the overlay toast. */
|
|
47
|
+
readonly store: SnapshotStore<SessionMarkdownCopyState>;
|
|
48
|
+
private pending;
|
|
49
|
+
private disposed;
|
|
50
|
+
private noticeSeq;
|
|
51
|
+
constructor(fetcher?: Fetch, clipboard?: SessionMarkdownClipboard);
|
|
52
|
+
/**
|
|
53
|
+
* Copy one Session's complete transcript. A request received while a copy is
|
|
54
|
+
* pending joins that operation and keeps its originally captured Session.
|
|
55
|
+
* @param sessionId - Session captured by the click.
|
|
56
|
+
* @returns after the clipboard work settles, a failure notice is published, or a late post-disposal request is ignored.
|
|
57
|
+
*/
|
|
58
|
+
copy(sessionId: SessionId): Promise<void>;
|
|
59
|
+
/** Clear the shown toast without affecting a pending copy. */
|
|
60
|
+
dismiss(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Abort a pending read, suppress a late clipboard write or notice, and reach
|
|
63
|
+
* quiescence. A write already accepted by the operating system cannot be
|
|
64
|
+
* undone.
|
|
65
|
+
* @returns after the pending operation and any admitted clipboard work settle.
|
|
66
|
+
*/
|
|
67
|
+
dispose(): Promise<void>;
|
|
68
|
+
private run;
|
|
69
|
+
private prepare;
|
|
70
|
+
private settleDeferred;
|
|
71
|
+
private settleFallback;
|
|
72
|
+
private isCancelled;
|
|
73
|
+
private publishNotice;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=copy-controller.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Browser plugin owning ZIP download and Markdown copy state, plus feedback controls. */
|
|
2
|
+
import type { Context as ClientContext } from '@unieai/cordis';
|
|
3
|
+
import { SessionLogDownloadController } from './controller.ts';
|
|
4
|
+
import { type SessionLogDownloadKey } from './locales.ts';
|
|
5
|
+
declare module '@unieai/cordis' {
|
|
6
|
+
interface Context {
|
|
7
|
+
sessionLogDownload: SessionLogDownloadController;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare module '@unieai/rabi-client-ui-slots' {
|
|
11
|
+
interface LocaleNamespaceMap {
|
|
12
|
+
'session-log-download': SessionLogDownloadKey;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export type { SessionLogDownloadEntry, SessionLogDownloadState } from './controller.ts';
|
|
16
|
+
export declare const inject: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Provide the download controller and mount its modal, the Markdown copy
|
|
19
|
+
* controller and its root toast, and the shared Session menu actions.
|
|
20
|
+
* @param ctx - browser context carrying slots and locale services.
|
|
21
|
+
*/
|
|
22
|
+
export declare function apply(ctx: ClientContext): void;
|
|
23
|
+
export type { SessionLogDownloadDialogInjected, SessionLogDownloadDialogProps } from './Dialog.tsx';
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** Locale namespace owned by Session export browser feedback. */
|
|
2
|
+
export declare const NS = "session-log-download";
|
|
3
|
+
/** Simplified-Chinese Session export strings. */
|
|
4
|
+
export declare const zh: {
|
|
5
|
+
readonly 'menu.copyMarkdown': "复制会话为 Markdown";
|
|
6
|
+
readonly 'menu.download': "下载 Session 日志";
|
|
7
|
+
readonly 'menu.feedback': "反馈";
|
|
8
|
+
readonly 'toast.copied': "Session 已复制为 Markdown";
|
|
9
|
+
readonly 'toast.preparationFailed': "无法读取 Session 进行复制,请重试";
|
|
10
|
+
readonly 'toast.clipboardFailed': "无法写入剪贴板,请检查剪贴板权限后重试";
|
|
11
|
+
readonly 'dialog.session': "Session:{sessionId}";
|
|
12
|
+
readonly 'dialog.preparingTitle': "正在导出 Session";
|
|
13
|
+
readonly 'dialog.preparingDescription': "正在准备包含指定 Session、子 Session 和附件的 ZIP 文件";
|
|
14
|
+
readonly 'dialog.successTitle': "Session 导出已开始下载";
|
|
15
|
+
readonly 'dialog.successDescription': "浏览器正在下载 Session ZIP 文件。";
|
|
16
|
+
readonly 'dialog.errorTitle': "Session 导出失败";
|
|
17
|
+
readonly 'dialog.close': "关闭";
|
|
18
|
+
readonly 'dialog.commandFailed': "无法启动 Session 导出。";
|
|
19
|
+
};
|
|
20
|
+
/** English Session export strings. */
|
|
21
|
+
export declare const en: Record<keyof typeof zh, string>;
|
|
22
|
+
/** Stable locale keys consumed by the shared modal. */
|
|
23
|
+
export type SessionLogDownloadKey = keyof typeof zh;
|
|
24
|
+
/** Japanese copy, checked against the English keys. */
|
|
25
|
+
export declare const ja: {
|
|
26
|
+
'menu.copyMarkdown': string;
|
|
27
|
+
'menu.download': string;
|
|
28
|
+
'menu.feedback': string;
|
|
29
|
+
'toast.copied': string;
|
|
30
|
+
'toast.preparationFailed': string;
|
|
31
|
+
'toast.clipboardFailed': string;
|
|
32
|
+
'dialog.session': string;
|
|
33
|
+
'dialog.preparingTitle': string;
|
|
34
|
+
'dialog.preparingDescription': string;
|
|
35
|
+
'dialog.successTitle': string;
|
|
36
|
+
'dialog.successDescription': string;
|
|
37
|
+
'dialog.errorTitle': string;
|
|
38
|
+
'dialog.close': string;
|
|
39
|
+
'dialog.commandFailed': string;
|
|
40
|
+
};
|
|
41
|
+
/** Spanish dictionary, checked against the English keys. */
|
|
42
|
+
export declare const es: {
|
|
43
|
+
'menu.copyMarkdown': string;
|
|
44
|
+
'menu.download': string;
|
|
45
|
+
'menu.feedback': string;
|
|
46
|
+
'toast.copied': string;
|
|
47
|
+
'toast.preparationFailed': string;
|
|
48
|
+
'toast.clipboardFailed': string;
|
|
49
|
+
'dialog.session': string;
|
|
50
|
+
'dialog.preparingTitle': string;
|
|
51
|
+
'dialog.preparingDescription': string;
|
|
52
|
+
'dialog.successTitle': string;
|
|
53
|
+
'dialog.successDescription': string;
|
|
54
|
+
'dialog.errorTitle': string;
|
|
55
|
+
'dialog.close': string;
|
|
56
|
+
'dialog.commandFailed': string;
|
|
57
|
+
};
|
|
58
|
+
/** French dictionary, checked against the English keys. */
|
|
59
|
+
export declare const fr: {
|
|
60
|
+
'menu.copyMarkdown': string;
|
|
61
|
+
'menu.download': string;
|
|
62
|
+
'menu.feedback': string;
|
|
63
|
+
'toast.copied': string;
|
|
64
|
+
'toast.preparationFailed': string;
|
|
65
|
+
'toast.clipboardFailed': string;
|
|
66
|
+
'dialog.session': string;
|
|
67
|
+
'dialog.preparingTitle': string;
|
|
68
|
+
'dialog.preparingDescription': string;
|
|
69
|
+
'dialog.successTitle': string;
|
|
70
|
+
'dialog.successDescription': string;
|
|
71
|
+
'dialog.errorTitle': string;
|
|
72
|
+
'dialog.close': string;
|
|
73
|
+
'dialog.commandFailed': string;
|
|
74
|
+
};
|
|
75
|
+
/** German dictionary, checked against the English keys. */
|
|
76
|
+
export declare const de: {
|
|
77
|
+
'menu.copyMarkdown': string;
|
|
78
|
+
'menu.download': string;
|
|
79
|
+
'menu.feedback': string;
|
|
80
|
+
'toast.copied': string;
|
|
81
|
+
'toast.preparationFailed': string;
|
|
82
|
+
'toast.clipboardFailed': string;
|
|
83
|
+
'dialog.session': string;
|
|
84
|
+
'dialog.preparingTitle': string;
|
|
85
|
+
'dialog.preparingDescription': string;
|
|
86
|
+
'dialog.successTitle': string;
|
|
87
|
+
'dialog.successDescription': string;
|
|
88
|
+
'dialog.errorTitle': string;
|
|
89
|
+
'dialog.close': string;
|
|
90
|
+
'dialog.commandFailed': string;
|
|
91
|
+
};
|
|
92
|
+
/** Russian dictionary, checked against the English keys. */
|
|
93
|
+
export declare const ru: {
|
|
94
|
+
'menu.copyMarkdown': string;
|
|
95
|
+
'menu.download': string;
|
|
96
|
+
'menu.feedback': string;
|
|
97
|
+
'toast.copied': string;
|
|
98
|
+
'toast.preparationFailed': string;
|
|
99
|
+
'toast.clipboardFailed': string;
|
|
100
|
+
'dialog.session': string;
|
|
101
|
+
'dialog.preparingTitle': string;
|
|
102
|
+
'dialog.preparingDescription': string;
|
|
103
|
+
'dialog.successTitle': string;
|
|
104
|
+
'dialog.successDescription': string;
|
|
105
|
+
'dialog.errorTitle': string;
|
|
106
|
+
'dialog.close': string;
|
|
107
|
+
'dialog.commandFailed': string;
|
|
108
|
+
};
|
|
109
|
+
/** Portuguese dictionary, checked against the English keys. */
|
|
110
|
+
export declare const pt: {
|
|
111
|
+
'menu.copyMarkdown': string;
|
|
112
|
+
'menu.download': string;
|
|
113
|
+
'menu.feedback': string;
|
|
114
|
+
'toast.copied': string;
|
|
115
|
+
'toast.preparationFailed': string;
|
|
116
|
+
'toast.clipboardFailed': string;
|
|
117
|
+
'dialog.session': string;
|
|
118
|
+
'dialog.preparingTitle': string;
|
|
119
|
+
'dialog.preparingDescription': string;
|
|
120
|
+
'dialog.successTitle': string;
|
|
121
|
+
'dialog.successDescription': string;
|
|
122
|
+
'dialog.errorTitle': string;
|
|
123
|
+
'dialog.close': string;
|
|
124
|
+
'dialog.commandFailed': string;
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Session export command and Host-owned ZIP download and Markdown copy routes. */
|
|
2
|
+
import type { Context } from '@unieai/cordis';
|
|
3
|
+
import Schema from '@unieai/schemastery';
|
|
4
|
+
import { type SessionLogCompressionLevel } from './archive.ts';
|
|
5
|
+
export { DEFAULT_SESSION_LOG_COMPRESSION_LEVEL, flushLiveSessionLog, readSessionLogText, serializeSessionLog, SESSION_LOG_FILENAME, sessionLogExportDeps, sessionLogZipEntries, sessionLogZipFilename, streamSessionLogZip, } from './archive.ts';
|
|
6
|
+
export type { SessionLogCompressionLevel, SessionLogExportDeps, SessionLogExportReady, SessionLogZipEntry, } from './archive.ts';
|
|
7
|
+
export { formatSessionMarkdown } from './markdown.ts';
|
|
8
|
+
export declare const name = "session-log-download";
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
export { SESSION_LOG_EXPORT_PATH } from './routes.ts';
|
|
11
|
+
/** Session-log archive policy. */
|
|
12
|
+
export interface Config {
|
|
13
|
+
/** DEFLATE level for each ZIP entry. @default 6 */
|
|
14
|
+
readonly compressionLevel?: SessionLogCompressionLevel;
|
|
15
|
+
}
|
|
16
|
+
/** Validate Session-log archive configuration. */
|
|
17
|
+
export declare const Config: Schema<Config>;
|
|
18
|
+
/**
|
|
19
|
+
* Register the `/export` command and authenticated ZIP download and Markdown copy routes.
|
|
20
|
+
* @param ctx - Host context carrying the human-command registry.
|
|
21
|
+
* @param config - resolved compression policy.
|
|
22
|
+
*/
|
|
23
|
+
export declare function apply(ctx: Context, config?: Config): void;
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure backend converter for one complete committed Session log. The Session
|
|
3
|
+
* Markdown copy Host route uses it, and the package entry exports it for
|
|
4
|
+
* callers that already hold the logical events. The raw log is authoritative:
|
|
5
|
+
* compaction surface replacements never remove earlier messages, and
|
|
6
|
+
* fork-inherited history appears once. Reasoning, system and developer
|
|
7
|
+
* messages, injected non-human context, request headers, and runtime records
|
|
8
|
+
* are omitted.
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import type { SessionEvent } from '@unieai/rabi-session';
|
|
12
|
+
/**
|
|
13
|
+
* Render one complete committed Session log as Markdown. This is a pure backend
|
|
14
|
+
* utility: it needs no mounted plugin, reads no storage, and does not mutate the
|
|
15
|
+
* supplied events. The latest `session/title` event supplies the heading; the
|
|
16
|
+
* rest of the transcript is derived only from the supplied logical events.
|
|
17
|
+
* @param events - complete committed logical event snapshot in seq order, including any inherited prefix.
|
|
18
|
+
* @param sourcePath - optional backend-resolved path to the selected Session artifact; emitted verbatim in a fenced text block.
|
|
19
|
+
* @returns Markdown ending in exactly one newline; an empty log returns the heading and optional source metadata only.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatSessionMarkdown(events: readonly SessionEvent[], sourcePath?: string): string;
|
|
22
|
+
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The absolute pathnames the Host registers the export routes under and the
|
|
3
|
+
* document-relative forms the browser addresses; see
|
|
4
|
+
* .agents/notes/implemented/architecture/2026-09-14-web-document-relative-app-routes.md.
|
|
5
|
+
*/
|
|
6
|
+
/** Absolute registration path for the ZIP download route. */
|
|
7
|
+
export declare const SESSION_LOG_EXPORT_PATH = "/api/session.export";
|
|
8
|
+
/** Browser-relative form of {@link SESSION_LOG_EXPORT_PATH}. */
|
|
9
|
+
export declare const SESSION_LOG_EXPORT_ROUTE: string;
|
|
10
|
+
/** Absolute registration path for the Markdown copy route. */
|
|
11
|
+
export declare const SESSION_MARKDOWN_EXPORT_PATH = "/api/session.markdown";
|
|
12
|
+
/** Browser-relative form of {@link SESSION_MARKDOWN_EXPORT_PATH}. */
|
|
13
|
+
export declare const SESSION_MARKDOWN_EXPORT_ROUTE: string;
|
|
14
|
+
//# sourceMappingURL=routes.d.ts.map
|
package/locale/de.json
ADDED
package/locale/en.json
ADDED
package/locale/es.json
ADDED
package/locale/fr.json
ADDED
package/locale/ja.json
ADDED
package/locale/pt.json
ADDED
package/locale/ru.json
ADDED