@tita-agent/dsh-data-table 0.0.0-stage → 0.2.0
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 +172 -2
- package/cordis.patch.yml +7 -0
- package/lib/client.js +16766 -0
- package/lib/contract-envelope.d.ts +91 -0
- package/lib/contract-envelope.js +106 -0
- package/lib/contract-layout.d.ts +130 -0
- package/lib/contract-layout.js +138 -0
- package/lib/contract-refs.d.ts +39 -0
- package/lib/contract-refs.js +9 -0
- package/lib/contract-version.d.ts +311 -0
- package/lib/contract-version.js +270 -0
- package/lib/contract-wire.d.ts +147 -0
- package/lib/contract-wire.js +99 -0
- package/lib/contracts.d.ts +12 -0
- package/lib/contracts.js +12 -0
- package/lib/types/audit.d.ts +42 -0
- package/lib/types/audit.js +39 -0
- package/lib/types/client/ProjectImportMenu.d.ts +30 -0
- package/lib/types/client/ProjectImportMenu.js +70 -0
- package/lib/types/client/SheetPanel.d.ts +33 -0
- package/lib/types/client/SheetPanel.js +1766 -0
- package/lib/types/client/SheetToggle.d.ts +18 -0
- package/lib/types/client/SheetToggle.js +26 -0
- package/lib/types/client/index.d.ts +15 -0
- package/lib/types/client/index.js +110 -0
- package/lib/types/client/persistence/changes.d.ts +15 -0
- package/lib/types/client/persistence/changes.js +51 -0
- package/lib/types/client/persistence/ids.d.ts +34 -0
- package/lib/types/client/persistence/ids.js +48 -0
- package/lib/types/client/persistence/merge.d.ts +35 -0
- package/lib/types/client/persistence/merge.js +362 -0
- package/lib/types/client/store.d.ts +61 -0
- package/lib/types/client/store.js +152 -0
- package/lib/types/client/surface-context.d.ts +27 -0
- package/lib/types/client/surface-context.js +104 -0
- package/lib/types/client/surface-control.d.ts +2 -0
- package/lib/types/client/surface-control.js +12 -0
- package/lib/types/client/transport/workbookApi.d.ts +159 -0
- package/lib/types/client/transport/workbookApi.js +246 -0
- package/lib/types/client/univer/StandaloneWorkbookPage.d.ts +5 -0
- package/lib/types/client/univer/StandaloneWorkbookPage.js +7 -0
- package/lib/types/client/univer/WorkbookCanvas.d.ts +40 -0
- package/lib/types/client/univer/WorkbookCanvas.js +87 -0
- package/lib/types/client/univer/WorkbookView.d.ts +3 -0
- package/lib/types/client/univer/WorkbookView.js +2 -0
- package/lib/types/client/univer/loader.d.ts +18 -0
- package/lib/types/client/univer/loader.js +81 -0
- package/lib/types/client/univer/standalone-entry.d.ts +1 -0
- package/lib/types/client/univer/standalone-entry.js +19 -0
- package/lib/types/client/versions/VersionChrome.d.ts +33 -0
- package/lib/types/client/versions/VersionChrome.js +21 -0
- package/lib/types/client/versions/inspect.d.ts +70 -0
- package/lib/types/client/versions/inspect.js +88 -0
- package/lib/types/client/versions/preview-decoration.d.ts +11 -0
- package/lib/types/client/versions/preview-decoration.js +54 -0
- package/lib/types/client/versions/records.d.ts +19 -0
- package/lib/types/client/versions/records.js +70 -0
- package/lib/types/client/workspace-host.d.ts +61 -0
- package/lib/types/client/workspace-host.js +124 -0
- package/lib/types/collaboration-hub.d.ts +31 -0
- package/lib/types/collaboration-hub.js +69 -0
- package/lib/types/contract/ids.d.ts +24 -0
- package/lib/types/contract/ids.js +46 -0
- package/lib/types/contract/mutations.d.ts +25 -0
- package/lib/types/contract/mutations.js +782 -0
- package/lib/types/contract/operations.d.ts +54 -0
- package/lib/types/contract/operations.js +203 -0
- package/lib/types/contract/snapshots.d.ts +176 -0
- package/lib/types/contract/snapshots.js +351 -0
- package/lib/types/contract/univer-api-catalog.d.ts +29 -0
- package/lib/types/contract/univer-api-catalog.js +264 -0
- package/lib/types/errors.d.ts +8 -0
- package/lib/types/errors.js +12 -0
- package/lib/types/http/assets-routes.d.ts +3 -0
- package/lib/types/http/assets-routes.js +169 -0
- package/lib/types/http/collaboration.d.ts +10 -0
- package/lib/types/http/collaboration.js +154 -0
- package/lib/types/http/history.d.ts +15 -0
- package/lib/types/http/history.js +134 -0
- package/lib/types/http/project-files.d.ts +79 -0
- package/lib/types/http/project-files.js +206 -0
- package/lib/types/http/project-scope.d.ts +50 -0
- package/lib/types/http/project-scope.js +52 -0
- package/lib/types/http/routes.d.ts +98 -0
- package/lib/types/http/routes.js +323 -0
- package/lib/types/http/standalone.d.ts +9 -0
- package/lib/types/http/standalone.js +31 -0
- package/lib/types/http/trunk.d.ts +10 -0
- package/lib/types/http/trunk.js +322 -0
- package/lib/types/http/worktree.d.ts +9 -0
- package/lib/types/http/worktree.js +145 -0
- package/lib/types/index.d.ts +18 -0
- package/lib/types/index.js +156 -0
- package/lib/types/invariant.d.ts +15 -0
- package/lib/types/invariant.js +15 -0
- package/lib/types/request-params.d.ts +21 -0
- package/lib/types/request-params.js +76 -0
- package/lib/types/store/paths.d.ts +68 -0
- package/lib/types/store/paths.js +148 -0
- package/lib/types/store/project.d.ts +88 -0
- package/lib/types/store/project.js +120 -0
- package/lib/types/store/read.d.ts +110 -0
- package/lib/types/store/read.js +404 -0
- package/lib/types/store/retention.d.ts +27 -0
- package/lib/types/store/retention.js +111 -0
- package/lib/types/store/write.d.ts +22 -0
- package/lib/types/store/write.js +210 -0
- package/lib/types/tools/arguments.d.ts +40 -0
- package/lib/types/tools/arguments.js +130 -0
- package/lib/types/tools/cells.d.ts +50 -0
- package/lib/types/tools/cells.js +298 -0
- package/lib/types/tools/index.d.ts +2 -0
- package/lib/types/tools/index.js +250 -0
- package/lib/types/tools/render.d.ts +47 -0
- package/lib/types/tools/render.js +290 -0
- package/lib/types/tools/univer-api.d.ts +18 -0
- package/lib/types/tools/univer-api.js +198 -0
- package/lib/types/tools/workbook-catalog.d.ts +3 -0
- package/lib/types/tools/workbook-catalog.js +83 -0
- package/lib/types/tools/workbook-edit.d.ts +192 -0
- package/lib/types/tools/workbook-edit.js +912 -0
- package/lib/types/tools/workbook-find.d.ts +11 -0
- package/lib/types/tools/workbook-find.js +89 -0
- package/lib/types/tools/workbook-history.d.ts +2 -0
- package/lib/types/tools/workbook-history.js +59 -0
- package/lib/types/tools/workbook-read.d.ts +21 -0
- package/lib/types/tools/workbook-read.js +204 -0
- package/lib/types/types.d.ts +377 -0
- package/lib/types/types.js +34 -0
- package/lib/types/univer/apply-operation.d.ts +14 -0
- package/lib/types/univer/apply-operation.js +398 -0
- package/lib/types/univer/chunk.d.ts +68 -0
- package/lib/types/univer/chunk.js +16 -0
- package/lib/types/univer/decoration.d.ts +34 -0
- package/lib/types/univer/decoration.js +88 -0
- package/lib/types/univer/diagnostics.d.ts +31 -0
- package/lib/types/univer/diagnostics.js +141 -0
- package/lib/types/univer/engine.d.ts +33 -0
- package/lib/types/univer/engine.js +338 -0
- package/lib/types/univer/entry.d.ts +8 -0
- package/lib/types/univer/entry.js +11 -0
- package/lib/types/univer/facade.d.ts +107 -0
- package/lib/types/univer/facade.js +1 -0
- package/lib/types/univer/fonts.d.ts +202 -0
- package/lib/types/univer/fonts.js +140 -0
- package/lib/types/univer/plugins/collaboration.d.ts +23 -0
- package/lib/types/univer/plugins/collaboration.js +47 -0
- package/lib/types/univer/plugins/export.d.ts +39 -0
- package/lib/types/univer/plugins/export.js +246 -0
- package/lib/types/univer/plugins/history.d.ts +24 -0
- package/lib/types/univer/plugins/history.js +50 -0
- package/lib/types/univer/plugins/version.d.ts +13 -0
- package/lib/types/univer/plugins/version.js +13 -0
- package/lib/types/version/diff.d.ts +36 -0
- package/lib/types/version/diff.js +156 -0
- package/lib/types/version/grouping.d.ts +7 -0
- package/lib/types/version/grouping.js +94 -0
- package/lib/types/version/records.d.ts +17 -0
- package/lib/types/version/records.js +102 -0
- package/lib/types/version/session.d.ts +36 -0
- package/lib/types/version/session.js +89 -0
- package/lib/types/version/summary.d.ts +24 -0
- package/lib/types/version/summary.js +111 -0
- package/lib/types/workbook-manager.d.ts +191 -0
- package/lib/types/workbook-manager.js +935 -0
- package/lib/types/xlsx-export-worker.d.ts +5 -0
- package/lib/types/xlsx-export-worker.js +24 -0
- package/lib/types/xlsx-export.d.ts +21 -0
- package/lib/types/xlsx-export.js +371 -0
- package/lib/types/xlsx-import-worker.d.ts +1 -0
- package/lib/types/xlsx-import-worker.js +19 -0
- package/lib/univer-client.js +690 -0
- package/lib/workbook-page.js +23826 -0
- package/lib/xlsx-export-worker.js +104 -0
- package/lib/xlsx-import-worker.js +46 -0
- package/package.json +106 -3
- package/src/audit.ts +58 -0
- package/src/client/ProjectImportMenu.tsx +100 -0
- package/src/client/SheetPanel.module.css +1578 -0
- package/src/client/SheetPanel.tsx +1934 -0
- package/src/client/SheetToggle.module.css +73 -0
- package/src/client/SheetToggle.tsx +65 -0
- package/src/client/contract.d.ts +19 -0
- package/src/client/index.ts +131 -0
- package/src/client/persistence/changes.ts +58 -0
- package/src/client/persistence/ids.ts +60 -0
- package/src/client/persistence/merge.ts +392 -0
- package/src/client/store.ts +188 -0
- package/src/client/surface-context.ts +123 -0
- package/src/client/surface-control.ts +13 -0
- package/src/client/transport/workbookApi.ts +355 -0
- package/src/client/univer/SheetView.module.css +110 -0
- package/src/client/univer/StandaloneWorkbookPage.module.css +8 -0
- package/src/client/univer/StandaloneWorkbookPage.tsx +15 -0
- package/src/client/univer/WorkbookCanvas.tsx +128 -0
- package/src/client/univer/WorkbookView.module.css +30 -0
- package/src/client/univer/WorkbookView.tsx +3 -0
- package/src/client/univer/loader.ts +90 -0
- package/src/client/univer/react-dom-client.d.ts +10 -0
- package/src/client/univer/standalone-entry.tsx +19 -0
- package/src/client/univer/standalone.css +12 -0
- package/src/client/univer/univer-locales.d.ts +89 -0
- package/src/client/univer/univer-modules.d.ts +26 -0
- package/src/client/versions/VersionChrome.tsx +114 -0
- package/src/client/versions/inspect.ts +138 -0
- package/src/client/versions/preview-decoration.ts +54 -0
- package/src/client/versions/records.ts +78 -0
- package/src/client/workspace-host.ts +147 -0
- package/src/collaboration-hub.ts +83 -0
- package/src/contract/ids.ts +50 -0
- package/src/contract/mutations.ts +791 -0
- package/src/contract/operations.ts +221 -0
- package/src/contract/snapshots.ts +383 -0
- package/src/contract/univer-api-catalog.ts +289 -0
- package/src/css-modules.d.ts +6 -0
- package/src/errors.ts +25 -0
- package/src/http/assets-routes.ts +177 -0
- package/src/http/collaboration.ts +144 -0
- package/src/http/history.ts +151 -0
- package/src/http/project-files.ts +227 -0
- package/src/http/project-scope.ts +77 -0
- package/src/http/routes.ts +364 -0
- package/src/http/standalone.ts +32 -0
- package/src/http/trunk.ts +322 -0
- package/src/http/worktree.ts +119 -0
- package/src/index.ts +165 -0
- package/src/invariant.ts +17 -0
- package/src/request-params.ts +92 -0
- package/src/store/paths.ts +165 -0
- package/src/store/project.ts +137 -0
- package/src/store/read.ts +454 -0
- package/src/store/retention.ts +106 -0
- package/src/store/write.ts +230 -0
- package/src/tools/arguments.ts +128 -0
- package/src/tools/cells.ts +298 -0
- package/src/tools/index.ts +274 -0
- package/src/tools/render.ts +301 -0
- package/src/tools/univer-api.ts +243 -0
- package/src/tools/workbook-catalog.ts +94 -0
- package/src/tools/workbook-edit.ts +987 -0
- package/src/tools/workbook-find.ts +80 -0
- package/src/tools/workbook-history.ts +63 -0
- package/src/tools/workbook-read.ts +210 -0
- package/src/types.ts +432 -0
- package/src/univer/apply-operation.ts +369 -0
- package/src/univer/chunk.ts +77 -0
- package/src/univer/decoration.ts +111 -0
- package/src/univer/diagnostics.ts +136 -0
- package/src/univer/engine.ts +370 -0
- package/src/univer/entry.ts +14 -0
- package/src/univer/facade.ts +91 -0
- package/src/univer/fonts.ts +148 -0
- package/src/univer/overrides.css +33 -0
- package/src/univer/plugins/collaboration.ts +47 -0
- package/src/univer/plugins/export.ts +236 -0
- package/src/univer/plugins/history.ts +49 -0
- package/src/univer/plugins/version.ts +13 -0
- package/src/version/diff.ts +169 -0
- package/src/version/grouping.ts +96 -0
- package/src/version/records.ts +113 -0
- package/src/version/session.ts +90 -0
- package/src/version/summary.ts +117 -0
- package/src/workbook-manager.ts +1111 -0
- package/src/xlsx-export-worker.ts +34 -0
- package/src/xlsx-export.ts +373 -0
- package/src/xlsx-import-worker.ts +30 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 结果信封:工具与 HTTP 返回的统一形状。
|
|
3
|
+
*
|
|
4
|
+
* 这一组的寿命最长、变更最慢——它是跨插件与跨工具的**约定**,改它等于改所有人的
|
|
5
|
+
* 返回形状。`Envelope<T,E>` 把载荷放在 `data` 下,`status` 由 `toolStatus()` 单点派生
|
|
6
|
+
* (有 warning 即 `partial`,无则 `success`;`failed` 没有 warning 形态)。
|
|
7
|
+
*
|
|
8
|
+
* `isRecord` 也在这里:它是构造与校验这些信封时用的通用对象守卫。
|
|
9
|
+
*
|
|
10
|
+
* 见 spec/contracts/envelope.json。
|
|
11
|
+
*/
|
|
12
|
+
export interface DataError {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
/** A model/client-readable next action, not an opaque stack trace. */
|
|
16
|
+
nextAction?: string;
|
|
17
|
+
retryable?: boolean;
|
|
18
|
+
details?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/** The statuses a call that returned usable data can carry. */
|
|
21
|
+
export type SuccessStatus = 'success' | 'partial';
|
|
22
|
+
/**
|
|
23
|
+
* Outcome of one tool call or HTTP response (spec/contracts/envelope.json).
|
|
24
|
+
*
|
|
25
|
+
* `partial` is not "many warnings": it means the call produced a usable result
|
|
26
|
+
* while something in it was skipped or downgraded, so a caller may proceed but
|
|
27
|
+
* must still read `warnings`. That is why the status is derived once
|
|
28
|
+
* ({@link toolStatus}) instead of being written by hand at every return site —
|
|
29
|
+
* three hand-written copies is how `error: null` went missing from the
|
|
30
|
+
* intent envelopes.
|
|
31
|
+
*
|
|
32
|
+
* `failed` is the only status a caller can trust without reading the payload:
|
|
33
|
+
* an envelope that carries it has `ok: false` and a non-null error.
|
|
34
|
+
*/
|
|
35
|
+
export type ToolStatus = SuccessStatus | 'failed';
|
|
36
|
+
/**
|
|
37
|
+
* The unified response envelope: exactly the five keys the frozen contract
|
|
38
|
+
* names, and no others.
|
|
39
|
+
*
|
|
40
|
+
* It stays a discriminated union on `ok` for the same reason `DataResult` does:
|
|
41
|
+
* `if (!result.ok)` must hand the caller a non-null `error` without a second
|
|
42
|
+
* guard, which is how transport and tool code reads it. The union also pins the
|
|
43
|
+
* one status pairing that matters — `failed` only ever rides with `ok: false`.
|
|
44
|
+
*
|
|
45
|
+
* The error type is generic so a domain plugin can narrow it (for example
|
|
46
|
+
* `Envelope<T, KnowledgeError>` to keep `retryable` / `suggestion` visible)
|
|
47
|
+
* without forking the envelope itself.
|
|
48
|
+
*/
|
|
49
|
+
export type Envelope<T, E extends DataError = DataError> = {
|
|
50
|
+
ok: true;
|
|
51
|
+
status: SuccessStatus;
|
|
52
|
+
data: T;
|
|
53
|
+
warnings: string[];
|
|
54
|
+
error: null;
|
|
55
|
+
} | {
|
|
56
|
+
ok: false;
|
|
57
|
+
status: 'failed';
|
|
58
|
+
data: T;
|
|
59
|
+
warnings: string[];
|
|
60
|
+
error: E;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* The status rule, in one place: a call that produced warnings is `partial`,
|
|
64
|
+
* one that produced none is `success`. `failed` has no warning form — a failure
|
|
65
|
+
* carries an error, so it comes from {@link envelopeFailure}.
|
|
66
|
+
*/
|
|
67
|
+
export declare function toolStatus(warnings?: readonly string[]): SuccessStatus;
|
|
68
|
+
/** A successful envelope; downgraded to `partial` when there are warnings. */
|
|
69
|
+
export declare function envelopeSuccess<T, E extends DataError = DataError>(data: T, warnings?: string[]): Envelope<T, E>;
|
|
70
|
+
/** A failed envelope. `data` still carries whatever partial payload exists. */
|
|
71
|
+
export declare function envelopeFailure<T, E extends DataError = DataError>(data: T, error: E): Envelope<T, E>;
|
|
72
|
+
/**
|
|
73
|
+
* 把一份载荷收成「JSON 装得下的样子」:丢掉值为 `undefined` 的键、数组空位补成
|
|
74
|
+
* `null`、非有限数(`NaN` / `±Infinity`)与 `-0` 归一,类实例(`Date`、自定义类)
|
|
75
|
+
* 变成它的可枚举自有属性。
|
|
76
|
+
*
|
|
77
|
+
* 为什么信封这一层要做:工具返回值会被原样写进会话日志,平台的
|
|
78
|
+
* `snapshotJsonValue` 只收 lossless JSON —— **对象里一个值为 `undefined` 的键就足以
|
|
79
|
+
* 让整次调用判为非法输出**(`INVALID_TOOL_OUTPUT`)。而 HTTP 那条路是
|
|
80
|
+
* `JSON.stringify`,本来就丢掉 `undefined`,所以这个错永远只在工具调用上现形,
|
|
81
|
+
* 而且现形成「明明成功却报错」。
|
|
82
|
+
*
|
|
83
|
+
* 实跑复现(0045):`rebuild_knowledge` 只重建 wiki 时,报告里的
|
|
84
|
+
* `vectorQuantization` / `embeddingDimension` 是 `undefined` —— 卡片、`wiki_notes`、
|
|
85
|
+
* 图谱、FTS 全都已经落盘,调用方收到的是 `value is not lossless JSON`。
|
|
86
|
+
*
|
|
87
|
+
* 语义就是 `JSON.parse(JSON.stringify(v))`,只是不真的走一遍字符串。干净的值原样
|
|
88
|
+
* 返回(不复制),所以每次调用不会为一份没问题的载荷多付一次深拷贝。
|
|
89
|
+
*/
|
|
90
|
+
export declare function jsonSafe<T>(value: T): T;
|
|
91
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 结果信封:工具与 HTTP 返回的统一形状。
|
|
3
|
+
*
|
|
4
|
+
* 这一组的寿命最长、变更最慢——它是跨插件与跨工具的**约定**,改它等于改所有人的
|
|
5
|
+
* 返回形状。`Envelope<T,E>` 把载荷放在 `data` 下,`status` 由 `toolStatus()` 单点派生
|
|
6
|
+
* (有 warning 即 `partial`,无则 `success`;`failed` 没有 warning 形态)。
|
|
7
|
+
*
|
|
8
|
+
* `isRecord` 也在这里:它是构造与校验这些信封时用的通用对象守卫。
|
|
9
|
+
*
|
|
10
|
+
* 见 spec/contracts/envelope.json。
|
|
11
|
+
*/
|
|
12
|
+
/* -------------------------------------------------------- result envelope */
|
|
13
|
+
/**
|
|
14
|
+
* The status rule, in one place: a call that produced warnings is `partial`,
|
|
15
|
+
* one that produced none is `success`. `failed` has no warning form — a failure
|
|
16
|
+
* carries an error, so it comes from {@link envelopeFailure}.
|
|
17
|
+
*/
|
|
18
|
+
export function toolStatus(warnings = []) {
|
|
19
|
+
return warnings.length === 0 ? 'success' : 'partial';
|
|
20
|
+
}
|
|
21
|
+
/** A successful envelope; downgraded to `partial` when there are warnings. */
|
|
22
|
+
export function envelopeSuccess(data, warnings = []) {
|
|
23
|
+
return { ok: true, status: toolStatus(warnings), data: jsonSafe(data), warnings, error: null };
|
|
24
|
+
}
|
|
25
|
+
/** A failed envelope. `data` still carries whatever partial payload exists. */
|
|
26
|
+
export function envelopeFailure(data, error) {
|
|
27
|
+
return { ok: false, status: 'failed', data: jsonSafe(data), warnings: [], error: jsonSafe(error) };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 把一份载荷收成「JSON 装得下的样子」:丢掉值为 `undefined` 的键、数组空位补成
|
|
31
|
+
* `null`、非有限数(`NaN` / `±Infinity`)与 `-0` 归一,类实例(`Date`、自定义类)
|
|
32
|
+
* 变成它的可枚举自有属性。
|
|
33
|
+
*
|
|
34
|
+
* 为什么信封这一层要做:工具返回值会被原样写进会话日志,平台的
|
|
35
|
+
* `snapshotJsonValue` 只收 lossless JSON —— **对象里一个值为 `undefined` 的键就足以
|
|
36
|
+
* 让整次调用判为非法输出**(`INVALID_TOOL_OUTPUT`)。而 HTTP 那条路是
|
|
37
|
+
* `JSON.stringify`,本来就丢掉 `undefined`,所以这个错永远只在工具调用上现形,
|
|
38
|
+
* 而且现形成「明明成功却报错」。
|
|
39
|
+
*
|
|
40
|
+
* 实跑复现(0045):`rebuild_knowledge` 只重建 wiki 时,报告里的
|
|
41
|
+
* `vectorQuantization` / `embeddingDimension` 是 `undefined` —— 卡片、`wiki_notes`、
|
|
42
|
+
* 图谱、FTS 全都已经落盘,调用方收到的是 `value is not lossless JSON`。
|
|
43
|
+
*
|
|
44
|
+
* 语义就是 `JSON.parse(JSON.stringify(v))`,只是不真的走一遍字符串。干净的值原样
|
|
45
|
+
* 返回(不复制),所以每次调用不会为一份没问题的载荷多付一次深拷贝。
|
|
46
|
+
*/
|
|
47
|
+
export function jsonSafe(value) {
|
|
48
|
+
return collapse(value);
|
|
49
|
+
}
|
|
50
|
+
function collapse(value) {
|
|
51
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
52
|
+
return value;
|
|
53
|
+
const kind = typeof value;
|
|
54
|
+
if (kind === 'number') {
|
|
55
|
+
const num = value;
|
|
56
|
+
if (!Number.isFinite(num))
|
|
57
|
+
return null;
|
|
58
|
+
return Object.is(num, -0) ? 0 : num;
|
|
59
|
+
}
|
|
60
|
+
// JSON 没有 BigInt 这个类型,`JSON.stringify` 遇到它会直接抛。这里取它的十进制写法:
|
|
61
|
+
// 一个能存下来的近似值,好过让整次调用失败。
|
|
62
|
+
if (kind === 'bigint')
|
|
63
|
+
return String(value);
|
|
64
|
+
// `undefined` / 函数 / symbol:在 JSON 里表示「这个键不存在」。
|
|
65
|
+
if (kind !== 'object')
|
|
66
|
+
return undefined;
|
|
67
|
+
const record = value;
|
|
68
|
+
const toJSON = record.toJSON;
|
|
69
|
+
if (typeof toJSON === 'function')
|
|
70
|
+
return collapse(toJSON.call(value));
|
|
71
|
+
if (Array.isArray(value)) {
|
|
72
|
+
// 逐下标而不是 `map`:`map` 会跳过空位,留下的空位仍是非法 JSON
|
|
73
|
+
// (`[1, , 3]` 序列化出来是 `[1,null,3]`,而 `snapshotJsonValue` 直接拒)。
|
|
74
|
+
let changed = Object.keys(value).length !== value.length;
|
|
75
|
+
const out = [];
|
|
76
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
77
|
+
const item = value[index];
|
|
78
|
+
const next = collapse(item) ?? null;
|
|
79
|
+
if (next !== item)
|
|
80
|
+
changed = true;
|
|
81
|
+
out.push(next);
|
|
82
|
+
}
|
|
83
|
+
return changed ? out : value;
|
|
84
|
+
}
|
|
85
|
+
const proto = Object.getPrototypeOf(value);
|
|
86
|
+
// 类实例、带符号键或不可枚举自有属性的对象:`snapshotJsonValue` 都会拒。
|
|
87
|
+
// 判据用「自有属性名」而不是「可枚举键」就是为了看见后两者。
|
|
88
|
+
let changed = (proto !== Object.prototype && proto !== null)
|
|
89
|
+
|| Object.getOwnPropertySymbols(value).length > 0
|
|
90
|
+
|| Object.getOwnPropertyNames(value).length !== Object.keys(record).length;
|
|
91
|
+
const out = {};
|
|
92
|
+
for (const key of Object.keys(record)) {
|
|
93
|
+
const next = collapse(record[key]);
|
|
94
|
+
if (next === undefined) {
|
|
95
|
+
changed = true;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
out[key] = next;
|
|
99
|
+
if (next !== record[key])
|
|
100
|
+
changed = true;
|
|
101
|
+
}
|
|
102
|
+
return changed ? out : value;
|
|
103
|
+
}
|
|
104
|
+
export function isRecord(value) {
|
|
105
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
106
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 磁盘布局:项目根在哪、工作簿与画布存哪、新建的文件叫什么名字。
|
|
3
|
+
*
|
|
4
|
+
* table 与 excalidraw 插件必须对同一个问题给出同一个答案。两边对「项目根」的算法不一致就会找不到文件。
|
|
5
|
+
*
|
|
6
|
+
* 文件名同理:「叫什么」是持久化契约的一部分 —— 落盘名就是 id,改一次规则等于把
|
|
7
|
+
* 已有文件变成孤儿;所以规则与目录名放在同一个子路径里,一起冻结。
|
|
8
|
+
*
|
|
9
|
+
* 见 spec/VERSION-MATRIX.md 的冻结契约表(`storages/` 是持久化路径)。
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* The one directory name a plugin's project-local files live under.
|
|
13
|
+
*
|
|
14
|
+
* `data-table` and `data-excalidraw` keep their state beside
|
|
15
|
+
* the project it belongs to — `<project>/storages/<plugin>/…` — instead of in a
|
|
16
|
+
* single per-user store. That makes a project directory self-contained: copy it
|
|
17
|
+
* and the workbooks and drawings travel with it; delete it and
|
|
18
|
+
* nothing is left behind in the user's home. Each plugin supplies its own leaf
|
|
19
|
+
* name; this constant fixes only the segment they share, so the plugins cannot
|
|
20
|
+
* drift into separate layouts.
|
|
21
|
+
*/
|
|
22
|
+
export declare const STORAGES_DIRECTORY = "storages";
|
|
23
|
+
/**
|
|
24
|
+
* What a caller knows about the project directory of one Session.
|
|
25
|
+
*
|
|
26
|
+
* All three fields are read structurally: the Session registry's header and the
|
|
27
|
+
* sandbox policy belong to the Host, and a plugin sees them as plain objects.
|
|
28
|
+
*/
|
|
29
|
+
export interface ProjectLocation {
|
|
30
|
+
/** `Session.header.cwd` — the Session's working directory. */
|
|
31
|
+
cwd?: unknown;
|
|
32
|
+
/** The sandbox policy's workspace root; DSH's own fallback. */
|
|
33
|
+
workspaceRoot?: unknown;
|
|
34
|
+
/**
|
|
35
|
+
* The caller's last resort, passed explicitly because there is no correct
|
|
36
|
+
* default here: a run with neither a Session nor a policy is a run whose
|
|
37
|
+
* process directory is the only honest answer, and only the caller has it.
|
|
38
|
+
*/
|
|
39
|
+
fallback: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The project directory one Session's files belong to.
|
|
43
|
+
*
|
|
44
|
+
* The derivation is the Host's, not this package's: the Session header's `cwd`
|
|
45
|
+
* first, then the sandbox policy's workspace root (what DSH's own workspace-file
|
|
46
|
+
* service falls back to), then the caller's own directory. It lives here because
|
|
47
|
+
* three plugins now need the same answer, and "the project" quietly becoming
|
|
48
|
+
* three slightly different directories is exactly the failure this prevents —
|
|
49
|
+
* each caller supplies the two facts only it has.
|
|
50
|
+
*
|
|
51
|
+
* @param location - Session cwd, policy root, and the last-resort fallback.
|
|
52
|
+
* @returns an absolute directory that may not exist yet.
|
|
53
|
+
*/
|
|
54
|
+
export declare function projectRootOf(location: ProjectLocation): string;
|
|
55
|
+
/**
|
|
56
|
+
* Whether a path could be a project directory.
|
|
57
|
+
*
|
|
58
|
+
* A filesystem root is not a project. DSH's local sandbox policy reports
|
|
59
|
+
* `workspaceRoot: "/"` whenever it has no better answer, and taking that literally puts
|
|
60
|
+
* `<root>/storages/...` at `/storages/...` — which fails with EACCES on macOS, and would be
|
|
61
|
+
* wrong even where it succeeded. Skipping it lets the caller's real fallback apply.
|
|
62
|
+
*
|
|
63
|
+
* @param value - Candidate path.
|
|
64
|
+
* @returns true when it is a non-empty path that is not a filesystem root.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isProjectDirectory(value: unknown): value is string;
|
|
67
|
+
/**
|
|
68
|
+
* How many characters of the meaning a new storage file name carries.
|
|
69
|
+
*
|
|
70
|
+
* 25 是**人读的长度**,不是文件系统的限制:名字出现在侧栏、文件树和工具回执里,
|
|
71
|
+
* 超过一屏半行的名字等于没有名字。上限以内按整字截断(不是按字节、也不是按 UTF-16
|
|
72
|
+
* 码元 —— 后者会把一个汉字或一个 emoji 劈成两半)。
|
|
73
|
+
*/
|
|
74
|
+
export declare const STORAGE_NAME_MAX_CHARS = 25;
|
|
75
|
+
/** 名字里一个可用字符都没有时用的占位,例如 name 只给了 `!!!`。 */
|
|
76
|
+
export declare const STORAGE_NAME_FALLBACK = "\u672A\u547D\u540D";
|
|
77
|
+
/**
|
|
78
|
+
* `yyyymmdd`:某一刻的**本地**日期,用作新建存储文件名的前缀。
|
|
79
|
+
*
|
|
80
|
+
* 本地而不是 UTC:文件是给人看的,用户说「今天建的」就是他自己日历上的今天。
|
|
81
|
+
* 与知识插件的 `output/<YYYY-MM-DD>/` 按本地日分桶是同一条理由。
|
|
82
|
+
*
|
|
83
|
+
* @param at - 时刻,默认现在。
|
|
84
|
+
* @returns 8 位数字,例如 `20261002`。
|
|
85
|
+
*/
|
|
86
|
+
export declare function compactDate(at?: Date): string;
|
|
87
|
+
/**
|
|
88
|
+
* 把一段任意文本压成安全的文件名片段:保留汉字、字母、数字、`_`、`-`、`.`,
|
|
89
|
+
* 其余(空格、标点、路径分隔符、表情)一律并成 `-`,并去掉首尾的 `-`。
|
|
90
|
+
*
|
|
91
|
+
* 这是**字符集**规则,不含日期和长度 —— 已存在的 id 也要经过它,而给老文件补日期或
|
|
92
|
+
* 截短名字会让它再也找不到;所有调用方必须接受同一批字符,否则同一个名字会无法读取。
|
|
93
|
+
*
|
|
94
|
+
* 路径分隔符在这里被消掉,所以片段接到目录后面不会跑出目录;`..` 只会变成一个普通
|
|
95
|
+
* 文件名的一部分。
|
|
96
|
+
*
|
|
97
|
+
* @param value - 任意文本,通常是显示名或调用方给的 id。
|
|
98
|
+
* @returns 安全片段,可能为空串(当输入没有任何可用字符时)。
|
|
99
|
+
*/
|
|
100
|
+
export declare function storageSegment(value: string): string;
|
|
101
|
+
/**
|
|
102
|
+
* 新建存储文件叫什么名字:`yyyymmdd-中文名`,中文名(即日期前缀之后的整段)不超过
|
|
103
|
+
* {@link STORAGE_NAME_MAX_CHARS} 个字。
|
|
104
|
+
*
|
|
105
|
+
* 为什么要有统一的一个函数:table 的工作簿和画布文件都放在
|
|
106
|
+
* `<project>/storages/<plugin>/<名字>.<扩展名>`(工作簿 `.json`,画布 `.excalidraw`),落盘名
|
|
107
|
+
* 就是 id。过去它们各自生成 `_<ascii slug>`、`session-<uuid>`、`main` —— 打开 storages 目录
|
|
108
|
+
* 看不出哪个文件是什么,而中文显示名会被字符集规则整段换成 `-`(`销售汇总` 变成 `_wb`)。
|
|
109
|
+
* 所以**含义进名字**:用户看见的 `销售汇总` 就是文件名里的 `销售汇总`。
|
|
110
|
+
*
|
|
111
|
+
* 画布接入晚于这个函数:画布长期用固定的 `main.excalidraw` 和 `画布 N` 当新文件名,
|
|
112
|
+
* 所以这条规则对画布**没有生效**过。现在画布的新建路径(Agent 的 `excalidraw_create`、面板的
|
|
113
|
+
* 「新建画布」)也走它;`main.excalidraw` 保留为「省略名字时的默认地址」——地址不是新名字,
|
|
114
|
+
* 给它补日期等于让老文件找不到。
|
|
115
|
+
*
|
|
116
|
+
* 已经带 `yyyymmdd-` 前缀的输入保留自己的日期,不叠加第二个前缀(调用方按规则起好名
|
|
117
|
+
* 时不该被改写成「今天」);其余输入补当天日期。
|
|
118
|
+
*
|
|
119
|
+
* 碰撞后缀(`-2`、`-3`)由调用方在同一目录里自己让路,它们不计入 25 字上限 —— 上限管
|
|
120
|
+
* 的是「含义有多长」,不是「目录里有几个重名」。
|
|
121
|
+
*
|
|
122
|
+
* @param meaning - 名字的含义,通常是显示名;也可以已经是 `yyyymmdd-名字`。
|
|
123
|
+
* @param options.at - 日期前缀用的时刻,默认现在。
|
|
124
|
+
* @param options.fallback - 含义为空时的替代名,默认 {@link STORAGE_NAME_FALLBACK}。
|
|
125
|
+
* @returns 形如 `20261002-销售汇总` 的文件名片段。
|
|
126
|
+
*/
|
|
127
|
+
export declare function storageNameOf(meaning: string, options?: {
|
|
128
|
+
readonly at?: Date;
|
|
129
|
+
readonly fallback?: string;
|
|
130
|
+
}): string;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 磁盘布局:项目根在哪、工作簿与画布存哪、新建的文件叫什么名字。
|
|
3
|
+
*
|
|
4
|
+
* table 与 excalidraw 插件必须对同一个问题给出同一个答案。两边对「项目根」的算法不一致就会找不到文件。
|
|
5
|
+
*
|
|
6
|
+
* 文件名同理:「叫什么」是持久化契约的一部分 —— 落盘名就是 id,改一次规则等于把
|
|
7
|
+
* 已有文件变成孤儿;所以规则与目录名放在同一个子路径里,一起冻结。
|
|
8
|
+
*
|
|
9
|
+
* 见 spec/VERSION-MATRIX.md 的冻结契约表(`storages/` 是持久化路径)。
|
|
10
|
+
*/
|
|
11
|
+
/* ------------------------------------------------------ project storage */
|
|
12
|
+
/**
|
|
13
|
+
* The one directory name a plugin's project-local files live under.
|
|
14
|
+
*
|
|
15
|
+
* `data-table` and `data-excalidraw` keep their state beside
|
|
16
|
+
* the project it belongs to — `<project>/storages/<plugin>/…` — instead of in a
|
|
17
|
+
* single per-user store. That makes a project directory self-contained: copy it
|
|
18
|
+
* and the workbooks and drawings travel with it; delete it and
|
|
19
|
+
* nothing is left behind in the user's home. Each plugin supplies its own leaf
|
|
20
|
+
* name; this constant fixes only the segment they share, so the plugins cannot
|
|
21
|
+
* drift into separate layouts.
|
|
22
|
+
*/
|
|
23
|
+
export const STORAGES_DIRECTORY = 'storages';
|
|
24
|
+
/**
|
|
25
|
+
* The project directory one Session's files belong to.
|
|
26
|
+
*
|
|
27
|
+
* The derivation is the Host's, not this package's: the Session header's `cwd`
|
|
28
|
+
* first, then the sandbox policy's workspace root (what DSH's own workspace-file
|
|
29
|
+
* service falls back to), then the caller's own directory. It lives here because
|
|
30
|
+
* three plugins now need the same answer, and "the project" quietly becoming
|
|
31
|
+
* three slightly different directories is exactly the failure this prevents —
|
|
32
|
+
* each caller supplies the two facts only it has.
|
|
33
|
+
*
|
|
34
|
+
* @param location - Session cwd, policy root, and the last-resort fallback.
|
|
35
|
+
* @returns an absolute directory that may not exist yet.
|
|
36
|
+
*/
|
|
37
|
+
export function projectRootOf(location) {
|
|
38
|
+
if (isProjectDirectory(location.cwd))
|
|
39
|
+
return location.cwd;
|
|
40
|
+
if (isProjectDirectory(location.workspaceRoot))
|
|
41
|
+
return location.workspaceRoot;
|
|
42
|
+
return location.fallback;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Whether a path could be a project directory.
|
|
46
|
+
*
|
|
47
|
+
* A filesystem root is not a project. DSH's local sandbox policy reports
|
|
48
|
+
* `workspaceRoot: "/"` whenever it has no better answer, and taking that literally puts
|
|
49
|
+
* `<root>/storages/...` at `/storages/...` — which fails with EACCES on macOS, and would be
|
|
50
|
+
* wrong even where it succeeded. Skipping it lets the caller's real fallback apply.
|
|
51
|
+
*
|
|
52
|
+
* @param value - Candidate path.
|
|
53
|
+
* @returns true when it is a non-empty path that is not a filesystem root.
|
|
54
|
+
*/
|
|
55
|
+
export function isProjectDirectory(value) {
|
|
56
|
+
if (typeof value !== 'string' || value.length === 0)
|
|
57
|
+
return false;
|
|
58
|
+
return value.replace(/[/\\]+$/, '').length > 0;
|
|
59
|
+
}
|
|
60
|
+
/* ------------------------------------------------ storage file names */
|
|
61
|
+
/**
|
|
62
|
+
* How many characters of the meaning a new storage file name carries.
|
|
63
|
+
*
|
|
64
|
+
* 25 是**人读的长度**,不是文件系统的限制:名字出现在侧栏、文件树和工具回执里,
|
|
65
|
+
* 超过一屏半行的名字等于没有名字。上限以内按整字截断(不是按字节、也不是按 UTF-16
|
|
66
|
+
* 码元 —— 后者会把一个汉字或一个 emoji 劈成两半)。
|
|
67
|
+
*/
|
|
68
|
+
export const STORAGE_NAME_MAX_CHARS = 25;
|
|
69
|
+
/** 名字里一个可用字符都没有时用的占位,例如 name 只给了 `!!!`。 */
|
|
70
|
+
export const STORAGE_NAME_FALLBACK = '未命名';
|
|
71
|
+
/**
|
|
72
|
+
* `yyyymmdd`:某一刻的**本地**日期,用作新建存储文件名的前缀。
|
|
73
|
+
*
|
|
74
|
+
* 本地而不是 UTC:文件是给人看的,用户说「今天建的」就是他自己日历上的今天。
|
|
75
|
+
* 与知识插件的 `output/<YYYY-MM-DD>/` 按本地日分桶是同一条理由。
|
|
76
|
+
*
|
|
77
|
+
* @param at - 时刻,默认现在。
|
|
78
|
+
* @returns 8 位数字,例如 `20261002`。
|
|
79
|
+
*/
|
|
80
|
+
export function compactDate(at = new Date()) {
|
|
81
|
+
const pad = (value) => `${value}`.padStart(2, '0');
|
|
82
|
+
return `${at.getFullYear()}${pad(at.getMonth() + 1)}${pad(at.getDate())}`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 把一段任意文本压成安全的文件名片段:保留汉字、字母、数字、`_`、`-`、`.`,
|
|
86
|
+
* 其余(空格、标点、路径分隔符、表情)一律并成 `-`,并去掉首尾的 `-`。
|
|
87
|
+
*
|
|
88
|
+
* 这是**字符集**规则,不含日期和长度 —— 已存在的 id 也要经过它,而给老文件补日期或
|
|
89
|
+
* 截短名字会让它再也找不到;所有调用方必须接受同一批字符,否则同一个名字会无法读取。
|
|
90
|
+
*
|
|
91
|
+
* 路径分隔符在这里被消掉,所以片段接到目录后面不会跑出目录;`..` 只会变成一个普通
|
|
92
|
+
* 文件名的一部分。
|
|
93
|
+
*
|
|
94
|
+
* @param value - 任意文本,通常是显示名或调用方给的 id。
|
|
95
|
+
* @returns 安全片段,可能为空串(当输入没有任何可用字符时)。
|
|
96
|
+
*/
|
|
97
|
+
export function storageSegment(value) {
|
|
98
|
+
return value
|
|
99
|
+
.trim()
|
|
100
|
+
.replace(/[^\p{L}\p{N}_.-]+/gu, '-')
|
|
101
|
+
.replace(/^-+|-+$/g, '');
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 新建存储文件叫什么名字:`yyyymmdd-中文名`,中文名(即日期前缀之后的整段)不超过
|
|
105
|
+
* {@link STORAGE_NAME_MAX_CHARS} 个字。
|
|
106
|
+
*
|
|
107
|
+
* 为什么要有统一的一个函数:table 的工作簿和画布文件都放在
|
|
108
|
+
* `<project>/storages/<plugin>/<名字>.<扩展名>`(工作簿 `.json`,画布 `.excalidraw`),落盘名
|
|
109
|
+
* 就是 id。过去它们各自生成 `_<ascii slug>`、`session-<uuid>`、`main` —— 打开 storages 目录
|
|
110
|
+
* 看不出哪个文件是什么,而中文显示名会被字符集规则整段换成 `-`(`销售汇总` 变成 `_wb`)。
|
|
111
|
+
* 所以**含义进名字**:用户看见的 `销售汇总` 就是文件名里的 `销售汇总`。
|
|
112
|
+
*
|
|
113
|
+
* 画布接入晚于这个函数:画布长期用固定的 `main.excalidraw` 和 `画布 N` 当新文件名,
|
|
114
|
+
* 所以这条规则对画布**没有生效**过。现在画布的新建路径(Agent 的 `excalidraw_create`、面板的
|
|
115
|
+
* 「新建画布」)也走它;`main.excalidraw` 保留为「省略名字时的默认地址」——地址不是新名字,
|
|
116
|
+
* 给它补日期等于让老文件找不到。
|
|
117
|
+
*
|
|
118
|
+
* 已经带 `yyyymmdd-` 前缀的输入保留自己的日期,不叠加第二个前缀(调用方按规则起好名
|
|
119
|
+
* 时不该被改写成「今天」);其余输入补当天日期。
|
|
120
|
+
*
|
|
121
|
+
* 碰撞后缀(`-2`、`-3`)由调用方在同一目录里自己让路,它们不计入 25 字上限 —— 上限管
|
|
122
|
+
* 的是「含义有多长」,不是「目录里有几个重名」。
|
|
123
|
+
*
|
|
124
|
+
* @param meaning - 名字的含义,通常是显示名;也可以已经是 `yyyymmdd-名字`。
|
|
125
|
+
* @param options.at - 日期前缀用的时刻,默认现在。
|
|
126
|
+
* @param options.fallback - 含义为空时的替代名,默认 {@link STORAGE_NAME_FALLBACK}。
|
|
127
|
+
* @returns 形如 `20261002-销售汇总` 的文件名片段。
|
|
128
|
+
*/
|
|
129
|
+
export function storageNameOf(meaning, options = {}) {
|
|
130
|
+
const raw = meaning.trim();
|
|
131
|
+
const dated = /^(\d{8})-(.*)$/su.exec(raw);
|
|
132
|
+
const prefix = dated === null ? compactDate(options.at) : dated[1];
|
|
133
|
+
const segment = storageSegment(dated === null ? raw : dated[2]);
|
|
134
|
+
const fallback = options.fallback ?? STORAGE_NAME_FALLBACK;
|
|
135
|
+
// 截断之后再收一次尾:断在第 25 个字是 `-` 时别留一个 `20261002-销售汇总-`。
|
|
136
|
+
const cut = [...(segment.length === 0 ? fallback : segment)].slice(0, STORAGE_NAME_MAX_CHARS).join('').replace(/-+$/g, '');
|
|
137
|
+
return `${prefix}-${cut.length === 0 ? fallback : cut}`;
|
|
138
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 跨插件引用与血缘:一个插件指向另一个插件产出的东西时,用的就是这些形状。
|
|
3
|
+
*
|
|
4
|
+
* `SheetRef` 是 Sheet 单元格指向 table 的工作簿,`LineageContext` / `LineageRef` 是
|
|
5
|
+
*「这次写入源自哪次会话的哪个动作」。
|
|
6
|
+
*
|
|
7
|
+
* 它们必须共享:跨插件生成的引用要保持同一形状。
|
|
8
|
+
*/
|
|
9
|
+
export interface SheetRef {
|
|
10
|
+
workbookId: string;
|
|
11
|
+
sheetId: string;
|
|
12
|
+
sheetName: string;
|
|
13
|
+
range?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Cross-plugin business lineage. These ids are deliberately opaque and do
|
|
17
|
+
* not encode user input. A task is the user's business objective, a subtask
|
|
18
|
+
* is one plan/workflow node, and a run is one execution attempt.
|
|
19
|
+
*
|
|
20
|
+
* All properties are optional so existing persisted records and user-originated
|
|
21
|
+
* browser mutations remain readable without a migration.
|
|
22
|
+
*/
|
|
23
|
+
export interface LineageContext {
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
turnId?: string;
|
|
26
|
+
intentId?: string;
|
|
27
|
+
taskId?: string;
|
|
28
|
+
subtaskId?: string;
|
|
29
|
+
parentSubtaskId?: string;
|
|
30
|
+
runId?: string;
|
|
31
|
+
traceId?: string;
|
|
32
|
+
domain?: string;
|
|
33
|
+
}
|
|
34
|
+
/** A provenance edge from a durable artifact or knowledge record to a task. */
|
|
35
|
+
export interface LineageRef extends LineageContext {
|
|
36
|
+
role?: 'created' | 'derived' | 'retrieved' | 'executed' | 'feedback' | 'triggered';
|
|
37
|
+
refType?: string;
|
|
38
|
+
refId?: string;
|
|
39
|
+
}
|