@larkup/tool-video-intelligence 0.3.3 → 0.3.6

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.
@@ -1,43 +1,5 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
 
4
- usage() {
5
- echo "Usage: $0 <user-id> <monthly-source-minutes> [plan]" >&2
6
- echo "Requires LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT and LARKUP_VIDEO_ADMIN_TOKEN." >&2
7
- exit 64
8
- }
9
-
10
- USER_ID="${1:-}"
11
- SOURCE_MINUTES="${2:-}"
12
- PLAN="${3:-support-grant}"
13
-
14
- [[ -n "$USER_ID" && -n "$SOURCE_MINUTES" ]] || usage
15
- [[ "$USER_ID" =~ ^[A-Za-z0-9._-]{32,128}$ ]] || {
16
- echo "User ID must be the generated ID shown in Installed Tools." >&2
17
- exit 64
18
- }
19
- [[ "$SOURCE_MINUTES" =~ ^[0-9]+([.][0-9]+)?$ ]] || {
20
- echo "Monthly source minutes must be a non-negative number." >&2
21
- exit 64
22
- }
23
- [[ "$PLAN" =~ ^[A-Za-z0-9._-]{1,80}$ ]] || {
24
- echo "Plan may contain only letters, numbers, dots, underscores, and hyphens." >&2
25
- exit 64
26
- }
27
-
28
- ENDPOINT="${LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT:-}"
29
- ADMIN_TOKEN="${LARKUP_VIDEO_ADMIN_TOKEN:-}"
30
- [[ -n "$ENDPOINT" && -n "$ADMIN_TOKEN" ]] || {
31
- echo "Set LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT and LARKUP_VIDEO_ADMIN_TOKEN first." >&2
32
- exit 64
33
- }
34
-
35
- ENDPOINT="${ENDPOINT%/}"
36
- PAYLOAD=$(printf '{"sourceMinutesPerMonth":%s,"plan":"%s"}' "$SOURCE_MINUTES" "$PLAN")
37
-
38
- curl --fail-with-body --silent --show-error \
39
- --request POST "$ENDPOINT/v1/admin/devices/$USER_ID/entitlement" \
40
- --header 'Content-Type: application/json' \
41
- --header "X-Larkup-Admin-Token: $ADMIN_TOKEN" \
42
- --data "$PAYLOAD"
43
- echo
4
+ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
5
+ exec "$SCRIPT_DIR/manage-cloud-usage.sh" set "$@"
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ usage() {
5
+ cat >&2 <<'EOF'
6
+ Usage:
7
+ manage-cloud-usage.sh status <user-id>
8
+ manage-cloud-usage.sh reset <user-id>
9
+ manage-cloud-usage.sh set <user-id> <monthly-source-minutes> [plan]
10
+ manage-cloud-usage.sh add <user-id> <monthly-source-minutes> [plan]
11
+ manage-cloud-usage.sh remove <user-id> <monthly-source-minutes> [plan]
12
+ manage-cloud-usage.sh usage-set <user-id> <used-source-minutes>
13
+ manage-cloud-usage.sh usage-add <user-id> <used-source-minutes>
14
+ manage-cloud-usage.sh usage-remove <user-id> <used-source-minutes>
15
+
16
+ set/add/remove change the monthly allowance. reset clears current-period usage.
17
+ Requires LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT and LARKUP_VIDEO_ADMIN_TOKEN.
18
+ EOF
19
+ exit 64
20
+ }
21
+
22
+ ACTION="${1:-}"
23
+ USER_ID="${2:-}"
24
+ VALUE="${3:-}"
25
+ PLAN="${4:-support-grant}"
26
+
27
+ case "$ACTION" in
28
+ status|reset) [[ $# -eq 2 ]] || usage ;;
29
+ set|add|remove) [[ $# -ge 3 && $# -le 4 ]] || usage ;;
30
+ usage-set|usage-add|usage-remove) [[ $# -eq 3 ]] || usage ;;
31
+ *) usage ;;
32
+ esac
33
+
34
+ [[ "$USER_ID" =~ ^[A-Za-z0-9._-]{32,128}$ ]] || {
35
+ echo "User ID must be the generated ID shown in Installed Tools." >&2
36
+ exit 64
37
+ }
38
+ if [[ -n "$VALUE" ]]; then
39
+ [[ "$VALUE" =~ ^[0-9]+([.][0-9]+)?$ ]] || {
40
+ echo "Source minutes must be a non-negative number." >&2
41
+ exit 64
42
+ }
43
+ fi
44
+ [[ "$PLAN" =~ ^[A-Za-z0-9._-]{1,80}$ ]] || {
45
+ echo "Plan may contain only letters, numbers, dots, underscores, and hyphens." >&2
46
+ exit 64
47
+ }
48
+
49
+ ENDPOINT="${LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT:-}"
50
+ ADMIN_TOKEN="${LARKUP_VIDEO_ADMIN_TOKEN:-}"
51
+ [[ -n "$ENDPOINT" && -n "$ADMIN_TOKEN" ]] || {
52
+ echo "Set LARKUP_VIDEO_INTELLIGENCE_CLOUD_ENDPOINT and LARKUP_VIDEO_ADMIN_TOKEN first." >&2
53
+ exit 64
54
+ }
55
+ command -v jq >/dev/null || {
56
+ echo "jq is required." >&2
57
+ exit 69
58
+ }
59
+
60
+ ENDPOINT="${ENDPOINT%/}"
61
+ USAGE_URL="$ENDPOINT/v1/admin/devices/$USER_ID/usage"
62
+ ENTITLEMENT_URL="$ENDPOINT/v1/admin/devices/$USER_ID/entitlement"
63
+
64
+ request() {
65
+ local method="$1"
66
+ local url="$2"
67
+ local payload="${3:-}"
68
+ local args=(
69
+ --fail-with-body
70
+ --silent
71
+ --show-error
72
+ --request "$method"
73
+ "$url"
74
+ --header 'Content-Type: application/json'
75
+ --header "X-Larkup-Admin-Token: $ADMIN_TOKEN"
76
+ )
77
+ if [[ -n "$payload" ]]; then
78
+ args+=(--data "$payload")
79
+ fi
80
+ curl "${args[@]}"
81
+ }
82
+
83
+ case "$ACTION" in
84
+ status)
85
+ request GET "$USAGE_URL"
86
+ ;;
87
+ reset)
88
+ request POST "$USAGE_URL" '{"operation":"reset"}'
89
+ ;;
90
+ usage-set|usage-add|usage-remove)
91
+ operation="${ACTION#usage-}"
92
+ payload=$(jq -cn --arg operation "$operation" --argjson sourceMinutes "$VALUE" \
93
+ '{operation: $operation, sourceMinutes: $sourceMinutes}')
94
+ request POST "$USAGE_URL" "$payload"
95
+ ;;
96
+ set|add|remove)
97
+ target="$VALUE"
98
+ if [[ "$ACTION" != "set" ]]; then
99
+ current=$(request GET "$USAGE_URL" | jq -er '.sourceMinutesLimit | select(type == "number")') || {
100
+ echo "Cannot add to or remove from an unlimited monthly allowance; use set instead." >&2
101
+ exit 65
102
+ }
103
+ if [[ "$ACTION" == "add" ]]; then
104
+ target=$(jq -cn --argjson current "$current" --argjson amount "$VALUE" '$current + $amount')
105
+ else
106
+ target=$(jq -cn --argjson current "$current" --argjson amount "$VALUE" \
107
+ '[$current - $amount, 0] | max')
108
+ fi
109
+ fi
110
+ payload=$(jq -cn --argjson sourceMinutesPerMonth "$target" --arg plan "$PLAN" \
111
+ '{sourceMinutesPerMonth: $sourceMinutesPerMonth, plan: $plan}')
112
+ request POST "$ENTITLEMENT_URL" "$payload" >/dev/null
113
+ request GET "$USAGE_URL"
114
+ ;;
115
+ esac
116
+ echo
@@ -7,7 +7,7 @@
7
7
  "description": "Help your AI understand your videos, so you can ask questions and get answers from the right moments.",
8
8
  "longDescription": "Turn videos into knowledge your AI can understand. It listens to what is said, reads what appears on screen, and helps you find the moments that matter.",
9
9
  "category": "media",
10
- "version": "0.3.3",
10
+ "version": "0.3.6",
11
11
  "pricing": "free",
12
12
  "emoji": "🎥",
13
13
  "icon": "Film",
@@ -654,7 +654,7 @@
654
654
  "downloads": 0,
655
655
  "repositoryUrl": "https://github.com/Larkup-AI/larkup",
656
656
  "license": "Apache-2.0",
657
- "updatedAt": "2026-08-20",
657
+ "updatedAt": "2026-10-06",
658
658
  "trustLevel": "elevated",
659
659
  "permissions": {
660
660
  "httpAllow": [