@posthog/agent 2.3.256 → 2.3.261

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/agent.js CHANGED
@@ -245,7 +245,7 @@ import { v7 as uuidv7 } from "uuid";
245
245
  // package.json
246
246
  var package_default = {
247
247
  name: "@posthog/agent",
248
- version: "2.3.256",
248
+ version: "2.3.261",
249
249
  repository: "https://github.com/PostHog/code",
250
250
  description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
251
251
  exports: {
@@ -341,6 +341,7 @@ var package_default = {
341
341
  },
342
342
  dependencies: {
343
343
  "@agentclientprotocol/sdk": "0.16.1",
344
+ ajv: "^8.17.1",
344
345
  "@anthropic-ai/claude-agent-sdk": "0.2.76",
345
346
  "@anthropic-ai/sdk": "^0.78.0",
346
347
  "@hono/node-server": "^1.19.9",
@@ -2984,6 +2985,7 @@ function buildSessionOptions(params) {
2984
2985
  params.settingsManager,
2985
2986
  params.logger
2986
2987
  ),
2988
+ outputFormat: params.outputFormat,
2987
2989
  abortController: getAbortController(
2988
2990
  params.userProvidedOptions?.abortController
2989
2991
  ),
@@ -3571,6 +3573,11 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3571
3573
  };
3572
3574
  const result = handleResultMessage(message);
3573
3575
  if (result.error) throw result.error;
3576
+ if (message.subtype === "success" && message.structured_output != null && this.options?.onStructuredOutput) {
3577
+ await this.options.onStructuredOutput(
3578
+ message.structured_output
3579
+ );
3580
+ }
3574
3581
  if (isLocalOnlyCommand && message.subtype === "success" && message.result) {
3575
3582
  await this.client.sessionUpdate({
3576
3583
  sessionId: params.sessionId,
@@ -3796,6 +3803,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3796
3803
  const earlyModelId = settingsManager.getSettings().model || meta?.model || "";
3797
3804
  const mcpServers = supportsMcpInjection(earlyModelId) ? parseMcpServers(params) : {};
3798
3805
  const systemPrompt = buildSystemPrompt(meta?.systemPrompt);
3806
+ const outputFormat = meta?.jsonSchema && this.options?.onStructuredOutput ? { type: "json_schema", schema: meta.jsonSchema } : void 0;
3799
3807
  this.logger.info(isResume ? "Resuming session" : "Creating new session", {
3800
3808
  sessionId,
3801
3809
  taskId,
@@ -3819,6 +3827,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3819
3827
  ...meta?.additionalRoots ?? []
3820
3828
  ],
3821
3829
  disableBuiltInTools: meta?.disableBuiltInTools,
3830
+ outputFormat,
3822
3831
  settingsManager,
3823
3832
  onModeChange: this.createOnModeChange(),
3824
3833
  onProcessSpawned: this.options?.onProcessSpawned,
@@ -4781,7 +4790,10 @@ function createClaudeConnection(config) {
4781
4790
  const agentStream = ndJsonStream2(agentWritable, streams.agent.readable);
4782
4791
  let agent = null;
4783
4792
  const agentConnection = new AgentSideConnection((client) => {
4784
- agent = new ClaudeAcpAgent(client, config.processCallbacks);
4793
+ agent = new ClaudeAcpAgent(client, {
4794
+ ...config.processCallbacks,
4795
+ onStructuredOutput: config.onStructuredOutput
4796
+ });
4785
4797
  logger.info(`Created ${agent.adapterName} agent`);
4786
4798
  return agent;
4787
4799
  }, agentStream);
@@ -4974,6 +4986,15 @@ var PostHogAPIClient = class {
4974
4986
  }
4975
4987
  );
4976
4988
  }
4989
+ async setTaskRunOutput(taskId, runId, output) {
4990
+ return this.apiRequest(
4991
+ `/api/projects/${this.getTeamId()}/tasks/${taskId}/runs/${runId}/set_output/`,
4992
+ {
4993
+ method: "PATCH",
4994
+ body: JSON.stringify(output)
4995
+ }
4996
+ );
4997
+ }
4977
4998
  async appendTaskRunLog(taskId, runId, entries) {
4978
4999
  const teamId = this.getTeamId();
4979
5000
  return this.apiRequest(
@@ -5499,6 +5520,7 @@ var Agent = class {
5499
5520
  deviceType: "local",
5500
5521
  logger: this.logger,
5501
5522
  processCallbacks: options.processCallbacks,
5523
+ onStructuredOutput: options.onStructuredOutput,
5502
5524
  allowedModelIds,
5503
5525
  codexOptions: options.adapter === "codex" && gatewayConfig ? {
5504
5526
  cwd: options.repositoryPath,