@goodpeanuts/dsh-sui 0.1.2-fix.1 → 0.1.2-fix.3
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/README.md +1 -1
- package/apps/cli/dist/packages/finance/src/transactions/contracts.mjs +3 -2
- package/apps/cli/dist/packages/finance/src/transactions/mutation.mjs +1 -1
- package/bundles/sui-ledger/dist/capabilities/book-authorization.mjs +96 -0
- package/bundles/sui-ledger/dist/capabilities/tools.mjs +12 -2
- package/bundles/sui-ledger/dist/client.js +589 -420
- package/bundles/sui-ledger/dist/finance-state-context.mjs +1 -1
- package/bundles/sui-ledger/dist/index.mjs +14 -1
- package/bundles/sui-ledger/dist/node_modules/.pnpm/{@deepseek-ai_dsh-home-paths_159c15e70066431314381a350c2ee56a → @deepseek-ai_dsh-home-paths_43f382ed782d46f05123e7add538564e}/node_modules/@deepseek-ai/dsh-home-paths/lib/index.mjs +1 -1
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/contracts.mjs +3 -2
- package/bundles/sui-ledger/dist/packages/finance/src/transactions/mutation.mjs +1 -1
- package/bundles/sui-ledger/dist/packages/finance-module/src/capabilities.mjs +6 -18
- package/bundles/sui-ledger/dist/packages/finance-module/src/service.mjs +2 -2
- package/bundles/sui-ledger/dist/packages/finance-module/src/tool-contracts.mjs +2 -2
- package/bundles/sui-ledger/dist/storage/business-runtime.mjs +1 -0
- package/bundles/sui-ledger/dist/storage/paths.mjs +1 -1
- package/bundles/sui-ledger/dist/style.css +114 -5
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ function registerFinanceStateContext(prompt, read) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function buildFinanceStateContext(snapshot) {
|
|
28
|
-
if (snapshot.status === "unbound") return "【当前账务状态】\n
|
|
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
|
-
|
|
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-
|
|
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
|
*
|
|
@@ -6,6 +6,7 @@ const explicitOffsetDateTime = string().min(1).refine((value) => {
|
|
|
6
6
|
return !Number.isNaN(Date.parse(value));
|
|
7
7
|
}, "occurredAt must be a valid date-time with an explicit timezone offset").refine(isSecondPrecisionInstant, "occurredAt must have whole-second precision; nonzero fractional seconds cannot be sent");
|
|
8
8
|
const remoteId = string().trim().min(1).max(128);
|
|
9
|
+
const amountCents = number().int().nonnegative().safe();
|
|
9
10
|
const createTransactionInputSchema = object({
|
|
10
11
|
occurredAt: explicitOffsetDateTime,
|
|
11
12
|
type: _enum([
|
|
@@ -13,7 +14,7 @@ const createTransactionInputSchema = object({
|
|
|
13
14
|
"income",
|
|
14
15
|
"transfer"
|
|
15
16
|
]),
|
|
16
|
-
amountCents
|
|
17
|
+
amountCents,
|
|
17
18
|
secondaryAmountCents: number().int().positive().safe().optional(),
|
|
18
19
|
accountId: remoteId,
|
|
19
20
|
destinationAccountId: remoteId.optional(),
|
|
@@ -64,7 +65,7 @@ const updateTransactionPatchSchema = object({
|
|
|
64
65
|
"income",
|
|
65
66
|
"transfer"
|
|
66
67
|
]).optional(),
|
|
67
|
-
amountCents:
|
|
68
|
+
amountCents: amountCents.optional(),
|
|
68
69
|
secondaryAmountCents: number().int().positive().safe().nullable().optional(),
|
|
69
70
|
accountId: remoteId.optional(),
|
|
70
71
|
destinationAccountId: remoteId.nullable().optional(),
|
|
@@ -554,7 +554,7 @@ function validateTransactionMetadata(input, metadata) {
|
|
|
554
554
|
if (input.projectId) requireRemoteId(metadata.projects, input.projectId, "projectId");
|
|
555
555
|
if (input.memberId) requireRemoteId(metadata.members, input.memberId, "memberId");
|
|
556
556
|
if (input.storeId) requireRemoteId(metadata.stores, input.storeId, "storeId");
|
|
557
|
-
if (!Number.isSafeInteger(input.amountCents) || input.amountCents
|
|
557
|
+
if (!Number.isSafeInteger(input.amountCents) || input.amountCents < 0) throw new FeideeError("amountCents must be a non-negative safe integer", "INVALID_ARGUMENT");
|
|
558
558
|
if (input.secondaryAmountCents !== void 0 && (!Number.isSafeInteger(input.secondaryAmountCents) || input.secondaryAmountCents <= 0)) throw new FeideeError("secondaryAmountCents must be a positive safe integer", "INVALID_ARGUMENT");
|
|
559
559
|
if (Number.isNaN(Date.parse(input.occurredAt))) throw new FeideeError("occurredAt is invalid", "INVALID_ARGUMENT");
|
|
560
560
|
}
|
|
@@ -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.
|
|
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({
|
|
@@ -711,7 +711,7 @@ function createFinanceTools(service, ledger, options = {}) {
|
|
|
711
711
|
endDate: dateSchema,
|
|
712
712
|
amountCents: {
|
|
713
713
|
type: "integer",
|
|
714
|
-
minimum:
|
|
714
|
+
minimum: 0
|
|
715
715
|
},
|
|
716
716
|
text: boundedTextSchema(2e3),
|
|
717
717
|
offset: {
|
|
@@ -1181,10 +1181,6 @@ const draftRevisionSetSchema = objectSchema([], {
|
|
|
1181
1181
|
"income",
|
|
1182
1182
|
"transfer"
|
|
1183
1183
|
] },
|
|
1184
|
-
amountCents: {
|
|
1185
|
-
type: "integer",
|
|
1186
|
-
minimum: 1
|
|
1187
|
-
},
|
|
1188
1184
|
currency: boundedTextSchema(16),
|
|
1189
1185
|
accountId: idSchema,
|
|
1190
1186
|
destinationAccountId: idSchema,
|
|
@@ -1229,7 +1225,7 @@ const financialDraftFieldsSchema = objectSchema([], Object.fromEntries(Object.en
|
|
|
1229
1225
|
type: "integer",
|
|
1230
1226
|
minimum: 0,
|
|
1231
1227
|
maximum: Number.MAX_SAFE_INTEGER,
|
|
1232
|
-
description: "金额单位为分(整数),不是元;人民币 3.00 元 → 300,0.03 元 → 3。来源为元时用十进制运算统一换算,不按金额大小自动纠正。"
|
|
1228
|
+
description: "金额单位为分(整数),不是元;人民币 0 元 → 0,3.00 元 → 300,0.03 元 → 3。来源为元时用十进制运算统一换算,不按金额大小自动纠正。"
|
|
1233
1229
|
},
|
|
1234
1230
|
secondaryAmountCents: {
|
|
1235
1231
|
type: "integer",
|
|
@@ -1252,7 +1248,6 @@ const financialDraftFieldsSchema = objectSchema([], Object.fromEntries(Object.en
|
|
|
1252
1248
|
anyOf: [valueSchema, { type: "null" }]
|
|
1253
1249
|
}];
|
|
1254
1250
|
})));
|
|
1255
|
-
const positiveDraftAmountConstraint = { properties: { amountCents: { minimum: 1 } } };
|
|
1256
1251
|
const financialDraftSchema = {
|
|
1257
1252
|
...objectSchema(["operation"], {
|
|
1258
1253
|
operation: financialDraftOperationSchema,
|
|
@@ -1265,25 +1260,18 @@ const financialDraftSchema = {
|
|
|
1265
1260
|
oneOf: [
|
|
1266
1261
|
{ properties: {
|
|
1267
1262
|
operation: { const: "create" },
|
|
1268
|
-
remoteId: false
|
|
1269
|
-
fields: positiveDraftAmountConstraint
|
|
1263
|
+
remoteId: false
|
|
1270
1264
|
} },
|
|
1271
1265
|
{
|
|
1272
1266
|
required: ["remoteId", "fields"],
|
|
1273
1267
|
properties: {
|
|
1274
1268
|
operation: { const: "update" },
|
|
1275
|
-
fields: {
|
|
1276
|
-
...positiveDraftAmountConstraint,
|
|
1277
|
-
minProperties: 1
|
|
1278
|
-
}
|
|
1269
|
+
fields: { minProperties: 1 }
|
|
1279
1270
|
}
|
|
1280
1271
|
},
|
|
1281
1272
|
{
|
|
1282
1273
|
required: ["remoteId"],
|
|
1283
|
-
properties: {
|
|
1284
|
-
operation: { enum: ["delete", "matched"] },
|
|
1285
|
-
fields: positiveDraftAmountConstraint
|
|
1286
|
-
}
|
|
1274
|
+
properties: { operation: { enum: ["delete", "matched"] } }
|
|
1287
1275
|
}
|
|
1288
1276
|
]
|
|
1289
1277
|
};
|
|
@@ -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.
|
|
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}.
|
|
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 };
|
|
@@ -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-
|
|
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
|
-
|
|
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;
|