hostlet 0.1.0-alpha.1 → 0.1.0-alpha.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.
- package/dist/plugins/model-profiles/index.js +5 -2
- package/dist/plugins/model-profiles/rules.d.ts +2 -0
- package/dist/plugins/model-profiles/rules.js +46 -8
- package/dist/plugins/model-profiles/skills/model-profile/SKILL.md +2 -1
- package/dist/plugins/model-profiles/storage.d.ts +28 -8
- package/dist/plugins/model-profiles/storage.js +59 -22
- package/dist/plugins/model-profiles/types.d.ts +9 -1
- package/dist/plugins/tools/index.js +7 -4
- package/node_modules/@hostlet/adapter-kit/package.json +1 -1
- package/node_modules/@hostlet/platform/dist/desktop.js +17 -11
- package/node_modules/@hostlet/platform/package.json +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
2
2
|
import { address, ArgsError, array, HttpError, newId, object, OWNER_ID } from 'hostlet/sdk';
|
|
3
3
|
import { computeMeasured, demoteExpiredLines, emptyLines, familiesOverlap, hasVerifiedFamilyBootstrap, independentConfirmationCount, isQualifyingCrossFamilyObservation, sameStringArray, validateFamilyTagUpdate, validateProfileWrite, } from "./rules.js";
|
|
4
4
|
import { createSources, domainOfTopic, resolveHostLink } from "./sources.js";
|
|
5
|
-
import { ProfilesStore, renderProfileDetail, renderProfileMeta, renderProfileSummary, } from "./storage.js";
|
|
5
|
+
import { ProfilesStore, renderProfileCaption, renderProfileCard, renderProfileDetail, renderProfileMeta, renderProfilePending, renderProfileSummary, } from "./storage.js";
|
|
6
6
|
import { EXPIRY_CHECK_MS, RECENT_MODEL_MS, ROLES, SIGNS, WINDOW_DAYS, WINDOW_MS, } from "./types.js";
|
|
7
7
|
import { runWakeupCheck } from "./wakeup.js";
|
|
8
8
|
const string = { type: 'string' };
|
|
@@ -15,6 +15,7 @@ const profileLineSchema = object({
|
|
|
15
15
|
evidence: { ...array(string), description: '引用的观察记录编号列表' },
|
|
16
16
|
selfDescribed: boolean,
|
|
17
17
|
reason: string,
|
|
18
|
+
expiredAt: { type: 'number', description: '自动降级时间。原样回传 profiles.get 里的降级行时可带上;只认与已存降级行相同的行,其余忽略' },
|
|
18
19
|
}, ['text']);
|
|
19
20
|
const profileLinesSchema = object({
|
|
20
21
|
strengths: { ...array(profileLineSchema), description: '擅长(最多 3 行)' },
|
|
@@ -105,7 +106,8 @@ export default function modelProfilesPlugin(home, ext) {
|
|
|
105
106
|
const meta = renderProfileMeta(clean);
|
|
106
107
|
const summary = renderProfileSummary(clean);
|
|
107
108
|
const detail = renderProfileDetail(clean, domainLabel, bootstrapped);
|
|
108
|
-
|
|
109
|
+
const card = renderProfileCard(clean, domainLabel);
|
|
110
|
+
return { ...clean, meta, summary, detail, caption: renderProfileCaption(clean), card, pending: renderProfilePending(clean, domainLabel) };
|
|
109
111
|
};
|
|
110
112
|
const readBook = () => store.readBook(sourcesAvailability());
|
|
111
113
|
const findRecord = (kind, key) => {
|
|
@@ -750,6 +752,7 @@ export default function modelProfilesPlugin(home, ext) {
|
|
|
750
752
|
callerId,
|
|
751
753
|
callerModel,
|
|
752
754
|
now,
|
|
755
|
+
keepLines: lines === undefined,
|
|
753
756
|
});
|
|
754
757
|
const familyTag = kind === 'model'
|
|
755
758
|
? validateFamilyTagUpdate({
|
|
@@ -85,6 +85,8 @@ export interface WriteValidationContext {
|
|
|
85
85
|
callerId: string;
|
|
86
86
|
callerModel: string | null;
|
|
87
87
|
now: number;
|
|
88
|
+
/** A labels-only write: check the version and keep the three sections exactly as stored. */
|
|
89
|
+
keepLines?: boolean;
|
|
88
90
|
}
|
|
89
91
|
export declare function validateProfileWrite(ctx: WriteValidationContext): ProfileLines;
|
|
90
92
|
/**
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ArgsError, HttpError, OWNER_ID } from 'hostlet/sdk';
|
|
2
2
|
import { MAX_BODY_CHARS, MAX_LINES, MAX_WAKEUP_EVIDENCE, ROLES, WAKEUP_THRESHOLD, WINDOW_DAYS, WINDOW_MS, } from "./types.js";
|
|
3
3
|
const ROLE_SET = new Set(ROLES);
|
|
4
|
+
// Any link, external or into the host: Markdown links, bare URLs, #chat-/#plans/ addresses and res: resources.
|
|
5
|
+
const URL_RE = /https?:\/\/|\]\(|#(?:chat|plans)-?\/?[\w-]|\bres:/i;
|
|
6
|
+
const MAX_REASON_CHARS = 12;
|
|
4
7
|
const FAMILY_TAG_RE = /^[a-z0-9][a-z0-9._-]{0,31}$/;
|
|
5
8
|
const MAX_FAMILY_TAGS = 8;
|
|
6
9
|
export function familiesOverlap(a, b) {
|
|
@@ -400,15 +403,48 @@ export function validateProfileWrite(ctx) {
|
|
|
400
403
|
if (baseVersion !== expectedVersion) {
|
|
401
404
|
throw new HttpError(409, `版本冲突:当前版本为 ${expectedVersion},传入的 baseVersion 为 ${baseVersion}`);
|
|
402
405
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
+
if (ctx.keepLines)
|
|
407
|
+
return structuredClone(current?.lines ?? emptyLines());
|
|
408
|
+
// A conclusion written into 擅长/注意 is confirmed now: any earlier expiry mark does not come with it.
|
|
409
|
+
const confirmed = (line) => { const { expiredAt: _old, ...rest } = line; return rest; };
|
|
410
|
+
const strengths = (ctx.lines.strengths ?? []).map((line, i) => confirmed(normalizeLine(line, '擅长', i)));
|
|
411
|
+
const cautions = (ctx.lines.cautions ?? []).map((line, i) => confirmed(normalizeLine(line, '注意', i)));
|
|
412
|
+
// A line written back exactly as a stored demoted line is that line: it keeps its expiry mark, tag and evidence.
|
|
413
|
+
// Each stored demoted line can be carried back once, as is; an edited reason makes it a line written now.
|
|
414
|
+
const unclaimed = (current?.lines.review ?? []).filter((prior) => prior.expiredAt !== undefined);
|
|
415
|
+
const carried = new Set();
|
|
416
|
+
const review = (ctx.lines.review ?? []).map((line, i) => {
|
|
417
|
+
const normalized = normalizeLine(line, '待复核', i);
|
|
418
|
+
const at = unclaimed.findIndex((item) => sameProfileLine(normalized, item)
|
|
419
|
+
&& (normalized.reason === undefined || normalized.reason === item.reason));
|
|
420
|
+
if (at >= 0) {
|
|
421
|
+
const kept = structuredClone(unclaimed.splice(at, 1)[0]);
|
|
422
|
+
carried.add(kept);
|
|
423
|
+
return kept;
|
|
424
|
+
}
|
|
425
|
+
return confirmed(normalized);
|
|
426
|
+
});
|
|
406
427
|
if (strengths.length > MAX_LINES) {
|
|
407
428
|
throw new ArgsError(`「擅长」最多 ${MAX_LINES} 行,当前有 ${strengths.length} 行`);
|
|
408
429
|
}
|
|
409
430
|
if (cautions.length > MAX_LINES) {
|
|
410
431
|
throw new ArgsError(`「注意」最多 ${MAX_LINES} 行,当前有 ${cautions.length} 行`);
|
|
411
432
|
}
|
|
433
|
+
// 待复核 holds conclusions awaiting cross-family confirmation and a line or two of self-description;
|
|
434
|
+
// not notes on why something was left out, nor copied specs, prices, scores or links. Lines the expiry
|
|
435
|
+
// check demoted keep their evidence and do not count, so demotion never blocks the next write.
|
|
436
|
+
const written = review.filter((line) => !carried.has(line));
|
|
437
|
+
if (written.length > MAX_LINES) {
|
|
438
|
+
throw new ArgsError(`「待复核」最多 ${MAX_LINES} 行(不含过期降级的行),当前有 ${written.length} 行:只留待跨系列确认的结论和一两句模型定位`);
|
|
439
|
+
}
|
|
440
|
+
written.forEach((line, i) => {
|
|
441
|
+
if (URL_RE.test(line.text) || (line.reason && URL_RE.test(line.reason))) {
|
|
442
|
+
throw new ArgsError(`「待复核」第 ${i + 1} 行不要放链接:资料来源写进观察记录,画像只写结论`);
|
|
443
|
+
}
|
|
444
|
+
if (line.reason && [...line.reason].length > MAX_REASON_CHARS) {
|
|
445
|
+
throw new ArgsError(`「待复核」第 ${i + 1} 行的 reason 最多 ${MAX_REASON_CHARS} 字,只写短标签(如「仅 1 位判断人」)`);
|
|
446
|
+
}
|
|
447
|
+
});
|
|
412
448
|
const normalized = { strengths, cautions, review };
|
|
413
449
|
const totalChars = bodyCharCount(normalized);
|
|
414
450
|
if (totalChars > MAX_BODY_CHARS) {
|
|
@@ -432,11 +468,13 @@ export function validateProfileWrite(ctx) {
|
|
|
432
468
|
const existingReview = current?.lines.review ?? [];
|
|
433
469
|
const nextReview = sameFamilyCaller
|
|
434
470
|
? review.map((line) => {
|
|
435
|
-
|
|
471
|
+
if (carried.has(line))
|
|
472
|
+
return line;
|
|
473
|
+
const prior = existingReview.find((item) => item.expiredAt === undefined && sameProfileLine(line, item)
|
|
474
|
+
&& (line.reason === undefined || line.reason === item.reason));
|
|
436
475
|
if (prior)
|
|
437
476
|
return { ...prior, evidence: [...prior.evidence] };
|
|
438
|
-
|
|
439
|
-
return { ...clean, selfDescribed: true, reason: clean.reason || '自述' };
|
|
477
|
+
return { ...line, selfDescribed: true, reason: line.reason || '自述' };
|
|
440
478
|
})
|
|
441
479
|
: review;
|
|
442
480
|
return {
|
|
@@ -578,13 +616,13 @@ export function demoteExpiredLines(lines, observations, now) {
|
|
|
578
616
|
const moved = [];
|
|
579
617
|
for (const line of lines.strengths) {
|
|
580
618
|
if (expired(line))
|
|
581
|
-
moved.push({ ...line, expiredAt: now, reason:
|
|
619
|
+
moved.push({ ...line, expiredAt: now, reason: '原擅长,证据已过期' });
|
|
582
620
|
else
|
|
583
621
|
keptStrengths.push(line);
|
|
584
622
|
}
|
|
585
623
|
for (const line of lines.cautions) {
|
|
586
624
|
if (expired(line))
|
|
587
|
-
moved.push({ ...line, expiredAt: now, reason:
|
|
625
|
+
moved.push({ ...line, expiredAt: now, reason: '原注意,证据已过期' });
|
|
588
626
|
else
|
|
589
627
|
keptCautions.push(line);
|
|
590
628
|
}
|
|
@@ -55,5 +55,6 @@ description: 派活、挑选复核人、自感知或维护模型与客户端画
|
|
|
55
55
|
- **模型系列标签(`families`)**:
|
|
56
56
|
- 宿主与插件代码不再硬编码模型前缀规则,所有模型的所属系列均通过画像初始化或修订时传入 `families` 维护(支持复合模型多系列,如 `["anthropic", "cognition"]`;可只传 `families` 与 `baseVersion` 不改文字栏)。
|
|
57
57
|
- **防伪与冷启动边界**:机主设置立即生效;非机主提交先记为待确认,须由 **2 位彼此不同系列且均不与该模型系列重叠的已核实成员** 分别调用 `profiles.write` 确认同一 `families` 后才生效,并统一提供给会签、代码复核与画像使用。全新宿主尚未产生两个互不重叠的已核实系列前,冷启动阶段允许 2 位使用不同模型的其他成员确认首批模型,满 2 个互不重叠已核实系列后自动切换为严格跨系列确认。
|
|
58
|
-
-
|
|
58
|
+
- **保持简短**:「擅长」「注意」「待复核」各不超过 3 行(「待复核」里插件自动降级的过期行原样保留、不计入),整份画像正文(不含证据编号)不超过 200 字。
|
|
59
|
+
- **「待复核」只放两类**:等跨系列确认的结论,以及一两句模型定位的自述。不写“为什么没写进擅长/注意”(未达门槛的观察留在观察记录里,下一批唤醒会再出现),不抄定价、跑分、上下文长度等公开资料,不放链接(含站内的 `#chat-`、`#plans/`、`res:` 地址);`reason` 只写 12 字以内的短标签,如「仅 1 位判断人」。插件会拒绝超过 3 行、带链接或 reason 过长的写入。主题页每个模型一行,正文只显示实测、「擅长」「注意」和证据条数,「待复核」点开这一行才显示;证据编号用 `profiles.get` 看。只改系列标签(只传 `families`)时三栏原样保留、不做文字校验;原样回传 `profiles.get` 里的降级行(可带 `expiredAt`)会被认作原降级行。
|
|
59
60
|
- **反例处理**:已被后续证据推翻的结论在修订时直接删掉;条件明确的两面现象改写成带条件的句子。
|
|
@@ -3,6 +3,14 @@ export declare function atomicWrite(path: string, content: string): void;
|
|
|
3
3
|
export declare function appendJsonl(path: string, entry: unknown): void;
|
|
4
4
|
export declare function readJsonl<T>(path: string): T[];
|
|
5
5
|
export declare function formatMeasuredLines(stats: MeasuredStats, kind: 'model' | 'client'): string[];
|
|
6
|
+
/** The page card body: measured stats, then 擅长 and 注意 with evidence counts instead of IDs. */
|
|
7
|
+
export declare function renderProfileCard(record: Pick<ProfileRecord, 'kind' | 'measured' | 'lines'>, domainLabel: (id: string) => string): string;
|
|
8
|
+
/** 待复核 lines for the row's own expand area, one Markdown line each. */
|
|
9
|
+
export declare function renderProfilePending(record: Pick<ProfileRecord, 'lines'>, domainLabel: (id: string) => string): {
|
|
10
|
+
text: string;
|
|
11
|
+
}[];
|
|
12
|
+
/** Row title: the key, family and how many 待复核 lines the row folds away. */
|
|
13
|
+
export declare function renderProfileCaption(record: Pick<ProfileRecord, 'key' | 'families' | 'pendingFamilies' | 'version' | 'lines'>): string;
|
|
6
14
|
export declare function renderProfileDetail(record: Pick<ProfileRecord, 'key' | 'kind' | 'families' | 'pendingFamilies' | 'version' | 'updatedAt' | 'updatedBy' | 'measured' | 'lines'>, domainLabel: (id: string) => string, bootstrapped?: boolean): string;
|
|
7
15
|
export declare function renderProfileSummary(record: Pick<ProfileRecord, 'kind' | 'families' | 'pendingFamilies' | 'measured' | 'lines'>): string;
|
|
8
16
|
export declare function renderProfileMeta(record: Pick<ProfileRecord, 'version' | 'updatedAt'>): string;
|
|
@@ -39,21 +47,33 @@ export declare const DEFAULT_VIEW_JSON: {
|
|
|
39
47
|
type: string;
|
|
40
48
|
when: string;
|
|
41
49
|
text: string;
|
|
50
|
+
id?: undefined;
|
|
42
51
|
from?: undefined;
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
expand?: undefined;
|
|
53
|
+
row?: undefined;
|
|
45
54
|
} | {
|
|
46
55
|
type: string;
|
|
56
|
+
id: string;
|
|
47
57
|
from: string;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
expand: string;
|
|
59
|
+
row: {
|
|
60
|
+
layout: string;
|
|
61
|
+
key: string;
|
|
62
|
+
title: string;
|
|
63
|
+
more: {
|
|
53
64
|
type: string;
|
|
54
65
|
text: string;
|
|
55
66
|
}[];
|
|
56
|
-
|
|
67
|
+
expand: {
|
|
68
|
+
type: string;
|
|
69
|
+
from: string;
|
|
70
|
+
itemKey: string;
|
|
71
|
+
blocks: {
|
|
72
|
+
type: string;
|
|
73
|
+
text: string;
|
|
74
|
+
}[];
|
|
75
|
+
}[];
|
|
76
|
+
};
|
|
57
77
|
when?: undefined;
|
|
58
78
|
text?: undefined;
|
|
59
79
|
})[];
|
|
@@ -88,6 +88,45 @@ function formatSectionLines(items, domainLabel) {
|
|
|
88
88
|
return `- ${tags ? `${tags} ` : ''}${line.text}${refs}`;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
+
function formatCardLines(items, domainLabel) {
|
|
92
|
+
return items.map((line) => {
|
|
93
|
+
const tags = [
|
|
94
|
+
line.domain ? domainLabel(line.domain) : '',
|
|
95
|
+
line.selfDescribed ? '自述' : '',
|
|
96
|
+
line.reason && !line.selfDescribed ? line.reason : '',
|
|
97
|
+
].filter(Boolean).join(' · ');
|
|
98
|
+
const refs = line.evidence.length ? `证据 ${line.evidence.length} 条` : '';
|
|
99
|
+
const note = [tags, refs].filter(Boolean).join(' · ');
|
|
100
|
+
return `- ${line.text}${note ? `(${note})` : ''}`;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/** The page card body: measured stats, then 擅长 and 注意 with evidence counts instead of IDs. */
|
|
104
|
+
export function renderProfileCard(record, domainLabel) {
|
|
105
|
+
const parts = [];
|
|
106
|
+
const measuredLines = formatMeasuredLines(record.measured, record.kind);
|
|
107
|
+
if (measuredLines.length)
|
|
108
|
+
parts.push(measuredLines.join('\n'));
|
|
109
|
+
if (record.lines.strengths.length)
|
|
110
|
+
parts.push(`**擅长**\n${formatCardLines(record.lines.strengths, domainLabel).join('\n')}`);
|
|
111
|
+
if (record.lines.cautions.length)
|
|
112
|
+
parts.push(`**注意**\n${formatCardLines(record.lines.cautions, domainLabel).join('\n')}`);
|
|
113
|
+
if (!record.lines.strengths.length && !record.lines.cautions.length)
|
|
114
|
+
parts.push('_暂无经跨系列确认的结论_');
|
|
115
|
+
return parts.join('\n\n');
|
|
116
|
+
}
|
|
117
|
+
/** 待复核 lines for the row's own expand area, one Markdown line each. */
|
|
118
|
+
export function renderProfilePending(record, domainLabel) {
|
|
119
|
+
return formatCardLines(record.lines.review, domainLabel).map((text) => ({ text: text.replace(/^- /, '') }));
|
|
120
|
+
}
|
|
121
|
+
/** Row title: the key, family and how many 待复核 lines the row folds away. */
|
|
122
|
+
export function renderProfileCaption(record) {
|
|
123
|
+
return [
|
|
124
|
+
record.key,
|
|
125
|
+
record.families?.length ? record.families.join(' + ') : record.pendingFamilies ? `系列待确认(${record.pendingFamilies.families.join(' + ')})` : '',
|
|
126
|
+
`v${record.version}`,
|
|
127
|
+
record.lines.review.length ? `待复核 ${record.lines.review.length} 条` : '',
|
|
128
|
+
].filter(Boolean).join(' · ');
|
|
129
|
+
}
|
|
91
130
|
export function renderProfileDetail(record, domainLabel, bootstrapped = true) {
|
|
92
131
|
const parts = [];
|
|
93
132
|
const header = [
|
|
@@ -166,18 +205,17 @@ export const DEFAULT_VIEW_JSON = {
|
|
|
166
205
|
text: '还没有模型画像。随着回合与跨系列观察积累,画像会自动生成。',
|
|
167
206
|
},
|
|
168
207
|
{
|
|
169
|
-
type: '
|
|
208
|
+
type: 'list',
|
|
209
|
+
id: 'modelsRows',
|
|
170
210
|
from: '$.data.profiles.models',
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
},
|
|
180
|
-
],
|
|
211
|
+
expand: 'many',
|
|
212
|
+
row: {
|
|
213
|
+
layout: 'two',
|
|
214
|
+
key: '@key',
|
|
215
|
+
title: '@caption',
|
|
216
|
+
more: [{ type: 'markdown', text: '@card' }],
|
|
217
|
+
expand: [{ type: 'each', from: '@pending', itemKey: '@text', blocks: [{ type: 'markdown', text: '@text' }] }],
|
|
218
|
+
},
|
|
181
219
|
},
|
|
182
220
|
],
|
|
183
221
|
},
|
|
@@ -192,18 +230,17 @@ export const DEFAULT_VIEW_JSON = {
|
|
|
192
230
|
text: '还没有客户端画像。',
|
|
193
231
|
},
|
|
194
232
|
{
|
|
195
|
-
type: '
|
|
233
|
+
type: 'list',
|
|
234
|
+
id: 'clientsRows',
|
|
196
235
|
from: '$.data.profiles.clients',
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
},
|
|
206
|
-
],
|
|
236
|
+
expand: 'many',
|
|
237
|
+
row: {
|
|
238
|
+
layout: 'two',
|
|
239
|
+
key: '@key',
|
|
240
|
+
title: '@caption',
|
|
241
|
+
more: [{ type: 'markdown', text: '@card' }],
|
|
242
|
+
expand: [{ type: 'each', from: '@pending', itemKey: '@text', blocks: [{ type: 'markdown', text: '@text' }] }],
|
|
243
|
+
},
|
|
207
244
|
},
|
|
208
245
|
],
|
|
209
246
|
},
|
|
@@ -116,8 +116,16 @@ export interface ProfileRecord {
|
|
|
116
116
|
meta: string;
|
|
117
117
|
/** One-line summary shown on the list row in view.json. */
|
|
118
118
|
summary: string;
|
|
119
|
-
/** Full Markdown
|
|
119
|
+
/** Full Markdown with evidence IDs, returned to members by profiles.get. */
|
|
120
120
|
detail: string;
|
|
121
|
+
/** Row title on the topic page: key, family, version and how many 待复核 lines are folded. */
|
|
122
|
+
caption: string;
|
|
123
|
+
/** Row body on the topic page: measured stats, 擅长 and 注意 with evidence counts. */
|
|
124
|
+
card: string;
|
|
125
|
+
/** 待复核 lines shown when the row is expanded. */
|
|
126
|
+
pending: {
|
|
127
|
+
text: string;
|
|
128
|
+
}[];
|
|
121
129
|
}
|
|
122
130
|
export interface ProfilesBook {
|
|
123
131
|
schemaVersion: 1;
|
|
@@ -351,14 +351,17 @@ export function toolsPlugin(home) {
|
|
|
351
351
|
input: object({
|
|
352
352
|
content: { type: 'string' },
|
|
353
353
|
replyTo: { type: 'string', description: '要回复的消息编号(当前主题里的 msg_…)。省略时在主线平级发新话题' },
|
|
354
|
-
targets: { type: 'array', items: { type: 'string' }, description: '收件人的成员 ID
|
|
354
|
+
targets: { type: 'array', items: { type: 'string' }, description: '收件人的成员 ID 或句柄,句柄可带 @。填空数组时只发知会,省略时按正文行首 @ 投递。显式指定但无人可接收时会报错。' },
|
|
355
355
|
}, ['content']),
|
|
356
356
|
run({ content, replyTo, targets }, { topicId: here, member }) {
|
|
357
357
|
const byHandle = targets?.length
|
|
358
|
-
? new Map([...members.list(), ...members.people()].map(({ id, handle }) => [
|
|
358
|
+
? new Map([...members.list(), ...members.people()].map(({ id, handle }) => [handle.toLowerCase(), id]))
|
|
359
359
|
: undefined;
|
|
360
|
-
const sent = a2a.send({
|
|
361
|
-
|
|
360
|
+
const sent = a2a.send({
|
|
361
|
+
topicId: here, from: { kind: 'member', id: member.id }, content, replyTo,
|
|
362
|
+
targets: targets?.map((target) => members.get(target)?.id ?? byHandle?.get(target.replace(/^@/, '').toLowerCase()) ?? target),
|
|
363
|
+
requireRecipient: Boolean(targets?.length),
|
|
364
|
+
});
|
|
362
365
|
const { id, thread, read } = sent.message;
|
|
363
366
|
if (!thread)
|
|
364
367
|
return `已在主线平级发出(${id})${calls(sent)}。不影响本轮原楼回复。`;
|
|
@@ -67,15 +67,26 @@ const APPLE_PICK_FOLDER = [
|
|
|
67
67
|
' end try',
|
|
68
68
|
'end run',
|
|
69
69
|
].join('\n');
|
|
70
|
-
|
|
70
|
+
// Hidden powershell.exe has no visible window, so an unowned dialog opens behind the browser and appears hung.
|
|
71
|
+
// An unshown TopMost Form keeps ownership in-process without compiling C# or disabling another process's window.
|
|
72
|
+
const windowsPicker = (dialogClass, configure, onOk) => [
|
|
71
73
|
"$ErrorActionPreference = 'Stop'",
|
|
72
74
|
'[Console]::OutputEncoding = [Text.UTF8Encoding]::new($false)',
|
|
73
75
|
'Add-Type -AssemblyName System.Windows.Forms',
|
|
74
|
-
'$
|
|
76
|
+
'$owner = New-Object System.Windows.Forms.Form -Property @{ TopMost = $true }',
|
|
77
|
+
`$dialog = New-Object System.Windows.Forms.${dialogClass}`,
|
|
78
|
+
'try {',
|
|
79
|
+
...configure.map((line) => ` ${line}`),
|
|
80
|
+
` if ($dialog.ShowDialog($owner) -eq [System.Windows.Forms.DialogResult]::OK) { ${onOk} }`,
|
|
81
|
+
'} finally {',
|
|
82
|
+
' $dialog.Dispose()',
|
|
83
|
+
' $owner.Dispose()',
|
|
84
|
+
'}',
|
|
85
|
+
].join('\n');
|
|
86
|
+
const WINDOWS_PICK_FOLDER = windowsPicker('FolderBrowserDialog', [
|
|
75
87
|
'if ($env:HOSTLET_PICK_TITLE) { $dialog.Description = $env:HOSTLET_PICK_TITLE }',
|
|
76
88
|
'if ($env:HOSTLET_PICK_INITIAL -and (Test-Path -LiteralPath $env:HOSTLET_PICK_INITIAL -PathType Container)) { $dialog.SelectedPath = $env:HOSTLET_PICK_INITIAL }',
|
|
77
|
-
|
|
78
|
-
].join('\n');
|
|
89
|
+
], '[Console]::Write($dialog.SelectedPath)');
|
|
79
90
|
const APPLE_PICK_FILES = `
|
|
80
91
|
function run(argv) {
|
|
81
92
|
const app = Application.currentApplication();
|
|
@@ -91,16 +102,11 @@ function run(argv) {
|
|
|
91
102
|
throw error;
|
|
92
103
|
}
|
|
93
104
|
}`;
|
|
94
|
-
const WINDOWS_PICK_FILES = [
|
|
95
|
-
"$ErrorActionPreference = 'Stop'",
|
|
96
|
-
'[Console]::OutputEncoding = [Text.UTF8Encoding]::new($false)',
|
|
97
|
-
'Add-Type -AssemblyName System.Windows.Forms',
|
|
98
|
-
'$dialog = New-Object System.Windows.Forms.OpenFileDialog',
|
|
105
|
+
const WINDOWS_PICK_FILES = windowsPicker('OpenFileDialog', [
|
|
99
106
|
'$dialog.Title = $env:HOSTLET_PICK_TITLE',
|
|
100
107
|
"$dialog.Multiselect = $env:HOSTLET_PICK_MULTIPLE -eq 'true'",
|
|
101
108
|
'if ($env:HOSTLET_PICK_FILTER) { $dialog.Filter = $env:HOSTLET_PICK_FILTER }',
|
|
102
|
-
|
|
103
|
-
].join('\n');
|
|
109
|
+
], 'ConvertTo-Json -Compress -InputObject @($dialog.FileNames)');
|
|
104
110
|
const ps = (command, sta = false) => ['-NoLogo', '-NoProfile', '-NonInteractive', ...(sta ? ['-STA'] : []), '-Command', command];
|
|
105
111
|
function run(command, args, options = {}) {
|
|
106
112
|
return new Promise((resolve, reject) => {
|
package/package.json
CHANGED