| 1 | set -uo pipefail |
| 2 | PM="/shared/projects/zion-pm" |
| 3 | TASK_ID="${1:?task-id}"; KIND="${2:?kind}"; PREVIEW="${3:?preview}" |
| 4 | OID="o-$(date +%s)-$RANDOM" |
| 5 | python3 - "$PM/state/outbox.json" "$OID" "$TASK_ID" "$KIND" "$PREVIEW" <<'PY' |
| 6 | import json,sys,time |
| 7 | path,oid,task,kind,preview=sys.argv[1:6] |
| 8 | try: o=json.load(open(path)) |
| 9 | except Exception: o={"pending":[],"history":[]} |
| 10 | o["pending"].append({"id":oid,"task":task,"kind":kind,"preview":preview, |
| 11 | "created":time.strftime("%Y-%m-%dT%H:%M:%S"),"decision":"pending"}) |
| 12 | json.dump(o,open(path,"w"),indent=2) |
| 13 | print(f"[pm] outbox queued {oid} ({kind}) for task {task} -> awaiting approval") |
| 14 | PY |