@posthog/agent 2.3.169 → 2.3.171
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 +52 -11
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.js +1 -1
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +50 -10
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +50 -10
- package/dist/server/bin.cjs.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/adapters/codex/codex-agent.ts +40 -9
- package/src/adapters/codex/codex-client.ts +19 -2
- package/src/adapters/codex/spawn.ts +8 -0
- package/src/agent.ts +1 -0
- package/src/types.ts +1 -0
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.
|
|
248
|
+
version: "2.3.171",
|
|
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: {
|
|
@@ -4161,6 +4161,22 @@ function createCodexClient(upstreamClient, logger, sessionState, callbacks) {
|
|
|
4161
4161
|
const size = update.size;
|
|
4162
4162
|
if (used !== void 0) sessionState.contextUsed = used;
|
|
4163
4163
|
if (size !== void 0) sessionState.contextSize = size;
|
|
4164
|
+
const inputTokens = update.inputTokens;
|
|
4165
|
+
const outputTokens = update.outputTokens;
|
|
4166
|
+
if (inputTokens !== void 0) {
|
|
4167
|
+
sessionState.accumulatedUsage.inputTokens += inputTokens;
|
|
4168
|
+
}
|
|
4169
|
+
if (outputTokens !== void 0) {
|
|
4170
|
+
sessionState.accumulatedUsage.outputTokens += outputTokens;
|
|
4171
|
+
}
|
|
4172
|
+
const cachedRead = update.cachedReadTokens;
|
|
4173
|
+
const cachedWrite = update.cachedWriteTokens;
|
|
4174
|
+
if (cachedRead !== void 0) {
|
|
4175
|
+
sessionState.accumulatedUsage.cachedReadTokens += cachedRead;
|
|
4176
|
+
}
|
|
4177
|
+
if (cachedWrite !== void 0) {
|
|
4178
|
+
sessionState.accumulatedUsage.cachedWriteTokens += cachedWrite;
|
|
4179
|
+
}
|
|
4164
4180
|
callbacks?.onUsageUpdate?.(update);
|
|
4165
4181
|
}
|
|
4166
4182
|
await upstreamClient.sessionUpdate(params);
|
|
@@ -4340,6 +4356,10 @@ function buildConfigArgs(options) {
|
|
|
4340
4356
|
if (options.model) {
|
|
4341
4357
|
args.push("-c", `model="${options.model}"`);
|
|
4342
4358
|
}
|
|
4359
|
+
if (options.instructions) {
|
|
4360
|
+
const escaped = options.instructions.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
4361
|
+
args.push("-c", `instructions="${escaped}"`);
|
|
4362
|
+
}
|
|
4343
4363
|
return args;
|
|
4344
4364
|
}
|
|
4345
4365
|
function findCodexBinary(options) {
|
|
@@ -4566,17 +4586,37 @@ var CodexAcpAgent = class extends BaseAcpAgent {
|
|
|
4566
4586
|
resetUsage(this.sessionState);
|
|
4567
4587
|
}
|
|
4568
4588
|
const response = await this.codexConnection.prompt(params);
|
|
4569
|
-
if (this.sessionState
|
|
4570
|
-
|
|
4589
|
+
if (this.sessionState && response.usage) {
|
|
4590
|
+
this.sessionState.accumulatedUsage.inputTokens += response.usage.inputTokens ?? 0;
|
|
4591
|
+
this.sessionState.accumulatedUsage.outputTokens += response.usage.outputTokens ?? 0;
|
|
4592
|
+
this.sessionState.accumulatedUsage.cachedReadTokens += response.usage.cachedReadTokens ?? 0;
|
|
4593
|
+
this.sessionState.accumulatedUsage.cachedWriteTokens += response.usage.cachedWriteTokens ?? 0;
|
|
4594
|
+
}
|
|
4595
|
+
if (this.sessionState?.taskRunId) {
|
|
4596
|
+
const { accumulatedUsage } = this.sessionState;
|
|
4597
|
+
await this.client.extNotification(POSTHOG_NOTIFICATIONS.TURN_COMPLETE, {
|
|
4571
4598
|
sessionId: params.sessionId,
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4599
|
+
stopReason: response.stopReason ?? "end_turn",
|
|
4600
|
+
usage: {
|
|
4601
|
+
inputTokens: accumulatedUsage.inputTokens,
|
|
4602
|
+
outputTokens: accumulatedUsage.outputTokens,
|
|
4603
|
+
cachedReadTokens: accumulatedUsage.cachedReadTokens,
|
|
4604
|
+
cachedWriteTokens: accumulatedUsage.cachedWriteTokens,
|
|
4605
|
+
totalTokens: accumulatedUsage.inputTokens + accumulatedUsage.outputTokens + accumulatedUsage.cachedReadTokens + accumulatedUsage.cachedWriteTokens
|
|
4606
|
+
}
|
|
4579
4607
|
});
|
|
4608
|
+
if (response.usage) {
|
|
4609
|
+
await this.client.extNotification("_posthog/usage_update", {
|
|
4610
|
+
sessionId: params.sessionId,
|
|
4611
|
+
used: {
|
|
4612
|
+
inputTokens: response.usage.inputTokens ?? 0,
|
|
4613
|
+
outputTokens: response.usage.outputTokens ?? 0,
|
|
4614
|
+
cachedReadTokens: response.usage.cachedReadTokens ?? 0,
|
|
4615
|
+
cachedWriteTokens: response.usage.cachedWriteTokens ?? 0
|
|
4616
|
+
},
|
|
4617
|
+
cost: null
|
|
4618
|
+
});
|
|
4619
|
+
}
|
|
4580
4620
|
}
|
|
4581
4621
|
return response;
|
|
4582
4622
|
}
|
|
@@ -5393,7 +5433,8 @@ var Agent = class {
|
|
|
5393
5433
|
apiBaseUrl: `${gatewayConfig.gatewayUrl}/v1`,
|
|
5394
5434
|
apiKey: gatewayConfig.apiKey,
|
|
5395
5435
|
binaryPath: options.codexBinaryPath,
|
|
5396
|
-
model: sanitizedModel
|
|
5436
|
+
model: sanitizedModel,
|
|
5437
|
+
instructions: options.instructions
|
|
5397
5438
|
} : void 0
|
|
5398
5439
|
});
|
|
5399
5440
|
return this.acpConnection;
|