odant-work 1.0.103 → 1.0.105

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 (72) hide show
  1. package/$server/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js +15 -12
  2. package/$server/$folder/$class/$module/$mcp/handlers/pages/form/system/mcp/$handler/class.js +17 -24
  3. package/$server/$folder/$class/$module/$provider/handlers/pages/form/system/ai/$handler/class.js +15 -12
  4. package/$server/$folder/$class/$structure/$project/class.js +39 -5
  5. package/$server/$folder/$class/$structure/$project/handlers/pages/form/system/modules/$handler/class.js +40 -25
  6. package/$server/$folder/$class/$structure/$project/handlers/pages/form/system/requisites/$handler/class.js +1 -0
  7. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/license/$handler/class.js +13 -12
  8. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/agent/$handler/class.js +11 -1
  9. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/messengers/$handler/class.js +11 -1
  10. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +1 -0
  11. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/requisites/$handler/class.js +3 -0
  12. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/settings/$handler/class.js +261 -0
  13. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/skills/$handler/class.js +11 -1
  14. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js +2 -0
  15. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/users/$handler/class.js +1 -0
  16. package/$server/$folder/$class/$structure/class.js +15 -0
  17. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +17 -4
  18. package/$server/$folder/$class/$structure/handlers/pages/form/system/agent/$handler/class.js +19 -40
  19. package/$server/$folder/$class/$structure/handlers/pages/form/system/database/$handler/class.js +1 -0
  20. package/$server/$folder/$class/$structure/handlers/pages/form/system/messengers/$handler/class.js +1 -0
  21. package/$server/$folder/$class/$structure/handlers/pages/form/system/skills/$handler/class.js +276 -179
  22. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +1 -0
  23. package/$server/$folder/$class/ai/system.md +2 -2
  24. package/$server/$folder/$class/class.js +5 -1
  25. package/$server/$folder/$class/handlers/pages/form/system/requisites/$handler/class.js +39 -45
  26. package/$server/$folder/$file/$html/handlers/preview/$handler/preview.js +7 -0
  27. package/$server/$folder/$file/$image/handlers/preview/$handler/preview.js +11 -0
  28. package/$server/$folder/$file/$md/handlers/preview/$handler/preview.js +29 -8
  29. package/$server/$folder/$file/$office/handlers/preview/$handler/preview.js +6 -0
  30. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/class.js +34 -2
  31. package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/feed.js +14 -11
  32. package/$server/$folder/$file/$task/handlers/preview/$handler/preview.js +1 -0
  33. package/$server/$folder/$file/$txt/handlers/preview/$handler/preview.js +9 -0
  34. package/$server/$folder/$file/$video/handlers/preview/$handler/preview.js +15 -0
  35. package/$server/$folder/handlers/pages/form/$handler/class.js +187 -3
  36. package/$server/$folder/handlers/pages/form/folder/$handler/class.js +3 -114
  37. package/$server/$folder/lib/explorer/explorer.js +63 -0
  38. package/$server/$folder/lib/folder-browser/folder-browser.js +793 -0
  39. package/$server/$folder/lib/folder-browser/readme.md +5 -0
  40. package/$server/$folder/lib/tree/tree.js +61 -20
  41. package/AGENTS.md +2 -2
  42. package/MODULES/$domain/handlers/pages/form/system/mcp/$handler/class.js +10 -21
  43. package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/handlers/pages/form/system/engine/$handler/class.js +1 -0
  44. package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/handlers/pages/form/system/models/$handler/class.js +5 -10
  45. package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/handlers/pages/form/system/training/$handler/class.js +1 -0
  46. package/MODULES//320/243/321/207/321/221/321/202 /320/270 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/321/213/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/241/321/207/321/221/321/202 /320/275/320/260 /320/276/320/277/320/273/320/260/321/202/321/203.html" +5 -1
  47. package/MODULES//320/243/321/207/321/221/321/202 /320/270 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/321/213/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/242/320/276/320/262/320/260/321/200/320/275/320/260/321/217 /320/275/320/260/320/272/320/273/320/260/320/264/320/275/320/260/321/217.html" +1 -1
  48. package/NODES/$node/handlers/pages/form/network/$handler/class.js +552 -36
  49. package/oda/components/icon/icon.js +20 -7
  50. package/oda/components/layouts/editor-form/editor-form.js +54 -9
  51. package/package.json +1 -1
  52. package/sources/client.js +24 -0
  53. package/sources/data/print.js +27 -3
  54. package/sources/host/websocket.js +28 -1
  55. package/sources/modules/agent/index.js +25 -6
  56. package/sources/modules/agent/permissions.js +4 -2
  57. package/sources/modules/agent/scope.js +72 -5
  58. package/sources/modules/agent/session.js +59 -6
  59. package/sources/modules/agent/tools/work/classes.js +16 -1
  60. package/sources/modules/license/index.js +120 -0
  61. package/sources/modules/nodes/registry.js +57 -7
  62. package/sources/modules/trainer/local-engine.js +22 -9
  63. package/sources/modules/user-profile/user-profile.js +0 -129
  64. package/sources/modules/user-profile/user-tokens.js +381 -86
  65. package/sources/server/access/gateway.js +32 -5
  66. package/sources/server/class/base-template.js +18 -18
  67. package/sources/server/class.js +9 -0
  68. package/sources/server/folder.js +5 -1
  69. package/sources/server/handler.js +6 -0
  70. package/sources/server/node.js +16 -0
  71. package/sources/server/server.js +14 -5
  72. package/sources/server/user.js +3 -0
