set -e printf 'URL=%s\nREF=%s\n' "$SUPABASE_URL" "$SUPABASE_PROJECT_REF" command -v psql || true command -v curl || true python3 - <<'PY' import os for k in ['SUPABASE_URL','SUPABASE_DB_URL','SUPABASE_ANON_KEY','SUPABASE_SERVICE_ROLE_KEY']: print(k, 'set' if os.getenv(k) else 'MISSING') PY
URL=https://<ref>.supabase.co REF=<ref> /usr/bin/psql /usr/bin/curl SUPABASE_URL set SUPABASE_DB_URL set SUPABASE_ANON_KEY set SUPABASE_SERVICE_ROLE_KEY set
set -e psql "$SUPABASE_DB_URL" -v ON_ERROR_STOP=1 -P pager=off -c "select id,title,embedding_json from public.documents order by id;" -c "select name,default_version,installed_version from pg_available_extensions where name='vector';"
id | title | embedding_json ----+---------+------------------ 1 | alpha | [10, 0.5, 0, 0] 2 | bravo | [0.9, 0.3, 0, 0] 3 | delta | [20, 60, 0, 0] 4 | echo | [0, 1, 0, 0] 5 | foxtrot | [-5, 0.1, 0, 0] 6 | golf | [0.1, 0.1, 3, 4] (6 rows) name | default_version | installed_version --------+-----------------+------------------- vector | 0.8.2 | (1 row)
set -e
psql "$SUPABASE_DB_URL" -v ON_ERROR_STOP=1 -P pager=off <<'SQL'
create extension if not exists vector with schema extensions;
alter table public.documents
add column if not exists embedding extensions.vector(4);
update public.documents
set embedding = embedding_json::text::extensions.vector
where embedding_json is not null;
create index if not exists documents_embedding_hnsw_cosine_idx
on public.documents using hnsw (embedding extensions.vector_cosine_ops);
create or replace function public.match_documents(
query_embedding extensions.vector(4),
match_count integer
)
returns table (id integer, title text, distance double precision)
language sql
stable
as $$
select d.id, d.title,
(d.embedding <=> query_embedding)::double precision as distance
from public.documents as d
where d.embedding is not null
order by d.embedding <=> query_embedding
limit match_count;
$$;
grant execute on function public.match_documents(extensions.vector, integer) to anon;
SQL
psql "$SUPABASE_DB_URL" -v ON_ERROR_STOP=1 -P pager=off -c "select id,title,embedding from public.documents order by id;" -c "select indexname,indexdef from pg_indexes where schemaname='public' and tablename='documents';" -c "select * from public.match_documents('[1,0,0,0]'::extensions.vector(4), 3);"CREATE EXTENSION
ALTER TABLE
UPDATE 6
CREATE INDEX
CREATE FUNCTION
GRANT
id | title | embedding
----+---------+---------------
1 | alpha | [10,0.5,0,0]
2 | bravo | [0.9,0.3,0,0]
3 | delta | [20,60,0,0]
4 | echo | [0,1,0,0]
5 | foxtrot | [-5,0.1,0,0]
6 | golf | [0.1,0.1,3,4]
(6 rows)
indexname | indexdef
-------------------------------------+---------------------------------------------------------------------------------------------------------------
documents_embedding_hnsw_cosine_idx | CREATE INDEX documents_embedding_hnsw_cosine_idx ON public.documents USING hnsw (embedding vector_cosine_ops)
documents_pkey | CREATE UNIQUE INDEX documents_pkey ON public.documents USING btree (id)
(2 rows)
id | title | distance
----+-------+---------------------
1 | alpha | 0.00124766112215546
2 | bravo | 0.0513167145152487
3 | delta | 0.683772233983162
(3 rows)
set -e
curl --fail-with-body -sS -X POST "$SUPABASE_URL/rest/v1/rpc/match_documents" \
-H "apikey: $SUPABASE_ANON_KEY" \
-H "Authorization: Bearer $SUPABASE_ANON_KEY" \
-H "Content-Type: application/json" \
-d '{"query_embedding":[1,0,0,0],"match_count":3}' | tee /tmp/match.json
printf '\n'[{"id":1,"title":"alpha","distance":0.00124766112215546},
{"id":2,"title":"bravo","distance":0.0513167145152487},
{"id":3,"title":"delta","distance":0.683772233983162}]
A shell script executed against the live project and asserted on the state the agent left behind. No model judged another model.
Raw transcript · Task definition and verifier · Every attempt