@goodpeanuts/dsh-sui 0.1.2-fix.1 → 0.1.2-fix.2

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.
@@ -25,7 +25,7 @@ function registerFinanceStateContext(prompt, read) {
25
25
  }
26
26
  }
27
27
  function buildFinanceStateContext(snapshot) {
28
- if (snapshot.status === "unbound") return "【当前账务状态】\n当前会话尚无账本授权;未读取任何默认账本统计。用 finance_books_list 查看默认账本和授权;没有默认账本时,请用户点击会话输入框上方的“账本授权”选择并确认。若没有可选账本,先打开账本页面登录并同步。";
28
+ if (snapshot.status === "unbound") return "【当前账务状态】\n当前会话尚无账本授权;未读取任何默认账本统计。普通聊天不要请求授权;仅在处理用户明确提出的财务任务时使用财务工具。用 finance_books_list 查看默认账本和授权;没有默认账本时,需要账本访问的工具会按需请求授权;也可在账本页面的“数据与同步 → 账本授权”设置默认账本。若没有可选账本,先打开账本页面登录并同步。";
29
29
  return [
30
30
  "【当前账务状态】",
31
31
  "以下是本次模型上下文组装时的轻量状态,覆盖之前的状态快照,不是已读取或已核对的凭据。fingerprint 仅为状态指纹,不能作为读取工具的分页版本;续读须使用各工具实际返回的 dataVersion。",
@@ -7,6 +7,7 @@ import { PersonalPreferencesStore } from "./packages/finance-module/src/personal
7
7
  import { financeDataset } from "./packages/finance-module/src/storage.mjs";
8
8
  import { ManagedDataset } from "./packages/data-maintenance/src/runtime.mjs";
9
9
  import { projectFinanceTools } from "./capabilities/tools.mjs";
10
+ import { createBookAuthorization } from "./capabilities/book-authorization.mjs";
10
11
  import { sessionAttachmentOwnership } from "./session/attachment-ownership.mjs";
11
12
  import { resolveRemoteWritePolicy } from "./remote-write-policy.mjs";
12
13
  import { resolveStoragePaths } from "./storage/paths.mjs";
@@ -92,7 +93,19 @@ async function apply(ctx, config) {
92
93
  const value = Reflect.get(current, key);
93
94
  return typeof value === "function" ? value.bind(current) : value;
94
95
  } });