@@ -1,215 +1,206 @@
1
- export default {
2
- label: 'Навыки',
3
- icon: 'carbon:skill-level-advanced',
4
- order: 25,
5
- tag: 'work-structure-skills',
6
- component: {
7
- imports: 'oda//icon',
1
+ import { buildMergedLayerFolder } from '/~/lib/folder-browser/folder-browser.js';
2
+
3
+ const SKILL_IMPORT_MODAL_TAG = 'work-skill-import-modal';
4
+ if (typeof ODA === 'function' && !customElements.get(SKILL_IMPORT_MODAL_TAG)) {
5
+ ODA({
6
+ is: SKILL_IMPORT_MODAL_TAG,
7
+ imports: 'oda//icon, oda//button',
8
8
  template: /* html */`
9
9
  <style>
10
10
  :host {
11
- display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: auto;
12
- padding: 20px 24px 32px; box-sizing: border-box; gap: 16px;
13
- font-family: var(--font-family, system-ui, -apple-system, sans-serif);
11
+ @apply --vertical;
12
+ gap: 14px;
13
+ padding: 16px 20px;
14
+ min-width: min(640px, 90vw);
15
+ max-width: 760px;
16
+ max-height: 80vh;
17
+ overflow: auto;
18
+ box-sizing: border-box;
19
+ font-size: 13px;
14
20
  color: var(--content-color, #1f2937);
21
+ background: var(--content-background, #ffffff);
15
22
  }
16
- .top-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
17
- .title-wrap { display: flex; align-items: center; gap: 10px; }
18
- .title-icon {
19
- width: 38px; height: 38px; border-radius: 10px;
20
- display: flex; align-items: center; justify-content: center;
21
- background: color-mix(in srgb, var(--accent-color, #2563eb) 14%, transparent);
22
- color: var(--accent-color, #2563eb);
23
+ .section {
24
+ @apply --vertical;
25
+ gap: 10px;
26
+ padding: 12px 14px;
27
+ border: 1px solid var(--subtle-border, var(--border-color));
28
+ border-radius: 10px;
29
+ background: var(--subtle-background, rgba(128, 128, 128, 0.03));
23
30
  }
24
- h2 { margin: 0; font-size: 18px; font-weight: 700; }
25
- .top-bar p { margin: 2px 0 0; font-size: 13px; opacity: 0.75; }
26
- .section-card {
27
- border: 1px solid var(--border-color, rgba(128,128,128,0.22));
28
- border-radius: 12px; padding: 16px;
29
- background: var(--header-background, rgba(128,128,128,0.03));
30
- display: flex; flex-direction: column; gap: 12px;
31
+ .section-title {
32
+ font-size: 13.5px;
33
+ font-weight: 700;
31
34
  }
32
- .section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
33
- .section-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
34
- .cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
35
- .srv-card {
36
- border: 1px solid var(--border-color, rgba(128,128,128,0.22));
37
- border-radius: 10px; padding: 14px;
38
- background: var(--content-background, #fff);
39
- display: flex; flex-direction: column; gap: 8px;
35
+ .host-row {
36
+ @apply --horizontal;
37
+ align-items: center;
38
+ justify-content: space-between;
39
+ gap: 10px;
40
+ padding: 8px 10px;
41
+ border-radius: 8px;
42
+ border: 1px solid var(--subtle-border, var(--border-color));
43
+ background: var(--content-background, #ffffff);
44
+ flex-wrap: wrap;
45
+ }
46
+ .host-info {
47
+ @apply --vertical;
48
+ gap: 2px;
49
+ min-width: 0;
50
+ flex: 1 1 260px;
51
+ }
52
+ .host-sub {
53
+ font-size: 12px;
54
+ color: var(--muted-color);
40
55
  }
41
- .srv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
42
- .srv-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
43
- .srv-sub { font-size: 12px; opacity: 0.72; line-height: 1.4; }
44
56
  .code-chip {
45
- display: inline-block; font-family: ui-monospace, monospace; font-size: 11px;
46
- padding: 2px 7px; border-radius: 6px;
57
+ display: inline-block;
58
+ font-family: ui-monospace, monospace;
59
+ font-size: 11px;
60
+ padding: 2px 7px;
61
+ border-radius: 6px;
47
62
  background: color-mix(in srgb, var(--accent-color, #2563eb) 10%, transparent);
48
63
  color: var(--accent-color, #2563eb);
49
64
  }
50
- .status-pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
51
- .status-on { background: rgba(16,185,129,0.14); color: #059669; }
52
- .status-off { background: rgba(156,163,175,0.2); color: #6b7280; }
53
- .cmd-box { font-family: ui-monospace, monospace; font-size: 11px; padding: 6px 8px; border-radius: 6px; background: rgba(128,128,128,0.08); word-break: break-all; }
54
- .btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
55
- .btn {
56
- border: 1px solid var(--border-color, rgba(128,128,128,0.3));
57
- background: var(--content-background, transparent); color: inherit;
58
- padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 500;
59
- cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
65
+ .field {
66
+ @apply --vertical;
67
+ gap: 4px;
68
+ }
69
+ .field label {
70
+ font-size: 12px;
71
+ font-weight: 600;
72
+ color: var(--muted-color);
60
73
  }
61
- .btn:disabled { opacity: 0.45; cursor: default; }
62
- .btn-primary { background: var(--accent-color, #2563eb); color: #fff; border-color: transparent; }
63
- .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
64
- .field { display: flex; flex-direction: column; gap: 4px; }
65
- .field label { font-size: 12px; font-weight: 600; opacity: 0.85; }
66
74
  .field input, .field textarea {
67
- font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 8px;
75
+ font: inherit;
76
+ font-size: 13px;
77
+ padding: 8px 10px;
78
+ border-radius: 8px;
79
+ border: 1px solid var(--control-border-color, var(--border-color));
80
+ background: var(--content-background, #ffffff);
81
+ color: inherit;
82
+ box-sizing: border-box;
83
+ }
84
+ .field textarea {
85
+ min-height: 120px;
86
+ font-family: ui-monospace, monospace;
87
+ font-size: 12px;
88
+ resize: vertical;
89
+ }
90
+ .btn-row {
91
+ @apply --horizontal;
92
+ align-items: center;
93
+ gap: 8px;
94
+ justify-content: flex-end;
95
+ flex-wrap: wrap;
96
+ }
97
+ .btn {
68
98
  border: 1px solid var(--border-color, rgba(128,128,128,0.3));
69
- background: var(--content-background, transparent); color: inherit; box-sizing: border-box;
99
+ background: var(--content-background, transparent);
100
+ color: inherit;
101
+ padding: 7px 14px;
102
+ border-radius: 8px;
103
+ font-size: 12.5px;
104
+ font-weight: 600;
105
+ cursor: pointer;
106
+ }
107
+ .btn:disabled {
108
+ opacity: 0.45;
109
+ cursor: default;
110
+ }
111
+ .btn-primary {
112
+ background: var(--accent-color, #2563eb);
113
+ color: #ffffff;
114
+ border-color: transparent;
115
+ }
116
+ .notice {
117
+ padding: 9px 12px;
118
+ border-radius: 8px;
119
+ font-size: 12.5px;
120
+ background: rgba(16, 185, 129, 0.12);
121
+ color: #047857;
70
122
  }
71
- .field textarea { min-height: 110px; font-family: ui-monospace, monospace; font-size: 12px; resize: vertical; }
72
- .notice { padding: 10px 14px; border-radius: 10px; font-size: 13px; background: rgba(16,185,129,0.12); color: #047857; }
73
- .notice[error] { background: rgba(239,68,68,0.12); color: #b91c1c; }
74
- .skill-preview {
75
- white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: 11px;
76
- max-height: 220px; overflow: auto; padding: 10px; border-radius: 8px;
77
- background: rgba(128,128,128,0.08);
123
+ .notice[error] {
124
+ background: rgba(239, 68, 68, 0.12);
125
+ color: #b91c1c;
78
126
  }
79
127
  </style>
80
128
 
81
- <div class="top-bar">
82
- <div class="title-wrap">
83
- <div class="title-icon"><oda-icon icon="carbon:skill-level-advanced" icon-size="22"></oda-icon></div>
84
- <div>
85
- <h2>Навыки ИИ (Skills)</h2>
86
- <p>Навыки <span class="code-chip">ai/skills/</span> наследуются вниз по ветке структур; вызываются через <span class="code-chip">@имя</span></p>
87
- </div>
88
- </div>
89
- </div>
90
-
91
129
  <div ~if="noticeText" class="notice" :error="noticeError">{{noticeText}}</div>
92
130
 
93
- <div class="section-card" ~if="hostSkills.length">
94
- <div class="section-head">
95
- <h3>💻 Найдены на этом ПК в OpenCode / Claude Code ({{hostSkills.length}})</h3>
96
- </div>
97
- <div class="cards-grid">
98
- <div class="srv-card" ~for="hostSkills">
99
- <div class="srv-head">
100
- <div>
101
- <div class="srv-title">
102
- <span class="code-chip">@{{$for.item.id}}</span>
103
- <span>{{$for.item.sourceLabel}}</span>
104
- </div>
105
- <div class="srv-sub">{{$for.item.description}}</div>
106
- </div>
107
- <span class="status-pill" :class="$for.item.installedInWork ? 'status-on' : 'status-off'">
108
- {{$for.item.installedInWork ? '✓ В WORK' : 'Внешний'}}
109
- </span>
110
- </div>
111
- <div class="cmd-box">{{$for.item.filePath}}</div>
112
- <div class="btn-row">
113
- <button class="btn btn-primary" @tap="importHostSkill($for.item)">
114
- {{$for.item.installedInWork ? '⬇ Перезаписать с ПК' : '⬇ Импортировать в WORK'}}
115
- </button>
131
+ <div class="section" ~if="hostSkills.length">
132
+ <div class="section-title">Найдены на этом ПК в OpenCode / Claude Code ({{hostSkills.length}})</div>
133
+ <div class="host-row" ~for="hostSkills">
134
+ <div class="host-info">
135
+ <div>
136
+ <span class="code-chip">@{{$for.item.id}}</span>
137
+ <span style="font-weight:600;margin-left:6px;">{{$for.item.sourceLabel}}</span>
116
138
  </div>
139
+ <div class="host-sub">{{$for.item.description || $for.item.filePath}}</div>
117
140
  </div>
141
+ <button type="button" class="btn btn-primary" :disabled="busy" @tap="importHostSkill($for.item)">
142
+ {{$for.item.installedInWork ? 'Перезаписать с ПК' : 'Импортировать'}}
143
+ </button>
118
144
  </div>
119
145
  </div>
120
146
 
121
- <div class="section-card">
122
- <div class="section-head">
123
- <h3>➕ Добавить навык (URL / GitHub или SKILL.md)</h3>
147
+ <div class="section">
148
+ <div class="section-title">Добавить навык по ссылке или из текста SKILL.md</div>
149
+ <div class="field">
150
+ <label>Ссылка на SKILL.md или папку навыка на GitHub</label>
151
+ <input type="text" :value="skillUrlInput" @input="skillUrlInput = $event.target.value" placeholder="https://github.com/.../SKILL.md">
124
152
  </div>
125
- <div class="form-grid">
126
- <div class="field" style="grid-column: span 2;">
127
- <label>Ссылка на SKILL.md или папку навыка на GitHub</label>
128
- <input type="text" :value="skillUrlInput" @input="skillUrlInput = $event.target.value" placeholder="https://github.com/.../SKILL.md">
129
- </div>
130
- <div class="field">
131
- <label>Имя навыка (если нет во фронтматтере)</label>
132
- <input type="text" :value="skillIdInput" @input="skillIdInput = $event.target.value" placeholder="my-skill">
133
- </div>
153
+ <div class="field">
154
+ <label>Имя навыка (если нет во фронтматтере)</label>
155
+ <input type="text" :value="skillIdInput" @input="skillIdInput = $event.target.value" placeholder="my-skill">
134
156
  </div>
135
157
  <div class="field">
136
- <label>Или вставьте текст <code>SKILL.md</code>:</label>
158
+ <label>Или вставьте текст <code>SKILL.md</code></label>
137
159
  <textarea :value="skillContentInput" @input="skillContentInput = $event.target.value" placeholder="---\nname: my-skill\ndescription: Когда применять навык\n---\n\nИнструкция..."></textarea>
138
160
  </div>
139
161
  <div class="btn-row">
140
- <button class="btn btn-primary" :disabled="!canSaveCustomSkill" @tap="installCustomSkill">⚡ Сохранить навык</button>
141
- </div>
142
- </div>
143
-
144
- <div class="section-card">
145
- <div class="section-head">
146
- <h3>🧠 Доступные навыки ({{skills.length}})</h3>
147
- </div>
148
- <div class="cards-grid">
149
- <div class="srv-card" ~for="skills">
150
- <div class="srv-head">
151
- <div>
152
- <div class="srv-title"><span class="code-chip">@{{$for.item.id}}</span></div>
153
- <div class="srv-sub">{{$for.item.description}}</div>
154
- </div>
155
- <span class="status-pill status-on">{{$for.item.isFolder ? 'SKILL.md' : '.md'}}</span>
156
- </div>
157
- <div class="cmd-box">{{$for.item.path}}</div>
158
- <div class="btn-row">
159
- <button class="btn" @tap="togglePreviewSkill($for.item)">
160
- {{expandedSkillId === $for.item.id ? '▲ Скрыть' : '👁 Инструкция'}}
161
- </button>
162
- <button class="btn" @tap="copySkillMention($for.item)">📋 @{{$for.item.id}}</button>
163
- </div>
164
- <div ~if="expandedSkillId === $for.item.id" class="skill-preview">{{$for.item.body}}</div>
165
- </div>
162
+ <button type="button" class="btn" @tap="closeModal()">Закрыть</button>
163
+ <button type="button" class="btn btn-primary" :disabled="busy || !canSaveCustomSkill" @tap="installCustomSkill()">Сохранить навык</button>
166
164
  </div>
167
165
  </div>
168
166
  `,
169
- $item: {
170
- $def: null,
171
- set(n, o) {
172
- if (o && this._onChanged) o.unlisten?.('changed', this._onChanged);
173
- if (n) {
174
- this._onChanged ??= () => this.debounce?.('skills-reload', () => this.reload(), 150) ?? this.reload();
175
- n.listen?.('changed', this._onChanged);
176
- this.reload();
177
- }
178
- },
179
- },
180
- skills: [],
167
+ $item: null,
181
168
  hostSkills: [],
182
- expandedSkillId: '',
169
+ busy: false,
183
170
  noticeText: '',
184
171
  noticeError: false,
185
172
  skillUrlInput: '',
186
173
  skillIdInput: '',
187
174
  skillContentInput: '',
175
+ onInstalled: null,
188
176
  get canSaveCustomSkill() {
189
177
  return Boolean(String(this.skillUrlInput || '').trim() || String(this.skillContentInput || '').trim());
190
178
  },
191
179
  attached() {
192
- this.reload();
180
+ this.loadHostSkills();
193
181
  },
194
- detached() {
195
- if (this.$item && this._onChanged) this.$item.unlisten?.('changed', this._onChanged);
182
+ async loadHostSkills() {
183
+ if (!this.$item?.fetch) return;
184
+ try {
185
+ const res = await this.$item.fetch('skills_catalog', { place: this.$item.path || '/' });
186
+ this.hostSkills = Array.isArray(res?.hostSkills) ? res.hostSkills : [];
187
+ } catch { /* ignore */ }
196
188
  },
197
189
  showNotice(text, isError = false) {
198
190
  this.noticeText = String(text || '');
199
191
  this.noticeError = Boolean(isError);
200
192
  },
201
- async reload() {
202
- if (!this.$item || typeof this.$item.fetch !== 'function') return;
203
- try {
204
- const res = await this.$item.fetch('skills_catalog', { place: this.$item.path || '/' });
205
- this.skills = Array.isArray(res?.skills) ? res.skills : [];
206
- this.hostSkills = Array.isArray(res?.hostSkills) ? res.hostSkills : [];
207
- }
208
- catch (e) {
209
- this.showNotice('Ошибка загрузки навыков: ' + (e?.message || e), true);
193
+ closeModal() {
194
+ for (let p = this.parentElement || this.domHost; p; p = p.parentElement || p.domHost) {
195
+ if (typeof p.close === 'function') {
196
+ p.close();
197
+ return;
198
+ }
210
199
  }
211
200
  },
212
201
  async importHostSkill(hostSkill) {
202
+ if (!this.$item?.fetch || this.busy) return;
203
+ this.busy = true;
213
204
  try {
214
205
  const res = await this.$item.fetch('skill_install', {
215
206
  sourceType: 'host',
@@ -217,20 +208,21 @@ export default {
217
208
  scope: this.$item?.path === '/' ? 'global' : 'place',
218
209
  targetPath: this.$item?.path || '/',
219
210
  });
220
- this.showNotice(`Навык @${res.id} импортирован в ${res.path}!`);
221
- await this.reload();
222
- }
223
- catch (e) {
211
+ this.showNotice(`Навык @${res.id} импортирован в ${res.path}`);
212
+ await this.loadHostSkills();
213
+ await this.onInstalled?.();
214
+ } catch (e) {
224
215
  this.showNotice(e?.message || String(e), true);
216
+ } finally {
217
+ this.busy = false;
225
218
  }
226
219
  },
227
220
  async installCustomSkill() {
221
+ if (!this.$item?.fetch || this.busy) return;
228
222
  const hasUrl = Boolean(String(this.skillUrlInput || '').trim());
229
223
  const hasContent = Boolean(String(this.skillContentInput || '').trim());
230
- if (!hasUrl && !hasContent) {
231
- this.showNotice('Укажите ссылку на SKILL.md или вставьте текст навыка', true);
232
- return;
233
- }
224
+ if (!hasUrl && !hasContent) return;
225
+ this.busy = true;
234
226
  try {
235
227
  const res = await this.$item.fetch('skill_install', {
236
228
  sourceType: hasUrl ? 'url' : 'content',
@@ -243,25 +235,130 @@ export default {
243
235
  this.skillUrlInput = '';
244
236
  this.skillIdInput = '';
245
237
  this.skillContentInput = '';
246
- this.showNotice(`Навык @${res.id} установлен в ${res.path}!`);
247
- await this.reload();
248
- }
249
- catch (e) {
238
+ this.showNotice(`Навык @${res.id} установлен в ${res.path}`);
239
+ await this.onInstalled?.();
240
+ } catch (e) {
250
241
  this.showNotice(e?.message || String(e), true);
242
+ } finally {
243
+ this.busy = false;
251
244
  }
252
245
  },
253
- togglePreviewSkill(skill) {
254
- this.expandedSkillId = this.expandedSkillId === skill.id ? '' : skill.id;
246
+ });
247
+ }
248
+
249
+ export default {
250
+ label: 'Навыки и агенты',
251
+ description: 'Файловое дерево ai/ текущего контекста: навыки (skills/), субагенты (agents/), инструкции и память',
252
+ icon: 'carbon:skill-level-advanced',
253
+ order: 25,
254
+ tag: 'work-structure-skills',
255
+ component: {
256
+ imports: '~/lib//folder-browser.js',
257
+ template: /* html */`
258
+ <style>
259
+ :host {
260
+ @apply --vertical;
261
+ @apply --flex;
262
+ min-height: 0;
263
+ min-width: 0;
264
+ overflow: hidden;
265
+ }
266
+ </style>
267
+ <work-folder-browser
268
+ ~if="aiRoot"
269
+ flex
270
+ :root-folder="aiRoot"
271
+ :root-title="aiRootTitle"
272
+ hide-system-toggle
273
+ :default-hide-system="false"
274
+ :allow-global-search="false"
275
+ :show-tree-tools="false"
276
+ empty-hint-text="Выберите файл в дереве слева (skills/, agents/, system.md, config.js) для просмотра. Двойной клик или «Открыть» открывает файл во вкладке.">
277
+ </work-folder-browser>
278
+ <div ~if="!aiRoot" style="padding:20px;color:var(--muted-color);font-size:13px;">Загрузка дерева ai/…</div>
279
+ `,
280
+ $item: {
281
+ $def: null,
282
+ set(n, o) {
283
+ if (o && this._onChanged) o.unlisten?.('changed', this._onChanged);
284
+ if (n) {
285
+ this._onChanged ??= () => this.debounce?.('ai-reload', () => this.reload(), 150) ?? this.reload();
286
+ n.listen?.('changed', this._onChanged);
287
+ this.reload();
288
+ } else {
289
+ this.aiRoot = null;
290
+ }
291
+ },
292
+ },
293
+ aiRoot: null,
294
+ get aiRootTitle() {
295
+ const lbl = this.$item?.DATA?.label || this.$item?.label || this.$item?.id || 'ai';
296
+ return `${lbl} / ai`;
255
297
  },
256
- async copySkillMention(skill) {
257
- const mention = '@' + skill.id + ' ';
258
- try {
259
- await navigator.clipboard.writeText(mention);
260
- this.showNotice(`Скопировано «${mention.trim()}»`);
298
+ get headerActions() {
299
+ if (!this.$item) return [];
300
+ return [{
301
+ id: 'import-skill',
302
+ icon: 'icons:add',
303
+ label: 'Импорт навыка',
304
+ title: 'Установить навык с ПК, по URL (GitHub) или из текста SKILL.md',
305
+ onClick: () => this.openImportDialog(),
306
+ }];
307
+ },
308
+ attached() {
309
+ if (this.$item && !this.aiRoot)
310
+ this.reload();
311
+ },
312
+ detached() {
313
+ if (this.$item && this._onChanged)
314
+ this.$item.unlisten?.('changed', this._onChanged);
315
+ },
316
+ async reload() {
317
+ const item = this.$item;
318
+ if (!item || typeof item.fetch !== 'function') {
319
+ this.aiRoot = null;
320
+ return;
261
321
  }
262
- catch {
263
- this.showNotice(`Напишите ${mention.trim()} в чате.`);
322
+ const seq = (this._reloadSeq = (this._reloadSeq || 0) + 1);
323
+ try {
324
+ const rawLayers = await item.fetch('ai_layers').catch(() => []);
325
+ if (seq !== this._reloadSeq || this.$item !== item)
326
+ return;
327
+ const list = Array.isArray(rawLayers) ? rawLayers : [];
328
+ const resolved = await Promise.all(list.map(async l => {
329
+ const folder = l?.path ? await WORK.get_item(l.path).catch(() => null) : null;
330
+ return folder ? { item: folder, scope: l.scope || '/', isOwn: Boolean(l.isOwn) } : null;
331
+ }));
332
+ if (seq !== this._reloadSeq || this.$item !== item)
333
+ return;
334
+ const valid = resolved.filter(Boolean);
335
+ if (!valid.length) {
336
+ this.aiRoot = null;
337
+ return;
338
+ }
339
+ const ownAiPath = (item.meta_folder?.path || item.path || '') + '/ai';
340
+ this.aiRoot = buildMergedLayerFolder(valid, {
341
+ id: 'ai',
342
+ label: 'ai',
343
+ path: ownAiPath,
344
+ });
345
+ } catch {
346
+ if (seq === this._reloadSeq)
347
+ this.aiRoot = null;
264
348
  }
265
349
  },
350
+ async openImportDialog() {
351
+ if (!this.$item || typeof WORK?.showModal !== 'function')
352
+ return;
353
+ const dlg = ODA.createComponent(SKILL_IMPORT_MODAL_TAG, {
354
+ $item: this.$item,
355
+ onInstalled: () => this.reload(),
356
+ });
357
+ try {
358
+ await WORK.showModal(dlg, {
359
+ TITLE: { label: 'Импорт навыка в ai/skills/', icon: 'carbon:skill-level-advanced' },
360
+ });
361
+ } catch { /* closed */ }
362
+ },
266
363
  },
267
364
  };
@@ -1154,6 +1154,7 @@ if (typeof ODA === 'function' && !customElements.get('staff-role-node')) {
1154
1154
  // ---------------------------------------------------------------------------
1155
1155
  export default {
1156
1156
  label: 'Пользователи',
1157
+ description: 'Владельцы (BOSS), рабочие места подразделений и матрица прав доступа',
1157
1158
  icon: 'icons:supervisor-account',
1158
1159
  order: 20,
1159
1160
  component: {
@@ -27,8 +27,8 @@
27
27
  - **Учёт:** `$catalog` (листья хранят объекты, группы агрегируют), `$virtual` (`turnover`/`balance` + `OVERLAY`), `$struct` (`table: true` — таблица), `$operation` — двойная запись (Дебет + Кредит в `$account` + `logs`); проведённое исправляется только сторно; поля справочника-аналитики — субаналитики.
28
28
  - **Ядро и дерево:** ядро (`sources/`, `oda/`, `run.mjs`, `#system/`) меняется только по явной задаче доработки движка через `developer`-контур (тесты, отложенный перезапуск). Остальное — дерево, включая системный типизатор `/$server/$folder`; оно меняется штатно, без git. Правки типизатора и модулей уровня WORK — только извне проектов, с подтверждением, проверкой последствий и сбросом кэша.
29
29
  - **Арены инструментов:** дерево — WORK-инструментами (`ls/read/find/write/edit/delete`, `create_class/update_class/move_class/delete_class`), файлы ОС вне WORK — `os_*`; `shell` не служит обходом WORK-ограничений.
30
- - **Интерфейс:** две базовые страницы (`explorer` в `$structure`, `form` в `$folder` — единый `work-form`, включая вкладку `form/folder` для `$class` и потомков с режимом «Показать системные» для `BOSS`). Представления и суб-представления — дерево `$handler` в `handlers/pages/form/<view>[/<subview>]/$handler/class.js` (без `tabs/` и без `<имя>.js`: метаданные и `component` в одном `class.js`). Штатные компоненты (`form/objects`, `form/objects/object`, `oda-packets`, `item-class-picker`) не дублируются; дерево `#formClassTree` включается по `objects: true`.
31
- - **Правило изменений:** новая возможность — файл или папка в нужном типе плюс штатное наследование. Не выражается так — спецслучай не делай, принеси пользователю развилку.
30
+ - **Интерфейс:** две базовые страницы (`explorer` в `$structure`, `form` в `$folder` — единый `work-form`, включая `work-folder-browser` для `form/folder` с режимом «Показать системные» для `BOSS` и для `.../ai/...`). Представления и суб-представления — дерево `$handler` в `handlers/pages/form/<view>[/<subview>]/$handler/class.js` (без `tabs/` и без `<имя>.js`: метаданные и `component` в одном `class.js`). Единый заголовок суб-форм рисует сам `work-subview-container` из `{ icon, label, description }` хендлера — самописные шапки внутри суб-форм запрещены. Штатные компоненты (`form/objects`, `form/objects/object`, `oda-packets`, `item-class-picker`, `work-folder-browser`) не дублируются; дерево `#formClassTree` включается по `objects: true`.
31
+ - **Правило правил и изменений:** всё строится строго по общим принципам, единым шаблонам и метаданным — **без костылей**. Новая возможность — файл или папка в нужном типе плюс штатное наследование; не выражается так — спецслучай не делай, принеси пользователю развилку.
32
32
 
33
33
  ## Память и делегирование
34
34
 
@@ -1,5 +1,9 @@
1
1
  export default{
2
- METADATA: {},
2
+ METADATA: {
3
+ STATIC: [
4
+ { id: 'label', label: 'Название', type: 'string', required: true },
5
+ ],
6
+ },
3
7
  /**
4
8
  * Мета ролей: внешний вид. Поведение единственной встроенной роли
5
9
  * (BOSS) — в коде (sources/server/access/policy.js), данными