@posthog/agent 2.3.74 → 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.74",
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",
@@ -3681,7 +3710,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3681
3710
  cwd,
3682
3711
  mcpServers,
3683
3712
  permissionMode,
3684
- canUseTool: this.createCanUseTool(sessionId),
3713
+ canUseTool: this.createCanUseTool(sessionId, meta?.allowedDomains),
3685
3714
  logger: this.logger,
3686
3715
  systemPrompt,
3687
3716
  userProvidedOptions: meta?.claudeCode?.options,
@@ -3811,7 +3840,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3811
3840
  );
3812
3841
  return { sessionId, modes, models, configOptions };
3813
3842
  }
3814
- createCanUseTool(sessionId) {
3843
+ createCanUseTool(sessionId, allowedDomains) {
3815
3844
  return async (toolName, toolInput, { suggestions, toolUseID, signal }) => canUseTool({
3816
3845
  session: this.session,
3817
3846
  toolName,
@@ -3823,7 +3852,8 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
3823
3852
  sessionId,
3824
3853
  fileContentCache: this.fileContentCache,
3825
3854
  logger: this.logger,
3826
- updateConfigOption: (configId, value) => this.updateConfigOption(configId, value)
3855
+ updateConfigOption: (configId, value) => this.updateConfigOption(configId, value),
3856
+ allowedDomains
3827
3857
  });
3828
3858
  }
3829
3859
  createOnModeChange() {