@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.
Files changed (69) hide show
  1. package/dist/index.js +4 -5
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/agent-registry.d.ts +1 -1
  4. package/dist/src/agent-registry.d.ts.map +1 -1
  5. package/dist/src/agent-registry.js +4 -2
  6. package/dist/src/agent-registry.js.map +1 -1
  7. package/dist/src/agent.d.ts +6 -6
  8. package/dist/src/agent.d.ts.map +1 -1
  9. package/dist/src/agent.js +18 -17
  10. package/dist/src/agent.js.map +1 -1
  11. package/dist/src/agents/execution.js +4 -2
  12. package/dist/src/agents/execution.js.map +1 -1
  13. package/dist/src/agents/planning.js +4 -2
  14. package/dist/src/agents/planning.js.map +1 -1
  15. package/dist/src/event-transformer.js +4 -2
  16. package/dist/src/event-transformer.js.map +1 -1
  17. package/dist/src/file-manager.d.ts +2 -2
  18. package/dist/src/file-manager.d.ts.map +1 -1
  19. package/dist/src/file-manager.js +18 -15
  20. package/dist/src/file-manager.js.map +1 -1
  21. package/dist/src/git-manager.d.ts +1 -1
  22. package/dist/src/git-manager.d.ts.map +1 -1
  23. package/dist/src/git-manager.js +6 -3
  24. package/dist/src/git-manager.js.map +1 -1
  25. package/dist/src/posthog-api.d.ts +2 -2
  26. package/dist/src/posthog-api.d.ts.map +1 -1
  27. package/dist/src/posthog-api.js +4 -2
  28. package/dist/src/posthog-api.js.map +1 -1
  29. package/dist/src/prompt-builder.d.ts +3 -3
  30. package/dist/src/prompt-builder.d.ts.map +1 -1
  31. package/dist/src/prompt-builder.js +6 -3
  32. package/dist/src/prompt-builder.js.map +1 -1
  33. package/dist/src/stage-executor.d.ts +5 -5
  34. package/dist/src/stage-executor.d.ts.map +1 -1
  35. package/dist/src/stage-executor.js +11 -9
  36. package/dist/src/stage-executor.js.map +1 -1
  37. package/dist/src/task-manager.js +5 -2
  38. package/dist/src/task-manager.js.map +1 -1
  39. package/dist/src/template-manager.d.ts.map +1 -1
  40. package/dist/src/template-manager.js +16 -6
  41. package/dist/src/template-manager.js.map +1 -1
  42. package/dist/src/types.js +4 -2
  43. package/dist/src/types.js.map +1 -1
  44. package/dist/src/utils/logger.js +5 -3
  45. package/dist/src/utils/logger.js.map +1 -1
  46. package/dist/src/utils/mcp.js +4 -2
  47. package/dist/src/utils/mcp.js.map +1 -1
  48. package/dist/src/workflow-registry.d.ts +2 -2
  49. package/dist/src/workflow-registry.d.ts.map +1 -1
  50. package/dist/src/workflow-registry.js +4 -3
  51. package/dist/src/workflow-registry.js.map +1 -1
  52. package/dist/src/workflow-types.d.ts +1 -1
  53. package/dist/src/workflow-types.d.ts.map +1 -1
  54. package/dist/templates/plan-template.md +45 -0
  55. package/package.json +8 -2
  56. package/src/agent-registry.ts +1 -2
  57. package/src/agent.ts +19 -19
  58. package/src/file-manager.ts +3 -3
  59. package/src/git-manager.ts +2 -2
  60. package/src/posthog-api.ts +3 -3
  61. package/src/prompt-builder.ts +3 -4
  62. package/src/stage-executor.ts +9 -10
  63. package/src/template-manager.ts +11 -3
  64. package/src/workflow-registry.ts +2 -3
  65. package/src/workflow-types.ts +1 -2
  66. package/dist/example.js +0 -49
  67. package/dist/example.js.map +0 -1
  68. package/dist/src/workflow-types.js +0 -2
  69. package/dist/src/workflow-types.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-registry.js","sourceRoot":"","sources":["../../src/workflow-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,OAAO,gBAAgB;IACnB,aAAa,GAAoC,IAAI,GAAG,EAAE,CAAC;IAC3D,SAAS,CAAoB;IAErC,YAAY,SAA4B,EAAE,iBAAwC;QAChF,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,iBAAiB,EAAE,CAAC;YACtB,KAAK,MAAM,CAAC,IAAI,iBAAiB;gBAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC;YACvD,KAAK,MAAM,CAAC,IAAI,SAAS;gBAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED,WAAW,CAAC,EAAU;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;IAED,aAAa;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,CAAC;CACF"}
