@pawlogic/dl 0.6.0 → 0.8.0

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/dl-npm-update.sh CHANGED
@@ -50,6 +50,32 @@ report_event() {
50
50
  if [ -f "$_verfile" ] && command -v node >/dev/null 2>&1; then
51
51
  _ver=$(node -e 'try{console.log(require("'"$_verfile"'").version||"")}catch(e){}' 2>/dev/null || echo "")
52
52
  fi
53
+ # 上下文维度: 全部从 hono-pi-e2b 注入的 PI_* env 里读 (e2b-operations.ts:582-627),
54
+ # 加上 E2B sandbox hostname (= sandbox ID)。校验只允许 [A-Za-z0-9_-], 防奇怪字符
55
+ # 破坏 JSON 后续没办法 escape; 不合法 / 空一律 null。
56
+ #
57
+ # 维度用途:
58
+ # - project_id per-project 去重 (COUNT_DISTINCT) 是 fleet 升级率口径
59
+ # - mode dramaland / ilands / ... 按产品线切升级率
60
+ # - user_tier starter / pro / ... 看付费用户升级率差异
61
+ # - user_id 单用户排障 (高基数)
62
+ # - prompt_id LLM turn 级聚合 (高基数)
63
+ # - tool_call_id 单次工具调用关联到自更新 outcome (高基数)
64
+ # - sandbox_id 单沙箱排障; E2B 内 hostname 就是 sandbox ID
65
+ _json_or_null() {
66
+ case "${1:-}" in
67
+ "") echo "null" ;;
68
+ *[!A-Za-z0-9_-]*) echo "null" ;;
69
+ *) printf '"%s"' "$1" ;;
70
+ esac
71
+ }
72
+ _proj_json=$(_json_or_null "${PI_PROJECT_ID:-}")
73
+ _mode_json=$(_json_or_null "${PI_MODE:-}")
74
+ _tier_json=$(_json_or_null "${PI_USER_TIER:-}")
75
+ _user_json=$(_json_or_null "${PI_USER_ID:-}")
76
+ _prompt_json=$(_json_or_null "${PI_PROMPT_ID:-}")
77
+ _toolcall_json=$(_json_or_null "${PI_TOOL_CALL_ID:-}")
78
+ _sandbox_json=$(_json_or_null "${HOSTNAME:-$(hostname 2>/dev/null || echo)}")
53
79
  # error_tail: 末尾 200 字节, JSON 不安全字符 (\ " 控制符 / 换行 / tab) 一律压成
54
80
  # 单空格; 长度上限挡住 LB 滥用,字符替换让 JSON 不需要复杂 escape。
55
81
  _err_json="null"
@@ -64,7 +90,7 @@ report_event() {
64
90
  curl -fsS -m 2 -X POST "${CALLBACK_SERVER_URL%/}/sandbox-rpc/dl/selfupdate-event" \
65
91
  -H 'content-type: application/json' \
66
92
  -H "authorization: Bearer ${DL_PROXY_TOKEN}" \
67
- -d "{\"trigger\":\"wrapper\",\"dist_tag\":\"$_tag\",\"outcome\":\"$_outcome\",\"duration_ms\":$_dur,\"installed_version\":\"$_ver\",\"build_short_sha\":null,\"error_tail\":$_err_json}" \
93
+ -d "{\"trigger\":\"wrapper\",\"dist_tag\":\"$_tag\",\"outcome\":\"$_outcome\",\"duration_ms\":$_dur,\"installed_version\":\"$_ver\",\"build_short_sha\":null,\"error_tail\":$_err_json,\"project_id\":$_proj_json,\"mode\":$_mode_json,\"user_tier\":$_tier_json,\"user_id\":$_user_json,\"prompt_id\":$_prompt_json,\"tool_call_id\":$_toolcall_json,\"sandbox_id\":$_sandbox_json}" \
68
94
  >/dev/null 2>&1 || true
69
95
  ) &
70
96
  }