qlogicagent 2.13.7 → 2.13.8
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/cli.js +329 -329
- package/dist/index.js +326 -326
- package/dist/types/cli/tool-bootstrap-community-registration.d.ts +9 -0
- package/dist/types/orchestration/workflow/params-schema.d.ts +77 -0
- package/dist/types/orchestration/workflow/run-history-store.d.ts +7 -1
- package/dist/types/orchestration/workflow/workflow-error.d.ts +28 -0
- package/dist/types/orchestration/workflow-chat-builder.d.ts +10 -0
- package/dist/types/runtime/community/activity-event-emitter.d.ts +24 -0
- package/dist/types/runtime/community/activity-event.d.ts +60 -0
- package/dist/types/runtime/community/autonomy-budget.d.ts +26 -0
- package/dist/types/runtime/community/community-consent-client.d.ts +47 -0
- package/dist/types/runtime/community/pet-key.d.ts +7 -0
- package/dist/types/runtime/community/roaming-gate.d.ts +19 -0
- package/dist/types/runtime/community/social-emission.d.ts +16 -0
- package/dist/types/skills/tools/community-seek-tool.d.ts +73 -0
- package/package.json +110 -110
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PortableTool } from "../skills/portable-tool.js";
|
|
2
|
+
import { type CommunityDiscoveryResult } from "../runtime/community/community-discovery-coordinator.js";
|
|
3
|
+
export interface LocalCommunityToolRegistrationContext {
|
|
4
|
+
tools: PortableTool<any>[];
|
|
5
|
+
/** 测试可注入的发现实现;默认从 env consent client 构造协调器。 */
|
|
6
|
+
discover?: (intent: string) => Promise<CommunityDiscoveryResult>;
|
|
7
|
+
}
|
|
8
|
+
export declare const localCommunityToolRegistrationModule: import("../runtime/ports/tool-contracts.js").ToolRegistrationModule<LocalCommunityToolRegistrationContext>;
|
|
9
|
+
export declare function registerLocalCommunityTools(context: LocalCommunityToolRegistrationContext): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node params schema — single source for "what params does each node kind take" (spec R6 / D45).
|
|
3
|
+
*
|
|
4
|
+
* Two schema sources, one resolver:
|
|
5
|
+
* - tool / mcp → per-capability `paramsSchema` on the CapabilityEntry (the tool's own arg schema,
|
|
6
|
+
* validates node.params.args).
|
|
7
|
+
* - everything else (http/agent/channel/memory/if/filter/switch/transform/wait/...) → a per-KIND
|
|
8
|
+
* schema here (KIND_PARAM_SCHEMAS), validates node.params directly.
|
|
9
|
+
*
|
|
10
|
+
* The schemas are a JSON-Schema subset aligned with the canvas SchemaArgsForm consumer
|
|
11
|
+
* (type/enum/default/minimum/maximum/multipleOf/format/x-widget). `required` mirrors what the REAL
|
|
12
|
+
* executors throw on (host-executors.ts / builtin-executors.ts) — not a wishlist.
|
|
13
|
+
*
|
|
14
|
+
* fail-loud posture: `validateParamsAgainstSchema` flags missing-required / wrong-enum / wrong-type
|
|
15
|
+
* so the AI generation gate (AI-2) can reject and self-correct. Two deliberate exemptions:
|
|
16
|
+
* - a value that is a `{{ }}` template is skipped for type checks (resolved at runtime).
|
|
17
|
+
* - an `__ASK__: 问题` sentinel (brace-less ON PURPOSE so it bypasses the {{ }} expression gate in
|
|
18
|
+
* validateDefExpressions) counts as "present but pending" (the agent honestly marking an unknown,
|
|
19
|
+
* not a hallucination) — surfaced by collectClarifications for the 待补 badge + activation gate.
|
|
20
|
+
*/
|
|
21
|
+
import type { CapabilityEntry } from "./capability-catalog.js";
|
|
22
|
+
/** Per-kind params schemas for non tool/mcp kinds. `trigger` (workflow-level trigger def) and
|
|
23
|
+
* `manual` (n8n import placeholder that always fails) are intentionally excluded. */
|
|
24
|
+
export declare const KIND_PARAM_SCHEMAS: Record<string, Record<string, unknown>>;
|
|
25
|
+
/** An `__ASK__: 问题` sentinel — the agent honestly marking an unknown required value (AI-2).
|
|
26
|
+
* Brace-less by design so it doesn't enter the {{ }} restricted-expression gate. */
|
|
27
|
+
export declare function isAskPlaceholder(v: unknown): boolean;
|
|
28
|
+
type NodeLike = {
|
|
29
|
+
id: string;
|
|
30
|
+
kind: string;
|
|
31
|
+
params?: Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The schema that governs a node's params:
|
|
35
|
+
* - tool → the tool capability's paramsSchema (governs params.args).
|
|
36
|
+
* - mcp → the "server.tool" capability's paramsSchema (governs params.args).
|
|
37
|
+
* - else → KIND_PARAM_SCHEMAS[kind] (governs params directly).
|
|
38
|
+
* Returns undefined when no schema is known (e.g. a tool ref outside the catalog).
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveNodeParamsSchema(node: NodeLike, entries: CapabilityEntry[]): Record<string, unknown> | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Validate every node's params against its resolved schema. Returns human-readable Chinese errors
|
|
43
|
+
* (empty = clean). Skips `trigger` (trigger def is validated elsewhere) and `manual` (placeholder).
|
|
44
|
+
* Unknown kinds with no schema are skipped here (validateCapabilityRefs / validateGraph cover refs).
|
|
45
|
+
*/
|
|
46
|
+
export declare function validateParamsAgainstSchema(def: {
|
|
47
|
+
nodes: NodeLike[];
|
|
48
|
+
}, entries: CapabilityEntry[]): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Collect every `{{ __ASK__ }}` placeholder in a def (top-level params + one level into `args`).
|
|
51
|
+
* Drives the canvas "待补" badge and the activation gate (a workflow with pending asks cannot be
|
|
52
|
+
* activated). Empty = nothing pending.
|
|
53
|
+
*/
|
|
54
|
+
export declare function collectAskPlaceholders(def: {
|
|
55
|
+
nodes: NodeLike[];
|
|
56
|
+
}): {
|
|
57
|
+
nodeId: string;
|
|
58
|
+
field: string;
|
|
59
|
+
}[];
|
|
60
|
+
/**
|
|
61
|
+
* Like collectAskPlaceholders but carries the question text — drives the workflow.chat `clarify`
|
|
62
|
+
* bubble (AI-2). Empty = nothing to ask.
|
|
63
|
+
*/
|
|
64
|
+
export declare function collectClarifications(def: {
|
|
65
|
+
nodes: NodeLike[];
|
|
66
|
+
}): {
|
|
67
|
+
nodeId: string;
|
|
68
|
+
field: string;
|
|
69
|
+
question: string;
|
|
70
|
+
}[];
|
|
71
|
+
/**
|
|
72
|
+
* Compact per-kind params hint for the AI graph-builder prompt, derived from KIND_PARAM_SCHEMAS
|
|
73
|
+
* (single source — the prompt never hand-duplicates param names). tool/mcp carry per-capability
|
|
74
|
+
* arg schemas (the agent reads them via list_capabilities), so they get a pointer not a field list.
|
|
75
|
+
*/
|
|
76
|
+
export declare function renderKindParamsForPrompt(): string;
|
|
77
|
+
export {};
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* must never block a run).
|
|
20
20
|
*/
|
|
21
21
|
import type { RunResult } from "./workflow-runtime.js";
|
|
22
|
+
import { type WorkflowError } from "./workflow-error.js";
|
|
22
23
|
export declare const MAX_RUN_HISTORY = 20;
|
|
23
24
|
export type RunHistoryStatus = "running" | "completed" | "failed" | "paused" | "skipped" | "canceled";
|
|
24
25
|
export interface RunNodeRecord {
|
|
@@ -42,6 +43,11 @@ export interface RunHistoryEntry {
|
|
|
42
43
|
finishedAt?: string;
|
|
43
44
|
durationMs?: number;
|
|
44
45
|
error?: string;
|
|
46
|
+
/** AI-5 (D49): classified, human-readable form of `error` (人话 + class + 0-死端 next-step actions). */
|
|
47
|
+
errorInfo?: WorkflowError;
|
|
48
|
+
/** AI-5: node that caused a "failed" run — precise canvas attribution. Hard-stop failures reject
|
|
49
|
+
* without node records, so the runtime tags the failing node onto the thrown error. */
|
|
50
|
+
failedNodeId?: string;
|
|
45
51
|
/** nodeId → output record. Present once the run settles (not while running). */
|
|
46
52
|
nodes?: Record<string, RunNodeRecord>;
|
|
47
53
|
}
|
|
@@ -55,7 +61,7 @@ export declare class WorkflowRunHistoryStore {
|
|
|
55
61
|
/** Record a run start. Prepends a "running" entry and prunes to the bound. */
|
|
56
62
|
begin(workflowId: string, entry: Pick<RunHistoryEntry, "runId" | "triggerType" | "startedAt">): Promise<void>;
|
|
57
63
|
/** Settle a run entry (status/outputs/error). Unknown runId is a no-op (pruned entry). */
|
|
58
|
-
finish(workflowId: string, runId: string, patch: Partial<Pick<RunHistoryEntry, "status" | "finishedAt" | "durationMs" | "error" | "nodes">>): Promise<void>;
|
|
64
|
+
finish(workflowId: string, runId: string, patch: Partial<Pick<RunHistoryEntry, "status" | "finishedAt" | "durationMs" | "error" | "failedNodeId" | "nodes">>): Promise<void>;
|
|
59
65
|
/** Most-recent-first run summaries (no node outputs — those stay behind get()). */
|
|
60
66
|
list(workflowId: string): Promise<RunHistorySummary[]>;
|
|
61
67
|
/** Full entry incl. per-node output previews. */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow run-error classification (spec R6 / D49 / AI-5).
|
|
3
|
+
*
|
|
4
|
+
* Turns a raw thrown Error message into a human-readable, classified WorkflowError so the canvas can
|
|
5
|
+
* show 人话 (never a stack) + the right next-step buttons (0 死端). Pure & deterministic — unit
|
|
6
|
+
* tested. The executors throw plain Error(message); this maps those messages to a class + 中文说明.
|
|
7
|
+
*/
|
|
8
|
+
export type WorkflowErrorClass = "user" | "capability" | "network" | "system";
|
|
9
|
+
/** Next-step buttons the canvas offers for an error (0 死端 — every failure has a way forward). */
|
|
10
|
+
export type WorkflowErrorAction = "ai_fix" | "rerun_node" | "rerun_all" | "open_credentials" | "swap_capability";
|
|
11
|
+
export interface WorkflowError {
|
|
12
|
+
class: WorkflowErrorClass;
|
|
13
|
+
/** Plain-language Chinese explanation (NO stack trace). */
|
|
14
|
+
message: string;
|
|
15
|
+
/** What to do about it, in one line. */
|
|
16
|
+
hint?: string;
|
|
17
|
+
/** Ordered next-step actions for the UI (first = primary). */
|
|
18
|
+
actions: WorkflowErrorAction[];
|
|
19
|
+
/** Truncated raw message, for the advanced/debug view only. */
|
|
20
|
+
detail?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Classify a node failure. `raw` is the thrown error's message; `opts.nodeKind` refines wording.
|
|
24
|
+
* Order matters: credential/auth and capability checks run before the generic "param" check.
|
|
25
|
+
*/
|
|
26
|
+
export declare function classifyWorkflowError(raw: string, opts?: {
|
|
27
|
+
nodeKind?: string;
|
|
28
|
+
}): WorkflowError;
|
|
@@ -50,6 +50,16 @@ export interface WorkflowChatResult {
|
|
|
50
50
|
attempts: number;
|
|
51
51
|
errors: string[];
|
|
52
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* AI-2: per-field {{ __ASK__ }} placeholders the agent left for genuinely-unknown REQUIRED values.
|
|
55
|
+
* The def IS applied (so the user sees the shape) but these nodes show a 待补 badge and the
|
|
56
|
+
* workflow cannot be activated until resolved. Absent/empty = nothing pending.
|
|
57
|
+
*/
|
|
58
|
+
clarify?: {
|
|
59
|
+
nodeId: string;
|
|
60
|
+
field: string;
|
|
61
|
+
question: string;
|
|
62
|
+
}[];
|
|
53
63
|
}
|
|
54
64
|
/** agent 按需检索能力长尾(系统提示只放每类前 N 条)。 */
|
|
55
65
|
export declare const LIST_CAPABILITIES_TOOL_NAME = "list_capabilities";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ActivityEvent, type CreateActivityEventInput } from "./activity-event.js";
|
|
2
|
+
import { type CommunityConsentClient } from "./community-consent-client.js";
|
|
3
|
+
export type ActivityEmitStatus = "emitted" | "disabled" | "consent-blocked" | "failed";
|
|
4
|
+
/** 活动事件出口:真实实现把事件写入 community-service(社交通道,非权威)。 */
|
|
5
|
+
export interface ActivityEventTransport {
|
|
6
|
+
emit(event: ActivityEvent): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export interface ActivityEventEmitterDeps {
|
|
9
|
+
/** 无 transport(未配置 / dev)→ "disabled"。 */
|
|
10
|
+
transport: ActivityEventTransport | null;
|
|
11
|
+
/** consent 源;community 事件必须能验 consent,否则 fail-safe 拦下。 */
|
|
12
|
+
consent: Pick<CommunityConsentClient, "getConsent"> | null;
|
|
13
|
+
}
|
|
14
|
+
export interface ActivityEventEmitter {
|
|
15
|
+
emit(input: CreateActivityEventInput): Promise<ActivityEmitStatus>;
|
|
16
|
+
}
|
|
17
|
+
export declare function createActivityEventEmitter(deps: ActivityEventEmitterDeps): ActivityEventEmitter;
|
|
18
|
+
/** 把 community-service 的 emitActivity 包成 transport(社交写只走此通道,零触碰权威)。 */
|
|
19
|
+
export declare function createHubActivityTransport(client: Pick<CommunityConsentClient, "emitActivity">): ActivityEventTransport;
|
|
20
|
+
/**
|
|
21
|
+
* 默认发射器:从 env consent client 构造 transport + consent。
|
|
22
|
+
* 无 token(dev)→ client null → transport null(emit 返回 "disabled",fail-safe)。
|
|
23
|
+
*/
|
|
24
|
+
export declare function createDefaultActivityEventEmitter(): ActivityEventEmitter;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type TrustSignalEventType = "installed" | "success" | "fail" | "error" | "kept" | "uninstalled" | "endorse";
|
|
2
|
+
export type ExperientialEventType = "acquire" | "ask" | "answer" | "encounter" | "review";
|
|
3
|
+
export type FlauntEventType = "unlock" | "flaunt";
|
|
4
|
+
export type ActivityEventType = TrustSignalEventType | ExperientialEventType | FlauntEventType;
|
|
5
|
+
/**
|
|
6
|
+
* 空间锚点:agent 发射时本就持有 resourceId 与其 category,事件自带锚点让集市
|
|
7
|
+
* 端零反查地把微动画钉到正确街区 / 店铺。**只允许 districtId / shopId。**
|
|
8
|
+
*/
|
|
9
|
+
export interface ActivitySpatialAnchor {
|
|
10
|
+
/** RESOURCE_CATEGORIES 的 category key(23 类稳定 key)。 */
|
|
11
|
+
districtId?: string;
|
|
12
|
+
/** canonical resourceId(店铺稳定主键)。 */
|
|
13
|
+
shopId?: string;
|
|
14
|
+
}
|
|
15
|
+
/** 禁止出现在 anchor 上的权威坐标键(DR12 红线,防后人误加诱导 v2 位置漂移)。 */
|
|
16
|
+
export declare const FORBIDDEN_ANCHOR_KEYS: readonly string[];
|
|
17
|
+
export interface ActivityPayload {
|
|
18
|
+
/** 空间归属锚点(可选);禁权威坐标。 */
|
|
19
|
+
anchor?: ActivitySpatialAnchor;
|
|
20
|
+
[k: string]: unknown;
|
|
21
|
+
}
|
|
22
|
+
export type ActivityVisibility = "owner" | "community";
|
|
23
|
+
export interface ActivityEvent {
|
|
24
|
+
/** 幂等键。 */
|
|
25
|
+
id: string;
|
|
26
|
+
type: ActivityEventType;
|
|
27
|
+
/** 逐事件时间戳(epoch ms)。 */
|
|
28
|
+
ts: number;
|
|
29
|
+
/** 行动者 = 本人宠物人格(community-service 持有)。 */
|
|
30
|
+
actorPetId: string;
|
|
31
|
+
/** 对端 actorPetId(社交事件;离场降级"最近一次在场",不承诺在线;OFF 时缺省)。 */
|
|
32
|
+
peerRef?: string;
|
|
33
|
+
/** 已过脱敏边界(DR3);anchor 禁权威坐标。 */
|
|
34
|
+
payload: ActivityPayload;
|
|
35
|
+
/** owner=只进自己偷窥窗;community=游历 ON 才有(默认 owner,fail-safe)。 */
|
|
36
|
+
visibility: ActivityVisibility;
|
|
37
|
+
}
|
|
38
|
+
export declare function isTrustSignalEvent(type: ActivityEventType): type is TrustSignalEventType;
|
|
39
|
+
export declare function isExperientialEvent(type: ActivityEventType): type is ExperientialEventType;
|
|
40
|
+
export declare function isFlauntEvent(type: ActivityEventType): type is FlauntEventType;
|
|
41
|
+
export declare function isActivityEventType(value: unknown): value is ActivityEventType;
|
|
42
|
+
export interface CreateActivityEventInput {
|
|
43
|
+
id: string;
|
|
44
|
+
type: ActivityEventType;
|
|
45
|
+
ts: number;
|
|
46
|
+
actorPetId: string;
|
|
47
|
+
peerRef?: string;
|
|
48
|
+
payload?: ActivityPayload;
|
|
49
|
+
/** 默认 "owner"(fail-safe:跨租户可见须显式 + 上游 consent/roaming 闸放行)。 */
|
|
50
|
+
visibility?: ActivityVisibility;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 校验 anchor:只保留 districtId / shopId;若出现任何权威坐标键 → 抛错(DR12 红线,
|
|
54
|
+
* 纵深防御:契约层就拦,不靠调用方自觉)。
|
|
55
|
+
*/
|
|
56
|
+
export declare function sanitizeAnchor(anchor: ActivitySpatialAnchor | undefined): ActivitySpatialAnchor | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* 构造一个经校验的 ActivityEvent。校验必填字段、规范化 anchor、默认 visibility=owner。
|
|
59
|
+
*/
|
|
60
|
+
export declare function createActivityEvent(input: CreateActivityEventInput): ActivityEvent;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type AcquisitionRiskTier = "R0" | "R1" | "R2" | "R3";
|
|
2
|
+
export type AcquisitionSourceTier = "official" | "community";
|
|
3
|
+
export type AcquisitionMode = "silent" | "ask" | "high-risk-ask";
|
|
4
|
+
export interface AutonomyBudgetConfig {
|
|
5
|
+
/** 自治预算总开关。默认 ON(DR6);OFF → 一律问人。 */
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** 默认配置:开箱即默认开(DR6 安装自治默认 ON;仅管本地取 R0/低风险 inert)。 */
|
|
9
|
+
export declare const DEFAULT_AUTONOMY_BUDGET: AutonomyBudgetConfig;
|
|
10
|
+
export interface AcquisitionContext {
|
|
11
|
+
effectiveRiskTier: AcquisitionRiskTier;
|
|
12
|
+
sourceTier: AcquisitionSourceTier;
|
|
13
|
+
}
|
|
14
|
+
export interface AcquisitionDecision {
|
|
15
|
+
mode: AcquisitionMode;
|
|
16
|
+
/** 是否需要 explicitInstallConsent(R>0 的普通问人)。 */
|
|
17
|
+
requiresInstallConsent: boolean;
|
|
18
|
+
/** 是否需要 explicitHighRiskConsent(R2/R3)。 */
|
|
19
|
+
requiresHighRiskConsent: boolean;
|
|
20
|
+
reason: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 决定一次资源获取走静默 / 问人 / 高危问人。纯函数,无副作用。
|
|
24
|
+
* 高危(R2/R3)优先级最高:无论预算开关,都必须高危问人(可执行高危永不自动)。
|
|
25
|
+
*/
|
|
26
|
+
export declare function decideAcquisition(ctx: AcquisitionContext, config?: AutonomyBudgetConfig): AcquisitionDecision;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ConfigPort } from "../ports/index.js";
|
|
2
|
+
import type { ActivityEvent } from "./activity-event.js";
|
|
2
3
|
import type { CommunityTelemetryEvent } from "./community-telemetry-types.js";
|
|
3
4
|
export interface CommunityConsentView {
|
|
4
5
|
enabled: boolean;
|
|
@@ -37,6 +38,16 @@ export interface CommunityConsentClient {
|
|
|
37
38
|
listComments?(resourceId: string): Promise<CommunityComment[]>;
|
|
38
39
|
/** Post a community comment (WS-B4); new accounts are folded by the Hub. Optional for mocks. */
|
|
39
40
|
postComment?(resourceId: string, body: string): Promise<CommunityCommentPosted>;
|
|
41
|
+
/** Cut2: emit one ActivityEvent to community-service (social channel, non-authoritative). Optional for mocks. */
|
|
42
|
+
emitActivity?(event: ActivityEvent): Promise<void>;
|
|
43
|
+
/** Cut4: author an agent review for a resource (social channel). Optional for mocks. */
|
|
44
|
+
recordCommunityReview?(input: CommunityReviewInput): Promise<void>;
|
|
45
|
+
/** Cut4: post a help request to the community (social channel). Optional for mocks. */
|
|
46
|
+
recordCommunityAsk?(input: CommunityAskInput): Promise<void>;
|
|
47
|
+
/** Cut4: answer a peer's help request (social channel). Optional for mocks. */
|
|
48
|
+
recordCommunityAnswer?(input: CommunityAnswerInput): Promise<void>;
|
|
49
|
+
/** Cut5: record a pet-to-pet interaction (gated by roaming/gateSocialEvent first). Optional for mocks. */
|
|
50
|
+
recordCommunityInteraction?(input: CommunityInteractionInput): Promise<void>;
|
|
40
51
|
/** Resolve a vetted runtime binary (e.g. officecli) for this platform → Hub-signed download. */
|
|
41
52
|
resolveRuntime(id: string, platform: string): Promise<CommunityRuntimeResolution>;
|
|
42
53
|
listSharedResources(): Promise<CommunitySharedResource[]>;
|
|
@@ -112,6 +123,42 @@ export interface CommunityRecordSignalInput {
|
|
|
112
123
|
export interface CommunityRecordSignalResult {
|
|
113
124
|
accepted: true;
|
|
114
125
|
}
|
|
126
|
+
/** Cut4:agent 撰写的评价(经历 + 结果 + 场景)。experience 须已过 soul.ts 脱敏(R24)。 */
|
|
127
|
+
export interface CommunityReviewInput {
|
|
128
|
+
id: string;
|
|
129
|
+
resourceId: string;
|
|
130
|
+
/** 不可逆 petKey(derivePetKey)。 */
|
|
131
|
+
actorPetId: string;
|
|
132
|
+
experience: string;
|
|
133
|
+
outcome: "success" | "fail" | "neutral";
|
|
134
|
+
contextCategory?: string;
|
|
135
|
+
ts: number;
|
|
136
|
+
}
|
|
137
|
+
/** Cut4 求助频道:agent 发求助帖。question 须已脱敏(R24)。 */
|
|
138
|
+
export interface CommunityAskInput {
|
|
139
|
+
id: string;
|
|
140
|
+
askerPetId: string;
|
|
141
|
+
question: string;
|
|
142
|
+
contextCategory?: string;
|
|
143
|
+
ts: number;
|
|
144
|
+
}
|
|
145
|
+
/** Cut4 求助频道:对端 agent 应答。answer 须已脱敏(R24)。 */
|
|
146
|
+
export interface CommunityAnswerInput {
|
|
147
|
+
id: string;
|
|
148
|
+
askId: string;
|
|
149
|
+
answererPetId: string;
|
|
150
|
+
answer: string;
|
|
151
|
+
ts: number;
|
|
152
|
+
}
|
|
153
|
+
/** Cut5 宠物互动:greet/share/mention。须已过 gateSocialEvent 游历门控放行。 */
|
|
154
|
+
export interface CommunityInteractionInput {
|
|
155
|
+
id: string;
|
|
156
|
+
kind: "greet" | "share" | "mention";
|
|
157
|
+
actorPetId: string;
|
|
158
|
+
peerPetId: string;
|
|
159
|
+
payload?: Record<string, unknown>;
|
|
160
|
+
ts: number;
|
|
161
|
+
}
|
|
115
162
|
export interface CommunityRecordTelemetryInput {
|
|
116
163
|
event: CommunityTelemetryEvent;
|
|
117
164
|
metadata?: Record<string, unknown>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 由 (ownerUserId, deviceId) 派生不可逆 petKey。sha256 截断;owner/device 原文绝不出现在结果里。
|
|
3
|
+
* 用 NUL(charCode 0)分隔,避免 ("a b","c") 与 ("a","b c") 撞键(owner/device 不含 NUL)。
|
|
4
|
+
*/
|
|
5
|
+
export declare function derivePetKey(ownerUserId: string, deviceId: string): string;
|
|
6
|
+
/** 是否是合法 petKey 形状(pk_ + 24 位 hex)。 */
|
|
7
|
+
export declare function isPetKey(value: unknown): value is string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type CarryOutLevel = "capability-meta" | "sanitized-story";
|
|
2
|
+
export type CarryOutVisibility = "owner" | "community";
|
|
3
|
+
export interface RoamingContext {
|
|
4
|
+
/** 设置-宠物「外出游历」总闸(DR2,默认 OFF / 首启知情 opt-in)。 */
|
|
5
|
+
roamingEnabled: boolean;
|
|
6
|
+
/** 本次带出物是否含高敏感内容(由调用方的敏感度判定给出)。 */
|
|
7
|
+
highSensitivity: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CarryOutDecision {
|
|
10
|
+
level: CarryOutLevel;
|
|
11
|
+
visibility: CarryOutVisibility;
|
|
12
|
+
/** 高敏感 → 自动升级问人一次(DR3),不静默外发。 */
|
|
13
|
+
escalateToAsk: boolean;
|
|
14
|
+
reason: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 决定带出级别 / 可见性 / 是否升级。纯函数,无副作用。优先级:高敏感 > 游历闸。
|
|
18
|
+
*/
|
|
19
|
+
export declare function decideCarryOut(ctx: RoamingContext): CarryOutDecision;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RoamingContext } from "./roaming-gate.js";
|
|
2
|
+
import type { CarryOutLevel } from "./roaming-gate.js";
|
|
3
|
+
import type { CreateActivityEventInput } from "./activity-event.js";
|
|
4
|
+
export type SocialEmissionAction = "emit-community" | "owner-only" | "escalate";
|
|
5
|
+
export interface GatedSocialEvent {
|
|
6
|
+
action: SocialEmissionAction;
|
|
7
|
+
/** 已按 DR2/DR3 设好 visibility 的事件(escalate / owner-only 时 visibility=owner)。 */
|
|
8
|
+
event: CreateActivityEventInput;
|
|
9
|
+
carryOutLevel: CarryOutLevel;
|
|
10
|
+
reason: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 过游历闸决定一条社交事件的最终归宿。纯函数,不发射。
|
|
14
|
+
* 调用方:escalate → 升级问用户;emit-community / owner-only → 交 emitter.emit(gated.event)。
|
|
15
|
+
*/
|
|
16
|
+
export declare function gateSocialEvent(base: CreateActivityEventInput, ctx: RoamingContext): GatedSocialEvent;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
import type { CommunityDiscoveryResult, CommunityDiscoveryStatus } from "../../runtime/community/community-discovery-coordinator.js";
|
|
3
|
+
import type { CommunityInstallRiskTier, CommunityInstallSourceTier, CommunityInstallTrustStage, CommunityRegistryMatchResult } from "../../runtime/community/community-consent-client.js";
|
|
4
|
+
export declare const COMMUNITY_SEEK_TOOL_NAME: "community_seek";
|
|
5
|
+
export type CommunitySeekKind = "package" | "answer";
|
|
6
|
+
export interface CommunitySeekParams {
|
|
7
|
+
intent: string;
|
|
8
|
+
kinds?: CommunitySeekKind[];
|
|
9
|
+
}
|
|
10
|
+
export interface CommunitySeekPackageCandidate {
|
|
11
|
+
kind: "package";
|
|
12
|
+
id: string;
|
|
13
|
+
title: string;
|
|
14
|
+
summary: string;
|
|
15
|
+
capabilityTags: string[];
|
|
16
|
+
sourceTier: CommunityInstallSourceTier;
|
|
17
|
+
trustStage: CommunityInstallTrustStage;
|
|
18
|
+
effectiveRiskTier: CommunityInstallRiskTier;
|
|
19
|
+
latestVersion: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface CommunitySeekAnswerCandidate {
|
|
22
|
+
kind: "answer";
|
|
23
|
+
reviewId: string;
|
|
24
|
+
resourceId: string;
|
|
25
|
+
title: string;
|
|
26
|
+
/** 对端 agent 的经验文本(发布侧已过脱敏硬闸 R24)。 */
|
|
27
|
+
experience: string;
|
|
28
|
+
outcome: "success" | "fail" | "neutral";
|
|
29
|
+
}
|
|
30
|
+
export type CommunitySeekCandidate = CommunitySeekPackageCandidate | CommunitySeekAnswerCandidate;
|
|
31
|
+
/** 轻回执:落进对话的可折叠"去社区找了个 X"(展示侧由 UI 渲染)。 */
|
|
32
|
+
export interface CommunitySeekReceipt {
|
|
33
|
+
intent: string;
|
|
34
|
+
status: CommunityDiscoveryStatus;
|
|
35
|
+
packageCount: number;
|
|
36
|
+
answerCount: number;
|
|
37
|
+
topTitle?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface CommunitySeekResult {
|
|
40
|
+
status: CommunityDiscoveryStatus;
|
|
41
|
+
intent: string;
|
|
42
|
+
packages: CommunitySeekPackageCandidate[];
|
|
43
|
+
answers: CommunitySeekAnswerCandidate[];
|
|
44
|
+
}
|
|
45
|
+
export interface CommunitySeekDeps {
|
|
46
|
+
/** 发现协调器:本地前置 + consent + 缓存 + ≤1 次 O(1) registry_match。 */
|
|
47
|
+
discover(intent: string): Promise<CommunityDiscoveryResult>;
|
|
48
|
+
/** 经验答案源(Cut1 默认无:hub registry_match 扩返经验答案后接入)。 */
|
|
49
|
+
findAnswers?(intent: string, topK: number): Promise<CommunitySeekAnswerCandidate[]>;
|
|
50
|
+
/** 轻回执 sink(对话侧渲染);best-effort,抛错不影响工具结果。 */
|
|
51
|
+
onReceipt?(receipt: CommunitySeekReceipt): void;
|
|
52
|
+
}
|
|
53
|
+
export declare function toPackageCandidate(match: CommunityRegistryMatchResult): CommunitySeekPackageCandidate;
|
|
54
|
+
export declare function runCommunitySeek(deps: CommunitySeekDeps, params: CommunitySeekParams): Promise<CommunitySeekResult>;
|
|
55
|
+
export declare const COMMUNITY_SEEK_TOOL_SCHEMA: {
|
|
56
|
+
readonly type: "object";
|
|
57
|
+
readonly properties: {
|
|
58
|
+
readonly intent: {
|
|
59
|
+
readonly type: "string";
|
|
60
|
+
readonly description: string;
|
|
61
|
+
};
|
|
62
|
+
readonly kinds: {
|
|
63
|
+
readonly type: "array";
|
|
64
|
+
readonly items: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
readonly enum: readonly ["package", "answer"];
|
|
67
|
+
};
|
|
68
|
+
readonly description: "Restrict results to packages and/or answers. Omit for both.";
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
readonly required: readonly ["intent"];
|
|
72
|
+
};
|
|
73
|
+
export declare function createCommunitySeekTool(deps: CommunitySeekDeps): PortableTool<CommunitySeekParams>;
|