95
- const tools = projectFinanceTools(selectFinanceModelTools(createFinanceTools(service, ledger, { listSourceRefs: () => [] })));
96
+ let questions;
97
+ ctx.inject(["userQuestions"], (host) => {
98
+ questions = (request) => host.userQuestions.ask(request);
99
+ host.effect(() => () => {
100
+ questions = void 0;
101
+ });
102
+ });
103
+ const authorization = createBookAuthorization({
104
+ runtime: () => manager.get(),
105
+ questions: () => questions
106
+ });
107
+ ctx.effect(() => () => authorization.dispose());
108
+ const tools = projectFinanceTools(selectFinanceModelTools(createFinanceTools(service, ledger, { listSourceRefs: () => [] })), authorization.authorize);
96
109
  for (const tool of tools) ctx.tools.register({
97
110
  ...tool,
98
111
  execute: (args, exec) => manager.run(async () => {
@@ -1,6 +1,6 @@
1
1
  import { join, resolve } from "node:path";
2
2
  import { homedir } from "node:os";
3
- //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-home-paths_159c15e70066431314381a350c2ee56a/node_modules/@deepseek-ai/dsh-home-paths/lib/index.js
3
+ //#region ../../node_modules/.pnpm/@deepseek-ai+dsh-home-paths_43f382ed782d46f05123e7add538564e/node_modules/@deepseek-ai/dsh-home-paths/lib/index.js
4
4
  /**
5
5
  * Shared filesystem path helpers for DeepSeek Harness user data.
6
6
  *
@@ -90,7 +90,7 @@ function createFinanceTools(service, ledger, options = {}) {
90
90
  throw new FinancePublicError(JSON.stringify({
91
91
  code,
92
92
  activeGrant: books.activeGrant,
93
- message: code === "finance_grant_book_mismatch" ? "Use the active grant's bookId if the requested ID was mistyped. Selecting another book requires trusted user action." : "No active book grant. Ask the user to click 账本授权 (Book access) above the conversation input and confirm a book; if the list is empty, open the Ledger panel to log in and sync first."
93
+ message: code === "finance_grant_book_mismatch" ? "Use the active grant's bookId if the requested ID was mistyped. Selecting another book requires trusted user action." : "No active book grant. Authorize a default book in Ledger → 数据与同步 → 账本授权, or confirm the contextual book selection. If no books exist, log in and sync in Ledger first."
94
94
  }));
95
95
  }
96
96
  if (code) throw new FinancePublicError(JSON.stringify({
@@ -20,7 +20,7 @@ import { createHash, randomUUID } from "node:crypto";
20
20
  //#region ../../packages/finance-module/src/service.ts
21
21
  const DEFAULT_BOOK_SETTING_KEY = "default_book_id";
22
22
  const FINANCE_REMOTE_WRITES_DISABLED_ERROR = "finance_remote_writes_disabled";
23
- const FINANCE_GRANT_MISSING_HINT = "finance_grant_missing: no active BookReadGrant for this subject. Ask the user to click 账本授权 (Book access) above the conversation input and confirm a book. If no books are listed, open the Ledger panel to log in and sync first. Do not retry other book tools before authorization.";
23
+ const FINANCE_GRANT_MISSING_HINT = "finance_grant_missing: no active BookReadGrant for this subject. Authorize a book in Ledger → 数据与同步 → 账本授权, or confirm the contextual book selection when a finance tool asks. If no books are listed, open the Ledger panel to log in and sync first. Do not retry other book tools before authorization.";
24
24
  function knownBook(ledger, bookId) {
25
25
  const books = ledger.cachedBooks();
26
26
  return Array.isArray(books) && books.some((book) => book?.id === bookId);
@@ -1828,7 +1828,7 @@ var FinanceApplicationService = class {
1828
1828
  requireGrant(subjectId, bookId, grantId) {
1829
1829
  const grant = this.ensureDefaultBookGrant(subjectId);
1830
1830
  if (!grant) throw new Error(FINANCE_GRANT_MISSING_HINT);
1831
- if (grant.bookId !== bookId || grantId && grant.id !== grantId) throw new Error(`finance_grant_book_mismatch: the active BookReadGrant covers book ${grant.bookId}, not ${bookId}. Ask the user to click 账本授权 (Book access) above the conversation input to select another book instead of retrying other book tools.`);
1831
+ if (grant.bookId !== bookId || grantId && grant.id !== grantId) throw new Error(`finance_grant_book_mismatch: the active BookReadGrant covers book ${grant.bookId}, not ${bookId}. Switch the book from a financial draft or confirm the contextual book selection; do not retry with a mismatched book.`);
1832
1832
  return grant;
1833
1833
  }
1834
1834
  draftMutationOnce(context, operation, input, mutate) {
@@ -1,4 +1,4 @@
1
- import "../../finance/src/public-error.mjs";
1
+ import { FinancePublicError } from "../../finance/src/public-error.mjs";
2
2
  //#region ../../packages/finance-module/src/tool-contracts.ts
3
3
  const FINANCE_MODEL_TOOL_NAMES = Object.freeze([
4
4
  "finance_ledger_refresh",
@@ -39,4 +39,4 @@ function selectFinanceModelTools(definitions) {
39
39
  return selected;
40
40
  }
41
41
  //#endregion
42
- export { FINANCE_MODEL_TOOL_NAMES, selectFinanceModelTools };
42
+ export { FINANCE_MODEL_TOOL_NAMES, FinancePublicError, selectFinanceModelTools };
@@ -81,6 +81,7 @@ function openBusinessRuntime(options, cleanup, close) {
81
81
  resume();
82
82
  return {
83
83
  service,
84
+ interaction,
84
85
  preferences,
85
86
  ledger,
86
87
  tools,
@@ -1,6 +1,6 @@
1
1
  import { dataDirectory } from "../packages/data-maintenance/src/paths.mjs";
2
2
  import "../packages/data-maintenance/src/index.mjs";
3
- import { dshHomePath } from "../node_modules/.pnpm/@deepseek-ai_dsh-home-paths_159c15e70066431314381a350c2ee56a/node_modules/@deepseek-ai/dsh-home-paths/lib/index.mjs";
3
+ import { dshHomePath } from "../node_modules/.pnpm/@deepseek-ai_dsh-home-paths_43f382ed782d46f05123e7add538564e/node_modules/@deepseek-ai/dsh-home-paths/lib/index.mjs";
4
4
  import { join } from "node:path";
5
5
  //#region src/storage/paths.ts
6
6
  function resolveStoragePaths(configured) {
@@ -1,9 +1,5 @@
1
1
  .book-grant-control {
2
- box-sizing: border-box;
3
- width: calc(100% - 2 * var(--finance-composer-side-clearance, 16px));
4
- max-width: var(--finance-composer-card-max-width, 712px);
5
- margin-inline: auto;
6
- padding: 0 0 6px;
2
+ display: inline-flex;
7
3
  }
8
4
 
9
5
  .book-grant-trigger {
@@ -111,6 +107,20 @@
111
107
  flex-wrap: wrap;
112
108
  justify-content: flex-end;
113
109
  }
110
+ .ledger-sync-tabs.ledger-sync-tabs {
111
+ box-sizing: border-box;
112
+ scrollbar-width: thin;
113
+ flex-wrap: nowrap;
114
+ min-width: 0;
115
+ max-width: 100%;
116
+ overflow-x: auto;
117
+ }
118
+
119
+ .ledger-sync-tabs.ledger-sync-tabs > button {
120
+ white-space: nowrap;
121
+ word-break: keep-all;
122
+ flex: none;
123
+ }
114
124
  .backup-recovery-page .page-head h1 {
115
125
  margin: 0 0 26px;
116
126
  font-size: 24px;
@@ -260,6 +270,105 @@
260
270
  padding: 22px;
261
271
  }
262
272
  }
273
+ .book-authorization-settings {
274
+ padding: 28px 0;
275
+ }
276
+
277
+ .book-authorization-settings > header {
278
+ align-items: center;
279
+ gap: 12px;
280
+ display: flex;
281
+ }
282
+
283
+ .book-authorization-settings h2 {
284
+ margin: 0;
285
+ font-size: 18px;
286
+ }
287
+
288
+ .book-authorization-settings > p {
289
+ color: var(--muted);
290
+ margin: 14px 0 28px;
291
+ font-size: 14px;
292
+ line-height: 1.7;
293
+ }
294
+
295
+ .book-authorization-status {
296
+ background: var(--surface-soft);
297
+ color: var(--muted);
298
+ border-radius: 12px;
299
+ padding: 3px 9px;
300
+ font-size: 12px;
301
+ }
302
+
303
+ .book-authorization-settings form {
304
+ gap: 24px;
305
+ display: grid;
306
+ }
307
+
308
+ .book-authorization-field {
309
+ align-items: center;
310
+ gap: 32px;
311
+ font-size: 14px;
312
+ display: flex;
313
+ }
314
+
315
+ .book-authorization-field select {
316
+ box-sizing: border-box;
317
+ border: 1px solid var(--line);
318
+ background: var(--surface);
319
+ width: min(360px, 100%);
320
+ min-width: 0;
321
+ color: var(--ink);
322
+ font: inherit;
323
+ border-radius: 8px;
324
+ padding: 9px 12px;
325
+ }
326
+
327
+ .book-authorization-remember {
328
+ align-items: flex-start;
329
+ gap: 8px;
330
+ font-size: 14px;
331
+ line-height: 1.6;
332
+ display: flex;
333
+ }
334
+
335
+ .book-authorization-remember input {
336
+ accent-color: var(--blue);
337
+ flex: none;
338
+ margin-top: 4px;
339
+ }
340
+
341
+ .book-authorization-note {
342
+ color: var(--muted);
343
+ margin: 0;
344
+ font-size: 13px;
345
+ line-height: 1.7;
346
+ }
347
+
348
+ .book-authorization-settings footer {
349
+ border-top: 1px solid var(--line);
350
+ flex-wrap: wrap;
351
+ justify-content: flex-end;
352
+ gap: 12px;
353
+ padding-top: 20px;
354
+ display: flex;
355
+ }
356
+
357
+ .book-authorization-settings [role="alert"] {
358
+ color: var(--danger);
359
+ }
360
+
361
+ @media (width <= 600px) {
362
+ .book-authorization-field {
363
+ flex-direction: column;
364
+ align-items: stretch;
365
+ gap: 8px;
366
+ }
367
+
368
+ .book-authorization-field select {
369
+ width: 100%;
370
+ }
371
+ }
263
372
  .first-run-card {
264
373
  max-width: 640px;
265
374
  padding: 24px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodpeanuts/dsh-sui",
3
- "version": "0.1.2-fix.1",
3
+ "version": "0.1.2-fix.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Ledger (随手记/feidee) plugin for DeepSeek Harness — finance tools and ledger UI",