qlogicagent 2.16.7 → 2.16.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.
Files changed (54) hide show
  1. package/dist/cli.js +403 -403
  2. package/dist/default-project-knowledge/INSTRUCTIONS.md +7 -0
  3. package/dist/default-project-knowledge/rules/project-workflow.md +6 -0
  4. package/dist/index.js +408 -408
  5. package/dist/types/cli/agent-runtime-bootstrap.d.ts +1 -0
  6. package/dist/types/cli/base-tool-bootstrap.d.ts +2 -0
  7. package/dist/types/cli/handlers/community-handler.d.ts +2 -28
  8. package/dist/types/cli/handlers/files-handler.d.ts +1 -0
  9. package/dist/types/cli/handlers/message-feedback-handler.d.ts +2 -0
  10. package/dist/types/cli/handlers/pet-handler.d.ts +1 -0
  11. package/dist/types/cli/handlers/workflow-handler.d.ts +0 -11
  12. package/dist/types/cli/memory-coordinator.d.ts +1 -0
  13. package/dist/types/cli/project-template-seeder.d.ts +2 -2
  14. package/dist/types/cli/runtime-hook-bootstrap.d.ts +1 -0
  15. package/dist/types/cli/stdio-agent-session-bootstrap.d.ts +1 -0
  16. package/dist/types/cli/tool-bootstrap-community-registration.d.ts +0 -6
  17. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +1 -0
  18. package/dist/types/cli/tool-bootstrap.d.ts +1 -0
  19. package/dist/types/cli/turn-skill-autopersist.d.ts +0 -25
  20. package/dist/types/protocol/methods.d.ts +0 -201
  21. package/dist/types/protocol/wire/agent-methods.d.ts +10 -205
  22. package/dist/types/protocol/wire/notification-payloads.d.ts +7 -0
  23. package/dist/types/runtime/community/community-consent-client.d.ts +9 -186
  24. package/dist/types/runtime/community/community-discovery-coordinator.d.ts +1 -1
  25. package/dist/types/runtime/infra/default-path-service.d.ts +1 -1
  26. package/dist/types/runtime/infra/feedback-event-store.d.ts +19 -0
  27. package/dist/types/runtime/infra/feedback-upload-client.d.ts +1 -0
  28. package/dist/types/runtime/infra/project-data-paths.d.ts +5 -5
  29. package/dist/types/runtime/pet/daily-journey-summarizer.d.ts +25 -0
  30. package/dist/types/runtime/pet/index.d.ts +2 -1
  31. package/dist/types/runtime/pet/journey-catchup.d.ts +14 -0
  32. package/dist/types/runtime/pet/journey-day-aggregator.d.ts +27 -0
  33. package/dist/types/runtime/pet/journey-narrative-prompt.d.ts +8 -0
  34. package/dist/types/runtime/pet/pet-profile-service.d.ts +14 -1
  35. package/dist/types/runtime/ports/path-service.d.ts +1 -1
  36. package/dist/types/runtime/ports/tool-contracts.d.ts +1 -0
  37. package/dist/types/runtime/prompt/instruction-loader.d.ts +7 -7
  38. package/dist/types/skills/plugins/plugin-marketplace.d.ts +1 -1
  39. package/dist/types/skills/tools/community-seek-tool.d.ts +0 -33
  40. package/dist/types/skills/tools/instructions-tool.d.ts +2 -2
  41. package/package.json +1 -1
  42. package/dist/types/runtime/community/activity-event-emitter.d.ts +0 -31
  43. package/dist/types/runtime/community/activity-event.d.ts +0 -62
  44. package/dist/types/runtime/community/community-desensitization-red-team-cli.d.ts +0 -7
  45. package/dist/types/runtime/community/community-desensitization.d.ts +0 -29
  46. package/dist/types/runtime/community/community-pet-publisher.d.ts +0 -27
  47. package/dist/types/runtime/community/community-signal-reporter.d.ts +0 -19
  48. package/dist/types/runtime/community/community-telemetry-metadata.d.ts +0 -4
  49. package/dist/types/runtime/community/community-telemetry-recorder.d.ts +0 -6
  50. package/dist/types/runtime/community/community-telemetry-types.d.ts +0 -1
  51. package/dist/types/runtime/community/pet-activity-sink.d.ts +0 -36
  52. package/dist/types/runtime/community/pet-key.d.ts +0 -7
  53. package/dist/types/runtime/community/roaming-gate.d.ts +0 -19
  54. package/dist/types/runtime/community/social-emission.d.ts +0 -16
