@arcfold/dsh-method-ui 0.0.0-stage → 0.4.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.
Files changed (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -2
  3. package/THIRD_PARTY_NOTICES.md +11 -0
  4. package/lib/client.js +4237 -0
  5. package/package.json +35 -4
  6. package/src/Brand.mjs +17 -0
  7. package/src/CollaborationView.mjs +56 -0
  8. package/src/DesktopModels.mjs +40 -0
  9. package/src/DesktopSetup.mjs +48 -0
  10. package/src/GoalDock.mjs +130 -0
  11. package/src/GoalWorkList.mjs +52 -0
  12. package/src/ImportDock.mjs +172 -0
  13. package/src/MethodDock.mjs +145 -0
  14. package/src/ModelSettings.mjs +144 -0
  15. package/src/OpportunityDock.mjs +66 -0
  16. package/src/UnderstandingDock.mjs +117 -0
  17. package/src/browse-scope.mjs +6 -0
  18. package/src/browse-source.mjs +31 -0
  19. package/src/client.mjs +138 -0
  20. package/src/desktop-setup-host.mjs +30 -0
  21. package/src/desktop-workspace.mjs +8 -0
  22. package/src/goal-host.mjs +133 -0
  23. package/src/goal-locales.mjs +78 -0
  24. package/src/goal-source.mjs +72 -0
  25. package/src/import-host.mjs +98 -0
  26. package/src/import-locales.mjs +126 -0
  27. package/src/import-source.mjs +83 -0
  28. package/src/index.mjs +127 -0
  29. package/src/locales.mjs +153 -0
  30. package/src/main-session.mjs +7 -0
  31. package/src/method-source.mjs +82 -0
  32. package/src/model-host.mjs +56 -0
  33. package/src/model-settings-locales.mjs +91 -0
  34. package/src/model-settings-source.mjs +119 -0
  35. package/src/opportunity-host.mjs +118 -0
  36. package/src/opportunity-locales.mjs +34 -0
  37. package/src/opportunity-source.mjs +56 -0
  38. package/src/style.css +99 -0
  39. package/src/tree-client.mjs +15 -0
  40. package/src/tree-host.mjs +39 -0
  41. package/src/tree-source.mjs +65 -0
  42. package/src/tree-style.css +19 -0
  43. package/src/tree-view.mjs +278 -0
  44. package/src/understanding-host.mjs +123 -0
  45. package/src/understanding-locales.mjs +38 -0
  46. package/src/understanding-source.mjs +64 -0
@@ -0,0 +1,38 @@
1
+ export const understandingZh = {
2
+ understandingTitle: '理解与依据', understandingOpen: '查看理解', understandingHide: '收起理解',
3
+ understandingEmpty: '还没有可查看的理解。', understandingLoading: '正在读取理解…',
4
+ understandingBoundary: '这里保留原话、AI 的推断和后续纠正。可采用表示依据仍有效,不代表已经证实,也不授予执行权限。',
5
+ understandingAvailable: '可采用', understandingUnavailable: '已停止采用或依据不可用',
6
+ understandingInference: 'AI 推断', understandingLiteral: '你的明确陈述', understandingQuestion: '待确认的问题',
7
+ understandingStop: '停止采用这条理解', understandingWithdraw: '停止采用这条来源',
8
+ understandingWithdrawalHelp: '停止来源会影响依赖它的理解、方法和目标依据;原聊天记录仍保留,已发出的工作不会撤销,目标的追踪状态不会改变。',
9
+ understandingCorrect: '纠正这条理解', understandingReplacement: '完整替换为',
10
+ understandingCorrectionHelp: '请写出这条理解应当完整替换成的内容。原话会进入当前对话,在下一次尚未发出的步骤中核对并采用;旧版本仍可查看。',
11
+ understandingSubmit: '发送纠正原话', understandingCancel: '取消编辑',
12
+ understandingSaved: '操作已记录。', understandingPending: '已送入对话,尚未确认采用。请刷新查看实际结果。',
13
+ understandingUnknown: '发送结果未确认,未自动重发。请刷新查看记录。',
14
+ understandingApplied: '已采用', understandingFailed: '未采用', understandingAwaiting: '等待实际采用',
15
+ understandingAdmission: '对话接收', understandingAccepted: '已接收', understandingAdmissionFailed: '未送入',
16
+ understandingAdmissionUnknown: '未确认', understandingVersion: '内容版本', understandingHistory: '保留的版本', understandingCommands: '操作记录',
17
+ understandingSuccessors: '后续版本', understandingEffects: '受影响的记录', understandingGoalEffects: '目标依据变化',
18
+ understandingSource: '原始来源', understandingProvenance: '查看来源信息', understandingMissing: '来源缺失',
19
+ };
20
+ export const understandingEn = {
21
+ understandingTitle: 'Understanding and evidence', understandingOpen: 'View understanding', understandingHide: 'Hide understanding',
22
+ understandingEmpty: 'No understanding is available yet.', understandingLoading: 'Loading understanding…',
23
+ understandingBoundary: 'Original statements, AI inferences and corrections are retained. Eligible evidence is neither verified truth nor permission to act.',
24
+ understandingAvailable: 'Eligible', understandingUnavailable: 'Stopped or evidence unavailable',
25
+ understandingInference: 'AI inference', understandingLiteral: 'Your explicit statement', understandingQuestion: 'Open question',
26
+ understandingStop: 'Stop using this understanding', understandingWithdraw: 'Stop using this source',
27
+ understandingWithdrawalHelp: 'This affects dependent understanding, methods and goal evidence. Native history remains; sent work is not undone and goal tracking is unchanged.',
28
+ understandingCorrect: 'Correct this understanding', understandingReplacement: 'Full replacement text',
29
+ understandingCorrectionHelp: 'Write the complete replacement. Your exact words enter this conversation and are checked before the next unsent step. Earlier versions remain available.',
30
+ understandingSubmit: 'Send correction', understandingCancel: 'Cancel editing',
31
+ understandingSaved: 'Operation recorded.', understandingPending: 'Admitted to the conversation; application is not confirmed. Refresh to see the actual result.',
32
+ understandingUnknown: 'Admission is unconfirmed. Nothing was resent automatically. Refresh the record.',
33
+ understandingApplied: 'Applied', understandingFailed: 'Not applied', understandingAwaiting: 'Awaiting application',
34
+ understandingAdmission: 'Conversation admission', understandingAccepted: 'Accepted', understandingAdmissionFailed: 'Not sent',
35
+ understandingAdmissionUnknown: 'Unknown', understandingVersion: 'Content version', understandingHistory: 'Retained versions', understandingCommands: 'Operations',
36
+ understandingSuccessors: 'Later versions', understandingEffects: 'Affected records', understandingGoalEffects: 'Goal evidence changes',
37
+ understandingSource: 'Original source', understandingProvenance: 'View provenance', understandingMissing: 'Source missing',
38
+ };
@@ -0,0 +1,64 @@
1
+ import { requireViewScope, viewScopeFields } from './browse-source.mjs';
2
+ // Refresh and reconnect only read. Every write has an explicit UI caller.
3
+ export function createUnderstandingSource({ rpc, sessionId, viewScope, subscribeReset, intervalMs = 5000 }) {
4
+ viewScopeFields(viewScope);
5
+ let snapshot = { loading: true, error: null, items: [], total: 0, offset: 0, nextOffset: null, readEpoch: 0 };
6
+ let generation = 0, controller, timer, reset, disposed = false;
7
+ const listeners = new Set(), reads = new Set();
8
+ const stopped = () => Object.assign(new Error('这次读取已经结束,请重新打开。'), { code: 'understanding_read_cancelled' });
9
+ const call = async (endpoint, payload, signal) => {
10
+ if (disposed) throw stopped();
11
+ const scope = ['list', 'details'].includes(endpoint) ? viewScopeFields(viewScope) : {};
12
+ const result = await rpc.call('/api', `arcfoldUnderstandings/${endpoint}`, { args: { request: { ...payload, sessionId, ...scope } } }, signal);
13
+ if (result?.ok !== true) throw Object.assign(new Error(result?.error?.message || '理解请求未完成。'),
14
+ { code: result?.error?.code || 'understanding_request_failed', remote: true });
15
+ return result.value;
16
+ };
17
+ const publish = value => { snapshot = { ...snapshot, ...value }; for (const listener of listeners) listener(); };
18
+ function invalidateReads() {
19
+ controller?.abort(); generation++;
20
+ for (const read of reads) read.abort();
21
+ publish({ loading: true, error: null, items: [], total: 0, offset: 0, nextOffset: null, readEpoch: snapshot.readEpoch + 1 });
22
+ }
23
+ async function refresh(offset = snapshot.offset) {
24
+ if (disposed) return;
25
+ controller?.abort(); controller = new AbortController();
26
+ const current = ++generation, signal = controller.signal;
27
+ try {
28
+ const result = await call('list', { offset, limit: 20 }, signal);
29
+ if (current === generation && !disposed && !signal.aborted) publish({ ...result, offset, loading: false, error: null });
30
+ } catch (error) {
31
+ if (current === generation && !disposed && !signal.aborted) publish({ loading: false, error: error.message });
32
+ }
33
+ }
34
+ async function details(understandingId) {
35
+ if (disposed) throw stopped();
36
+ const read = new AbortController(), epoch = snapshot.readEpoch; reads.add(read);
37
+ try {
38
+ const result = await call('details', { understandingId }, read.signal);
39
+ if (disposed || read.signal.aborted || epoch !== snapshot.readEpoch) throw stopped();
40
+ return result;
41
+ } finally { reads.delete(read); }
42
+ }
43
+ function stop() { clearInterval(timer); timer = undefined; reset?.(); reset = undefined; invalidateReads(); }
44
+ return {
45
+ getSnapshot: () => snapshot,
46
+ subscribe(listener) {
47
+ if (disposed) return () => {};
48
+ listeners.add(listener);
49
+ if (listeners.size === 1) { void refresh(); timer = setInterval(() => { void refresh(); }, intervalMs);
50
+ reset = subscribeReset(() => { invalidateReads(); void refresh(0); }); }
51
+ return () => { listeners.delete(listener); if (!listeners.size) stop(); };
52
+ },
53
+ refresh, details,
54
+ setViewScope(value) {
55
+ requireViewScope(value);
56
+ if (disposed || viewScope === value) return;
57
+ viewScope = value; invalidateReads();
58
+ if (listeners.size) void refresh(0);
59
+ },
60
+ decide: request => call('decide', request),
61
+ correct: request => call('correct', request),
62
+ dispose() { disposed = true; stop(); listeners.clear(); },
63
+ };
64
+ }