@telvine/cli 0.1.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/README.md +34 -0
- package/dist/keytar-f6bnxfss.node +0 -0
- package/dist/telvine.js +14862 -0
- package/package.json +59 -0
- package/src/templates/wrapper.py +75 -0
- package/src/templates/wrapper.sh +59 -0
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@telvine/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Telvine CLI - instrument SKILL.md capabilities inside agent plugins",
|
|
5
|
+
"homepage": "https://telvine.com",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/telvinehq/telvine.git",
|
|
10
|
+
"directory": "apps/cli"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/telvinehq/telvine/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"agent-plugin",
|
|
17
|
+
"ai-agent",
|
|
18
|
+
"plugin-telemetry",
|
|
19
|
+
"plugin-analytics",
|
|
20
|
+
"copilot-cowork",
|
|
21
|
+
"codex-plugin",
|
|
22
|
+
"claude-plugin",
|
|
23
|
+
"mcp",
|
|
24
|
+
"skill-md",
|
|
25
|
+
"llm-tools"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"bin": {
|
|
29
|
+
"telvine": "./dist/telvine.js"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"src/templates"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "bun build src/telvine.ts --target=node --outdir=dist --banner='#!/usr/bin/env node'",
|
|
40
|
+
"dev": "tsx src/telvine.ts",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"start": "node dist/telvine.js"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@inquirer/prompts": "^7.0.0",
|
|
46
|
+
"clipanion": "^4.0.0-rc.4",
|
|
47
|
+
"gray-matter": "^4.0.3",
|
|
48
|
+
"keytar": "^7.9.0",
|
|
49
|
+
"open": "^10.1.0",
|
|
50
|
+
"picocolors": "^1.1.1",
|
|
51
|
+
"typanion": "^3.14.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@telvine/schema": "workspace:0.1.0",
|
|
55
|
+
"@types/node": "^22.7.5",
|
|
56
|
+
"tsx": "^4.19.1",
|
|
57
|
+
"typescript": "^5.6.3"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Telvine script wrapper. Generated by `telvine publish` — do not edit by hand."""
|
|
2
|
+
import os, sys, time, uuid, json, urllib.request, urllib.error
|
|
3
|
+
from contextlib import contextmanager
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
_TELVINE_API = "https://api.telvine.com/v1/events"
|
|
7
|
+
_TELVINE_INSTALL_FILE = Path.home() / ".telvine" / "install_id"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _install_id() -> str:
|
|
11
|
+
try:
|
|
12
|
+
if _TELVINE_INSTALL_FILE.exists():
|
|
13
|
+
return _TELVINE_INSTALL_FILE.read_text().strip()
|
|
14
|
+
_TELVINE_INSTALL_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
15
|
+
new_id = f"inst_{uuid.uuid4().hex[:16]}"
|
|
16
|
+
_TELVINE_INSTALL_FILE.write_text(new_id)
|
|
17
|
+
return new_id
|
|
18
|
+
except Exception:
|
|
19
|
+
return f"inst_{uuid.uuid4().hex[:16]}"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _post(event: dict) -> None:
|
|
23
|
+
key = os.environ.get("TELVINE_WRITE_KEY")
|
|
24
|
+
if not key:
|
|
25
|
+
return
|
|
26
|
+
req = urllib.request.Request(
|
|
27
|
+
_TELVINE_API,
|
|
28
|
+
data=json.dumps(event).encode("utf-8"),
|
|
29
|
+
headers={
|
|
30
|
+
"Content-Type": "application/json",
|
|
31
|
+
"Authorization": f"Bearer {key}",
|
|
32
|
+
},
|
|
33
|
+
method="POST",
|
|
34
|
+
)
|
|
35
|
+
try:
|
|
36
|
+
urllib.request.urlopen(req, timeout=2).read()
|
|
37
|
+
except (urllib.error.URLError, TimeoutError, Exception):
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@contextmanager
|
|
42
|
+
def _telvine_track(script_name: str):
|
|
43
|
+
start_ns = time.monotonic_ns()
|
|
44
|
+
exit_code = 0
|
|
45
|
+
try:
|
|
46
|
+
yield
|
|
47
|
+
except SystemExit as e:
|
|
48
|
+
exit_code = int(e.code) if isinstance(e.code, int) else (0 if e.code is None else 1)
|
|
49
|
+
raise
|
|
50
|
+
except Exception:
|
|
51
|
+
exit_code = 1
|
|
52
|
+
raise
|
|
53
|
+
finally:
|
|
54
|
+
event = {
|
|
55
|
+
"event_type": "skill.script.invoked",
|
|
56
|
+
"skill_id": os.environ.get("TELVINE_SKILL_ID", "skl_unknown"),
|
|
57
|
+
"version": os.environ.get("TELVINE_SKILL_VERSION", "0.0.0"),
|
|
58
|
+
"installation_id": _install_id(),
|
|
59
|
+
"occurred_at": time.strftime("%Y-%m-%dT%H:%M:%S+00:00", time.gmtime()),
|
|
60
|
+
"idempotency_key": str(uuid.uuid4()),
|
|
61
|
+
"properties": {
|
|
62
|
+
"script_name": script_name,
|
|
63
|
+
"exit_code": exit_code,
|
|
64
|
+
"duration_ms": (time.monotonic_ns() - start_ns) // 1_000_000,
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
if os.environ.get("TELVINE_PLUGIN_ID"):
|
|
68
|
+
event["plugin_id"] = os.environ["TELVINE_PLUGIN_ID"]
|
|
69
|
+
_post(event)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if __name__ == "__main__":
|
|
73
|
+
target = sys.argv[1] if len(sys.argv) > 1 else __file__
|
|
74
|
+
with _telvine_track(os.path.basename(target)):
|
|
75
|
+
exec(compile(open(target).read(), target, "exec"), {"__name__": "__main__"})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Telvine script wrapper. Generated by `telvine publish` — do not edit by hand.
|
|
3
|
+
set +e
|
|
4
|
+
|
|
5
|
+
_TELVINE_API="https://api.telvine.com/v1/events"
|
|
6
|
+
_TELVINE_INSTALL_FILE="${HOME}/.telvine/install_id"
|
|
7
|
+
_TELVINE_START_NS=$(date +%s%N 2>/dev/null || python3 -c 'import time; print(int(time.monotonic_ns()))')
|
|
8
|
+
|
|
9
|
+
_telvine_install_id() {
|
|
10
|
+
if [[ -f "$_TELVINE_INSTALL_FILE" ]]; then
|
|
11
|
+
cat "$_TELVINE_INSTALL_FILE"
|
|
12
|
+
else
|
|
13
|
+
mkdir -p "$(dirname "$_TELVINE_INSTALL_FILE")"
|
|
14
|
+
local id="inst_$(LC_ALL=C tr -dc 'a-z0-9' </dev/urandom | head -c 16)"
|
|
15
|
+
printf "%s" "$id" >"$_TELVINE_INSTALL_FILE"
|
|
16
|
+
printf "%s" "$id"
|
|
17
|
+
fi
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_telvine_post() {
|
|
21
|
+
local script_name="$1" exit_code="$2"
|
|
22
|
+
[[ -z "${TELVINE_WRITE_KEY:-}" ]] && return 0
|
|
23
|
+
local end_ns now duration_ms
|
|
24
|
+
end_ns=$(date +%s%N 2>/dev/null || python3 -c 'import time; print(int(time.monotonic_ns()))')
|
|
25
|
+
duration_ms=$(( (end_ns - _TELVINE_START_NS) / 1000000 ))
|
|
26
|
+
now=$(date -u +"%Y-%m-%dT%H:%M:%S+00:00")
|
|
27
|
+
local idem plugin_line
|
|
28
|
+
idem=$(LC_ALL=C tr -dc 'a-f0-9' </dev/urandom | head -c 32)
|
|
29
|
+
plugin_line=""
|
|
30
|
+
[[ -n "${TELVINE_PLUGIN_ID:-}" ]] && plugin_line=" \"plugin_id\": \"${TELVINE_PLUGIN_ID}\","
|
|
31
|
+
curl -sS --max-time 2 -o /dev/null \
|
|
32
|
+
-H "Content-Type: application/json" \
|
|
33
|
+
-H "Authorization: Bearer ${TELVINE_WRITE_KEY}" \
|
|
34
|
+
-X POST "$_TELVINE_API" \
|
|
35
|
+
-d "$(cat <<EOF
|
|
36
|
+
{
|
|
37
|
+
"event_type": "skill.script.invoked",
|
|
38
|
+
"skill_id": "${TELVINE_SKILL_ID:-skl_unknown}",
|
|
39
|
+
${plugin_line}
|
|
40
|
+
"version": "${TELVINE_SKILL_VERSION:-0.0.0}",
|
|
41
|
+
"installation_id": "$(_telvine_install_id)",
|
|
42
|
+
"occurred_at": "${now}",
|
|
43
|
+
"idempotency_key": "${idem}",
|
|
44
|
+
"properties": {
|
|
45
|
+
"script_name": "${script_name}",
|
|
46
|
+
"exit_code": ${exit_code},
|
|
47
|
+
"duration_ms": ${duration_ms}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
EOF
|
|
51
|
+
)" || true
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_telvine_target="$1"
|
|
55
|
+
shift || true
|
|
56
|
+
bash "$_telvine_target" "$@"
|
|
57
|
+
_telvine_exit=$?
|
|
58
|
+
_telvine_post "$(basename "$_telvine_target")" "$_telvine_exit"
|
|
59
|
+
exit $_telvine_exit
|