@itpay/cli 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itpay/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "ItPay CLI, buyer skill, and agent-readable docs for agent-native commerce.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,8 +14,6 @@
14
14
  "docs/",
15
15
  "install.sh",
16
16
  "install.ps1",
17
- "smoke.sh",
18
- "e2e-local.sh",
19
17
  "README.md",
20
18
  "LICENSE"
21
19
  ],
@@ -28,7 +26,6 @@
28
26
  },
29
27
  "keywords": [
30
28
  "itpay",
31
- "voltagent",
32
29
  "agent",
33
30
  "cli",
34
31
  "claude-code",
package/e2e-local.sh DELETED
@@ -1,134 +0,0 @@
1
- #!/usr/bin/env sh
2
- set -eu
3
-
4
- ROOT=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
5
- API_BASE=${VOLTAGENT_API_BASE:-http://localhost:3000}
6
- NODE=${NODE:-$(command -v node)}
7
-
8
- TMP_HOME=$(mktemp -d "${TMPDIR:-/tmp}/voltagent-itp-e2e-home.XXXXXX")
9
- TMP_SETUP_HOME=$(mktemp -d "${TMPDIR:-/tmp}/voltagent-itp-setup-home.XXXXXX")
10
- TMP_SETUP_NOWAIT_HOME=$(mktemp -d "${TMPDIR:-/tmp}/voltagent-itp-setup-nowait-home.XXXXXX")
11
-
12
- cleanup() {
13
- rm -rf "$TMP_HOME" "$TMP_SETUP_HOME" "$TMP_SETUP_NOWAIT_HOME"
14
- }
15
- trap cleanup EXIT INT TERM
16
-
17
- itp_home() {
18
- itp_home_dir="$1"
19
- shift
20
- attempt=0
21
- while :; do
22
- err_file="$itp_home_dir/itp-error.log"
23
- if out=$(HOME="$itp_home_dir" PATH=/nonexistent VOLTAGENT_API_BASE="$API_BASE" "$NODE" "$ROOT/bin/itp" "$@" 2>"$err_file"); then
24
- printf '%s' "$out"
25
- return 0
26
- fi
27
- status=$?
28
- error_text=$(cat "$err_file" 2>/dev/null || true)
29
- attempt=$((attempt + 1))
30
- if [ "$attempt" -lt 6 ] && printf '%s' "$error_text" | grep -q 'request failed: 429'; then
31
- sleep "$attempt"
32
- continue
33
- fi
34
- printf '%s\n' "$error_text" >&2
35
- return "$status"
36
- done
37
- }
38
-
39
- itp() {
40
- itp_home "$TMP_HOME" "$@"
41
- }
42
-
43
- json_get() {
44
- "$NODE" -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{const v=JSON.parse(d); const path=process.argv[1].split('.'); let cur=v; for (const p of path) cur=cur?.[p]; if (cur === undefined || cur === null) process.exit(2); process.stdout.write(String(cur));})" "$1"
45
- }
46
-
47
- json_assert() {
48
- "$NODE" -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{const v=JSON.parse(d); const fn = new Function('v', process.argv[1]); if (!fn(v)) process.exit(1);})" "$1"
49
- }
50
-
51
- printf 'checking server %s\n' "$API_BASE" >&2
52
- curl -fsS "$API_BASE/api/status" >/dev/null
53
- curl -fsS "$API_BASE/api/itp/plans" | json_assert "return v.success === true && v.data.plans.some(p => p.plan_id === 'credit-100') && v.data.unit_rule === '1 credit = 1 CNY'" >/dev/null
54
-
55
- printf 'running one-command setup flow\n' >&2
56
- SETUP=$(itp_home "$TMP_SETUP_HOME" setup --credits 100 --method fake --mock-approve --allow-fake --offline --json)
57
- printf '%s' "$SETUP" | json_assert "return v.status === 'grant_ready' && v.target === 'generic' && v.grant_id && v.base_url && v.openai_base_url && v.credential && v.credential.stored === true && v.auth && v.auth.session_stored === true && v.runtime_install.status === 'skipped'"
58
- test ! -f "$TMP_SETUP_HOME/.codex/config.toml"
59
- TOKEN_FROM_SETUP=$(HOME="$TMP_SETUP_HOME" PATH=/nonexistent VOLTAGENT_API_BASE="$API_BASE" "$NODE" "$ROOT/bin/itp" token issue --grant "$(printf '%s' "$SETUP" | json_get grant_id)" --stdout)
60
- case "$TOKEN_FROM_SETUP" in
61
- sk-*) ;;
62
- *) echo "setup token issue did not return sk-* token" >&2; exit 1 ;;
63
- esac
64
-
65
- printf 'checking setup no-wait auth handoff\n' >&2
66
- SETUP_NOWAIT=$(itp_home "$TMP_SETUP_NOWAIT_HOME" setup --credits 100 --method fake --allow-fake --no-wait --json)
67
- printf '%s' "$SETUP_NOWAIT" | json_assert "return v.status === 'waiting_human_auth' && v.action === 'scan_alipay_auth' && v.run_id && v.auth_id && v.user_code && v.verification_uri_complete && v.human_action && v.human_action.display.length > 0"
68
- SETUP_NOWAIT_STATUS=$(itp_home "$TMP_SETUP_NOWAIT_HOME" status --json)
69
- printf '%s' "$SETUP_NOWAIT_STATUS" | json_assert "return v.status === 'waiting_human_auth' && v.run_id && v.auth_id && v.next && v.next.command.includes('resume')"
70
- SETUP_RESUMED=$(itp_home "$TMP_SETUP_NOWAIT_HOME" resume --mock-approve --allow-fake --offline --json)
71
- printf '%s' "$SETUP_RESUMED" | json_assert "return v.status === 'grant_ready' && v.run_id && v.grant_id && v.credential && v.credential.stored === true"
72
-
73
- USERNAME="e2e-$(date +%Y%m%d%H%M%S)-$$"
74
- printf 'registering %s\n' "$USERNAME" >&2
75
- AUTH=$(itp auth register --runtime codex --mock-approve --allow-fake --alipay-user-id "2088$RANDOM$RANDOM" --json)
76
- printf '%s' "$AUTH" | json_assert "return v.account_id && v.device_id && v.session_stored === true"
77
-
78
- ACCOUNT=$(itp account show --json)
79
- printf '%s' "$ACCOUNT" | json_assert "return v.password_set === false && v.account && v.account.account_id"
80
-
81
- printf 'setting first password\n' >&2
82
- printf 'secret123\n' | itp account set-password --password-stdin --json | json_assert "return v.password_set === true"
83
- ACCOUNT=$(itp account show --json)
84
- printf '%s' "$ACCOUNT" | json_assert "return v.password_set === true"
85
-
86
- printf 'creating fake checkout\n' >&2
87
- CHECKOUT=$(itp checkout create --credits 100 --method fake --allow-fake --idempotency-key "e2e-$USERNAME" --json)
88
- CHECKOUT_ID=$(printf '%s' "$CHECKOUT" | json_get checkout_id)
89
- GRANT_ID=$(printf '%s' "$CHECKOUT" | json_get grant_id)
90
- printf '%s' "$CHECKOUT" | json_assert "return v.status === 'grant_issued' && v.grant_id && !v.payment.cashier_url"
91
-
92
- printf 'waiting payment %s\n' "$CHECKOUT_ID" >&2
93
- PAYMENT=$(itp payment wait "$CHECKOUT_ID" --timeout 10 --json)
94
- printf '%s' "$PAYMENT" | json_assert "return v.status === 'grant_issued' && v.grant_id"
95
-
96
- printf 'installing grant %s\n' "$GRANT_ID" >&2
97
- INSTALL=$(itp grants install "$GRANT_ID" --target codex --json)
98
- printf '%s' "$INSTALL" | json_assert "return v.grant_id && v.credential && v.credential.credential_store"
99
-
100
- printf 'installing codex profile in temp HOME\n' >&2
101
- itp install codex --grant "$GRANT_ID" --offline --no-test --json | json_assert "return v.target === 'codex' && v.grant_id"
102
- test -f "$TMP_HOME/.codex/config.toml"
103
- test -f "$TMP_HOME/.itp/voltagent.env"
104
-
105
- BALANCE=$(itp balance --json)
106
- printf '%s' "$BALANCE" | json_assert "return v.active_grants === 1 && v.credits_remaining === '100.000000'"
107
-
108
- ORDERS=$(itp checkout list --limit 5 --json)
109
- printf '%s' "$ORDERS" | json_assert "return Array.isArray(v.orders) && v.orders.some(o => o.checkout_id === '$CHECKOUT_ID')"
110
-
111
- USAGE=$(itp usage --grant "$GRANT_ID" --json)
112
- printf '%s' "$USAGE" | json_assert "return v.grant_id === '$GRANT_ID' && v.total && v.total.requests === 0"
113
-
114
- printf 'rotating grant key\n' >&2
115
- ROTATE=$(itp keys rotate --grant "$GRANT_ID" --json)
116
- printf '%s' "$ROTATE" | json_assert "return v.grant_id === '$GRANT_ID' && v.credential && v.credential.credential_store"
117
- TOKEN=$(itp token issue --grant "$GRANT_ID" --stdout)
118
- case "$TOKEN" in
119
- sk-*) ;;
120
- *) echo "token issue did not return sk-* token" >&2; exit 1 ;;
121
- esac
122
-
123
- printf 'revoking grant\n' >&2
124
- REVOKE=$(itp grants revoke "$GRANT_ID" --json)
125
- printf '%s' "$REVOKE" | json_assert "return v.status === 'revoked'"
126
- BALANCE=$(itp balance --json)
127
- printf '%s' "$BALANCE" | json_assert "return v.active_grants === 0"
128
-
129
- printf 'voltagent local e2e ok\n'
130
- printf 'server: %s\n' "$API_BASE"
131
- printf 'account: %s\n' "$(printf '%s' "$AUTH" | json_get account_id)"
132
- printf 'checkout: %s\n' "$CHECKOUT_ID"
133
- printf 'grant: %s\n' "$GRANT_ID"
134
- printf 'temp_home_cleaned_on_exit: %s\n' "$TMP_HOME"