@posthog/agent 2.3.73 → 2.3.80

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
@@ -281,7 +281,7 @@ import { v7 as uuidv7 } from "uuid";
281
281
  // package.json
282
282
  var package_default = {
283
283
  name: "@posthog/agent",
284
- version: "2.3.73",
284
+ version: "2.3.80",
285
285
  repository: "https://github.com/PostHog/code",
286
286
  description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
287
287
  exports: {
@@ -2512,8 +2512,37 @@ function handlePlanFileException(context) {
2512
2512
  updatedInput: toolInput
2513
2513
  };
2514
2514
  }
2515
+ function extractDomainFromUrl(url) {
2516
+ try {
2517
+ return new URL(url).hostname;
2518
+ } catch {
2519
+ return null;
2520
+ }
2521
+ }
2522
+ function isDomainAllowed(hostname, allowedDomains) {
2523
+ return allowedDomains.some((pattern) => {
2524
+ if (pattern.startsWith("*.")) {
2525
+ const suffix = pattern.slice(1);
2526
+ return hostname === pattern.slice(2) || hostname.endsWith(suffix);
2527
+ }
2528
+ return hostname === pattern;
2529
+ });
2530
+ }
2515
2531
  async function canUseTool(context) {
2516
- const { toolName, toolInput, session } = context;
2532
+ const { toolName, toolInput, session, allowedDomains } = context;
2533
+ if (allowedDomains && allowedDomains.length > 0) {
2534
+ if (toolName === "WebFetch" || toolName === "WebSearch") {
2535
+ const url = toolInput.url;
2536
+ if (url) {
2537
+ const hostname = extractDomainFromUrl(url);
2538
+ if (hostname && !isDomainAllowed(hostname, allowedDomains)) {
2539
+ const message = `Domain "${hostname}" is not in the allowed list: ${allowedDomains.join(", ")}`;
2540
+ await emitToolDenial(context, message);
2541
+ return { behavior: "deny", message, interrupt: false };
2542
+ }
2543
+ }
2544
+ }
2545
+ }
2517
2546
  if (isToolAllowedForMode(toolName, session.permissionMode)) {
2518
2547
  return {
2519
2548
  behavior: "allow",
@@ -2843,6 +2872,7 @@ function buildSessionOptions(params) {
2843
2872
  const tools = params.userProvidedOptions?.tools ?? (params.disableBuiltInTools ? [] : { type: "preset", preset: "claude_code" });
2844
2873
  const options = {
2845
2874
  ...params.userProvidedOptions,
2875
+ betas: ["context-1m-2025-08-07"],
2846
2876
  systemPrompt: params.systemPrompt ?? buildSystemPrompt(),
2847
2877
  settingSources: ["user", "project", "local"],
2848
2878
  stderr: (err) => params.logger.error(err),
@@ -3680,7 +3710,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3680
3710
  cwd,
3681
3711
  mcpServers,
3682
3712
  permissionMode,
3683
- canUseTool: this.createCanUseTool(sessionId),
3713
+ canUseTool: this.createCanUseTool(sessionId, meta?.allowedDomains),
3684
3714
  logger: this.logger,
3685
3715
  systemPrompt,
3686
3716
  userProvidedOptions: meta?.claudeCode?.options,
@@ -3810,7 +3840,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3810
3840
  );
3811
3841
  return { sessionId, modes, models, configOptions };
3812
3842
  }
3813
- createCanUseTool(sessionId) {
3843
+ createCanUseTool(sessionId, allowedDomains) {
3814
3844
  return async (toolName, toolInput, { suggestions, toolUseID, signal }) => canUseTool({
3815
3845
  session: this.session,
3816
3846
  toolName,
@@ -3822,7 +3852,8 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3822
3852
  sessionId,
3823
3853
  fileContentCache: this.fileContentCache,
3824
3854
  logger: this.logger,
3825
- updateConfigOption: (configId, value) => this.updateConfigOption(configId, value)
3855
+ updateConfigOption: (configId, value) => this.updateConfigOption(configId, value),
3856
+ allowedDomains
3826
3857
  });
3827
3858
  }
3828
3859
  createOnModeChange() {