Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
258 lines (245 loc) · 11.4 KB
/
Copy pathaction.yml
File metadata and controls
258 lines (245 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: Murmur Spawn
description: >-
Spawn a murmur agent from a GitHub workflow, optionally wait for it, and return
its structured output. A composite action that runs the published murmur CLI
image (docker run … --json) and parses the typed JSON into step outputs,
authenticated with a service-profile API key (mur_…).
inputs:
api-key:
description: A mur_-prefixed service-profile API key. Pass via a secret, never inline.
required: true
api-address:
description: >-
murmur-api gRPC address as host:port (e.g. api.murmur.dev:9090), set on
MURMUR_API_ADDRESS. Leave empty to use the CLI's built-in production
default (api.murmur.dev:9090, TLS on). This is NOT the /mcp HTTP URL the
old composite action took — the CLI speaks gRPC.
required: false
default: ""
workspace:
description: Murmur workspace the agent runs in.
required: true
prompt:
description: The agent task description.
required: true
slug:
description: >-
Agent slug. Required (no silent default) — give re-runs a distinct,
meaningful slug. A run-scoped value such as
"gha-<github.run_id>-<github.run_attempt>" works well; build it in the
caller workflow (action.yml metadata cannot read the github context).
required: true
agent-persona:
description: Agent persona name (resolved from the tenant catalog). Optional.
required: false
default: ""
output-schema:
description: >-
JSON Schema for the agent's structured answer — inline JSON, or @path to
read from a file in the checkout (the action's working directory is the
checked-out repo). The schema-validated result is returned on the
structured-output output.
required: false
default: ""
expected-output:
description: 'Expected artifact: respond, pr, push, diff, report, none, or freeform text.'
required: false
default: respond
on-idle:
description: >-
What the agent does once it goes idle: terminate (default — tears the agent
down so a CI spawn leaves nothing lingering), sleep (stays reachable for
follow-ups/event wakes), or keep-alive (keep_alive also accepted). CI
spawns are one-shot, so the default is terminate. A persistent per-PR
worker overrides this to sleep.
required: false
default: terminate
force-new:
description: >-
Start a fresh agent even if one with this slug already exists (e.g. a dead
agent left over from a prior, since-closed PR that reused the slug). Maps to
`murmur spawn --force-new`.
required: false
default: "false"
wait:
description: >-
Block until the agent reaches a terminal/at-rest phase and surface its
outputs (default). Set to "false" to fire-and-return: the action spawns the
agent and exits immediately, emitting only agent-ref. Use false for a
persistent worker that reports asynchronously (e.g. posts its own PR
comment), so the CI step stays a thin RPC instead of blocking for the whole
run.
required: false
default: "true"
model:
description: Model override. Optional.
required: false
default: ""
reasoning-effort:
description: 'Reasoning effort: low, medium, high, xhigh, max. Optional.'
required: false
default: ""
purpose:
description: One-sentence human-readable goal shown in the dashboard. Optional.
required: false
default: ""
tags:
description: >-
Comma-separated tag names to attach for dashboard grouping/filtering
(e.g. "ci,pr-verify"). Maps to repeated `murmur spawn --tag`. Each tag
must be a DNS-label slug (^[a-z0-9][a-z0-9-]{0,62}$), max 8 per agent —
the server rejects a non-conforming or over-cap set loudly. A tag that
does not yet exist is created. Optional.
required: false
default: ""
timeout:
description: >-
With wait=true, max seconds to block before failing the step (a client
deadline; 0 = no client deadline).
required: false
default: "600"
outputs:
structured-output:
description: The caller-schema result as a JSON string (empty if no output-schema was given).
value: ${{ steps.run.outputs.structured-output }}
response:
description: The agent's human-readable response summary.
value: ${{ steps.run.outputs.response }}
agent-ref:
description: The slug of the spawned agent.
value: ${{ steps.run.outputs.agent-ref }}
phase:
description: The agent's terminal/at-rest phase (empty when wait=false).
value: ${{ steps.run.outputs.phase }}
is-error:
description: '"true" if the agent run errored (empty when wait=false).'
value: ${{ steps.run.outputs.is-error }}
runs:
# Composite, not a Docker container action: a container action's process is the
# only thing that runs, so it cannot post-process the CLI's output. A composite
# has steps, so it runs the published murmur-cli image with `docker run … --json`
# and a shell step parses the typed JSON into the action's outputs. The CLI
# stays format-agnostic (just --json); the GHA-output glue lives here.
using: composite
steps:
- id: run
shell: bash
env:
MURMUR_API_KEY: ${{ inputs.api-key }}
MURMUR_API_ADDRESS: ${{ inputs.api-address }}
# Pinned by digest so an action ref names exactly one CLI build: a
# caller who pins this action to a commit SHA gets the same image on
# every run. The tag is for readers; Docker resolves the digest. Bump
# all three actions (spawn, queue-add, kill) together to a released
# `vMAJOR.MINOR` image, which must stay within the server's
# MinClientVersion.
MURMUR_IMAGE: ghcr.io/prassoai/murmur-cli:v319.2@sha256:c4df4033475a70a0186188d4606c0c2ae820e7a8ea6ae002f992ab25b1a08c33
IN_WORKSPACE: ${{ inputs.workspace }}
IN_SLUG: ${{ inputs.slug }}
IN_PROMPT: ${{ inputs.prompt }}
IN_AGENT: ${{ inputs.agent-persona }}
IN_OUT: ${{ inputs.expected-output }}
IN_ON_IDLE: ${{ inputs.on-idle }}
IN_FORCE_NEW: ${{ inputs.force-new }}
IN_WAIT: ${{ inputs.wait }}
IN_MODEL: ${{ inputs.model }}
IN_REASONING: ${{ inputs.reasoning-effort }}
IN_PURPOSE: ${{ inputs.purpose }}
IN_TAGS: ${{ inputs.tags }}
IN_OUTPUT_SCHEMA: ${{ inputs.output-schema }}
IN_TIMEOUT: ${{ inputs.timeout }}
run: |
set -euo pipefail
# Fail loud up front if a required tool is missing, rather than spawning
# the agent and then crashing mid-parse: docker runs the CLI image, and
# (when --wait) jq parses the AgentStatus and openssl mints the heredoc
# delimiter for the multiline outputs.
for cmd in docker jq openssl; do
command -v "$cmd" >/dev/null || { echo "::error::$cmd is required to run this action" >&2; exit 1; }
done
# slug_log = slug with CR/LF stripped, for safe use in log lines and the
# agent-ref $GITHUB_OUTPUT — a workflow command (::error::…) or an output
# line begins at a newline, so an untrusted slug containing "\n::error::…"
# could otherwise forge one. The raw $IN_SLUG still goes to the CLI.
slug_log=${IN_SLUG//[$'\n\r']/}
# --tag is repeatable on the CLI; the action's tags input is a
# comma-separated list. Each element is trimmed of leading/trailing
# whitespace ONLY — interior whitespace is preserved so a malformed tag
# like "prod us" reaches the server and is rejected loudly (DNS-label
# slug, max 8) instead of being silently rewritten to "produs". Empty
# elements are dropped. The ${arr[@]+…} expansion keeps `set -u` happy
# on an empty array under pre-4.4 bash.
# read -d '' consumes the whole input (not just the first line, which
# would silently truncate a multiline value) and returns nonzero at
# EOF — hence the || true; the array is populated regardless.
tag_args=()
IFS=',' read -rd '' -a tags <<<"$IN_TAGS" || true
for t in "${tags[@]}"; do
t="${t#"${t%%[![:space:]]*}"}"
t="${t%"${t##*[![:space:]]}"}"
[ -n "$t" ] && tag_args+=("--tag=$t")
done
# Spawn the agent. Never --wait here: agent-ref must be emitted before any
# blocking wait, so a downstream step can reference (or tear down) the
# agent even if the wait below times out. The workspace is mounted so an
# --output-schema=@path resolves against the checkout. The mur_ key is
# forwarded by name (-e), never on the command line. -- terminates flags
# so a slug/prompt starting with "-" is never read as one.
docker run --rm \
-e MURMUR_API_KEY -e MURMUR_API_ADDRESS \
-v "$GITHUB_WORKSPACE":/github/workspace -w /github/workspace \
"$MURMUR_IMAGE" spawn --json \
"--workspace=$IN_WORKSPACE" "--agent=$IN_AGENT" "--out=$IN_OUT" \
"--on-idle=$IN_ON_IDLE" "--force-new=$IN_FORCE_NEW" \
"--model=$IN_MODEL" "--reasoning-effort=$IN_REASONING" \
"--purpose=$IN_PURPOSE" "--output-schema=$IN_OUTPUT_SCHEMA" \
${tag_args[@]+"${tag_args[@]}"} \
-- "$IN_SLUG" "$IN_PROMPT" >/dev/null
echo "agent-ref=$slug_log" >>"$GITHUB_OUTPUT"
if [ "$IN_WAIT" != "true" ]; then
echo "Spawned '$slug_log' (wait=false); not blocking on completion." >&2
exit 0
fi
# Block until the agent is terminal or at rest. --timeout bounds the wait;
# on expiry the CLI exits non-zero and this step fails with no turn
# outputs written — a still-running agent has no terminal result, so an
# `if: always()` consumer must not read partial data.
status_json=$(docker run --rm \
-e MURMUR_API_KEY -e MURMUR_API_ADDRESS \
"$MURMUR_IMAGE" wait --json \
"--workspace=$IN_WORKSPACE" "--timeout=$IN_TIMEOUT" -- "$IN_SLUG")
# `wait --json` prints the AgentStatus as protojson (camelCase keys).
phase=$(jq -r '.phase // ""' <<<"$status_json")
is_error=$(jq -r '.output.isError // false' <<<"$status_json")
response=$(jq -r '.output.response // ""' <<<"$status_json")
structured=$(jq -r '.output.structuredOutput // ""' <<<"$status_json")
# printf + a random heredoc delimiter so a multiline value (a response or
# a JSON structured-output) round-trips verbatim.
emit_multiline() {
local name="$1" value="$2" delim
delim="ghadelim_$(openssl rand -hex 16)"
{
echo "${name}<<${delim}"
printf '%s\n' "$value"
echo "$delim"
} >>"$GITHUB_OUTPUT"
}
{
echo "phase=$phase"
echo "is-error=$is_error"
} >>"$GITHUB_OUTPUT"
emit_multiline response "$response"
emit_multiline structured-output "$structured"
echo "Agent '$slug_log' finished in phase '$phase' (is_error=$is_error)." >&2
# Fail the step on an agent-reported error or a terminal failure phase,
# after outputs are written (so an `if: always()` step still sees them).
if [ "$is_error" = "true" ]; then
echo "::error::murmur agent '$slug_log' reported an error result" >&2
exit 1
fi
case "$phase" in
PHASE_FAILED | PHASE_CANCELED)
echo "::error::murmur agent '$slug_log' ended in phase $phase" >&2
exit 1
;;
esac