1
+ {"version":3,"file":"workflow-registry.js","sources":["../../src/workflow-registry.ts"],"sourcesContent":["import type { WorkflowDefinition } from './workflow-types.js';\nimport { PostHogAPIClient } from './posthog-api.js';\n\nexport class WorkflowRegistry {\n private workflowsById: Map<string, WorkflowDefinition> = new Map();\n private apiClient?: PostHogAPIClient;\n\n constructor(apiClient?: PostHogAPIClient, staticDefinitions?: WorkflowDefinition[]) {\n this.apiClient = apiClient;\n if (staticDefinitions) {\n for (const w of staticDefinitions) this.workflowsById.set(w.id, w);\n }\n }\n\n async loadWorkflows(): Promise<void> {\n if (this.apiClient) {\n const workflows = await this.apiClient.listWorkflows();\n for (const w of workflows) this.workflowsById.set(w.id, w);\n }\n }\n\n getWorkflow(id: string): WorkflowDefinition | undefined {\n return this.workflowsById.get(id);\n }\n\n listWorkflows(): WorkflowDefinition[] {\n return Array.from(this.workflowsById.values());\n }\n}\n\n"],"names":[],"mappings":"MAGa,gBAAgB,CAAA;AACnB,IAAA,aAAa,GAAoC,IAAI,GAAG,EAAE;AAC1D,IAAA,SAAS;IAEjB,WAAA,CAAY,SAA4B,EAAE,iBAAwC,EAAA;AAChF,QAAA,IAAI,CAAC,SAAS,GAAG,SAAS;QAC1B,IAAI,iBAAiB,EAAE;YACrB,KAAK,MAAM,CAAC,IAAI,iBAAiB;gBAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACpE;IACF;AAEA,IAAA,MAAM,aAAa,GAAA;AACjB,QAAA,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE;YACtD,KAAK,MAAM,CAAC,IAAI,SAAS;gBAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5D;IACF;AAEA,IAAA,WAAW,CAAC,EAAU,EAAA;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;IACnC;IAEA,aAAa,GAAA;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;IAChD;AACD;;;;"}
@@ -1,4 +1,4 @@
1
- import type { PermissionMode, AgentEvent } from './types';
1
+ import type { PermissionMode, AgentEvent } from './types.js';
2
2
  export type AgentType = 'planning' | 'execution' | 'review' | 'testing';
3
3
  export interface AgentDefinition {
4
4
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-types.d.ts","sourceRoot":"","sources":["../../src/workflow-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1D,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExE,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAA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C,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACtD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACtC"}
@@ -0,0 +1,45 @@
1
+ # Implementation Plan: {{task_title}}
2
+
3
+ **Task ID:** {{task_id}}
4
+ **Generated:** {{date}}
5
+
6
+ ## Summary
7
+
8
+ Brief description of what will be implemented and the overall approach.
9
+
10
+ ## Implementation Steps
11
+
12
+ ### 1. Analysis
13
+ - [ ] Identify relevant files and components
14
+ - [ ] Review existing patterns and constraints
15
+
16
+ ### 2. Changes Required
17
+ - [ ] Files to create/modify
18
+ - [ ] Dependencies to add/update
19
+
20
+ ### 3. Implementation
21
+ - [ ] Core functionality changes
22
+ - [ ] Tests and validation
23
+ - [ ] Documentation updates
24
+
25
+ ## File Changes
26
+
27
+ ### New Files
28
+ ```
29
+ path/to/new/file.ts - Purpose
30
+ ```
31
+
32
+ ### Modified Files
33
+ ```
34
+ path/to/existing/file.ts - Changes needed
35
+ ```
36
+
37
+ ## Considerations
38
+
39
+ - Key architectural decisions
40
+ - Potential risks and mitigation
41
+ - Testing approach
42
+
43
+ ---
44
+
45
+ *Generated by PostHog Agent*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/agent",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "TypeScript agent framework wrapping Claude Agent SDK with Git-based workflow for PostHog tasks",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -32,7 +32,13 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@changesets/cli": "^2.27.8",
35
+ "@rollup/plugin-commonjs": "^25.0.7",
36
+ "@rollup/plugin-node-resolve": "^15.2.3",
35
37
  "@types/bun": "latest",
38
+ "rimraf": "^6.0.1",
39
+ "rollup": "^4.24.0",
40
+ "rollup-plugin-copy": "^3.5.0",
41
+ "rollup-plugin-typescript2": "^0.36.0",
36
42
  "typescript": "^5.5.0"
37
43
  },
