From 334d471153dda7538889742b07fa56e57c3f9ac8 Mon Sep 17 00:00:00 2001 From: 86156 Date: Sun, 15 Mar 2026 06:23:26 +0800 Subject: [PATCH] add quickstart example script --- first_run.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 first_run.py diff --git a/first_run.py b/first_run.py new file mode 100644 index 0000000..4543932 --- /dev/null +++ b/first_run.py @@ -0,0 +1,45 @@ +from hashlib import sha256 +from shadowthreads import ArtifactReference, RevisionMetadata, ShadowClient + +package_id = "readme-first-run" +prompt_hash = sha256(b"Summarize the current workflow state.").hexdigest() +started_at = "2026-03-12T09:00:00+00:00" +finished_at = "2026-03-12T09:00:01+00:00" + +with ShadowClient(base_url="http://localhost:3001") as client: + artifact = client.capture_artifact( + schema="artifact.task.state.v1", + package_id=package_id, + payload={"task": "example", "state": "ready"}, + ) + + ref = ArtifactReference(bundle_hash=artifact.bundle_hash, role="primary_state") + + revision = client.create_revision( + package_id=package_id, + artifacts=[ref], + metadata=RevisionMetadata( + author="README example", + message="Initial task state", + created_by="python-sdk", + timestamp=started_at, + source="human", + ), + ) + + execution = client.record_execution( + package_id=package_id, + revision_hash=revision.revision_hash, + provider="local-example", + model="shadow-demo-model", + prompt_hash=prompt_hash, + parameters={"temperature": 0}, + input_artifacts=[ref], + output_artifacts=[ref], + status="success", + started_at=started_at, + finished_at=finished_at, + ) + + replay = client.replay_execution(execution.execution_id) + print(replay.verified) \ No newline at end of file