-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents.sh
More file actions
executable file
·46 lines (42 loc) · 1.83 KB
/
events.sh
File metadata and controls
executable file
·46 lines (42 loc) · 1.83 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
#!/usr/bin/env bash
# Event recording utility for profit agent
# Usage: source events.sh; record_event "event_type" "details" ["channel"] ["product_id"] ["agent"]
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
EVENTS_FILE="${EVENTS_FILE:-$SCRIPT_DIR/board/events.jsonl}"
record_event() {
local event_type="${1:?event_type required}"
local details="${2:-}"
local channel="${3:-}"
local product_id="${4:-}"
local agent="${5:-}"
local ts
ts=$(date -u +%Y-%m-%dT%H:%M:%SZ)
if command -v jq >/dev/null 2>&1; then
jq -nc \
--arg ts "$ts" \
--arg type "$event_type" \
--arg details "$details" \
--arg channel "$channel" \
--arg product_id "$product_id" \
--arg agent "$agent" \
--arg actor "autonomy414941" \
'{ts: $ts, type: $type, details: $details, channel: $channel, product_id: $product_id, agent: $agent, actor: $actor} | del(.[] | select(. == ""))' >> "$EVENTS_FILE"
else
printf '{"ts":"%s","type":"%s","details":"%s","agent":"%s","actor":"autonomy414941"}\n' \
"$ts" "$event_type" "$details" "$agent" >> "$EVENTS_FILE"
fi
}
# Valid event types:
# product_created - Built a product artifact
# product_published - Published to npm / marketplace
# service_deployed - Web service/API deployed
# external_install - Non-owner installed or downloaded
# external_interaction - Non-owner communicated (issue, comment)
# external_usage - Verified non-owner usage
# outreach_draft - Drafted outreach content (seller)
# human_task_created - Created a human-task issue
# seo_updated - Updated SEO/marketing on own properties (seller)
# reply_received - Got a reply from external human
# payment_received - Received payment from external party
# pivot - Changed strategy
# session_error - Session encountered a runtime error