@autoposting.ai/cli 0.2.31 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../sdk/src/index.ts","../../sdk/src/version.ts","../../sdk/src/errors.ts","../../sdk/src/resource.ts","../../sdk/src/resources/agents.ts","../../sdk/src/resources/billing.ts","../../sdk/src/resources/brands.ts","../../sdk/src/resources/carousels.ts","../../sdk/src/resources/clips.ts","../../sdk/src/resources/posts.ts","../../sdk/src/resources/kb.ts","../../sdk/src/resources/ideas.ts","../../sdk/src/resources/usage.ts","../../sdk/src/resources/webhooks.ts","../../sdk/src/resources/workspaces.ts","../../sdk/src/client.ts","../src/mcp/tools.ts","../src/mcp/handler.ts","../src/mcp/server.ts","../src/cli.ts","../src/commands/agents.ts","../src/auth/credential-store.ts","../src/auth/auth-manager.ts","../src/output/formatter.ts","../src/output/spinner.ts","../src/output/printer.ts","../src/output/exit-codes.ts","../src/commands/auth.ts","../src/auth/device-code-client.ts","../src/commands/billing.ts","../src/commands/brands.ts","../src/commands/carousels.ts","../src/commands/clips.ts","../src/commands/posts.ts","../src/commands/kb.ts","../src/commands/ideas.ts","../src/commands/usage.ts","../src/commands/webhooks.ts","../src/commands/workspaces.ts","../src/commands/doctor.ts","../src/commands/whoami.ts","../src/commands/open.ts","../src/commands/update.ts","../src/commands/completion.ts","../src/commands/mcp.ts"],"sourcesContent":["export { Autoposting, type AutopostingConfig } from './client'\nexport { AgentsResource } from './resources/agents'\nexport type { Agent, AgentRun, CreateAgentParams, UpdateAgentParams } from './types/agents'\nexport { BillingResource } from './resources/billing'\nexport type { BillingStatus, CreditBalance } from './types/billing'\nexport { BrandsResource } from './resources/brands'\nexport type { Brand, CreateBrandParams, UpdateBrandParams, PlatformConnection } from './types/brands'\nexport { CarouselsResource } from './resources/carousels'\nexport type { Carousel, CarouselSlide, CreateCarouselParams, GenerateCarouselParams } from './types/carousels'\nexport { ClipsResource } from './resources/clips'\nexport type { Clip, ClipStatus, ImportClipParams } from './types/clips'\nexport { PostsResource } from './resources/posts'\nexport type { Post, CreatePostParams, UpdatePostParams, ListPostsParams, MediaItem } from './types/posts'\nexport { KbResource } from './resources/kb'\nexport { IdeasResource } from './resources/ideas'\nexport { UsageResource } from './resources/usage'\nexport type { UsageSummary } from './types/usage'\nexport { WebhooksResource } from './resources/webhooks'\nexport type { Webhook, CreateWebhookParams, UpdateWebhookParams } from './types/webhooks'\nexport { WorkspacesResource } from './resources/workspaces'\nexport type { Workspace } from './types/workspaces'\nexport type {\n KnowledgeBase,\n KbDocument,\n CreateKbParams,\n SearchResult,\n Idea,\n GenerateIdeasParams,\n} from './types/kb'\nexport {\n AutopostingError,\n AuthenticationError,\n ScopeError,\n NotFoundError,\n ValidationError,\n RateLimitError,\n ServerError,\n} from './errors'\nexport { Resource } from './resource'\nexport type { Platform, PaginatedResponse, ApiResponse } from './types'\nexport { VERSION } from './version'\n","export const VERSION = '0.1.0'\n","export class AutopostingError extends Error {\n status: number\n code: string\n\n constructor(message: string, status: number, code: string) {\n super(message)\n this.name = this.constructor.name\n this.status = status\n this.code = code\n // Restore prototype chain (required for custom Error subclasses in TS)\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport class AuthenticationError extends AutopostingError {}\nexport class ScopeError extends AutopostingError {}\nexport class NotFoundError extends AutopostingError {}\nexport class ValidationError extends AutopostingError {}\n\nexport class RateLimitError extends AutopostingError {\n retryAfter?: number\n}\n\nexport class ServerError extends AutopostingError {}\n\nexport function createError(\n status: number,\n body: { error?: string; code?: string },\n): AutopostingError {\n const message = body.error ?? 'An error occurred'\n const code = body.code ?? 'UNKNOWN'\n\n if (status === 401) return new AuthenticationError(message, status, code)\n if (status === 403) return new ScopeError(message, status, code)\n if (status === 404) return new NotFoundError(message, status, code)\n if (status === 400 || status === 422) return new ValidationError(message, status, code)\n if (status === 429) return new RateLimitError(message, status, code)\n if (status >= 500) return new ServerError(message, status, code)\n\n return new AutopostingError(message, status, code)\n}\n","import type { Autoposting } from './client'\n\nexport abstract class Resource {\n constructor(protected client: Autoposting) {}\n\n protected get<T>(path: string, query?: Record<string, unknown>): Promise<T> {\n return this.client.request<T>('GET', path, undefined, query)\n }\n\n protected post<T>(path: string, body?: unknown): Promise<T> {\n return this.client.request<T>('POST', path, body)\n }\n\n protected put<T>(path: string, body?: unknown): Promise<T> {\n return this.client.request<T>('PUT', path, body)\n }\n\n protected patch<T>(path: string, body?: unknown): Promise<T> {\n return this.client.request<T>('PATCH', path, body)\n }\n\n protected delete<T>(path: string): Promise<T> {\n return this.client.request<T>('DELETE', path)\n }\n}\n","import { Resource } from '../resource'\nimport type { Agent, AgentRun, CreateAgentParams, UpdateAgentParams } from '../types/agents'\n\nexport class AgentsResource extends Resource {\n list(): Promise<Agent[]> {\n return this.get<Agent[]>('/agents')\n }\n\n retrieve(id: string): Promise<Agent> {\n return this.get<Agent>(`/agents/${id}`)\n }\n\n create(params: CreateAgentParams): Promise<Agent> {\n return this.post<Agent>('/agents', params)\n }\n\n update(id: string, params: UpdateAgentParams): Promise<Agent> {\n return this.patch<Agent>(`/agents/${id}`, params)\n }\n\n remove(id: string): Promise<void> {\n return this.delete<void>(`/agents/${id}`)\n }\n\n run(id: string): Promise<AgentRun> {\n return this.post<AgentRun>(`/agents/${id}/run`)\n }\n\n toggle(id: string): Promise<Agent> {\n return this.post<Agent>(`/agents/${id}/toggle`)\n }\n\n runs(id: string): Promise<AgentRun[]> {\n return this.get<AgentRun[]>(`/agents/${id}/runs`)\n }\n}\n","import { Resource } from '../resource'\nimport type { BillingStatus, CreditBalance } from '../types/billing'\n\nexport class BillingResource extends Resource {\n status(): Promise<BillingStatus> {\n return this.get<BillingStatus>('/billing/status')\n }\n\n credits(): Promise<CreditBalance> {\n return this.get<CreditBalance>('/billing/credits')\n }\n}\n","import { Resource } from '../resource'\nimport type { Brand, CreateBrandParams, PlatformConnection, UpdateBrandParams } from '../types/brands'\n\nexport class BrandsResource extends Resource {\n list(): Promise<Brand[]> {\n return this.get<Brand[]>('/brands')\n }\n\n retrieve(slug: string): Promise<Brand> {\n return this.get<Brand>(`/brands/${slug}`)\n }\n\n create(params: CreateBrandParams): Promise<Brand> {\n return this.post<Brand>('/brands', params)\n }\n\n update(slug: string, params: UpdateBrandParams): Promise<Brand> {\n return this.patch<Brand>(`/brands/${slug}`, params)\n }\n\n remove(slug: string): Promise<void> {\n return this.delete<void>(`/brands/${slug}`)\n }\n\n authStatus(slug: string): Promise<PlatformConnection[]> {\n return this.get<PlatformConnection[]>(`/brands/${slug}/auth/status`)\n }\n}\n","import { Resource } from '../resource'\nimport type { Carousel, CreateCarouselParams, GenerateCarouselParams } from '../types/carousels'\n\nexport class CarouselsResource extends Resource {\n list(): Promise<Carousel[]> {\n return this.get<Carousel[]>('/carousels')\n }\n\n retrieve(id: string): Promise<Carousel> {\n return this.get<Carousel>(`/carousels/${id}`)\n }\n\n create(params?: CreateCarouselParams): Promise<Carousel> {\n return this.post<Carousel>('/carousels', params)\n }\n\n generate(params: GenerateCarouselParams): Promise<Carousel> {\n return this.post<Carousel>('/carousels/generate', params)\n }\n\n /** POST /carousels/:id/draft — converts carousel to a post draft */\n draft(id: string): Promise<Carousel> {\n return this.post<Carousel>(`/carousels/${id}/draft`)\n }\n\n remove(id: string): Promise<void> {\n return this.client.request<void>('DELETE', `/carousels/${id}`)\n }\n}\n","import { Resource } from '../resource'\nimport type { Clip, ImportClipParams } from '../types/clips'\n\nexport class ClipsResource extends Resource {\n list(): Promise<Clip[]> {\n return this.client.request<Clip[]>('GET', '/clips')\n }\n\n retrieve(id: string): Promise<Clip> {\n return this.client.request<Clip>('GET', `/clips/${id}`)\n }\n\n async upload(\n filePath: string,\n options?: { name?: string; onProgress?: (pct: number) => void },\n ): Promise<Clip> {\n const fs = await import('node:fs')\n const path = await import('node:path')\n const data = fs.readFileSync(filePath)\n const name = options?.name ?? path.basename(filePath)\n\n const formData = new FormData()\n formData.append('file', new Blob([data]), name)\n formData.append('name', name)\n\n // onProgress not supported in single-request upload — signal start/end only\n options?.onProgress?.(0)\n const clip = await this.client.request<Clip>('POST', '/clips/upload', formData)\n options?.onProgress?.(100)\n return clip\n }\n\n importUrl(params: ImportClipParams): Promise<Clip> {\n return this.client.request<Clip>('POST', '/clips/import', params)\n }\n\n render(id: string): Promise<Clip> {\n return this.client.request<Clip>('POST', `/clips/${id}/render`)\n }\n\n remove(id: string): Promise<void> {\n return this.client.request<void>('DELETE', `/clips/${id}`)\n }\n}\n","import { Resource } from '../resource'\nimport type { Post, CreatePostParams, UpdatePostParams, ListPostsParams } from '../types/posts'\nimport type { PaginatedResponse } from '../types'\n\n// PostsResource methods `get` and `delete` cannot directly override the base class\n// protected generics (`get<T>`, `delete<T>`) due to TypeScript generic covariance rules.\n// We call `this.client.request` directly and expose public methods with unambiguous names.\n// The public API surface is: list, get, create, update, delete, publish, schedule, retry, rewrite, score.\nexport class PostsResource extends Resource {\n list(params?: ListPostsParams): Promise<PaginatedResponse<Post>> {\n return this.client.request<PaginatedResponse<Post>>(\n 'GET',\n '/v1/posts',\n undefined,\n params as Record<string, unknown>,\n )\n }\n\n /** GET /v1/posts/:id */\n getById(id: string): Promise<Post> {\n return this.client.request<Post>('GET', `/v1/posts/${id}`)\n }\n\n create(params: CreatePostParams): Promise<Post> {\n return this.client.request<Post>('POST', '/v1/posts', params)\n }\n\n update(id: string, params: UpdatePostParams): Promise<Post> {\n return this.client.request<Post>('PUT', `/v1/posts/${id}`, params)\n }\n\n /** DELETE /v1/posts/:id */\n remove(id: string): Promise<void> {\n return this.client.request<void>('DELETE', `/v1/posts/${id}`)\n }\n\n publish(id: string): Promise<Post> {\n return this.client.request<Post>('POST', `/v1/posts/${id}/publish`)\n }\n\n schedule(id: string, scheduledAt: string): Promise<Post> {\n return this.client.request<Post>('PUT', `/v1/posts/${id}/schedule`, { scheduledAt })\n }\n\n retry(id: string): Promise<Post> {\n return this.client.request<Post>('POST', `/v1/posts/${id}/retry`)\n }\n\n rewrite(id: string): Promise<Post> {\n return this.client.request<Post>('POST', `/v1/posts/${id}/rewrite`)\n }\n\n score(id: string): Promise<{ score: number; feedback: string }> {\n return this.client.request<{ score: number; feedback: string }>(\n 'POST',\n `/v1/posts/${id}/score`,\n )\n }\n}\n","import { Resource } from '../resource'\nimport type { KnowledgeBase, KbDocument, CreateKbParams, SearchResult } from '../types/kb'\n\nexport class KbResource extends Resource {\n list(): Promise<KnowledgeBase[]> {\n return this.get<KnowledgeBase[]>('/kbs')\n }\n\n retrieve(id: string): Promise<KnowledgeBase> {\n return this.get<KnowledgeBase>(`/kbs/${id}`)\n }\n\n create(params: CreateKbParams): Promise<KnowledgeBase> {\n return this.post<KnowledgeBase>('/kbs', params)\n }\n\n remove(id: string): Promise<void> {\n return this.delete<void>(`/kbs/${id}`)\n }\n\n search(id: string, query: string): Promise<SearchResult[]> {\n return this.post<SearchResult[]>(`/kbs/${id}/search`, { query })\n }\n\n ingestUrl(id: string, url: string): Promise<KbDocument> {\n return this.post<KbDocument>(`/kbs/${id}/docs/ingest-url`, { url })\n }\n\n docs(id: string): Promise<KbDocument[]> {\n return this.get<KbDocument[]>(`/kbs/${id}/docs`)\n }\n}\n","import { Resource } from '../resource'\nimport type { Idea, GenerateIdeasParams } from '../types/kb'\n\nexport class IdeasResource extends Resource {\n generate(params: GenerateIdeasParams = {}): Promise<Idea[]> {\n return this.post<Idea[]>('/ideas/generate', params)\n }\n\n list(): Promise<Idea[]> {\n return this.get<Idea[]>('/ideas')\n }\n\n enrich(id: string): Promise<Idea> {\n return this.post<Idea>(`/ideas/${id}/enrich`)\n }\n\n remove(id: string): Promise<void> {\n return this.delete<void>(`/ideas/${id}`)\n }\n}\n","import { Resource } from '../resource'\nimport type { UsageSummary } from '../types/usage'\n\nexport class UsageResource extends Resource {\n summary(): Promise<UsageSummary> {\n return this.get<UsageSummary>('/usage/summary')\n }\n}\n","import { Resource } from '../resource'\nimport type { Webhook, CreateWebhookParams, UpdateWebhookParams } from '../types/webhooks'\n\nexport class WebhooksResource extends Resource {\n list(): Promise<Webhook[]> {\n return this.get<Webhook[]>('/webhooks')\n }\n\n retrieve(id: string): Promise<Webhook> {\n return this.get<Webhook>(`/webhooks/${id}`)\n }\n\n create(params: CreateWebhookParams): Promise<Webhook> {\n return this.post<Webhook>('/webhooks', params)\n }\n\n update(id: string, params: UpdateWebhookParams): Promise<Webhook> {\n return this.patch<Webhook>(`/webhooks/${id}`, params)\n }\n\n remove(id: string): Promise<void> {\n return this.client.request<void>('DELETE', `/webhooks/${id}`)\n }\n\n test(id: string): Promise<void> {\n return this.post<void>(`/webhooks/${id}/test`)\n }\n}\n","import { Resource } from '../resource'\nimport type { Workspace } from '../types/workspaces'\nimport type { Autoposting } from '../client'\n\nexport class WorkspacesResource extends Resource {\n constructor(client: Autoposting) {\n super(client)\n }\n\n list(): Promise<Workspace[]> {\n return this.get<Workspace[]>('/orgs')\n }\n\n switchWorkspace(id: string): Promise<void> {\n // API keys are scoped to a single workspace at creation time.\n // Switching requires a session token that can act across orgs.\n if (this.client.authSource === 'api-key') {\n return Promise.reject(\n new Error(\n 'API keys are bound to a single workspace. Use session auth to switch.',\n ),\n )\n }\n return this.post<void>('/orgs/set-active', { organizationId: id })\n }\n}\n","import { VERSION } from './version'\nimport { createError, RateLimitError } from './errors'\nimport { AgentsResource } from './resources/agents'\nimport { BillingResource } from './resources/billing'\nimport { BrandsResource } from './resources/brands'\nimport { CarouselsResource } from './resources/carousels'\nimport { ClipsResource } from './resources/clips'\nimport { PostsResource } from './resources/posts'\nimport { KbResource } from './resources/kb'\nimport { IdeasResource } from './resources/ideas'\nimport { UsageResource } from './resources/usage'\nimport { WebhooksResource } from './resources/webhooks'\nimport { WorkspacesResource } from './resources/workspaces'\n\nexport interface AutopostingConfig {\n apiKey?: string\n baseUrl?: string\n timeout?: number\n headers?: Record<string, string>\n /** Mark the auth source so workspace-switching can enforce API key restrictions. */\n authSource?: 'api-key' | 'session'\n}\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n\nexport class Autoposting {\n /** @internal Not part of the public API — use SDK methods to make requests. */\n private readonly _apiKey: string\n readonly baseUrl: string\n readonly timeout: number\n private readonly extraHeaders: Record<string, string>\n /** Indicates how the client was authenticated; used by WorkspacesResource. */\n readonly authSource: 'api-key' | 'session'\n readonly agents: AgentsResource\n readonly billing: BillingResource\n readonly brands: BrandsResource\n readonly carousels: CarouselsResource\n readonly clips: ClipsResource\n readonly posts: PostsResource\n readonly kb: KbResource\n readonly ideas: IdeasResource\n readonly usage: UsageResource\n readonly webhooks: WebhooksResource\n readonly workspaces: WorkspacesResource\n\n constructor(config: AutopostingConfig = {}) {\n const key = config.apiKey ?? process.env.AUTOPOSTING_API_KEY\n if (!key) {\n throw new Error(\n 'API key is required. Pass apiKey in config or set AUTOPOSTING_API_KEY env var.',\n )\n }\n this._apiKey = key\n this.baseUrl = (config.baseUrl ?? 'https://app.autoposting.ai').replace(/\\/$/, '')\n this.timeout = config.timeout ?? 30_000\n this.extraHeaders = config.headers ?? {}\n this.authSource = config.authSource ?? 'api-key'\n this.agents = new AgentsResource(this)\n this.billing = new BillingResource(this)\n this.brands = new BrandsResource(this)\n this.carousels = new CarouselsResource(this)\n this.clips = new ClipsResource(this)\n this.posts = new PostsResource(this)\n this.kb = new KbResource(this)\n this.ideas = new IdeasResource(this)\n this.usage = new UsageResource(this)\n this.webhooks = new WebhooksResource(this)\n this.workspaces = new WorkspacesResource(this)\n }\n\n async request<T = unknown>(\n method: HttpMethod,\n path: string,\n body?: unknown,\n query?: Record<string, unknown>,\n ): Promise<T> {\n let url = `${this.baseUrl}${path}`\n\n if (query && Object.keys(query).length > 0) {\n const params = new URLSearchParams()\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined && v !== null) {\n params.set(k, String(v))\n }\n }\n url = `${url}?${params.toString()}`\n }\n\n // FormData must not have a content-type header — fetch sets it with the multipart boundary\n const isFormData = body instanceof FormData\n const headers: Record<string, string> = {\n authorization: `Bearer ${this._apiKey}`,\n 'user-agent': `autoposting-sdk/${VERSION}`,\n 'x-source': 'sdk',\n ...this.extraHeaders,\n }\n if (!isFormData) {\n headers['content-type'] = 'application/json'\n }\n\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n\n let response: Response\n try {\n response = await fetch(url, {\n method,\n headers,\n body: isFormData ? body : body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n })\n } finally {\n clearTimeout(timer)\n }\n\n if (!response.ok) {\n let errorBody: { error?: string; code?: string } = {}\n try {\n errorBody = (await response.json()) as { error?: string; code?: string }\n } catch {\n // non-JSON error body — leave as empty object\n }\n\n const err = createError(response.status, errorBody)\n\n if (err instanceof RateLimitError) {\n const retryAfter = response.headers.get('Retry-After')\n if (retryAfter) {\n err.retryAfter = parseInt(retryAfter, 10)\n }\n }\n\n throw err\n }\n\n // 204 No Content — return empty object\n if (response.status === 204) {\n return {} as T\n }\n\n return response.json() as Promise<T>\n }\n}\n","import type { Tool } from '@modelcontextprotocol/sdk/types.js'\n\nexport const ALL_TOOLS: Tool[] = [\n // Posts\n {\n name: 'list-posts',\n description: 'List posts with optional filters by brand, status, limit, and page.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Filter by brand slug' },\n status: {\n type: 'string',\n enum: ['draft', 'scheduled', 'published', 'failed'],\n description: 'Filter by post status',\n },\n limit: { type: 'number', description: 'Max results per page (default 20)' },\n page: { type: 'number', description: 'Page number (default 1)' },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'get-post',\n description: 'Get a post by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-post',\n description: 'Create a new post draft for a brand on one or more platforms.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Brand slug to post under' },\n text: { type: 'string', description: 'Post text content' },\n platforms: {\n type: 'string',\n description: 'Comma-separated platform list (e.g. x,linkedin)',\n },\n scheduledAt: {\n type: 'string',\n description: 'ISO 8601 datetime to schedule the post',\n },\n },\n required: ['brandSlug', 'text', 'platforms'],\n additionalProperties: false,\n },\n },\n {\n name: 'update-post',\n description: 'Update the text, platforms, or scheduled time of an existing post.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID' },\n text: { type: 'string', description: 'New post text' },\n platforms: { type: 'string', description: 'Comma-separated new platform list' },\n scheduledAt: { type: 'string', description: 'New ISO 8601 scheduled datetime' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-post',\n description: 'Permanently delete a post by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'publish-post',\n description: 'Immediately publish a post to all its platforms.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to publish' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'schedule-post',\n description: 'Schedule a post to be published at a specific date and time.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to schedule' },\n scheduledAt: { type: 'string', description: 'ISO 8601 datetime for publishing' },\n },\n required: ['id', 'scheduledAt'],\n additionalProperties: false,\n },\n },\n {\n name: 'retry-post',\n description: 'Retry publishing a failed post.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to retry' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'rewrite-post',\n description: 'AI-rewrite the text of a post.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to rewrite' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'score-post',\n description: 'Score a post with AI feedback and return a numeric score with explanation.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to score' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Brands\n {\n name: 'list-brands',\n description: 'List all brands in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-brand',\n description: 'Get a brand by its slug.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Brand slug' },\n },\n required: ['brandSlug'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-brand',\n description: 'Create a new brand in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: 'Brand display name' },\n timezone: { type: 'string', description: 'IANA timezone (e.g. America/New_York)' },\n },\n required: ['name'],\n additionalProperties: false,\n },\n },\n {\n name: 'update-brand',\n description: 'Update a brand name or timezone.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Brand slug to update' },\n name: { type: 'string', description: 'New display name' },\n timezone: { type: 'string', description: 'New IANA timezone' },\n },\n required: ['brandSlug'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-brand',\n description: 'Permanently delete a brand by slug.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Brand slug to delete' },\n },\n required: ['brandSlug'],\n additionalProperties: false,\n },\n },\n {\n name: 'brand-auth-status',\n description: 'Show the platform connection status for a brand.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Brand slug' },\n },\n required: ['brandSlug'],\n additionalProperties: false,\n },\n },\n\n // Agents\n {\n name: 'list-agents',\n description: 'List all agents in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-agent',\n description: 'Get an agent by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-agent',\n description: 'Create a new publish or research agent.',\n inputSchema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: 'Agent name' },\n type: {\n type: 'string',\n enum: ['publish', 'research'],\n description: 'Agent type',\n },\n brandSlug: { type: 'string', description: 'Brand slug to associate with' },\n prompt: { type: 'string', description: 'Agent instructions or prompt' },\n frequency: {\n type: 'string',\n enum: ['manual', 'daily', 'weekly'],\n description: 'Run frequency',\n },\n time: { type: 'string', description: 'Time of day to run (HH:MM)' },\n weekday: { type: 'string', description: 'Day of week (required for weekly frequency)' },\n kbId: { type: 'string', description: 'Knowledge base ID to attach' },\n },\n required: ['name', 'type', 'prompt', 'frequency'],\n additionalProperties: false,\n },\n },\n {\n name: 'update-agent',\n description: 'Update an agent name, prompt, frequency, or schedule.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID' },\n name: { type: 'string', description: 'New agent name' },\n prompt: { type: 'string', description: 'New prompt' },\n frequency: { type: 'string', description: 'New frequency: manual, daily, or weekly' },\n time: { type: 'string', description: 'New time of day (HH:MM)' },\n weekday: { type: 'string', description: 'New day of week' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-agent',\n description: 'Permanently delete an agent by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'run-agent',\n description: 'Trigger an immediate run of an agent.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID to run' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'toggle-agent',\n description: 'Enable or disable an agent.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID to toggle' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'agent-runs',\n description: 'List the run history for an agent.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Knowledge Bases\n {\n name: 'list-kbs',\n description: 'List all knowledge bases in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-kb',\n description: 'Get a knowledge base by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Knowledge base ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-kb',\n description: 'Create a new knowledge base.',\n inputSchema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: 'Knowledge base name' },\n },\n required: ['name'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-kb',\n description: 'Permanently delete a knowledge base by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Knowledge base ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'search-kb',\n description: 'Search a knowledge base with a text query.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Knowledge base ID to search' },\n query: { type: 'string', description: 'Search query text' },\n },\n required: ['id', 'query'],\n additionalProperties: false,\n },\n },\n {\n name: 'ingest-kb',\n description: 'Ingest a URL into a knowledge base.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Knowledge base ID to ingest into' },\n url: { type: 'string', description: 'URL to ingest' },\n },\n required: ['id', 'url'],\n additionalProperties: false,\n },\n },\n {\n name: 'kb-docs',\n description: 'List documents stored in a knowledge base.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Knowledge base ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Ideas\n {\n name: 'generate-ideas',\n description: 'AI-generate content ideas, optionally seeded from a knowledge base or topic.',\n inputSchema: {\n type: 'object',\n properties: {\n kbId: { type: 'string', description: 'Knowledge base ID to draw context from' },\n topic: { type: 'string', description: 'Topic or theme for idea generation' },\n count: { type: 'number', description: 'Number of ideas to generate (default 5)' },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'list-ideas',\n description: 'List all saved content ideas.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'enrich-idea',\n description: 'Enrich an idea with additional AI-generated context.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Idea ID to enrich' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-idea',\n description: 'Permanently delete an idea by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Idea ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Clips\n {\n name: 'list-clips',\n description: 'List all video clips in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-clip',\n description: 'Get a video clip by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Clip ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'import-clip',\n description: 'Import a video clip from a remote URL.',\n inputSchema: {\n type: 'object',\n properties: {\n url: { type: 'string', description: 'URL of the video to import' },\n name: { type: 'string', description: 'Optional name for the imported clip' },\n },\n required: ['url'],\n additionalProperties: false,\n },\n },\n {\n name: 'render-clip',\n description: 'Trigger rendering for a video clip.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Clip ID to render' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-clip',\n description: 'Permanently delete a video clip by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Clip ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Carousels\n {\n name: 'list-carousels',\n description: 'List all carousels in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-carousel',\n description: 'Get a carousel by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Carousel ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-carousel',\n description: 'Create a new empty carousel.',\n inputSchema: {\n type: 'object',\n properties: {\n title: { type: 'string', description: 'Optional carousel title' },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'generate-carousel',\n description: 'AI-generate a carousel from a topic.',\n inputSchema: {\n type: 'object',\n properties: {\n topic: { type: 'string', description: 'Topic to generate slides for' },\n brandSlug: { type: 'string', description: 'Brand slug for brand voice' },\n slideCount: { type: 'number', description: 'Number of slides to generate' },\n },\n required: ['topic'],\n additionalProperties: false,\n },\n },\n {\n name: 'draft-carousel',\n description: 'Convert a carousel into a post draft.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Carousel ID to convert' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-carousel',\n description: 'Permanently delete a carousel by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Carousel ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Webhooks\n {\n name: 'list-webhooks',\n description: 'List all webhooks in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-webhook',\n description: 'Get a webhook by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Webhook ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-webhook',\n description: 'Create a new webhook endpoint for receiving events.',\n inputSchema: {\n type: 'object',\n properties: {\n url: { type: 'string', description: 'HTTPS endpoint URL to receive events' },\n events: {\n type: 'string',\n description: 'Comma-separated event types (e.g. post.published,post.failed)',\n },\n secret: { type: 'string', description: 'Optional HMAC signing secret' },\n },\n required: ['url', 'events'],\n additionalProperties: false,\n },\n },\n {\n name: 'update-webhook',\n description: 'Update the URL, events, or active state of a webhook.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Webhook ID' },\n url: { type: 'string', description: 'New endpoint URL' },\n events: { type: 'string', description: 'New comma-separated event types' },\n active: { type: 'boolean', description: 'Whether the webhook is active' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-webhook',\n description: 'Permanently delete a webhook by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Webhook ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'test-webhook',\n description: 'Send a test event to a webhook endpoint.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Webhook ID to send the test event to' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Billing\n {\n name: 'billing-status',\n description: 'Get the current billing plan and subscription status.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'billing-credits',\n description: 'Get the current AI credit balance and usage breakdown.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n\n // Usage\n {\n name: 'usage-summary',\n description: 'Get a summary of post and publishing usage for the current period.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n]\n","import type { Autoposting } from '@autoposting.ai/sdk'\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js'\n\ntype ToolArgs = Record<string, unknown>\n\nfunction ok(data: unknown): CallToolResult {\n return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }\n}\n\nfunction parsePlatforms(raw: unknown): string[] {\n if (typeof raw !== 'string') return []\n return raw.split(',').map((p) => p.trim())\n}\n\nfunction parseEvents(raw: unknown): string[] {\n if (typeof raw !== 'string') return []\n return raw.split(',').map((e) => e.trim())\n}\n\nexport async function handleToolCall(\n name: string,\n args: ToolArgs,\n client: Autoposting,\n): Promise<CallToolResult> {\n switch (name) {\n // Posts\n case 'list-posts': {\n const result = await client.posts.list({\n brandSlug: args.brandSlug as string | undefined,\n status: args.status as 'draft' | 'scheduled' | 'published' | 'failed' | undefined,\n limit: args.limit as number | undefined,\n page: args.page as number | undefined,\n })\n return ok(result)\n }\n case 'get-post': {\n const result = await client.posts.getById(args.id as string)\n return ok(result)\n }\n case 'create-post': {\n const result = await client.posts.create({\n brandSlug: args.brandSlug as string,\n text: args.text as string,\n platforms: parsePlatforms(args.platforms) as ReturnType<typeof parsePlatforms>,\n ...(args.scheduledAt ? { scheduledAt: args.scheduledAt as string } : {}),\n })\n return ok(result)\n }\n case 'update-post': {\n const result = await client.posts.update(args.id as string, {\n ...(args.text ? { text: args.text as string } : {}),\n ...(args.platforms\n ? {\n platforms: parsePlatforms(args.platforms) as ReturnType<typeof parsePlatforms>,\n }\n : {}),\n ...(args.scheduledAt ? { scheduledAt: args.scheduledAt as string } : {}),\n })\n return ok(result)\n }\n case 'delete-post': {\n await client.posts.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n case 'publish-post': {\n const result = await client.posts.publish(args.id as string)\n return ok(result)\n }\n case 'schedule-post': {\n const result = await client.posts.schedule(args.id as string, args.scheduledAt as string)\n return ok(result)\n }\n case 'retry-post': {\n const result = await client.posts.retry(args.id as string)\n return ok(result)\n }\n case 'rewrite-post': {\n const result = await client.posts.rewrite(args.id as string)\n return ok(result)\n }\n case 'score-post': {\n const result = await client.posts.score(args.id as string)\n return ok(result)\n }\n\n // Brands\n case 'list-brands': {\n const result = await client.brands.list()\n return ok(result)\n }\n case 'get-brand': {\n const result = await client.brands.retrieve(args.brandSlug as string)\n return ok(result)\n }\n case 'create-brand': {\n const result = await client.brands.create({\n name: args.name as string,\n ...(args.timezone ? { timezone: args.timezone as string } : {}),\n })\n return ok(result)\n }\n case 'update-brand': {\n const result = await client.brands.update(args.brandSlug as string, {\n ...(args.name ? { name: args.name as string } : {}),\n ...(args.timezone ? { timezone: args.timezone as string } : {}),\n })\n return ok(result)\n }\n case 'delete-brand': {\n await client.brands.remove(args.brandSlug as string)\n return ok({ deleted: true, brandSlug: args.brandSlug })\n }\n case 'brand-auth-status': {\n const result = await client.brands.authStatus(args.brandSlug as string)\n return ok(result)\n }\n\n // Agents\n case 'list-agents': {\n const result = await client.agents.list()\n return ok(result)\n }\n case 'get-agent': {\n const result = await client.agents.retrieve(args.id as string)\n return ok(result)\n }\n case 'create-agent': {\n const result = await client.agents.create({\n name: args.name as string,\n type: args.type as 'publish' | 'research',\n prompt: args.prompt as string,\n frequency: args.frequency as 'manual' | 'daily' | 'weekly',\n ...(args.brandSlug ? { brandSlug: args.brandSlug as string } : {}),\n ...(args.time ? { time: args.time as string } : {}),\n ...(args.weekday ? { weekday: args.weekday as string } : {}),\n ...(args.kbId ? { kbId: args.kbId as string } : {}),\n })\n return ok(result)\n }\n case 'update-agent': {\n const result = await client.agents.update(args.id as string, {\n ...(args.name ? { name: args.name as string } : {}),\n ...(args.prompt ? { prompt: args.prompt as string } : {}),\n ...(args.frequency ? { frequency: args.frequency as string } : {}),\n ...(args.time ? { time: args.time as string } : {}),\n ...(args.weekday ? { weekday: args.weekday as string } : {}),\n })\n return ok(result)\n }\n case 'delete-agent': {\n await client.agents.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n case 'run-agent': {\n const result = await client.agents.run(args.id as string)\n return ok(result)\n }\n case 'toggle-agent': {\n const result = await client.agents.toggle(args.id as string)\n return ok(result)\n }\n case 'agent-runs': {\n const result = await client.agents.runs(args.id as string)\n return ok(result)\n }\n\n // Knowledge Bases\n case 'list-kbs': {\n const result = await client.kb.list()\n return ok(result)\n }\n case 'get-kb': {\n const result = await client.kb.retrieve(args.id as string)\n return ok(result)\n }\n case 'create-kb': {\n const result = await client.kb.create({ name: args.name as string })\n return ok(result)\n }\n case 'delete-kb': {\n await client.kb.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n case 'search-kb': {\n const result = await client.kb.search(args.id as string, args.query as string)\n return ok(result)\n }\n case 'ingest-kb': {\n const result = await client.kb.ingestUrl(args.id as string, args.url as string)\n return ok(result)\n }\n case 'kb-docs': {\n const result = await client.kb.docs(args.id as string)\n return ok(result)\n }\n\n // Ideas\n case 'generate-ideas': {\n const result = await client.ideas.generate({\n ...(args.kbId ? { kbId: args.kbId as string } : {}),\n ...(args.topic ? { topic: args.topic as string } : {}),\n ...(args.count ? { count: args.count as number } : {}),\n })\n return ok(result)\n }\n case 'list-ideas': {\n const result = await client.ideas.list()\n return ok(result)\n }\n case 'enrich-idea': {\n const result = await client.ideas.enrich(args.id as string)\n return ok(result)\n }\n case 'delete-idea': {\n await client.ideas.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n\n // Clips\n case 'list-clips': {\n const result = await client.clips.list()\n return ok(result)\n }\n case 'get-clip': {\n const result = await client.clips.retrieve(args.id as string)\n return ok(result)\n }\n case 'import-clip': {\n const result = await client.clips.importUrl({\n url: args.url as string,\n ...(args.name ? { name: args.name as string } : {}),\n })\n return ok(result)\n }\n case 'render-clip': {\n const result = await client.clips.render(args.id as string)\n return ok(result)\n }\n case 'delete-clip': {\n await client.clips.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n\n // Carousels\n case 'list-carousels': {\n const result = await client.carousels.list()\n return ok(result)\n }\n case 'get-carousel': {\n const result = await client.carousels.retrieve(args.id as string)\n return ok(result)\n }\n case 'create-carousel': {\n const result = await client.carousels.create(\n args.title ? { title: args.title as string } : undefined,\n )\n return ok(result)\n }\n case 'generate-carousel': {\n const result = await client.carousels.generate({\n topic: args.topic as string,\n ...(args.brandSlug ? { brandSlug: args.brandSlug as string } : {}),\n ...(args.slideCount ? { slideCount: args.slideCount as number } : {}),\n })\n return ok(result)\n }\n case 'draft-carousel': {\n const result = await client.carousels.draft(args.id as string)\n return ok(result)\n }\n case 'delete-carousel': {\n await client.carousels.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n\n // Webhooks\n case 'list-webhooks': {\n const result = await client.webhooks.list()\n return ok(result)\n }\n case 'get-webhook': {\n const result = await client.webhooks.retrieve(args.id as string)\n return ok(result)\n }\n case 'create-webhook': {\n const result = await client.webhooks.create({\n url: args.url as string,\n events: parseEvents(args.events),\n ...(args.secret ? { secret: args.secret as string } : {}),\n })\n return ok(result)\n }\n case 'update-webhook': {\n const result = await client.webhooks.update(args.id as string, {\n ...(args.url ? { url: args.url as string } : {}),\n ...(args.events ? { events: parseEvents(args.events) } : {}),\n ...(args.active !== undefined ? { active: args.active as boolean } : {}),\n })\n return ok(result)\n }\n case 'delete-webhook': {\n await client.webhooks.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n case 'test-webhook': {\n await client.webhooks.test(args.id as string)\n return ok({ sent: true, id: args.id })\n }\n\n // Billing\n case 'billing-status': {\n const result = await client.billing.status()\n return ok(result)\n }\n case 'billing-credits': {\n const result = await client.billing.credits()\n return ok(result)\n }\n\n // Usage\n case 'usage-summary': {\n const result = await client.usage.summary()\n return ok(result)\n }\n\n default:\n return {\n content: [{ type: 'text', text: `Unknown tool: ${name}` }],\n isError: true,\n }\n }\n}\n","import { Server } from '@modelcontextprotocol/sdk/server/index.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport {\n ListToolsRequestSchema,\n CallToolRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { ALL_TOOLS } from './tools.js'\nimport { handleToolCall } from './handler.js'\n\nexport async function startMcpServer(): Promise<void> {\n const client = new Autoposting() // reads AUTOPOSTING_API_KEY from env\n\n const server = new Server(\n { name: 'autoposting-mcp', version: '0.1.0' },\n { capabilities: { tools: {} } },\n )\n\n server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: ALL_TOOLS,\n }))\n\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params\n return handleToolCall(name, (args ?? {}) as Record<string, unknown>, client)\n })\n\n const transport = new StdioServerTransport()\n await server.connect(transport)\n}\n","#!/usr/bin/env node\nimport { Command } from 'commander'\nimport { createAgentsCommand } from './commands/agents.js'\nimport { createAuthCommand } from './commands/auth.js'\nimport { createBillingCommand } from './commands/billing.js'\nimport { createBrandsCommand } from './commands/brands.js'\nimport { createCarouselsCommand } from './commands/carousels.js'\nimport { createClipsCommand } from './commands/clips.js'\nimport { createPostsCommand } from './commands/posts.js'\nimport { createKbCommand } from './commands/kb.js'\nimport { createIdeasCommand } from './commands/ideas.js'\nimport { createUsageCommand } from './commands/usage.js'\nimport { createWebhooksCommand } from './commands/webhooks.js'\nimport { createWorkspacesCommand } from './commands/workspaces.js'\nimport { createDoctorCommand } from './commands/doctor.js'\nimport { createWhoamiCommand } from './commands/whoami.js'\nimport { createOpenCommand } from './commands/open.js'\nimport { createUpdateCommand } from './commands/update.js'\nimport { createCompletionCommand } from './commands/completion.js'\nimport { createMcpCommand } from './commands/mcp.js'\nimport { disableColor } from './output/index.js'\n\nconst program = new Command()\n .name('autoposting')\n .description('Autoposting CLI — manage social media from the terminal')\n .version('0.1.0')\n .option('--json', 'Output as JSON')\n .option('--quiet', 'Suppress spinners and non-essential output')\n .option('--format <type>', 'Output format: table, json', 'table')\n .option('--api-key <key>', 'API key (overrides env/stored credentials)')\n .option('--no-color', 'Disable color output')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts<{ color: boolean }>()\n if (!opts.color) disableColor()\n })\n\nprogram.addCommand(createAuthCommand())\nprogram.addCommand(createBillingCommand())\nprogram.addCommand(createBrandsCommand())\nprogram.addCommand(createCarouselsCommand())\nprogram.addCommand(createClipsCommand())\nprogram.addCommand(createPostsCommand())\nprogram.addCommand(createAgentsCommand())\nprogram.addCommand(createKbCommand())\nprogram.addCommand(createIdeasCommand())\nprogram.addCommand(createUsageCommand())\nprogram.addCommand(createWebhooksCommand())\nprogram.addCommand(createWorkspacesCommand())\nprogram.addCommand(createDoctorCommand())\nprogram.addCommand(createWhoamiCommand())\nprogram.addCommand(createOpenCommand())\nprogram.addCommand(createUpdateCommand())\nprogram.addCommand(createCompletionCommand())\nprogram.addCommand(createMcpCommand())\n\nprogram.parse()\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createAgentsCommand(): Command {\n const agents = new Command('agents').description('Manage agents')\n\n // ap agents list\n agents\n .command('list')\n .description('List all agents')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching agents…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.agents.list()\n spinner.stop()\n const rows = list.map((a) => ({\n id: a.id,\n name: a.name,\n type: a.type,\n brand: a.brandSlug ?? '—',\n frequency: a.frequency,\n enabled: a.enabled ? 'yes' : 'no',\n }))\n printer.table(rows, ['id', 'name', 'type', 'brand', 'frequency', 'enabled'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap agents get <id>\n agents\n .command('get <id>')\n .description('Get an agent by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const agent = await client.agents.retrieve(id)\n spinner.stop()\n printer.log(agent)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap agents create --name <name> --type <publish|research> [--brand <slug>] --prompt <text> --frequency <manual|daily|weekly>\n agents\n .command('create')\n .description('Create a new agent')\n .requiredOption('--name <name>', 'Agent name')\n .requiredOption('--type <type>', 'Agent type: publish or research')\n .option('--brand <slug>', 'Brand slug to associate with')\n .requiredOption('--prompt <text>', 'Agent prompt / instructions')\n .requiredOption('--frequency <freq>', 'Run frequency: manual, daily, or weekly')\n .option('--time <HH:MM>', 'Time of day to run (required for daily/weekly)')\n .option('--weekday <day>', 'Day of week to run (required for weekly)')\n .option('--kb <id>', 'Knowledge base ID to attach')\n .action(\n async (\n opts: {\n name: string\n type: string\n brand?: string\n prompt: string\n frequency: string\n time?: string\n weekday?: string\n kb?: string\n },\n cmd: Command,\n ) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating agent…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const agent = await client.agents.create({\n name: opts.name,\n type: opts.type as 'publish' | 'research',\n prompt: opts.prompt,\n frequency: opts.frequency as 'manual' | 'daily' | 'weekly',\n ...(opts.brand ? { brandSlug: opts.brand } : {}),\n ...(opts.time ? { time: opts.time } : {}),\n ...(opts.weekday ? { weekday: opts.weekday } : {}),\n ...(opts.kb ? { kbId: opts.kb } : {}),\n })\n spinner.stop()\n printer.log(agent)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap agents update <id> [--name] [--prompt] [--frequency] [--time] [--weekday]\n agents\n .command('update <id>')\n .description('Update an agent')\n .option('--name <name>', 'New agent name')\n .option('--prompt <text>', 'New prompt / instructions')\n .option('--frequency <freq>', 'New frequency: manual, daily, or weekly')\n .option('--time <HH:MM>', 'New time of day')\n .option('--weekday <day>', 'New day of week')\n .action(\n async (\n id: string,\n opts: { name?: string; prompt?: string; frequency?: string; time?: string; weekday?: string },\n cmd: Command,\n ) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Updating agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const agent = await client.agents.update(id, {\n ...(opts.name ? { name: opts.name } : {}),\n ...(opts.prompt ? { prompt: opts.prompt } : {}),\n ...(opts.frequency ? { frequency: opts.frequency } : {}),\n ...(opts.time ? { time: opts.time } : {}),\n ...(opts.weekday ? { weekday: opts.weekday } : {}),\n })\n spinner.stop()\n printer.log(agent)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap agents delete <id> --force\n agents\n .command('delete <id>')\n .description('Delete an agent (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete an agent. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.agents.remove(id)\n spinner.stop()\n printer.log(`Agent \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap agents run <id>\n agents\n .command('run <id>')\n .description('Trigger an agent run immediately')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Running agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const agentRun = await client.agents.run(id)\n spinner.stop()\n printer.log(agentRun)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap agents toggle <id>\n agents\n .command('toggle <id>')\n .description('Enable or disable an agent')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Toggling agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const agent = await client.agents.toggle(id)\n spinner.stop()\n printer.log(agent)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap agents runs <id>\n agents\n .command('runs <id>')\n .description('List run history for an agent')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching runs for agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.agents.runs(id)\n spinner.stop()\n const rows = list.map((r) => ({\n id: r.id,\n status: r.status,\n output: r.output ? (r.output.length > 60 ? `${r.output.slice(0, 57)}…` : r.output) : '—',\n createdAt: r.createdAt,\n }))\n printer.table(rows, ['id', 'status', 'output', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return agents\n}\n","import fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nexport interface StoredProfile {\n apiKey: string\n workspace?: string\n email?: string\n createdAt: string\n}\n\nexport interface CredentialsFile {\n activeProfile: string\n profiles: Record<string, StoredProfile>\n}\n\nexport function getCredentialsPath(): string {\n const configBase = process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), '.config')\n return path.join(configBase, 'autoposting', 'credentials.json')\n}\n\nexport function readCredentials(): CredentialsFile | null {\n const filePath = getCredentialsPath()\n try {\n const raw = fs.readFileSync(filePath, 'utf8')\n return JSON.parse(raw) as CredentialsFile\n } catch {\n // Missing or corrupt file — return null gracefully\n return null\n }\n}\n\nexport function writeCredentials(creds: CredentialsFile): void {\n const filePath = getCredentialsPath()\n const dir = path.dirname(filePath)\n\n // Use { recursive: true } so mkdirSync is idempotent (avoids TOCTOU race between\n // existsSync + mkdirSync). Mode 0o700 ensures only the owning user can read the dir.\n fs.mkdirSync(dir, { recursive: true, mode: 0o700 })\n\n fs.writeFileSync(filePath, JSON.stringify(creds, null, 2), { encoding: 'utf8', mode: 0o600 })\n\n // Ensure 0600 even if file already existed before\n fs.chmodSync(filePath, 0o600)\n}\n\nexport function saveProfile(name: string, profile: StoredProfile): void {\n const existing = readCredentials()\n const creds: CredentialsFile = existing ?? { activeProfile: name, profiles: {} }\n creds.profiles[name] = profile\n creds.activeProfile = name\n writeCredentials(creds)\n}\n\nexport function deleteProfile(name: string): void {\n const creds = readCredentials()\n if (!creds) return\n\n delete creds.profiles[name]\n\n // If deleted profile was active, clear active or pick another\n if (creds.activeProfile === name) {\n const remaining = Object.keys(creds.profiles)\n creds.activeProfile = remaining[0] ?? ''\n }\n\n writeCredentials(creds)\n}\n\nexport function deleteAllProfiles(): void {\n writeCredentials({ activeProfile: '', profiles: {} })\n}\n\nexport function getActiveProfile(): StoredProfile | null {\n const creds = readCredentials()\n if (!creds || !creds.activeProfile) return null\n return creds.profiles[creds.activeProfile] ?? null\n}\n\nexport function setActiveProfile(name: string): void {\n const creds = readCredentials()\n if (!creds) throw new Error(`Profile \"${name}\" does not exist (no credentials file)`)\n if (!creds.profiles[name]) throw new Error(`Profile \"${name}\" does not exist`)\n creds.activeProfile = name\n writeCredentials(creds)\n}\n","import { getActiveProfile, getCredentialsPath } from './credential-store.js'\n\nexport interface AuthCredentials {\n apiKey: string\n source: 'flag' | 'env' | 'stored'\n profile?: string\n}\n\nexport { getCredentialsPath }\n\n/**\n * Resolves credentials using priority chain:\n * 1. --api-key flag (explicit)\n * 2. AUTOPOSTING_API_KEY env var\n * 3. Stored credentials from file (active profile)\n *\n * Throws with exit-code-2-compatible error when no auth is available.\n */\nexport function resolveAuth(options?: { apiKey?: string }): AuthCredentials {\n // 1. Explicit flag\n if (options?.apiKey) {\n return { apiKey: options.apiKey, source: 'flag' }\n }\n\n // 2. Env var\n const envKey = process.env.AUTOPOSTING_API_KEY\n if (envKey) {\n return { apiKey: envKey, source: 'env' }\n }\n\n // 3. Stored profile\n const profile = getActiveProfile()\n if (profile?.apiKey) {\n return { apiKey: profile.apiKey, source: 'stored' }\n }\n\n const err = new Error(\n 'No API key found. Run `ap auth login --api-key <key>` or set AUTOPOSTING_API_KEY.',\n )\n ;(err as NodeJS.ErrnoException & { exitCode?: number }).exitCode = 2\n throw err\n}\n","// ANSI color codes — no chalk dependency to keep bundle small\nconst RED = '\\x1b[31m'\nconst RESET = '\\x1b[0m'\n\nlet colorEnabled = true\n\nexport function disableColor(): void {\n colorEnabled = false\n}\n\nfunction red(text: string): string {\n if (!colorEnabled || !process.stdout.isTTY) return text\n return `${RED}${text}${RESET}`\n}\n\nexport type OutputMode = 'tty' | 'json' | 'quiet'\n\nexport interface OutputOptions {\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n color?: boolean\n}\n\nexport function detectOutputMode(options: OutputOptions): OutputMode {\n if (options.quiet) return 'quiet'\n if (options.json || !process.stdout.isTTY) return 'json'\n return 'tty'\n}\n\nexport function formatOutput(data: unknown, mode: OutputMode): string {\n if (mode === 'quiet') return ''\n if (mode === 'json') return JSON.stringify(data, null, 2)\n // tty: pretty-print objects or stringify primitives\n if (typeof data === 'string') return data\n return JSON.stringify(data, null, 2)\n}\n\nexport function formatTable(\n rows: Record<string, unknown>[],\n columns?: string[],\n): string {\n if (rows.length === 0) return ''\n\n const cols = columns ?? Object.keys(rows[0]!)\n const widths: number[] = cols.map((col) => col.length)\n\n // Compute max widths\n for (const row of rows) {\n for (let i = 0; i < cols.length; i++) {\n const val = String(row[cols[i]!] ?? '')\n if (val.length > widths[i]!) widths[i] = val.length\n }\n }\n\n const pad = (s: string, w: number) => s.padEnd(w, ' ')\n const separator = widths.map((w) => '-'.repeat(w)).join(' ')\n\n const header = cols.map((c, i) => pad(c.toUpperCase(), widths[i]!)).join(' ')\n const dataRows = rows.map((row) =>\n cols.map((c, i) => pad(String(row[c] ?? ''), widths[i]!)).join(' '),\n )\n\n return [header, separator, ...dataRows].join('\\n')\n}\n\nexport function formatError(error: Error | string, mode: OutputMode): string {\n const message = error instanceof Error ? error.message : error\n if (mode === 'tty') return red(`Error: ${message}`)\n // json and quiet both return JSON error — errors always show\n return JSON.stringify({ error: message }, null, 2)\n}\n","import type { OutputMode } from './formatter.js'\n\nexport interface Spinner {\n start(message: string): void\n stop(message?: string): void\n fail(message: string): void\n}\n\n// No-op spinner for JSON/quiet modes — no TTY output during machine-readable runs\nconst NO_OP_SPINNER: Spinner = {\n start: () => {},\n stop: () => {},\n fail: () => {},\n}\n\n// TTY spinner backed by ora (dynamic import for CJS compatibility)\nclass OraSpinner implements Spinner {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private instance: any = null\n\n start(message: string): void {\n import('ora').then(({ default: ora }) => {\n this.instance = ora(message).start()\n }).catch(() => {\n // ora unavailable — fall back to plain stdout\n process.stdout.write(`${message}\\n`)\n })\n }\n\n stop(message?: string): void {\n if (this.instance) {\n this.instance.succeed(message)\n this.instance = null\n } else if (message) {\n process.stdout.write(`${message}\\n`)\n }\n }\n\n fail(message: string): void {\n if (this.instance) {\n this.instance.fail(message)\n this.instance = null\n } else {\n process.stderr.write(`${message}\\n`)\n }\n }\n}\n\nexport function createSpinner(mode: OutputMode): Spinner {\n if (mode === 'tty') return new OraSpinner()\n return NO_OP_SPINNER\n}\n","import { type OutputMode, type OutputOptions, formatOutput, formatTable, formatError, detectOutputMode } from './formatter.js'\nimport { createSpinner, type Spinner } from './spinner.js'\n\nexport class Printer {\n constructor(private mode: OutputMode) {}\n\n log(data: unknown): void {\n const out = formatOutput(data, this.mode)\n if (out !== '') console.log(out)\n }\n\n table(rows: Record<string, unknown>[], columns?: string[]): void {\n if (this.mode === 'quiet') return\n if (this.mode === 'json') {\n console.log(formatOutput(rows, 'json'))\n return\n }\n const out = formatTable(rows, columns)\n if (out !== '') console.log(out)\n }\n\n error(err: Error | string): void {\n const out = formatError(err, this.mode)\n console.error(out)\n }\n\n spinner(message: string): Spinner {\n const s = createSpinner(this.mode)\n s.start(message)\n return s\n }\n}\n\nexport function createPrinter(options: OutputOptions): Printer {\n const mode = detectOutputMode(options)\n return new Printer(mode)\n}\n","export const EXIT_CODES = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n AUTH_ERROR: 2,\n SCOPE_ERROR: 3,\n NOT_FOUND: 4,\n RATE_LIMITED: 5,\n VALIDATION_ERROR: 6,\n NETWORK_ERROR: 7,\n} as const\n\nexport type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES]\n\n// Named sentinel classes used for instanceof checks against @autoposting.ai/sdk errors.\n// We match by constructor name so this works even if the SDK hasn't shipped error\n// classes yet (dynamic require would silently fail). When the SDK exports these\n// classes they will inherit from AutopostingError and carry the same names.\nfunction matchesClass(error: unknown, className: string): boolean {\n if (error == null || typeof error !== 'object') return false\n // Walk prototype chain checking constructor names\n let proto = Object.getPrototypeOf(error) as object | null\n while (proto !== null) {\n const ctor = (proto as { constructor?: { name?: string } }).constructor\n if (ctor?.name === className) return true\n proto = Object.getPrototypeOf(proto) as object | null\n }\n return false\n}\n\nexport function exitCodeFromError(error: unknown): ExitCode {\n if (matchesClass(error, 'AuthenticationError')) return EXIT_CODES.AUTH_ERROR\n if (matchesClass(error, 'ScopeError')) return EXIT_CODES.SCOPE_ERROR\n if (matchesClass(error, 'NotFoundError')) return EXIT_CODES.NOT_FOUND\n if (matchesClass(error, 'RateLimitError')) return EXIT_CODES.RATE_LIMITED\n if (matchesClass(error, 'ValidationError')) return EXIT_CODES.VALIDATION_ERROR\n if (matchesClass(error, 'NetworkError')) return EXIT_CODES.NETWORK_ERROR\n return EXIT_CODES.GENERAL_ERROR\n}\n","import { Command } from 'commander'\nimport { execSync } from 'node:child_process'\nimport {\n deleteAllProfiles,\n deleteProfile,\n getActiveProfile,\n readCredentials,\n saveProfile,\n setActiveProfile,\n} from '../auth/credential-store.js'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { requestDeviceCode, pollDeviceCode } from '../auth/device-code-client.js'\n\nconst DEFAULT_BASE_URL = 'https://app.autoposting.ai'\n\nfunction resolveBaseUrl(globals: { baseUrl?: string }): string {\n return globals.baseUrl ?? process.env.AUTOPOSTING_BASE_URL ?? DEFAULT_BASE_URL\n}\n\nfunction tryOpenUrl(url: string): void {\n try {\n // Attempt to open browser; ignore failures (CI, headless, etc.)\n const platform = process.platform\n if (platform === 'darwin') execSync(`open \"${url}\"`, { stdio: 'ignore' })\n else if (platform === 'win32') execSync(`start \"\" \"${url}\"`, { stdio: 'ignore' })\n else execSync(`xdg-open \"${url}\"`, { stdio: 'ignore' })\n } catch {\n // Non-fatal: user can open URL manually\n }\n}\n\nexport function createAuthCommand(): Command {\n const auth = new Command('auth').description('Manage authentication and profiles')\n\n // ap auth login [--api-key <key>] [--profile <name>] [--base-url <url>]\n // Note: --api-key is also a root-level global option on the program. Commander consumes\n // options left-to-right so the root picks it up first. We use optsWithGlobals() to\n // merge root + local options and read whichever level captured the flag.\n auth\n .command('login')\n .description('Log in via browser device code flow, or store an API key directly with --api-key')\n .option('--api-key <key>', 'API key to store directly (skips device code flow)')\n .option('--profile <name>', 'Profile name to save under', 'default')\n .option('--base-url <url>', 'API base URL (overrides AUTOPOSTING_BASE_URL)')\n .action(async (localOpts: { apiKey?: string; profile: string; baseUrl?: string }, cmd: Command) => {\n const opts = cmd.optsWithGlobals<{ apiKey?: string; profile: string; baseUrl?: string }>()\n\n // Fast path: --api-key provided, store directly\n if (opts.apiKey) {\n saveProfile(opts.profile, {\n apiKey: opts.apiKey,\n createdAt: new Date().toISOString(),\n })\n console.log(`Logged in. Profile \"${opts.profile}\" saved.`)\n return\n }\n\n // Device code flow\n const baseUrl = resolveBaseUrl(opts)\n\n let deviceCodeResp\n try {\n deviceCodeResp = await requestDeviceCode(baseUrl)\n } catch (err) {\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n\n const { deviceCode, userCode, verificationUri } = deviceCodeResp\n let pollInterval = deviceCodeResp.interval\n\n console.log(`\\nEnter code ${userCode} at ${verificationUri}\\n`)\n tryOpenUrl(verificationUri)\n\n // Spinner-style wait indicator using process.stdout so we can overwrite it\n const frames = ['|', '/', '-', '\\\\']\n let frameIdx = 0\n const spinnerInterval = setInterval(() => {\n process.stdout.write(`\\rWaiting for authorization... ${frames[frameIdx++ % frames.length]}`)\n }, 100)\n\n const clearSpinner = () => {\n clearInterval(spinnerInterval)\n process.stdout.write('\\r\\x1b[K') // clear spinner line\n }\n\n // Poll loop\n while (true) {\n await new Promise<void>((resolve) => setTimeout(resolve, pollInterval * 1000))\n\n let result\n try {\n result = await pollDeviceCode(baseUrl, deviceCode)\n } catch (err) {\n clearSpinner()\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n\n switch (result.status) {\n case 'complete': {\n clearSpinner()\n const token = result.sessionToken!\n saveProfile(opts.profile, {\n apiKey: token,\n createdAt: new Date().toISOString(),\n })\n console.log(`Logged in. Profile \"${opts.profile}\" saved.`)\n return\n }\n\n case 'expired_token':\n clearSpinner()\n console.error('Error: Authorization expired. Run `ap auth login` again.')\n process.exit(2)\n break\n\n case 'access_denied':\n clearSpinner()\n console.error('Error: Access denied.')\n process.exit(2)\n break\n\n case 'slow_down':\n // Double the interval as instructed by server\n pollInterval = result.interval ?? pollInterval * 2\n break\n\n case 'authorization_pending':\n default:\n // Continue polling\n break\n }\n }\n })\n\n // ap auth logout [--all]\n auth\n .command('logout')\n .description('Remove the active profile (or all profiles with --all)')\n .option('--all', 'Remove all stored profiles')\n .action((opts: { all?: boolean }) => {\n if (opts.all) {\n deleteAllProfiles()\n console.log('All profiles removed.')\n return\n }\n\n const creds = readCredentials()\n const active = creds?.activeProfile\n if (!active) {\n console.log('No active profile to log out from.')\n return\n }\n\n deleteProfile(active)\n console.log(`Profile \"${active}\" removed.`)\n })\n\n // ap auth switch <profile>\n auth\n .command('switch <profile>')\n .description('Switch the active profile')\n .action((profile: string) => {\n try {\n setActiveProfile(profile)\n console.log(`Switched to profile \"${profile}\".`)\n } catch (err) {\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n })\n\n // ap auth whoami\n auth\n .command('whoami')\n .description('Show current authentication method and identity')\n .action((_opts: Record<string, unknown>, cmd: Command) => {\n try {\n const globals = cmd.optsWithGlobals<{ apiKey?: string }>()\n const cred = resolveAuth({ apiKey: globals.apiKey })\n\n console.log(`Source: ${cred.source}`)\n if (cred.source === 'stored') {\n const creds = readCredentials()\n const profileName = creds?.activeProfile ?? 'unknown'\n const profile = creds?.profiles[profileName]\n console.log(`Profile: ${profileName}`)\n if (profile?.workspace) console.log(`Workspace: ${profile.workspace}`)\n if (profile?.email) console.log(`Email: ${profile.email}`)\n }\n // Never print the raw API key\n const masked = `${cred.apiKey.slice(0, 8)}${'*'.repeat(Math.max(0, cred.apiKey.length - 8))}`\n console.log(`API key: ${masked}`)\n } catch (err) {\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n })\n\n // ap auth status — alias for whoami\n auth\n .command('status')\n .description('Alias for whoami — show current authentication status')\n .action((_opts: Record<string, unknown>, cmd: Command) => {\n try {\n const globals = cmd.optsWithGlobals<{ apiKey?: string }>()\n const cred = resolveAuth({ apiKey: globals.apiKey })\n console.log(`Source: ${cred.source}`)\n if (cred.source === 'stored') {\n const creds = readCredentials()\n const profileName = creds?.activeProfile ?? 'unknown'\n console.log(`Profile: ${profileName}`)\n }\n const masked = `${cred.apiKey.slice(0, 8)}${'*'.repeat(Math.max(0, cred.apiKey.length - 8))}`\n console.log(`API key: ${masked}`)\n } catch (err) {\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n })\n\n return auth\n}\n","export interface DeviceCodeResponse {\n deviceCode: string\n userCode: string\n verificationUri: string\n expiresIn: number\n interval: number\n}\n\nexport interface PollResult {\n status: 'authorization_pending' | 'complete' | 'expired_token' | 'access_denied' | 'slow_down'\n sessionToken?: string\n orgId?: string\n interval?: number\n}\n\nexport async function requestDeviceCode(baseUrl: string): Promise<DeviceCodeResponse> {\n const res = await fetch(`${baseUrl}/auth/cli/device-code`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n })\n\n if (!res.ok) {\n const text = await res.text().catch(() => res.statusText)\n throw new Error(`Device code request failed (${res.status}): ${text}`)\n }\n\n const data = (await res.json()) as DeviceCodeResponse\n return data\n}\n\nexport async function pollDeviceCode(baseUrl: string, deviceCode: string): Promise<PollResult> {\n const url = `${baseUrl}/auth/cli/poll?device_code=${encodeURIComponent(deviceCode)}`\n const res = await fetch(url)\n\n if (!res.ok) {\n const text = await res.text().catch(() => res.statusText)\n throw new Error(`Poll request failed (${res.status}): ${text}`)\n }\n\n const data = (await res.json()) as PollResult\n return data\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createBillingCommand(): Command {\n const billing = new Command('billing').description('View billing information')\n\n // ap billing status\n billing\n .command('status')\n .description('Show current plan and subscription status')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching billing status…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const status = await client.billing.status()\n spinner.stop()\n printer.table(\n [\n {\n plan: status.plan,\n status: status.status,\n 'trial ends': status.trialEndsAt ?? '—',\n 'renewal date': status.renewalDate ?? '—',\n 'cancels at': status.cancelAt ?? '—',\n },\n ],\n ['plan', 'status', 'trial ends', 'renewal date', 'cancels at'],\n )\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap billing credits\n billing\n .command('credits')\n .description('Show credit balance and usage breakdown')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching credit balance…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const credits = await client.billing.credits()\n spinner.stop()\n printer.table(\n [\n {\n total: credits.total,\n used: credits.used,\n remaining: credits.remaining,\n },\n ],\n ['total', 'used', 'remaining'],\n )\n if (credits.breakdown && Object.keys(credits.breakdown).length > 0) {\n const breakdownRows = Object.entries(credits.breakdown).map(([key, val]) => ({\n category: key,\n credits: val,\n }))\n printer.table(breakdownRows, ['category', 'credits'])\n }\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return billing\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\nexport function createBrandsCommand(): Command {\n const brands = new Command('brands').description('Manage brands')\n\n // ap brands list\n brands\n .command('list')\n .description('List all brands')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching brands…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.brands.list()\n spinner.stop()\n const rows = list.map((b) => ({\n slug: b.slug,\n name: b.name,\n platforms: b.platforms\n .filter((p) => p.connected)\n .map((p) => p.platform)\n .join(', ') || '—',\n timezone: b.timezone,\n }))\n printer.table(rows, ['slug', 'name', 'platforms', 'timezone'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n // ap brands get <slug>\n brands\n .command('get <slug>')\n .description('Get a brand by slug')\n .action(async (slug: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching brand \"${slug}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const brand = await client.brands.retrieve(slug)\n spinner.stop()\n printer.log(brand)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n // ap brands create --name <name> [--timezone <tz>]\n brands\n .command('create')\n .description('Create a new brand')\n .requiredOption('--name <name>', 'Brand display name')\n .option('--timezone <tz>', 'IANA timezone (e.g. America/New_York)')\n .action(async (opts: { name: string; timezone?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating brand…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const brand = await client.brands.create({\n name: opts.name,\n ...(opts.timezone ? { timezone: opts.timezone } : {}),\n })\n spinner.stop()\n printer.log(brand)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n // ap brands update <slug> [--name <name>] [--timezone <tz>]\n brands\n .command('update <slug>')\n .description('Update a brand')\n .option('--name <name>', 'New display name')\n .option('--timezone <tz>', 'New IANA timezone')\n .action(async (slug: string, opts: { name?: string; timezone?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Updating brand \"${slug}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const brand = await client.brands.update(slug, {\n ...(opts.name ? { name: opts.name } : {}),\n ...(opts.timezone ? { timezone: opts.timezone } : {}),\n })\n spinner.stop()\n printer.log(brand)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n // ap brands delete <slug> [--force]\n brands\n .command('delete <slug>')\n .description('Delete a brand (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (slug: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a brand. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting brand \"${slug}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.brands.remove(slug)\n spinner.stop()\n printer.log(`Brand \"${slug}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n // ap brands auth-status <slug>\n brands\n .command('auth-status <slug>')\n .description('Show platform connection status for a brand')\n .action(async (slug: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching auth status for \"${slug}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const connections = await client.brands.authStatus(slug)\n spinner.stop()\n const rows = connections.map((c) => ({\n platform: c.platform,\n connected: c.connected ? 'yes' : 'no',\n username: c.username ?? '—',\n 'token status': c.tokenExpired === true ? 'expired' : c.connected ? 'ok' : '—',\n }))\n printer.table(rows, ['platform', 'connected', 'username', 'token status'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n return brands\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createCarouselsCommand(): Command {\n const carousels = new Command('carousels').description('Manage carousels')\n\n // ap carousels list\n carousels\n .command('list')\n .description('List all carousels')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching carousels…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.carousels.list()\n spinner.stop()\n const rows = list.map((c) => ({\n id: c.id,\n title: c.title ?? '—',\n slides: c.slides.length,\n status: c.status,\n createdAt: c.createdAt,\n }))\n printer.table(rows, ['id', 'title', 'slides', 'status', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap carousels get <id>\n carousels\n .command('get <id>')\n .description('Get a carousel by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching carousel \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const carousel = await client.carousels.retrieve(id)\n spinner.stop()\n printer.log(carousel)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap carousels create [--title <title>]\n carousels\n .command('create')\n .description('Create a new carousel')\n .option('--title <title>', 'Carousel title')\n .action(async (opts: { title?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating carousel…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const carousel = await client.carousels.create(\n opts.title ? { title: opts.title } : undefined,\n )\n spinner.stop()\n printer.log(carousel)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap carousels generate --topic <topic> [--brand <slug>] [--slides <n>]\n carousels\n .command('generate')\n .description('AI-generate a carousel from a topic')\n .requiredOption('--topic <topic>', 'Topic to generate slides for')\n .option('--brand <slug>', 'Brand slug for brand voice')\n .option('--slides <n>', 'Number of slides to generate')\n .action(async (opts: { topic: string; brand?: string; slides?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Generating carousel…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const carousel = await client.carousels.generate({\n topic: opts.topic,\n ...(opts.brand ? { brandSlug: opts.brand } : {}),\n ...(opts.slides ? { slideCount: parseInt(opts.slides, 10) } : {}),\n })\n spinner.stop()\n printer.log(carousel)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap carousels draft <id>\n carousels\n .command('draft <id>')\n .description('Convert a carousel to a post draft')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Converting carousel \"${id}\" to draft…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.carousels.draft(id)\n spinner.stop()\n printer.log(result)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap carousels delete <id> --force\n carousels\n .command('delete <id>')\n .description('Delete a carousel (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a carousel. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting carousel \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.carousels.remove(id)\n spinner.stop()\n printer.log(`Carousel \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return carousels\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createClipsCommand(): Command {\n const clips = new Command('clips').description('Manage video clips')\n\n // ap clips list\n clips\n .command('list')\n .description('List all clips')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching clips…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.clips.list()\n spinner.stop()\n const rows = list.map((c) => ({\n id: c.id,\n name: c.name,\n status: c.status,\n duration: c.duration !== undefined ? `${c.duration}s` : '—',\n }))\n printer.table(rows, ['id', 'name', 'status', 'duration'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap clips get <id>\n clips\n .command('get <id>')\n .description('Get a clip by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching clip \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const clip = await client.clips.retrieve(id)\n spinner.stop()\n printer.log(clip)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap clips upload <file> [--name <name>]\n clips\n .command('upload <file>')\n .description('Upload a video file as a clip')\n .option('--name <name>', 'Override the clip name (defaults to filename)')\n .action(async (file: string, opts: { name?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Uploading clip…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const clip = await client.clips.upload(file, {\n name: opts.name,\n onProgress: (pct) => {\n if (pct > 0 && pct < 100) spinner.stop()\n },\n })\n spinner.stop()\n printer.log(clip)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap clips import --url <url> [--name <name>]\n clips\n .command('import')\n .description('Import a clip from a URL')\n .requiredOption('--url <url>', 'URL of the video to import')\n .option('--name <name>', 'Name for the imported clip')\n .action(async (opts: { url: string; name?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Importing clip…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const clip = await client.clips.importUrl({\n url: opts.url,\n ...(opts.name ? { name: opts.name } : {}),\n })\n spinner.stop()\n printer.log(clip)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap clips render <id>\n clips\n .command('render <id>')\n .description('Trigger rendering for a clip')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Rendering clip \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const clip = await client.clips.render(id)\n spinner.stop()\n printer.log(clip)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap clips delete <id> --force\n clips\n .command('delete <id>')\n .description('Delete a clip (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a clip. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting clip \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.clips.remove(id)\n spinner.stop()\n printer.log(`Clip \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return clips\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport type { Platform } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction parsePlatforms(raw: string): Platform[] {\n return raw.split(',').map((p) => p.trim() as Platform)\n}\n\n/**\n * Resolves the process exit code for a caught error.\n * Honours the `exitCode` property set by `resolveAuth` (exit 2 for auth errors)\n * before falling back to the SDK error class mapping.\n */\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createPostsCommand(): Command {\n const posts = new Command('posts').description('Manage posts')\n\n // ap posts list [--brand <slug>] [--status <status>] [--limit <n>] [--page <n>]\n posts\n .command('list')\n .description('List posts')\n .option('--brand <slug>', 'Filter by brand slug')\n .option('--status <status>', 'Filter by status (draft|scheduled|published|failed)')\n .option('--limit <n>', 'Max results per page', '20')\n .option('--page <n>', 'Page number', '1')\n .action(async (opts: { brand?: string; status?: string; limit: string; page: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching posts…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.posts.list({\n brandSlug: opts.brand,\n status: opts.status as 'draft' | 'scheduled' | 'published' | 'failed' | undefined,\n limit: parseInt(opts.limit, 10),\n page: parseInt(opts.page, 10),\n })\n spinner.stop()\n const rows = result.data.map((p) => ({\n id: p.id,\n brand: p.brandSlug,\n status: p.status,\n platforms: p.platforms.join(', '),\n text: p.text.length > 60 ? `${p.text.slice(0, 57)}…` : p.text,\n scheduledAt: p.scheduledAt ?? '—',\n }))\n printer.table(rows, ['id', 'brand', 'status', 'platforms', 'text', 'scheduledAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts get <id>\n posts\n .command('get <id>')\n .description('Get a post by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.getById(id)\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts create --brand <slug> --text <text> --platforms <x,linkedin,...>\n posts\n .command('create')\n .description('Create a new post')\n .requiredOption('--brand <slug>', 'Brand slug')\n .requiredOption('--text <text>', 'Post text content')\n .requiredOption('--platforms <list>', 'Comma-separated platforms (e.g. x,linkedin)')\n .option('--at <iso>', 'Schedule date/time (ISO 8601)')\n .action(\n async (\n opts: { brand: string; text: string; platforms: string; at?: string },\n cmd: Command,\n ) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating post…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.create({\n brandSlug: opts.brand,\n text: opts.text,\n platforms: parsePlatforms(opts.platforms),\n ...(opts.at ? { scheduledAt: opts.at } : {}),\n })\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap posts update <id> [--text <text>] [--platforms <list>] [--at <iso>]\n posts\n .command('update <id>')\n .description('Update a post')\n .option('--text <text>', 'New post text')\n .option('--platforms <list>', 'New comma-separated platforms')\n .option('--at <iso>', 'New scheduled date/time (ISO 8601)')\n .action(\n async (\n id: string,\n opts: { text?: string; platforms?: string; at?: string },\n cmd: Command,\n ) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Updating post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.update(id, {\n ...(opts.text ? { text: opts.text } : {}),\n ...(opts.platforms ? { platforms: parsePlatforms(opts.platforms) } : {}),\n ...(opts.at ? { scheduledAt: opts.at } : {}),\n })\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap posts delete <id> [--force]\n posts\n .command('delete <id>')\n .description('Delete a post (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a post. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.posts.remove(id)\n spinner.stop()\n printer.log(`Post \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts publish <id>\n posts\n .command('publish <id>')\n .description('Publish a post immediately')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Publishing post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.publish(id)\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts schedule <id> --at <iso-datetime>\n posts\n .command('schedule <id>')\n .description('Schedule a post for a specific time')\n .requiredOption('--at <iso>', 'ISO 8601 datetime to schedule the post')\n .action(async (id: string, opts: { at: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Scheduling post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.schedule(id, opts.at)\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts retry <id>\n posts\n .command('retry <id>')\n .description('Retry a failed post')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Retrying post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.retry(id)\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts rewrite <id>\n posts\n .command('rewrite <id>')\n .description('AI-rewrite a post')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Rewriting post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.rewrite(id)\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts score <id>\n posts\n .command('score <id>')\n .description('Score a post with AI feedback')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Scoring post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.posts.score(id)\n spinner.stop()\n printer.log(result)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return posts\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createKbCommand(): Command {\n const kb = new Command('kb').description('Manage knowledge bases')\n\n // ap kb list\n kb\n .command('list')\n .description('List all knowledge bases')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching knowledge bases…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.kb.list()\n spinner.stop()\n const rows = list.map((k) => ({\n id: k.id,\n name: k.name,\n docs: k.docCount ?? 0,\n createdAt: k.createdAt,\n }))\n printer.table(rows, ['id', 'name', 'docs', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb get <id>\n kb\n .command('get <id>')\n .description('Get a knowledge base by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching knowledge base \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.kb.retrieve(id)\n spinner.stop()\n printer.log(result)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb create --name <name>\n kb\n .command('create')\n .description('Create a new knowledge base')\n .requiredOption('--name <name>', 'Knowledge base name')\n .action(async (opts: { name: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating knowledge base…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.kb.create({ name: opts.name })\n spinner.stop()\n printer.log(result)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb delete <id> [--force]\n kb\n .command('delete <id>')\n .description('Delete a knowledge base (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a knowledge base. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting knowledge base \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.kb.remove(id)\n spinner.stop()\n printer.log(`Knowledge base \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb search <id> --query <text>\n kb\n .command('search <id>')\n .description('Search a knowledge base')\n .requiredOption('--query <text>', 'Search query')\n .action(async (id: string, opts: { query: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Searching knowledge base \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const results = await client.kb.search(id, opts.query)\n spinner.stop()\n const rows = results.map((r) => ({\n docId: r.docId,\n score: r.score.toFixed(3),\n content: r.content.length > 80 ? `${r.content.slice(0, 77)}…` : r.content,\n }))\n printer.table(rows, ['docId', 'score', 'content'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb ingest <id> --url <url>\n kb\n .command('ingest <id>')\n .description('Ingest a URL into a knowledge base')\n .requiredOption('--url <url>', 'URL to ingest')\n .action(async (id: string, opts: { url: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Ingesting URL into knowledge base \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const doc = await client.kb.ingestUrl(id, opts.url)\n spinner.stop()\n printer.log(doc)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb docs <id>\n kb\n .command('docs <id>')\n .description('List documents in a knowledge base')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching documents for knowledge base \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const docs = await client.kb.docs(id)\n spinner.stop()\n const rows = docs.map((d) => ({\n id: d.id,\n name: d.name,\n type: d.type,\n status: d.status,\n createdAt: d.createdAt,\n }))\n printer.table(rows, ['id', 'name', 'type', 'status', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return kb\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createIdeasCommand(): Command {\n const ideas = new Command('ideas').description('Manage content ideas')\n\n // ap ideas generate [--kb <id>] [--topic <text>] [--count <n>]\n ideas\n .command('generate')\n .description('Generate content ideas')\n .option('--kb <id>', 'Knowledge base ID to draw context from')\n .option('--topic <text>', 'Topic or theme for ideas')\n .option('--count <n>', 'Number of ideas to generate', '5')\n .action(async (opts: { kb?: string; topic?: string; count: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Generating ideas…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.ideas.generate({\n ...(opts.kb ? { kbId: opts.kb } : {}),\n ...(opts.topic ? { topic: opts.topic } : {}),\n count: parseInt(opts.count, 10),\n })\n spinner.stop()\n const rows = result.map((i) => ({\n id: i.id,\n topic: i.topic ?? '—',\n enriched: i.enriched ? 'yes' : 'no',\n text: i.text.length > 80 ? `${i.text.slice(0, 77)}…` : i.text,\n }))\n printer.table(rows, ['id', 'topic', 'enriched', 'text'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap ideas list\n ideas\n .command('list')\n .description('List all ideas')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching ideas…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.ideas.list()\n spinner.stop()\n const rows = list.map((i) => ({\n id: i.id,\n topic: i.topic ?? '—',\n enriched: i.enriched ? 'yes' : 'no',\n text: i.text.length > 80 ? `${i.text.slice(0, 77)}…` : i.text,\n createdAt: i.createdAt,\n }))\n printer.table(rows, ['id', 'topic', 'enriched', 'text', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap ideas enrich <id>\n ideas\n .command('enrich <id>')\n .description('Enrich an idea with AI context')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Enriching idea \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const idea = await client.ideas.enrich(id)\n spinner.stop()\n printer.log(idea)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap ideas delete <id> [--force]\n ideas\n .command('delete <id>')\n .description('Delete an idea (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete an idea. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting idea \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.ideas.remove(id)\n spinner.stop()\n printer.log(`Idea \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return ideas\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createUsageCommand(): Command {\n const usage = new Command('usage').description('View usage statistics')\n\n // ap usage summary\n usage\n .command('summary')\n .description('Show usage summary for the current period')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching usage summary…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const summary = await client.usage.summary()\n spinner.stop()\n const rows = Object.entries(summary.platforms).map(([platform, stats]) => ({\n platform,\n posts: stats.posts,\n published: stats.published,\n failed: stats.failed,\n }))\n if (rows.length === 0) {\n printer.log(`No usage data for period: ${summary.period}`)\n } else {\n printer.log(`Period: ${summary.period}`)\n printer.table(rows, ['platform', 'posts', 'published', 'failed'])\n }\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return usage\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createWebhooksCommand(): Command {\n const webhooks = new Command('webhooks').description('Manage webhooks')\n\n // ap webhooks list\n webhooks\n .command('list')\n .description('List all webhooks')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching webhooks…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.webhooks.list()\n spinner.stop()\n const rows = list.map((w) => ({\n id: w.id,\n url: w.url,\n events: w.events.join(', '),\n active: w.active ? 'yes' : 'no',\n createdAt: w.createdAt,\n }))\n printer.table(rows, ['id', 'url', 'events', 'active', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap webhooks get <id>\n webhooks\n .command('get <id>')\n .description('Get a webhook by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching webhook \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const webhook = await client.webhooks.retrieve(id)\n spinner.stop()\n printer.log(webhook)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap webhooks create --url <url> --events <post.published,post.failed,...>\n webhooks\n .command('create')\n .description('Create a new webhook')\n .requiredOption('--url <url>', 'Endpoint URL to receive events')\n .requiredOption('--events <list>', 'Comma-separated event types (e.g. post.published,post.failed)')\n .option('--secret <secret>', 'Signing secret for HMAC verification')\n .action(\n async (opts: { url: string; events: string; secret?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating webhook…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const webhook = await client.webhooks.create({\n url: opts.url,\n events: opts.events.split(',').map((e) => e.trim()),\n ...(opts.secret ? { secret: opts.secret } : {}),\n })\n spinner.stop()\n printer.log(webhook)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap webhooks update <id> [--url <url>] [--events <events>] [--active]\n webhooks\n .command('update <id>')\n .description('Update a webhook')\n .option('--url <url>', 'New endpoint URL')\n .option('--events <list>', 'New comma-separated event types')\n .option('--active', 'Set webhook as active')\n .option('--no-active', 'Set webhook as inactive')\n .action(\n async (\n id: string,\n opts: { url?: string; events?: string; active?: boolean },\n cmd: Command,\n ) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Updating webhook \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const webhook = await client.webhooks.update(id, {\n ...(opts.url ? { url: opts.url } : {}),\n ...(opts.events ? { events: opts.events.split(',').map((e) => e.trim()) } : {}),\n ...(opts.active !== undefined ? { active: opts.active } : {}),\n })\n spinner.stop()\n printer.log(webhook)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap webhooks delete <id> --force\n webhooks\n .command('delete <id>')\n .description('Delete a webhook (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a webhook. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting webhook \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.webhooks.remove(id)\n spinner.stop()\n printer.log(`Webhook \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap webhooks test <id>\n webhooks\n .command('test <id>')\n .description('Send a test event to a webhook')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Sending test event to webhook \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.webhooks.test(id)\n spinner.stop()\n printer.log(`Test event sent to webhook \"${id}\".`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return webhooks\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createWorkspacesCommand(): Command {\n const workspaces = new Command('workspaces').description('Manage workspaces')\n\n // ap workspaces list\n workspaces\n .command('list')\n .description('List all workspaces')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching workspaces…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.workspaces.list()\n spinner.stop()\n const rows = list.map((w) => ({\n id: w.id,\n name: w.name,\n slug: w.slug,\n active: w.isActive ? 'yes' : 'no',\n createdAt: w.createdAt,\n }))\n printer.table(rows, ['id', 'name', 'slug', 'active', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap workspaces switch <id>\n workspaces\n .command('switch <id>')\n .description('Switch the active workspace (session auth only)')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Switching to workspace \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n // Pass the auth source so the SDK can enforce the API key restriction.\n const authSource = cred.source === 'flag' || cred.source === 'env' || cred.source === 'stored'\n ? 'api-key'\n : 'session'\n const client = new Autoposting({ apiKey: cred.apiKey, authSource })\n await client.workspaces.switchWorkspace(id)\n spinner.stop()\n printer.log(`Switched to workspace \"${id}\".`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return workspaces\n}\n","import { Command } from 'commander'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { getCredentialsPath } from '../auth/credential-store.js'\nimport fs from 'node:fs'\n\nconst VERSION = '0.1.0'\nconst API_HEALTH_URL = 'https://app.autoposting.ai/api/health'\n\ntype CheckResult = {\n name: string\n status: 'pass' | 'fail' | 'warn'\n value: string\n}\n\nasync function runChecks(): Promise<CheckResult[]> {\n const results: CheckResult[] = []\n\n // CLI Version\n results.push({ name: 'CLI Version', status: 'pass', value: VERSION })\n\n // Node.js\n const nodeVersion = process.version\n const nodeMajor = parseInt(nodeVersion.slice(1), 10)\n results.push({\n name: 'Node.js',\n status: nodeMajor >= 20 ? 'pass' : 'fail',\n value: nodeVersion,\n })\n\n // Auth\n try {\n resolveAuth()\n results.push({ name: 'Auth', status: 'pass', value: 'authenticated' })\n } catch {\n results.push({ name: 'Auth', status: 'fail', value: 'not configured' })\n }\n\n // Credentials file permissions\n const credPath = getCredentialsPath()\n try {\n const stat = fs.statSync(credPath)\n const mode = stat.mode & 0o777\n const isSecure = mode === 0o600\n results.push({\n name: 'Credentials',\n status: isSecure ? 'pass' : 'warn',\n value: isSecure ? `${credPath} (0600)` : `${credPath} (mode ${mode.toString(8)} — expected 0600)`,\n })\n } catch {\n results.push({ name: 'Credentials', status: 'warn', value: 'no credentials file found' })\n }\n\n // API health\n try {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort(), 5000)\n const res = await fetch(API_HEALTH_URL, { signal: controller.signal })\n clearTimeout(timeout)\n results.push({\n name: 'API',\n status: res.ok ? 'pass' : 'fail',\n value: `HTTP ${res.status}`,\n })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n results.push({ name: 'API', status: 'fail', value: `unreachable: ${msg}` })\n }\n\n return results\n}\n\nexport function createDoctorCommand(): Command {\n const cmd = new Command('doctor')\n .description('Run diagnostic checks on your CLI setup')\n .option('--json', 'Output results as JSON')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{ json?: boolean }>()\n const results = await runChecks()\n\n if (globals.json) {\n console.log(JSON.stringify(results, null, 2))\n } else {\n for (const r of results) {\n const icon = r.status === 'pass' ? '✓' : r.status === 'warn' ? '!' : '✗'\n const label = r.status === 'pass' ? 'pass' : r.status === 'warn' ? 'warn' : 'FAIL'\n console.log(` ${icon} ${r.name.padEnd(16)} [${label}] ${r.value}`)\n }\n }\n\n const anyFail = results.some((r) => r.status === 'fail')\n if (anyFail) process.exit(1)\n })\n\n return cmd\n}\n","import { Command } from 'commander'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { readCredentials } from '../auth/credential-store.js'\n\nexport function createWhoamiCommand(): Command {\n return new Command('whoami')\n .description('Show current authentication identity (alias for `auth whoami`)')\n .action((_opts: Record<string, unknown>, cmd: Command) => {\n try {\n const globals = cmd.optsWithGlobals<{ apiKey?: string; json?: boolean }>()\n const cred = resolveAuth({ apiKey: globals.apiKey })\n\n const masked = `${cred.apiKey.slice(0, 8)}${'*'.repeat(Math.max(0, cred.apiKey.length - 8))}`\n\n if (globals.json) {\n const out: Record<string, string> = { source: cred.source, apiKey: masked }\n if (cred.source === 'stored') {\n const creds = readCredentials()\n const profileName = creds?.activeProfile ?? 'unknown'\n const profile = creds?.profiles[profileName]\n out.profile = profileName\n if (profile?.workspace) out.workspace = profile.workspace\n if (profile?.email) out.email = profile.email\n }\n console.log(JSON.stringify(out, null, 2))\n return\n }\n\n console.log(`Source: ${cred.source}`)\n if (cred.source === 'stored') {\n const creds = readCredentials()\n const profileName = creds?.activeProfile ?? 'unknown'\n const profile = creds?.profiles[profileName]\n console.log(`Profile: ${profileName}`)\n if (profile?.workspace) console.log(`Workspace: ${profile.workspace}`)\n if (profile?.email) console.log(`Email: ${profile.email}`)\n }\n console.log(`API key: ${masked}`)\n } catch (err) {\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n })\n}\n","import { Command } from 'commander'\nimport open from 'open'\n\nconst URLS: Record<string, string> = {\n '': 'https://app.autoposting.ai',\n posts: 'https://app.autoposting.ai/posts',\n brands: 'https://app.autoposting.ai/brands',\n agents: 'https://app.autoposting.ai/agents',\n settings: 'https://app.autoposting.ai/settings',\n billing: 'https://app.autoposting.ai/settings/billing',\n}\n\nconst VALID_SECTIONS = Object.keys(URLS).filter((k) => k !== '')\n\nexport function createOpenCommand(): Command {\n return new Command('open')\n .description(`Open the Autoposting dashboard in your browser. Sections: ${VALID_SECTIONS.join(', ')}`)\n .argument('[section]', `Dashboard section to open (${VALID_SECTIONS.join('|')})`, '')\n .option('--no-browser', 'Print URL only, do not open browser')\n .action(async (section: string, opts: { browser: boolean }) => {\n const key = section ?? ''\n if (!(key in URLS)) {\n console.error(`Error: unknown section \"${key}\". Valid sections: ${VALID_SECTIONS.join(', ')}`)\n process.exit(1)\n }\n\n const url = URLS[key]\n\n if (!opts.browser) {\n console.log(url)\n return\n }\n\n console.log(`Opening ${url}`)\n try {\n await open(url)\n } catch (err) {\n console.error(`Error: failed to open browser — ${(err as Error).message}`)\n console.log(`Visit manually: ${url}`)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport { execSync } from 'node:child_process'\n\nconst VERSION = '0.1.0'\nconst REGISTRY_URL = 'https://registry.npmjs.org/autoposting-cli/latest'\n\nexport function createUpdateCommand(): Command {\n return new Command('update')\n .description('Check for a newer version of the CLI and optionally install it')\n .option('--yes', 'Install the latest version without prompting')\n .action(async (opts: { yes?: boolean }) => {\n let latest: string\n try {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort(), 8000)\n const res = await fetch(REGISTRY_URL, { signal: controller.signal })\n clearTimeout(timeout)\n if (!res.ok) {\n console.error(`Error: registry returned HTTP ${res.status}`)\n process.exit(1)\n }\n const data = (await res.json()) as { version: string }\n latest = data.version\n } catch (err) {\n console.error(`Error: could not reach npm registry — ${(err as Error).message}`)\n process.exit(1)\n }\n\n if (latest === VERSION) {\n console.log(`You are already on the latest version (${VERSION}).`)\n return\n }\n\n console.log(`Current version: ${VERSION}`)\n console.log(`Latest version: ${latest}`)\n\n if (!opts.yes) {\n console.log(`Run \\`ap update --yes\\` to install v${latest}.`)\n return\n }\n\n console.log(`Installing autoposting-cli@${latest}…`)\n try {\n execSync(`npm install -g autoposting-cli@${latest}`, { stdio: 'inherit' })\n console.log(`Updated to v${latest}.`)\n } catch (err) {\n console.error(`Error: install failed — ${(err as Error).message}`)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\n\nconst ALL_COMMANDS = [\n 'posts',\n 'brands',\n 'agents',\n 'kb',\n 'ideas',\n 'clips',\n 'carousels',\n 'webhooks',\n 'billing',\n 'usage',\n 'workspaces',\n 'auth',\n 'doctor',\n 'whoami',\n 'open',\n 'update',\n 'completion',\n]\n\nconst SHELLS = ['bash', 'zsh', 'fish', 'pwsh'] as const\ntype Shell = (typeof SHELLS)[number]\n\nconst TEMPLATES: Record<Shell, (cmds: string[]) => string> = {\n bash: (cmds) => `# bash completion for ap / autoposting\n# Add to ~/.bashrc or ~/.bash_profile:\n# source <(ap completion bash)\n_ap_completions() {\n local cur=\"\\${COMP_WORDS[COMP_CWORD]}\"\n local commands=\"${cmds.join(' ')}\"\n COMPREPLY=( $(compgen -W \"$commands\" -- \"$cur\") )\n}\ncomplete -F _ap_completions ap\ncomplete -F _ap_completions autoposting\n`,\n\n zsh: (cmds) => `# zsh completion for ap / autoposting\n# Add to ~/.zshrc:\n# source <(ap completion zsh)\n# Or append directly:\n# ap completion zsh >> ~/.zshrc\n_ap() {\n compadd ${cmds.join(' ')}\n}\ncompdef _ap ap autoposting\n`,\n\n fish: (cmds) => `# fish completion for ap / autoposting\n# Save to ~/.config/fish/completions/ap.fish or run:\n# ap completion fish | source\n${cmds.map((c) => `complete -c ap -f -a '${c}'`).join('\\n')}\n${cmds.map((c) => `complete -c autoposting -f -a '${c}'`).join('\\n')}\n`,\n\n pwsh: (cmds) => `# PowerShell completion for ap / autoposting\n# Add to your $PROFILE:\n# ap completion pwsh | Invoke-Expression\nRegister-ArgumentCompleter -Native -CommandName @('ap', 'autoposting') -ScriptBlock {\n param($wordToComplete, $commandAst, $cursorPosition)\n $commands = @(${cmds.map((c) => `'${c}'`).join(', ')})\n $commands | Where-Object { $_ -like \"$wordToComplete*\" } | ForEach-Object {\n [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n }\n}\n`,\n}\n\nexport function createCompletionCommand(): Command {\n return new Command('completion')\n .description(`Generate shell completion script. Shells: ${SHELLS.join(', ')}`)\n .argument('<shell>', `Shell type (${SHELLS.join('|')})`)\n .action((shell: string) => {\n if (!SHELLS.includes(shell as Shell)) {\n console.error(`Error: unsupported shell \"${shell}\". Supported: ${SHELLS.join(', ')}`)\n process.exit(1)\n }\n process.stdout.write(TEMPLATES[shell as Shell](ALL_COMMANDS))\n })\n}\n","import { Command } from 'commander'\n\nexport function createMcpCommand(): Command {\n return new Command('mcp')\n .description('Start MCP stdio server for AI agent integration')\n .action(async () => {\n const { startMcpServer } = await import('../mcp/server.js')\n await startMcpServer()\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,QAAA,gBAAA,CAAA;AAAA,IAAAA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,MAAO,cAAa;AAChC,CAAC;AAEH,QAAQ,WAAW,kBAAkB,CAAC;AACtC,QAAQ,WAAW,qBAAqB,CAAC;AACzC,QAAQ,WAAW,oBAAoB,CAAC;AACxC,QAAQ,WAAW,uBAAuB,CAAC;AAC3C,QAAQ,WAAW,mBAAmB,CAAC;AACvC,QAAQ,WAAW,mBAAmB,CAAC;AACvC,QAAQ,WAAW,oBAAoB,CAAC;AACxC,QAAQ,WAAW,gBAAgB,CAAC;AACpC,QAAQ,WAAW,mBAAmB,CAAC;AACvC,QAAQ,WAAW,mBAAmB,CAAC;AACvC,QAAQ,WAAW,sBAAsB,CAAC;AAC1C,QAAQ,WAAW,wBAAwB,CAAC;AAC5C,QAAQ,WAAW,oBAAoB,CAAC;AACxC,QAAQ,WAAW,oBAAoB,CAAC;AACxC,QAAQ,WAAW,kBAAkB,CAAC;AACtC,QAAQ,WAAW,oBAAoB,CAAC;AACxC,QAAQ,WAAW,wBAAwB,CAAC;AAC5C,QAAQ,WAAW,iBAAiB,CAAC;AAErC,QAAQ,MAAM;","names":["__export","Autoposting","VERSION","module","path","fs","parsePlatforms","import_sdk","import_commander","path","os","fs","import_commander","import_commander","import_sdk","resolveExitCode","import_commander","import_sdk","import_commander","import_sdk","resolveExitCode","import_commander","import_sdk","resolveExitCode","import_commander","import_sdk","resolveExitCode","import_commander","import_sdk","resolveExitCode","import_commander","import_sdk","resolveExitCode","import_commander","import_sdk","resolveExitCode","import_commander","import_sdk","resolveExitCode","import_commander","import_sdk","resolveExitCode","import_commander","import_node_fs","fs","cmd","import_commander","import_commander","open","import_commander","import_node_child_process","VERSION","import_commander","import_commander","startMcpServer"]}
1
+ {"version":3,"sources":["../../sdk/src/version.ts","../../sdk/src/errors.ts","../../sdk/src/resource.ts","../../sdk/src/resources/agents.ts","../../sdk/src/resources/billing.ts","../../sdk/src/resources/brands.ts","../../sdk/src/resources/carousels.ts","../../sdk/src/resources/clips.ts","../../sdk/src/resources/posts.ts","../../sdk/src/resources/kb.ts","../../sdk/src/resources/ideas.ts","../../sdk/src/resources/usage.ts","../../sdk/src/resources/webhooks.ts","../../sdk/src/resources/workspaces.ts","../../sdk/src/client.ts","../src/mcp/tools.ts","../src/mcp/handler.ts","../src/mcp/server.ts","../src/cli.ts","../src/commands/agents.ts","../src/auth/credential-store.ts","../src/auth/auth-manager.ts","../src/output/formatter.ts","../src/output/spinner.ts","../src/output/printer.ts","../src/output/exit-codes.ts","../src/commands/auth.ts","../src/auth/device-code-client.ts","../src/commands/billing.ts","../src/commands/brands.ts","../src/commands/carousels.ts","../src/commands/clips.ts","../src/commands/posts.ts","../src/commands/kb.ts","../src/commands/ideas.ts","../src/commands/usage.ts","../src/commands/webhooks.ts","../src/commands/workspaces.ts","../src/commands/doctor.ts","../src/commands/whoami.ts","../src/commands/open.ts","../src/commands/update.ts","../src/commands/completion.ts","../src/commands/mcp.ts"],"sourcesContent":["export const VERSION = '0.3.0'\n","export class AutopostingError extends Error {\n status: number\n code: string\n\n constructor(message: string, status: number, code: string) {\n super(message)\n this.name = this.constructor.name\n this.status = status\n this.code = code\n // Restore prototype chain (required for custom Error subclasses in TS)\n Object.setPrototypeOf(this, new.target.prototype)\n }\n}\n\nexport class AuthenticationError extends AutopostingError {}\nexport class ScopeError extends AutopostingError {}\nexport class NotFoundError extends AutopostingError {}\nexport class ValidationError extends AutopostingError {}\n\nexport class RateLimitError extends AutopostingError {\n retryAfter?: number\n}\n\nexport class ServerError extends AutopostingError {}\n\nexport function createError(\n status: number,\n body: { error?: string; code?: string },\n): AutopostingError {\n const message = body.error ?? 'An error occurred'\n const code = body.code ?? 'UNKNOWN'\n\n if (status === 401) return new AuthenticationError(message, status, code)\n if (status === 403) return new ScopeError(message, status, code)\n if (status === 404) return new NotFoundError(message, status, code)\n if (status === 400 || status === 422) return new ValidationError(message, status, code)\n if (status === 429) return new RateLimitError(message, status, code)\n if (status >= 500) return new ServerError(message, status, code)\n\n return new AutopostingError(message, status, code)\n}\n","import type { Autoposting } from './client'\n\nexport abstract class Resource {\n constructor(protected client: Autoposting) {}\n\n protected get<T>(path: string, query?: Record<string, unknown>): Promise<T> {\n return this.client.request<T>('GET', path, undefined, query)\n }\n\n protected post<T>(path: string, body?: unknown): Promise<T> {\n return this.client.request<T>('POST', path, body)\n }\n\n protected put<T>(path: string, body?: unknown): Promise<T> {\n return this.client.request<T>('PUT', path, body)\n }\n\n protected patch<T>(path: string, body?: unknown): Promise<T> {\n return this.client.request<T>('PATCH', path, body)\n }\n\n protected delete<T>(path: string): Promise<T> {\n return this.client.request<T>('DELETE', path)\n }\n}\n","import { Resource } from '../resource'\nimport type { Agent, AgentRun, CreateAgentParams, UpdateAgentParams } from '../types/agents'\n\nexport class AgentsResource extends Resource {\n list(): Promise<Agent[]> {\n return this.get<Agent[]>('/agents')\n }\n\n retrieve(id: string): Promise<Agent> {\n return this.get<Agent>(`/agents/${id}`)\n }\n\n create(params: CreateAgentParams): Promise<Agent> {\n return this.post<Agent>('/agents', params)\n }\n\n update(id: string, params: UpdateAgentParams): Promise<Agent> {\n return this.patch<Agent>(`/agents/${id}`, params)\n }\n\n remove(id: string): Promise<void> {\n return this.delete<void>(`/agents/${id}`)\n }\n\n run(id: string): Promise<AgentRun> {\n return this.post<AgentRun>(`/agents/${id}/run`)\n }\n\n toggle(id: string): Promise<Agent> {\n return this.post<Agent>(`/agents/${id}/toggle`)\n }\n\n runs(id: string): Promise<AgentRun[]> {\n return this.get<AgentRun[]>(`/agents/${id}/runs`)\n }\n}\n","import { Resource } from '../resource'\nimport type { BillingStatus, CreditBalance } from '../types/billing'\n\nexport class BillingResource extends Resource {\n status(): Promise<BillingStatus> {\n return this.get<BillingStatus>('/billing/status')\n }\n\n credits(): Promise<CreditBalance> {\n return this.get<CreditBalance>('/billing/credits')\n }\n}\n","import { Resource } from '../resource'\nimport type { Brand, CreateBrandParams, PlatformConnection, UpdateBrandParams } from '../types/brands'\n\nexport class BrandsResource extends Resource {\n list(): Promise<Brand[]> {\n return this.get<Brand[]>('/brands')\n }\n\n retrieve(slug: string): Promise<Brand> {\n return this.get<Brand>(`/brands/${slug}`)\n }\n\n create(params: CreateBrandParams): Promise<Brand> {\n return this.post<Brand>('/brands', params)\n }\n\n update(slug: string, params: UpdateBrandParams): Promise<Brand> {\n return this.patch<Brand>(`/brands/${slug}`, params)\n }\n\n remove(slug: string): Promise<void> {\n return this.delete<void>(`/brands/${slug}`)\n }\n\n authStatus(slug: string): Promise<PlatformConnection[]> {\n return this.get<PlatformConnection[]>(`/brands/${slug}/auth/status`)\n }\n}\n","import { Resource } from '../resource'\nimport type { Carousel, CreateCarouselParams, GenerateCarouselParams } from '../types/carousels'\n\nexport class CarouselsResource extends Resource {\n list(): Promise<Carousel[]> {\n return this.get<Carousel[]>('/carousels')\n }\n\n retrieve(id: string): Promise<Carousel> {\n return this.get<Carousel>(`/carousels/${id}`)\n }\n\n create(params?: CreateCarouselParams): Promise<Carousel> {\n return this.post<Carousel>('/carousels', params)\n }\n\n generate(params: GenerateCarouselParams): Promise<Carousel> {\n return this.post<Carousel>('/carousels/generate', params)\n }\n\n /** POST /carousels/:id/draft — converts carousel to a post draft */\n draft(id: string): Promise<Carousel> {\n return this.post<Carousel>(`/carousels/${id}/draft`)\n }\n\n remove(id: string): Promise<void> {\n return this.client.request<void>('DELETE', `/carousels/${id}`)\n }\n}\n","import { Resource } from '../resource'\nimport type { Clip, ImportClipParams } from '../types/clips'\n\nexport class ClipsResource extends Resource {\n list(): Promise<Clip[]> {\n return this.client.request<Clip[]>('GET', '/clips')\n }\n\n retrieve(id: string): Promise<Clip> {\n return this.client.request<Clip>('GET', `/clips/${id}`)\n }\n\n async upload(\n filePath: string,\n options?: { name?: string; onProgress?: (pct: number) => void },\n ): Promise<Clip> {\n const fs = await import('node:fs')\n const path = await import('node:path')\n const data = fs.readFileSync(filePath)\n const name = options?.name ?? path.basename(filePath)\n\n const formData = new FormData()\n formData.append('file', new Blob([data]), name)\n formData.append('name', name)\n\n // onProgress not supported in single-request upload — signal start/end only\n options?.onProgress?.(0)\n const clip = await this.client.request<Clip>('POST', '/clips/upload', formData)\n options?.onProgress?.(100)\n return clip\n }\n\n importUrl(params: ImportClipParams): Promise<Clip> {\n return this.client.request<Clip>('POST', '/clips/import', params)\n }\n\n render(id: string): Promise<Clip> {\n return this.client.request<Clip>('POST', `/clips/${id}/render`)\n }\n\n remove(id: string): Promise<void> {\n return this.client.request<void>('DELETE', `/clips/${id}`)\n }\n}\n","import { Resource } from '../resource'\nimport type { Post, CreatePostParams, UpdatePostParams, ListPostsParams } from '../types/posts'\nimport type { PaginatedResponse } from '../types'\n\n// PostsResource methods `get` and `delete` cannot directly override the base class\n// protected generics (`get<T>`, `delete<T>`) due to TypeScript generic covariance rules.\n// We call `this.client.request` directly and expose public methods with unambiguous names.\n// The public API surface is: list, get, create, update, delete, publish, schedule, retry, rewrite, score.\nexport class PostsResource extends Resource {\n list(params?: ListPostsParams): Promise<PaginatedResponse<Post>> {\n return this.client.request<PaginatedResponse<Post>>(\n 'GET',\n '/v1/posts',\n undefined,\n params as Record<string, unknown>,\n )\n }\n\n /** GET /v1/posts/:id */\n getById(id: string): Promise<Post> {\n return this.client.request<Post>('GET', `/v1/posts/${id}`)\n }\n\n create(params: CreatePostParams): Promise<Post> {\n return this.client.request<Post>('POST', '/v1/posts', params)\n }\n\n update(id: string, params: UpdatePostParams): Promise<Post> {\n return this.client.request<Post>('PUT', `/v1/posts/${id}`, params)\n }\n\n /** DELETE /v1/posts/:id */\n remove(id: string): Promise<void> {\n return this.client.request<void>('DELETE', `/v1/posts/${id}`)\n }\n\n publish(id: string): Promise<Post> {\n return this.client.request<Post>('POST', `/v1/posts/${id}/publish`)\n }\n\n schedule(id: string, scheduledAt: string): Promise<Post> {\n return this.client.request<Post>('PUT', `/v1/posts/${id}/schedule`, { scheduledAt })\n }\n\n retry(id: string): Promise<Post> {\n return this.client.request<Post>('POST', `/v1/posts/${id}/retry`)\n }\n\n rewrite(id: string): Promise<Post> {\n return this.client.request<Post>('POST', `/v1/posts/${id}/rewrite`)\n }\n\n score(id: string): Promise<{ score: number; feedback: string }> {\n return this.client.request<{ score: number; feedback: string }>(\n 'POST',\n `/v1/posts/${id}/score`,\n )\n }\n}\n","import { Resource } from '../resource'\nimport type { KnowledgeBase, KbDocument, CreateKbParams, SearchResult } from '../types/kb'\n\nexport class KbResource extends Resource {\n list(): Promise<KnowledgeBase[]> {\n return this.get<KnowledgeBase[]>('/kbs')\n }\n\n retrieve(id: string): Promise<KnowledgeBase> {\n return this.get<KnowledgeBase>(`/kbs/${id}`)\n }\n\n create(params: CreateKbParams): Promise<KnowledgeBase> {\n return this.post<KnowledgeBase>('/kbs', params)\n }\n\n remove(id: string): Promise<void> {\n return this.delete<void>(`/kbs/${id}`)\n }\n\n search(id: string, query: string): Promise<SearchResult[]> {\n return this.post<SearchResult[]>(`/kbs/${id}/search`, { query })\n }\n\n ingestUrl(id: string, url: string): Promise<KbDocument> {\n return this.post<KbDocument>(`/kbs/${id}/docs/ingest-url`, { url })\n }\n\n docs(id: string): Promise<KbDocument[]> {\n return this.get<KbDocument[]>(`/kbs/${id}/docs`)\n }\n}\n","import { Resource } from '../resource'\nimport type { Idea, GenerateIdeasParams } from '../types/kb'\n\nexport class IdeasResource extends Resource {\n generate(params: GenerateIdeasParams = {}): Promise<Idea[]> {\n return this.post<Idea[]>('/ideas/generate', params)\n }\n\n list(): Promise<Idea[]> {\n return this.get<Idea[]>('/ideas')\n }\n\n enrich(id: string): Promise<Idea> {\n return this.post<Idea>(`/ideas/${id}/enrich`)\n }\n\n remove(id: string): Promise<void> {\n return this.delete<void>(`/ideas/${id}`)\n }\n}\n","import { Resource } from '../resource'\nimport type { UsageSummary } from '../types/usage'\n\nexport class UsageResource extends Resource {\n summary(): Promise<UsageSummary> {\n return this.get<UsageSummary>('/usage/summary')\n }\n}\n","import { Resource } from '../resource'\nimport type { Webhook, CreateWebhookParams, UpdateWebhookParams } from '../types/webhooks'\n\nexport class WebhooksResource extends Resource {\n list(): Promise<Webhook[]> {\n return this.get<Webhook[]>('/webhooks')\n }\n\n retrieve(id: string): Promise<Webhook> {\n return this.get<Webhook>(`/webhooks/${id}`)\n }\n\n create(params: CreateWebhookParams): Promise<Webhook> {\n return this.post<Webhook>('/webhooks', params)\n }\n\n update(id: string, params: UpdateWebhookParams): Promise<Webhook> {\n return this.patch<Webhook>(`/webhooks/${id}`, params)\n }\n\n remove(id: string): Promise<void> {\n return this.client.request<void>('DELETE', `/webhooks/${id}`)\n }\n\n test(id: string): Promise<void> {\n return this.post<void>(`/webhooks/${id}/test`)\n }\n}\n","import { Resource } from '../resource'\nimport type { Workspace } from '../types/workspaces'\nimport type { Autoposting } from '../client'\n\nexport class WorkspacesResource extends Resource {\n constructor(client: Autoposting) {\n super(client)\n }\n\n list(): Promise<Workspace[]> {\n return this.get<Workspace[]>('/orgs')\n }\n\n switchWorkspace(id: string): Promise<void> {\n // API keys are scoped to a single workspace at creation time.\n // Switching requires a session token that can act across orgs.\n if (this.client.authSource === 'api-key') {\n return Promise.reject(\n new Error(\n 'API keys are bound to a single workspace. Use session auth to switch.',\n ),\n )\n }\n return this.post<void>('/orgs/set-active', { organizationId: id })\n }\n}\n","import { VERSION } from './version'\nimport { createError, RateLimitError } from './errors'\nimport { AgentsResource } from './resources/agents'\nimport { BillingResource } from './resources/billing'\nimport { BrandsResource } from './resources/brands'\nimport { CarouselsResource } from './resources/carousels'\nimport { ClipsResource } from './resources/clips'\nimport { PostsResource } from './resources/posts'\nimport { KbResource } from './resources/kb'\nimport { IdeasResource } from './resources/ideas'\nimport { UsageResource } from './resources/usage'\nimport { WebhooksResource } from './resources/webhooks'\nimport { WorkspacesResource } from './resources/workspaces'\n\nexport interface AutopostingConfig {\n apiKey?: string\n baseUrl?: string\n timeout?: number\n headers?: Record<string, string>\n /** Mark the auth source so workspace-switching can enforce API key restrictions. */\n authSource?: 'api-key' | 'session'\n}\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n\nexport class Autoposting {\n /** @internal Not part of the public API — use SDK methods to make requests. */\n private readonly _apiKey: string\n readonly baseUrl: string\n readonly timeout: number\n private readonly extraHeaders: Record<string, string>\n /** Indicates how the client was authenticated; used by WorkspacesResource. */\n readonly authSource: 'api-key' | 'session'\n readonly agents: AgentsResource\n readonly billing: BillingResource\n readonly brands: BrandsResource\n readonly carousels: CarouselsResource\n readonly clips: ClipsResource\n readonly posts: PostsResource\n readonly kb: KbResource\n readonly ideas: IdeasResource\n readonly usage: UsageResource\n readonly webhooks: WebhooksResource\n readonly workspaces: WorkspacesResource\n\n constructor(config: AutopostingConfig = {}) {\n const key = config.apiKey ?? process.env.AUTOPOSTING_API_KEY\n if (!key) {\n throw new Error(\n 'API key is required. Pass apiKey in config or set AUTOPOSTING_API_KEY env var.',\n )\n }\n this._apiKey = key\n this.baseUrl = (config.baseUrl ?? 'https://app.autoposting.ai').replace(/\\/$/, '')\n this.timeout = config.timeout ?? 30_000\n this.extraHeaders = config.headers ?? {}\n this.authSource = config.authSource ?? 'api-key'\n this.agents = new AgentsResource(this)\n this.billing = new BillingResource(this)\n this.brands = new BrandsResource(this)\n this.carousels = new CarouselsResource(this)\n this.clips = new ClipsResource(this)\n this.posts = new PostsResource(this)\n this.kb = new KbResource(this)\n this.ideas = new IdeasResource(this)\n this.usage = new UsageResource(this)\n this.webhooks = new WebhooksResource(this)\n this.workspaces = new WorkspacesResource(this)\n }\n\n async request<T = unknown>(\n method: HttpMethod,\n path: string,\n body?: unknown,\n query?: Record<string, unknown>,\n ): Promise<T> {\n let url = `${this.baseUrl}${path}`\n\n if (query && Object.keys(query).length > 0) {\n const params = new URLSearchParams()\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined && v !== null) {\n params.set(k, String(v))\n }\n }\n url = `${url}?${params.toString()}`\n }\n\n // FormData must not have a content-type header — fetch sets it with the multipart boundary\n const isFormData = body instanceof FormData\n const headers: Record<string, string> = {\n authorization: `Bearer ${this._apiKey}`,\n 'user-agent': `autoposting-sdk/${VERSION}`,\n 'x-source': 'sdk',\n ...this.extraHeaders,\n }\n if (!isFormData) {\n headers['content-type'] = 'application/json'\n }\n\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeout)\n\n let response: Response\n try {\n response = await fetch(url, {\n method,\n headers,\n body: isFormData ? body : body !== undefined ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n })\n } finally {\n clearTimeout(timer)\n }\n\n if (!response.ok) {\n let errorBody: { error?: string; code?: string } = {}\n try {\n errorBody = (await response.json()) as { error?: string; code?: string }\n } catch {\n // non-JSON error body — leave as empty object\n }\n\n const err = createError(response.status, errorBody)\n\n if (err instanceof RateLimitError) {\n const retryAfter = response.headers.get('Retry-After')\n if (retryAfter) {\n err.retryAfter = parseInt(retryAfter, 10)\n }\n }\n\n throw err\n }\n\n // 204 No Content — return empty object\n if (response.status === 204) {\n return {} as T\n }\n\n return response.json() as Promise<T>\n }\n}\n","import type { Tool } from '@modelcontextprotocol/sdk/types.js'\n\nexport const ALL_TOOLS: Tool[] = [\n // Posts\n {\n name: 'list-posts',\n description: 'List posts with optional filters by brand, status, limit, and page.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Filter by brand slug' },\n status: {\n type: 'string',\n enum: ['draft', 'scheduled', 'published', 'failed'],\n description: 'Filter by post status',\n },\n limit: { type: 'number', description: 'Max results per page (default 20)' },\n page: { type: 'number', description: 'Page number (default 1)' },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'get-post',\n description: 'Get a post by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-post',\n description: 'Create a new post draft for a brand on one or more platforms.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Brand slug to post under' },\n text: { type: 'string', description: 'Post text content' },\n platforms: {\n type: 'string',\n description: 'Comma-separated platform list (e.g. x,linkedin)',\n },\n scheduledAt: {\n type: 'string',\n description: 'ISO 8601 datetime to schedule the post',\n },\n },\n required: ['brandSlug', 'text', 'platforms'],\n additionalProperties: false,\n },\n },\n {\n name: 'update-post',\n description: 'Update the text, platforms, or scheduled time of an existing post.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID' },\n text: { type: 'string', description: 'New post text' },\n platforms: { type: 'string', description: 'Comma-separated new platform list' },\n scheduledAt: { type: 'string', description: 'New ISO 8601 scheduled datetime' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-post',\n description: 'Permanently delete a post by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'publish-post',\n description: 'Immediately publish a post to all its platforms.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to publish' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'schedule-post',\n description: 'Schedule a post to be published at a specific date and time.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to schedule' },\n scheduledAt: { type: 'string', description: 'ISO 8601 datetime for publishing' },\n },\n required: ['id', 'scheduledAt'],\n additionalProperties: false,\n },\n },\n {\n name: 'retry-post',\n description: 'Retry publishing a failed post.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to retry' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'rewrite-post',\n description: 'AI-rewrite the text of a post.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to rewrite' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'score-post',\n description: 'Score a post with AI feedback and return a numeric score with explanation.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Post ID to score' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Brands\n {\n name: 'list-brands',\n description: 'List all brands in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-brand',\n description: 'Get a brand by its slug.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Brand slug' },\n },\n required: ['brandSlug'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-brand',\n description: 'Create a new brand in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: 'Brand display name' },\n timezone: { type: 'string', description: 'IANA timezone (e.g. America/New_York)' },\n },\n required: ['name'],\n additionalProperties: false,\n },\n },\n {\n name: 'update-brand',\n description: 'Update a brand name or timezone.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Brand slug to update' },\n name: { type: 'string', description: 'New display name' },\n timezone: { type: 'string', description: 'New IANA timezone' },\n },\n required: ['brandSlug'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-brand',\n description: 'Permanently delete a brand by slug.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Brand slug to delete' },\n },\n required: ['brandSlug'],\n additionalProperties: false,\n },\n },\n {\n name: 'brand-auth-status',\n description: 'Show the platform connection status for a brand.',\n inputSchema: {\n type: 'object',\n properties: {\n brandSlug: { type: 'string', description: 'Brand slug' },\n },\n required: ['brandSlug'],\n additionalProperties: false,\n },\n },\n\n // Agents\n {\n name: 'list-agents',\n description: 'List all agents in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-agent',\n description: 'Get an agent by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-agent',\n description: 'Create a new publish or research agent.',\n inputSchema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: 'Agent name' },\n type: {\n type: 'string',\n enum: ['publish', 'research'],\n description: 'Agent type',\n },\n brandSlug: { type: 'string', description: 'Brand slug to associate with' },\n prompt: { type: 'string', description: 'Agent instructions or prompt' },\n frequency: {\n type: 'string',\n enum: ['manual', 'daily', 'weekly'],\n description: 'Run frequency',\n },\n time: { type: 'string', description: 'Time of day to run (HH:MM)' },\n weekday: { type: 'string', description: 'Day of week (required for weekly frequency)' },\n kbId: { type: 'string', description: 'Knowledge base ID to attach' },\n },\n required: ['name', 'type', 'prompt', 'frequency'],\n additionalProperties: false,\n },\n },\n {\n name: 'update-agent',\n description: 'Update an agent name, prompt, frequency, or schedule.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID' },\n name: { type: 'string', description: 'New agent name' },\n prompt: { type: 'string', description: 'New prompt' },\n frequency: { type: 'string', description: 'New frequency: manual, daily, or weekly' },\n time: { type: 'string', description: 'New time of day (HH:MM)' },\n weekday: { type: 'string', description: 'New day of week' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-agent',\n description: 'Permanently delete an agent by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'run-agent',\n description: 'Trigger an immediate run of an agent.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID to run' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'toggle-agent',\n description: 'Enable or disable an agent.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID to toggle' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'agent-runs',\n description: 'List the run history for an agent.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Agent ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Knowledge Bases\n {\n name: 'list-kbs',\n description: 'List all knowledge bases in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-kb',\n description: 'Get a knowledge base by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Knowledge base ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-kb',\n description: 'Create a new knowledge base.',\n inputSchema: {\n type: 'object',\n properties: {\n name: { type: 'string', description: 'Knowledge base name' },\n },\n required: ['name'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-kb',\n description: 'Permanently delete a knowledge base by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Knowledge base ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'search-kb',\n description: 'Search a knowledge base with a text query.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Knowledge base ID to search' },\n query: { type: 'string', description: 'Search query text' },\n },\n required: ['id', 'query'],\n additionalProperties: false,\n },\n },\n {\n name: 'ingest-kb',\n description: 'Ingest a URL into a knowledge base.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Knowledge base ID to ingest into' },\n url: { type: 'string', description: 'URL to ingest' },\n },\n required: ['id', 'url'],\n additionalProperties: false,\n },\n },\n {\n name: 'kb-docs',\n description: 'List documents stored in a knowledge base.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Knowledge base ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Ideas\n {\n name: 'generate-ideas',\n description: 'AI-generate content ideas, optionally seeded from a knowledge base or topic.',\n inputSchema: {\n type: 'object',\n properties: {\n kbId: { type: 'string', description: 'Knowledge base ID to draw context from' },\n topic: { type: 'string', description: 'Topic or theme for idea generation' },\n count: { type: 'number', description: 'Number of ideas to generate (default 5)' },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'list-ideas',\n description: 'List all saved content ideas.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'enrich-idea',\n description: 'Enrich an idea with additional AI-generated context.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Idea ID to enrich' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-idea',\n description: 'Permanently delete an idea by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Idea ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Clips\n {\n name: 'list-clips',\n description: 'List all video clips in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-clip',\n description: 'Get a video clip by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Clip ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'import-clip',\n description: 'Import a video clip from a remote URL.',\n inputSchema: {\n type: 'object',\n properties: {\n url: { type: 'string', description: 'URL of the video to import' },\n name: { type: 'string', description: 'Optional name for the imported clip' },\n },\n required: ['url'],\n additionalProperties: false,\n },\n },\n {\n name: 'render-clip',\n description: 'Trigger rendering for a video clip.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Clip ID to render' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-clip',\n description: 'Permanently delete a video clip by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Clip ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Carousels\n {\n name: 'list-carousels',\n description: 'List all carousels in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-carousel',\n description: 'Get a carousel by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Carousel ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-carousel',\n description: 'Create a new empty carousel.',\n inputSchema: {\n type: 'object',\n properties: {\n title: { type: 'string', description: 'Optional carousel title' },\n },\n additionalProperties: false,\n },\n },\n {\n name: 'generate-carousel',\n description: 'AI-generate a carousel from a topic.',\n inputSchema: {\n type: 'object',\n properties: {\n topic: { type: 'string', description: 'Topic to generate slides for' },\n brandSlug: { type: 'string', description: 'Brand slug for brand voice' },\n slideCount: { type: 'number', description: 'Number of slides to generate' },\n },\n required: ['topic'],\n additionalProperties: false,\n },\n },\n {\n name: 'draft-carousel',\n description: 'Convert a carousel into a post draft.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Carousel ID to convert' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-carousel',\n description: 'Permanently delete a carousel by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Carousel ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Webhooks\n {\n name: 'list-webhooks',\n description: 'List all webhooks in the workspace.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'get-webhook',\n description: 'Get a webhook by its ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Webhook ID' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'create-webhook',\n description: 'Create a new webhook endpoint for receiving events.',\n inputSchema: {\n type: 'object',\n properties: {\n url: { type: 'string', description: 'HTTPS endpoint URL to receive events' },\n events: {\n type: 'string',\n description: 'Comma-separated event types (e.g. post.published,post.failed)',\n },\n secret: { type: 'string', description: 'Optional HMAC signing secret' },\n },\n required: ['url', 'events'],\n additionalProperties: false,\n },\n },\n {\n name: 'update-webhook',\n description: 'Update the URL, events, or active state of a webhook.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Webhook ID' },\n url: { type: 'string', description: 'New endpoint URL' },\n events: { type: 'string', description: 'New comma-separated event types' },\n active: { type: 'boolean', description: 'Whether the webhook is active' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'delete-webhook',\n description: 'Permanently delete a webhook by ID.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Webhook ID to delete' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n {\n name: 'test-webhook',\n description: 'Send a test event to a webhook endpoint.',\n inputSchema: {\n type: 'object',\n properties: {\n id: { type: 'string', description: 'Webhook ID to send the test event to' },\n },\n required: ['id'],\n additionalProperties: false,\n },\n },\n\n // Billing\n {\n name: 'billing-status',\n description: 'Get the current billing plan and subscription status.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n {\n name: 'billing-credits',\n description: 'Get the current AI credit balance and usage breakdown.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n\n // Usage\n {\n name: 'usage-summary',\n description: 'Get a summary of post and publishing usage for the current period.',\n inputSchema: {\n type: 'object',\n properties: {},\n additionalProperties: false,\n },\n },\n]\n","import type { Autoposting } from '@autoposting.ai/sdk'\nimport type { Platform } from '@autoposting.ai/sdk'\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js'\n\ntype ToolArgs = Record<string, unknown>\nconst PLATFORMS: Platform[] = [\n 'x',\n 'linkedin',\n 'instagram',\n 'threads',\n 'youtube',\n]\nconst PLATFORM_SET = new Set<string>(PLATFORMS)\n\nfunction ok(data: unknown): CallToolResult {\n return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }\n}\n\nfunction fail(error: unknown): CallToolResult {\n const message = error instanceof Error ? error.message : String(error)\n return { content: [{ type: 'text', text: message }], isError: true }\n}\n\nfunction parsePlatforms(raw: unknown): Platform[] {\n if (typeof raw !== 'string') return []\n const platforms = raw\n .split(',')\n .map((p) => p.trim())\n .filter(Boolean)\n const invalid = platforms.filter((platform) => !PLATFORM_SET.has(platform))\n if (invalid.length > 0) {\n throw new Error(\n `Invalid platform(s): ${invalid.join(', ')}. Expected one of: ${PLATFORMS.join(', ')}.`,\n )\n }\n return platforms as Platform[]\n}\n\nfunction parseEvents(raw: unknown): string[] {\n if (typeof raw !== 'string') return []\n return raw.split(',').map((e) => e.trim())\n}\n\nexport async function handleToolCall(\n name: string,\n args: ToolArgs,\n client: Autoposting,\n): Promise<CallToolResult> {\n try {\n return await dispatchToolCall(name, args, client)\n } catch (error) {\n return fail(error)\n }\n}\n\nasync function dispatchToolCall(\n name: string,\n args: ToolArgs,\n client: Autoposting,\n): Promise<CallToolResult> {\n switch (name) {\n // Posts\n case 'list-posts': {\n const result = await client.posts.list({\n brandSlug: args.brandSlug as string | undefined,\n status: args.status as\n | 'draft'\n | 'scheduled'\n | 'published'\n | 'failed'\n | undefined,\n limit: args.limit as number | undefined,\n page: args.page as number | undefined,\n })\n return ok(result)\n }\n case 'get-post': {\n const result = await client.posts.getById(args.id as string)\n return ok(result)\n }\n case 'create-post': {\n const result = await client.posts.create({\n brandSlug: args.brandSlug as string,\n text: args.text as string,\n platforms: parsePlatforms(args.platforms),\n ...(args.scheduledAt\n ? { scheduledAt: args.scheduledAt as string }\n : {}),\n })\n return ok(result)\n }\n case 'update-post': {\n const result = await client.posts.update(args.id as string, {\n ...(args.text ? { text: args.text as string } : {}),\n ...(args.platforms\n ? {\n platforms: parsePlatforms(args.platforms),\n }\n : {}),\n ...(args.scheduledAt\n ? { scheduledAt: args.scheduledAt as string }\n : {}),\n })\n return ok(result)\n }\n case 'delete-post': {\n await client.posts.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n case 'publish-post': {\n const result = await client.posts.publish(args.id as string)\n return ok(result)\n }\n case 'schedule-post': {\n const result = await client.posts.schedule(\n args.id as string,\n args.scheduledAt as string,\n )\n return ok(result)\n }\n case 'retry-post': {\n const result = await client.posts.retry(args.id as string)\n return ok(result)\n }\n case 'rewrite-post': {\n const result = await client.posts.rewrite(args.id as string)\n return ok(result)\n }\n case 'score-post': {\n const result = await client.posts.score(args.id as string)\n return ok(result)\n }\n\n // Brands\n case 'list-brands': {\n const result = await client.brands.list()\n return ok(result)\n }\n case 'get-brand': {\n const result = await client.brands.retrieve(args.brandSlug as string)\n return ok(result)\n }\n case 'create-brand': {\n const result = await client.brands.create({\n name: args.name as string,\n ...(args.timezone ? { timezone: args.timezone as string } : {}),\n })\n return ok(result)\n }\n case 'update-brand': {\n const result = await client.brands.update(args.brandSlug as string, {\n ...(args.name ? { name: args.name as string } : {}),\n ...(args.timezone ? { timezone: args.timezone as string } : {}),\n })\n return ok(result)\n }\n case 'delete-brand': {\n await client.brands.remove(args.brandSlug as string)\n return ok({ deleted: true, brandSlug: args.brandSlug })\n }\n case 'brand-auth-status': {\n const result = await client.brands.authStatus(args.brandSlug as string)\n return ok(result)\n }\n\n // Agents\n case 'list-agents': {\n const result = await client.agents.list()\n return ok(result)\n }\n case 'get-agent': {\n const result = await client.agents.retrieve(args.id as string)\n return ok(result)\n }\n case 'create-agent': {\n const result = await client.agents.create({\n name: args.name as string,\n type: args.type as 'publish' | 'research',\n prompt: args.prompt as string,\n frequency: args.frequency as 'manual' | 'daily' | 'weekly',\n ...(args.brandSlug ? { brandSlug: args.brandSlug as string } : {}),\n ...(args.time ? { time: args.time as string } : {}),\n ...(args.weekday ? { weekday: args.weekday as string } : {}),\n ...(args.kbId ? { kbId: args.kbId as string } : {}),\n })\n return ok(result)\n }\n case 'update-agent': {\n const result = await client.agents.update(args.id as string, {\n ...(args.name ? { name: args.name as string } : {}),\n ...(args.prompt ? { prompt: args.prompt as string } : {}),\n ...(args.frequency ? { frequency: args.frequency as string } : {}),\n ...(args.time ? { time: args.time as string } : {}),\n ...(args.weekday ? { weekday: args.weekday as string } : {}),\n })\n return ok(result)\n }\n case 'delete-agent': {\n await client.agents.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n case 'run-agent': {\n const result = await client.agents.run(args.id as string)\n return ok(result)\n }\n case 'toggle-agent': {\n const result = await client.agents.toggle(args.id as string)\n return ok(result)\n }\n case 'agent-runs': {\n const result = await client.agents.runs(args.id as string)\n return ok(result)\n }\n\n // Knowledge Bases\n case 'list-kbs': {\n const result = await client.kb.list()\n return ok(result)\n }\n case 'get-kb': {\n const result = await client.kb.retrieve(args.id as string)\n return ok(result)\n }\n case 'create-kb': {\n const result = await client.kb.create({ name: args.name as string })\n return ok(result)\n }\n case 'delete-kb': {\n await client.kb.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n case 'search-kb': {\n const result = await client.kb.search(\n args.id as string,\n args.query as string,\n )\n return ok(result)\n }\n case 'ingest-kb': {\n const result = await client.kb.ingestUrl(\n args.id as string,\n args.url as string,\n )\n return ok(result)\n }\n case 'kb-docs': {\n const result = await client.kb.docs(args.id as string)\n return ok(result)\n }\n\n // Ideas\n case 'generate-ideas': {\n const result = await client.ideas.generate({\n ...(args.kbId ? { kbId: args.kbId as string } : {}),\n ...(args.topic ? { topic: args.topic as string } : {}),\n ...(args.count ? { count: args.count as number } : {}),\n })\n return ok(result)\n }\n case 'list-ideas': {\n const result = await client.ideas.list()\n return ok(result)\n }\n case 'enrich-idea': {\n const result = await client.ideas.enrich(args.id as string)\n return ok(result)\n }\n case 'delete-idea': {\n await client.ideas.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n\n // Clips\n case 'list-clips': {\n const result = await client.clips.list()\n return ok(result)\n }\n case 'get-clip': {\n const result = await client.clips.retrieve(args.id as string)\n return ok(result)\n }\n case 'import-clip': {\n const result = await client.clips.importUrl({\n url: args.url as string,\n ...(args.name ? { name: args.name as string } : {}),\n })\n return ok(result)\n }\n case 'render-clip': {\n const result = await client.clips.render(args.id as string)\n return ok(result)\n }\n case 'delete-clip': {\n await client.clips.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n\n // Carousels\n case 'list-carousels': {\n const result = await client.carousels.list()\n return ok(result)\n }\n case 'get-carousel': {\n const result = await client.carousels.retrieve(args.id as string)\n return ok(result)\n }\n case 'create-carousel': {\n const result = await client.carousels.create(\n args.title ? { title: args.title as string } : undefined,\n )\n return ok(result)\n }\n case 'generate-carousel': {\n const result = await client.carousels.generate({\n topic: args.topic as string,\n ...(args.brandSlug ? { brandSlug: args.brandSlug as string } : {}),\n ...(args.slideCount ? { slideCount: args.slideCount as number } : {}),\n })\n return ok(result)\n }\n case 'draft-carousel': {\n const result = await client.carousels.draft(args.id as string)\n return ok(result)\n }\n case 'delete-carousel': {\n await client.carousels.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n\n // Webhooks\n case 'list-webhooks': {\n const result = await client.webhooks.list()\n return ok(result)\n }\n case 'get-webhook': {\n const result = await client.webhooks.retrieve(args.id as string)\n return ok(result)\n }\n case 'create-webhook': {\n const result = await client.webhooks.create({\n url: args.url as string,\n events: parseEvents(args.events),\n ...(args.secret ? { secret: args.secret as string } : {}),\n })\n return ok(result)\n }\n case 'update-webhook': {\n const result = await client.webhooks.update(args.id as string, {\n ...(args.url ? { url: args.url as string } : {}),\n ...(args.events ? { events: parseEvents(args.events) } : {}),\n ...(args.active !== undefined\n ? { active: args.active as boolean }\n : {}),\n })\n return ok(result)\n }\n case 'delete-webhook': {\n await client.webhooks.remove(args.id as string)\n return ok({ deleted: true, id: args.id })\n }\n case 'test-webhook': {\n await client.webhooks.test(args.id as string)\n return ok({ sent: true, id: args.id })\n }\n\n // Billing\n case 'billing-status': {\n const result = await client.billing.status()\n return ok(result)\n }\n case 'billing-credits': {\n const result = await client.billing.credits()\n return ok(result)\n }\n\n // Usage\n case 'usage-summary': {\n const result = await client.usage.summary()\n return ok(result)\n }\n\n default:\n return {\n content: [{ type: 'text', text: `Unknown tool: ${name}` }],\n isError: true,\n }\n }\n}\n","import { Server } from '@modelcontextprotocol/sdk/server/index.js'\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'\nimport {\n ListToolsRequestSchema,\n CallToolRequestSchema,\n} from '@modelcontextprotocol/sdk/types.js'\nimport { Autoposting, VERSION } from '@autoposting.ai/sdk'\nimport { ALL_TOOLS } from './tools.js'\nimport { handleToolCall } from './handler.js'\n\nexport async function startMcpServer(): Promise<void> {\n const client = new Autoposting() // reads AUTOPOSTING_API_KEY from env\n\n const server = new Server(\n { name: 'autoposting-mcp', version: VERSION },\n { capabilities: { tools: {} } },\n )\n\n server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: ALL_TOOLS,\n }))\n\n server.setRequestHandler(CallToolRequestSchema, async (request) => {\n const { name, arguments: args } = request.params\n return handleToolCall(name, (args ?? {}) as Record<string, unknown>, client)\n })\n\n const transport = new StdioServerTransport()\n await server.connect(transport)\n}\n","#!/usr/bin/env node\nimport { Command } from 'commander'\nimport { VERSION } from '@autoposting.ai/sdk'\nimport { createAgentsCommand } from './commands/agents.js'\nimport { createAuthCommand } from './commands/auth.js'\nimport { createBillingCommand } from './commands/billing.js'\nimport { createBrandsCommand } from './commands/brands.js'\nimport { createCarouselsCommand } from './commands/carousels.js'\nimport { createClipsCommand } from './commands/clips.js'\nimport { createPostsCommand } from './commands/posts.js'\nimport { createKbCommand } from './commands/kb.js'\nimport { createIdeasCommand } from './commands/ideas.js'\nimport { createUsageCommand } from './commands/usage.js'\nimport { createWebhooksCommand } from './commands/webhooks.js'\nimport { createWorkspacesCommand } from './commands/workspaces.js'\nimport { createDoctorCommand } from './commands/doctor.js'\nimport { createWhoamiCommand } from './commands/whoami.js'\nimport { createOpenCommand } from './commands/open.js'\nimport { createUpdateCommand } from './commands/update.js'\nimport { createCompletionCommand } from './commands/completion.js'\nimport { createMcpCommand } from './commands/mcp.js'\nimport { disableColor } from './output/index.js'\n\nconst program = new Command()\n .name('autoposting')\n .description('Autoposting CLI — manage social media from the terminal')\n .version(VERSION)\n .option('--json', 'Output as JSON')\n .option('--quiet', 'Suppress spinners and non-essential output')\n .option('--format <type>', 'Output format: table, json', 'table')\n .option('--api-key <key>', 'API key (overrides env/stored credentials)')\n .option('--no-color', 'Disable color output')\n .hook('preAction', (thisCommand) => {\n const opts = thisCommand.opts<{ color: boolean }>()\n if (!opts.color) disableColor()\n })\n\nprogram.addCommand(createAuthCommand())\nprogram.addCommand(createBillingCommand())\nprogram.addCommand(createBrandsCommand())\nprogram.addCommand(createCarouselsCommand())\nprogram.addCommand(createClipsCommand())\nprogram.addCommand(createPostsCommand())\nprogram.addCommand(createAgentsCommand())\nprogram.addCommand(createKbCommand())\nprogram.addCommand(createIdeasCommand())\nprogram.addCommand(createUsageCommand())\nprogram.addCommand(createWebhooksCommand())\nprogram.addCommand(createWorkspacesCommand())\nprogram.addCommand(createDoctorCommand())\nprogram.addCommand(createWhoamiCommand())\nprogram.addCommand(createOpenCommand())\nprogram.addCommand(createUpdateCommand())\nprogram.addCommand(createCompletionCommand())\nprogram.addCommand(createMcpCommand())\n\nprogram.parse()\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createAgentsCommand(): Command {\n const agents = new Command('agents').description('Manage agents')\n\n // ap agents list\n agents\n .command('list')\n .description('List all agents')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching agents…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.agents.list()\n spinner.stop()\n const rows = list.map((a) => ({\n id: a.id,\n name: a.name,\n type: a.type,\n brand: a.brandSlug ?? '—',\n frequency: a.frequency,\n enabled: a.enabled ? 'yes' : 'no',\n }))\n printer.table(rows, ['id', 'name', 'type', 'brand', 'frequency', 'enabled'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap agents get <id>\n agents\n .command('get <id>')\n .description('Get an agent by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const agent = await client.agents.retrieve(id)\n spinner.stop()\n printer.log(agent)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap agents create --name <name> --type <publish|research> [--brand <slug>] --prompt <text> --frequency <manual|daily|weekly>\n agents\n .command('create')\n .description('Create a new agent')\n .requiredOption('--name <name>', 'Agent name')\n .requiredOption('--type <type>', 'Agent type: publish or research')\n .option('--brand <slug>', 'Brand slug to associate with')\n .requiredOption('--prompt <text>', 'Agent prompt / instructions')\n .requiredOption('--frequency <freq>', 'Run frequency: manual, daily, or weekly')\n .option('--time <HH:MM>', 'Time of day to run (required for daily/weekly)')\n .option('--weekday <day>', 'Day of week to run (required for weekly)')\n .option('--kb <id>', 'Knowledge base ID to attach')\n .action(\n async (\n opts: {\n name: string\n type: string\n brand?: string\n prompt: string\n frequency: string\n time?: string\n weekday?: string\n kb?: string\n },\n cmd: Command,\n ) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating agent…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const agent = await client.agents.create({\n name: opts.name,\n type: opts.type as 'publish' | 'research',\n prompt: opts.prompt,\n frequency: opts.frequency as 'manual' | 'daily' | 'weekly',\n ...(opts.brand ? { brandSlug: opts.brand } : {}),\n ...(opts.time ? { time: opts.time } : {}),\n ...(opts.weekday ? { weekday: opts.weekday } : {}),\n ...(opts.kb ? { kbId: opts.kb } : {}),\n })\n spinner.stop()\n printer.log(agent)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap agents update <id> [--name] [--prompt] [--frequency] [--time] [--weekday]\n agents\n .command('update <id>')\n .description('Update an agent')\n .option('--name <name>', 'New agent name')\n .option('--prompt <text>', 'New prompt / instructions')\n .option('--frequency <freq>', 'New frequency: manual, daily, or weekly')\n .option('--time <HH:MM>', 'New time of day')\n .option('--weekday <day>', 'New day of week')\n .action(\n async (\n id: string,\n opts: { name?: string; prompt?: string; frequency?: string; time?: string; weekday?: string },\n cmd: Command,\n ) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Updating agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const agent = await client.agents.update(id, {\n ...(opts.name ? { name: opts.name } : {}),\n ...(opts.prompt ? { prompt: opts.prompt } : {}),\n ...(opts.frequency ? { frequency: opts.frequency } : {}),\n ...(opts.time ? { time: opts.time } : {}),\n ...(opts.weekday ? { weekday: opts.weekday } : {}),\n })\n spinner.stop()\n printer.log(agent)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap agents delete <id> --force\n agents\n .command('delete <id>')\n .description('Delete an agent (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete an agent. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.agents.remove(id)\n spinner.stop()\n printer.log(`Agent \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap agents run <id>\n agents\n .command('run <id>')\n .description('Trigger an agent run immediately')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Running agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const agentRun = await client.agents.run(id)\n spinner.stop()\n printer.log(agentRun)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap agents toggle <id>\n agents\n .command('toggle <id>')\n .description('Enable or disable an agent')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Toggling agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const agent = await client.agents.toggle(id)\n spinner.stop()\n printer.log(agent)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap agents runs <id>\n agents\n .command('runs <id>')\n .description('List run history for an agent')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching runs for agent \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.agents.runs(id)\n spinner.stop()\n const rows = list.map((r) => ({\n id: r.id,\n status: r.status,\n output: r.output ? (r.output.length > 60 ? `${r.output.slice(0, 57)}…` : r.output) : '—',\n createdAt: r.createdAt,\n }))\n printer.table(rows, ['id', 'status', 'output', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return agents\n}\n","import fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\n\nexport interface StoredProfile {\n apiKey: string\n workspace?: string\n email?: string\n createdAt: string\n}\n\nexport interface CredentialsFile {\n activeProfile: string\n profiles: Record<string, StoredProfile>\n}\n\nexport function getCredentialsPath(): string {\n const configBase = process.env.XDG_CONFIG_HOME ?? path.join(os.homedir(), '.config')\n return path.join(configBase, 'autoposting', 'credentials.json')\n}\n\nexport function readCredentials(): CredentialsFile | null {\n const filePath = getCredentialsPath()\n try {\n const raw = fs.readFileSync(filePath, 'utf8')\n return JSON.parse(raw) as CredentialsFile\n } catch {\n // Missing or corrupt file — return null gracefully\n return null\n }\n}\n\nexport function writeCredentials(creds: CredentialsFile): void {\n const filePath = getCredentialsPath()\n const dir = path.dirname(filePath)\n\n // Use { recursive: true } so mkdirSync is idempotent (avoids TOCTOU race between\n // existsSync + mkdirSync). Mode 0o700 ensures only the owning user can read the dir.\n fs.mkdirSync(dir, { recursive: true, mode: 0o700 })\n\n fs.writeFileSync(filePath, JSON.stringify(creds, null, 2), { encoding: 'utf8', mode: 0o600 })\n\n // Ensure 0600 even if file already existed before\n fs.chmodSync(filePath, 0o600)\n}\n\nexport function saveProfile(name: string, profile: StoredProfile): void {\n const existing = readCredentials()\n const creds: CredentialsFile = existing ?? { activeProfile: name, profiles: {} }\n creds.profiles[name] = profile\n creds.activeProfile = name\n writeCredentials(creds)\n}\n\nexport function deleteProfile(name: string): void {\n const creds = readCredentials()\n if (!creds) return\n\n delete creds.profiles[name]\n\n // If deleted profile was active, clear active or pick another\n if (creds.activeProfile === name) {\n const remaining = Object.keys(creds.profiles)\n creds.activeProfile = remaining[0] ?? ''\n }\n\n writeCredentials(creds)\n}\n\nexport function deleteAllProfiles(): void {\n writeCredentials({ activeProfile: '', profiles: {} })\n}\n\nexport function getActiveProfile(): StoredProfile | null {\n const creds = readCredentials()\n if (!creds || !creds.activeProfile) return null\n return creds.profiles[creds.activeProfile] ?? null\n}\n\nexport function setActiveProfile(name: string): void {\n const creds = readCredentials()\n if (!creds) throw new Error(`Profile \"${name}\" does not exist (no credentials file)`)\n if (!creds.profiles[name]) throw new Error(`Profile \"${name}\" does not exist`)\n creds.activeProfile = name\n writeCredentials(creds)\n}\n","import { getActiveProfile, getCredentialsPath } from './credential-store.js'\n\nexport interface AuthCredentials {\n apiKey: string\n source: 'flag' | 'env' | 'stored'\n profile?: string\n}\n\nexport { getCredentialsPath }\n\n/**\n * Resolves credentials using priority chain:\n * 1. --api-key flag (explicit)\n * 2. AUTOPOSTING_API_KEY env var\n * 3. Stored credentials from file (active profile)\n *\n * Throws with exit-code-2-compatible error when no auth is available.\n */\nexport function resolveAuth(options?: { apiKey?: string }): AuthCredentials {\n // 1. Explicit flag\n if (options?.apiKey) {\n return { apiKey: options.apiKey, source: 'flag' }\n }\n\n // 2. Env var\n const envKey = process.env.AUTOPOSTING_API_KEY\n if (envKey) {\n return { apiKey: envKey, source: 'env' }\n }\n\n // 3. Stored profile\n const profile = getActiveProfile()\n if (profile?.apiKey) {\n return { apiKey: profile.apiKey, source: 'stored' }\n }\n\n const err = new Error(\n 'No API key found. Run `ap auth login --api-key <key>` or set AUTOPOSTING_API_KEY.',\n )\n ;(err as NodeJS.ErrnoException & { exitCode?: number }).exitCode = 2\n throw err\n}\n","// ANSI color codes — no chalk dependency to keep bundle small\nconst RED = '\\x1b[31m'\nconst RESET = '\\x1b[0m'\n\nlet colorEnabled = true\n\nexport function disableColor(): void {\n colorEnabled = false\n}\n\nfunction red(text: string): string {\n if (!colorEnabled || !process.stdout.isTTY) return text\n return `${RED}${text}${RESET}`\n}\n\nexport type OutputMode = 'tty' | 'json' | 'quiet'\n\nexport interface OutputOptions {\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n color?: boolean\n}\n\nexport function detectOutputMode(options: OutputOptions): OutputMode {\n if (options.quiet) return 'quiet'\n if (options.json || !process.stdout.isTTY) return 'json'\n return 'tty'\n}\n\nexport function formatOutput(data: unknown, mode: OutputMode): string {\n if (mode === 'quiet') return ''\n if (mode === 'json') return JSON.stringify(data, null, 2)\n // tty: pretty-print objects or stringify primitives\n if (typeof data === 'string') return data\n return JSON.stringify(data, null, 2)\n}\n\nexport function formatTable(\n rows: Record<string, unknown>[],\n columns?: string[],\n): string {\n if (rows.length === 0) return ''\n\n const cols = columns ?? Object.keys(rows[0]!)\n const widths: number[] = cols.map((col) => col.length)\n\n // Compute max widths\n for (const row of rows) {\n for (let i = 0; i < cols.length; i++) {\n const val = String(row[cols[i]!] ?? '')\n if (val.length > widths[i]!) widths[i] = val.length\n }\n }\n\n const pad = (s: string, w: number) => s.padEnd(w, ' ')\n const separator = widths.map((w) => '-'.repeat(w)).join(' ')\n\n const header = cols.map((c, i) => pad(c.toUpperCase(), widths[i]!)).join(' ')\n const dataRows = rows.map((row) =>\n cols.map((c, i) => pad(String(row[c] ?? ''), widths[i]!)).join(' '),\n )\n\n return [header, separator, ...dataRows].join('\\n')\n}\n\nexport function formatError(error: Error | string, mode: OutputMode): string {\n const message = error instanceof Error ? error.message : error\n if (mode === 'tty') return red(`Error: ${message}`)\n // json and quiet both return JSON error — errors always show\n return JSON.stringify({ error: message }, null, 2)\n}\n","import type { OutputMode } from './formatter.js'\n\nexport interface Spinner {\n start(message: string): void\n stop(message?: string): void\n fail(message: string): void\n}\n\n// No-op spinner for JSON/quiet modes — no TTY output during machine-readable runs\nconst NO_OP_SPINNER: Spinner = {\n start: () => {},\n stop: () => {},\n fail: () => {},\n}\n\n// TTY spinner backed by ora (dynamic import for CJS compatibility)\nclass OraSpinner implements Spinner {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private instance: any = null\n\n start(message: string): void {\n import('ora').then(({ default: ora }) => {\n this.instance = ora(message).start()\n }).catch(() => {\n // ora unavailable — fall back to plain stdout\n process.stdout.write(`${message}\\n`)\n })\n }\n\n stop(message?: string): void {\n if (this.instance) {\n this.instance.succeed(message)\n this.instance = null\n } else if (message) {\n process.stdout.write(`${message}\\n`)\n }\n }\n\n fail(message: string): void {\n if (this.instance) {\n this.instance.fail(message)\n this.instance = null\n } else {\n process.stderr.write(`${message}\\n`)\n }\n }\n}\n\nexport function createSpinner(mode: OutputMode): Spinner {\n if (mode === 'tty') return new OraSpinner()\n return NO_OP_SPINNER\n}\n","import { type OutputMode, type OutputOptions, formatOutput, formatTable, formatError, detectOutputMode } from './formatter.js'\nimport { createSpinner, type Spinner } from './spinner.js'\n\nexport class Printer {\n constructor(private mode: OutputMode) {}\n\n log(data: unknown): void {\n const out = formatOutput(data, this.mode)\n if (out !== '') console.log(out)\n }\n\n table(rows: Record<string, unknown>[], columns?: string[]): void {\n if (this.mode === 'quiet') return\n if (this.mode === 'json') {\n console.log(formatOutput(rows, 'json'))\n return\n }\n const out = formatTable(rows, columns)\n if (out !== '') console.log(out)\n }\n\n error(err: Error | string): void {\n const out = formatError(err, this.mode)\n console.error(out)\n }\n\n spinner(message: string): Spinner {\n const s = createSpinner(this.mode)\n s.start(message)\n return s\n }\n}\n\nexport function createPrinter(options: OutputOptions): Printer {\n const mode = detectOutputMode(options)\n return new Printer(mode)\n}\n","export const EXIT_CODES = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n AUTH_ERROR: 2,\n SCOPE_ERROR: 3,\n NOT_FOUND: 4,\n RATE_LIMITED: 5,\n VALIDATION_ERROR: 6,\n NETWORK_ERROR: 7,\n} as const\n\nexport type ExitCode = (typeof EXIT_CODES)[keyof typeof EXIT_CODES]\n\n// Named sentinel classes used for instanceof checks against @autoposting.ai/sdk errors.\n// We match by constructor name so this works even if the SDK hasn't shipped error\n// classes yet (dynamic require would silently fail). When the SDK exports these\n// classes they will inherit from AutopostingError and carry the same names.\nfunction matchesClass(error: unknown, className: string): boolean {\n if (error == null || typeof error !== 'object') return false\n // Walk prototype chain checking constructor names\n let proto = Object.getPrototypeOf(error) as object | null\n while (proto !== null) {\n const ctor = (proto as { constructor?: { name?: string } }).constructor\n if (ctor?.name === className) return true\n proto = Object.getPrototypeOf(proto) as object | null\n }\n return false\n}\n\nexport function exitCodeFromError(error: unknown): ExitCode {\n if (matchesClass(error, 'AuthenticationError')) return EXIT_CODES.AUTH_ERROR\n if (matchesClass(error, 'ScopeError')) return EXIT_CODES.SCOPE_ERROR\n if (matchesClass(error, 'NotFoundError')) return EXIT_CODES.NOT_FOUND\n if (matchesClass(error, 'RateLimitError')) return EXIT_CODES.RATE_LIMITED\n if (matchesClass(error, 'ValidationError')) return EXIT_CODES.VALIDATION_ERROR\n if (matchesClass(error, 'NetworkError')) return EXIT_CODES.NETWORK_ERROR\n return EXIT_CODES.GENERAL_ERROR\n}\n","import { Command } from 'commander'\nimport { execSync } from 'node:child_process'\nimport {\n deleteAllProfiles,\n deleteProfile,\n getActiveProfile,\n readCredentials,\n saveProfile,\n setActiveProfile,\n} from '../auth/credential-store.js'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { requestDeviceCode, pollDeviceCode } from '../auth/device-code-client.js'\n\nconst DEFAULT_BASE_URL = 'https://app.autoposting.ai'\n\nfunction resolveBaseUrl(globals: { baseUrl?: string }): string {\n return globals.baseUrl ?? process.env.AUTOPOSTING_BASE_URL ?? DEFAULT_BASE_URL\n}\n\nfunction tryOpenUrl(url: string): void {\n try {\n // Attempt to open browser; ignore failures (CI, headless, etc.)\n const platform = process.platform\n if (platform === 'darwin') execSync(`open \"${url}\"`, { stdio: 'ignore' })\n else if (platform === 'win32') execSync(`start \"\" \"${url}\"`, { stdio: 'ignore' })\n else execSync(`xdg-open \"${url}\"`, { stdio: 'ignore' })\n } catch {\n // Non-fatal: user can open URL manually\n }\n}\n\nexport function createAuthCommand(): Command {\n const auth = new Command('auth').description('Manage authentication and profiles')\n\n // ap auth login [--api-key <key>] [--profile <name>] [--base-url <url>]\n // Note: --api-key is also a root-level global option on the program. Commander consumes\n // options left-to-right so the root picks it up first. We use optsWithGlobals() to\n // merge root + local options and read whichever level captured the flag.\n auth\n .command('login')\n .description('Log in via browser device code flow, or store an API key directly with --api-key')\n .option('--api-key <key>', 'API key to store directly (skips device code flow)')\n .option('--profile <name>', 'Profile name to save under', 'default')\n .option('--base-url <url>', 'API base URL (overrides AUTOPOSTING_BASE_URL)')\n .action(async (localOpts: { apiKey?: string; profile: string; baseUrl?: string }, cmd: Command) => {\n const opts = cmd.optsWithGlobals<{ apiKey?: string; profile: string; baseUrl?: string }>()\n\n // Fast path: --api-key provided, store directly\n if (opts.apiKey) {\n saveProfile(opts.profile, {\n apiKey: opts.apiKey,\n createdAt: new Date().toISOString(),\n })\n console.log(`Logged in. Profile \"${opts.profile}\" saved.`)\n return\n }\n\n // Device code flow\n const baseUrl = resolveBaseUrl(opts)\n\n let deviceCodeResp\n try {\n deviceCodeResp = await requestDeviceCode(baseUrl)\n } catch (err) {\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n\n const { deviceCode, userCode, verificationUri } = deviceCodeResp\n let pollInterval = deviceCodeResp.interval\n\n console.log(`\\nEnter code ${userCode} at ${verificationUri}\\n`)\n tryOpenUrl(verificationUri)\n\n // Spinner-style wait indicator using process.stdout so we can overwrite it\n const frames = ['|', '/', '-', '\\\\']\n let frameIdx = 0\n const spinnerInterval = setInterval(() => {\n process.stdout.write(`\\rWaiting for authorization... ${frames[frameIdx++ % frames.length]}`)\n }, 100)\n\n const clearSpinner = () => {\n clearInterval(spinnerInterval)\n process.stdout.write('\\r\\x1b[K') // clear spinner line\n }\n\n // Poll loop\n while (true) {\n await new Promise<void>((resolve) => setTimeout(resolve, pollInterval * 1000))\n\n let result\n try {\n result = await pollDeviceCode(baseUrl, deviceCode)\n } catch (err) {\n clearSpinner()\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n\n switch (result.status) {\n case 'complete': {\n clearSpinner()\n const token = result.sessionToken!\n saveProfile(opts.profile, {\n apiKey: token,\n createdAt: new Date().toISOString(),\n })\n console.log(`Logged in. Profile \"${opts.profile}\" saved.`)\n return\n }\n\n case 'expired_token':\n clearSpinner()\n console.error('Error: Authorization expired. Run `ap auth login` again.')\n process.exit(2)\n break\n\n case 'access_denied':\n clearSpinner()\n console.error('Error: Access denied.')\n process.exit(2)\n break\n\n case 'slow_down':\n // Double the interval as instructed by server\n pollInterval = result.interval ?? pollInterval * 2\n break\n\n case 'authorization_pending':\n default:\n // Continue polling\n break\n }\n }\n })\n\n // ap auth logout [--all]\n auth\n .command('logout')\n .description('Remove the active profile (or all profiles with --all)')\n .option('--all', 'Remove all stored profiles')\n .action((opts: { all?: boolean }) => {\n if (opts.all) {\n deleteAllProfiles()\n console.log('All profiles removed.')\n return\n }\n\n const creds = readCredentials()\n const active = creds?.activeProfile\n if (!active) {\n console.log('No active profile to log out from.')\n return\n }\n\n deleteProfile(active)\n console.log(`Profile \"${active}\" removed.`)\n })\n\n // ap auth switch <profile>\n auth\n .command('switch <profile>')\n .description('Switch the active profile')\n .action((profile: string) => {\n try {\n setActiveProfile(profile)\n console.log(`Switched to profile \"${profile}\".`)\n } catch (err) {\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n })\n\n // ap auth whoami\n auth\n .command('whoami')\n .description('Show current authentication method and identity')\n .action((_opts: Record<string, unknown>, cmd: Command) => {\n try {\n const globals = cmd.optsWithGlobals<{ apiKey?: string }>()\n const cred = resolveAuth({ apiKey: globals.apiKey })\n\n console.log(`Source: ${cred.source}`)\n if (cred.source === 'stored') {\n const creds = readCredentials()\n const profileName = creds?.activeProfile ?? 'unknown'\n const profile = creds?.profiles[profileName]\n console.log(`Profile: ${profileName}`)\n if (profile?.workspace) console.log(`Workspace: ${profile.workspace}`)\n if (profile?.email) console.log(`Email: ${profile.email}`)\n }\n // Never print the raw API key\n const masked = `${cred.apiKey.slice(0, 8)}${'*'.repeat(Math.max(0, cred.apiKey.length - 8))}`\n console.log(`API key: ${masked}`)\n } catch (err) {\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n })\n\n // ap auth status — alias for whoami\n auth\n .command('status')\n .description('Alias for whoami — show current authentication status')\n .action((_opts: Record<string, unknown>, cmd: Command) => {\n try {\n const globals = cmd.optsWithGlobals<{ apiKey?: string }>()\n const cred = resolveAuth({ apiKey: globals.apiKey })\n console.log(`Source: ${cred.source}`)\n if (cred.source === 'stored') {\n const creds = readCredentials()\n const profileName = creds?.activeProfile ?? 'unknown'\n console.log(`Profile: ${profileName}`)\n }\n const masked = `${cred.apiKey.slice(0, 8)}${'*'.repeat(Math.max(0, cred.apiKey.length - 8))}`\n console.log(`API key: ${masked}`)\n } catch (err) {\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n })\n\n return auth\n}\n","export interface DeviceCodeResponse {\n deviceCode: string\n userCode: string\n verificationUri: string\n expiresIn: number\n interval: number\n}\n\nexport interface PollResult {\n status: 'authorization_pending' | 'complete' | 'expired_token' | 'access_denied' | 'slow_down'\n sessionToken?: string\n orgId?: string\n interval?: number\n}\n\nexport async function requestDeviceCode(baseUrl: string): Promise<DeviceCodeResponse> {\n const res = await fetch(`${baseUrl}/auth/cli/device-code`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n })\n\n if (!res.ok) {\n const text = await res.text().catch(() => res.statusText)\n throw new Error(`Device code request failed (${res.status}): ${text}`)\n }\n\n const data = (await res.json()) as DeviceCodeResponse\n return data\n}\n\nexport async function pollDeviceCode(baseUrl: string, deviceCode: string): Promise<PollResult> {\n const url = `${baseUrl}/auth/cli/poll?device_code=${encodeURIComponent(deviceCode)}`\n const res = await fetch(url)\n\n if (!res.ok) {\n const text = await res.text().catch(() => res.statusText)\n throw new Error(`Poll request failed (${res.status}): ${text}`)\n }\n\n const data = (await res.json()) as PollResult\n return data\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createBillingCommand(): Command {\n const billing = new Command('billing').description('View billing information')\n\n // ap billing status\n billing\n .command('status')\n .description('Show current plan and subscription status')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching billing status…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const status = await client.billing.status()\n spinner.stop()\n printer.table(\n [\n {\n plan: status.plan,\n status: status.status,\n 'trial ends': status.trialEndsAt ?? '—',\n 'renewal date': status.renewalDate ?? '—',\n 'cancels at': status.cancelAt ?? '—',\n },\n ],\n ['plan', 'status', 'trial ends', 'renewal date', 'cancels at'],\n )\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap billing credits\n billing\n .command('credits')\n .description('Show credit balance and usage breakdown')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching credit balance…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const credits = await client.billing.credits()\n spinner.stop()\n printer.table(\n [\n {\n total: credits.total,\n used: credits.used,\n remaining: credits.remaining,\n },\n ],\n ['total', 'used', 'remaining'],\n )\n if (credits.breakdown && Object.keys(credits.breakdown).length > 0) {\n const breakdownRows = Object.entries(credits.breakdown).map(([key, val]) => ({\n category: key,\n credits: val,\n }))\n printer.table(breakdownRows, ['category', 'credits'])\n }\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return billing\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\nexport function createBrandsCommand(): Command {\n const brands = new Command('brands').description('Manage brands')\n\n // ap brands list\n brands\n .command('list')\n .description('List all brands')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching brands…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.brands.list()\n spinner.stop()\n const rows = list.map((b) => ({\n slug: b.slug,\n name: b.name,\n platforms: b.platforms\n .filter((p) => p.connected)\n .map((p) => p.platform)\n .join(', ') || '—',\n timezone: b.timezone,\n }))\n printer.table(rows, ['slug', 'name', 'platforms', 'timezone'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n // ap brands get <slug>\n brands\n .command('get <slug>')\n .description('Get a brand by slug')\n .action(async (slug: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching brand \"${slug}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const brand = await client.brands.retrieve(slug)\n spinner.stop()\n printer.log(brand)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n // ap brands create --name <name> [--timezone <tz>]\n brands\n .command('create')\n .description('Create a new brand')\n .requiredOption('--name <name>', 'Brand display name')\n .option('--timezone <tz>', 'IANA timezone (e.g. America/New_York)')\n .action(async (opts: { name: string; timezone?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating brand…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const brand = await client.brands.create({\n name: opts.name,\n ...(opts.timezone ? { timezone: opts.timezone } : {}),\n })\n spinner.stop()\n printer.log(brand)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n // ap brands update <slug> [--name <name>] [--timezone <tz>]\n brands\n .command('update <slug>')\n .description('Update a brand')\n .option('--name <name>', 'New display name')\n .option('--timezone <tz>', 'New IANA timezone')\n .action(async (slug: string, opts: { name?: string; timezone?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Updating brand \"${slug}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const brand = await client.brands.update(slug, {\n ...(opts.name ? { name: opts.name } : {}),\n ...(opts.timezone ? { timezone: opts.timezone } : {}),\n })\n spinner.stop()\n printer.log(brand)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n // ap brands delete <slug> [--force]\n brands\n .command('delete <slug>')\n .description('Delete a brand (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (slug: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a brand. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting brand \"${slug}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.brands.remove(slug)\n spinner.stop()\n printer.log(`Brand \"${slug}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n // ap brands auth-status <slug>\n brands\n .command('auth-status <slug>')\n .description('Show platform connection status for a brand')\n .action(async (slug: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n }>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching auth status for \"${slug}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const connections = await client.brands.authStatus(slug)\n spinner.stop()\n const rows = connections.map((c) => ({\n platform: c.platform,\n connected: c.connected ? 'yes' : 'no',\n username: c.username ?? '—',\n 'token status': c.tokenExpired === true ? 'expired' : c.connected ? 'ok' : '—',\n }))\n printer.table(rows, ['platform', 'connected', 'username', 'token status'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(exitCodeFromError(err))\n }\n })\n\n return brands\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createCarouselsCommand(): Command {\n const carousels = new Command('carousels').description('Manage carousels')\n\n // ap carousels list\n carousels\n .command('list')\n .description('List all carousels')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching carousels…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.carousels.list()\n spinner.stop()\n const rows = list.map((c) => ({\n id: c.id,\n title: c.title ?? '—',\n slides: c.slides.length,\n status: c.status,\n createdAt: c.createdAt,\n }))\n printer.table(rows, ['id', 'title', 'slides', 'status', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap carousels get <id>\n carousels\n .command('get <id>')\n .description('Get a carousel by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching carousel \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const carousel = await client.carousels.retrieve(id)\n spinner.stop()\n printer.log(carousel)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap carousels create [--title <title>]\n carousels\n .command('create')\n .description('Create a new carousel')\n .option('--title <title>', 'Carousel title')\n .action(async (opts: { title?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating carousel…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const carousel = await client.carousels.create(\n opts.title ? { title: opts.title } : undefined,\n )\n spinner.stop()\n printer.log(carousel)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap carousels generate --topic <topic> [--brand <slug>] [--slides <n>]\n carousels\n .command('generate')\n .description('AI-generate a carousel from a topic')\n .requiredOption('--topic <topic>', 'Topic to generate slides for')\n .option('--brand <slug>', 'Brand slug for brand voice')\n .option('--slides <n>', 'Number of slides to generate')\n .action(async (opts: { topic: string; brand?: string; slides?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Generating carousel…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const carousel = await client.carousels.generate({\n topic: opts.topic,\n ...(opts.brand ? { brandSlug: opts.brand } : {}),\n ...(opts.slides ? { slideCount: parseInt(opts.slides, 10) } : {}),\n })\n spinner.stop()\n printer.log(carousel)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap carousels draft <id>\n carousels\n .command('draft <id>')\n .description('Convert a carousel to a post draft')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Converting carousel \"${id}\" to draft…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.carousels.draft(id)\n spinner.stop()\n printer.log(result)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap carousels delete <id> --force\n carousels\n .command('delete <id>')\n .description('Delete a carousel (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a carousel. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting carousel \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.carousels.remove(id)\n spinner.stop()\n printer.log(`Carousel \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return carousels\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createClipsCommand(): Command {\n const clips = new Command('clips').description('Manage video clips')\n\n // ap clips list\n clips\n .command('list')\n .description('List all clips')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching clips…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.clips.list()\n spinner.stop()\n const rows = list.map((c) => ({\n id: c.id,\n name: c.name,\n status: c.status,\n duration: c.duration !== undefined ? `${c.duration}s` : '—',\n }))\n printer.table(rows, ['id', 'name', 'status', 'duration'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap clips get <id>\n clips\n .command('get <id>')\n .description('Get a clip by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching clip \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const clip = await client.clips.retrieve(id)\n spinner.stop()\n printer.log(clip)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap clips upload <file> [--name <name>]\n clips\n .command('upload <file>')\n .description('Upload a video file as a clip')\n .option('--name <name>', 'Override the clip name (defaults to filename)')\n .action(async (file: string, opts: { name?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Uploading clip…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const clip = await client.clips.upload(file, {\n name: opts.name,\n onProgress: (pct) => {\n if (pct > 0 && pct < 100) spinner.stop()\n },\n })\n spinner.stop()\n printer.log(clip)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap clips import --url <url> [--name <name>]\n clips\n .command('import')\n .description('Import a clip from a URL')\n .requiredOption('--url <url>', 'URL of the video to import')\n .option('--name <name>', 'Name for the imported clip')\n .action(async (opts: { url: string; name?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Importing clip…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const clip = await client.clips.importUrl({\n url: opts.url,\n ...(opts.name ? { name: opts.name } : {}),\n })\n spinner.stop()\n printer.log(clip)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap clips render <id>\n clips\n .command('render <id>')\n .description('Trigger rendering for a clip')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Rendering clip \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const clip = await client.clips.render(id)\n spinner.stop()\n printer.log(clip)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap clips delete <id> --force\n clips\n .command('delete <id>')\n .description('Delete a clip (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a clip. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting clip \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.clips.remove(id)\n spinner.stop()\n printer.log(`Clip \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return clips\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport type { Platform } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction parsePlatforms(raw: string): Platform[] {\n return raw.split(',').map((p) => p.trim() as Platform)\n}\n\n/**\n * Resolves the process exit code for a caught error.\n * Honours the `exitCode` property set by `resolveAuth` (exit 2 for auth errors)\n * before falling back to the SDK error class mapping.\n */\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createPostsCommand(): Command {\n const posts = new Command('posts').description('Manage posts')\n\n // ap posts list [--brand <slug>] [--status <status>] [--limit <n>] [--page <n>]\n posts\n .command('list')\n .description('List posts')\n .option('--brand <slug>', 'Filter by brand slug')\n .option('--status <status>', 'Filter by status (draft|scheduled|published|failed)')\n .option('--limit <n>', 'Max results per page', '20')\n .option('--page <n>', 'Page number', '1')\n .action(async (opts: { brand?: string; status?: string; limit: string; page: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching posts…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.posts.list({\n brandSlug: opts.brand,\n status: opts.status as 'draft' | 'scheduled' | 'published' | 'failed' | undefined,\n limit: parseInt(opts.limit, 10),\n page: parseInt(opts.page, 10),\n })\n spinner.stop()\n const rows = result.data.map((p) => ({\n id: p.id,\n brand: p.brandSlug,\n status: p.status,\n platforms: p.platforms.join(', '),\n text: p.text.length > 60 ? `${p.text.slice(0, 57)}…` : p.text,\n scheduledAt: p.scheduledAt ?? '—',\n }))\n printer.table(rows, ['id', 'brand', 'status', 'platforms', 'text', 'scheduledAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts get <id>\n posts\n .command('get <id>')\n .description('Get a post by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.getById(id)\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts create --brand <slug> --text <text> --platforms <x,linkedin,...>\n posts\n .command('create')\n .description('Create a new post')\n .requiredOption('--brand <slug>', 'Brand slug')\n .requiredOption('--text <text>', 'Post text content')\n .requiredOption('--platforms <list>', 'Comma-separated platforms (e.g. x,linkedin)')\n .option('--at <iso>', 'Schedule date/time (ISO 8601)')\n .action(\n async (\n opts: { brand: string; text: string; platforms: string; at?: string },\n cmd: Command,\n ) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating post…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.create({\n brandSlug: opts.brand,\n text: opts.text,\n platforms: parsePlatforms(opts.platforms),\n ...(opts.at ? { scheduledAt: opts.at } : {}),\n })\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap posts update <id> [--text <text>] [--platforms <list>] [--at <iso>]\n posts\n .command('update <id>')\n .description('Update a post')\n .option('--text <text>', 'New post text')\n .option('--platforms <list>', 'New comma-separated platforms')\n .option('--at <iso>', 'New scheduled date/time (ISO 8601)')\n .action(\n async (\n id: string,\n opts: { text?: string; platforms?: string; at?: string },\n cmd: Command,\n ) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Updating post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.update(id, {\n ...(opts.text ? { text: opts.text } : {}),\n ...(opts.platforms ? { platforms: parsePlatforms(opts.platforms) } : {}),\n ...(opts.at ? { scheduledAt: opts.at } : {}),\n })\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap posts delete <id> [--force]\n posts\n .command('delete <id>')\n .description('Delete a post (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a post. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.posts.remove(id)\n spinner.stop()\n printer.log(`Post \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts publish <id>\n posts\n .command('publish <id>')\n .description('Publish a post immediately')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Publishing post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.publish(id)\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts schedule <id> --at <iso-datetime>\n posts\n .command('schedule <id>')\n .description('Schedule a post for a specific time')\n .requiredOption('--at <iso>', 'ISO 8601 datetime to schedule the post')\n .action(async (id: string, opts: { at: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Scheduling post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.schedule(id, opts.at)\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts retry <id>\n posts\n .command('retry <id>')\n .description('Retry a failed post')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Retrying post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.retry(id)\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts rewrite <id>\n posts\n .command('rewrite <id>')\n .description('AI-rewrite a post')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Rewriting post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const post = await client.posts.rewrite(id)\n spinner.stop()\n printer.log(post)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap posts score <id>\n posts\n .command('score <id>')\n .description('Score a post with AI feedback')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Scoring post \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.posts.score(id)\n spinner.stop()\n printer.log(result)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return posts\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createKbCommand(): Command {\n const kb = new Command('kb').description('Manage knowledge bases')\n\n // ap kb list\n kb\n .command('list')\n .description('List all knowledge bases')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching knowledge bases…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.kb.list()\n spinner.stop()\n const rows = list.map((k) => ({\n id: k.id,\n name: k.name,\n docs: k.docCount ?? 0,\n createdAt: k.createdAt,\n }))\n printer.table(rows, ['id', 'name', 'docs', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb get <id>\n kb\n .command('get <id>')\n .description('Get a knowledge base by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching knowledge base \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.kb.retrieve(id)\n spinner.stop()\n printer.log(result)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb create --name <name>\n kb\n .command('create')\n .description('Create a new knowledge base')\n .requiredOption('--name <name>', 'Knowledge base name')\n .action(async (opts: { name: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating knowledge base…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.kb.create({ name: opts.name })\n spinner.stop()\n printer.log(result)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb delete <id> [--force]\n kb\n .command('delete <id>')\n .description('Delete a knowledge base (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a knowledge base. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting knowledge base \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.kb.remove(id)\n spinner.stop()\n printer.log(`Knowledge base \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb search <id> --query <text>\n kb\n .command('search <id>')\n .description('Search a knowledge base')\n .requiredOption('--query <text>', 'Search query')\n .action(async (id: string, opts: { query: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Searching knowledge base \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const results = await client.kb.search(id, opts.query)\n spinner.stop()\n const rows = results.map((r) => ({\n docId: r.docId,\n score: r.score.toFixed(3),\n content: r.content.length > 80 ? `${r.content.slice(0, 77)}…` : r.content,\n }))\n printer.table(rows, ['docId', 'score', 'content'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb ingest <id> --url <url>\n kb\n .command('ingest <id>')\n .description('Ingest a URL into a knowledge base')\n .requiredOption('--url <url>', 'URL to ingest')\n .action(async (id: string, opts: { url: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Ingesting URL into knowledge base \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const doc = await client.kb.ingestUrl(id, opts.url)\n spinner.stop()\n printer.log(doc)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap kb docs <id>\n kb\n .command('docs <id>')\n .description('List documents in a knowledge base')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching documents for knowledge base \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const docs = await client.kb.docs(id)\n spinner.stop()\n const rows = docs.map((d) => ({\n id: d.id,\n name: d.name,\n type: d.type,\n status: d.status,\n createdAt: d.createdAt,\n }))\n printer.table(rows, ['id', 'name', 'type', 'status', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return kb\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createIdeasCommand(): Command {\n const ideas = new Command('ideas').description('Manage content ideas')\n\n // ap ideas generate [--kb <id>] [--topic <text>] [--count <n>]\n ideas\n .command('generate')\n .description('Generate content ideas')\n .option('--kb <id>', 'Knowledge base ID to draw context from')\n .option('--topic <text>', 'Topic or theme for ideas')\n .option('--count <n>', 'Number of ideas to generate', '5')\n .action(async (opts: { kb?: string; topic?: string; count: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Generating ideas…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const result = await client.ideas.generate({\n ...(opts.kb ? { kbId: opts.kb } : {}),\n ...(opts.topic ? { topic: opts.topic } : {}),\n count: parseInt(opts.count, 10),\n })\n spinner.stop()\n const rows = result.map((i) => ({\n id: i.id,\n topic: i.topic ?? '—',\n enriched: i.enriched ? 'yes' : 'no',\n text: i.text.length > 80 ? `${i.text.slice(0, 77)}…` : i.text,\n }))\n printer.table(rows, ['id', 'topic', 'enriched', 'text'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap ideas list\n ideas\n .command('list')\n .description('List all ideas')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching ideas…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.ideas.list()\n spinner.stop()\n const rows = list.map((i) => ({\n id: i.id,\n topic: i.topic ?? '—',\n enriched: i.enriched ? 'yes' : 'no',\n text: i.text.length > 80 ? `${i.text.slice(0, 77)}…` : i.text,\n createdAt: i.createdAt,\n }))\n printer.table(rows, ['id', 'topic', 'enriched', 'text', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap ideas enrich <id>\n ideas\n .command('enrich <id>')\n .description('Enrich an idea with AI context')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Enriching idea \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const idea = await client.ideas.enrich(id)\n spinner.stop()\n printer.log(idea)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap ideas delete <id> [--force]\n ideas\n .command('delete <id>')\n .description('Delete an idea (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete an idea. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting idea \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.ideas.remove(id)\n spinner.stop()\n printer.log(`Idea \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return ideas\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createUsageCommand(): Command {\n const usage = new Command('usage').description('View usage statistics')\n\n // ap usage summary\n usage\n .command('summary')\n .description('Show usage summary for the current period')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching usage summary…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const summary = await client.usage.summary()\n spinner.stop()\n const rows = Object.entries(summary.platforms).map(([platform, stats]) => ({\n platform,\n posts: stats.posts,\n published: stats.published,\n failed: stats.failed,\n }))\n if (rows.length === 0) {\n printer.log(`No usage data for period: ${summary.period}`)\n } else {\n printer.log(`Period: ${summary.period}`)\n printer.table(rows, ['platform', 'posts', 'published', 'failed'])\n }\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return usage\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createWebhooksCommand(): Command {\n const webhooks = new Command('webhooks').description('Manage webhooks')\n\n // ap webhooks list\n webhooks\n .command('list')\n .description('List all webhooks')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching webhooks…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.webhooks.list()\n spinner.stop()\n const rows = list.map((w) => ({\n id: w.id,\n url: w.url,\n events: w.events.join(', '),\n active: w.active ? 'yes' : 'no',\n createdAt: w.createdAt,\n }))\n printer.table(rows, ['id', 'url', 'events', 'active', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap webhooks get <id>\n webhooks\n .command('get <id>')\n .description('Get a webhook by ID')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Fetching webhook \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const webhook = await client.webhooks.retrieve(id)\n spinner.stop()\n printer.log(webhook)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap webhooks create --url <url> --events <post.published,post.failed,...>\n webhooks\n .command('create')\n .description('Create a new webhook')\n .requiredOption('--url <url>', 'Endpoint URL to receive events')\n .requiredOption('--events <list>', 'Comma-separated event types (e.g. post.published,post.failed)')\n .option('--secret <secret>', 'Signing secret for HMAC verification')\n .action(\n async (opts: { url: string; events: string; secret?: string }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Creating webhook…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const webhook = await client.webhooks.create({\n url: opts.url,\n events: opts.events.split(',').map((e) => e.trim()),\n ...(opts.secret ? { secret: opts.secret } : {}),\n })\n spinner.stop()\n printer.log(webhook)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap webhooks update <id> [--url <url>] [--events <events>] [--active]\n webhooks\n .command('update <id>')\n .description('Update a webhook')\n .option('--url <url>', 'New endpoint URL')\n .option('--events <list>', 'New comma-separated event types')\n .option('--active', 'Set webhook as active')\n .option('--no-active', 'Set webhook as inactive')\n .action(\n async (\n id: string,\n opts: { url?: string; events?: string; active?: boolean },\n cmd: Command,\n ) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Updating webhook \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const webhook = await client.webhooks.update(id, {\n ...(opts.url ? { url: opts.url } : {}),\n ...(opts.events ? { events: opts.events.split(',').map((e) => e.trim()) } : {}),\n ...(opts.active !== undefined ? { active: opts.active } : {}),\n })\n spinner.stop()\n printer.log(webhook)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n },\n )\n\n // ap webhooks delete <id> --force\n webhooks\n .command('delete <id>')\n .description('Delete a webhook (requires --force)')\n .option('--force', 'Confirm deletion without interactive prompt')\n .action(async (id: string, opts: { force?: boolean }, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n if (!opts.force) {\n printer.error('--force is required to delete a webhook. Pass --force to confirm.')\n process.exit(1)\n }\n const spinner = printer.spinner(`Deleting webhook \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.webhooks.remove(id)\n spinner.stop()\n printer.log(`Webhook \"${id}\" deleted.`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap webhooks test <id>\n webhooks\n .command('test <id>')\n .description('Send a test event to a webhook')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Sending test event to webhook \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n await client.webhooks.test(id)\n spinner.stop()\n printer.log(`Test event sent to webhook \"${id}\".`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return webhooks\n}\n","import { Command } from 'commander'\nimport { Autoposting } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { createPrinter } from '../output/printer.js'\nimport { exitCodeFromError } from '../output/exit-codes.js'\n\ntype GlobalOpts = {\n apiKey?: string\n json?: boolean\n quiet?: boolean\n format?: 'table' | 'json'\n}\n\nfunction resolveExitCode(err: unknown): number {\n const attached = (err as { exitCode?: number }).exitCode\n if (typeof attached === 'number') return attached\n return exitCodeFromError(err)\n}\n\nexport function createWorkspacesCommand(): Command {\n const workspaces = new Command('workspaces').description('Manage workspaces')\n\n // ap workspaces list\n workspaces\n .command('list')\n .description('List all workspaces')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner('Fetching workspaces…')\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n const client = new Autoposting({ apiKey: cred.apiKey })\n const list = await client.workspaces.list()\n spinner.stop()\n const rows = list.map((w) => ({\n id: w.id,\n name: w.name,\n slug: w.slug,\n active: w.isActive ? 'yes' : 'no',\n createdAt: w.createdAt,\n }))\n printer.table(rows, ['id', 'name', 'slug', 'active', 'createdAt'])\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n // ap workspaces switch <id>\n workspaces\n .command('switch <id>')\n .description('Switch the active workspace (session auth only)')\n .action(async (id: string, _opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<GlobalOpts>()\n const printer = createPrinter(globals)\n const spinner = printer.spinner(`Switching to workspace \"${id}\"…`)\n try {\n const cred = resolveAuth({ apiKey: globals.apiKey })\n // Pass the auth source so the SDK can enforce the API key restriction.\n const authSource = cred.source === 'flag' || cred.source === 'env' || cred.source === 'stored'\n ? 'api-key'\n : 'session'\n const client = new Autoposting({ apiKey: cred.apiKey, authSource })\n await client.workspaces.switchWorkspace(id)\n spinner.stop()\n printer.log(`Switched to workspace \"${id}\".`)\n } catch (err) {\n spinner.stop()\n printer.error(err as Error)\n process.exit(resolveExitCode(err))\n }\n })\n\n return workspaces\n}\n","import { Command } from 'commander'\nimport { VERSION } from '@autoposting.ai/sdk'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { getCredentialsPath } from '../auth/credential-store.js'\nimport fs from 'node:fs'\n\nconst API_HEALTH_URL = 'https://app.autoposting.ai/api/health'\n\ntype CheckResult = {\n name: string\n status: 'pass' | 'fail' | 'warn'\n value: string\n}\n\nasync function runChecks(): Promise<CheckResult[]> {\n const results: CheckResult[] = []\n\n // CLI Version\n results.push({ name: 'CLI Version', status: 'pass', value: VERSION })\n\n // Node.js\n const nodeVersion = process.version\n const nodeMajor = parseInt(nodeVersion.slice(1), 10)\n results.push({\n name: 'Node.js',\n status: nodeMajor >= 20 ? 'pass' : 'fail',\n value: nodeVersion,\n })\n\n // Auth\n try {\n resolveAuth()\n results.push({ name: 'Auth', status: 'pass', value: 'authenticated' })\n } catch {\n results.push({ name: 'Auth', status: 'fail', value: 'not configured' })\n }\n\n // Credentials file permissions\n const credPath = getCredentialsPath()\n try {\n const stat = fs.statSync(credPath)\n const mode = stat.mode & 0o777\n const isSecure = mode === 0o600\n results.push({\n name: 'Credentials',\n status: isSecure ? 'pass' : 'warn',\n value: isSecure\n ? `${credPath} (0600)`\n : `${credPath} (mode ${mode.toString(8)} — expected 0600)`,\n })\n } catch {\n results.push({\n name: 'Credentials',\n status: 'warn',\n value: 'no credentials file found',\n })\n }\n\n // API health\n try {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort(), 5000)\n const res = await fetch(API_HEALTH_URL, { signal: controller.signal })\n clearTimeout(timeout)\n results.push({\n name: 'API',\n status: res.ok ? 'pass' : 'fail',\n value: `HTTP ${res.status}`,\n })\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n results.push({ name: 'API', status: 'fail', value: `unreachable: ${msg}` })\n }\n\n return results\n}\n\nexport function createDoctorCommand(): Command {\n const cmd = new Command('doctor')\n .description('Run diagnostic checks on your CLI setup')\n .option('--json', 'Output results as JSON')\n .action(async (_opts: Record<string, unknown>, cmd: Command) => {\n const globals = cmd.optsWithGlobals<{ json?: boolean }>()\n const results = await runChecks()\n\n if (globals.json) {\n console.log(JSON.stringify(results, null, 2))\n } else {\n for (const r of results) {\n const icon =\n r.status === 'pass' ? '✓' : r.status === 'warn' ? '!' : '✗'\n const label =\n r.status === 'pass' ? 'pass' : r.status === 'warn' ? 'warn' : 'FAIL'\n console.log(` ${icon} ${r.name.padEnd(16)} [${label}] ${r.value}`)\n }\n }\n\n const anyFail = results.some((r) => r.status === 'fail')\n if (anyFail) process.exit(1)\n })\n\n return cmd\n}\n","import { Command } from 'commander'\nimport { resolveAuth } from '../auth/auth-manager.js'\nimport { readCredentials } from '../auth/credential-store.js'\n\nexport function createWhoamiCommand(): Command {\n return new Command('whoami')\n .description('Show current authentication identity (alias for `auth whoami`)')\n .action((_opts: Record<string, unknown>, cmd: Command) => {\n try {\n const globals = cmd.optsWithGlobals<{ apiKey?: string; json?: boolean }>()\n const cred = resolveAuth({ apiKey: globals.apiKey })\n\n const masked = `${cred.apiKey.slice(0, 8)}${'*'.repeat(Math.max(0, cred.apiKey.length - 8))}`\n\n if (globals.json) {\n const out: Record<string, string> = { source: cred.source, apiKey: masked }\n if (cred.source === 'stored') {\n const creds = readCredentials()\n const profileName = creds?.activeProfile ?? 'unknown'\n const profile = creds?.profiles[profileName]\n out.profile = profileName\n if (profile?.workspace) out.workspace = profile.workspace\n if (profile?.email) out.email = profile.email\n }\n console.log(JSON.stringify(out, null, 2))\n return\n }\n\n console.log(`Source: ${cred.source}`)\n if (cred.source === 'stored') {\n const creds = readCredentials()\n const profileName = creds?.activeProfile ?? 'unknown'\n const profile = creds?.profiles[profileName]\n console.log(`Profile: ${profileName}`)\n if (profile?.workspace) console.log(`Workspace: ${profile.workspace}`)\n if (profile?.email) console.log(`Email: ${profile.email}`)\n }\n console.log(`API key: ${masked}`)\n } catch (err) {\n console.error(`Error: ${(err as Error).message}`)\n process.exit(2)\n }\n })\n}\n","import { Command } from 'commander'\nimport open from 'open'\n\nconst URLS: Record<string, string> = {\n '': 'https://app.autoposting.ai',\n posts: 'https://app.autoposting.ai/posts',\n brands: 'https://app.autoposting.ai/brands',\n agents: 'https://app.autoposting.ai/agents',\n settings: 'https://app.autoposting.ai/settings',\n billing: 'https://app.autoposting.ai/settings/billing',\n}\n\nconst VALID_SECTIONS = Object.keys(URLS).filter((k) => k !== '')\n\nexport function createOpenCommand(): Command {\n return new Command('open')\n .description(`Open the Autoposting dashboard in your browser. Sections: ${VALID_SECTIONS.join(', ')}`)\n .argument('[section]', `Dashboard section to open (${VALID_SECTIONS.join('|')})`, '')\n .option('--no-browser', 'Print URL only, do not open browser')\n .action(async (section: string, opts: { browser: boolean }) => {\n const key = section ?? ''\n if (!(key in URLS)) {\n console.error(`Error: unknown section \"${key}\". Valid sections: ${VALID_SECTIONS.join(', ')}`)\n process.exit(1)\n }\n\n const url = URLS[key]\n\n if (!opts.browser) {\n console.log(url)\n return\n }\n\n console.log(`Opening ${url}`)\n try {\n await open(url)\n } catch (err) {\n console.error(`Error: failed to open browser — ${(err as Error).message}`)\n console.log(`Visit manually: ${url}`)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\nimport { VERSION } from '@autoposting.ai/sdk'\nimport { execSync } from 'node:child_process'\n\nconst REGISTRY_URL = 'https://registry.npmjs.org/@autoposting.ai%2fcli/latest'\n\nexport function createUpdateCommand(): Command {\n return new Command('update')\n .description(\n 'Check for a newer version of the CLI and optionally install it',\n )\n .option('--yes', 'Install the latest version without prompting')\n .action(async (opts: { yes?: boolean }) => {\n let latest: string\n try {\n const controller = new AbortController()\n const timeout = setTimeout(() => controller.abort(), 8000)\n const res = await fetch(REGISTRY_URL, { signal: controller.signal })\n clearTimeout(timeout)\n if (!res.ok) {\n console.error(`Error: registry returned HTTP ${res.status}`)\n process.exit(1)\n }\n const data = (await res.json()) as { version: string }\n latest = data.version\n } catch (err) {\n console.error(\n `Error: could not reach npm registry — ${(err as Error).message}`,\n )\n process.exit(1)\n }\n\n if (latest === VERSION) {\n console.log(`You are already on the latest version (${VERSION}).`)\n return\n }\n\n console.log(`Current version: ${VERSION}`)\n console.log(`Latest version: ${latest}`)\n\n if (!opts.yes) {\n console.log(`Run \\`ap update --yes\\` to install v${latest}.`)\n return\n }\n\n console.log(`Installing @autoposting.ai/cli@${latest}…`)\n try {\n execSync(`npm install -g @autoposting.ai/cli@${latest}`, {\n stdio: 'inherit',\n })\n console.log(`Updated to v${latest}.`)\n } catch (err) {\n console.error(`Error: install failed — ${(err as Error).message}`)\n process.exit(1)\n }\n })\n}\n","import { Command } from 'commander'\n\nconst ALL_COMMANDS = [\n 'posts',\n 'brands',\n 'agents',\n 'kb',\n 'ideas',\n 'clips',\n 'carousels',\n 'webhooks',\n 'billing',\n 'usage',\n 'workspaces',\n 'auth',\n 'doctor',\n 'whoami',\n 'open',\n 'update',\n 'completion',\n]\n\nconst SHELLS = ['bash', 'zsh', 'fish', 'pwsh'] as const\ntype Shell = (typeof SHELLS)[number]\n\nconst TEMPLATES: Record<Shell, (cmds: string[]) => string> = {\n bash: (cmds) => `# bash completion for ap / autoposting\n# Add to ~/.bashrc or ~/.bash_profile:\n# source <(ap completion bash)\n_ap_completions() {\n local cur=\"\\${COMP_WORDS[COMP_CWORD]}\"\n local commands=\"${cmds.join(' ')}\"\n COMPREPLY=( $(compgen -W \"$commands\" -- \"$cur\") )\n}\ncomplete -F _ap_completions ap\ncomplete -F _ap_completions autoposting\n`,\n\n zsh: (cmds) => `# zsh completion for ap / autoposting\n# Add to ~/.zshrc:\n# source <(ap completion zsh)\n# Or append directly:\n# ap completion zsh >> ~/.zshrc\n_ap() {\n compadd ${cmds.join(' ')}\n}\ncompdef _ap ap autoposting\n`,\n\n fish: (cmds) => `# fish completion for ap / autoposting\n# Save to ~/.config/fish/completions/ap.fish or run:\n# ap completion fish | source\n${cmds.map((c) => `complete -c ap -f -a '${c}'`).join('\\n')}\n${cmds.map((c) => `complete -c autoposting -f -a '${c}'`).join('\\n')}\n`,\n\n pwsh: (cmds) => `# PowerShell completion for ap / autoposting\n# Add to your $PROFILE:\n# ap completion pwsh | Invoke-Expression\nRegister-ArgumentCompleter -Native -CommandName @('ap', 'autoposting') -ScriptBlock {\n param($wordToComplete, $commandAst, $cursorPosition)\n $commands = @(${cmds.map((c) => `'${c}'`).join(', ')})\n $commands | Where-Object { $_ -like \"$wordToComplete*\" } | ForEach-Object {\n [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)\n }\n}\n`,\n}\n\nexport function createCompletionCommand(): Command {\n return new Command('completion')\n .description(`Generate shell completion script. Shells: ${SHELLS.join(', ')}`)\n .argument('<shell>', `Shell type (${SHELLS.join('|')})`)\n .action((shell: string) => {\n if (!SHELLS.includes(shell as Shell)) {\n console.error(`Error: unsupported shell \"${shell}\". Supported: ${SHELLS.join(', ')}`)\n process.exit(1)\n }\n process.stdout.write(TEMPLATES[shell as Shell](ALL_COMMANDS))\n })\n}\n","import { Command } from 'commander'\n\nexport function createMcpCommand(): Command {\n return new Command('mcp')\n .description('Start MCP stdio server for AI agent integration')\n .action(async () => {\n const { startMcpServer } = await import('../mcp/server.js')\n await startMcpServer()\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACyBO,SAAS,YACd,QACA,MACkB;AAClB,QAAM,UAAU,KAAK,SAAS;AAC9B,QAAM,OAAO,KAAK,QAAQ;AAE1B,MAAI,WAAW,IAAK,QAAO,IAAI,oBAAoB,SAAS,QAAQ,IAAI;AACxE,MAAI,WAAW,IAAK,QAAO,IAAI,WAAW,SAAS,QAAQ,IAAI;AAC/D,MAAI,WAAW,IAAK,QAAO,IAAI,cAAc,SAAS,QAAQ,IAAI;AAClE,MAAI,WAAW,OAAO,WAAW,IAAK,QAAO,IAAI,gBAAgB,SAAS,QAAQ,IAAI;AACtF,MAAI,WAAW,IAAK,QAAO,IAAI,eAAe,SAAS,QAAQ,IAAI;AACnE,MAAI,UAAU,IAAK,QAAO,IAAI,YAAY,SAAS,QAAQ,IAAI;AAE/D,SAAO,IAAI,iBAAiB,SAAS,QAAQ,IAAI;AACnD;IDxCa,SCAA,kBAcA,qBACA,YACA,eACA,iBAEA,gBAIA,aCrBS,UCCT,gBCAA,iBCAA,gBCAA,mBCAA,eCKA,eCLA,YCAA,eCAA,eCAA,kBCCA,oBCqBA;;;;AdzBN,IAAM,UAAU;ACAhB,IAAM,mBAAN,cAA+B,MAAM;MA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;AACtC,QAAQ,WAAW,oBAAoB,CAAC;AACxC,QAAQ,WAAW,wBAAwB,CAAC;AAC5C,QAAQ,WAAW,iBAAiB,CAAC;AAErC,QAAQ,MAAM;","names":["path","fs","parsePlatforms","import_commander","path","os","fs","import_commander","import_commander","resolveExitCode","import_commander","import_commander","resolveExitCode","import_commander","resolveExitCode","import_commander","resolveExitCode","import_commander","resolveExitCode","import_commander","resolveExitCode","import_commander","resolveExitCode","import_commander","resolveExitCode","import_commander","resolveExitCode","import_commander","import_node_fs","fs","cmd","import_commander","import_commander","open","import_commander","import_node_child_process","import_commander","import_commander","startMcpServer"]}