38
44
  "dependencies": {
@@ -49,7 +55,7 @@
49
55
  "access": "public"
50
56
  },
51
57
  "scripts": {
52
- "build": "tsc --project tsconfig.build.json",
58
+ "build": "rimraf dist && rollup -c && tsc --project tsconfig.build.json --emitDeclarationOnly",
53
59
  "example": "bun run example-usage.ts",
54
60
  "dev": "bun run example-usage.ts",
55
61
  "changeset": "changeset",
@@ -1,4 +1,4 @@
1
- import type { AgentDefinition, AgentType } from './workflow-types';
1
+ import type { AgentDefinition, AgentType } from './workflow-types.js';
2
2
 
3
3
  export class AgentRegistry {
4
4
  private agentsByName: Map<string, AgentDefinition> = new Map();
@@ -57,4 +57,3 @@ export class AgentRegistry {
57
57
  }
58
58
  }
59
59
 
60
-
package/src/agent.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { query } from "@anthropic-ai/claude-agent-sdk";
2
- import type { Task, ExecutionResult, PlanResult, AgentConfig } from './types';
3
- import type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions } from './workflow-types';
4
- import { TaskManager } from './task-manager';
5
- import { PostHogAPIClient } from './posthog-api';
6
- import { PostHogFileManager } from './file-manager';
7
- import { GitManager } from './git-manager';
8
- import { TemplateManager } from './template-manager';
9
- import { EventTransformer } from './event-transformer';
10
- import { PLANNING_SYSTEM_PROMPT } from './agents/planning';
11
- import { EXECUTION_SYSTEM_PROMPT } from './agents/execution';
12
- import { Logger } from './utils/logger';
13
- import { AgentRegistry } from './agent-registry';
14
- import { WorkflowRegistry } from './workflow-registry';
15
- import { StageExecutor } from './stage-executor';
16
- import { PromptBuilder } from './prompt-builder';
2
+ import type { Task, ExecutionResult, PlanResult, AgentConfig } from './types.js';
3
+ import type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions } from './workflow-types.js';
4
+ import { TaskManager } from './task-manager.js';
5
+ import { PostHogAPIClient } from './posthog-api.js';
6
+ import { PostHogFileManager } from './file-manager.js';
7
+ import { GitManager } from './git-manager.js';
8
+ import { TemplateManager } from './template-manager.js';
9
+ import { EventTransformer } from './event-transformer.js';
10
+ import { PLANNING_SYSTEM_PROMPT } from './agents/planning.js';
11
+ import { EXECUTION_SYSTEM_PROMPT } from './agents/execution.js';
12
+ import { Logger } from './utils/logger.js';
13
+ import { AgentRegistry } from './agent-registry.js';
14
+ import { WorkflowRegistry } from './workflow-registry.js';
15
+ import { StageExecutor } from './stage-executor.js';
16
+ import { PromptBuilder } from './prompt-builder.js';
17
17
 
