Initial import: Stitch 0.4.3 (versionCode 16)
The project's first commit, six days and 16 releases after it started. Everything up to this point existed only as files on one machine, with no history and no undo. Contents: single Gradle module, 62 Kotlin files (11,244 lines) and the Needle 2 JNI bridge, 70 tools, 87 passing unit tests, and the five documents in docs/ plus DEVELOPMENT_HISTORY.md and README.md. Not tracked: build outputs (build/, .cxx/, .gradle/), the release APKs in dist/ (~800 MB, rebuildable), local.properties, and .claude/settings.local.json — all machine-specific. The prebuilt libneedle.a files (38 MB) *are* tracked on purpose, so a checkout builds without depending on Hugging Face still serving them.
This commit is contained in:
commit
61409cb444
111 files changed
+15481
No files matched your search
@@ -0,0 +1,64 @@
|
||||
turn on the flashlight flashlight on=true
|
||||
turn off the torch flashlight on=false
|
||||
set an alarm for 7am set_alarm
|
||||
wake me up at 6:30 tomorrow set_alarm
|
||||
set an alarm for 7:45 pm set_alarm
|
||||
set a timer for 5 minutes set_timer
|
||||
timer 30 seconds set_timer
|
||||
call mom call_phone to=mom
|
||||
call Ali Khan call_phone to=Ali Khan
|
||||
ring 03001234567 call_phone to=03001234567
|
||||
text Ali that I'll be 10 minutes late send_sms to=Ali
|
||||
send sms to 03001234567 saying hello send_sms to=03001234567,message=hello
|
||||
show my last 5 calls get_recent_calls limit=5
|
||||
any missed calls? get_recent_calls type=missed
|
||||
who called me last get_recent_calls
|
||||
read my latest messages read_sms
|
||||
read my messages from Sara read_sms from=Sara
|
||||
show my last 3 sms read_sms limit=3
|
||||
summarize my last 5 calls get_recent_calls limit=5
|
||||
whatsapp Ahmed see you at 8 whatsapp_send to=Ahmed,message=see you at 8
|
||||
open youtube open_app app_name=youtube
|
||||
launch the camera app open_app
|
||||
what's my battery get_battery
|
||||
play music media_control action=play
|
||||
pause media_control action=pause
|
||||
next song media_control action=next
|
||||
set volume to 50 set_volume level_percent=50
|
||||
navigate to the airport navigate destination=airport
|
||||
directions to Lahore navigate destination=Lahore
|
||||
what's on my calendar today get_calendar_events
|
||||
open wifi settings open_settings page=wifi
|
||||
turn on bluetooth open_settings page=bluetooth
|
||||
show my notifications get_notifications
|
||||
any new whatsapp messages get_notifications app=whatsapp
|
||||
take a photo open_camera
|
||||
find Bilal's number search_contacts name=Bilal
|
||||
search the web for cricket scores open_web_search
|
||||
what's the capital of France -
|
||||
write me a poem about rain -
|
||||
set a timer for 2 hours set_timer
|
||||
set an alarm after 30 minutes set_alarm
|
||||
send whatsapp message to Ali saying hi whatsapp_send to=Ali
|
||||
message Sara on WhatsApp hello whatsapp_send to=Sara
|
||||
play Believer on Spotify play_music query=Believer,app=spotify
|
||||
play some lofi music play_music query=lofi
|
||||
what song is playing now_playing
|
||||
turn on do not disturb do_not_disturb mode=
|
||||
put my phone on silent ringer_mode mode=silent
|
||||
set brightness to 30 display_setting setting=brightness,value=30
|
||||
what's the weather tomorrow get_weather
|
||||
what time is it get_time
|
||||
hang up call_control action=hang_up
|
||||
Hello -
|
||||
Hi -
|
||||
hey -
|
||||
thanks -
|
||||
how are you -
|
||||
ok -
|
||||
what is a flower -
|
||||
meaning of a name 'Zara' -
|
||||
no, i mean what is the meaning of name 'Zara' -
|
||||
who is the president of Pakistan -
|
||||
why is the sky blue -
|
||||
don't turn on the flashlight -
|
||||
|
Executable
+71
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Runs eval_set.tsv through the Needle CLI with the app's tool catalog and reports routing accuracy.
|
||||
|
||||
Usage: run_eval.py <needle-binary> <tools.json> [threshold]
|
||||
tools.json is written by the unit test ProviderFormatTest.exportToolCatalog (app/build/needle-tools.json).
|
||||
Expected tool "-" means no on-device tool should be used (the request should go to the AI).
|
||||
"""
|
||||
import json, subprocess, sys, tempfile, os, re
|
||||
|
||||
needle, tools = sys.argv[1], sys.argv[2]
|
||||
thr = float(sys.argv[3]) if len(sys.argv) > 3 else 0.6
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
sysf = tempfile.NamedTemporaryFile("w", suffix=".txt", delete=False)
|
||||
sysf.write("date: 2026-09-19 Sat 14:30; locale: en-US; device: phone; battery: 62%; assistant: Stitch")
|
||||
sysf.close()
|
||||
idx = os.path.join(tempfile.gettempdir(), "needle-eval.idx")
|
||||
required = {t["name"]: set(t["parameters"].get("required", [])) for t in json.load(open(tools))}
|
||||
# The app's own safety checks (written by the unit tests): Needle's pick only runs if they pass.
|
||||
rules_path = os.path.join(os.path.dirname(tools), "needle-safety.json")
|
||||
rules = json.load(open(rules_path)) if os.path.exists(rules_path) else None
|
||||
def app_blocks(prompt, name):
|
||||
if not rules: return None
|
||||
p = prompt.strip().lower()
|
||||
if re.fullmatch(rules["small_talk"], p): return "small talk"
|
||||
if re.search(rules["negation"], prompt, re.I): return "negated"
|
||||
ev = rules["evidence"].get(name)
|
||||
if name != "-" and (ev is None or not re.search(ev, prompt, re.I)): return "no evidence"
|
||||
return None
|
||||
|
||||
def matches(args, expect):
|
||||
for kv in filter(None, expect.split(",")):
|
||||
k, v = kv.split("=", 1)
|
||||
got = str(args.get(k, "")).lower()
|
||||
if got != v.lower() and v.lower() not in got:
|
||||
return False
|
||||
return True
|
||||
|
||||
right_tool = right_args = acted = acted_wrong = 0
|
||||
rows = [l.rstrip("\n").split("\t") for l in open(os.path.join(here, "eval_set.tsv")) if l.strip()]
|
||||
for prompt, want, *rest in rows:
|
||||
expect = rest[0] if rest else ""
|
||||
out = subprocess.run([needle, "--tools", tools, "--tool-index", idx, "--system", sysf.name, "--prompt", prompt],
|
||||
capture_output=True, text=True).stdout
|
||||
j = json.loads(out)
|
||||
calls = j.get("function_calls") or []
|
||||
conf = j.get("confidence") or 0
|
||||
ung = (j.get("validation") or {}).get("ungrounded") or []
|
||||
name = calls[0]["name"] if calls else "-"
|
||||
args = dict(calls[0]["arguments"]) if calls else {}
|
||||
# Same rule as Agent.decide(): drop made-up optional args, reject made-up required ones.
|
||||
bad = []
|
||||
for path in ung:
|
||||
fn, _, arg = path.partition(".")
|
||||
if fn != name: continue
|
||||
if arg in required.get(name, ()): bad.append(arg)
|
||||
else: args.pop(arg, None)
|
||||
args = {k: v for k, v in args.items() if v != "" or k in required.get(name, ())}
|
||||
missing = [k for k in required.get(name, ()) if str(args.get(k, "")).strip() == ""]
|
||||
tool_ok = name == want
|
||||
args_ok = tool_ok and matches(args, expect)
|
||||
blocked = app_blocks(prompt, name) if calls else None
|
||||
would_act = bool(calls) and conf >= thr and not bad and not missing and not blocked
|
||||
right_tool += tool_ok
|
||||
right_args += args_ok
|
||||
acted += would_act
|
||||
acted_wrong += would_act and not args_ok
|
||||
mark = "✓" if args_ok else ("~" if tool_ok else "✗")
|
||||
act = "ACT " if would_act else ("blk " if blocked else "ai ")
|
||||
print(f"{mark} {act}{conf:4.2f} {prompt[:40]:40} → {name} {json.dumps(args)[:70]}{' GUESSED' + str(bad) if bad else ''}")
|
||||
n = len(rows)
|
||||
print(f"\ntool {right_tool}/{n} · tool+args {right_args}/{n} · acts on-device {acted}/{n} (wrong: {acted_wrong}) at threshold {thr}")
|
||||
Reference in new issue
Block a user