From c3b9ecedb4ec4ce5ab56918c6333f68dd8782294 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 22 Mar 2026 19:47:00 +0000
Subject: [PATCH 1/5] Initial plan
From 717e76f6de8967f96d97a5ea1782d735572d26b5 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Sun, 22 Mar 2026 20:24:09 +0000
Subject: [PATCH 2/5] feat: add dispatch_repository safe-output type for
repository_dispatch events
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/a736f787-d406-4bb4-a907-eab2bc837100
---
actions/setup/js/dispatch_repository.cjs | 183 ++++++
.../setup/js/safe_output_handler_manager.cjs | 1 +
.../setup/js/safe_outputs_mcp_server_http.cjs | 22 +-
.../setup/js/safe_outputs_tools_loader.cjs | 35 +
pkg/parser/schemas/main_workflow_schema.json | 97 +++
pkg/workflow/compiler.go | 6 +
pkg/workflow/compiler_safe_outputs_config.go | 20 +
pkg/workflow/compiler_types.go | 1 +
pkg/workflow/dispatch_repository.go | 228 +++++++
pkg/workflow/dispatch_repository_test.go | 602 ++++++++++++++++++
.../dispatch_repository_validation.go | 107 ++++
pkg/workflow/safe_outputs_config.go | 6 +
.../safe_outputs_config_generation.go | 29 +
pkg/workflow/safe_outputs_state.go | 1 +
pkg/workflow/safe_outputs_tools_filtering.go | 35 +
pkg/workflow/unified_prompt_step.go | 3 +
16 files changed, 1375 insertions(+), 1 deletion(-)
create mode 100644 actions/setup/js/dispatch_repository.cjs
create mode 100644 pkg/workflow/dispatch_repository.go
create mode 100644 pkg/workflow/dispatch_repository_test.go
create mode 100644 pkg/workflow/dispatch_repository_validation.go
diff --git a/actions/setup/js/dispatch_repository.cjs b/actions/setup/js/dispatch_repository.cjs
new file mode 100644
index 00000000000..8848d11ecb6
--- /dev/null
+++ b/actions/setup/js/dispatch_repository.cjs
@@ -0,0 +1,183 @@
+// @ts-check
+///
+
+/**
+ * @typedef {import('./types/handler-factory').HandlerFactoryFunction} HandlerFactoryFunction
+ */
+
+/** @type {string} Safe output type handled by this module */
+const HANDLER_TYPE = "dispatch_repository";
+
+const { getErrorMessage } = require("./error_helpers.cjs");
+const { createAuthenticatedGitHubClient } = require("./handler_auth.cjs");
+const { parseRepoSlug, validateTargetRepo, parseAllowedRepos } = require("./repo_helpers.cjs");
+const { logStagedPreviewInfo } = require("./staged_preview.cjs");
+const { isStagedMode } = require("./safe_output_helpers.cjs");
+
+/**
+ * Main handler factory for dispatch_repository
+ * Returns a message handler function that processes individual dispatch_repository messages
+ * @type {HandlerFactoryFunction}
+ */
+async function main(config = {}) {
+ const tools = config.tools || {};
+ const githubClient = await createAuthenticatedGitHubClient(config);
+ const isStaged = isStagedMode(config);
+
+ const contextRepoSlug = `${context.repo.owner}/${context.repo.repo}`;
+ core.info(`dispatch_repository handler initialized: tools=${Object.keys(tools).join(", ")}, context_repo=${contextRepoSlug}`);
+
+ // Per-tool dispatch counters for max enforcement
+ /** @type {Record} */
+ const dispatchCounts = {};
+
+ /**
+ * Message handler function that processes a single dispatch_repository message
+ * @param {Object} message - The dispatch_repository message to process
+ * @param {Object} resolvedTemporaryIds - Map of temporary IDs to resolved values
+ * @returns {Promise