18
18
  export class Agent {
19
19
  private workingDirectory: string;
@@ -237,7 +237,7 @@ export class Agent {
237
237
  }
238
238
 
239
239
  // Direct prompt execution - still supported for low-level usage
240
- async run(prompt: string, options: { repositoryPath?: string; permissionMode?: import('./types').PermissionMode; queryOverrides?: Record<string, any> } = {}): Promise<ExecutionResult> {
240
+ async run(prompt: string, options: { repositoryPath?: string; permissionMode?: import('./types.js').PermissionMode; queryOverrides?: Record<string, any> } = {}): Promise<ExecutionResult> {
241
241
  const baseOptions: Record<string, any> = {
242
242
  model: "claude-4-5-sonnet",
243
243
  cwd: options.repositoryPath || this.workingDirectory,
@@ -423,6 +423,6 @@ Generated by PostHog Agent`;
423
423
  }
424
424
  }
425
425
 
426
- export { PermissionMode } from './types';
427
- export type { Task, SupportingFile, ExecutionResult, AgentConfig } from './types';
428
- export type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions } from './workflow-types';
426
+ export { PermissionMode } from './types.js';
427
+ export type { Task, SupportingFile, ExecutionResult, AgentConfig } from './types.js';
428
+ export type { WorkflowDefinition, WorkflowStage, WorkflowExecutionOptions } from './workflow-types.js';
@@ -1,7 +1,7 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import { join, dirname } from 'path';
3
- import type { SupportingFile } from './types';
4
- import { Logger } from './utils/logger';
3
+ import type { SupportingFile } from './types.js';
4
+ import { Logger } from './utils/logger.js';
5
5
 
6
6
  export interface TaskFile {
7
7
  name: string;
@@ -201,4 +201,4 @@ export class PostHogFileManager {
201
201
  await fs.writeFile(gitignorePath, gitignoreContent, 'utf8');
202
202
  }
203
203
  }
204
- }
204
+ }
@@ -1,6 +1,6 @@
1
1
  import { exec } from 'child_process';
2
2
  import { promisify } from 'util';
3
- import { Logger } from './utils/logger';
3
+ import { Logger } from './utils/logger.js';
4
4
 
5
5
  const execAsync = promisify(exec);
6
6
 
@@ -341,4 +341,4 @@ Generated by PostHog Agent`;
341
341
  throw new Error(`Failed to create PR: ${error}`);
342
342
  }
343
343
  }
344
- }
344
+ }
@@ -1,5 +1,5 @@
1
- import type { Task, SupportingFile, PostHogAPIConfig } from './types';
2
- import type { WorkflowDefinition, AgentDefinition } from './workflow-types';
1
+ import type { Task, SupportingFile, PostHogAPIConfig } from './types.js';
2
+ import type { WorkflowDefinition, AgentDefinition } from './workflow-types.js';
3
3
 
4
4
  interface PostHogApiResponse<T> {
5
5
  results?: T[];
@@ -166,4 +166,4 @@ export class PostHogAPIClient {
166
166
  body: JSON.stringify(options || {}),
167
167
  });
168
168
  }
169
- }
169
+ }
@@ -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
 
5
5
  export interface PromptBuilderDeps {
6
6
  getTaskFiles: (taskId: string) => Promise<any[]>;
@@ -90,4 +90,3 @@ export class PromptBuilder {
90
90
  }
91
91
 
92
92
 
93
-
@@ -1,13 +1,13 @@
1
1
  import { query } from '@anthropic-ai/claude-agent-sdk';
2
- import { Logger } from './utils/logger';
3
- import { EventTransformer } from './event-transformer';
4
- import { AgentRegistry } from './agent-registry';
5
- import type { Task } from './types';
6
- import type { WorkflowStage, WorkflowStageExecutionResult, WorkflowExecutionOptions } from './workflow-types';
7
- import { PLANNING_SYSTEM_PROMPT } from './agents/planning';
8
- import { EXECUTION_SYSTEM_PROMPT } from './agents/execution';
9
- import { PromptBuilder } from './prompt-builder';
10
- import { POSTHOG_MCP } from './utils/mcp';
2
+ import { Logger } from './utils/logger.js';
3
+ import { EventTransformer } from './event-transformer.js';
4
+ import { AgentRegistry } from './agent-registry.js';
5
+ import type { Task } from './types.js';
6
+ import type { WorkflowStage, WorkflowStageExecutionResult, WorkflowExecutionOptions } from './workflow-types.js';
7
+ import { PLANNING_SYSTEM_PROMPT } from './agents/planning.js';
8
+ import { EXECUTION_SYSTEM_PROMPT } from './agents/execution.js';
9
+ import { PromptBuilder } from './prompt-builder.js';
10
+ import { POSTHOG_MCP } from './utils/mcp.js';
11
11
 
12
12
  export class StageExecutor {
13
13
  private registry: AgentRegistry;
@@ -134,4 +134,3 @@ export class StageExecutor {
134
134
  }
135
135
  }
136
136
 
137
-
@@ -1,4 +1,4 @@
1
- import { promises as fs } from 'fs';
1
+ import { promises as fs, existsSync } from 'fs';
2
2
  import { join, dirname } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
 
@@ -17,7 +17,15 @@ export class TemplateManager {
17
17
  constructor() {
18
18
  const __filename = fileURLToPath(import.meta.url);
19
19
  const __dirname = dirname(__filename);
20
- this.templatesDir = join(__dirname, 'templates');
20
+ const candidateDirs = [
21
+ join(__dirname, 'templates'),
22
+ join(__dirname, '..', 'templates'),
23
+ join(__dirname, '..', '..', 'templates'),
24
+ join(__dirname, '..', '..', 'src', 'templates')
25
+ ];
26
+
27
+ const resolvedDir = candidateDirs.find((dir) => existsSync(dir));
28
+ this.templatesDir = resolvedDir ?? candidateDirs[0];
21
29
  }
22
30
 
23
31
  private async loadTemplate(templateName: string): Promise<string> {
@@ -146,4 +154,4 @@ Customize \`.posthog/.gitignore\` to control which files are committed:
146
154
  *Generated by PostHog Agent*
147
155
  `;
148
156
  }
149
- }
157
+ }
@@ -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
 
