@oh-my-pi/pi-coding-agent 16.0.7 → 16.0.8
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/CHANGELOG.md +31 -0
- package/dist/cli.js +4752 -12462
- package/dist/types/cli/update-cli.d.ts +11 -0
- package/dist/types/debug/remote-debugger.d.ts +45 -0
- package/dist/types/internal-urls/docs-index.d.ts +19 -0
- package/dist/types/markit/converters/docx.d.ts +6 -0
- package/dist/types/markit/converters/epub.d.ts +15 -0
- package/dist/types/markit/converters/pdf/columns.d.ts +35 -0
- package/dist/types/markit/converters/pdf/extract.d.ts +10 -0
- package/dist/types/markit/converters/pdf/grid.d.ts +25 -0
- package/dist/types/markit/converters/pdf/headers.d.ts +24 -0
- package/dist/types/markit/converters/pdf/index.d.ts +6 -0
- package/dist/types/markit/converters/pdf/render.d.ts +24 -0
- package/dist/types/markit/converters/pdf/types.d.ts +75 -0
- package/dist/types/markit/converters/pptx.d.ts +57 -0
- package/dist/types/markit/converters/xlsx.d.ts +25 -0
- package/dist/types/markit/index.d.ts +2 -0
- package/dist/types/markit/registry.d.ts +16 -0
- package/dist/types/markit/types.d.ts +30 -0
- package/dist/types/session/agent-session.d.ts +7 -8
- package/dist/types/session/auth-storage.d.ts +3 -2
- package/dist/types/session/yield-queue.d.ts +3 -1
- package/dist/types/tools/browser/attach.d.ts +1 -1
- package/dist/types/utils/markit.d.ts +0 -8
- package/dist/types/utils/mupdf-wasm-embed.d.ts +1 -0
- package/dist/types/utils/turndown.d.ts +15 -0
- package/dist/types/utils/zip.d.ts +119 -0
- package/package.json +20 -18
- package/scripts/build-binary.ts +7 -3
- package/scripts/bundle-dist.ts +28 -12
- package/scripts/embed-mupdf-wasm.ts +67 -0
- package/scripts/generate-docs-index.ts +48 -32
- package/scripts/omp +1 -1
- package/src/advisor/__tests__/advisor.test.ts +83 -0
- package/src/advisor/runtime.ts +16 -1
- package/src/cli/auth-broker-cli.ts +1 -3
- package/src/cli/auth-gateway-cli.ts +2 -5
- package/src/cli/update-cli.ts +63 -3
- package/src/config/model-discovery.ts +20 -8
- package/src/config/models-config-schema.ts +8 -1
- package/src/debug/index.ts +44 -0
- package/src/debug/remote-debugger.ts +151 -0
- package/src/debug/report-bundle.ts +2 -1
- package/src/internal-urls/docs-index.generated.txt +2 -0
- package/src/internal-urls/docs-index.ts +102 -0
- package/src/internal-urls/omp-protocol.ts +10 -9
- package/src/markit/NOTICE +32 -0
- package/src/markit/converters/docx.ts +56 -0
- package/src/markit/converters/epub.ts +136 -0
- package/src/markit/converters/mammoth.d.ts +24 -0
- package/src/markit/converters/pdf/columns.ts +103 -0
- package/src/markit/converters/pdf/extract.ts +574 -0
- package/src/markit/converters/pdf/grid.ts +780 -0
- package/src/markit/converters/pdf/headers.ts +106 -0
- package/src/markit/converters/pdf/index.ts +146 -0
- package/src/markit/converters/pdf/render.ts +501 -0
- package/src/markit/converters/pdf/types.ts +84 -0
- package/src/markit/converters/pptx.ts +325 -0
- package/src/markit/converters/xlsx.ts +173 -0
- package/src/markit/index.ts +2 -0
- package/src/markit/registry.ts +59 -0
- package/src/markit/types.ts +35 -0
- package/src/modes/components/snapcompact-shape-preview-doc.md +14 -7
- package/src/modes/components/snapcompact-shape-preview.ts +2 -2
- package/src/modes/controllers/input-controller.ts +29 -8
- package/src/modes/interactive-mode.ts +26 -9
- package/src/prompts/advisor/system.md +1 -0
- package/src/sdk.ts +5 -9
- package/src/session/agent-session.ts +62 -40
- package/src/session/auth-storage.ts +2 -11
- package/src/session/yield-queue.ts +7 -1
- package/src/tools/browser/attach.ts +2 -2
- package/src/tools/fetch.ts +25 -60
- package/src/tools/read.ts +1 -1
- package/src/tools/search.ts +1 -6
- package/src/tools/write.ts +25 -65
- package/src/utils/markit.ts +25 -9
- package/src/utils/mupdf-wasm-embed.ts +12 -0
- package/src/utils/tools-manager.ts +2 -11
- package/src/utils/turndown.ts +83 -0
- package/src/{tools/archive-reader.ts → utils/zip.ts} +453 -83
- package/src/web/scrapers/types.ts +3 -46
- package/dist/types/internal-urls/docs-index.generated.d.ts +0 -2
- package/dist/types/tools/archive-reader.d.ts +0 -49
- package/src/internal-urls/docs-index.generated.ts +0 -120
|
@@ -27,6 +27,17 @@ interface UpdateMethodResolutionOptions {
|
|
|
27
27
|
miseDataDir?: string;
|
|
28
28
|
}
|
|
29
29
|
export declare function resolveUpdateMethodForTest(ompPath: string, bunBinDir: string | undefined, options?: UpdateMethodResolutionOptions): UpdateMethod;
|
|
30
|
+
/**
|
|
31
|
+
* Best-effort removal of binary-update backups left by earlier runs.
|
|
32
|
+
*
|
|
33
|
+
* Each self-update moves the previous executable to `<binary>.<timestamp>.<pid>.bak`
|
|
34
|
+
* before swapping the new one in. On Windows that backup cannot be deleted
|
|
35
|
+
* while the updating process is alive, so it is left for a later run to reclaim
|
|
36
|
+
* once its owning process has exited. Also matches the legacy fixed
|
|
37
|
+
* `<binary>.bak` name produced before backups were timestamped, so users
|
|
38
|
+
* upgrading from a buggy release get the orphaned file cleaned up.
|
|
39
|
+
*/
|
|
40
|
+
export declare function sweepStaleBackups(targetPath: string): Promise<void>;
|
|
30
41
|
/**
|
|
31
42
|
* Atomically replace the installed binary and roll back if version verification fails.
|
|
32
43
|
*/
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bun JavaScriptCore remote inspector control.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `bun:jsc`'s `startRemoteDebugger`, which exposes JavaScriptCore's
|
|
5
|
+
* built-in WebKit RemoteInspectorServer over a raw socket. The API is one-shot
|
|
6
|
+
* and rough around the edges (Bun documents it as untested, "may not be
|
|
7
|
+
* supported yet on macOS"):
|
|
8
|
+
* - it returns `void` and has no stop handle, so we track the live endpoint
|
|
9
|
+
* at module scope and make starting idempotent;
|
|
10
|
+
* - it rejects port `0`, so "let the OS pick" is implemented by reserving a
|
|
11
|
+
* free port via `node:net` and handing the concrete number to Bun;
|
|
12
|
+
* - on macOS (Bun 1.3.x) it throws a spurious "port already in use" error
|
|
13
|
+
* even when the server binds fine, so success is decided by a loopback
|
|
14
|
+
* probe rather than by whether the call threw.
|
|
15
|
+
*/
|
|
16
|
+
export interface RemoteDebuggerInfo {
|
|
17
|
+
host: string;
|
|
18
|
+
port: number;
|
|
19
|
+
}
|
|
20
|
+
/** Underlying starter signature; tests inject a disposable listener in its place. */
|
|
21
|
+
export type RemoteDebuggerStarter = (host: string, port: number) => void;
|
|
22
|
+
export interface StartRemoteDebuggerOptions {
|
|
23
|
+
/** Explicit port; when omitted a free port is reserved automatically. */
|
|
24
|
+
port?: number;
|
|
25
|
+
/** Override the JSC starter. Defaults to `bun:jsc`'s `startRemoteDebugger`. */
|
|
26
|
+
start?: RemoteDebuggerStarter;
|
|
27
|
+
}
|
|
28
|
+
/** The live inspector endpoint for this process, or `null` if not started. */
|
|
29
|
+
export declare function getRemoteDebugger(): RemoteDebuggerInfo | null;
|
|
30
|
+
/**
|
|
31
|
+
* Start the JavaScriptCore remote inspector for this process and return its
|
|
32
|
+
* endpoint. Idempotent: the underlying API cannot be stopped or rebound, so a
|
|
33
|
+
* second call returns the existing endpoint instead of starting again. When
|
|
34
|
+
* `port` is omitted a free port is reserved automatically.
|
|
35
|
+
*
|
|
36
|
+
* Throws only when the socket never comes up; Bun's spurious bind error is
|
|
37
|
+
* swallowed and overridden by the loopback probe.
|
|
38
|
+
*/
|
|
39
|
+
export declare function startRemoteDebuggerServer(options?: StartRemoteDebuggerOptions): Promise<RemoteDebuggerInfo>;
|
|
40
|
+
/**
|
|
41
|
+
* Test-only: forget the tracked endpoint so a fresh start can be exercised.
|
|
42
|
+
* Does not (and cannot) stop a real JSC inspector — callers in tests own the
|
|
43
|
+
* disposable listener they injected.
|
|
44
|
+
*/
|
|
45
|
+
export declare function __resetRemoteDebuggerForTests(): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface DocsIndex {
|
|
2
|
+
/** Sorted documentation file names, relative to `docs/`. */
|
|
3
|
+
readonly filenames: readonly string[];
|
|
4
|
+
/** Resolve a doc body by path; inflates the embedded bodies off-thread, lazily, on first call. */
|
|
5
|
+
getBody(relativePath: string): Promise<string | undefined>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Decode a populated two-line embed (`<filenames JSON>\n<base64 gzip of bodies>`)
|
|
9
|
+
* into a lazily-inflating index, or `null` when there is no newline separator
|
|
10
|
+
* (the empty placeholder, or a malformed payload — the caller decides which).
|
|
11
|
+
* Reading `filenames` never touches the blob; the bodies are gunzipped off the
|
|
12
|
+
* event loop into a path→content table on the first `getBody` call, and that
|
|
13
|
+
* work is shared across concurrent reads.
|
|
14
|
+
*/
|
|
15
|
+
export declare function decodeDocsIndex(embed: string): DocsIndex | null;
|
|
16
|
+
/** Sorted list of available documentation file names (relative to `docs/`). */
|
|
17
|
+
export declare function getDocFilenames(): readonly string[];
|
|
18
|
+
/** Resolve a documentation file's content, or `undefined` when not found. */
|
|
19
|
+
export declare function getEmbeddedDoc(relativePath: string): Promise<string | undefined>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ConversionResult, Converter, StreamInfo } from "../types";
|
|
2
|
+
export declare class DocxConverter implements Converter {
|
|
3
|
+
name: string;
|
|
4
|
+
accepts(streamInfo: StreamInfo): boolean;
|
|
5
|
+
convert(input: Buffer, streamInfo: StreamInfo): Promise<ConversionResult>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ConversionResult, Converter, StreamInfo } from "../types";
|
|
2
|
+
/** A metadata value: a bare string, or a node carrying `#text` and/or array children. */
|
|
3
|
+
type MetaValue = string | MetaNode;
|
|
4
|
+
interface MetaNode {
|
|
5
|
+
"#text"?: string;
|
|
6
|
+
[index: number]: MetaValue;
|
|
7
|
+
}
|
|
8
|
+
export declare class EpubConverter implements Converter {
|
|
9
|
+
name: string;
|
|
10
|
+
accepts(streamInfo: StreamInfo): boolean;
|
|
11
|
+
convert(input: Buffer, _streamInfo: StreamInfo): Promise<ConversionResult>;
|
|
12
|
+
getText(node: MetaValue | undefined): string | undefined;
|
|
13
|
+
getTextArray(node: MetaValue | undefined): (string | undefined)[];
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-column layout detection and text box reordering.
|
|
3
|
+
*
|
|
4
|
+
* Many PDFs (legal documents, datasheets, academic papers) use two-column
|
|
5
|
+
* layouts. Without column detection, text boxes are ordered by Y position
|
|
6
|
+
* only, interleaving left and right column content.
|
|
7
|
+
*
|
|
8
|
+
* Algorithm:
|
|
9
|
+
* 1. Collect left edges of all text boxes on the page
|
|
10
|
+
* 2. Find the largest horizontal gap between consecutive left edges
|
|
11
|
+
* 3. If gap > MIN_GAP_RATIO of the text width and both sides have
|
|
12
|
+
* enough boxes → multi-column detected
|
|
13
|
+
* 4. Assign each text box to a column based on its center X
|
|
14
|
+
* 5. Return columns in reading order (left-to-right, top-to-bottom)
|
|
15
|
+
*
|
|
16
|
+
* This only detects the column structure. The caller is responsible for
|
|
17
|
+
* processing each column's text boxes independently (table detection,
|
|
18
|
+
* rendering, etc.).
|
|
19
|
+
*/
|
|
20
|
+
import type { TextBox } from "./types";
|
|
21
|
+
export interface ColumnLayout {
|
|
22
|
+
/** Number of columns detected (1 = single column, 2+ = multi-column). */
|
|
23
|
+
columnCount: number;
|
|
24
|
+
/** Text boxes grouped by column, in reading order (left to right). */
|
|
25
|
+
columns: TextBox[][];
|
|
26
|
+
/** X positions of column boundaries (between columns). */
|
|
27
|
+
boundaries: number[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Detect column layout and return text boxes grouped by column.
|
|
31
|
+
*
|
|
32
|
+
* For single-column pages, returns all boxes in one group.
|
|
33
|
+
* For multi-column pages, returns boxes split by column in reading order.
|
|
34
|
+
*/
|
|
35
|
+
export declare function detectColumns(textBoxes: TextBox[]): ColumnLayout;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ImageRegion, PageContent } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Render an image region from a PDF page as a PNG buffer.
|
|
4
|
+
* Uses mupdf's DrawDevice to render just the cropped area at 2x resolution.
|
|
5
|
+
*/
|
|
6
|
+
export declare function renderImageRegion(input: Uint8Array, region: ImageRegion): Promise<Uint8Array>;
|
|
7
|
+
/**
|
|
8
|
+
* Extract text boxes and vector segments from all pages of a PDF buffer.
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractPages(input: Uint8Array): Promise<PageContent[]>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table grid detection from vector segments and text boxes.
|
|
3
|
+
*
|
|
4
|
+
* Ported from @oharato/pdf2md-ts with TypeScript types and without
|
|
5
|
+
* CJK-specific borderless table heuristics. The core algorithm:
|
|
6
|
+
*
|
|
7
|
+
* 1. Classify segments as horizontal or vertical lines
|
|
8
|
+
* 2. Group horizontal Y-lines into table groups (split by vertical gaps)
|
|
9
|
+
* 3. For each group:
|
|
10
|
+
* a. Full grid (H+V lines): build cells from grid intersections,
|
|
11
|
+
* place text via raycasting
|
|
12
|
+
* b. H-line only (no V lines): infer columns from text X positions
|
|
13
|
+
* 4. Prune empty rows/cols
|
|
14
|
+
*
|
|
15
|
+
* Coordinate system: PDF native (bottom-left origin, Y increases upward).
|
|
16
|
+
*/
|
|
17
|
+
import type { Segment, TableGrid, TextBox } from "./types";
|
|
18
|
+
export interface GridResult {
|
|
19
|
+
grids: TableGrid[];
|
|
20
|
+
consumedIds: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Detect all table grids on a single page from its text boxes and segments.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveTableGrids(pageNumber: number, textBoxes: TextBox[], segments: Segment[]): GridResult;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Running header/footer detection and removal.
|
|
3
|
+
*
|
|
4
|
+
* Many PDFs have repeated text at the top or bottom of every page:
|
|
5
|
+
* document titles, chapter names, page numbers, copyright notices.
|
|
6
|
+
* These pollute the markdown output as false headings or noise.
|
|
7
|
+
*
|
|
8
|
+
* Algorithm:
|
|
9
|
+
* 1. For each page, bucket text boxes by Y position (top/bottom zones)
|
|
10
|
+
* 2. Collect the text content at each zone across all pages
|
|
11
|
+
* 3. Text appearing on >20% of pages OR 8+ consecutive pages is a
|
|
12
|
+
* running header/footer
|
|
13
|
+
* 4. Remove matching text boxes before further processing
|
|
14
|
+
*/
|
|
15
|
+
import type { PageContent } from "./types";
|
|
16
|
+
/**
|
|
17
|
+
* Detect and remove running headers and footers from all pages.
|
|
18
|
+
* Mutates the pages array in place, removing header/footer text boxes.
|
|
19
|
+
*
|
|
20
|
+
* Uses two strategies:
|
|
21
|
+
* 1. Global frequency: text appearing on > 20% of all pages
|
|
22
|
+
* 2. Consecutive runs: text appearing on 8+ consecutive pages
|
|
23
|
+
*/
|
|
24
|
+
export declare function stripHeadersFooters(pages: PageContent[]): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ConversionResult, Converter, StreamInfo } from "../../types";
|
|
2
|
+
export declare class PdfConverter implements Converter {
|
|
3
|
+
name: string;
|
|
4
|
+
accepts(streamInfo: StreamInfo): boolean;
|
|
5
|
+
convert(input: Buffer, streamInfo: StreamInfo): Promise<ConversionResult>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown rendering for PDF pages.
|
|
3
|
+
*
|
|
4
|
+
* Converts table grids and free text boxes into markdown, handling:
|
|
5
|
+
* - Table grid → markdown table (`| col | col |`)
|
|
6
|
+
* - Free text → paragraphs with heading detection (by font size)
|
|
7
|
+
* - Content ordering (top-to-bottom via Y coordinate)
|
|
8
|
+
* - Paragraph wrap merging (lines broken across PDF line boundaries)
|
|
9
|
+
* - Page number removal
|
|
10
|
+
*
|
|
11
|
+
* Ported from @oharato/pdf2md-ts, stripped of CJK/TDnet-specific logic.
|
|
12
|
+
*/
|
|
13
|
+
import type { TableGrid, TextBox } from "./types";
|
|
14
|
+
/**
|
|
15
|
+
* Render a TableGrid as a markdown table.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderTableToMarkdown(table: TableGrid): string;
|
|
18
|
+
/**
|
|
19
|
+
* Render one page's content: free text and tables interleaved top-to-bottom.
|
|
20
|
+
*/
|
|
21
|
+
export declare function renderPageContent(freeTextBoxes: TextBox[], tables: TableGrid[], imageBlocks?: Array<{
|
|
22
|
+
topY: number;
|
|
23
|
+
markdown: string;
|
|
24
|
+
}>, allTextBoxes?: TextBox[]): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** Bounding box in PDF coordinate space (origin = bottom-left). */
|
|
2
|
+
export type Bounds = {
|
|
3
|
+
left: number;
|
|
4
|
+
right: number;
|
|
5
|
+
/** Higher value = higher on the page. */
|
|
6
|
+
top: number;
|
|
7
|
+
bottom: number;
|
|
8
|
+
};
|
|
9
|
+
/** A text fragment with position and font metadata. */
|
|
10
|
+
export type TextBox = {
|
|
11
|
+
id: string;
|
|
12
|
+
text: string;
|
|
13
|
+
bounds: Bounds;
|
|
14
|
+
pageNumber: number;
|
|
15
|
+
/** Dominant font size in points. */
|
|
16
|
+
fontSize: number;
|
|
17
|
+
/** True if rendered bold (font name or rendering mode). */
|
|
18
|
+
isBold: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** A horizontal or vertical line segment extracted from vector graphics. */
|
|
21
|
+
export type Segment = {
|
|
22
|
+
id: string;
|
|
23
|
+
x1: number;
|
|
24
|
+
y1: number;
|
|
25
|
+
x2: number;
|
|
26
|
+
y2: number;
|
|
27
|
+
};
|
|
28
|
+
/** A single cell in a resolved table grid. */
|
|
29
|
+
export type TableCell = {
|
|
30
|
+
row: number;
|
|
31
|
+
col: number;
|
|
32
|
+
text: string;
|
|
33
|
+
rowSpan: number;
|
|
34
|
+
colSpan: number;
|
|
35
|
+
};
|
|
36
|
+
/** A resolved table grid ready for markdown rendering. */
|
|
37
|
+
export type TableGrid = {
|
|
38
|
+
pageNumber: number;
|
|
39
|
+
rows: number;
|
|
40
|
+
cols: number;
|
|
41
|
+
cells: TableCell[];
|
|
42
|
+
warnings: string[];
|
|
43
|
+
/** Top Y coordinate (PDF space: larger = higher on page). */
|
|
44
|
+
topY: number;
|
|
45
|
+
/** True for tables detected without vector borders. */
|
|
46
|
+
isBorderless: boolean;
|
|
47
|
+
};
|
|
48
|
+
/** An image/diagram region detected on a page. */
|
|
49
|
+
export type ImageRegion = {
|
|
50
|
+
id: string;
|
|
51
|
+
pageNumber: number;
|
|
52
|
+
/** Bounding box in mupdf coordinates (top-left origin). */
|
|
53
|
+
bbox: {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
w: number;
|
|
57
|
+
h: number;
|
|
58
|
+
};
|
|
59
|
+
/** Y position in PDF coordinates (bottom-left) for ordering. */
|
|
60
|
+
topY: number;
|
|
61
|
+
};
|
|
62
|
+
/** Result of extracting content from a single PDF page. */
|
|
63
|
+
export type PageContent = {
|
|
64
|
+
pageNumber: number;
|
|
65
|
+
textBoxes: TextBox[];
|
|
66
|
+
segments: Segment[];
|
|
67
|
+
images: ImageRegion[];
|
|
68
|
+
};
|
|
69
|
+
/** A block of rendered content (text paragraph or table). */
|
|
70
|
+
export type ContentBlock = {
|
|
71
|
+
topY: number;
|
|
72
|
+
content: string;
|
|
73
|
+
/** True if this line has wide gaps between text boxes (column headers). */
|
|
74
|
+
isTabular?: boolean;
|
|
75
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ConversionResult, Converter, StreamInfo } from "../types";
|
|
2
|
+
/** A text value: bare string/number, or a `{ "#text" }` node when the element carries attributes. */
|
|
3
|
+
type XmlText = string | number | {
|
|
4
|
+
"#text"?: string;
|
|
5
|
+
};
|
|
6
|
+
interface TextRun {
|
|
7
|
+
"a:t"?: XmlText;
|
|
8
|
+
}
|
|
9
|
+
interface Paragraph {
|
|
10
|
+
"a:r"?: TextRun | TextRun[];
|
|
11
|
+
}
|
|
12
|
+
interface TextBody {
|
|
13
|
+
"a:p"?: Paragraph | Paragraph[];
|
|
14
|
+
}
|
|
15
|
+
interface CNvPr {
|
|
16
|
+
"@_name": string;
|
|
17
|
+
}
|
|
18
|
+
interface Placeholder {
|
|
19
|
+
"@_type": string;
|
|
20
|
+
}
|
|
21
|
+
interface NvPr {
|
|
22
|
+
"p:ph"?: Placeholder;
|
|
23
|
+
}
|
|
24
|
+
interface NvSpPr {
|
|
25
|
+
"p:cNvPr"?: CNvPr;
|
|
26
|
+
"p:nvPr"?: NvPr;
|
|
27
|
+
}
|
|
28
|
+
interface Shape {
|
|
29
|
+
"p:txBody"?: TextBody;
|
|
30
|
+
"p:nvSpPr"?: NvSpPr;
|
|
31
|
+
}
|
|
32
|
+
interface TableCell {
|
|
33
|
+
"a:txBody"?: TextBody;
|
|
34
|
+
}
|
|
35
|
+
interface TableRow {
|
|
36
|
+
"a:tc"?: TableCell | TableCell[];
|
|
37
|
+
}
|
|
38
|
+
interface Table {
|
|
39
|
+
"a:tr"?: TableRow | TableRow[];
|
|
40
|
+
}
|
|
41
|
+
interface GraphicData {
|
|
42
|
+
"a:tbl"?: Table;
|
|
43
|
+
}
|
|
44
|
+
interface Graphic {
|
|
45
|
+
"a:graphicData"?: GraphicData;
|
|
46
|
+
}
|
|
47
|
+
interface GraphicFrame {
|
|
48
|
+
"a:graphic"?: Graphic;
|
|
49
|
+
}
|
|
50
|
+
export declare class PptxConverter implements Converter {
|
|
51
|
+
name: string;
|
|
52
|
+
accepts(streamInfo: StreamInfo): boolean;
|
|
53
|
+
convert(input: Buffer, streamInfo: StreamInfo): Promise<ConversionResult>;
|
|
54
|
+
extractText(shape: Shape): string;
|
|
55
|
+
extractTable(gf: GraphicFrame): string | null;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ConversionResult, Converter, StreamInfo } from "../types";
|
|
2
|
+
/** A text value: bare string/number, or a `{ "#text" }` node when the element carries attributes. */
|
|
3
|
+
type XmlText = string | number | {
|
|
4
|
+
"#text"?: string;
|
|
5
|
+
};
|
|
6
|
+
interface RichTextRun {
|
|
7
|
+
t?: XmlText;
|
|
8
|
+
}
|
|
9
|
+
interface StringItem {
|
|
10
|
+
t?: XmlText;
|
|
11
|
+
r?: RichTextRun | RichTextRun[];
|
|
12
|
+
}
|
|
13
|
+
interface Cell {
|
|
14
|
+
"@_t"?: string;
|
|
15
|
+
v?: string | number;
|
|
16
|
+
is?: StringItem;
|
|
17
|
+
}
|
|
18
|
+
export declare class XlsxConverter implements Converter {
|
|
19
|
+
name: string;
|
|
20
|
+
accepts(streamInfo: StreamInfo): boolean;
|
|
21
|
+
convert(input: Buffer, _streamInfo: StreamInfo): Promise<ConversionResult>;
|
|
22
|
+
getCellValue(cell: Cell, shared: StringItem[]): string;
|
|
23
|
+
getSharedString(shared: StringItem[], idx: number): string;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ConversionResult, MarkitOptions, StreamInfo } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* In-house document → markdown engine (replaces the `markit-ai` package).
|
|
4
|
+
*
|
|
5
|
+
* Only the document converters omp routes are registered (pdf, docx, pptx,
|
|
6
|
+
* xlsx, epub). The first converter whose `accepts()` returns true and whose
|
|
7
|
+
* `convert()` succeeds wins.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Markit {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(options?: MarkitOptions);
|
|
12
|
+
convertFile(filePath: string, extra?: {
|
|
13
|
+
imageDir?: string;
|
|
14
|
+
}): Promise<ConversionResult>;
|
|
15
|
+
convert(input: Buffer, streamInfo: StreamInfo): Promise<ConversionResult>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface StreamInfo {
|
|
2
|
+
mimetype?: string;
|
|
3
|
+
extension?: string;
|
|
4
|
+
charset?: string;
|
|
5
|
+
filename?: string;
|
|
6
|
+
localPath?: string;
|
|
7
|
+
url?: string;
|
|
8
|
+
/** Directory to write extracted images/diagrams. */
|
|
9
|
+
imageDir?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ConversionResult {
|
|
12
|
+
markdown: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface MarkitOptions {
|
|
16
|
+
/** Describe an image, return markdown. Receives raw bytes and mimetype. */
|
|
17
|
+
describe?: (image: Buffer, mimetype: string) => Promise<string>;
|
|
18
|
+
/** Transcribe audio, return text. Receives raw bytes and mimetype. */
|
|
19
|
+
transcribe?: (audio: Buffer, mimetype: string) => Promise<string>;
|
|
20
|
+
/** Extra instructions appended to the image description prompt. */
|
|
21
|
+
prompt?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface Converter {
|
|
24
|
+
/** Human-readable name for error messages. */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Quick check: can this converter handle the given stream? */
|
|
27
|
+
accepts(streamInfo: StreamInfo): boolean;
|
|
28
|
+
/** Convert the source to markdown. */
|
|
29
|
+
convert(input: Buffer, streamInfo: StreamInfo, options?: MarkitOptions): Promise<ConversionResult>;
|
|
30
|
+
}
|
|
@@ -397,18 +397,17 @@ export declare class AgentSession {
|
|
|
397
397
|
get obfuscator(): SecretObfuscator | undefined;
|
|
398
398
|
/** Whether a TTSR abort is pending (stream was aborted to inject rules) */
|
|
399
399
|
get isTtsrAbortPending(): boolean;
|
|
400
|
-
/** Whether
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
|
|
404
|
-
get isPlanCompactAbortPending(): boolean;
|
|
400
|
+
/** Whether an expected internal plan-mode abort is pending. Consumed by
|
|
401
|
+
* `#handleAgentEvent` to stamp `SILENT_ABORT_MARKER` on the next aborted
|
|
402
|
+
* assistant message_end; callers clear it in `finally`. */
|
|
403
|
+
get isPlanInternalAbortPending(): boolean;
|
|
405
404
|
/** Arm the silent-abort marker for the next aborted assistant message_end.
|
|
406
|
-
* Caller MUST clear via `
|
|
405
|
+
* Caller MUST clear via `clearPlanInternalAbortPending()` in a `finally`
|
|
407
406
|
* to guarantee no leak. */
|
|
408
|
-
|
|
407
|
+
markPlanInternalAbortPending(): void;
|
|
409
408
|
/** Unconditionally clear the silent-abort flag. Idempotent: safe when the
|
|
410
409
|
* flag was never set OR was already consumed by `#handleAgentEvent`. */
|
|
411
|
-
|
|
410
|
+
clearPlanInternalAbortPending(): void;
|
|
412
411
|
getAsyncJobSnapshot(options?: {
|
|
413
412
|
recentLimit?: number;
|
|
414
413
|
}): AsyncJobSnapshot | null;
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* Re-exports from @oh-my-pi/pi-ai.
|
|
3
3
|
* All credential storage types and the AuthStorage class now live in the ai package.
|
|
4
4
|
*/
|
|
5
|
-
export type { ApiKeyCredential, AuthCredential, AuthCredentialEntry, AuthCredentialStore, AuthStorageData, AuthStorageOptions, CredentialOrigin, CredentialOriginKind, OAuthAccountIdentity, OAuthCredential, ResetCreditAccountStatus, ResetCreditRedeemOutcome, ResetCreditTarget, SerializedAuthStorage,
|
|
6
|
-
export {
|
|
5
|
+
export type { ApiKeyCredential, AuthCredential, AuthCredentialEntry, AuthCredentialStore, AuthStorageData, AuthStorageOptions, CredentialOrigin, CredentialOriginKind, OAuthAccountIdentity, OAuthCredential, ResetCreditAccountStatus, ResetCreditRedeemOutcome, ResetCreditTarget, SerializedAuthStorage, StoredAuthCredential, } from "@oh-my-pi/pi-ai";
|
|
6
|
+
export { AuthStorage, REMOTE_REFRESH_SENTINEL, SqliteAuthCredentialStore } from "@oh-my-pi/pi-ai";
|
|
7
|
+
export type { SnapshotResponse } from "@oh-my-pi/pi-ai/auth-broker/types";
|
|
@@ -30,6 +30,8 @@ export declare class YieldQueue {
|
|
|
30
30
|
* the model between requests without the agent having to stop.
|
|
31
31
|
*/
|
|
32
32
|
drainLazy(): Array<() => AgentMessage | null>;
|
|
33
|
-
|
|
33
|
+
/** Drop queued entries. With `kind`, drop only that kind's entries (leaving
|
|
34
|
+
* any pending idle-flush for other kinds intact); otherwise drop everything. */
|
|
35
|
+
clear(kind?: string): void;
|
|
34
36
|
}
|
|
35
37
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Browser, Page } from "puppeteer-core";
|
|
2
2
|
/**
|
|
3
3
|
* Allocate an unused TCP port on 127.0.0.1 by binding to port 0 and reading
|
|
4
4
|
* back the kernel-assigned port. There's a small race between close and the
|
|
@@ -12,13 +12,5 @@ export interface MarkitFileConversionOptions {
|
|
|
12
12
|
*/
|
|
13
13
|
imageDir?: string;
|
|
14
14
|
}
|
|
15
|
-
interface MuPdfWasmModuleConfig {
|
|
16
|
-
print?: (...values: unknown[]) => void;
|
|
17
|
-
printErr?: (...values: unknown[]) => void;
|
|
18
|
-
}
|
|
19
|
-
declare global {
|
|
20
|
-
var $libmupdf_wasm_Module: MuPdfWasmModuleConfig | undefined;
|
|
21
|
-
}
|
|
22
15
|
export declare function convertFileWithMarkit(filePath: string, signal?: AbortSignal, options?: MarkitFileConversionOptions): Promise<MarkitConversionResult>;
|
|
23
16
|
export declare function convertBufferWithMarkit(buffer: Uint8Array, extension: string, signal?: AbortSignal): Promise<MarkitConversionResult>;
|
|
24
|
-
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function loadEmbeddedMupdfWasm(): Uint8Array | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import TurndownService from "turndown";
|
|
2
|
+
/**
|
|
3
|
+
* Build a Turndown instance configured for GFM with the fixes omp relies on:
|
|
4
|
+
* `~~strikethrough~~`, unescaped heading periods, and single-space list markers.
|
|
5
|
+
*
|
|
6
|
+
* Shared by the web scrapers (HTML → markdown) and the markit document engine
|
|
7
|
+
* (`src/markit`). The rule set must stay identical across both call sites.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createTurndown(): TurndownService;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize HTML tables so turndown-plugin-gfm can render them:
|
|
12
|
+
* - strip `<p>` tags inside `<td>`/`<th>` cells (joining paragraphs with a space)
|
|
13
|
+
* - wrap the first row in `<thead>` when missing
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeTablesHtml(html: string): string;
|