mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-02 02:30:43 +01:00
Merge master into Speko UI and reconcile Storybook catalog
This commit is contained in:
commit
e61e19d0dc
1564 files changed
+208511
-127704
No files matched your search
@@ -689,6 +689,13 @@ describe("AppDefinition catalog", () => {
|
||||
consoleLinks: { register: "https://app.asana.com/0/my-apps" },
|
||||
});
|
||||
expect(method("linear")?.ownershipModes).toEqual(["dcr", "customer"]);
|
||||
expect(method("sentry")).toMatchObject({
|
||||
key: "mcp-oauth",
|
||||
defaults: {
|
||||
serverUrl: "https://mcp.sentry.dev/mcp",
|
||||
discoveryUrl: "https://mcp.sentry.dev/.well-known/oauth-protected-resource/mcp",
|
||||
},
|
||||
});
|
||||
expect(method("zapier")).toMatchObject({
|
||||
key: "generated-url",
|
||||
auth: "none",
|
||||
@@ -756,11 +763,6 @@ describe("AppDefinition catalog", () => {
|
||||
APP_DEFINITIONS.find((app) => app.slug === "linear")?.methods[0]?.defaults
|
||||
?.scopesHint,
|
||||
).toEqual(["read", "write"]));
|
||||
it("requests Hugging Face MCP read, contribution and job scopes", () =>
|
||||
expect(
|
||||
APP_DEFINITIONS.find((app) => app.slug === "hugging-face")?.methods[0]
|
||||
?.defaults?.scopesHint,
|
||||
).toEqual(["read-mcp", "read-repos", "contribute-repos", "jobs"]));
|
||||
it("defaults every new connection action to allowed except Enterpret writes", () => {
|
||||
for (const app of APP_DEFINITIONS)
|
||||
for (const method of app.methods) {
|
||||
@@ -1320,21 +1322,6 @@ describe("AppDefinition catalog", () => {
|
||||
?.available,
|
||||
).toBe(false);
|
||||
});
|
||||
it("enforces method and field invariants", () => {
|
||||
for (const app of APP_DEFINITIONS)
|
||||
for (const method of app.methods) {
|
||||
if (
|
||||
method.auth === "api_key" &&
|
||||
(method.purpose ?? "tool") !== "channel"
|
||||
)
|
||||
expect(method.keyPlacement).toBeTruthy();
|
||||
if (method.auth === "oauth")
|
||||
expect(method.ownershipModes.length).toBeGreaterThan(0);
|
||||
for (const field of method.credentialFields ?? [])
|
||||
if (field.required && field.type !== "checkbox")
|
||||
expect(field.placeholder).toBeTruthy();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"whenToUse": "Use the provider-hosted connection for the quickest setup.",
|
||||
"defaults": {
|
||||
"serverUrl": "https://mcp.sentry.dev/mcp",
|
||||
"discoveryUrl": "https://sentry.io/.well-known/oauth-authorization-server",
|
||||
"discoveryUrl": "https://mcp.sentry.dev/.well-known/oauth-protected-resource/mcp",
|
||||
"scopesHint": [
|
||||
"org:read",
|
||||
"project:write",
|
||||
|
||||
@@ -732,7 +732,7 @@ export type SecretProviderConfigHealthStatus =
|
||||
export const SECRET_STATUSES = ["active", "disabled", "archived", "deleted"] as const;
|
||||
export type SecretStatus = (typeof SECRET_STATUSES)[number];
|
||||
|
||||
export const SECRET_SCOPES = ["company", "user"] as const;
|
||||
export const SECRET_SCOPES = ["company", "user", "instance"] as const;
|
||||
export type SecretScope = (typeof SECRET_SCOPES)[number];
|
||||
|
||||
export const SECRET_MANAGED_MODES = ["paperclip_managed", "external_reference"] as const;
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { z } from "zod";
|
||||
import type {
|
||||
AiManagedConnectionSummary,
|
||||
AiProvider,
|
||||
} from "./ai-connections.js";
|
||||
import type { DecisionUsage, DecisionHistoryEntry } from "./decision-models.js";
|
||||
|
||||
export const FAST_RESPONSE_DEADLINE_MS = 3_000;
|
||||
export const FAST_RESPONSE_MAX_BYTES = 4_096;
|
||||
export const FAST_RESPONSE_MAX_CHARACTERS = 320;
|
||||
export const FAST_RESPONSE_DEFAULT_MODEL = "openai/gpt-oss-120b";
|
||||
export const updateFastResponseSchema = z
|
||||
.object({
|
||||
enabled: z.boolean(),
|
||||
connectionId: z.string().uuid().nullable(),
|
||||
grantId: z.string().uuid().nullable(),
|
||||
model: z.string().trim().min(1).max(256).nullable(),
|
||||
allowSponsored: z.boolean().default(true),
|
||||
})
|
||||
.strict()
|
||||
.refine(
|
||||
(v) =>
|
||||
Boolean(v.connectionId) === Boolean(v.grantId) &&
|
||||
(!v.enabled || Boolean(v.connectionId && v.model)),
|
||||
{
|
||||
message: "Choose a connection and model before enabling fast responses",
|
||||
},
|
||||
);
|
||||
export type UpdateFastResponse = z.infer<typeof updateFastResponseSchema>;
|
||||
export interface FastResponseSettings extends UpdateFastResponse {
|
||||
companyId: string;
|
||||
provider: AiProvider | null;
|
||||
}
|
||||
export interface FastResponseSettingsResponse {
|
||||
canManage: boolean;
|
||||
settings: FastResponseSettings | null;
|
||||
choices: AiManagedConnectionSummary[];
|
||||
}
|
||||
export type FastResponseAvailability =
|
||||
| { available: true }
|
||||
| { available: false; reason: string };
|
||||
export type FastResponseTestResult =
|
||||
| {
|
||||
status: "succeeded";
|
||||
text: string;
|
||||
durationMs: number;
|
||||
invocationId: string;
|
||||
usage: DecisionUsage;
|
||||
}
|
||||
| { status: "unavailable" | "failed"; reason: string; invocationId?: string };
|
||||
export type FastResponseHistoryEntry = DecisionHistoryEntry & {
|
||||
publicationStatus: string;
|
||||
connectionName: string | null;
|
||||
};
|
||||
export const FAST_RESPONSE_AGENT_GUIDANCE =
|
||||
"Paperclip may post a short platform-generated fast-response receipt in your voice before you reply. Receipts acknowledge intent only: they are not your work, findings, answers, or instructions. Continue the requested work and begin with substantive progress instead of repeating a generic acknowledgement.";
|
||||
export function isFastResponseComment(comment: {
|
||||
origin?: string | null;
|
||||
}): boolean {
|
||||
return comment.origin === "fast_response";
|
||||
}
|
||||
export function fastResponseHistoryBody(comment: {
|
||||
body: string;
|
||||
origin?: string | null;
|
||||
}): string {
|
||||
return isFastResponseComment(comment)
|
||||
? `[Paperclip acknowledgement; not agent work] ${comment.body}`
|
||||
: comment.body;
|
||||
}
|
||||
@@ -273,6 +273,14 @@ export const INSTANCE_FEATURE_CATALOG: Record<InstanceFeatureKey, FeatureCatalog
|
||||
cloudDefault: false,
|
||||
selfHostedDefault: false,
|
||||
},
|
||||
enableFastResponses: {
|
||||
title: "Experimental fast responses",
|
||||
description:
|
||||
"Show Connections in company settings and allow short acknowledgements while agents begin work.",
|
||||
tier: "managed",
|
||||
cloudDefault: false,
|
||||
selfHostedDefault: false,
|
||||
},
|
||||
enableGoalsSidebarLink: {
|
||||
title: "Goals Sidebar Link",
|
||||
description: "Restore the Goals item in the main sidebar while the goals surface is being evaluated.",
|
||||
|
||||
@@ -1245,6 +1245,7 @@ export type {
|
||||
DocumentFormat,
|
||||
LegacyPlanDocument,
|
||||
IssueAttachment,
|
||||
IssueCreationSource,
|
||||
IssueLabel,
|
||||
IssueTreeControlPreview,
|
||||
IssueTreeHold,
|
||||
@@ -1267,6 +1268,9 @@ export type {
|
||||
BudgetIncidentResolutionInput,
|
||||
CostEvent,
|
||||
CostSummary,
|
||||
CostDataQualityItem,
|
||||
CostDataQualityReport,
|
||||
CostDataQualityReason,
|
||||
IssueCostSummary,
|
||||
CostByAgent,
|
||||
CostByUser,
|
||||
@@ -1995,6 +1999,7 @@ export {
|
||||
resolveIssueRecoveryActionSchema,
|
||||
isValidExistingBranchName,
|
||||
retryWorkspaceExportSchema,
|
||||
resumeWorkspaceFinalizationSchema,
|
||||
issueReviewRequestSchema,
|
||||
issueExecutionWorkspaceSettingsSchema,
|
||||
checkoutIssueSchema,
|
||||
@@ -2868,3 +2873,12 @@ export { EXTERNAL_AGENT_TOOL_GUIDANCE, DOT_AGENT_TOOL_GUIDANCE } from "./externa
|
||||
export { AGENT_LIFECYCLE_STATES, type AgentLifecycleState, type AgentLifecycleOperation } from "./types/agent-lifecycle.js";
|
||||
|
||||
export type { AgentLifecycleRequest, AgentLifecycleResult } from "./types/agent-lifecycle.js";
|
||||
|
||||
export * from "./types/task-workspace.js";
|
||||
export * from "./validators/task-workspace.js";
|
||||
|
||||
export { prepareWorkspaceRepositorySchema, type PrepareWorkspaceRepository } from "./validators/workspace-repository.js";
|
||||
|
||||
export * from "./fast-response.js";
|
||||
|
||||
export { HUMAN_TASK_ORIGIN_KINDS, isAgentCreatedIssue, type IssueCreationSourceFields } from "./issue-creation-source.js";
|
||||
@@ -0,0 +1,20 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isAgentCreatedIssue } from "./issue-creation-source.js";
|
||||
|
||||
describe("task creation source", () => {
|
||||
it.each(["manual", "onboarding_first_task"])("preserves human-created %s tasks", (originKind) => {
|
||||
expect(isAgentCreatedIssue({ createdByUserId: "person", originKind })).toBe(false);
|
||||
});
|
||||
it.each(["chat_channel", "routine_execution", "stranded_issue_recovery", "task_watchdog", "harness_liveness_escalation", "plugin:workflow:operation", "built_in_agent_bundle", "pipeline_automation"])("classifies %s as automated even with human attribution", (originKind) => {
|
||||
expect(isAgentCreatedIssue({ createdByUserId: "person", originKind })).toBe(true);
|
||||
});
|
||||
it.each([null, "person"])("classifies channel work as automated with creator %s", (createdByUserId) => {
|
||||
expect(isAgentCreatedIssue({ originKind: "chat_channel", createdByUserId })).toBe(true);
|
||||
});
|
||||
it("recognizes agents and creator-less ordinary tasks", () => {
|
||||
expect(isAgentCreatedIssue({ createdByAgentId: "agent", originKind: "manual" })).toBe(true);
|
||||
expect(isAgentCreatedIssue({ originKind: "manual" })).toBe(true);
|
||||
expect(isAgentCreatedIssue({ createdByUserId: "person", createdByAgentId: "agent" })).toBe(true);
|
||||
expect(isAgentCreatedIssue({ createdByUserId: "person" })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
/** Origins that represent a person's ordinary task or onboarding request. */
|
||||
export const HUMAN_TASK_ORIGIN_KINDS = ["manual", "onboarding_first_task"] as const;
|
||||
|
||||
export interface IssueCreationSourceFields {
|
||||
createdByAgentId?: string | null;
|
||||
createdByUserId?: string | null;
|
||||
originKind?: string | null;
|
||||
}
|
||||
|
||||
/** Creation is independent of who is assigned or responsible for execution. */
|
||||
export function isAgentCreatedIssue(issue: IssueCreationSourceFields): boolean {
|
||||
return Boolean(issue.createdByAgentId)
|
||||
|| !issue.createdByUserId
|
||||
|| !HUMAN_TASK_ORIGIN_KINDS.includes(
|
||||
(issue.originKind ?? "manual") as typeof HUMAN_TASK_ORIGIN_KINDS[number],
|
||||
);
|
||||
}
|
||||
@@ -30,6 +30,12 @@ describe("Slack app manifest", () => {
|
||||
expect(manual.settings.event_subscriptions.request_url).toBe(input.webhookUrl);
|
||||
expect(manual.settings.interactivity).toEqual({ is_enabled: true, request_url: input.webhookUrl });
|
||||
expect(manual.settings.socket_mode_enabled).toBe(false);
|
||||
expect(manual.features).toHaveProperty("agent_view");
|
||||
expect(manual.features).not.toHaveProperty("assistant_view");
|
||||
expect(manual.features.bot_user).not.toHaveProperty("always_online");
|
||||
expect(manual.features.app_home).toEqual({
|
||||
home_tab_enabled: false, messages_tab_enabled: true, messages_tab_read_only_enabled: false,
|
||||
});
|
||||
// The reviewed provider permissions/events stay pinned across both creation paths.
|
||||
expect(manual.oauth_config.scopes.bot).toMatchSnapshot();
|
||||
expect(manual.settings.event_subscriptions.bot_events).toMatchSnapshot();
|
||||
|
||||
@@ -22,7 +22,7 @@ export function buildSlackAppManifest(input: {
|
||||
redirectUri?: string;
|
||||
}) {
|
||||
return {
|
||||
display_information: { name: input.app.appName },
|
||||
display_information: { name: input.app.appName, description: `Talk to ${input.agentName} and manage work in Paperclip.`.slice(0, 140) },
|
||||
features: {
|
||||
app_home: { home_tab_enabled: false, messages_tab_enabled: true, messages_tab_read_only_enabled: false },
|
||||
agent_view: { agent_description: "Work with a Paperclip agent in a task-backed conversation." },
|
||||
@@ -60,6 +60,7 @@ export const slackRegistrationStateSchema = z.object({
|
||||
status: slackRegistrationStatusSchema,
|
||||
appId: z.string().nullable().optional(),
|
||||
managementUrl: z.string().url().nullable().optional(),
|
||||
managerGrantId: z.string().uuid().nullable().optional(),
|
||||
errorCode: z.string().nullable().optional(),
|
||||
}).strict();
|
||||
export type SlackRegistrationState = z.infer<typeof slackRegistrationStateSchema>;
|
||||
@@ -79,11 +80,33 @@ export const slackAccountStateSchema = z.object({
|
||||
}).strict();
|
||||
export type SlackAccountState = z.infer<typeof slackAccountStateSchema>;
|
||||
export const slackInstallAuthorizationSchema = z.object({ authorizationUrl: z.string().url(), expiresAt: z.string().datetime() });
|
||||
export const slackManagerAuthorizationSchema = slackInstallAuthorizationSchema.extend({ handoff: z.object({ kind: z.literal("paperclip_cloud"), session: z.string().min(16).max(512) }).optional() });
|
||||
export type SlackManagerAuthorization = z.infer<typeof slackManagerAuthorizationSchema>;
|
||||
export type SlackInstallAuthorization = z.infer<typeof slackInstallAuthorizationSchema>;
|
||||
export const slackSetupActionSchema = z.object({}).strict();
|
||||
|
||||
export const slackTestMessageSchema = z.object({
|
||||
requestId: z.string().uuid(),
|
||||
slackUserId: z.string().regex(/^[UW][A-Z0-9]+$/).optional(),
|
||||
accountCursor: z.string().min(1).max(512).optional(),
|
||||
}).strict();
|
||||
export type SlackTestMessageInput = z.infer<typeof slackTestMessageSchema>;
|
||||
export const slackTestMessageResultSchema = z.discriminatedUnion("status", [
|
||||
z.object({ status: z.literal("sent"), slackUrl: z.string().url() }).strict(),
|
||||
z.object({ status: z.literal("connection_required"), accounts: z.array(z.object({
|
||||
id: z.string(), name: z.string(),
|
||||
}).strict()), nextCursor: z.string().nullable() }).strict(),
|
||||
z.object({ status: z.literal("connection_pending"), principalId: z.string().uuid(), expiresAt: z.string().datetime() }).strict(),
|
||||
]);
|
||||
export type SlackTestMessageResult = z.infer<typeof slackTestMessageResultSchema>;
|
||||
|
||||
export function slackRegistrationErrorMessage(code: string): string {
|
||||
const messages: Record<string, string> = {
|
||||
slack_managed_unavailable: "Managed Slack setup is unavailable. Try again later or use your own app before creation starts.",
|
||||
slack_manager_reauthorize: "Reconnect your Slack workspace to continue setting up this agent.",
|
||||
slack_approval_pending: "Slack is waiting for your workspace administrator to approve this app.",
|
||||
slack_approval_required: "Your Slack workspace requires approval. Continue in Slack to request it.",
|
||||
slack_approval_denied: "Your Slack administrator declined this installation. Contact them to continue.",
|
||||
slack_configuration_token_invalid: "Slack rejected the app configuration access token. Generate a new access token and try again.",
|
||||
slack_manifest_invalid: "Slack rejected this app configuration. Check the app details or use manual setup.",
|
||||
slack_manifest_update_pending: "Your Slack app is saved, but its event settings still need to be applied. Enter an app configuration access token to retry configuring the same app.",
|
||||
@@ -96,9 +119,29 @@ export function slackRegistrationErrorMessage(code: string): string {
|
||||
slack_install_identity_mismatch: "Slack returned a different app, workspace, or bot. Install the app created for this connection.",
|
||||
slack_install_scopes_missing: "Slack did not grant all required bot permissions. Install the app again and approve its requested permissions.",
|
||||
slack_bot_already_connected: "This Slack bot is already connected to Paperclip. Resume its existing connection or use a different app.",
|
||||
slack_install_token_invalid: "Slack rejected the saved bot credentials. Continue in Slack to authorize this app again.",
|
||||
slack_configuration_incomplete: "The app is installed, but Paperclip could not finish connecting it. Retry connecting the saved installation.",
|
||||
slack_install_account_missing: "Slack did not identify your account. Authorize the same app again to connect your Slack account.",
|
||||
slack_install_account_conflict: "This Slack account already has an existing link. Manage account links in connection settings, or authorize with your own Slack account.",
|
||||
};
|
||||
return messages[code] ?? "Slack setup could not be completed. Resume setup and try again.";
|
||||
}
|
||||
|
||||
/** Persisted legacy values keep their original meaning. Missing means manual. */
|
||||
export type SlackSetupMethod = "managed" | "automatic" | "manual" | "existing";
|
||||
export function isProvisionedSlackSetup(method: string | undefined): boolean {
|
||||
return method === "automatic" || method === "managed";
|
||||
}
|
||||
export const SLACK_MANAGER_SCOPES = ["app_configurations:read", "app_configurations:write", "managed_apps:install"] as const;
|
||||
export const slackSetupOptionsSchema = z.object({
|
||||
managedAvailable: z.boolean(),
|
||||
defaultMethod: z.enum(["managed", "automatic"]),
|
||||
workspaces: z.array(z.object({ grantId: z.string().uuid(), workspaceId: z.string(), workspaceName: z.string(), userId: z.string() })),
|
||||
});
|
||||
export type SlackSetupOptions = z.infer<typeof slackSetupOptionsSchema>;
|
||||
export const slackManagedProvisionSchema = z.object({
|
||||
requestId: z.string().uuid(), grantId: z.string().uuid(), confirmedNoAppCreated: z.boolean().optional(), reconnect: z.boolean().optional(),
|
||||
}).strict();
|
||||
export type SlackManagedProvisionInput = z.infer<typeof slackManagedProvisionSchema>;
|
||||
export const slackManagedResultSchema = z.object({ authorization: slackInstallAuthorizationSchema.optional() });
|
||||
export type SlackManagedResult = z.infer<typeof slackManagedResultSchema>;
|
||||
@@ -23,9 +23,11 @@ export interface AgentLifecycleRequest {
|
||||
operationId: string;
|
||||
version: number;
|
||||
phase: AgentLifecycleState;
|
||||
instanceSecrets?: Record<string, string>;
|
||||
}
|
||||
export interface AgentLifecycleResult {
|
||||
operationId: string;
|
||||
version: number;
|
||||
status: "complete" | "pending";
|
||||
instanceSecrets?: Record<string, string | null>;
|
||||
}
|
||||
@@ -1,3 +1,10 @@
|
||||
import type { TaskWorkspaceSelection } from "./task-workspace.js";
|
||||
|
||||
export interface ChatExecutionDefaults {
|
||||
projectId?: string | null;
|
||||
workspace?: TaskWorkspaceSelection | null;
|
||||
}
|
||||
|
||||
/** Provider-neutral contracts for Paperclip's native external chat subsystem. */
|
||||
export const CHAT_PROVIDERS = [
|
||||
"slack",
|
||||
@@ -190,7 +197,8 @@ export interface SlackAppConfiguration {
|
||||
}
|
||||
|
||||
export interface ChatEndpointSetupState {
|
||||
slackSetupMethod?: "automatic" | "manual" | "existing";
|
||||
slackSetupMethod?: "managed" | "automatic" | "manual" | "existing";
|
||||
slackManagerError?: string;
|
||||
slackRegistration?: import("../slack-app-manifest.js").SlackRegistrationState;
|
||||
/** Provider-confirmed app icon outcome; configuration tokens are never retained. */
|
||||
slackAvatar?: import("../slack-app-manifest.js").SlackAvatarState;
|
||||
@@ -243,6 +251,7 @@ export type ChannelPublicationMode = "automatic" | "explicit";
|
||||
export type ExternalMessageExecutionPolicy = "restricted" | "agent";
|
||||
|
||||
export interface ChatEndpoint {
|
||||
executionDefaults?: ChatExecutionDefaults | null;
|
||||
/** Additional presentation instructions captured only for newly created tasks. */
|
||||
communicationInstructions?: string;
|
||||
id: string;
|
||||
@@ -282,6 +291,7 @@ export interface ChatEndpoint {
|
||||
}
|
||||
|
||||
export interface ChatEndpointResource {
|
||||
executionDefaults?: ChatExecutionDefaults | null;
|
||||
id: string;
|
||||
companyId: string;
|
||||
endpointId: string;
|
||||
@@ -331,6 +341,7 @@ export interface ChatIdentityLink {
|
||||
externalDetail?: string | null;
|
||||
paperclipUserId?: string | null;
|
||||
paperclipUserLabel?: string | null;
|
||||
paperclipUserImage?: string | null;
|
||||
status: ChatIdentityLinkStatus;
|
||||
expiresAt?: string | null;
|
||||
confirmedAt?: string | null;
|
||||
@@ -508,10 +519,12 @@ export interface CreateChatEndpointInput {
|
||||
applicationId?: string;
|
||||
name?: string;
|
||||
slackApp?: SlackAppConfiguration;
|
||||
slackSetupMethod?: "managed" | "automatic" | "manual" | "existing";
|
||||
}
|
||||
|
||||
export interface UpdateChatEndpointInput {
|
||||
slackSetupMethod?: "automatic" | "manual" | "existing";
|
||||
executionDefaults?: ChatExecutionDefaults | null;
|
||||
slackSetupMethod?: "managed" | "automatic" | "manual" | "existing";
|
||||
slackApp?: SlackAppConfiguration;
|
||||
communicationInstructions?: string;
|
||||
allowDirectMessages?: boolean;
|
||||
|
||||
@@ -156,6 +156,8 @@ export interface CompanySkillCategoryCount {
|
||||
}
|
||||
|
||||
export interface CompanySkillVersion {
|
||||
repositorySnapshotId?: string | null;
|
||||
repositorySkillPath?: string | null;
|
||||
id: string;
|
||||
companyId: string;
|
||||
companySkillId: string;
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { BillingType, CostStatus } from "../constants.js";
|
||||
|
||||
export interface CostEvent {
|
||||
subscriptionId?: string | null;
|
||||
usageKind?: "agent" | "decision";
|
||||
usageKind?: "agent" | "decision" | "fast_response";
|
||||
responsibleUserId?: string | null;
|
||||
id: string;
|
||||
companyId: string;
|
||||
@@ -33,6 +33,8 @@ export interface CostSummary {
|
||||
pendingRunCount: number;
|
||||
unpricedEventCount: number;
|
||||
estimatedEventCount?: number;
|
||||
/** Receipts whose API/subscription billing identity was not established. */
|
||||
unknownBillingEventCount?: number;
|
||||
pricingComplete: boolean;
|
||||
companyId: string;
|
||||
spendCents: number;
|
||||
@@ -41,6 +43,30 @@ export interface CostSummary {
|
||||
utilizationPercent: number;
|
||||
}
|
||||
|
||||
export type CostDataQualityReason = "unknown_billing" | "missing_model" | "missing_price"
|
||||
| "waiting_for_receipt" | "receipt_unavailable" | "retryable";
|
||||
|
||||
export interface CostDataQualityItem {
|
||||
id: string;
|
||||
runId: string | null;
|
||||
agentId: string | null;
|
||||
agentName: string | null;
|
||||
agentAppearance?: AgentAppearance | null;
|
||||
occurredAt: string;
|
||||
provider: string | null;
|
||||
model: string | null;
|
||||
reason: CostDataQualityReason;
|
||||
}
|
||||
|
||||
export interface CostDataQualityReport {
|
||||
canRetry: boolean;
|
||||
/** Each category is bounded independently so one cannot hide another. */
|
||||
events: CostDataQualityItem[];
|
||||
runs: CostDataQualityItem[];
|
||||
hasMoreEvents: boolean;
|
||||
hasMoreRuns: boolean;
|
||||
}
|
||||
|
||||
export interface IssueCostSummary {
|
||||
issueId: string;
|
||||
issueCount: number;
|
||||
@@ -110,6 +136,9 @@ export interface CostByProviderModel {
|
||||
model: string;
|
||||
costCents: number;
|
||||
costCentsExact?: string;
|
||||
eventCount?: number;
|
||||
estimatedEventCount?: number;
|
||||
unpricedEventCount?: number;
|
||||
inputTokens: number;
|
||||
cachedInputTokens: number;
|
||||
outputTokens: number;
|
||||
@@ -124,6 +153,9 @@ export interface CostByBiller {
|
||||
biller: string;
|
||||
costCents: number;
|
||||
costCentsExact?: string;
|
||||
eventCount?: number;
|
||||
estimatedEventCount?: number;
|
||||
unpricedEventCount?: number;
|
||||
inputTokens: number;
|
||||
cachedInputTokens: number;
|
||||
outputTokens: number;
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface ExecutionBlocker {
|
||||
canRetry?: boolean;
|
||||
/** Required workspace files must be recovered before another provider turn. */
|
||||
workspaceRepairRequired?: boolean;
|
||||
canRecordWorkspaceRepair?: boolean;
|
||||
savedMessageCount?: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -804,6 +804,7 @@ export type {
|
||||
IssueAncestorProject,
|
||||
IssueAncestorGoal,
|
||||
IssueAttachment,
|
||||
IssueCreationSource,
|
||||
IssueLabel,
|
||||
IssueWatchdog,
|
||||
IssueWatchdogStatus,
|
||||
@@ -899,7 +900,7 @@ export type {
|
||||
RoutineExecutionIssueOrigin,
|
||||
RoutineListItem,
|
||||
} from "./routine.js";
|
||||
export type { CostEvent, CostSummary, IssueCostSummary, CostByUser, CostByUserReport, CostByAgent, CostByProviderModel, CostByBiller, CostByAgentModel, CostWindowSpendRow, CostByProject } from "./cost.js";
|
||||
export type { CostEvent, CostSummary, CostDataQualityItem, CostDataQualityReport, CostDataQualityReason, IssueCostSummary, CostByUser, CostByUserReport, CostByAgent, CostByProviderModel, CostByBiller, CostByAgentModel, CostWindowSpendRow, CostByProject } from "./cost.js";
|
||||
export type { FinanceEvent, FinanceSummary, FinanceByBiller, FinanceByKind } from "./finance.js";
|
||||
export type {
|
||||
AgentWakeupResponse,
|
||||
@@ -1100,3 +1101,5 @@ export type { AgentInstructionCandidate } from "./agent.js";
|
||||
export * from "./skill-source.js";
|
||||
|
||||
export * from "./agent-lifecycle.js";
|
||||
|
||||
export * from "./task-workspace.js";
|
||||
@@ -97,6 +97,8 @@ export interface InstanceExperimentalSettings {
|
||||
enableSummaries: boolean;
|
||||
enableStatusCards: boolean;
|
||||
enableDecisions: boolean;
|
||||
/** Show company connection settings and allow contextual fast-response acknowledgements. */
|
||||
enableFastResponses: boolean;
|
||||
enableGoalsSidebarLink: boolean;
|
||||
enableServerInfoDebugView: boolean;
|
||||
/** Shows internal Paperclip maintainer tools and observability links. */
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { TaskWorkspaceIntent, TaskWorkspacePendingSelection } from "./task-workspace.js";
|
||||
import type { ExecutionProjection, ExecutionBlocker } from "./execution-projection.js";
|
||||
import type {
|
||||
IssueCommentAuthorType,
|
||||
@@ -128,6 +129,22 @@ export interface IssueLabel {
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
/**
|
||||
* The task a run was executing when it created this issue, from recorded run
|
||||
* provenance. Independent of the structural parent and of blockers. Only
|
||||
* present when the viewer may read the source task and its run.
|
||||
*/
|
||||
export interface IssueCreationSource {
|
||||
issue: {
|
||||
id: string;
|
||||
identifier: string | null;
|
||||
title: string;
|
||||
status: string;
|
||||
};
|
||||
run: { id: string; agentId: string };
|
||||
agent: { id: string; name: string } | null;
|
||||
}
|
||||
|
||||
export interface IssueAssigneeAdapterOverrides {
|
||||
adapterConfig?: Record<string, unknown>;
|
||||
useProjectWorkspace?: boolean;
|
||||
@@ -839,6 +856,8 @@ export interface Issue {
|
||||
/** Immediate task from which private access flows downward, including chat handoffs. */
|
||||
privacyParentIssueId?: string | null;
|
||||
ancestors?: IssueAncestor[];
|
||||
/** Detail responses only: access-checked creation provenance, or null. */
|
||||
createdFrom?: IssueCreationSource | null;
|
||||
title: string;
|
||||
description: string | null;
|
||||
descriptionTruncated?: boolean;
|
||||
@@ -873,6 +892,9 @@ export interface Issue {
|
||||
monitorAttemptCount?: number;
|
||||
monitorNotes?: string | null;
|
||||
monitorScheduledBy?: IssueMonitorScheduledBy | null;
|
||||
workspaceBindingRevision?: number;
|
||||
workspaceSelection?: TaskWorkspaceIntent | null;
|
||||
workspacePendingSelection?: TaskWorkspacePendingSelection | null;
|
||||
executionWorkspaceId: string | null;
|
||||
executionWorkspacePreference: string | null;
|
||||
executionWorkspaceSettings: IssueExecutionWorkspaceSettings | null;
|
||||
@@ -1003,6 +1025,9 @@ export interface IssueComment {
|
||||
companyId: string;
|
||||
issueId: string;
|
||||
authorType: IssueCommentAuthorType;
|
||||
/** Server-generated receipt provenance; not writable by comment callers. */
|
||||
origin?: "comment" | "fast_response";
|
||||
fastResponseRequestId?: string | null;
|
||||
authorAgentId: string | null;
|
||||
authorUserId: string | null;
|
||||
/** Responsible user attribution. Legacy and plugin-provided comment values may omit it. */
|
||||
|
||||
@@ -5,5 +5,7 @@ export interface LiveEvent {
|
||||
companyId: string;
|
||||
type: LiveEventType;
|
||||
createdAt: string;
|
||||
/** Viewer-specific WebSocket projection; absent/false means no task toast. */
|
||||
toastEligible?: boolean;
|
||||
payload: Record<string, unknown>;
|
||||
}
|
||||
@@ -689,6 +689,8 @@ export interface PaperclipPluginManifestV1 {
|
||||
capabilities: PluginCapability[];
|
||||
/** Required participant in agent preparation, stop, resume, and cleanup. */
|
||||
agentLifecycle?: true;
|
||||
/** Durable, acknowledged resource events delivered to onResourceLifecycle. Requires events.subscribe. */
|
||||
resourceLifecycle?: Array<"agent" | "project">;
|
||||
/** Opt into the native pooled-connection catalog, setup, and management UI. */
|
||||
aiConnectionRouter?: { name: string; description: string };
|
||||
/** Entrypoint paths relative to the package root. */
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import type { CompanySkill } from './company-skill.js';
|
||||
|
||||
export type SkillSourcePackageMode = 'skills' | 'repository';
|
||||
export interface SkillRepositoryPackage {
|
||||
files: SkillPackageFile[];
|
||||
requirements: string | null;
|
||||
/** Author-declared public entrypoints; omitted when no manifest exists. */
|
||||
skillPaths?: string[];
|
||||
error: string | null;
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
/** Metadata from an audited, immutable repository scan; file contents are fetched on demand. */
|
||||
export interface SkillPackageInspection {
|
||||
/** Commit of this manifest, retained when a package disappears on a later refresh. */
|
||||
@@ -48,6 +58,8 @@ export interface SkillSourceEntry {
|
||||
export interface SkillSource {
|
||||
id: string;
|
||||
companyId: string;
|
||||
packageMode?: SkillSourcePackageMode;
|
||||
repositoryPackage?: SkillRepositoryPackage | null;
|
||||
repositoryId: string | null;
|
||||
repositoryUrl: string;
|
||||
fullName: string;
|
||||
@@ -63,6 +75,7 @@ export interface SkillSource {
|
||||
entries: SkillSourceEntry[];
|
||||
}
|
||||
export interface SkillSourceDiscoveryRequest {
|
||||
packageMode?: SkillSourcePackageMode;
|
||||
repositoryUrl: string;
|
||||
trackingRef?: string;
|
||||
connectionId?: string | null;
|
||||
@@ -77,6 +90,8 @@ export interface SkillSourceCandidate {
|
||||
warnings: string[];
|
||||
}
|
||||
export interface SkillSourceDiscovery {
|
||||
packageMode?: SkillSourcePackageMode;
|
||||
repositoryPackage?: SkillRepositoryPackage | null;
|
||||
/** Caller-authorized connection actually used; omitted by older servers. */
|
||||
connectionId?: string | null;
|
||||
repositoryId: string;
|
||||
@@ -113,6 +128,7 @@ export interface SkillSourceCreateRequest extends SkillSourceDiscoveryRequest {
|
||||
excludedFolders?: string[];
|
||||
}
|
||||
export interface SkillSourceSelectionRequest {
|
||||
packageMode?: SkillSourcePackageMode;
|
||||
revision: number;
|
||||
selectedPaths: string[];
|
||||
excludedFolders: string[];
|
||||
@@ -125,3 +141,13 @@ export interface SkillSourceRefreshResult {
|
||||
unchanged: number;
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
export interface SkillSourceDisconnectRequest {
|
||||
revision: number;
|
||||
skills: 'copy' | 'delete';
|
||||
}
|
||||
export interface SkillSourceDisconnectResult {
|
||||
id: string;
|
||||
copiedCount: number;
|
||||
deletedCount: number;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
export type TaskWorkspaceSelection =
|
||||
| { kind: "task_directory" }
|
||||
| { kind: "existing"; workspaceId: string }
|
||||
| { kind: "configured_source"; projectWorkspaceId: string; mode: "shared" | "managed_isolated" };
|
||||
export type TaskWorkspaceIntent = {
|
||||
version: 1;
|
||||
request?: { key: string; expectedBindingRevision: number };
|
||||
selection: TaskWorkspaceSelection;
|
||||
source: "explicit" | "parent" | "channel" | "project" | "operator_cwd" | "task_default" | "legacy";
|
||||
};
|
||||
export type TaskWorkspacePendingSelection = {
|
||||
version: 1;
|
||||
requestKey: string;
|
||||
expectedBindingRevision: number;
|
||||
intent: TaskWorkspaceIntent;
|
||||
};
|
||||
@@ -229,9 +229,9 @@ export interface WorkspaceOverviewItem {
|
||||
kind: "execution_workspace";
|
||||
workspaceId: string;
|
||||
workspaceName: string;
|
||||
projectId: string;
|
||||
projectUrlKey: string;
|
||||
projectName: string;
|
||||
projectId: string | null;
|
||||
projectUrlKey: string | null;
|
||||
projectName: string | null;
|
||||
mode: ExecutionWorkspaceSummary["mode"];
|
||||
strategyType: ExecutionWorkspaceStrategyType;
|
||||
cwd: string | null;
|
||||
@@ -262,7 +262,7 @@ export interface WorkspaceOverviewResponse {
|
||||
export interface ExecutionWorkspace {
|
||||
id: string;
|
||||
companyId: string;
|
||||
projectId: string;
|
||||
projectId: string | null;
|
||||
projectWorkspaceId: string | null;
|
||||
sourceIssueId: string | null;
|
||||
mode: Exclude<ExecutionWorkspaceMode, "inherit" | "reuse_existing" | "agent_default"> | "adapter_managed" | "cloud_sandbox";
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { z } from "zod";
|
||||
import { multilineTextSchema } from "./text.js";
|
||||
import { taskWorkspaceSelectionSchema } from "./task-workspace.js";
|
||||
|
||||
export const chatExecutionDefaultsSchema = z.object({
|
||||
projectId: z.string().uuid().nullable().optional(),
|
||||
workspace: taskWorkspaceSelectionSchema.nullable().optional(),
|
||||
}).strict();
|
||||
import {
|
||||
CHAT_CONCURRENCY_POLICIES,
|
||||
CHAT_DELIVERY_STATES,
|
||||
@@ -80,17 +86,19 @@ export const createChatEndpointSchema = z
|
||||
applicationId: z.string().uuid().optional(),
|
||||
name: z.string().trim().min(1).max(160).optional(),
|
||||
slackApp: slackAppConfigurationSchema.optional(),
|
||||
slackSetupMethod: z.enum(["managed", "automatic", "manual", "existing"]).optional(),
|
||||
})
|
||||
.strict()
|
||||
.refine(value => !value.slackApp || value.provider === "slack", {
|
||||
.refine(value => (!value.slackApp && !value.slackSetupMethod) || value.provider === "slack", {
|
||||
message: "Slack app details only apply to Slack connections", path: ["slackApp"],
|
||||
});
|
||||
|
||||
export const updateChatEndpointSchema = z
|
||||
.object({
|
||||
executionDefaults: chatExecutionDefaultsSchema.nullable().optional(),
|
||||
communicationInstructions: multilineTextSchema.pipe(z.string().trim().max(4000)).optional(),
|
||||
slackApp: slackAppConfigurationSchema.optional(),
|
||||
slackSetupMethod: z.enum(["automatic", "manual", "existing"]).optional(),
|
||||
slackSetupMethod: z.enum(["managed", "automatic", "manual", "existing"]).optional(),
|
||||
allowDirectMessages: z.boolean().optional(),
|
||||
requireAtMention: z.boolean().optional(),
|
||||
allowGroupChats: z.boolean().optional(),
|
||||
@@ -147,7 +155,8 @@ export const replaceChatEndpointResourcesSchema = z
|
||||
z
|
||||
.object({
|
||||
id: z.string().uuid(),
|
||||
enabled: z.boolean(),
|
||||
enabled: z.boolean().optional(),
|
||||
executionDefaults: chatExecutionDefaultsSchema.nullable().optional(),
|
||||
})
|
||||
.strict(),
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ export const createCostEventSchema = costEventFields.transform((value) => ({
|
||||
/** Internal service receipts; the public reporting endpoint retains its required agent. */
|
||||
export const createServiceCostEventSchema = costEventFields.extend({
|
||||
agentId: z.string().uuid().nullable(),
|
||||
usageKind: z.literal("decision"),
|
||||
usageKind: z.enum(["decision", "fast_response"]),
|
||||
responsibleUserId: z.string().nullable(),
|
||||
}).transform(value => ({ ...value, biller: value.biller ?? value.provider }));
|
||||
|
||||
|
||||
@@ -441,6 +441,7 @@ export {
|
||||
resolveIssueRecoveryActionSchema,
|
||||
isValidExistingBranchName,
|
||||
retryWorkspaceExportSchema,
|
||||
resumeWorkspaceFinalizationSchema,
|
||||
issueReviewRequestSchema,
|
||||
issueExecutionWorkspaceSettingsSchema,
|
||||
checkoutIssueSchema,
|
||||
@@ -996,3 +997,5 @@ export { restoreAgentInstructionSchema } from "./agent.js";
|
||||
|
||||
export * from "./skill-source.js";
|
||||
export * from "./agent-commentary.js";
|
||||
export * from "./task-workspace.js";
|
||||
export * from "./workspace-repository.js";
|
||||
@@ -73,6 +73,7 @@ export const instanceExperimentalSettingsSchema = z.object({
|
||||
enableSummaries: z.boolean().default(false),
|
||||
enableStatusCards: z.boolean().default(false),
|
||||
enableDecisions: z.boolean().default(false),
|
||||
enableFastResponses: z.boolean().default(false),
|
||||
enableGoalsSidebarLink: z.boolean().default(false),
|
||||
enableServerInfoDebugView: z.boolean().default(false),
|
||||
enablePaperclipDeveloperMode: z.boolean().default(false),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { taskWorkspaceSelectionSchema } from "./task-workspace.js";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
ISSUE_EXECUTION_DECISION_OUTCOMES,
|
||||
@@ -556,6 +557,14 @@ const RESOLVE_ISSUE_RECOVERY_ACTION_OUTCOMES = [
|
||||
"cancelled",
|
||||
] as const;
|
||||
|
||||
export const resumeWorkspaceFinalizationSchema = z.object({
|
||||
actionId: z.string().guid(),
|
||||
runId: z.string().guid(),
|
||||
ownerToken: z.string().guid(),
|
||||
controllerAndCopybackStopped: z.literal(true),
|
||||
stopEvidence: z.string().trim().min(20).max(12000),
|
||||
}).strict();
|
||||
|
||||
export const retryWorkspaceExportSchema = z.object({
|
||||
actionId: z.string().guid(),
|
||||
runId: z.string().guid(),
|
||||
@@ -737,6 +746,7 @@ const createIssueBaseSchema = z.object({
|
||||
.enum(ISSUE_EXECUTION_WORKSPACE_PREFERENCES)
|
||||
.optional()
|
||||
.nullable(),
|
||||
workspaceSelection: taskWorkspaceSelectionSchema.optional(),
|
||||
executionWorkspaceSettings: issueExecutionWorkspaceSettingsSchema
|
||||
.optional()
|
||||
.nullable(),
|
||||
@@ -884,6 +894,7 @@ const issueCommentAttachmentIdsSchema = z
|
||||
|
||||
export const updateIssueSchema = objectWithoutDefaults(
|
||||
createIssueBaseSchema.omit({
|
||||
workspaceSelection: true,
|
||||
createdByUserId: true,
|
||||
responsibleUserId: true,
|
||||
watchdog: true,
|
||||
|
||||
@@ -39,6 +39,15 @@ describe("plugin manifest validators", () => {
|
||||
expect(pluginManifestV1Schema.parse({ ...manifest, capabilities: ["agents.lifecycle.manage"] }).agentLifecycle).toBe(true);
|
||||
});
|
||||
|
||||
it("requires subscription authority and known resource types for durable delivery", () => {
|
||||
const manifest = { id: "example.lifecycle", apiVersion: 1, version: "1.0.0", displayName: "Lifecycle", description: "Lifecycle tests", author: "Tests", categories: ["automation"], entrypoints: { worker: "worker.js" }, resourceLifecycle: ["project"] };
|
||||
expect(pluginManifestV1Schema.safeParse({ ...manifest, capabilities: ["projects.read"] }).success).toBe(false);
|
||||
expect(pluginManifestV1Schema.parse({ ...manifest, capabilities: ["events.subscribe"] }).resourceLifecycle).toEqual(["project"]);
|
||||
for (const resourceLifecycle of [[], ["issue"]]) {
|
||||
expect(pluginManifestV1Schema.safeParse({ ...manifest, resourceLifecycle, capabilities: ["events.subscribe"] }).success).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it("requires routing authority for native pooled connector declarations without a custom UI bundle", () => {
|
||||
const manifest = { id: "example.pool", apiVersion: 1, version: "0.1.0", displayName: "Pool", description: "Pool", author: "Tests", categories: ["connector"], entrypoints: { worker: "worker.js" }, aiConnectionRouter: { name: "AI connection pool", description: "Use saved connections" } };
|
||||
expect(pluginManifestV1Schema.safeParse({ ...manifest, capabilities: ["ui.page.register"] }).success).toBe(false);
|
||||
|
||||
@@ -783,6 +783,7 @@ export const pluginManifestV1Schema = z.object({
|
||||
).optional(),
|
||||
capabilities: z.array(z.enum(PLUGIN_CAPABILITIES)).min(1),
|
||||
agentLifecycle: z.literal(true).optional(),
|
||||
resourceLifecycle: z.array(z.enum(["agent", "project"])).min(1).max(2).optional(),
|
||||
aiConnectionRouter: z.object({ name: z.string().trim().min(1).max(100), description: z.string().trim().min(1).max(500) }).strict().optional(),
|
||||
entrypoints: z.object({
|
||||
worker: z.string().min(1),
|
||||
@@ -811,6 +812,10 @@ export const pluginManifestV1Schema = z.object({
|
||||
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Agent lifecycle participation requires agents.lifecycle.manage", path: ["capabilities"] });
|
||||
}
|
||||
|
||||
if (manifest.resourceLifecycle && !manifest.capabilities.includes("events.subscribe")) {
|
||||
ctx.addIssue({ code: z.ZodIssueCode.custom, message: "Resource lifecycle delivery requires events.subscribe", path: ["capabilities"] });
|
||||
}
|
||||
|
||||
// ── Entrypoint ↔ UI slot consistency ──────────────────────────────────
|
||||
// Plugins that declare UI slots must also declare a UI entrypoint so the
|
||||
// host knows where to load the bundle from (PLUGIN_SPEC.md §10.1).
|
||||
|
||||
@@ -4,6 +4,7 @@ const repositoryUrl = z.string().trim().max(2048).refine(value => parseGitHubSki
|
||||
const repoPath = z.string().max(4096).refine(value => !value.startsWith('/') && !value.includes('\\') && !value.includes('\0') && !value.split('/').some(part => part === '..' || part === '.'), 'Invalid repository path');
|
||||
export const skillSourceDiscoverySchema = z.object({
|
||||
repositoryUrl,
|
||||
packageMode: z.enum(['skills', 'repository']).optional(),
|
||||
trackingRef: z.string().trim().min(1).max(255).optional(),
|
||||
connectionId: z.string().uuid().nullable().optional(),
|
||||
});
|
||||
@@ -18,8 +19,14 @@ export const skillSourceCreateSchema = skillSourceDiscoverySchema.extend({
|
||||
excludedFolders: z.array(repoPath).max(10000).default([]),
|
||||
});
|
||||
export const skillSourceSelectionSchema = z.object({
|
||||
packageMode: z.enum(['skills', 'repository']).optional(),
|
||||
revision: z.number().int().nonnegative(),
|
||||
selectedPaths: z.array(repoPath).max(10000),
|
||||
excludedFolders: z.array(repoPath).max(10000),
|
||||
connectionId: z.string().uuid().nullable().optional(),
|
||||
});
|
||||
|
||||
export const skillSourceDisconnectSchema = z.object({
|
||||
revision: z.number().int().nonnegative(),
|
||||
skills: z.enum(['copy', 'delete']),
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { z } from "zod";
|
||||
export const taskWorkspaceSelectionSchema = z.discriminatedUnion("kind", [
|
||||
z.object({ kind: z.literal("task_directory") }).strict(),
|
||||
z.object({ kind: z.literal("existing"), workspaceId: z.string().uuid() }).strict(),
|
||||
z.object({ kind: z.literal("configured_source"), projectWorkspaceId: z.string().uuid(), mode: z.enum(["shared", "managed_isolated"]) }).strict(),
|
||||
]);
|
||||
export const taskWorkspaceIntentSchema = z.object({
|
||||
version: z.literal(1), request: z.object({ key: z.string().min(1).max(200), expectedBindingRevision: z.number().int().nonnegative() }).strict().optional(), selection: taskWorkspaceSelectionSchema,
|
||||
source: z.enum(["explicit", "parent", "channel", "project", "operator_cwd", "task_default", "legacy"]),
|
||||
}).strict();
|
||||
export const selectTaskWorkspaceSchema = z.object({
|
||||
selection: taskWorkspaceSelectionSchema,
|
||||
expectedBindingRevision: z.number().int().nonnegative(),
|
||||
requestKey: z.string().trim().min(1).max(200),
|
||||
}).strict();
|
||||
@@ -0,0 +1,11 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const prepareWorkspaceRepositorySchema = z.object({
|
||||
repository: z.discriminatedUnion("kind", [
|
||||
z.object({ kind: z.literal("catalog"), id: z.string().min(1).max(255) }).strict(),
|
||||
z.object({ kind: z.literal("url"), url: z.string().url().max(2048) }).strict(),
|
||||
]),
|
||||
ref: z.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._\/-]*$/).refine(value => !value.includes("..") && !value.includes("//"), "Invalid Git ref").optional(),
|
||||
requestKey: z.string().min(1).max(240),
|
||||
}).strict();
|
||||
export type PrepareWorkspaceRepository = z.infer<typeof prepareWorkspaceRepositorySchema>;
|
||||
@@ -7,7 +7,7 @@ import { resolveCanonicalWorktreeSeedSource } from "./worktree-seed-source.js";
|
||||
const cleanup: string[] = [];
|
||||
|
||||
function makeInstance(prefix: string, instanceId: string) {
|
||||
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
||||
const cwd = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), prefix));
|
||||
cleanup.push(cwd);
|
||||
const configDir = path.join(cwd, ".paperclip");
|
||||
const configPath = path.join(configDir, "config.json");
|
||||
@@ -22,7 +22,7 @@ function makeInstance(prefix: string, instanceId: string) {
|
||||
* names its instance by directory and has no adjacent .env.
|
||||
*/
|
||||
function makeInstanceRoot(instanceId: string) {
|
||||
const home = fs.mkdtempSync(path.join(os.tmpdir(), "paperclip-seed-home-"));
|
||||
const home = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), "paperclip-seed-home-"));
|
||||
cleanup.push(home);
|
||||
const configDir = path.join(home, "instances", instanceId);
|
||||
fs.mkdirSync(configDir, { recursive: true });
|
||||
@@ -33,7 +33,7 @@ function makeInstanceRoot(instanceId: string) {
|
||||
|
||||
/** A managed project checkout: a plain clone with no `.paperclip` of its own. */
|
||||
function makePlainCheckout() {
|
||||
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), "paperclip-seed-checkout-"));
|
||||
const cwd = fs.mkdtempSync(path.join(fs.realpathSync(os.tmpdir()), "paperclip-seed-checkout-"));
|
||||
cleanup.push(cwd);
|
||||
return cwd;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user