4
4
  export class WorkflowRegistry {
5
5
  private workflowsById: Map<string, WorkflowDefinition> = new Map();
@@ -28,4 +28,3 @@ export class WorkflowRegistry {
28
28
  }
29
29
  }
30
30
 
31
-
@@ -1,4 +1,4 @@
1
- import type { PermissionMode, AgentEvent } from './types';
1
+ import type { PermissionMode, AgentEvent } from './types.js';
2
2
 
3
3
  export type AgentType = 'planning' | 'execution' | 'review' | 'testing';
4
4
 
@@ -50,4 +50,3 @@ export interface WorkflowExecutionOptions {
50
50
  queryOverrides?: Record<string, any>;
51
51
  }
52
52
 
53
-
package/dist/example.js DELETED
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env bun
2
- import { config } from "dotenv";
3
- config();
4
- import { Agent, PermissionMode } from './src/agent';
5
- async function testAgent() {
6
- const REPO_PATH = process.argv[2] || process.cwd();
7
- const TASK_ID = process.argv[3];
8
- if (!process.env.POSTHOG_API_KEY) {
9
- console.error("❌ POSTHOG_API_KEY required");
10
- process.exit(1);
11
- }
12
- console.log(`📁 Working in: ${REPO_PATH}`);
13
- const agent = new Agent({
14
- workingDirectory: REPO_PATH,
15
- posthogApiUrl: process.env.POSTHOG_API_URL || "http://localhost:8010",
16
- posthogApiKey: process.env.POSTHOG_API_KEY,
17
- onEvent: (event) => {
18
- console.log(`[${event.type}]`, event);
19
- },
20
- debug: true,
21
- });
22
- if (TASK_ID) {
23
- console.log(`🎯 Running task: ${TASK_ID}`);
24
- try {
25
- // Example: list and run a workflow
26
- await agent['workflowRegistry'].loadWorkflows();
27
- const workflows = agent['workflowRegistry'].listWorkflows();
28
- if (workflows.length === 0) {
29
- throw new Error('No workflows available');
30
- }
31
- const selectedWorkflow = workflows[0];
32
- const options = {
33
- repositoryPath: REPO_PATH,
34
- permissionMode: PermissionMode.ACCEPT_EDITS,
35
- autoProgress: true,
36
- };
37
- const result = await agent.runWorkflow(TASK_ID, selectedWorkflow.id, options);
38
- console.log("✅ Done!");
39
- console.log(`📁 Plan stored in: .posthog/${TASK_ID}/plan.md`);
40
- }
41
- finally {
42
- }
43
- }
44
- else {
45
- console.log("❌ Please provide a task ID");
46
- }
47
- }
48
- testAgent().catch(console.error);
49
- //# sourceMappingURL=example.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"example.js","sourceRoot":"","sources":["../example.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,MAAM,EAAE,CAAC;AAET,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGpD,KAAK,UAAU,SAAS;IACpB,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACnD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEhC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,kBAAkB,SAAS,EAAE,CAAC,CAAC;IAE3C,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;QACpB,gBAAgB,EAAE,SAAS;QAC3B,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,uBAAuB;QACrE,aAAa,EAAE,OAAO,CAAC,GAAG,C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@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-types.js","sourceRoot":"","sources":["../../src/workflow-types.ts"],"names":[],"mappings":""}