@@ -46,12 +46,25 @@ export interface PetdexPetAsset extends Omit<PetdexPetAssetSummary, "atlas"> {
46
46
  frame: number;
47
47
  };
48
48
  }
49
+ export interface JourneyStats {
50
+ turns: number;
51
+ filesChanged: number;
52
+ toolsUsed: string[];
53
+ projects: string[];
54
+ }
49
55
  export interface JourneySnapshot {
50
56
  date: string;
51
57
  day: number;
52
58
  petName: string;
53
59
  stateLabel: string;
54
- entries: Array<Record<string, unknown>>;
60
+ /** Pet-voice narrative of the day's local work (LLM-written from deterministic facts). */
61
+ narrative?: string;
62
+ /** Deterministic day stats (computed, never LLM-invented). */
63
+ stats?: JourneyStats;
64
+ generatedAt?: string;
65
+ generator?: "auto" | "manual";
66
+ /** Legacy mock entries — optional, superseded by narrative/stats. */
67
+ entries?: Array<Record<string, unknown>>;
55
68
  }
56
69
  export interface PetProfile {
57
70
  version: 1;
@@ -27,5 +27,5 @@ export interface PathService {
27
27
  getProjectInstructionsPath(projectRoot?: string): string;
28
28
  getProjectPluginsDir(projectRoot?: string): string;
29
29
  getProjectRulesDir(projectRoot?: string): string;
30
- getProjectSessionsRoot(projectRoot?: string): string;
30
+ getProjectSessionDataRoot(projectIdOrWorkspaceDir?: string): string;
31
31
  }
@@ -65,6 +65,7 @@ export interface ToolBootstrapConfig {
65
65
  };
66
66
  getTaskScopeKey?(): string | undefined;
67
67
  getCurrentTurnId?(): string | undefined;
68
+ sendNotification?(method: string, params: Record<string, unknown>): void;
68
69
  onExecProgress?(progress: ToolBootstrapProgress): void;
69
70
  }
