mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
Add feedback voting and thumbs capture flow
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
3db6bdfc3c
commit
c0d0d03bce
66 changed files with 18988 additions and 78 deletions
70
packages/db/src/migrations/0047_overjoyed_groot.sql
Normal file
70
packages/db/src/migrations/0047_overjoyed_groot.sql
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
CREATE TABLE "feedback_exports" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"company_id" uuid NOT NULL,
|
||||
"feedback_vote_id" uuid NOT NULL,
|
||||
"issue_id" uuid NOT NULL,
|
||||
"project_id" uuid,
|
||||
"author_user_id" text NOT NULL,
|
||||
"target_type" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"vote" text NOT NULL,
|
||||
"status" text DEFAULT 'local_only' NOT NULL,
|
||||
"destination" text,
|
||||
"export_id" text,
|
||||
"consent_version" text,
|
||||
"schema_version" text DEFAULT 'paperclip-feedback-envelope-v2' NOT NULL,
|
||||
"bundle_version" text DEFAULT 'paperclip-feedback-bundle-v2' NOT NULL,
|
||||
"payload_version" text DEFAULT 'paperclip-feedback-v1' NOT NULL,
|
||||
"payload_digest" text,
|
||||
"payload_snapshot" jsonb,
|
||||
"target_summary" jsonb NOT NULL,
|
||||
"redaction_summary" jsonb,
|
||||
"attempt_count" integer DEFAULT 0 NOT NULL,
|
||||
"last_attempted_at" timestamp with time zone,
|
||||
"exported_at" timestamp with time zone,
|
||||
"failure_reason" text,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "feedback_votes" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"company_id" uuid NOT NULL,
|
||||
"issue_id" uuid NOT NULL,
|
||||
"target_type" text NOT NULL,
|
||||
"target_id" text NOT NULL,
|
||||
"author_user_id" text NOT NULL,
|
||||
"vote" text NOT NULL,
|
||||
"reason" text,
|
||||
"shared_with_labs" boolean DEFAULT false NOT NULL,
|
||||
"shared_at" timestamp with time zone,
|
||||
"consent_version" text,
|
||||
"redaction_summary" jsonb,
|
||||
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
||||
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "companies" ADD COLUMN "feedback_data_sharing_enabled" boolean DEFAULT false NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "companies" ADD COLUMN "feedback_data_sharing_consent_at" timestamp with time zone;--> statement-breakpoint
|
||||
ALTER TABLE "companies" ADD COLUMN "feedback_data_sharing_consent_by_user_id" text;--> statement-breakpoint
|
||||
ALTER TABLE "companies" ADD COLUMN "feedback_data_sharing_terms_version" text;--> statement-breakpoint
|
||||
ALTER TABLE "document_revisions" ADD COLUMN "created_by_run_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "issue_comments" ADD COLUMN "created_by_run_id" uuid;--> statement-breakpoint
|
||||
ALTER TABLE "feedback_exports" ADD CONSTRAINT "feedback_exports_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "feedback_exports" ADD CONSTRAINT "feedback_exports_feedback_vote_id_feedback_votes_id_fk" FOREIGN KEY ("feedback_vote_id") REFERENCES "public"."feedback_votes"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "feedback_exports" ADD CONSTRAINT "feedback_exports_issue_id_issues_id_fk" FOREIGN KEY ("issue_id") REFERENCES "public"."issues"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "feedback_exports" ADD CONSTRAINT "feedback_exports_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "feedback_votes" ADD CONSTRAINT "feedback_votes_company_id_companies_id_fk" FOREIGN KEY ("company_id") REFERENCES "public"."companies"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "feedback_votes" ADD CONSTRAINT "feedback_votes_issue_id_issues_id_fk" FOREIGN KEY ("issue_id") REFERENCES "public"."issues"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "feedback_exports_feedback_vote_idx" ON "feedback_exports" USING btree ("feedback_vote_id");--> statement-breakpoint
|
||||
CREATE INDEX "feedback_exports_company_created_idx" ON "feedback_exports" USING btree ("company_id","created_at");--> statement-breakpoint
|
||||
CREATE INDEX "feedback_exports_company_status_idx" ON "feedback_exports" USING btree ("company_id","status","created_at");--> statement-breakpoint
|
||||
CREATE INDEX "feedback_exports_company_issue_idx" ON "feedback_exports" USING btree ("company_id","issue_id","created_at");--> statement-breakpoint
|
||||
CREATE INDEX "feedback_exports_company_project_idx" ON "feedback_exports" USING btree ("company_id","project_id","created_at");--> statement-breakpoint
|
||||
CREATE INDEX "feedback_exports_company_author_idx" ON "feedback_exports" USING btree ("company_id","author_user_id","created_at");--> statement-breakpoint
|
||||
CREATE INDEX "feedback_votes_company_issue_idx" ON "feedback_votes" USING btree ("company_id","issue_id");--> statement-breakpoint
|
||||
CREATE INDEX "feedback_votes_issue_target_idx" ON "feedback_votes" USING btree ("issue_id","target_type","target_id");--> statement-breakpoint
|
||||
CREATE INDEX "feedback_votes_author_idx" ON "feedback_votes" USING btree ("author_user_id","created_at");--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "feedback_votes_company_target_author_idx" ON "feedback_votes" USING btree ("company_id","target_type","target_id","author_user_id");--> statement-breakpoint
|
||||
ALTER TABLE "document_revisions" ADD CONSTRAINT "document_revisions_created_by_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("created_by_run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
||||
ALTER TABLE "issue_comments" ADD CONSTRAINT "issue_comments_created_by_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("created_by_run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE set null ON UPDATE no action;
|
||||
12539
packages/db/src/migrations/meta/0047_snapshot.json
Normal file
12539
packages/db/src/migrations/meta/0047_snapshot.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -330,6 +330,13 @@
|
|||
"when": 1774960197878,
|
||||
"tag": "0046_smooth_sentinels",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 47,
|
||||
"version": "7",
|
||||
"when": 1775137972687,
|
||||
"tag": "0047_overjoyed_groot",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -16,6 +16,12 @@ export const companies = pgTable(
|
|||
requireBoardApprovalForNewAgents: boolean("require_board_approval_for_new_agents")
|
||||
.notNull()
|
||||
.default(true),
|
||||
feedbackDataSharingEnabled: boolean("feedback_data_sharing_enabled")
|
||||
.notNull()
|
||||
.default(false),
|
||||
feedbackDataSharingConsentAt: timestamp("feedback_data_sharing_consent_at", { withTimezone: true }),
|
||||
feedbackDataSharingConsentByUserId: text("feedback_data_sharing_consent_by_user_id"),
|
||||
feedbackDataSharingTermsVersion: text("feedback_data_sharing_terms_version"),
|
||||
brandColor: text("brand_color"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { pgTable, uuid, text, integer, timestamp, index, uniqueIndex } from "dri
|
|||
import { companies } from "./companies.js";
|
||||
import { agents } from "./agents.js";
|
||||
import { documents } from "./documents.js";
|
||||
import { heartbeatRuns } from "./heartbeat_runs.js";
|
||||
|
||||
export const documentRevisions = pgTable(
|
||||
"document_revisions",
|
||||
|
|
@ -16,6 +17,7 @@ export const documentRevisions = pgTable(
|
|||
changeSummary: text("change_summary"),
|
||||
createdByAgentId: uuid("created_by_agent_id").references(() => agents.id, { onDelete: "set null" }),
|
||||
createdByUserId: text("created_by_user_id"),
|
||||
createdByRunId: uuid("created_by_run_id").references(() => heartbeatRuns.id, { onDelete: "set null" }),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
|
|
|
|||
45
packages/db/src/schema/feedback_exports.ts
Normal file
45
packages/db/src/schema/feedback_exports.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { index, integer, jsonb, pgTable, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
|
||||
import { companies } from "./companies.js";
|
||||
import { feedbackVotes } from "./feedback_votes.js";
|
||||
import { issues } from "./issues.js";
|
||||
import { projects } from "./projects.js";
|
||||
|
||||
export const feedbackExports = pgTable(
|
||||
"feedback_exports",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
companyId: uuid("company_id").notNull().references(() => companies.id),
|
||||
feedbackVoteId: uuid("feedback_vote_id").notNull().references(() => feedbackVotes.id, { onDelete: "cascade" }),
|
||||
issueId: uuid("issue_id").notNull().references(() => issues.id, { onDelete: "cascade" }),
|
||||
projectId: uuid("project_id").references(() => projects.id, { onDelete: "set null" }),
|
||||
authorUserId: text("author_user_id").notNull(),
|
||||
targetType: text("target_type").notNull(),
|
||||
targetId: text("target_id").notNull(),
|
||||
vote: text("vote").notNull(),
|
||||
status: text("status").notNull().default("local_only"),
|
||||
destination: text("destination"),
|
||||
exportId: text("export_id"),
|
||||
consentVersion: text("consent_version"),
|
||||
schemaVersion: text("schema_version").notNull().default("paperclip-feedback-envelope-v2"),
|
||||
bundleVersion: text("bundle_version").notNull().default("paperclip-feedback-bundle-v2"),
|
||||
payloadVersion: text("payload_version").notNull().default("paperclip-feedback-v1"),
|
||||
payloadDigest: text("payload_digest"),
|
||||
payloadSnapshot: jsonb("payload_snapshot"),
|
||||
targetSummary: jsonb("target_summary").notNull(),
|
||||
redactionSummary: jsonb("redaction_summary"),
|
||||
attemptCount: integer("attempt_count").notNull().default(0),
|
||||
lastAttemptedAt: timestamp("last_attempted_at", { withTimezone: true }),
|
||||
exportedAt: timestamp("exported_at", { withTimezone: true }),
|
||||
failureReason: text("failure_reason"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
voteUniqueIdx: uniqueIndex("feedback_exports_feedback_vote_idx").on(table.feedbackVoteId),
|
||||
companyCreatedIdx: index("feedback_exports_company_created_idx").on(table.companyId, table.createdAt),
|
||||
companyStatusIdx: index("feedback_exports_company_status_idx").on(table.companyId, table.status, table.createdAt),
|
||||
companyIssueIdx: index("feedback_exports_company_issue_idx").on(table.companyId, table.issueId, table.createdAt),
|
||||
companyProjectIdx: index("feedback_exports_company_project_idx").on(table.companyId, table.projectId, table.createdAt),
|
||||
companyAuthorIdx: index("feedback_exports_company_author_idx").on(table.companyId, table.authorUserId, table.createdAt),
|
||||
}),
|
||||
);
|
||||
34
packages/db/src/schema/feedback_votes.ts
Normal file
34
packages/db/src/schema/feedback_votes.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { boolean, index, jsonb, pgTable, text, timestamp, uniqueIndex, uuid } from "drizzle-orm/pg-core";
|
||||
import { companies } from "./companies.js";
|
||||
import { issues } from "./issues.js";
|
||||
|
||||
export const feedbackVotes = pgTable(
|
||||
"feedback_votes",
|
||||
{
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
companyId: uuid("company_id").notNull().references(() => companies.id),
|
||||
issueId: uuid("issue_id").notNull().references(() => issues.id),
|
||||
targetType: text("target_type").notNull(),
|
||||
targetId: text("target_id").notNull(),
|
||||
authorUserId: text("author_user_id").notNull(),
|
||||
vote: text("vote").notNull(),
|
||||
reason: text("reason"),
|
||||
sharedWithLabs: boolean("shared_with_labs").notNull().default(false),
|
||||
sharedAt: timestamp("shared_at", { withTimezone: true }),
|
||||
consentVersion: text("consent_version"),
|
||||
redactionSummary: jsonb("redaction_summary"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
},
|
||||
(table) => ({
|
||||
companyIssueIdx: index("feedback_votes_company_issue_idx").on(table.companyId, table.issueId),
|
||||
issueTargetIdx: index("feedback_votes_issue_target_idx").on(table.issueId, table.targetType, table.targetId),
|
||||
authorIdx: index("feedback_votes_author_idx").on(table.authorUserId, table.createdAt),
|
||||
companyTargetAuthorUniqueIdx: uniqueIndex("feedback_votes_company_target_author_idx").on(
|
||||
table.companyId,
|
||||
table.targetType,
|
||||
table.targetId,
|
||||
table.authorUserId,
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
|
@ -32,6 +32,8 @@ export { issueLabels } from "./issue_labels.js";
|
|||
export { issueApprovals } from "./issue_approvals.js";
|
||||
export { issueComments } from "./issue_comments.js";
|
||||
export { issueInboxArchives } from "./issue_inbox_archives.js";
|
||||
export { feedbackVotes } from "./feedback_votes.js";
|
||||
export { feedbackExports } from "./feedback_exports.js";
|
||||
export { issueReadStates } from "./issue_read_states.js";
|
||||
export { assets } from "./assets.js";
|
||||
export { issueAttachments } from "./issue_attachments.js";
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { pgTable, uuid, text, timestamp, index } from "drizzle-orm/pg-core";
|
|||
import { companies } from "./companies.js";
|
||||
import { issues } from "./issues.js";
|
||||
import { agents } from "./agents.js";
|
||||
import { heartbeatRuns } from "./heartbeat_runs.js";
|
||||
|
||||
export const issueComments = pgTable(
|
||||
"issue_comments",
|
||||
|
|
@ -11,6 +12,7 @@ export const issueComments = pgTable(
|
|||
issueId: uuid("issue_id").notNull().references(() => issues.id),
|
||||
authorAgentId: uuid("author_agent_id").references(() => agents.id),
|
||||
authorUserId: text("author_user_id"),
|
||||
createdByRunId: uuid("created_by_run_id").references(() => heartbeatRuns.id, { onDelete: "set null" }),
|
||||
body: text("body").notNull(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
|
|
|
|||
|
|
@ -138,6 +138,16 @@ export {
|
|||
|
||||
export type {
|
||||
Company,
|
||||
FeedbackVote,
|
||||
FeedbackDataSharingPreference,
|
||||
FeedbackTargetType,
|
||||
FeedbackVoteValue,
|
||||
FeedbackTrace,
|
||||
FeedbackTraceStatus,
|
||||
FeedbackTraceTargetSummary,
|
||||
FeedbackTraceBundleCaptureStatus,
|
||||
FeedbackTraceBundleFile,
|
||||
FeedbackTraceBundle,
|
||||
CompanySkillSourceType,
|
||||
CompanySkillTrustLevel,
|
||||
CompanySkillCompatibility,
|
||||
|
|
@ -325,6 +335,15 @@ export type {
|
|||
ProviderQuotaResult,
|
||||
} from "./types/index.js";
|
||||
|
||||
export {
|
||||
DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE,
|
||||
FEEDBACK_TARGET_TYPES,
|
||||
FEEDBACK_DATA_SHARING_PREFERENCES,
|
||||
FEEDBACK_TRACE_STATUSES,
|
||||
FEEDBACK_VOTE_VALUES,
|
||||
DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION,
|
||||
} from "./types/feedback.js";
|
||||
|
||||
export {
|
||||
instanceGeneralSettingsSchema,
|
||||
patchInstanceGeneralSettingsSchema,
|
||||
|
|
@ -338,9 +357,14 @@ export {
|
|||
createCompanySchema,
|
||||
updateCompanySchema,
|
||||
updateCompanyBrandingSchema,
|
||||
feedbackTargetTypeSchema,
|
||||
feedbackTraceStatusSchema,
|
||||
feedbackVoteValueSchema,
|
||||
upsertIssueFeedbackVoteSchema,
|
||||
type CreateCompany,
|
||||
type UpdateCompany,
|
||||
type UpdateCompanyBranding,
|
||||
type UpsertIssueFeedbackVote,
|
||||
agentSkillStateSchema,
|
||||
agentSkillSyncModeSchema,
|
||||
agentSkillEntrySchema,
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ export interface CompanyPortabilityCompanyManifestEntry {
|
|||
brandColor: string | null;
|
||||
logoPath: string | null;
|
||||
requireBoardApprovalForNewAgents: boolean;
|
||||
feedbackDataSharingEnabled: boolean;
|
||||
feedbackDataSharingConsentAt: string | null;
|
||||
feedbackDataSharingConsentByUserId: string | null;
|
||||
feedbackDataSharingTermsVersion: string | null;
|
||||
}
|
||||
|
||||
export interface CompanyPortabilitySidebarOrder {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ export interface Company {
|
|||
budgetMonthlyCents: number;
|
||||
spentMonthlyCents: number;
|
||||
requireBoardApprovalForNewAgents: boolean;
|
||||
feedbackDataSharingEnabled: boolean;
|
||||
feedbackDataSharingConsentAt: Date | null;
|
||||
feedbackDataSharingConsentByUserId: string | null;
|
||||
feedbackDataSharingTermsVersion: string | null;
|
||||
brandColor: string | null;
|
||||
logoAssetId: string | null;
|
||||
logoUrl: string | null;
|
||||
|
|
|
|||
120
packages/shared/src/types/feedback.ts
Normal file
120
packages/shared/src/types/feedback.ts
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
export const FEEDBACK_TARGET_TYPES = ["issue_comment", "issue_document_revision"] as const;
|
||||
export type FeedbackTargetType = (typeof FEEDBACK_TARGET_TYPES)[number];
|
||||
|
||||
export const FEEDBACK_VOTE_VALUES = ["up", "down"] as const;
|
||||
export type FeedbackVoteValue = (typeof FEEDBACK_VOTE_VALUES)[number];
|
||||
|
||||
export const FEEDBACK_DATA_SHARING_PREFERENCES = ["allowed", "not_allowed", "prompt"] as const;
|
||||
export type FeedbackDataSharingPreference = (typeof FEEDBACK_DATA_SHARING_PREFERENCES)[number];
|
||||
|
||||
export const DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE: FeedbackDataSharingPreference = "prompt";
|
||||
|
||||
export const FEEDBACK_TRACE_STATUSES = ["local_only", "pending", "sent", "failed"] as const;
|
||||
export type FeedbackTraceStatus = (typeof FEEDBACK_TRACE_STATUSES)[number];
|
||||
|
||||
export const DEFAULT_FEEDBACK_DATA_SHARING_TERMS_VERSION = "feedback-data-sharing-v1";
|
||||
|
||||
export interface FeedbackVote {
|
||||
id: string;
|
||||
companyId: string;
|
||||
issueId: string;
|
||||
targetType: FeedbackTargetType;
|
||||
targetId: string;
|
||||
authorUserId: string;
|
||||
vote: FeedbackVoteValue;
|
||||
reason: string | null;
|
||||
sharedWithLabs: boolean;
|
||||
sharedAt: Date | null;
|
||||
consentVersion: string | null;
|
||||
redactionSummary: Record<string, unknown> | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export interface FeedbackTraceTargetSummary {
|
||||
label: string;
|
||||
excerpt: string | null;
|
||||
authorAgentId: string | null;
|
||||
authorUserId: string | null;
|
||||
createdAt: Date | null;
|
||||
documentKey: string | null;
|
||||
documentTitle: string | null;
|
||||
revisionNumber: number | null;
|
||||
}
|
||||
|
||||
export interface FeedbackTrace {
|
||||
id: string;
|
||||
companyId: string;
|
||||
feedbackVoteId: string;
|
||||
issueId: string;
|
||||
projectId: string | null;
|
||||
issueIdentifier: string | null;
|
||||
issueTitle: string;
|
||||
authorUserId: string;
|
||||
targetType: FeedbackTargetType;
|
||||
targetId: string;
|
||||
vote: FeedbackVoteValue;
|
||||
status: FeedbackTraceStatus;
|
||||
destination: string | null;
|
||||
exportId: string | null;
|
||||
consentVersion: string | null;
|
||||
schemaVersion: string;
|
||||
bundleVersion: string;
|
||||
payloadVersion: string;
|
||||
payloadDigest: string | null;
|
||||
payloadSnapshot: Record<string, unknown> | null;
|
||||
targetSummary: FeedbackTraceTargetSummary;
|
||||
redactionSummary: Record<string, unknown> | null;
|
||||
attemptCount: number;
|
||||
lastAttemptedAt: Date | null;
|
||||
exportedAt: Date | null;
|
||||
failureReason: string | null;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export type FeedbackTraceBundleCaptureStatus = "full" | "partial" | "unavailable";
|
||||
|
||||
export interface FeedbackTraceBundleFile {
|
||||
path: string;
|
||||
contentType: string;
|
||||
encoding: "utf8";
|
||||
byteLength: number;
|
||||
sha256: string;
|
||||
source:
|
||||
| "paperclip_run"
|
||||
| "paperclip_run_events"
|
||||
| "paperclip_run_log"
|
||||
| "codex_session"
|
||||
| "claude_stream_json"
|
||||
| "claude_project_session"
|
||||
| "claude_project_artifact"
|
||||
| "claude_debug_log"
|
||||
| "claude_task_metadata"
|
||||
| "opencode_session"
|
||||
| "opencode_session_diff"
|
||||
| "opencode_message"
|
||||
| "opencode_message_part"
|
||||
| "opencode_project"
|
||||
| "opencode_todo";
|
||||
contents: string;
|
||||
}
|
||||
|
||||
export interface FeedbackTraceBundle {
|
||||
traceId: string;
|
||||
exportId: string | null;
|
||||
companyId: string;
|
||||
issueId: string;
|
||||
issueIdentifier: string | null;
|
||||
adapterType: string | null;
|
||||
captureStatus: FeedbackTraceBundleCaptureStatus;
|
||||
notes: string[];
|
||||
envelope: Record<string, unknown>;
|
||||
surface: Record<string, unknown> | null;
|
||||
paperclipRun: Record<string, unknown> | null;
|
||||
rawAdapterTrace: Record<string, unknown> | null;
|
||||
normalizedAdapterTrace: Record<string, unknown> | null;
|
||||
privacy: Record<string, unknown> | null;
|
||||
integrity: Record<string, unknown>;
|
||||
files: FeedbackTraceBundleFile[];
|
||||
}
|
||||
|
|
@ -1,4 +1,16 @@
|
|||
export type { Company } from "./company.js";
|
||||
export type {
|
||||
FeedbackVote,
|
||||
FeedbackDataSharingPreference,
|
||||
FeedbackTargetType,
|
||||
FeedbackVoteValue,
|
||||
FeedbackTrace,
|
||||
FeedbackTraceStatus,
|
||||
FeedbackTraceTargetSummary,
|
||||
FeedbackTraceBundleCaptureStatus,
|
||||
FeedbackTraceBundleFile,
|
||||
FeedbackTraceBundle,
|
||||
} from "./feedback.js";
|
||||
export type { InstanceExperimentalSettings, InstanceGeneralSettings, InstanceSettings } from "./instance.js";
|
||||
export type {
|
||||
CompanySkillSourceType,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import type { FeedbackDataSharingPreference } from "./feedback.js";
|
||||
|
||||
export interface InstanceGeneralSettings {
|
||||
censorUsernameInLogs: boolean;
|
||||
feedbackDataSharingPreference: FeedbackDataSharingPreference;
|
||||
}
|
||||
|
||||
export interface InstanceExperimentalSettings {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ export const portabilityCompanyManifestEntrySchema = z.object({
|
|||
brandColor: z.string().nullable(),
|
||||
logoPath: z.string().nullable(),
|
||||
requireBoardApprovalForNewAgents: z.boolean(),
|
||||
feedbackDataSharingEnabled: z.boolean().default(false),
|
||||
feedbackDataSharingConsentAt: z.string().datetime().nullable().default(null),
|
||||
feedbackDataSharingConsentByUserId: z.string().nullable().default(null),
|
||||
feedbackDataSharingTermsVersion: z.string().nullable().default(null),
|
||||
});
|
||||
|
||||
export const portabilitySidebarOrderSchema = z.object({
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { COMPANY_STATUSES } from "../constants.js";
|
|||
|
||||
const logoAssetIdSchema = z.string().uuid().nullable().optional();
|
||||
const brandColorSchema = z.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional();
|
||||
const feedbackDataSharingTermsVersionSchema = z.string().min(1).nullable().optional();
|
||||
|
||||
export const createCompanySchema = z.object({
|
||||
name: z.string().min(1),
|
||||
|
|
@ -18,6 +19,10 @@ export const updateCompanySchema = createCompanySchema
|
|||
status: z.enum(COMPANY_STATUSES).optional(),
|
||||
spentMonthlyCents: z.number().int().nonnegative().optional(),
|
||||
requireBoardApprovalForNewAgents: z.boolean().optional(),
|
||||
feedbackDataSharingEnabled: z.boolean().optional(),
|
||||
feedbackDataSharingConsentAt: z.coerce.date().nullable().optional(),
|
||||
feedbackDataSharingConsentByUserId: z.string().min(1).nullable().optional(),
|
||||
feedbackDataSharingTermsVersion: feedbackDataSharingTermsVersionSchema,
|
||||
brandColor: brandColorSchema,
|
||||
logoAssetId: logoAssetIdSchema,
|
||||
});
|
||||
|
|
|
|||
22
packages/shared/src/validators/feedback.ts
Normal file
22
packages/shared/src/validators/feedback.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { z } from "zod";
|
||||
import {
|
||||
FEEDBACK_DATA_SHARING_PREFERENCES,
|
||||
FEEDBACK_TARGET_TYPES,
|
||||
FEEDBACK_TRACE_STATUSES,
|
||||
FEEDBACK_VOTE_VALUES,
|
||||
} from "../types/feedback.js";
|
||||
|
||||
export const feedbackTargetTypeSchema = z.enum(FEEDBACK_TARGET_TYPES);
|
||||
export const feedbackTraceStatusSchema = z.enum(FEEDBACK_TRACE_STATUSES);
|
||||
export const feedbackVoteValueSchema = z.enum(FEEDBACK_VOTE_VALUES);
|
||||
export const feedbackDataSharingPreferenceSchema = z.enum(FEEDBACK_DATA_SHARING_PREFERENCES);
|
||||
|
||||
export const upsertIssueFeedbackVoteSchema = z.object({
|
||||
targetType: feedbackTargetTypeSchema,
|
||||
targetId: z.string().uuid(),
|
||||
vote: feedbackVoteValueSchema,
|
||||
reason: z.string().trim().max(1000).optional(),
|
||||
allowSharing: z.boolean().optional(),
|
||||
});
|
||||
|
||||
export type UpsertIssueFeedbackVote = z.infer<typeof upsertIssueFeedbackVoteSchema>;
|
||||
|
|
@ -24,6 +24,14 @@ export {
|
|||
type UpdateCompany,
|
||||
type UpdateCompanyBranding,
|
||||
} from "./company.js";
|
||||
export {
|
||||
feedbackDataSharingPreferenceSchema,
|
||||
feedbackTargetTypeSchema,
|
||||
feedbackTraceStatusSchema,
|
||||
feedbackVoteValueSchema,
|
||||
upsertIssueFeedbackVoteSchema,
|
||||
type UpsertIssueFeedbackVote,
|
||||
} from "./feedback.js";
|
||||
export {
|
||||
companySkillSourceTypeSchema,
|
||||
companySkillTrustLevelSchema,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
import { z } from "zod";
|
||||
import { DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE } from "../types/feedback.js";
|
||||
import { feedbackDataSharingPreferenceSchema } from "./feedback.js";
|
||||
|
||||
export const instanceGeneralSettingsSchema = z.object({
|
||||
censorUsernameInLogs: z.boolean().default(false),
|
||||
feedbackDataSharingPreference: feedbackDataSharingPreferenceSchema.default(
|
||||
DEFAULT_FEEDBACK_DATA_SHARING_PREFERENCE,
|
||||
),
|
||||
}).strict();
|
||||
|
||||
export const patchInstanceGeneralSettingsSchema = instanceGeneralSettingsSchema.partial();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue