qlogicagent 2.16.6 → 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.
- package/dist/agent.js +16 -16
- package/dist/cli.js +412 -413
- package/dist/default-project-knowledge/INSTRUCTIONS.md +7 -0
- package/dist/default-project-knowledge/rules/project-workflow.md +6 -0
- package/dist/index.js +411 -412
- package/dist/protocol.js +1 -1
- package/dist/types/cli/agent-runtime-bootstrap.d.ts +1 -0
- package/dist/types/cli/base-tool-bootstrap.d.ts +3 -0
- package/dist/types/cli/handlers/community-handler.d.ts +2 -28
- package/dist/types/cli/handlers/files-handler.d.ts +6 -0
- package/dist/types/cli/handlers/message-feedback-handler.d.ts +31 -0
- package/dist/types/cli/handlers/pet-handler.d.ts +1 -0
- package/dist/types/cli/handlers/project-handler.d.ts +1 -0
- package/dist/types/cli/handlers/turn-baseline-handler.d.ts +8 -0
- package/dist/types/cli/handlers/turn-handler.d.ts +5 -0
- package/dist/types/cli/handlers/workflow-handler.d.ts +0 -11
- package/dist/types/cli/handlers/working-materials-handler.d.ts +9 -0
- package/dist/types/cli/idle-dream-coordinator.d.ts +6 -0
- package/dist/types/cli/mcp-bootstrap.d.ts +1 -0
- package/dist/types/cli/memory-coordinator.d.ts +1 -0
- package/dist/types/cli/project-template-seeder.d.ts +2 -2
- package/dist/types/cli/rpc-registry.d.ts +6 -0
- package/dist/types/cli/runtime-hook-bootstrap.d.ts +1 -0
- package/dist/types/cli/stdio-agent-session-bootstrap.d.ts +1 -0
- package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +1 -0
- package/dist/types/cli/stdio-runtime-bootstrap.d.ts +1 -0
- package/dist/types/cli/tool-bootstrap-community-registration.d.ts +0 -6
- package/dist/types/cli/tool-bootstrap-core-registration.d.ts +2 -0
- package/dist/types/cli/tool-bootstrap.d.ts +2 -0
- package/dist/types/cli/turn-skill-autopersist.d.ts +0 -25
- package/dist/types/protocol/methods.d.ts +24 -201
- package/dist/types/protocol/wire/agent-events.d.ts +2 -2
- package/dist/types/protocol/wire/agent-methods.d.ts +10 -205
- package/dist/types/protocol/wire/gateway-rpc.d.ts +160 -0
- package/dist/types/protocol/wire/notification-payloads.d.ts +34 -0
- package/dist/types/runtime/community/community-consent-client.d.ts +9 -186
- package/dist/types/runtime/community/community-discovery-coordinator.d.ts +1 -1
- package/dist/types/runtime/infra/default-path-service.d.ts +1 -1
- package/dist/types/runtime/infra/feedback-distillation-worker.d.ts +20 -0
- package/dist/types/runtime/infra/feedback-distillation.d.ts +30 -0
- package/dist/types/runtime/infra/feedback-event-store.d.ts +179 -0
- package/dist/types/runtime/infra/feedback-outbox.d.ts +26 -0
- package/dist/types/runtime/infra/feedback-redaction.d.ts +71 -0
- package/dist/types/runtime/infra/feedback-upload-client.d.ts +40 -0
- package/dist/types/runtime/infra/feedback-upload-worker.d.ts +11 -0
- package/dist/types/runtime/infra/project-data-paths.d.ts +5 -5
- package/dist/types/runtime/infra/turn-baseline-store.d.ts +102 -0
- package/dist/types/runtime/infra/turn-telemetry-store.d.ts +59 -0
- package/dist/types/runtime/infra/working-materials-store.d.ts +35 -0
- package/dist/types/runtime/pet/daily-journey-summarizer.d.ts +25 -0
- package/dist/types/runtime/pet/index.d.ts +2 -1
- package/dist/types/runtime/pet/journey-catchup.d.ts +14 -0
- package/dist/types/runtime/pet/journey-day-aggregator.d.ts +27 -0
- package/dist/types/runtime/pet/journey-narrative-prompt.d.ts +8 -0
- package/dist/types/runtime/pet/pet-profile-service.d.ts +14 -1
- package/dist/types/runtime/ports/memory-provider.d.ts +6 -0
- package/dist/types/runtime/ports/path-service.d.ts +1 -1
- package/dist/types/runtime/ports/tool-contracts.d.ts +2 -0
- package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +14 -0
- package/dist/types/runtime/prompt/instruction-loader.d.ts +7 -7
- package/dist/types/skills/mcp/mcp-manager.d.ts +11 -0
- package/dist/types/skills/memory/local-memory-provider.d.ts +3 -3
- package/dist/types/skills/memory/local-store-records.d.ts +18 -1
- package/dist/types/skills/memory/local-store.d.ts +8 -195
- package/dist/types/skills/memory/memory-consolidation.d.ts +14 -0
- package/dist/types/skills/memory/sqlite-memory-schema.d.ts +1 -1
- package/dist/types/skills/plugins/plugin-marketplace.d.ts +1 -1
- package/dist/types/skills/tools/community-seek-tool.d.ts +0 -33
- package/dist/types/skills/tools/instructions-tool.d.ts +2 -2
- package/dist/types/skills/tools/skill-tool.d.ts +1 -1
- package/dist/vendor/hatch-pet/LICENSE.txt +201 -201
- package/dist/vendor/hatch-pet/NOTICE.md +25 -25
- package/dist/vendor/hatch-pet/references/animation-rows.md +29 -29
- package/dist/vendor/hatch-pet/references/codex-pet-contract.md +35 -35
- package/dist/vendor/hatch-pet/references/qa-rubric.md +66 -66
- package/dist/vendor/hatch-pet/scripts/compose_atlas.py +169 -169
- package/dist/vendor/hatch-pet/scripts/derive_running_left_from_running_right.py +150 -150
- package/dist/vendor/hatch-pet/scripts/extract_strip_frames.py +408 -408
- package/dist/vendor/hatch-pet/scripts/inspect_frames.py +256 -256
- package/dist/vendor/hatch-pet/scripts/make_contact_sheet.py +96 -96
- package/dist/vendor/hatch-pet/scripts/prepare_pet_run.py +834 -834
- package/dist/vendor/hatch-pet/scripts/render_animation_previews.py +78 -78
- package/dist/vendor/hatch-pet/scripts/validate_atlas.py +157 -157
- package/package.json +1 -1
- package/dist/types/runtime/community/activity-event-emitter.d.ts +0 -31
- package/dist/types/runtime/community/activity-event.d.ts +0 -62
- package/dist/types/runtime/community/community-desensitization-red-team-cli.d.ts +0 -7
- package/dist/types/runtime/community/community-desensitization.d.ts +0 -29
- package/dist/types/runtime/community/community-pet-publisher.d.ts +0 -27
- package/dist/types/runtime/community/community-signal-reporter.d.ts +0 -19
- package/dist/types/runtime/community/community-telemetry-metadata.d.ts +0 -4
- package/dist/types/runtime/community/community-telemetry-recorder.d.ts +0 -6
- package/dist/types/runtime/community/community-telemetry-types.d.ts +0 -1
- package/dist/types/runtime/community/pet-activity-sink.d.ts +0 -36
- package/dist/types/runtime/community/pet-key.d.ts +0 -7
- package/dist/types/runtime/community/roaming-gate.d.ts +0 -19
- package/dist/types/runtime/community/social-emission.d.ts +0 -16
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
export type FeedbackRating = "up" | "down";
|
|
2
|
+
export type FeedbackState = "active" | "retracted" | "replaced";
|
|
3
|
+
export type TelemetryStatus = "complete" | "partial" | "missing";
|
|
4
|
+
export type FeedbackReason = "missed_requirement" | "incomplete" | "broken_file_link_or_panel" | "code_or_test_failed" | "factually_wrong" | "too_verbose" | "too_short" | "wrong_style" | "other";
|
|
5
|
+
export interface FeedbackUsage {
|
|
6
|
+
inputTokens?: number;
|
|
7
|
+
outputTokens?: number;
|
|
8
|
+
totalTokens?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface FeedbackToolSummary {
|
|
11
|
+
calledTools: string[];
|
|
12
|
+
failedTools: string[];
|
|
13
|
+
blockedTools: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface FeedbackFileContext {
|
|
16
|
+
changedFileCount?: number;
|
|
17
|
+
changedPathsPreview?: string[];
|
|
18
|
+
hasTurnFileChanges?: boolean;
|
|
19
|
+
diffOpenState?: "not_applicable" | "opened" | "failed" | "unknown";
|
|
20
|
+
}
|
|
21
|
+
export interface FeedbackBrowserContext {
|
|
22
|
+
url?: string;
|
|
23
|
+
hadToastError?: boolean;
|
|
24
|
+
visiblePanel?: "chat" | "artifact" | "diff" | "unknown";
|
|
25
|
+
}
|
|
26
|
+
export interface FeedbackEvent {
|
|
27
|
+
feedbackId: string;
|
|
28
|
+
rating: FeedbackRating;
|
|
29
|
+
reason?: FeedbackReason;
|
|
30
|
+
comment?: string;
|
|
31
|
+
state: FeedbackState;
|
|
32
|
+
projectId?: string;
|
|
33
|
+
sessionId: string;
|
|
34
|
+
turnId: string;
|
|
35
|
+
assistantMessageId: string;
|
|
36
|
+
userId?: string;
|
|
37
|
+
telemetryStatus: TelemetryStatus;
|
|
38
|
+
messageRole: "assistant";
|
|
39
|
+
messagePreview: string;
|
|
40
|
+
messageHash: string;
|
|
41
|
+
model?: string;
|
|
42
|
+
provider?: string;
|
|
43
|
+
agentMode?: "chat" | "solo" | "product" | "workflow" | "unknown";
|
|
44
|
+
sourceChannel?: string;
|
|
45
|
+
usage?: FeedbackUsage;
|
|
46
|
+
toolSummary?: FeedbackToolSummary;
|
|
47
|
+
fileContext?: FeedbackFileContext;
|
|
48
|
+
browserContext?: FeedbackBrowserContext;
|
|
49
|
+
upload?: {
|
|
50
|
+
eligible: boolean;
|
|
51
|
+
uploadedAt?: string;
|
|
52
|
+
uploadBatchId?: string;
|
|
53
|
+
redactionVersion?: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Local distillation bookkeeping (mini-design §6): records that this event was folded into a
|
|
57
|
+
* memory proposal, and under which cluster + idempotency key. Observability only — the crash-safe
|
|
58
|
+
* dedup guard is the store-level idempotency key on the proposal, not this field.
|
|
59
|
+
*/
|
|
60
|
+
distill?: {
|
|
61
|
+
proposedAt: string;
|
|
62
|
+
clusterKey: string;
|
|
63
|
+
idempotencyKey: string;
|
|
64
|
+
};
|
|
65
|
+
createdAt: string;
|
|
66
|
+
updatedAt: string;
|
|
67
|
+
}
|
|
68
|
+
/** Telemetry-joined + click-time context the handler assembles before persisting. */
|
|
69
|
+
export interface FeedbackContext {
|
|
70
|
+
telemetryStatus: TelemetryStatus;
|
|
71
|
+
messagePreview: string;
|
|
72
|
+
messageHash: string;
|
|
73
|
+
userId?: string;
|
|
74
|
+
model?: string;
|
|
75
|
+
provider?: string;
|
|
76
|
+
agentMode?: FeedbackEvent["agentMode"];
|
|
77
|
+
sourceChannel?: string;
|
|
78
|
+
usage?: FeedbackUsage;
|
|
79
|
+
toolSummary?: FeedbackToolSummary;
|
|
80
|
+
fileContext?: FeedbackFileContext;
|
|
81
|
+
browserContext?: FeedbackBrowserContext;
|
|
82
|
+
}
|
|
83
|
+
export interface FeedbackSubmitInput {
|
|
84
|
+
rating: FeedbackRating;
|
|
85
|
+
reason?: FeedbackReason;
|
|
86
|
+
comment?: string;
|
|
87
|
+
projectId: string;
|
|
88
|
+
sessionId: string;
|
|
89
|
+
turnId: string;
|
|
90
|
+
assistantMessageId: string;
|
|
91
|
+
context: FeedbackContext;
|
|
92
|
+
}
|
|
93
|
+
export interface FeedbackStateEntry {
|
|
94
|
+
turnId: string;
|
|
95
|
+
assistantMessageId: string;
|
|
96
|
+
feedbackId: string;
|
|
97
|
+
rating: FeedbackRating;
|
|
98
|
+
reason?: FeedbackReason;
|
|
99
|
+
state: FeedbackState;
|
|
100
|
+
updatedAt: string;
|
|
101
|
+
}
|
|
102
|
+
export interface FeedbackSummary {
|
|
103
|
+
total: number;
|
|
104
|
+
active: number;
|
|
105
|
+
retracted: number;
|
|
106
|
+
replaced: number;
|
|
107
|
+
upCount: number;
|
|
108
|
+
downCount: number;
|
|
109
|
+
byReason: Record<string, number>;
|
|
110
|
+
byModel: Record<string, number>;
|
|
111
|
+
byAgentMode: Record<string, number>;
|
|
112
|
+
telemetryStatusCounts: Record<TelemetryStatus, number>;
|
|
113
|
+
}
|
|
114
|
+
export declare function hashMessageContent(content: string): string;
|
|
115
|
+
/**
|
|
116
|
+
* Create / switch / re-activate the feedback for a turn. Returns the stable feedbackId and the
|
|
117
|
+
* resulting state. Submitting the SAME rating while already active is a no-op (idempotent retry).
|
|
118
|
+
*/
|
|
119
|
+
export declare function submitFeedback(input: FeedbackSubmitInput): Promise<{
|
|
120
|
+
feedbackId: string;
|
|
121
|
+
state: FeedbackState;
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* Retract the active feedback for a turn (the frontend calls this when the user re-clicks the
|
|
125
|
+
* already-selected button). Idempotent: retracting when there is nothing active is a no-op.
|
|
126
|
+
*/
|
|
127
|
+
export declare function retractFeedback(input: {
|
|
128
|
+
projectId: string;
|
|
129
|
+
turnId: string;
|
|
130
|
+
feedbackId?: string;
|
|
131
|
+
}): Promise<{
|
|
132
|
+
ok: boolean;
|
|
133
|
+
feedbackId?: string;
|
|
134
|
+
state: FeedbackState | null;
|
|
135
|
+
}>;
|
|
136
|
+
/**
|
|
137
|
+
* Hydrate feedback state for a session's messages (initial render / refresh). Returns only ACTIVE
|
|
138
|
+
* feedback (absent = not rated) — the fixed contract per design §8.3, so the UI never has to
|
|
139
|
+
* interpret retracted/replaced records.
|
|
140
|
+
*/
|
|
141
|
+
export declare function getFeedbackState(input: {
|
|
142
|
+
projectId: string;
|
|
143
|
+
sessionId: string;
|
|
144
|
+
turnIds?: string[];
|
|
145
|
+
assistantMessageIds?: string[];
|
|
146
|
+
}): Promise<{
|
|
147
|
+
states: FeedbackStateEntry[];
|
|
148
|
+
}>;
|
|
149
|
+
/** Local single-instance aggregate used by messageFeedback.summary. Raw message text is not returned. */
|
|
150
|
+
export declare function summarizeFeedback(input: {
|
|
151
|
+
projectId: string;
|
|
152
|
+
sessionId?: string;
|
|
153
|
+
since?: string;
|
|
154
|
+
until?: string;
|
|
155
|
+
}): Promise<FeedbackSummary>;
|
|
156
|
+
/**
|
|
157
|
+
* Events eligible for cloud upload that have not yet been assigned to a batch (design §10). The
|
|
158
|
+
* worker redacts + ships these; once assigned a batchId (delivered or queued for retry) they are
|
|
159
|
+
* skipped until a state change resets the upload marks.
|
|
160
|
+
*/
|
|
161
|
+
export declare function listUploadableFeedback(projectId: string): Promise<FeedbackEvent[]>;
|
|
162
|
+
/** Mark an event as assigned to an in-flight upload batch (queued for retry, not yet delivered). */
|
|
163
|
+
export declare function assignFeedbackBatch(projectId: string, turnId: string, uploadBatchId: string): Promise<void>;
|
|
164
|
+
/** Mark an event as successfully uploaded (stamps uploadedAt + batch + redactionVersion). */
|
|
165
|
+
export declare function markFeedbackUploaded(projectId: string, turnId: string, uploadBatchId: string, redactionVersion: string): Promise<void>;
|
|
166
|
+
/**
|
|
167
|
+
* Active feedback eligible for memory distillation (mini-design §3.1). Distillation re-clusters the
|
|
168
|
+
* full active set every sweep; the store-level idempotency key (not a per-event flag) prevents
|
|
169
|
+
* duplicate proposals, so this intentionally returns ALL active events — already distilled or not.
|
|
170
|
+
* A newly added active event simply changes a cluster's id set and yields a fresh proposal.
|
|
171
|
+
*/
|
|
172
|
+
export declare function listDistillableFeedback(projectId: string): Promise<FeedbackEvent[]>;
|
|
173
|
+
/** Stamp local distillation bookkeeping on an event (which cluster + idempotency key folded it in). */
|
|
174
|
+
export declare function markFeedbackDistilled(projectId: string, turnId: string, info: {
|
|
175
|
+
clusterKey: string;
|
|
176
|
+
idempotencyKey: string;
|
|
177
|
+
}): Promise<void>;
|
|
178
|
+
/** Test helper: read the raw stored event for a turn (including retracted), or null. */
|
|
179
|
+
export declare function __getFeedbackEventForTest(projectId: string, turnId: string): Promise<FeedbackEvent | null>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type OutboxOp = "uploadBatch";
|
|
2
|
+
export interface OutboxEntry {
|
|
3
|
+
entryId: string;
|
|
4
|
+
/** Dedup key — re-enqueuing the same logical op is a no-op (no double upload). */
|
|
5
|
+
idempotencyKey: string;
|
|
6
|
+
op: OutboxOp;
|
|
7
|
+
payload: unknown;
|
|
8
|
+
attempts: number;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
nextAttemptAt: string;
|
|
11
|
+
lastError?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Enqueue a failed op for retry. Idempotent: an existing entry with the same key is kept as-is. */
|
|
14
|
+
export declare function enqueueOutbox(projectId: string, input: {
|
|
15
|
+
idempotencyKey: string;
|
|
16
|
+
op: OutboxOp;
|
|
17
|
+
payload: unknown;
|
|
18
|
+
}, now?: Date): Promise<OutboxEntry>;
|
|
19
|
+
/** Entries whose backoff window has elapsed and that have not exhausted their retry budget. */
|
|
20
|
+
export declare function listDueOutbox(projectId: string, now?: Date): Promise<OutboxEntry[]>;
|
|
21
|
+
/** Drop a successfully-delivered entry. */
|
|
22
|
+
export declare function removeOutbox(projectId: string, entryId: string): Promise<void>;
|
|
23
|
+
/** Record a failed attempt: bump attempts + schedule the next retry with exponential backoff. */
|
|
24
|
+
export declare function markOutboxFailure(projectId: string, entryId: string, error: string, now?: Date): Promise<void>;
|
|
25
|
+
/** Entries that have exhausted their retry budget — kept for local audit, never re-sent. */
|
|
26
|
+
export declare function listExhaustedOutbox(projectId: string): Promise<OutboxEntry[]>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { FeedbackEvent, FeedbackRating, FeedbackReason, FeedbackState, FeedbackToolSummary, FeedbackUsage, TelemetryStatus } from "./feedback-event-store.js";
|
|
2
|
+
/** Bump when the redaction rules change so uploaded samples stay traceable (§8.6/§13). */
|
|
3
|
+
export declare const REDACTION_VERSION = "feedback-redaction-v1";
|
|
4
|
+
export interface RedactedFeedbackEvent {
|
|
5
|
+
feedbackId: string;
|
|
6
|
+
rating: FeedbackRating;
|
|
7
|
+
reason?: FeedbackReason;
|
|
8
|
+
state: FeedbackState;
|
|
9
|
+
/** Hashed identity — correlate without exposing local ids (§8.6). */
|
|
10
|
+
messageHash: string;
|
|
11
|
+
sessionIdHash: string;
|
|
12
|
+
projectIdHash?: string;
|
|
13
|
+
turnIdHash: string;
|
|
14
|
+
/** ≤500 chars, secrets/emails/absolute-paths scrubbed (§13). */
|
|
15
|
+
messagePreview: string;
|
|
16
|
+
model?: string;
|
|
17
|
+
provider?: string;
|
|
18
|
+
agentMode?: FeedbackEvent["agentMode"];
|
|
19
|
+
sourceChannel?: string;
|
|
20
|
+
usage?: FeedbackUsage;
|
|
21
|
+
/** Tool names only (never args). */
|
|
22
|
+
toolSummary?: FeedbackToolSummary;
|
|
23
|
+
fileContext?: {
|
|
24
|
+
changedFileCount?: number;
|
|
25
|
+
hasTurnFileChanges?: boolean;
|
|
26
|
+
diffOpenState?: "not_applicable" | "opened" | "failed" | "unknown";
|
|
27
|
+
};
|
|
28
|
+
browserContext?: {
|
|
29
|
+
hadToastError?: boolean;
|
|
30
|
+
visiblePanel?: "chat" | "artifact" | "diff" | "unknown";
|
|
31
|
+
};
|
|
32
|
+
telemetryStatus: TelemetryStatus;
|
|
33
|
+
redactionVersion: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
}
|
|
36
|
+
export interface FeedbackRollup {
|
|
37
|
+
rollupId: string;
|
|
38
|
+
periodStart: string;
|
|
39
|
+
periodEnd: string;
|
|
40
|
+
total: number;
|
|
41
|
+
upCount: number;
|
|
42
|
+
downCount: number;
|
|
43
|
+
/** Down-vote reason → count. */
|
|
44
|
+
byReason: Record<string, number>;
|
|
45
|
+
byModel: Record<string, {
|
|
46
|
+
up: number;
|
|
47
|
+
down: number;
|
|
48
|
+
}>;
|
|
49
|
+
byAgentMode: Record<string, {
|
|
50
|
+
up: number;
|
|
51
|
+
down: number;
|
|
52
|
+
}>;
|
|
53
|
+
telemetryStatusCounts: {
|
|
54
|
+
complete: number;
|
|
55
|
+
partial: number;
|
|
56
|
+
missing: number;
|
|
57
|
+
};
|
|
58
|
+
redactionVersion: string;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
}
|
|
61
|
+
/** Truncate to the preview limit and scrub api keys / emails / absolute paths (§13). */
|
|
62
|
+
export declare function sanitizePreview(text: string): string;
|
|
63
|
+
/** Map a local feedback event to its upload-safe redacted form (§8.6/§13). */
|
|
64
|
+
export declare function redactFeedbackEvent(event: FeedbackEvent, redactionVersion?: string): RedactedFeedbackEvent;
|
|
65
|
+
/** Pre-aggregate a batch of local events into a rollup for low-cost trend upload (§10). */
|
|
66
|
+
export declare function aggregateFeedbackRollup(events: FeedbackEvent[], input: {
|
|
67
|
+
rollupId: string;
|
|
68
|
+
periodStart: string;
|
|
69
|
+
periodEnd: string;
|
|
70
|
+
redactionVersion?: string;
|
|
71
|
+
}): FeedbackRollup;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feedback upload client — the single HTTP exit that ships redacted feedback to the llmrouter
|
|
3
|
+
* feedback backend (design §8.6, §9.1 rule 4). The redaction worker calls this directly; the
|
|
4
|
+
* messageFeedback.uploadBatch RPC wraps it for manual/test triggers.
|
|
5
|
+
*
|
|
6
|
+
* Transport mirrors the usage client: append the route to the llmrouter base already injected into
|
|
7
|
+
* the agent (QLOGIC_LLMROUTER_BASE_URL, e.g. https://www.qlogicagent.com/api) and authenticate with
|
|
8
|
+
* the injected Bearer QLOGIC_LLMROUTER_ACCESS_TOKEN. Feedback lands at <base>/client/feedback, so a
|
|
9
|
+
* batch POSTs to <base>/client/feedback/uploadBatch — the contract the llmrouter ingest endpoint
|
|
10
|
+
* (Phase 3b) implements. No dedicated feedback env: one llmrouter base, like /client/usage.
|
|
11
|
+
*/
|
|
12
|
+
import type { FeedbackRollup, RedactedFeedbackEvent } from "./feedback-redaction.js";
|
|
13
|
+
export interface UploadBatchInput {
|
|
14
|
+
batchId: string;
|
|
15
|
+
events: RedactedFeedbackEvent[];
|
|
16
|
+
rollups: FeedbackRollup[];
|
|
17
|
+
redactionVersion: string;
|
|
18
|
+
clientBuild?: string;
|
|
19
|
+
runtimeVersion?: string;
|
|
20
|
+
qlogicagentVersion?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface UploadBatchResult {
|
|
23
|
+
ok: boolean;
|
|
24
|
+
accepted?: number;
|
|
25
|
+
status?: number;
|
|
26
|
+
error?: string;
|
|
27
|
+
refreshedToken?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the feedback ingest base, derived from the llmrouter base already injected into the agent
|
|
31
|
+
* (QLOGIC_LLMROUTER_BASE_URL), mirroring how the usage client reaches /client/usage. Returns
|
|
32
|
+
* undefined when llmrouter is not configured.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveFeedbackUploadBaseUrl(): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Ship one redacted batch to llmrouter. Fail-soft: an unconfigured base or a transport/HTTP error
|
|
37
|
+
* returns { ok: false }, so the caller (worker) keeps the events eligible and queues a retry rather
|
|
38
|
+
* than dropping feedback. Idempotent at the server by batchId + event id (§9.1 rule 5).
|
|
39
|
+
*/
|
|
40
|
+
export declare function uploadFeedbackBatch(input: UploadBatchInput, signal?: AbortSignal): Promise<UploadBatchResult>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface FeedbackSweepResult {
|
|
2
|
+
uploaded: number;
|
|
3
|
+
queued: number;
|
|
4
|
+
retried: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* One feedback upload sweep for a project. Retries due outbox batches, then redacts + ships any
|
|
8
|
+
* newly uploadable events. Fail-soft: a failed upload is queued in the outbox (its events assigned
|
|
9
|
+
* the batchId so they are not re-picked) and retried on a later sweep with backoff.
|
|
10
|
+
*/
|
|
11
|
+
export declare function runFeedbackUploadSweep(projectId: string, now?: Date): Promise<FeedbackSweepResult>;
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
* central-registry dependency for the storage key. Deleting a project = `rm` projectData/<id>/.
|
|
13
13
|
*/
|
|
14
14
|
export { getProjectDataDirById, getProjectDataRoot } from "./agent-paths.js";
|
|
15
|
-
/** `~/.qlogicagent/profiles/<owner>/projectData/<projectId>/`
|
|
16
|
-
export declare function getProjectDataDir(
|
|
15
|
+
/** `~/.qlogicagent/profiles/<owner>/projectData/<projectId>/` for a projectId or workspaceDir. */
|
|
16
|
+
export declare function getProjectDataDir(projectIdOrWorkspaceDir: string): string;
|
|
17
17
|
/** `projectData/<id>/sessions/` */
|
|
18
|
-
export declare function getProjectDataSessionsRoot(
|
|
18
|
+
export declare function getProjectDataSessionsRoot(projectIdOrWorkspaceDir: string): string;
|
|
19
19
|
/** `projectData/<id>/checkpoints/` or `.../checkpoints/<sessionId>` */
|
|
20
|
-
export declare function getProjectDataCheckpointsDir(
|
|
20
|
+
export declare function getProjectDataCheckpointsDir(projectIdOrWorkspaceDir: string, sessionId?: string): string;
|
|
21
21
|
/** `projectData/<id>/uploads/` or `.../uploads/<sessionId>` */
|
|
22
|
-
export declare function getProjectDataUploadsDir(
|
|
22
|
+
export declare function getProjectDataUploadsDir(projectIdOrWorkspaceDir: string, sessionId?: string): string;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export type TurnBaselineState = "running" | "completed" | "failed" | "cancelled";
|
|
2
|
+
export type FileChangeStatus = "added" | "modified" | "deleted" | "renamed" | "moved" | "copied" | "unchanged";
|
|
3
|
+
export type SnapshotKind = "missing" | "text" | "binary" | "directory" | "too-large";
|
|
4
|
+
export interface FileSnapshot {
|
|
5
|
+
exists: boolean;
|
|
6
|
+
kind: SnapshotKind;
|
|
7
|
+
sizeBytes?: number;
|
|
8
|
+
sha256?: string;
|
|
9
|
+
inlineContent?: string;
|
|
10
|
+
contentRef?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TurnFileChange {
|
|
13
|
+
path: string;
|
|
14
|
+
previousPath?: string;
|
|
15
|
+
status: FileChangeStatus;
|
|
16
|
+
additions?: number;
|
|
17
|
+
deletions?: number;
|
|
18
|
+
before?: FileSnapshot;
|
|
19
|
+
after?: FileSnapshot;
|
|
20
|
+
}
|
|
21
|
+
export interface TurnChangeSummary {
|
|
22
|
+
turnId: string;
|
|
23
|
+
sessionId: string;
|
|
24
|
+
projectId: string;
|
|
25
|
+
state: TurnBaselineState;
|
|
26
|
+
startedAt: string;
|
|
27
|
+
completedAt?: string;
|
|
28
|
+
filesChanged: number;
|
|
29
|
+
files: TurnFileChange[];
|
|
30
|
+
truncated?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare function resolveProjectRelativePath(projectRoot: string, input: string): string | null;
|
|
33
|
+
export declare function startTurnBaseline(input: {
|
|
34
|
+
turnId: string;
|
|
35
|
+
sessionId: string;
|
|
36
|
+
projectId?: string;
|
|
37
|
+
workspaceDir?: string;
|
|
38
|
+
seedPaths?: unknown;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
export declare function captureFileBefore(input: {
|
|
41
|
+
turnId?: string;
|
|
42
|
+
projectId?: string;
|
|
43
|
+
workspaceDir?: string;
|
|
44
|
+
path: string;
|
|
45
|
+
entryPath?: string;
|
|
46
|
+
previousPath?: string;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
export declare function captureFileAfter(input: {
|
|
49
|
+
turnId?: string;
|
|
50
|
+
projectId?: string;
|
|
51
|
+
workspaceDir?: string;
|
|
52
|
+
path: string;
|
|
53
|
+
entryPath?: string;
|
|
54
|
+
previousPath?: string;
|
|
55
|
+
status?: FileChangeStatus;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
export declare function captureAbsoluteBefore(input: {
|
|
58
|
+
turnId?: string;
|
|
59
|
+
workspaceDir: string;
|
|
60
|
+
absolutePath: string;
|
|
61
|
+
}): Promise<void>;
|
|
62
|
+
export declare function captureAbsoluteAfter(input: {
|
|
63
|
+
turnId?: string;
|
|
64
|
+
workspaceDir: string;
|
|
65
|
+
absolutePath: string;
|
|
66
|
+
status?: FileChangeStatus;
|
|
67
|
+
}): Promise<void>;
|
|
68
|
+
export declare function finalizeTurnBaseline(input: {
|
|
69
|
+
turnId: string;
|
|
70
|
+
state: TurnBaselineState;
|
|
71
|
+
}): Promise<TurnChangeSummary | null>;
|
|
72
|
+
export declare function getTurnBaselineSummary(projectId: string, turnId: string): Promise<TurnChangeSummary | null>;
|
|
73
|
+
export declare function listRecentTurnBaselines(input: {
|
|
74
|
+
projectId: string;
|
|
75
|
+
sessionId?: string;
|
|
76
|
+
limit?: number;
|
|
77
|
+
}): Promise<{
|
|
78
|
+
summaries: TurnChangeSummary[];
|
|
79
|
+
}>;
|
|
80
|
+
export declare function getTurnBaselineFileBaseline(input: {
|
|
81
|
+
projectId: string;
|
|
82
|
+
turnId: string;
|
|
83
|
+
path: string;
|
|
84
|
+
}): Promise<{
|
|
85
|
+
path: string;
|
|
86
|
+
content: string | null;
|
|
87
|
+
snapshot: FileSnapshot | null;
|
|
88
|
+
}>;
|
|
89
|
+
export declare function getTurnBaselineFileDiff(input: {
|
|
90
|
+
projectId: string;
|
|
91
|
+
turnId: string;
|
|
92
|
+
path: string;
|
|
93
|
+
}): Promise<{
|
|
94
|
+
path: string;
|
|
95
|
+
previousPath?: string;
|
|
96
|
+
status: FileChangeStatus;
|
|
97
|
+
original: string;
|
|
98
|
+
modified: string;
|
|
99
|
+
language?: string;
|
|
100
|
+
additions?: number;
|
|
101
|
+
deletions?: number;
|
|
102
|
+
}>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type AgentMode = "chat" | "solo" | "product" | "workflow" | "unknown";
|
|
2
|
+
export interface TurnTelemetryUsage {
|
|
3
|
+
inputTokens?: number;
|
|
4
|
+
outputTokens?: number;
|
|
5
|
+
totalTokens?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TurnTelemetryToolSummary {
|
|
8
|
+
calledTools: string[];
|
|
9
|
+
failedTools: string[];
|
|
10
|
+
blockedTools: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface TurnTelemetryFileContext {
|
|
13
|
+
changedFileCount?: number;
|
|
14
|
+
changedPathsPreview?: string[];
|
|
15
|
+
hasTurnFileChanges?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface TurnTelemetrySnapshot {
|
|
18
|
+
turnId: string;
|
|
19
|
+
sessionId: string;
|
|
20
|
+
projectId?: string;
|
|
21
|
+
/** Gateway-stamped alias; v1 MUST equal turnId (design §7.3). Set at finalize. */
|
|
22
|
+
assistantMessageId?: string;
|
|
23
|
+
model?: string;
|
|
24
|
+
provider?: string;
|
|
25
|
+
agentMode?: AgentMode;
|
|
26
|
+
sourceChannel?: string;
|
|
27
|
+
usage?: TurnTelemetryUsage;
|
|
28
|
+
toolSummary?: TurnTelemetryToolSummary;
|
|
29
|
+
fileContext?: TurnTelemetryFileContext;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
finalizedAt?: string;
|
|
32
|
+
}
|
|
33
|
+
/** Fields that can be merged into a turn's telemetry record as the turn progresses. */
|
|
34
|
+
export type TurnTelemetryPatch = Partial<Omit<TurnTelemetrySnapshot, "turnId" | "createdAt" | "finalizedAt" | "assistantMessageId">>;
|
|
35
|
+
/**
|
|
36
|
+
* Merge a telemetry fragment into the in-memory record for a turn. Pieces (tool summary,
|
|
37
|
+
* usage/model, file context) arrive at different points in the pipeline and upsert into the
|
|
38
|
+
* same turnId record. Safe to call before the projectId is known; the first call seeds it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function recordTurnTelemetry(turnId: string, patch: TurnTelemetryPatch): void;
|
|
41
|
+
/**
|
|
42
|
+
* Flush the accumulated telemetry for a turn to disk and drop it from memory. Returns null
|
|
43
|
+
* (after dropping the in-memory record) when no projectId resolved — telemetry, like the turn
|
|
44
|
+
* baseline, is only persisted for turns that belong to a registered project.
|
|
45
|
+
*/
|
|
46
|
+
export declare function finalizeTurnTelemetry(input: {
|
|
47
|
+
turnId: string;
|
|
48
|
+
projectId?: string;
|
|
49
|
+
}): Promise<TurnTelemetrySnapshot | null>;
|
|
50
|
+
export declare function getTurnTelemetryRecord(projectId: string, turnId: string): Promise<TurnTelemetrySnapshot | null>;
|
|
51
|
+
export declare function listTurnTelemetryBySession(input: {
|
|
52
|
+
projectId: string;
|
|
53
|
+
sessionId?: string;
|
|
54
|
+
limit?: number;
|
|
55
|
+
}): Promise<{
|
|
56
|
+
records: TurnTelemetrySnapshot[];
|
|
57
|
+
}>;
|
|
58
|
+
/** Test/maintenance helper: drop any in-memory telemetry not yet finalized. */
|
|
59
|
+
export declare function __resetActiveTurnTelemetryForTest(): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type WorkingMaterialKind = "workspace" | "instructions" | "generated" | "url";
|
|
2
|
+
export interface WorkingMaterialItem {
|
|
3
|
+
id: string;
|
|
4
|
+
projectId: string;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
sourceKind: WorkingMaterialKind;
|
|
7
|
+
path?: string;
|
|
8
|
+
title: string;
|
|
9
|
+
viewerHint?: string;
|
|
10
|
+
pinned: boolean;
|
|
11
|
+
order: number;
|
|
12
|
+
addedAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
missing?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function getWorkingMaterials(projectId: string, sessionId: string): Promise<{
|
|
17
|
+
items: WorkingMaterialItem[];
|
|
18
|
+
missing: WorkingMaterialItem[];
|
|
19
|
+
}>;
|
|
20
|
+
export declare function replaceWorkingMaterials(projectId: string, sessionId: string, items: unknown[]): Promise<{
|
|
21
|
+
ok: true;
|
|
22
|
+
items: WorkingMaterialItem[];
|
|
23
|
+
}>;
|
|
24
|
+
export declare function upsertWorkingMaterial(projectId: string, sessionId: string, item: unknown): Promise<{
|
|
25
|
+
ok: true;
|
|
26
|
+
items: WorkingMaterialItem[];
|
|
27
|
+
}>;
|
|
28
|
+
export declare function removeWorkingMaterial(projectId: string, sessionId: string, id: string): Promise<{
|
|
29
|
+
ok: true;
|
|
30
|
+
items: WorkingMaterialItem[];
|
|
31
|
+
}>;
|
|
32
|
+
export declare function reorderWorkingMaterials(projectId: string, sessionId: string, ids: string[]): Promise<{
|
|
33
|
+
ok: true;
|
|
34
|
+
items: WorkingMaterialItem[];
|
|
35
|
+
}>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Daily journey summarizer — orchestrates the day's local-work summary:
|
|
3
|
+
* aggregate → deterministic stats → pet-voice prompt → LLM narrative → JourneySnapshot.
|
|
4
|
+
*
|
|
5
|
+
* IO (aggregation, soul, LLM) is injected so this stays unit-testable. The LLM call
|
|
6
|
+
* signature is declared locally (not imported from cli/pet-runtime) to keep the
|
|
7
|
+
* runtime layer free of a cli dependency; the caller passes petRuntime.createSmallLLMCall().
|
|
8
|
+
* If the LLM is unavailable or fails, a deterministic templated narrative is used so the
|
|
9
|
+
* journey always renders.
|
|
10
|
+
*/
|
|
11
|
+
import type { PetSoul } from "./pet-types.js";
|
|
12
|
+
import type { DayDigest } from "./journey-day-aggregator.js";
|
|
13
|
+
import type { JourneySnapshot } from "./pet-profile-service.js";
|
|
14
|
+
export type JourneyLlmCall = (prompt: string, maxTokens: number) => Promise<string | null>;
|
|
15
|
+
export interface SummarizeDayOptions {
|
|
16
|
+
date: string;
|
|
17
|
+
petName: string;
|
|
18
|
+
aggregate: () => Promise<DayDigest>;
|
|
19
|
+
resolveSoul: () => PetSoul | null;
|
|
20
|
+
llmCall: JourneyLlmCall | undefined;
|
|
21
|
+
generator?: "auto" | "manual";
|
|
22
|
+
/** Injectable clock (ISO) for deterministic tests. */
|
|
23
|
+
now?: () => string;
|
|
24
|
+
}
|
|
25
|
+
export declare function summarizeDay(opts: SummarizeDayOptions): Promise<JourneySnapshot | null>;
|
|
@@ -12,7 +12,8 @@ export type { PetdexAnimationId, PetdexValidationReport } from "@xiaozhiclaw/pet
|
|
|
12
12
|
export type { ReactionPool, LLMReactionContext, ReactionStyle } from "@xiaozhiclaw/pet-core";
|
|
13
13
|
export { PetSoulService } from "./pet-soul-service.js";
|
|
14
14
|
export { petReactionEngine } from "./pet-reaction-engine.js";
|
|
15
|
-
export { PetProfileService, type PetProfile, type PetPreferences, type PetdexPetAsset, type PetdexPetAssetSummary, type JourneySnapshot } from "./pet-profile-service.js";
|
|
15
|
+
export { PetProfileService, type PetProfile, type PetPreferences, type PetdexPetAsset, type PetdexPetAssetSummary, type JourneySnapshot, type JourneyStats } from "./pet-profile-service.js";
|
|
16
|
+
export { catchUpJourney, readTurnTelemetryDir, type CatchUpJourneyOptions } from "./journey-catchup.js";
|
|
16
17
|
export { createPetdexAssetFromSpritesheet, listBuiltinPetdexAssetIds, listBuiltinPetdexAssets, writePetdexAssetPackage } from "./petdex-asset.js";
|
|
17
18
|
export { forgePetdexAsset, forgePetdexAssetPackage, readGeneratedPetdexImage } from "./petdex-forge-service.js";
|
|
18
19
|
export { loadPetFile, validatePetManifest, type PetManifest, type PetFileBundle } from "./pet-file-loader.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TurnTelemetrySnapshot } from "../infra/turn-telemetry-store.js";
|
|
2
|
+
import { type JourneyLlmCall } from "./daily-journey-summarizer.js";
|
|
3
|
+
/** All persisted turn-telemetry records for one project (best-effort; missing/corrupt → skip). */
|
|
4
|
+
export declare function readTurnTelemetryDir(projectId: string): TurnTelemetrySnapshot[];
|
|
5
|
+
export interface CatchUpJourneyOptions {
|
|
6
|
+
/** Look-back window of completed days (default 7, capped at retention). */
|
|
7
|
+
maxDays?: number;
|
|
8
|
+
generator?: "auto" | "manual";
|
|
9
|
+
llmCall: JourneyLlmCall | undefined;
|
|
10
|
+
listProjectIds: () => string[];
|
|
11
|
+
log?: (message: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/** Backfill missing completed-day journey snapshots. Returns the dates generated this run. */
|
|
14
|
+
export declare function catchUpJourney(ownerUserId: string, opts: CatchUpJourneyOptions): Promise<string[]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Journey day aggregator — collapses a day's turn telemetry (across all of an owner's
|
|
3
|
+
* projects) into a deterministic DayDigest. IO is injected (project list + per-project
|
|
4
|
+
* telemetry reader) so this stays pure and unit-testable; the caller wires the real
|
|
5
|
+
* project store + filesystem reader.
|
|
6
|
+
*
|
|
7
|
+
* Stats are computed here deterministically (never by an LLM) so the journey never
|
|
8
|
+
* shows invented numbers — the LLM only writes the narrative prose from these facts.
|
|
9
|
+
*/
|
|
10
|
+
import type { TurnTelemetrySnapshot } from "../infra/turn-telemetry-store.js";
|
|
11
|
+
export interface DayDigest {
|
|
12
|
+
date: string;
|
|
13
|
+
turns: number;
|
|
14
|
+
filesChanged: number;
|
|
15
|
+
toolsUsed: string[];
|
|
16
|
+
projects: string[];
|
|
17
|
+
models: string[];
|
|
18
|
+
modes: Record<string, number>;
|
|
19
|
+
topChangedPaths: string[];
|
|
20
|
+
}
|
|
21
|
+
export interface JourneyDayDeps {
|
|
22
|
+
/** All registered project ids for the owner. */
|
|
23
|
+
listProjectIds(): string[];
|
|
24
|
+
/** All persisted turn-telemetry records for one project (any date). */
|
|
25
|
+
readProjectTurns(projectId: string): Promise<TurnTelemetrySnapshot[]>;
|
|
26
|
+
}
|
|
27
|
+
export declare function aggregateOwnerDay(date: string, deps: JourneyDayDeps): Promise<DayDigest>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Journey narrative prompt — composes the pet-voice prompt from the pet's soul + the
|
|
3
|
+
* day's deterministic digest. Pure/testable. The LLM only writes prose from these facts;
|
|
4
|
+
* it is explicitly told not to invent numbers, file names, or events.
|
|
5
|
+
*/
|
|
6
|
+
import type { PetSoul } from "./pet-types.js";
|
|
7
|
+
import type { DayDigest } from "./journey-day-aggregator.js";
|
|
8
|
+
export declare function buildNarrativePrompt(soul: PetSoul | null, digest: DayDigest): string;
|
|
@@ -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
|
-
|
|
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;
|