@posthog/agent 1.0.1 → 1.1.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/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/src/agent-registry.d.ts +1 -1
- package/dist/src/agent-registry.d.ts.map +1 -1
- package/dist/src/agent-registry.js +4 -2
- package/dist/src/agent-registry.js.map +1 -1
- package/dist/src/agent.d.ts +6 -6
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +18 -17
- package/dist/src/agent.js.map +1 -1
- package/dist/src/agents/execution.js +4 -2
- package/dist/src/agents/execution.js.map +1 -1
- package/dist/src/agents/planning.js +4 -2
- package/dist/src/agents/planning.js.map +1 -1
- package/dist/src/event-transformer.js +4 -2
- package/dist/src/event-transformer.js.map +1 -1
- package/dist/src/file-manager.d.ts +2 -2
- package/dist/src/file-manager.d.ts.map +1 -1
- package/dist/src/file-manager.js +18 -15
- package/dist/src/file-manager.js.map +1 -1
- package/dist/src/git-manager.d.ts +1 -1
- package/dist/src/git-manager.d.ts.map +1 -1
- package/dist/src/git-manager.js +6 -3
- package/dist/src/git-manager.js.map +1 -1
- package/dist/src/posthog-api.d.ts +2 -2
- package/dist/src/posthog-api.d.ts.map +1 -1
- package/dist/src/posthog-api.js +4 -2
- package/dist/src/posthog-api.js.map +1 -1
- package/dist/src/prompt-builder.d.ts +3 -3
- package/dist/src/prompt-builder.d.ts.map +1 -1
- package/dist/src/prompt-builder.js +6 -3
- package/dist/src/prompt-builder.js.map +1 -1
- package/dist/src/stage-executor.d.ts +5 -5
- package/dist/src/stage-executor.d.ts.map +1 -1
- package/dist/src/stage-executor.js +11 -9
- package/dist/src/stage-executor.js.map +1 -1
- package/dist/src/task-manager.js +5 -2
- package/dist/src/task-manager.js.map +1 -1
- package/dist/src/template-manager.d.ts.map +1 -1
- package/dist/src/template-manager.js +16 -6
- package/dist/src/template-manager.js.map +1 -1
- package/dist/src/types.js +4 -2
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/logger.js +5 -3
- package/dist/src/utils/logger.js.map +1 -1
- package/dist/src/utils/mcp.js +4 -2
- package/dist/src/utils/mcp.js.map +1 -1
- package/dist/src/workflow-registry.d.ts +2 -2
- package/dist/src/workflow-registry.d.ts.map +1 -1
- package/dist/src/workflow-registry.js +4 -3
- package/dist/src/workflow-registry.js.map +1 -1
- package/dist/src/workflow-types.d.ts +1 -1
- package/dist/src/workflow-types.d.ts.map +1 -1
- package/dist/templates/plan-template.md +45 -0
- package/package.json +8 -2
- package/src/agent-registry.ts +1 -2
- package/src/agent.ts +19 -19
- package/src/file-manager.ts +3 -3
- package/src/git-manager.ts +2 -2
- package/src/posthog-api.ts +3 -3
- package/src/prompt-builder.ts +3 -4
- package/src/stage-executor.ts +9 -10
- package/src/template-manager.ts +11 -3
- package/src/workflow-registry.ts +2 -3
- package/src/workflow-types.ts +1 -2
- package/dist/example.js +0 -49
- package/dist/example.js.map +0 -1
- package/dist/src/workflow-types.js +0 -2
- package/dist/src/workflow-types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-manager.js","sourceRoot":"","sources":["../../src/git-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;AAelC,MAAM,OAAO,UAAU;IACb,cAAc,CAAS;IACvB,UAAU,CAAU;IACpB,WAAW,CAAU;IACrB,MAAM,CAAS;IAEvB,YAAY,MAAiB;QAC3B,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAA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,wBAAwB,KAAK,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"git-manager.js","sources":["../../src/git-manager.ts"],"sourcesContent":["import { exec } from 'child_process';\nimport { promisify } from 'util';\nimport { Logger } from './utils/logger.js';\n\nconst execAsync = promisify(exec);\n\nexport interface GitConfig {\n repositoryPath: string;\n authorName?: string;\n authorEmail?: string;\n logger?: Logger;\n}\n\nexport interface BranchInfo {\n name: string;\n exists: boolean;\n isCurrentBranch: boolean;\n}\n\nexport class GitManager {\n private repositoryPath: string;\n private authorName?: string;\n private authorEmail?: string;\n private logger: Logger;\n\n constructor(config: GitConfig) {\n this.repositoryPath = config.repositoryPath;\n this.authorName = config.authorName;\n this.authorEmail = config.authorEmail;\n this.logger = config.logger || new Logger({ debug: false, prefix: '[GitManager]' });\n }\n\n private async runGitCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && git ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Git command failed: ${command}\\n${error}`);\n }\n }\n\n private async runCommand(command: string): Promise<string> {\n try {\n const { stdout } = await execAsync(`cd \"${this.repositoryPath}\" && ${command}`);\n return stdout.trim();\n } catch (error) {\n throw new Error(`Command failed: ${command}\\n${error}`);\n }\n }\n\n async isGitRepository(): Promise<boolean> {\n try {\n await this.runGitCommand('rev-parse --git-dir');\n return true;\n } catch {\n return false;\n }\n }\n\n async getCurrentBranch(): Promise<string> {\n return await this.runGitCommand('branch --show-current');\n }\n\n async getDefaultBranch(): Promise<string> {\n try {\n // Try to get the default branch from remote\n const remoteBranch = await this.runGitCommand('symbolic-ref refs/remotes/origin/HEAD');\n return remoteBranch.replace('refs/remotes/origin/', '');\n } catch {\n // Fallback: check if main exists, otherwise use master\n if (await this.branchExists('main')) {\n return 'main';\n } else if (await this.branchExists('master')) {\n return 'master';\n } else {\n throw new Error('Cannot determine default branch. No main or master branch found.');\n }\n }\n }\n\n async branchExists(branchName: string): Promise<boolean> {\n try {\n await this.runGitCommand(`rev-parse --verify ${branchName}`);\n return true;\n } catch {\n return false;\n }\n }\n\n async createBranch(branchName: string, baseBranch?: string): Promise<void> {\n const base = baseBranch || await this.getCurrentBranch();\n await this.runGitCommand(`checkout -b ${branchName} ${base}`);\n }\n\n async switchToBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`checkout ${branchName}`);\n }\n\n async createOrSwitchToBranch(branchName: string, baseBranch?: string): Promise<void> {\n const exists = await this.branchExists(branchName);\n if (exists) {\n await this.switchToBranch(branchName);\n } else {\n await this.createBranch(branchName, baseBranch);\n }\n }\n\n async addFiles(paths: string[]): Promise<void> {\n const pathList = paths.map(p => `\"${p}\"`).join(' ');\n await this.runGitCommand(`add ${pathList}`);\n }\n\n async addAllPostHogFiles(): Promise<void> {\n await this.runGitCommand('add .posthog/');\n }\n\n async commitChanges(message: string, options?: {\n authorName?: string;\n authorEmail?: string;\n }): Promise<string> {\n let command = 'commit -m \"' + message.replace(/\"/g, '\\\\\"') + '\"';\n\n const authorName = options?.authorName || this.authorName;\n const authorEmail = options?.authorEmail || this.authorEmail;\n\n if (authorName && authorEmail) {\n command += ` --author=\"${authorName} <${authorEmail}>\"`;\n }\n\n return await this.runGitCommand(command);\n }\n\n async hasChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('status --porcelain');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async hasStagedChanges(): Promise<boolean> {\n try {\n const status = await this.runGitCommand('diff --cached --name-only');\n return status.length > 0;\n } catch {\n return false;\n }\n }\n\n async getRemoteUrl(): Promise<string | null> {\n try {\n return await this.runGitCommand('remote get-url origin');\n } catch {\n return null;\n }\n }\n\n async pushBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '--force' : '';\n await this.runGitCommand(`push ${forceFlag} -u origin ${branchName}`);\n }\n\n // Utility methods for PostHog task workflow\n async createTaskPlanningBranch(taskId: string, baseBranch?: string): Promise<string> {\n let branchName = `posthog/task-${taskId}-planning`;\n let counter = 1;\n\n // Find a unique branch name if the base name already exists\n while (await this.branchExists(branchName)) {\n branchName = `posthog/task-${taskId}-planning-${counter}`;\n counter++;\n }\n\n this.logger.debug('Creating unique planning branch', { branchName, taskId });\n\n // If no base branch specified, ensure we're on main/master\n if (!baseBranch) {\n baseBranch = await this.getDefaultBranch();\n await this.switchToBranch(baseBranch);\n\n // Check for uncommitted changes\n if (await this.hasChanges()) {\n throw new Error(`Uncommitted changes detected. Please commit or stash changes before running tasks.`);\n }\n }\n\n await this.createBranch(branchName, baseBranch); // Use createBranch instead of createOrSwitchToBranch for new branches\n return branchName;\n }\n\n async createTaskImplementationBranch(taskId: string, planningBranchName?: string): Promise<string> {\n let branchName = `posthog/task-${taskId}-implementation`;\n let counter = 1;\n\n // Find a unique branch name if the base name already exists\n while (await this.branchExists(branchName)) {\n branchName = `posthog/task-${taskId}-implementation-${counter}`;\n counter++;\n }\n\n const currentBranchBefore = await this.getCurrentBranch();\n this.logger.debug('Creating unique implementation branch', {\n branchName,\n taskId,\n currentBranch: currentBranchBefore\n });\n\n // Implementation branch should branch from the specific planning branch\n let baseBranch = planningBranchName;\n\n if (!baseBranch) {\n // Try to find the corresponding planning branch\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch.includes('-planning')) {\n baseBranch = currentBranch; // Use current planning branch\n this.logger.debug('Using current planning branch', { baseBranch });\n } else {\n // Fallback to default branch\n baseBranch = await this.getDefaultBranch();\n this.logger.debug('No planning branch found, using default', { baseBranch });\n await this.switchToBranch(baseBranch);\n }\n }\n\n this.logger.debug('Creating implementation branch from base', { baseBranch, branchName });\n await this.createBranch(branchName, baseBranch); // Create fresh branch from base\n\n const currentBranchAfter = await this.getCurrentBranch();\n this.logger.info('Implementation branch created', {\n branchName,\n currentBranch: currentBranchAfter\n });\n\n return branchName;\n }\n\n async commitPlan(taskId: string, taskTitle: string): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n this.logger.debug('Committing plan', { taskId, currentBranch });\n\n await this.addAllPostHogFiles();\n\n const hasChanges = await this.hasStagedChanges();\n this.logger.debug('Checking for staged changes', { hasChanges });\n\n if (!hasChanges) {\n this.logger.info('No plan changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n const message = `📋 Add plan for task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent\n\nThis commit contains the implementation plan and supporting documentation\nfor the task. Review the plan before proceeding with implementation.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Plan committed', { taskId, taskTitle });\n return result;\n }\n\n async commitImplementation(taskId: string, taskTitle: string, planSummary?: string): Promise<string> {\n await this.runGitCommand('add .');\n\n const hasChanges = await this.hasStagedChanges();\n if (!hasChanges) {\n this.logger.warn('No implementation changes to commit', { taskId });\n return 'No changes to commit';\n }\n\n let message = `✨ Implement task: ${taskTitle}\n\nTask ID: ${taskId}\nGenerated by PostHog Agent`;\n\n if (planSummary) {\n message += `\\n\\nPlan Summary:\\n${planSummary}`;\n }\n\n message += `\\n\\nThis commit implements the changes described in the task plan.`;\n\n const result = await this.commitChanges(message);\n this.logger.info('Implementation committed', { taskId, taskTitle });\n return result;\n }\n\n async deleteBranch(branchName: string, force: boolean = false): Promise<void> {\n const forceFlag = force ? '-D' : '-d';\n await this.runGitCommand(`branch ${forceFlag} ${branchName}`);\n }\n\n async deleteRemoteBranch(branchName: string): Promise<void> {\n await this.runGitCommand(`push origin --delete ${branchName}`);\n }\n\n async getBranchInfo(branchName: string): Promise<BranchInfo> {\n const exists = await this.branchExists(branchName);\n const currentBranch = await this.getCurrentBranch();\n\n return {\n name: branchName,\n exists,\n isCurrentBranch: branchName === currentBranch\n };\n }\n\n async getCommitSha(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`rev-parse ${ref}`);\n }\n\n async getCommitMessage(ref: string = 'HEAD'): Promise<string> {\n return await this.runGitCommand(`log -1 --pretty=%B ${ref}`);\n }\n\n async createPullRequest(\n branchName: string,\n title: string,\n body: string,\n baseBranch?: string\n ): Promise<string> {\n const currentBranch = await this.getCurrentBranch();\n if (currentBranch !== branchName) {\n await this.switchToBranch(branchName);\n }\n\n await this.pushBranch(branchName);\n\n let command = `gh pr create --title \"${title.replace(/\"/g, '\\\\\"')}\" --body \"${body.replace(/\"/g, '\\\\\"')}\"`;\n\n if (baseBranch) {\n command += ` --base ${baseBranch}`;\n }\n\n try {\n const prUrl = await this.runCommand(command);\n return prUrl.trim();\n } catch (error) {\n throw new Error(`Failed to create PR: ${error}`);\n }\n }\n}\n"],"names":[],"mappings":";;;;AAIA,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC;MAepB,UAAU,CAAA;AACb,IAAA,cAAc;AACd,IAAA,UAAU;AACV,IAAA,WAAW;AACX,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,MAAiB,EAAA;AAC3B,QAAA,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc;AAC3C,QAAA,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU;AACnC,QAAA,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACrF;IAEQ,MAAM,aAAa,CAAC,OAAe,EAAA;AACzC,QAAA,IAAI;AACF,YAAA,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,CAAA,IAAA,EAAO,IAAI,CAAC,cAAc,CAAA,SAAA,EAAY,OAAO,CAAA,CAAE,CAAC;AACnF,YAAA,OAAO,MAAM,CAAC,IAAI,EAAE;QACtB;QAAE,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,CAAA,oBAAA,EAAuB,OAAO,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAC;QAC7D;IACF;IAEQ,MAAM,UAAU,CAAC,OAAe,EAAA;AACtC,Q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AC,CAAA,UAAA,EAAa,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA,CAAA,CAAG;QAE1G,IAAI,UAAU,EAAE;AACd,YAAA,OAAO,IAAI,CAAA,QAAA,EAAW,UAAU,CAAA,CAAE;QACpC;AAEA,QAAA,IAAI;YACF,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;AAC5C,YAAA,OAAO,KAAK,CAAC,IAAI,EAAE;QACrB;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,CAAA,CAAE,CAAC;QAClD;IACF;AACD;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Task, PostHogAPIConfig } from './types';
|
|
2
|
-
import type { WorkflowDefinition, AgentDefinition } from './workflow-types';
|
|
1
|
+
import type { Task, PostHogAPIConfig } from './types.js';
|
|
2
|
+
import type { WorkflowDefinition, AgentDefinition } from './workflow-types.js';
|
|
3
3
|
interface TaskProgressResponse {
|
|
4
4
|
has_progress: boolean;
|
|
5
5
|
id?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-api.d.ts","sourceRoot":"","sources":["../../src/posthog-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAkB,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"posthog-api.d.ts","sourceRoot":"","sources":["../../src/posthog-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAkB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAS/E,UAAU,oBAAoB;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,WAAW,G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GAAG,OAAO,CAAC,oBAAoB,CAAC;IAM9D,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAK9D,aAAa,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAO9C,UAAU,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAIxC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAOxG"}
|
package/dist/src/posthog-api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
class PostHogAPIClient {
|
|
2
2
|
config;
|
|
3
3
|
_teamId = null;
|
|
4
4
|
constructor(config) {
|
|
@@ -107,4 +107,6 @@ export class PostHogAPIClient {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
|
|
111
|
+
export { PostHogAPIClient };
|
|
112
|
+
//# sourceMappingURL=posthog-api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog-api.js","
|
|
1
|
+
{"version":3,"file":"posthog-api.js","sources":["../../src/posthog-api.ts"],"sourcesContent":["import type { Task, SupportingFile, PostHogAPIConfig } from './types.js';\nimport type { WorkflowDefinition, AgentDefinition } from './workflow-types.js';\n\ninterface PostHogApiResponse<T> {\n results?: T[];\n count?: number;\n next?: string | null;\n previous?: string | null;\n}\n\ninterface TaskProgressResponse {\n has_progress: boolean;\n id?: string;\n status?: \"started\" | \"in_progress\" | \"completed\" | \"failed\";\n current_step?: string;\n completed_steps?: number;\n total_steps?: number;\n progress_percentage?: number;\n output_log?: string;\n error_message?: string;\n created_at?: string;\n updated_at?: string;\n completed_at?: string;\n workflow_id?: string;\n workflow_run_id?: string;\n message?: string;\n}\n\nexport class PostHogAPIClient {\n private config: PostHogAPIConfig;\n private _teamId: number | null = null;\n\n constructor(config: PostHogAPIConfig) {\n this.config = config;\n }\n\n private get baseUrl(): string {\n const host = this.config.apiUrl.endsWith(\"/\") \n ? this.config.apiUrl.slice(0, -1) \n : this.config.apiUrl;\n return host;\n }\n\n private get headers(): Record<string, string> {\n return {\n 'Authorization': `Bearer ${this.config.apiKey}`,\n 'Content-Type': 'application/json',\n };\n }\n\n private async apiRequest<T>(\n endpoint: string, \n options: RequestInit = {}\n ): Promise<T> {\n const url = `${this.baseUrl}${endpoint}`;\n \n const response = await fetch(url, {\n ...options,\n headers: {\n ...this.headers,\n ...options.headers,\n },\n });\n\n if (!response.ok) {\n let errorMessage: string;\n try {\n const errorResponse = await response.json();\n errorMessage = `Failed request: [${response.status}] ${JSON.stringify(errorResponse)}`;\n } catch {\n errorMessage = `Failed request: [${response.status}] ${response.statusText}`;\n }\n throw new Error(errorMessage);\n }\n\n return response.json();\n }\n\n private async getTeamId(): Promise<number> {\n if (this._teamId !== null) {\n return this._teamId;\n }\n\n // Fetch user info to get team ID (following Array's pattern)\n const userResponse = await this.apiRequest<any>('/api/users/@me/');\n \n if (!userResponse.team?.id) {\n throw new Error('No team found for user');\n }\n\n const teamId = Number(userResponse.team.id);\n this._teamId = teamId;\n return teamId;\n }\n\n async fetchTask(taskId: string): Promise<Task> {\n const teamId = await this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`);\n }\n\n async listTasks(filters?: {\n repository?: string;\n organization?: string;\n origin_product?: string;\n workflow?: string;\n current_stage?: string;\n }): Promise<Task[]> {\n const teamId = await this.getTeamId();\n const url = new URL(`${this.baseUrl}/api/projects/${teamId}/tasks/`);\n \n if (filters) {\n Object.entries(filters).forEach(([key, value]) => {\n if (value) url.searchParams.append(key, value);\n });\n }\n\n const response = await this.apiRequest<PostHogApiResponse<Task>>(\n url.pathname + url.search\n );\n \n return response.results || [];\n }\n\n async updateTask(taskId: string, updates: Partial<Task>): Promise<Task> {\n const teamId = await this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/`, {\n method: 'PATCH',\n body: JSON.stringify(updates),\n });\n }\n\n async updateTaskStage(taskId: string, stageId: string): Promise<Task> {\n const teamId = await this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/update_stage/`, {\n method: 'PATCH',\n body: JSON.stringify({ current_stage: stageId }),\n });\n }\n\n async getTaskProgress(taskId: string): Promise<TaskProgressResponse> {\n const teamId = await this.getTeamId();\n return this.apiRequest<TaskProgressResponse>(`/api/projects/${teamId}/tasks/${taskId}/progress/`);\n }\n\n // Workflow endpoints\n async fetchWorkflow(workflowId: string): Promise<WorkflowDefinition> {\n const teamId = await this.getTeamId();\n return this.apiRequest<WorkflowDefinition>(`/api/projects/${teamId}/task_workflows/${workflowId}/`);\n }\n\n async listWorkflows(): Promise<WorkflowDefinition[]> {\n const teamId = await this.getTeamId();\n const response = await this.apiRequest<PostHogApiResponse<WorkflowDefinition>>(`/api/projects/${teamId}/task_workflows/`);\n return response.results || [];\n }\n\n // Agent catalog exposure\n async listAgents(): Promise<AgentDefinition[]> {\n return this.apiRequest<AgentDefinition[]>(`/api/agents/`);\n }\n\n async progressTask(taskId: string, options?: { next_stage_id?: string; auto?: boolean }): Promise<Task> {\n const teamId = await this.getTeamId();\n return this.apiRequest<Task>(`/api/projects/${teamId}/tasks/${taskId}/progress_task/`, {\n method: 'POST',\n body: JSON.stringify(options || {}),\n });\n }\n}\n"],"names":[],"mappings":"MA4Ba,gBAAgB,CAAA;AACnB,IAAA,MAAM;IACN,OAAO,GAAkB,IAAI;AAErC,IAAA,WAAA,CAAY,MAAwB,EAAA;AAClC,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;AAEA,IAAA,IAAY,OAAO,GAAA;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG;AAC1C,cAAE,IAAI,CAA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IAAI,CAAC,UAAU,CAAyC,CAAA,cAAA,EAAiB,MAAM,CAAA,gBAAA,CAAkB,CAAC;AACzH,QAAA,OAAO,QAAQ,CAAC,OAAO,IAAI,EAAE;IAC/B;;AAGA,IAAA,MAAM,UAAU,GAAA;AACd,QAAA,OAAO,IAAI,CAAC,UAAU,CAAoB,CAAA,YAAA,CAAc,CAAC;IAC3D;AAEA,IAAA,MAAM,YAAY,CAAC,MAAc,EAAE,OAAoD,EAAA;AACrF,QAAA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE;QACrC,OAAO,IAAI,CAAC,UAAU,CAAO,iBAAiB,MAAM,CAAA,OAAA,EAAU,MAAM,CAAA,eAAA,CAAiB,EAAE;AACrF,YAAA,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,IAAI,EAAE,CAAC;AACpC,SAAA,CAAC;IACJ;AACD;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Task } from './types';
|
|
2
|
-
import type { TemplateVariables } from './template-manager';
|
|
3
|
-
import { Logger } from './utils/logger';
|
|
1
|
+
import type { Task } from './types.js';
|
|
2
|
+
import type { TemplateVariables } from './template-manager.js';
|
|
3
|
+
import { Logger } from './utils/logger.js';
|
|
4
4
|
export interface PromptBuilderDeps {
|
|
5
5
|
getTaskFiles: (taskId: string) => Promise<any[]>;
|
|
6
6
|
generatePlanTemplate: (vars: TemplateVariables) => Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"prompt-builder.d.ts","sourceRoot":"","sources":["../../src/prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACjD,oBAAoB,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,YAAY,CAAoC;IACxD,OAAO,CAAC,oBAAoB,CAA4C;IACxE,OAAO,CAAC,MAAM,CAAS;gBAEX,IAAI,EAAE,iBAAiB;IAM7B,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAoChD,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;CAgCxD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Logger } from './utils/logger';
|
|
2
|
-
|
|
1
|
+
import { Logger } from './utils/logger.js';
|
|
2
|
+
|
|
3
|
+
class PromptBuilder {
|
|
3
4
|
getTaskFiles;
|
|
4
5
|
generatePlanTemplate;
|
|
5
6
|
logger;
|
|
@@ -72,4 +73,6 @@ export class PromptBuilder {
|
|
|
72
73
|
return prompt;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
|
|
77
|
+
export { PromptBuilder };
|
|
78
|
+
//# sourceMappingURL=prompt-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-builder.js","
|
|
1
|
+
{"version":3,"file":"prompt-builder.js","sources":["../../src/prompt-builder.ts"],"sourcesContent":["import type { Task } from './types.js';\nimport type { TemplateVariables } from './template-manager.js';\nimport { Logger } from './utils/logger.js';\n\nexport interface PromptBuilderDeps {\n getTaskFiles: (taskId: string) => Promise<any[]>;\n generatePlanTemplate: (vars: TemplateVariables) => Promise<string>;\n logger?: Logger;\n}\n\nexport class PromptBuilder {\n private getTaskFiles: PromptBuilderDeps['getTaskFiles'];\n private generatePlanTemplate: PromptBuilderDeps['generatePlanTemplate'];\n private logger: Logger;\n\n constructor(deps: PromptBuilderDeps) {\n this.getTaskFiles = deps.getTaskFiles;\n this.generatePlanTemplate = deps.generatePlanTemplate;\n this.logger = deps.logger || new Logger({ debug: false, prefix: '[PromptBuilder]' });\n }\n\n async buildPlanningPrompt(task: Task): Promise<string> {\n let prompt = '';\n prompt += `## Current Task\\n\\n**Task**: ${task.title}\\n**Description**: ${task.description}`;\n\n if ((task as any).primary_repository) {\n prompt += `\\n**Repository**: ${(task as any).primary_repository}`;\n }\n\n try {\n const taskFiles = await this.getTaskFiles(task.id);\n const contextFiles = taskFiles.filter((f: any) => f.type === 'context' || f.type === 'reference');\n if (contextFiles.length > 0) {\n prompt += `\\n\\n## Supporting Files`;\n for (const file of contextFiles) {\n prompt += `\\n\\n### ${file.name} (${file.type})\\n${file.content}`;\n }\n }\n } catch (error) {\n this.logger.debug('No existing task files found for planning', { taskId: task.id });\n }\n\n const templateVariables = {\n task_id: task.id,\n task_title: task.title,\n task_description: task.description,\n date: new Date().toISOString().split('T')[0],\n repository: ((task as any).primary_repository || '') as string,\n };\n\n const planTemplate = await this.generatePlanTemplate(templateVariables);\n\n prompt += `\\n\\nPlease analyze the codebase and create a detailed implementation plan for this task. Use the following template structure for your plan:\\n\\n${planTemplate}\\n\\nFill in each section with specific, actionable information based on your analysis. Replace all placeholder content with actual details about this task.`;\n\n return prompt;\n }\n\n async buildExecutionPrompt(task: Task): Promise<string> {\n let prompt = '';\n prompt += `## Current Task\\n\\n**Task**: ${task.title}\\n**Description**: ${task.description}`;\n\n if ((task as any).primary_repository) {\n prompt += `\\n**Repository**: ${(task as any).primary_repository}`;\n }\n\n try {\n const taskFiles = await this.getTaskFiles(task.id);\n const hasPlan = taskFiles.some((f: any) => f.type === 'plan');\n if (taskFiles.length > 0) {\n prompt += `\\n\\n## Context and Supporting Information`;\n for (const file of taskFiles) {\n if (file.type === 'plan') {\n prompt += `\\n\\n### Execution Plan\\n${file.content}`;\n } else {\n prompt += `\\n\\n### ${file.name} (${file.type})\\n${file.content}`;\n }\n }\n }\n if (hasPlan) {\n prompt += `\\n\\nPlease implement the changes described in the execution plan above. Follow the plan step-by-step and make the necessary file modifications. You must actually edit files and make changes - do not just analyze or review.`;\n } else {\n prompt += `\\n\\nPlease implement the changes described in the task above. You must actually edit files and make changes - do not just analyze or review.`;\n }\n } catch (error) {\n this.logger.debug('No supporting files found for execution', { taskId: task.id });\n prompt += `\\n\\nPlease implement the changes described in the task above.`;\n }\n return prompt;\n }\n}\n\n\n"],"names":[],"mappings":";;MAUa,aAAa,CAAA;AAChB,IAAA,YAAY;AACZ,IAAA,oBAAoB;AACpB,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,IAAuB,EAAA;AACjC,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY;AACrC,QAAA,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAoB;QACrD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;IACtF;IAEA,MAAM,mBAAmB,CAAC,IAAU,EAAA;QAClC,IAAI,MAAM,GAAG,EAAE;QACf,MAAM,IAAI,CAAA,6BAAA,EAAgC,IAAI,CAAC,KAAK,sBAAsB,IAAI,CAAC,WAAW,CAAA,CAAE;AAE5F,QAAA,IAAK,IAAY,CAAC,kBAAkB,EAAE;AACpC,YAAA,MAAM,IAAI,CAAA,kBAAA,EAAsB,IAAY,CAAC,kBAAkB,EAAE;QACnE;AAEA,QAAA,IAAI;YACF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CA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E5F,QAAA,IAAK,IAAY,CAAC,kBAAkB,EAAE;AACpC,YAAA,MAAM,IAAI,CAAA,kBAAA,EAAsB,IAAY,CAAC,kBAAkB,EAAE;QACnE;AAEA,QAAA,IAAI;YACF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;AAClD,YAAA,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAM,KAAK,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;AAC7D,YAAA,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;gBACxB,MAAM,IAAI,2CAA2C;AACrD,gBAAA,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;AAC5B,oBAAA,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;AACxB,wBAAA,MAAM,IAAI,CAAA,wBAAA,EAA2B,IAAI,CAAC,OAAO,EAAE;oBACrD;yBAAO;AACL,wBAAA,MAAM,IAAI,CAAA,QAAA,EAAW,IAAI,CAAC,IAAI,CAAA,EAAA,EAAK,IAAI,CAAC,IAAI,CAAA,GAAA,EAAM,IAAI,CAAC,OAAO,EAAE;oBAClE;gBACF;YACF;YACA,IAAI,OAAO,EAAE;gBACX,MAAM,IAAI,gOAAgO;YAC5O;iBAAO;gBACL,MAAM,IAAI,8IAA8I;YAC1J;QACF;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;YACjF,MAAM,IAAI,+DAA+D;QAC3E;AACA,QAAA,OAAO,MAAM;IACf;AACD;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Logger } from './utils/logger';
|
|
2
|
-
import { AgentRegistry } from './agent-registry';
|
|
3
|
-
import type { Task } from './types';
|
|
4
|
-
import type { WorkflowStage, WorkflowStageExecutionResult, WorkflowExecutionOptions } from './workflow-types';
|
|
5
|
-
import { PromptBuilder } from './prompt-builder';
|
|
1
|
+
import { Logger } from './utils/logger.js';
|
|
2
|
+
import { AgentRegistry } from './agent-registry.js';
|
|
3
|
+
import type { Task } from './types.js';
|
|
4
|
+
import type { WorkflowStage, WorkflowStageExecutionResult, WorkflowExecutionOptions } from './workflow-types.js';
|
|
5
|
+
import { PromptBuilder } from './prompt-builder.js';
|
|
6
6
|
export declare class StageExecutor {
|
|
7
7
|
private registry;
|
|
8
8
|
private logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stage-executor.d.ts","sourceRoot":"","sources":["../../src/stage-executor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"stage-executor.d.ts","sourceRoot":"","sources":["../../src/stage-executor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAGjH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,aAAa,CAAgB;gBAEzB,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,aAAa;IAW5E,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,4BAA4B,CAAC;YA+B3G,WAAW;YAyCX,YAAY;CAkC3B"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
-
import
|
|
3
|
-
import { EventTransformer } from './event-transformer';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import './utils/logger.js';
|
|
3
|
+
import { EventTransformer } from './event-transformer.js';
|
|
4
|
+
import { PLANNING_SYSTEM_PROMPT } from './agents/planning.js';
|
|
5
|
+
import { EXECUTION_SYSTEM_PROMPT } from './agents/execution.js';
|
|
6
|
+
import { PromptBuilder } from './prompt-builder.js';
|
|
7
|
+
import { POSTHOG_MCP } from './utils/mcp.js';
|
|
8
|
+
|
|
9
|
+
class StageExecutor {
|
|
10
10
|
registry;
|
|
11
11
|
logger;
|
|
12
12
|
eventTransformer;
|
|
@@ -116,4 +116,6 @@ export class StageExecutor {
|
|
|
116
116
|
return { results };
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
|
|
120
|
+
export { StageExecutor };
|
|
121
|
+
//# sourceMappingURL=stage-executor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stage-executor.js","
|
|
1
|
+
{"version":3,"file":"stage-executor.js","sources":["../../src/stage-executor.ts"],"sourcesContent":["import { query } from '@anthropic-ai/claude-agent-sdk';\nimport { Logger } from './utils/logger.js';\nimport { EventTransformer } from './event-transformer.js';\nimport { AgentRegistry } from './agent-registry.js';\nimport type { Task } from './types.js';\nimport type { WorkflowStage, WorkflowStageExecutionResult, WorkflowExecutionOptions } from './workflow-types.js';\nimport { PLANNING_SYSTEM_PROMPT } from './agents/planning.js';\nimport { EXECUTION_SYSTEM_PROMPT } from './agents/execution.js';\nimport { PromptBuilder } from './prompt-builder.js';\nimport { POSTHOG_MCP } from './utils/mcp.js';\n\nexport class StageExecutor {\n private registry: AgentRegistry;\n private logger: Logger;\n private eventTransformer: EventTransformer;\n private promptBuilder: PromptBuilder;\n\n constructor(registry: AgentRegistry, logger: Logger, promptBuilder?: PromptBuilder) {\n this.registry = registry;\n this.logger = logger.child('StageExecutor');\n this.eventTransformer = new EventTransformer();\n this.promptBuilder = promptBuilder || new PromptBuilder({\n getTaskFiles: async () => [],\n generatePlanTemplate: async () => '',\n logger,\n });\n }\n\n async execute(task: Task, stage: WorkflowStage, options: WorkflowExecutionOptions): Promise<WorkflowStageExecutionResult> {\n const isManual = stage.is_manual_only === true;\n if (isManual) {\n this.logger.info('Manual stage detected; skipping agent execution', { stage: stage.key });\n return { results: [] };\n }\n\n const inferredAgent = stage.key.toLowerCase().includes('plan') ? 'planning_basic' : 'code_generation';\n const agentName = stage.agent_name || inferredAgent;\n const agent = this.registry.getAgent(agentName);\n if (!agent) {\n throw new Error(`Unknown agent '${agentName}' for stage '${stage.key}'`);\n }\n\n const permissionMode = (options.permissionMode as any) || 'acceptEdits';\n const cwd = options.repositoryPath || process.cwd();\n\n switch (agent.agent_type) {\n case 'planning':\n return this.runPlanning(task, cwd, options, stage.key);\n case 'execution':\n return this.runExecution(task, cwd, permissionMode, options, stage.key);\n case 'review': // TODO: Implement review\n case 'testing': // TODO: Implement testing\n default:\n // throw new Error(`Unsupported agent type: ${agent.agent_type}`);\n console.warn(`Unsupported agent type: ${agent.agent_type}`);\n return { results: [] };\n }\n }\n\n private async runPlanning(task: Task, cwd: string, options: WorkflowExecutionOptions, stageKey: string): Promise<WorkflowStageExecutionResult> {\n const contextPrompt = await this.promptBuilder.buildPlanningPrompt(task);\n let prompt = PLANNING_SYSTEM_PROMPT + '\\n\\n' + contextPrompt;\n\n const stageOverrides = options.stageOverrides?.[stageKey] || options.stageOverrides?.['plan'];\n const mergedOverrides = {\n ...(options.queryOverrides || {}),\n ...(stageOverrides?.queryOverrides || {}),\n } as Record<string, any>;\n\n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode: 'plan',\n settingSources: ['local'],\n mcpServers: {\n ...POSTHOG_MCP\n }\n };\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...mergedOverrides },\n });\n\n let plan = '';\n for await (const message of response) {\n const transformed = this.eventTransformer.transform(message);\n if (transformed && transformed.type !== 'token') {\n this.logger.debug('Planning event', { type: transformed.type });\n }\n if (message.type === 'assistant' && message.message?.content) {\n for (const c of message.message.content) {\n if (c.type === 'text' && c.text) plan += c.text + '\\n';\n }\n }\n }\n\n return { plan: plan.trim() };\n }\n\n private async runExecution(task: Task, cwd: string, permissionMode: WorkflowExecutionOptions['permissionMode'], options: WorkflowExecutionOptions, stageKey: string): Promise<WorkflowStageExecutionResult> {\n const contextPrompt = await this.promptBuilder.buildExecutionPrompt(task);\n let prompt = EXECUTION_SYSTEM_PROMPT + '\\n\\n' + contextPrompt;\n\n const stageOverrides = options.stageOverrides?.[stageKey];\n const mergedOverrides = {\n ...(options.queryOverrides || {}),\n ...(stageOverrides?.queryOverrides || {}),\n } as Record<string, any>;\n\n const baseOptions: Record<string, any> = {\n model: 'claude-sonnet-4-5-20250929',\n cwd,\n permissionMode,\n settingSources: ['local'],\n mcpServers: {\n ...POSTHOG_MCP\n }\n };\n\n const response = query({\n prompt,\n options: { ...baseOptions, ...mergedOverrides },\n });\n const results: any[] = [];\n for await (const message of response) {\n const transformed = this.eventTransformer.transform(message);\n if (transformed && transformed.type !== 'token') {\n this.logger.debug('Execution event', { type: transformed.type });\n }\n results.push(message);\n }\n return { results };\n }\n}\n\n"],"names":[],"mappings":";;;;;;;;MAWa,aAAa,CAAA;AAChB,IAAA,QAAQ;AACR,IAAA,MAAM;AACN,IAAA,gBAAgB;AAChB,IAAA,aAAa;AAErB,IAAA,WAAA,CAAY,QAAuB,EAAE,MAAc,EAAE,aAA6B,EAAA;AAChF,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC;AAC3C,QAAA,IAAI,CAAC,gBAAgB,G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AAM,QAAQ,GAAG,KAAK,CAAC;YACrB,MAAM;AACN,YAAA,OAAO,EAAE,EAAE,GAAG,WAAW,EAAE,GAAG,eAAe,EAAE;AAChD,SAAA,CAAC;QACF,MAAM,OAAO,GAAU,EAAE;AACzB,QAAA,WAAW,MAAM,OAAO,IAAI,QAAQ,EAAE;YACpC,MAAM,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,OAAO,CAAC;YAC5D,IAAI,WAAW,IAAI,WAAW,CAAC,IAAI,KAAK,OAAO,EAAE;AAC/C,gBAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;YAClE;AACA,YAAA,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;QACvB;QACA,OAAO,EAAE,OAAO,EAAE;IACpB;AACD;;;;"}
|
package/dist/src/task-manager.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomBytes } from 'crypto';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
class TaskManager {
|
|
3
4
|
executionStates = new Map();
|
|
4
5
|
defaultTimeout = 10 * 60 * 1000; // 10 minutes
|
|
5
6
|
generateExecutionId() {
|
|
@@ -116,4 +117,6 @@ export class TaskManager {
|
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
+
|
|
121
|
+
export { TaskManager };
|
|
122
|
+
//# sourceMappingURL=task-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-manager.js","
|
|
1
|
+
{"version":3,"file":"task-manager.js","sources":["../../src/task-manager.ts"],"sourcesContent":["import { randomBytes } from 'crypto';\n\nexport interface TaskExecutionState {\n taskId: string;\n status: 'running' | 'completed' | 'failed' | 'canceled' | 'timeout';\n mode: 'plan_only' | 'plan_and_build' | 'build_only';\n result?: any;\n startedAt: number;\n completedAt?: number;\n abortController?: AbortController;\n}\n\nexport class TaskManager {\n private executionStates = new Map<string, TaskExecutionState>();\n private defaultTimeout = 10 * 60 * 1000; // 10 minutes\n\n generateExecutionId(): string {\n return randomBytes(16).toString('hex');\n }\n\n startExecution(\n taskId: string, \n mode: 'plan_only' | 'plan_and_build' | 'build_only',\n executionId: string = this.generateExecutionId()\n ): TaskExecutionState {\n const executionState: TaskExecutionState = {\n taskId,\n status: 'running',\n mode,\n startedAt: Date.now(),\n abortController: new AbortController(),\n };\n\n this.executionStates.set(executionId, executionState);\n this.scheduleTimeout(executionId);\n \n return executionState;\n }\n\n async waitForCompletion(executionId: string): Promise<any> {\n const execution = this.executionStates.get(executionId);\n if (!execution) {\n throw new Error(`Execution ${executionId} not found`);\n }\n\n if (execution.result && execution.status === 'completed') {\n return execution.result;\n }\n\n return new Promise((resolve, reject) => {\n const checkInterval = setInterval(() => {\n const currentExecution = this.executionStates.get(executionId);\n if (!currentExecution) {\n clearInterval(checkInterval);\n reject(new Error(`Execution ${executionId} disappeared`));\n return;\n }\n\n if (currentExecution.status === 'completed' && currentExecution.result) {\n clearInterval(checkInterval);\n resolve(currentExecution.result);\n } else if (\n currentExecution.status === 'failed' || \n currentExecution.status === 'canceled' || \n currentExecution.status === 'timeout'\n ) {\n clearInterval(checkInterval);\n reject(new Error(`Execution ${executionId} ${currentExecution.status}`));\n }\n }, 100);\n });\n }\n\n completeExecution(executionId: string, result: any): void {\n const execution = this.executionStates.get(executionId);\n if (!execution) {\n throw new Error(`Execution ${executionId} not found`);\n }\n\n execution.status = 'completed';\n execution.result = result;\n execution.completedAt = Date.now();\n }\n\n failExecution(executionId: string, error: Error): void {\n const execution = this.executionStates.get(executionId);\n if (!execution) {\n throw new Error(`Execution ${executionId} not found`);\n }\n\n execution.status = 'failed';\n execution.completedAt = Date.now();\n execution.result = {\n error: error.message,\n status: 'failed',\n };\n }\n\n cancelExecution(executionId: string): void {\n const execution = this.executionStates.get(executionId);\n if (!execution) {\n throw new Error(`Execution ${executionId} not found`);\n }\n\n execution.status = 'canceled';\n execution.completedAt = Date.now();\n execution.abortController?.abort();\n \n if (!execution.result) {\n execution.result = {\n status: 'canceled',\n message: 'Execution was canceled',\n };\n }\n }\n\n getExecution(executionId: string): TaskExecutionState | undefined {\n return this.executionStates.get(executionId);\n }\n\n getAbortSignal(executionId: string): AbortSignal | undefined {\n return this.executionStates.get(executionId)?.abortController?.signal;\n }\n\n getAbortController(executionId: string): AbortController | undefined {\n return this.executionStates.get(executionId)?.abortController;\n }\n\n private scheduleTimeout(executionId: string, timeout: number = this.defaultTimeout): void {\n setTimeout(() => {\n const execution = this.executionStates.get(executionId);\n if (execution && execution.status === 'running') {\n execution.status = 'timeout';\n execution.completedAt = Date.now();\n execution.abortController?.abort();\n \n if (!execution.result) {\n execution.result = {\n status: 'timeout',\n message: 'Execution timed out',\n };\n }\n }\n }, timeout);\n }\n\n cleanup(olderThan: number = 60 * 60 * 1000): void {\n const cutoff = Date.now() - olderThan;\n for (const [executionId, execution] of this.executionStates) {\n if (execution.completedAt && execution.completedAt < cutoff) {\n this.executionStates.delete(executionId);\n }\n }\n }\n}"],"names":[],"mappings":";;MAYa,WAAW,CAAA;AACd,IAAA,eAAe,GAAG,IAAI,GAAG,EAA8B;IACvD,cAAc,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAExC,mBAAmB,GAAA;QACjB,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;IACxC;IAEA,cAAc,CACZ,MAAc,EACd,IAAmD,EACnD,WAAA,GAAsB,IAAI,CAAC,mBAAmB,EAAE,EAAA;AAEhD,QAAA,MAAM,cAAc,GAAuB;YACzC,MAAM;AACN,YAAA,MAAM,EAAE,SAAS;YACjB,IAAI;AACJ,YAAA,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,eAAe,EAAE,IAAI,eAAe,EAAE;SACvC;QAED,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,EAAE,cAAc,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,EAAE,GAAG,SAAS;QACrC,KAAK,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE;YAC3D,IAAI,SAAS,CAAC,WAAW,IAAI,SAAS,CAAC,WAAW,GAAG,MAAM,EAAE;AAC3D,gBAAA,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC;YAC1C;QACF;IACF;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-manager.d.ts","sourceRoot":"","sources":["../../src/template-manager.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,YAAY,CAAS;;
|
|
1
|
+
{"version":3,"file":"template-manager.d.ts","sourceRoot":"","sources":["../../src/template-manager.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,YAAY,CAAS;;YAgBf,YAAY;IAS1B,OAAO,CAAC,mBAAmB;IAerB,YAAY,CAAC,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAS3D,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAQvF,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QACrE,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,eAAe,CAAC,EAAE,KAAK,CAAC;YACtB,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC,CAAC;KACJ,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAA;KAAE,CAAC,CAAC;IA2CxG,qBAAqB,IAAI,MAAM;CAmChC"}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import { promises
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, promises } from 'fs';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
class TemplateManager {
|
|
5
6
|
templatesDir;
|
|
6
7
|
constructor() {
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
9
|
const __dirname = dirname(__filename);
|
|
9
|
-
|
|
10
|
+
const candidateDirs = [
|
|
11
|
+
join(__dirname, 'templates'),
|
|
12
|
+
join(__dirname, '..', 'templates'),
|
|
13
|
+
join(__dirname, '..', '..', 'templates'),
|
|
14
|
+
join(__dirname, '..', '..', 'src', 'templates')
|
|
15
|
+
];
|
|
16
|
+
const resolvedDir = candidateDirs.find((dir) => existsSync(dir));
|
|
17
|
+
this.templatesDir = resolvedDir ?? candidateDirs[0];
|
|
10
18
|
}
|
|
11
19
|
async loadTemplate(templateName) {
|
|
12
20
|
try {
|
|
13
21
|
const templatePath = join(this.templatesDir, templateName);
|
|
14
|
-
return await
|
|
22
|
+
return await promises.readFile(templatePath, 'utf8');
|
|
15
23
|
}
|
|
16
24
|
catch (error) {
|
|
17
25
|
throw new Error(`Failed to load template ${templateName}: ${error}`);
|
|
@@ -115,4 +123,6 @@ Customize \`.posthog/.gitignore\` to control which files are committed:
|
|
|
115
123
|
`;
|
|
116
124
|
}
|
|
117
125
|
}
|
|
118
|
-
|
|
126
|
+
|
|
127
|
+
export { TemplateManager };
|
|
128
|
+
//# sourceMappingURL=template-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-manager.js","
|
|
1
|
+
{"version":3,"file":"template-manager.js","sources":["../../src/template-manager.ts"],"sourcesContent":["import { promises as fs, existsSync } from 'fs';\nimport { join, dirname } from 'path';\nimport { fileURLToPath } from 'url';\n\nexport interface TemplateVariables {\n task_id: string;\n task_title: string;\n task_description?: string;\n date: string;\n repository?: string;\n [key: string]: string | undefined;\n}\n\nexport class TemplateManager {\n private templatesDir: string;\n\n constructor() {\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = dirname(__filename);\n const candidateDirs = [\n join(__dirname, 'templates'),\n join(__dirname, '..', 'templates'),\n join(__dirname, '..', '..', 'templates'),\n join(__dirname, '..', '..', 'src', 'templates')\n ];\n\n const resolvedDir = candidateDirs.find((dir) => existsSync(dir));\n this.templatesDir = resolvedDir ?? candidateDirs[0];\n }\n\n private async loadTemplate(templateName: string): Promise<string> {\n try {\n const templatePath = join(this.templatesDir, templateName);\n return await fs.readFile(templatePath, 'utf8');\n } catch (error) {\n throw new Error(`Failed to load template ${templateName}: ${error}`);\n }\n }\n\n private substituteVariables(template: string, variables: TemplateVariables): string {\n let result = template;\n \n for (const [key, value] of Object.entries(variables)) {\n if (value !== undefined) {\n const placeholder = new RegExp(`{{${key}}}`, 'g');\n result = result.replace(placeholder, value);\n }\n }\n \n result = result.replace(/{{[^}]+}}/g, '[PLACEHOLDER]');\n \n return result;\n }\n\n async generatePlan(variables: TemplateVariables): Promise<string> {\n const template = await this.loadTemplate('plan-template.md');\n return this.substituteVariables(template, {\n ...variables,\n date: variables.date || new Date().toISOString().split('T')[0]\n });\n }\n\n\n async generateCustomFile(templateName: string, variables: TemplateVariables): Promise<string> {\n const template = await this.loadTemplate(templateName);\n return this.substituteVariables(template, {\n ...variables,\n date: variables.date || new Date().toISOString().split('T')[0]\n });\n }\n\n async createTaskStructure(taskId: string, taskTitle: string, options?: {\n includePlan?: boolean;\n additionalFiles?: Array<{\n name: string;\n template?: string;\n content?: string;\n }>;\n }): Promise<Array<{ name: string; content: string; type: 'plan' | 'context' | 'reference' | 'output' }>> {\n const files: Array<{ name: string; content: string; type: 'plan' | 'context' | 'reference' | 'output' }> = [];\n \n const variables: TemplateVariables = {\n task_id: taskId,\n task_title: taskTitle,\n date: new Date().toISOString().split('T')[0]\n };\n\n // Generate plan file if requested\n if (options?.includePlan !== false) {\n const planContent = await this.generatePlan(variables);\n files.push({\n name: 'plan.md',\n content: planContent,\n type: 'plan'\n });\n }\n\n\n if (options?.additionalFiles) {\n for (const file of options.additionalFiles) {\n let content: string;\n \n if (file.template) {\n content = await this.generateCustomFile(file.template, variables);\n } else if (file.content) {\n content = this.substituteVariables(file.content, variables);\n } else {\n content = `# ${file.name}\\n\\nPlaceholder content for ${file.name}`;\n }\n\n files.push({\n name: file.name,\n content,\n type: file.name.includes('context') ? 'context' : 'reference'\n });\n }\n }\n\n return files;\n }\n\n generatePostHogReadme(): string {\n return `# PostHog Task Files\n\nThis directory contains task-related files generated by the PostHog Agent.\n\n## Structure\n\nEach task has its own subdirectory: \\`.posthog/{task-id}/\\`\n\n### Common Files\n\n- **plan.md** - Implementation plan generated during planning phase\n- **Supporting files** - Any additional files added for task context\n- **artifacts/** - Generated files, outputs, and temporary artifacts\n\n### Usage\n\nThese files are:\n- Version controlled alongside your code\n- Used by the PostHog Agent for context\n- Available for review in pull requests\n- Organized by task ID for easy reference\n\n### Gitignore\n\nCustomize \\`.posthog/.gitignore\\` to control which files are committed:\n- Include plans and documentation by default\n- Exclude temporary files and sensitive data\n- Customize based on your team's workflow\n\n---\n\n*Generated by PostHog Agent*\n`;\n }\n}\n"],"names":["fs"],"mappings":";;;;MAaa,eAAe,CAAA;AAClB,IAAA,YAAY;AAEpB,IAAA,WAAA,GAAA;QACE,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AACjD,QAAA,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC;AACrC,QAAA,MAAM,aAAa,GAAG;AACpB,YAAA,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC;AAC5B,YAAA,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC;YAClC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC;YACxC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW;SAC/C;AAED,QAAA,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,UAAU,CAAC,GAAG,CAAC,CAAC;QAChE,IAAI,CAAC,YAAY,GAAG,WAAW,IAAI,aAAa,CAAC,CAAC,CAAC;IACrD;IAEQ,MAAM,YAAY,CAAC,YAAoB,EAAA;AAC7C,QAAA,IAAI;YACF,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC;YAC1D,OAAO,MAAMA,QAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAChD;QAAE,OAAO,KAAK,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,CAAA,wBAAA,EAA2B,YAAY,CAAA,EAAA,EAAK,KAAK,CAAA,CAAE,CAAC;QACtE;IACF;IAEQ,mBAAmB,CAAC,QAAgB,EAAE,SAA4B,EAAA;QACxE,IAAI,MAAM,GAAG,QAAQ;AAErB,QAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,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AACD;;;;"}
|
package/dist/src/types.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Removed legacy ExecutionMode in favor of configurable workflows
|
|
2
|
-
|
|
2
|
+
var PermissionMode;
|
|
3
3
|
(function (PermissionMode) {
|
|
4
4
|
PermissionMode["PLAN"] = "plan";
|
|
5
5
|
PermissionMode["DEFAULT"] = "default";
|
|
6
6
|
PermissionMode["ACCEPT_EDITS"] = "acceptEdits";
|
|
7
7
|
PermissionMode["BYPASS"] = "bypassPermissions";
|
|
8
8
|
})(PermissionMode || (PermissionMode = {}));
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
export { PermissionMode };
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
package/dist/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["// PostHog Task model (matches Array's OpenAPI schema)\nexport interface Task {\n id: string;\n title: string;\n description: string;\n origin_product: 'error_tracking' | 'eval_clusters' | 'user_created' | 'support_queue' | 'session_summaries';\n position?: number;\n workflow?: string | null;\n current_stage?: string | null;\n github_integration?: number | null;\n repository_config?: unknown; // JSONField\n repository_list: string;\n primary_repository: string;\n github_branch: string | null;\n github_pr_url: string | null;\n created_at: string;\n updated_at: string;\n}\n\nexport interface SupportingFile {\n name: string;\n content: string;\n type: 'plan' | 'context' | 'reference' | 'output';\n created_at: string;\n}\n\n// Removed legacy ExecutionMode in favor of configurable workflows\n\nexport enum PermissionMode {\n PLAN = \"plan\",\n DEFAULT = \"default\",\n ACCEPT_EDITS = \"acceptEdits\",\n BYPASS = \"bypassPermissions\"\n}\n\nexport interface ExecutionOptions {\n repositoryPath?: string;\n permissionMode?: PermissionMode;\n}\n\n// Base event with timestamp\ninterface BaseEvent {\n ts: number;\n}\n\n// Streaming content events\nexport interface TokenEvent extends BaseEvent {\n type: 'token';\n content: string;\n contentType?: 'text' | 'thinking' | 'tool_input';\n}\n\nexport interface ContentBlockStartEvent extends BaseEvent {\n type: 'content_block_start';\n index: number;\n contentType: 'text' | 'tool_use' | 'thinking';\n toolName?: string;\n toolId?: string;\n}\n\nexport interface ContentBlockStopEvent extends BaseEvent {\n type: 'content_block_stop';\n index: number;\n}\n\n// Tool events\nexport interface ToolCallEvent extends BaseEvent {\n type: 'tool_call';\n toolName: string;\n callId: string;\n args: Record<string, any>;\n}\n\nexport interface ToolResultEvent extends BaseEvent {\n type: 'tool_result';\n toolName: string;\n callId: string;\n result: any;\n}\n\n// Message lifecycle events\nexport interface MessageStartEvent extends BaseEvent {\n type: 'message_start';\n messageId?: string;\n model?: string;\n}\n\nexport interface MessageDeltaEvent extends BaseEvent {\n type: 'message_delta';\n stopReason?: string;\n stopSequence?: string;\n usage?: {\n outputTokens: number;\n };\n}\n\nexport interface MessageStopEvent extends BaseEvent {\n type: 'message_stop';\n}\n\n// User message events\nexport interface UserMessageEvent extends BaseEvent {\n type: 'user_message';\n content: string;\n isSynthetic?: boolean;\n}\n\n// System events\nexport interface StatusEvent extends BaseEvent {\n type: 'status';\n phase: string;\n [key: string]: any;\n}\n\nexport interface InitEvent extends BaseEvent {\n type: 'init';\n model: string;\n tools: string[];\n permissionMode: string;\n cwd: string;\n apiKeySource: string;\n}\n\nexport interface CompactBoundaryEvent extends BaseEvent {\n type: 'compact_boundary';\n trigger: 'manual' | 'auto';\n preTokens: number;\n}\n\n// Result events\nexport interface DoneEvent extends BaseEvent {\n type: 'done';\n durationMs?: number;\n numTurns?: number;\n totalCostUsd?: number;\n usage?: any;\n}\n\nexport interface ErrorEvent extends BaseEvent {\n type: 'error';\n message: string;\n error?: any;\n errorType?: string;\n}\n\n// Legacy events (keeping for backwards compatibility)\nexport interface DiffEvent extends BaseEvent {\n type: 'diff';\n file: string;\n patch: string;\n summary?: string;\n}\n\nexport interface FileWriteEvent extends BaseEvent {\n type: 'file_write';\n path: string;\n bytes: number;\n}\n\nexport interface MetricEvent extends BaseEvent {\n type: 'metric';\n key: string;\n value: number;\n unit?: string;\n}\n\nexport interface ArtifactEvent extends BaseEvent {\n type: 'artifact';\n kind: string;\n content: any;\n}\n\nexport type AgentEvent =\n | TokenEvent\n | ContentBlockStartEvent\n | ContentBlockStopEvent\n | ToolCallEvent\n | ToolResultEvent\n | MessageStartEvent\n | MessageDeltaEvent\n | MessageStopEvent\n | UserMessageEvent\n | StatusEvent\n | InitEvent\n | CompactBoundaryEvent\n | DoneEvent\n | ErrorEvent\n | DiffEvent\n | FileWriteEvent\n | MetricEvent\n | ArtifactEvent;\n\nexport interface ExecutionResult {\n results: any[];\n}\n\nexport interface PlanResult {\n plan: string;\n}\n\nexport interface TaskExecutionResult {\n task: Task;\n plan?: string;\n executionResult?: ExecutionResult;\n // Deprecated: mode removed in workflow-based execution\n}\n\nexport interface AgentConfig {\n workingDirectory?: string;\n onEvent?: (event: AgentEvent) => void;\n \n // PostHog API configuration\n posthogApiUrl?: string;\n posthogApiKey?: string;\n \n // Logging configuration\n debug?: boolean;\n}\n\nexport interface PostHogAPIConfig {\n apiUrl: string;\n apiKey: string;\n}"],"names":[],"mappings":"AA0BA;IAEY;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,cAAA,CAAA,cAAA,CAAA,GAAA,aAA4B;AAC5B,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,mBAA4B;AAC9B,CAAC,EALW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/dist/src/utils/logger.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Simple logger utility with configurable debug mode
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
var LogLevel;
|
|
5
5
|
(function (LogLevel) {
|
|
6
6
|
LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
|
|
7
7
|
LogLevel[LogLevel["WARN"] = 1] = "WARN";
|
|
8
8
|
LogLevel[LogLevel["INFO"] = 2] = "INFO";
|
|
9
9
|
LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
|
|
10
10
|
})(LogLevel || (LogLevel = {}));
|
|
11
|
-
|
|
11
|
+
class Logger {
|
|
12
12
|
debugEnabled;
|
|
13
13
|
prefix;
|
|
14
14
|
constructor(config = {}) {
|
|
@@ -63,4 +63,6 @@ export class Logger {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
|
|
67
|
+
export { LogLevel, Logger };
|
|
68
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","
|
|
1
|
+
{"version":3,"file":"logger.js","sources":["../../../src/utils/logger.ts"],"sourcesContent":["/**\n * Simple logger utility with configurable debug mode\n */\nexport enum LogLevel {\n ERROR = 0,\n WARN = 1,\n INFO = 2,\n DEBUG = 3\n}\n\nexport interface LoggerConfig {\n debug?: boolean;\n prefix?: string;\n}\n\nexport class Logger {\n private debugEnabled: boolean;\n private prefix: string;\n\n constructor(config: LoggerConfig = {}) {\n this.debugEnabled = config.debug ?? false;\n this.prefix = config.prefix ?? '[PostHog Agent]';\n }\n\n setDebug(enabled: boolean) {\n this.debugEnabled = enabled;\n }\n\n private formatMessage(level: string, message: string, data?: any): string {\n const timestamp = new Date().toISOString();\n const base = `${timestamp} ${this.prefix} ${level} ${message}`;\n \n if (data !== undefined) {\n return `${base} ${JSON.stringify(data, null, 2)}`;\n }\n \n return base;\n }\n\n error(message: string, error?: Error | any) {\n // Always log errors\n if (error instanceof Error) {\n console.error(this.formatMessage('[ERROR]', message, {\n message: error.message,\n stack: error.stack\n }));\n } else {\n console.error(this.formatMessage('[ERROR]', message, error));\n }\n }\n\n warn(message: string, data?: any) {\n if (this.debugEnabled) {\n console.warn(this.formatMessage('[WARN]', message, data));\n }\n }\n\n info(message: string, data?: any) {\n if (this.debugEnabled) {\n console.log(this.formatMessage('[INFO]', message, data));\n }\n }\n\n debug(message: string, data?: any) {\n if (this.debugEnabled) {\n console.log(this.formatMessage('[DEBUG]', message, data));\n }\n }\n\n /**\n * Create a child logger with additional prefix\n */\n child(childPrefix: string): Logger {\n return new Logger({\n debug: this.debugEnabled,\n prefix: `${this.prefix} [${childPrefix}]`\n });\n }\n}"],"names":[],"mappings":"AAAA;;AAEG;IACS;AAAZ,CAAA,UAAY,QAAQ,EAAA;AAChB,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACT,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,QAAA,CAAA,QAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,QAAA,CAAA,QAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACb,CAAC,EALW,QAAQ,KAAR,QAAQ,GAAA,EAAA,CAAA,CAAA;MAYP,MAAM,CAAA;AACP,IAAA,YAAY;AACZ,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,SAAuB,EAAE,EAAA;QACjC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,KAAK,IAAI,KAAK;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,iBAAiB;IACpD;AAEA,IAAA,QAAQ,CAAC,OAAgB,EAAA;AACrB,QAAA,IAAI,CAAC,YAAY,GAAG,OAAO;IAC/B;AAEQ,IAAA,aAAa,CAAC,KAAa,EAAE,OAAe,EAAE,IAAU,EAAA;QAC5D,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;AAC1C,QAAA,MAAM,IAAI,GAAG,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM,CAAA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J;AAEA;;AAEG;AACH,IAAA,KAAK,CAAC,WAAmB,EAAA;QACrB,OAAO,IAAI,MAAM,CAAC;YACd,KAAK,EAAE,IAAI,CAAC,YAAY;AACxB,YAAA,MAAM,EAAE,CAAA,EAAG,IAAI,CAAC,MAAM,CAAA,EAAA,EAAK,WAAW,CAAA,CAAA;AACzC,SAAA,CAAC;IACN;AACH;;;;"}
|
package/dist/src/utils/mcp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const POSTHOG_MCP = {
|
|
2
2
|
posthog: {
|
|
3
3
|
command: "npx",
|
|
4
4
|
args: [
|
|
@@ -13,4 +13,6 @@ export const POSTHOG_MCP = {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
|
|
17
|
+
export { POSTHOG_MCP };
|
|
18
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.js","
|
|
1
|
+
{"version":3,"file":"mcp.js","sources":["../../../src/utils/mcp.ts"],"sourcesContent":["export const POSTHOG_MCP = {\n posthog: {\n command: \"npx\",\n args: [\n \"-y\",\n \"mcp-remote@latest\",\n \"https://mcp.posthog.com/mcp\",\n \"--header\",\n \"Authorization:${POSTHOG_AUTH_HEADER}\"\n ],\n env: {\n \"POSTHOG_AUTH_HEADER\": `Bearer ${process.env.POSTHOG_API_KEY}`\n }\n }\n};"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;AACvB,IAAA,OAAO,EAAE;AACL,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,IAAI,EAAE;YACF,IAAI;YACJ,mBAAmB;YACnB,6BAA6B;YAC7B,UAAU;YACV;AACH,SAAA;AACD,QAAA,GAAG,EAAE;AACD,YAAA,qBAAqB,EAAE,CAAA,OAAA,EAAU,OAAO,CAAC,GAAG,CAAC,eAAe,CAAA;AAC/D;AACJ;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { WorkflowDefinition } from './workflow-types';
|
|
2
|
-
import { PostHogAPIClient } from './posthog-api';
|
|
1
|
+
import type { WorkflowDefinition } from './workflow-types.js';
|
|
2
|
+
import { PostHogAPIClient } from './posthog-api.js';
|
|
3
3
|
export declare class WorkflowRegistry {
|
|
4
4
|
private workflowsById;
|
|
5
5
|
private apiClient?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-registry.d.ts","sourceRoot":"","sources":["../../src/workflow-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"workflow-registry.d.ts","sourceRoot":"","sources":["../../src/workflow-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,aAAa,CAA8C;IACnE,OAAO,CAAC,SAAS,CAAC,CAAmB;gBAEzB,SAAS,CAAC,EAAE,gBAAgB,EAAE,iBAAiB,CAAC,EAAE,kBAAkB,EAAE;IAO5E,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAOpC,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAIvD,aAAa,IAAI,kBAAkB,EAAE;CAGtC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export class WorkflowRegistry {
|
|
1
|
+
class WorkflowRegistry {
|
|
3
2
|
workflowsById = new Map();
|
|
4
3
|
apiClient;
|
|
5
4
|
constructor(apiClient, staticDefinitions) {
|
|
@@ -23,4 +22,6 @@ export class WorkflowRegistry {
|
|
|
23
22
|
return Array.from(this.workflowsById.values());
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
|
|
25
|
+
|
|
26
|
+
export { WorkflowRegistry };
|
|
27
|
+
//# sourceMappingURL=workflow-registry.js.map
|