70
71
  export interface ToolBootstrap {
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Instruction Loader — CC claudemd.ts parity (adapted for qlogicagent).
3
3
  *
4
- * Discovers and loads instruction files following CC's load order:
5
- * 1. User instructions (~/.qlogicagent/INSTRUCTIONS.md)
6
- * 2. Project instructions (INSTRUCTIONS.md, .qlogicagent/INSTRUCTIONS.md,
4
+ * Discovers and loads project instruction files following CC's walkup model:
5
+ * 1. Project instructions (INSTRUCTIONS.md, .qlogicagent/INSTRUCTIONS.md,
7
6
  * .qlogicagent/rules/*.md — walkup from cwd to git root)
8
- * 3. Local instructions (INSTRUCTIONS.local.md — private, not checked in)
7
+ * 2. Local instructions (INSTRUCTIONS.local.md — private, not checked in)
8
+ *
9
+ * Profile-scoped user templates are copied into project knowledge at project creation time.
9
10
  *
10
11
  * Features ported from CC:
11
12
  * - Walkup discovery (cwd → root)
@@ -37,12 +38,11 @@ export interface LiteralResponseRequirement {
37
38
  * Load all instruction files following CC's discovery order.
38
39
  *
39
40
  * Discovery order (priority: last loaded = highest):
40
- * 1. User: ~/.qlogicagent/INSTRUCTIONS.md, ~/.qlogicagent/rules/*.md
41
- * 2. Project: Walk from git root → cwd, each dir:
41
+ * 1. Project: Walk from git root → cwd, each dir:
42
42
  * - INSTRUCTIONS.md
43
43
  * - .qlogicagent/INSTRUCTIONS.md
44
44
  * - .qlogicagent/rules/*.md (unconditional)
45
- * 3. Local: INSTRUCTIONS.local.md (per dir, walkup)
45
+ * 2. Local: INSTRUCTIONS.local.md (per dir, walkup)
46
46
  *
47
47
  * @param cwd - Starting directory for walkup discovery
48
48
  * @param hooks - Optional hook registry for instructions.loaded event
@@ -51,7 +51,7 @@ export declare function loadCachedPlugins(): string[];
51
51
  export declare function installMarketplacePlugins(config: MarketplaceConfig, log: MarketplaceLogger): Promise<string[]>;
52
52
  /**
53
53
  * Get the marketplace config from user settings.
54
- * Reads ~/.qlogicagent/marketplace.json
54
+ * Reads ~/.qlogicagent/profiles/<owner>/marketplace.json
55
55
  */
56
56
  export declare function loadMarketplaceConfig(): MarketplaceConfig | null;
57
57
  /**
@@ -2,10 +2,8 @@ import type { PortableTool } from "../portable-tool.js";
2
2
  import type { CommunityDiscoveryResult, CommunityDiscoveryStatus } from "../../runtime/community/community-discovery-coordinator.js";
3
3
  import type { CommunityInstallRiskTier, CommunityInstallSourceTier, CommunityInstallTrustStage, CommunityRegistryMatchResult } from "../../runtime/community/community-consent-client.js";
4
4
  export declare const COMMUNITY_SEEK_TOOL_NAME: "community_seek";
5
- export type CommunitySeekKind = "package" | "answer";
6
5
  export interface CommunitySeekParams {
7
6
  intent: string;
8
- kinds?: CommunitySeekKind[];
9
7
  }
10
8
  export interface CommunitySeekPackageCandidate {
11
9
  kind: "package";
@@ -18,46 +16,23 @@ export interface CommunitySeekPackageCandidate {
18
16
  effectiveRiskTier: CommunityInstallRiskTier;
19
17
  latestVersion: string | null;
20
18
  }
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
19
  /** 轻回执:落进对话的可折叠"去社区找了个 X"(展示侧由 UI 渲染)。 */
32
20
  export interface CommunitySeekReceipt {
33
21
  intent: string;
34
22
  status: CommunityDiscoveryStatus;
35
23
  packageCount: number;
36
- answerCount: number;
37
24
  topTitle?: string;
38
25
  }
39
26
  export interface CommunitySeekResult {
40
27
  status: CommunityDiscoveryStatus;
41
28
  intent: string;
42
29
  packages: CommunitySeekPackageCandidate[];
43
- answers: CommunitySeekAnswerCandidate[];
44
30
  }
45
31
  export interface CommunitySeekDeps {
46
32
  /** 发现协调器:本地前置 + consent + 缓存 + ≤1 次 O(1) registry_match。 */
47
33
  discover(intent: string): Promise<CommunityDiscoveryResult>;
48
- /** 经验答案源(Cut1 默认无:hub registry_match 扩返经验答案后接入)。 */
49
- findAnswers?(intent: string, topK: number): Promise<CommunitySeekAnswerCandidate[]>;
50
34
  /** 轻回执 sink(对话侧渲染);best-effort,抛错不影响工具结果。 */
51
35
  onReceipt?(receipt: CommunitySeekReceipt): void;
52
- /**
53
- * 「去社区张罗到了」→ 发一条 acquire ActivityEvent(父总纲 Cut1「落…一条 ActivityEvent」):
54
- * 自家宠物现身于命中资源的店铺/街区。anchor 只给 shopId(店铺=canonical resourceId);
55
- * 街区由集市端按 layout 反解。best-effort fire-and-forget,抛错/未配置都不影响工具结果。
56
- */
57
- onAcquire?(anchor: {
58
- shopId?: string;
59
- districtId?: string;
60
- }): void;
61
36
  }
62
37
  export declare function toPackageCandidate(match: CommunityRegistryMatchResult): CommunitySeekPackageCandidate;
63
38
  export declare function runCommunitySeek(deps: CommunitySeekDeps, params: CommunitySeekParams): Promise<CommunitySeekResult>;
@@ -68,14 +43,6 @@ export declare const COMMUNITY_SEEK_TOOL_SCHEMA: {
68
43
  readonly type: "string";
69
44
  readonly description: string;
70
45
  };
71
- readonly kinds: {
72
- readonly type: "array";
73
- readonly items: {
74
- readonly type: "string";
75
- readonly enum: readonly ["package", "answer"];
76
- };
77
- readonly description: "Restrict results to packages and/or answers. Omit for both.";
78
- };
79
46
  };
80
47
  readonly required: readonly ["intent"];
81
48
  };
@@ -17,9 +17,9 @@ export interface InstructionsToolDeps {
17
17
  /** Read a single instruction file. Returns null if not found. */
18
18
  read(projectId: string, filename: string): InstructionFileContent | null;
19
19
  /** Write (create or overwrite) an instruction file. */
20
- write(projectId: string, filename: string, content: string): InstructionFileContent;
20
+ write(projectId: string, filename: string, content: string): InstructionFileContent | Promise<InstructionFileContent>;
21
21
  /** Remove an instruction file. Returns true if deleted. */
22
- remove(projectId: string, filename: string): boolean;
22
+ remove(projectId: string, filename: string): boolean | Promise<boolean>;
23
23
  }
24
24
  export declare const INSTRUCTIONS_TOOL_NAME: "instructions";
25
25
  export type InstructionsAction = "list" | "read" | "write" | "edit" | "delete";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qlogicagent",
3
- "version": "2.16.7",
3
+ "version": "2.16.8",
4
4
  "description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,31 +0,0 @@
1
- import { type ActivityEvent, type CreateActivityEventInput } from "./activity-event.js";
2
- import { type CommunityConsentClient } from "./community-consent-client.js";
3
- import type { ConfigPort } from "../ports/index.js";
4
- export type ActivityEmitStatus = "emitted" | "disabled" | "consent-blocked" | "failed";
5
- /** 活动事件出口:真实实现把事件写入 community-service(社交通道,非权威)。 */
6
- export interface ActivityEventTransport {
7
- emit(event: ActivityEvent): Promise<void>;
8
- }
9
- export interface ActivityEventEmitterDeps {
10
- /** 无 transport(未配置 / dev)→ "disabled"。 */
11
- transport: ActivityEventTransport | null;
12
- /** consent 源;community 事件必须能验 consent,否则 fail-safe 拦下。 */
13
- consent: Pick<CommunityConsentClient, "getConsent"> | null;
14
- }
15
- export interface ActivityEventEmitter {
16
- emit(input: CreateActivityEventInput): Promise<ActivityEmitStatus>;
17
- }
18
- export declare function createActivityEventEmitter(deps: ActivityEventEmitterDeps): ActivityEventEmitter;
19
- /** 把 community-service 的 emitActivity 包成 transport(社交写只走此通道,零触碰权威)。 */
20
- export declare function createHubActivityTransport(client: Pick<CommunityConsentClient, "emitActivity">): ActivityEventTransport;
21
- /**
22
- * 默认发射器:从 env consent client 构造 transport + consent。
23
- * 无 token(dev)→ client null → transport null(emit 返回 "disabled",fail-safe)。
24
- */
25
- export declare function createDefaultActivityEventEmitter(): ActivityEventEmitter;
26
- /**
27
- * 解析本 agent 自己的 actorPetId = derivePetKey(owner, device)(Cut7/#1)。
28
- * owner=QLOGIC_LLMROUTER_USER_ID、device=QLOGIC_LLMROUTER_DEVICE_ID(gateway 经 buildQlogicagentLlmrouterEnv 注入)。
29
- * 缺料(未登录/dev)→ null:调用方应跳过发射(fail-soft,绝不因社交写挂任务)。
30
- */
31
- export declare function resolveSelfActorPetId(configPort?: ConfigPort): string | null;
@@ -1,62 +0,0 @@
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
- /** 浏览/搜索族(Cut7/M5:agent 搜资源 → 宠物到该区"逛")。非 trust-signal;community 可见走 encounter 闸。 */
5
- export type BrowseEventType = "search";
6
- export type ActivityEventType = TrustSignalEventType | ExperientialEventType | FlauntEventType | BrowseEventType;
7
- /**
8
- * 空间锚点:agent 发射时本就持有 resourceId 与其 category,事件自带锚点让集市
9
- * 端零反查地把微动画钉到正确街区 / 店铺。**只允许 districtId / shopId。**
10
- */
11
- export interface ActivitySpatialAnchor {
12
- /** RESOURCE_CATEGORIES 的 category key(23 类稳定 key)。 */
13
- districtId?: string;
14
- /** canonical resourceId(店铺稳定主键)。 */
15
- shopId?: string;
16
- }
17
- /** 禁止出现在 anchor 上的权威坐标键(DR12 红线,防后人误加诱导 v2 位置漂移)。 */
18
- export declare const FORBIDDEN_ANCHOR_KEYS: readonly string[];
19
- export interface ActivityPayload {
20
- /** 空间归属锚点(可选);禁权威坐标。 */
21
- anchor?: ActivitySpatialAnchor;
22
- [k: string]: unknown;
23
- }
24
- export type ActivityVisibility = "owner" | "community";
25
- export interface ActivityEvent {
26
- /** 幂等键。 */
27
- id: string;
28
- type: ActivityEventType;
29
- /** 逐事件时间戳(epoch ms)。 */
30
- ts: number;
31
- /** 行动者 = 本人宠物人格(community-service 持有)。 */
32
- actorPetId: string;
33
- /** 对端 actorPetId(社交事件;离场降级"最近一次在场",不承诺在线;OFF 时缺省)。 */
34
- peerRef?: string;
35
- /** 已过脱敏边界(DR3);anchor 禁权威坐标。 */
36
- payload: ActivityPayload;
37
- /** owner=只进自己偷窥窗;community=游历 ON 才有(默认 owner,fail-safe)。 */
38
- visibility: ActivityVisibility;
39
- }
40
- export declare function isTrustSignalEvent(type: ActivityEventType): type is TrustSignalEventType;
41
- export declare function isExperientialEvent(type: ActivityEventType): type is ExperientialEventType;
42
- export declare function isFlauntEvent(type: ActivityEventType): type is FlauntEventType;
43
- export declare function isActivityEventType(value: unknown): value is ActivityEventType;
44
- export interface CreateActivityEventInput {
45
- id: string;
46
- type: ActivityEventType;
47
- ts: number;
48
- actorPetId: string;
49
- peerRef?: string;
50
- payload?: ActivityPayload;
51
- /** 默认 "owner"(fail-safe:跨租户可见须显式 + 上游 consent/roaming 闸放行)。 */
52
- visibility?: ActivityVisibility;
53
- }
54
- /**
55
- * 校验 anchor:只保留 districtId / shopId;若出现任何权威坐标键 → 抛错(DR12 红线,
56
- * 纵深防御:契约层就拦,不靠调用方自觉)。
57
- */
58
- export declare function sanitizeAnchor(anchor: ActivitySpatialAnchor | undefined): ActivitySpatialAnchor | undefined;
59
- /**
60
- * 构造一个经校验的 ActivityEvent。校验必填字段、规范化 anchor、默认 visibility=owner。
61
- */
62
- export declare function createActivityEvent(input: CreateActivityEventInput): ActivityEvent;
@@ -1,7 +0,0 @@
1
- export interface CommunityDesensitizationRedTeamCliDeps {
2
- log?: {
3
- info(message: string): void;
4
- error(message: string): void;
5
- };
6
- }
7
- export declare function runCommunityDesensitizationRedTeamCli(argv?: string[], deps?: CommunityDesensitizationRedTeamCliDeps): Promise<number>;
@@ -1,29 +0,0 @@
1
- export type CommunityDesensitizationRuleId = "sensitive-email" | "sensitive-secret" | "sensitive-path" | "sensitive-phone";
2
- export interface CommunityDesensitizationHit {
3
- reason: string;
4
- ruleId: CommunityDesensitizationRuleId;
5
- }
6
- export interface CommunityDesensitizationRedTeamCase {
7
- id: string;
8
- content: string;
9
- expectedRuleId: CommunityDesensitizationRuleId;
10
- }
11
- export interface CommunityDesensitizationRedTeamReport {
12
- suite: "desensitization";
13
- generatedAt: string;
14
- cases: number;
15
- passed: boolean;
16
- failures: number;
17
- breakdown: Record<CommunityDesensitizationRuleId, {
18
- cases: number;
19
- failures: number;
20
- }>;
21
- failureDetails: Array<{
22
- id: string;
23
- expectedRuleId: CommunityDesensitizationRuleId;
24
- actualRuleId: CommunityDesensitizationRuleId | null;
25
- }>;
26
- }
27
- export declare function detectCommunityPublishSensitiveContent(content: string): CommunityDesensitizationHit | null;
28
- export declare function buildCommunityDesensitizationRedTeamCases(): CommunityDesensitizationRedTeamCase[];
29
- export declare function runCommunityDesensitizationRedTeam(cases?: CommunityDesensitizationRedTeamCase[]): CommunityDesensitizationRedTeamReport;
@@ -1,27 +0,0 @@
1
- import type { CommunityConsentClient, CommunityPublishSkillResult } from "./community-consent-client.js";
2
- /**
3
- * Publish payload for a petdex pet: identity + safety-checked text, plus the prebuilt
4
- * registry manifest and gzipped `.petdex` blob (built by buildPetdexPublishPayload in the
5
- * pet module, so this stays free of pet packaging/IO knowledge).
6
- */
7
- export interface PetAssetPublishInput {
8
- id: string;
9
- name: string;
10
- description: string;
11
- manifest: Record<string, unknown>;
12
- version: string;
13
- packageGzipBase64: string;
14
- visibility?: "public" | "private";
15
- tags?: string[];
16
- }
17
- /**
18
- * Pets are display-only sprite data, but their visible name/description still ship to the
19
- * registry — keep the §11 safety gate: block private data leaks and any claim of agent powers.
20
- */
21
- export declare function assertSafePetPublish(fields: {
22
- id: string;
23
- name: string;
24
- description: string;
25
- tags?: string[];
26
- }): void;
27
- export declare function publishCommunityPetAsset(client: Pick<CommunityConsentClient, "getConsent" | "publishPet">, input: PetAssetPublishInput): Promise<CommunityPublishSkillResult>;
@@ -1,19 +0,0 @@
1
- import type { CommunityConsentClient, CommunityRecordSignalInput, CommunitySignalEvent } from "./community-consent-client.js";
2
- export interface CommunitySkillLifecycleRecord {
3
- name: string;
4
- createdAt: string;
5
- lastUsedAt?: string;
6
- source?: string;
7
- registryResourceId?: string;
8
- registryVersion?: string;
9
- registrySourceTier?: string;
10
- registryRiskTier?: string;
11
- registryEffectiveRiskTier?: string;
12
- registryKeptSignalAt?: string;
13
- }
14
- export interface CommunitySignalReporter {
15
- record(input: CommunityRecordSignalInput): Promise<"recorded" | "disabled" | "skipped" | "failed">;
16
- recordSkillLifecycle(record: CommunitySkillLifecycleRecord | undefined, event: Extract<CommunitySignalEvent, "kept" | "uninstalled" | "endorse">): Promise<"recorded" | "disabled" | "skipped" | "failed">;
17
- }
18
- export declare function createCommunitySignalReporter(client: Pick<CommunityConsentClient, "getConsent" | "recordSignal"> | null): CommunitySignalReporter;
19
- export declare function createDefaultCommunitySignalReporter(): CommunitySignalReporter | null;
@@ -1,4 +0,0 @@
1
- import type { CommunityTelemetryEvent } from "./community-telemetry-types.js";
2
- type SafeTelemetryMetadataValue = string | number | boolean;
3
- export declare function sanitizeCommunityTelemetryMetadata(event: CommunityTelemetryEvent, metadata: unknown): Record<string, SafeTelemetryMetadataValue> | undefined;
4
- export {};
@@ -1,6 +0,0 @@
1
- import { type CommunityRecordTelemetryInput } from "./community-consent-client.js";
2
- export interface CommunityTelemetryRecorder {
3
- recordTelemetry(input: CommunityRecordTelemetryInput): Promise<void>;
4
- }
5
- export declare function createDefaultCommunityTelemetryRecorder(): CommunityTelemetryRecorder | null;
6
- export declare function recordCommunityTelemetryBestEffort(recorder: CommunityTelemetryRecorder | null | undefined, input: CommunityRecordTelemetryInput): void;
@@ -1 +0,0 @@
1
- export type CommunityTelemetryEvent = "community.journey.view" | "community.share.generated" | "community.sandbox.violation" | "community.desensitization.hit" | "registry.install_failed";
@@ -1,36 +0,0 @@
1
- import { type ActivityEventType, type ActivitySpatialAnchor } from "./activity-event.js";
2
- import { type ActivityEmitStatus, type ActivityEventEmitter } from "./activity-event-emitter.js";
3
- import { type CommunityConsentClient } from "./community-consent-client.js";
4
- import type { ConfigPort } from "../ports/config-port.js";
5
- /** 一条要发射的活动:类型 + 空间锚点(街区/店铺)+ 可选对端 + 敏感度。actorPetId/ts/id 由 sink 注入。 */
6
- export interface PetActivityInput {
7
- type: ActivityEventType;
8
- anchor?: ActivitySpatialAnchor;
9
- peerRef?: string;
10
- /** 高敏感内容 → 升级问人,不自动外发(DR3);默认 false。 */
11
- highSensitivity?: boolean;
12
- }
13
- export type PetActivityEmitStatus = ActivityEmitStatus | "escalate";
14
- export interface PetActivitySink {
15
- /** 发一条活动事件。绝不抛(任何失败都 best-effort 吞掉)。 */
16
- emit(input: PetActivityInput): Promise<PetActivityEmitStatus>;
17
- }
18
- export interface PetActivitySinkDeps {
19
- actorPetId: string;
20
- consent: Pick<CommunityConsentClient, "getConsent">;
21
- emitter: ActivityEventEmitter;
22
- now: () => number;
23
- newId: () => string;
24
- }
25
- /** 纯逻辑 sink(可注入,供测试)。游历闸定 visibility,emitter 落库。 */
26
- export declare function createPetActivitySink(deps: PetActivitySinkDeps): PetActivitySink;
27
- /**
28
- * 由 (owner,device) 派生本 agent 自家宠物的 actorPetId。env 由 gateway 注入。
29
- * 缺 owner/device(dev / 未登录)→ null(无身份不发,fail-safe)。
30
- */
31
- export declare function resolveActorPetId(configPort?: ConfigPort): string | null;
32
- /**
33
- * 默认 sink:从 env 解析 actorPetId + 构造 consent/transport。
34
- * 无身份 / 无 token(dev)→ null(调用方 ?.emit 即 no-op,fail-safe 不发)。
35
- */
36
- export declare function createDefaultPetActivitySink(configPort?: ConfigPort): PetActivitySink | null;
@@ -1,7 +0,0 @@
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;
@@ -1,19 +0,0 @@
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;
@@ -1,16 +0,0 @@
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;