tilo-sdk 0.5.3__tar.gz

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.
Files changed (94) hide show
  1. tilo_sdk-0.5.3/.gitignore +11 -0
  2. tilo_sdk-0.5.3/PKG-INFO +141 -0
  3. tilo_sdk-0.5.3/README.md +128 -0
  4. tilo_sdk-0.5.3/examples/visa_proof.py +499 -0
  5. tilo_sdk-0.5.3/native/Cargo.toml +25 -0
  6. tilo_sdk-0.5.3/native/src/lib.rs +268 -0
  7. tilo_sdk-0.5.3/pyproject.toml +42 -0
  8. tilo_sdk-0.5.3/src/tilo/__init__.py +67 -0
  9. tilo_sdk-0.5.3/src/tilo/_client.py +572 -0
  10. tilo_sdk-0.5.3/src/tilo/_errors.py +57 -0
  11. tilo_sdk-0.5.3/src/tilo/_native.pyi +82 -0
  12. tilo_sdk-0.5.3/src/tilo/_resource.py +462 -0
  13. tilo_sdk-0.5.3/src/tilo/_transport.py +317 -0
  14. tilo_sdk-0.5.3/src/tilo/_vault.py +257 -0
  15. tilo_sdk-0.5.3/src/tilo/py.typed +0 -0
  16. tilo_sdk-0.5.3/src/tilo/types/__init__.py +14 -0
  17. tilo_sdk-0.5.3/src/tilo/types/account.py +288 -0
  18. tilo_sdk-0.5.3/src/tilo/types/activity.py +98 -0
  19. tilo_sdk-0.5.3/src/tilo/types/api_tester.py +1015 -0
  20. tilo_sdk-0.5.3/src/tilo/types/api_v1.py +470 -0
  21. tilo_sdk-0.5.3/src/tilo/types/backups.py +721 -0
  22. tilo_sdk-0.5.3/src/tilo/types/board.py +224 -0
  23. tilo_sdk-0.5.3/src/tilo/types/browser.py +2304 -0
  24. tilo_sdk-0.5.3/src/tilo/types/calculator.py +259 -0
  25. tilo_sdk-0.5.3/src/tilo/types/calendar.py +1516 -0
  26. tilo_sdk-0.5.3/src/tilo/types/camera.py +1169 -0
  27. tilo_sdk-0.5.3/src/tilo/types/canvas.py +2645 -0
  28. tilo_sdk-0.5.3/src/tilo/types/chat.py +2008 -0
  29. tilo_sdk-0.5.3/src/tilo/types/chip_design.py +1512 -0
  30. tilo_sdk-0.5.3/src/tilo/types/clocks.py +462 -0
  31. tilo_sdk-0.5.3/src/tilo/types/code_editor.py +1699 -0
  32. tilo_sdk-0.5.3/src/tilo/types/console.py +307 -0
  33. tilo_sdk-0.5.3/src/tilo/types/contacts.py +751 -0
  34. tilo_sdk-0.5.3/src/tilo/types/containers.py +320 -0
  35. tilo_sdk-0.5.3/src/tilo/types/counter.py +135 -0
  36. tilo_sdk-0.5.3/src/tilo/types/db_client.py +1037 -0
  37. tilo_sdk-0.5.3/src/tilo/types/diffmerge.py +778 -0
  38. tilo_sdk-0.5.3/src/tilo/types/discord.py +799 -0
  39. tilo_sdk-0.5.3/src/tilo/types/discussion.py +273 -0
  40. tilo_sdk-0.5.3/src/tilo/types/disk_usage.py +380 -0
  41. tilo_sdk-0.5.3/src/tilo/types/disks.py +152 -0
  42. tilo_sdk-0.5.3/src/tilo/types/ebook.py +1124 -0
  43. tilo_sdk-0.5.3/src/tilo/types/feeds.py +796 -0
  44. tilo_sdk-0.5.3/src/tilo/types/file_explorer.py +1321 -0
  45. tilo_sdk-0.5.3/src/tilo/types/firewall.py +308 -0
  46. tilo_sdk-0.5.3/src/tilo/types/gallery.py +637 -0
  47. tilo_sdk-0.5.3/src/tilo/types/git_client.py +1237 -0
  48. tilo_sdk-0.5.3/src/tilo/types/hex_editor.py +1136 -0
  49. tilo_sdk-0.5.3/src/tilo/types/logs.py +267 -0
  50. tilo_sdk-0.5.3/src/tilo/types/mail.py +950 -0
  51. tilo_sdk-0.5.3/src/tilo/types/maps.py +1050 -0
  52. tilo_sdk-0.5.3/src/tilo/types/messages.py +1224 -0
  53. tilo_sdk-0.5.3/src/tilo/types/migrate.py +537 -0
  54. tilo_sdk-0.5.3/src/tilo/types/monitor.py +142 -0
  55. tilo_sdk-0.5.3/src/tilo/types/music.py +774 -0
  56. tilo_sdk-0.5.3/src/tilo/types/notes.py +689 -0
  57. tilo_sdk-0.5.3/src/tilo/types/onboarding.py +91 -0
  58. tilo_sdk-0.5.3/src/tilo/types/osk.py +502 -0
  59. tilo_sdk-0.5.3/src/tilo/types/passwords.py +674 -0
  60. tilo_sdk-0.5.3/src/tilo/types/pdf_viewer.py +1555 -0
  61. tilo_sdk-0.5.3/src/tilo/types/photos.py +1150 -0
  62. tilo_sdk-0.5.3/src/tilo/types/playback.py +657 -0
  63. tilo_sdk-0.5.3/src/tilo/types/poker.py +417 -0
  64. tilo_sdk-0.5.3/src/tilo/types/preview.py +1488 -0
  65. tilo_sdk-0.5.3/src/tilo/types/print_centre.py +714 -0
  66. tilo_sdk-0.5.3/src/tilo/types/publisher.py +291 -0
  67. tilo_sdk-0.5.3/src/tilo/types/remote.py +537 -0
  68. tilo_sdk-0.5.3/src/tilo/types/scratchpad.py +161 -0
  69. tilo_sdk-0.5.3/src/tilo/types/sections.py +2990 -0
  70. tilo_sdk-0.5.3/src/tilo/types/settings.py +299 -0
  71. tilo_sdk-0.5.3/src/tilo/types/sheets.py +1237 -0
  72. tilo_sdk-0.5.3/src/tilo/types/shell.py +1634 -0
  73. tilo_sdk-0.5.3/src/tilo/types/shortcuts.py +1463 -0
  74. tilo_sdk-0.5.3/src/tilo/types/slides.py +1109 -0
  75. tilo_sdk-0.5.3/src/tilo/types/snippets.py +356 -0
  76. tilo_sdk-0.5.3/src/tilo/types/speed_test.py +249 -0
  77. tilo_sdk-0.5.3/src/tilo/types/store.py +1326 -0
  78. tilo_sdk-0.5.3/src/tilo/types/tasks.py +1450 -0
  79. tilo_sdk-0.5.3/src/tilo/types/terminal.py +1545 -0
  80. tilo_sdk-0.5.3/src/tilo/types/today.py +108 -0
  81. tilo_sdk-0.5.3/src/tilo/types/totp.py +403 -0
  82. tilo_sdk-0.5.3/src/tilo/types/tube.py +1020 -0
  83. tilo_sdk-0.5.3/src/tilo/types/typst_editor.py +658 -0
  84. tilo_sdk-0.5.3/src/tilo/types/video.py +300 -0
  85. tilo_sdk-0.5.3/src/tilo/types/video_editor.py +2869 -0
  86. tilo_sdk-0.5.3/src/tilo/types/views.py +272 -0
  87. tilo_sdk-0.5.3/src/tilo/types/weather.py +583 -0
  88. tilo_sdk-0.5.3/src/tilo/types/windows.py +181 -0
  89. tilo_sdk-0.5.3/src/tilo/types/word_processor.py +813 -0
  90. tilo_sdk-0.5.3/src/tilo/types/workspace.py +1240 -0
  91. tilo_sdk-0.5.3/tests/test_call_lane.py +107 -0
  92. tilo_sdk-0.5.3/tests/test_daemon.py +143 -0
  93. tilo_sdk-0.5.3/tests/test_http.py +246 -0
  94. tilo_sdk-0.5.3/uv.lock +287 -0
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.egg-info/
4
+ .pytest_cache/
5
+ dist/
6
+ # The native part, copied in for a run against a built one (tools/ci/sdk-native.sh).
7
+ src/tilo/_native.*.so
8
+ src/tilo/_native.so
9
+ src/tilo/tilo-automerge-worker
10
+ # The apps' types, written by `tilo sdk gen` at build time (tools/ci/sdk-gen.sh).
11
+ src/tilo/types/
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.5
2
+ Name: tilo-sdk
3
+ Version: 0.5.3
4
+ Summary: Drive Tilo workspaces from Python: the same resources, actions, runs and undo as clicking or an agent.
5
+ License: MIT OR Apache-2.0
6
+ Requires-Python: >=3.11
7
+ Requires-Dist: blake3>=1.0
8
+ Requires-Dist: httpx>=0.27
9
+ Provides-Extra: dev
10
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
11
+ Requires-Dist: pytest>=8; extra == 'dev'
12
+ Description-Content-Type: text/markdown
13
+
14
+ # tilo-sdk (Python SDK)
15
+
16
+ Drive Tilo workspaces from Python: the same resources, actions, invocations,
17
+ undo and attribution a person clicking or an agent gets. The SDK is a client of
18
+ Tilo's HTTP API, `/v1` ([the API](../../docs/developers/api.md)), and nothing
19
+ else.
20
+
21
+ ```sh
22
+ uv add tilo-sdk
23
+ ```
24
+
25
+ ```python
26
+ import asyncio
27
+ from tilo import Tilo, run
28
+
29
+ async def main():
30
+ async with Tilo() as tilo: # this computer's daemon
31
+ ws = tilo.workspace() # the workspace it serves
32
+
33
+ note = await run(ws, {"path": "notes", "action": "new-note"}, {"title": "Todo"})
34
+ print(note["result"]) # what the action produced
35
+
36
+ async for event in ws.events(): # changes, invocations and who is there
37
+ print(event["type"], event["data"])
38
+ break
39
+
40
+ asyncio.run(main())
41
+ ```
42
+
43
+ ## The client is the API
44
+
45
+ `Tilo` and `Workspace` are written from the API's description by `tilo sdk
46
+ gen`: one method per operation, its parameters, body and answer typed from the
47
+ description's schemas. `tilo.get_api()`, `tilo.list_account_resources(…)` and
48
+ `tilo.run_account_action(…)` are the account's; a workspace's are
49
+ `ws.list_resources`, `ws.read_resource`, `ws.view_resource`, `ws.run_action`,
50
+ `ws.get_invocation`, `ws.cancel_invocation`, `ws.undo_invocation`,
51
+ `ws.invocation_output`, `ws.ask_model`, `ws.run_program`, `ws.put_content`,
52
+ `ws.get_content` and `ws.events`. The types are built with the package and never
53
+ committed (`tools/ci/sdk-gen.sh`).
54
+
55
+ A request goes one of two ways:
56
+
57
+ - **This computer's daemon** (default). `Tilo()` reaches the daemon through the
58
+ `tilo._native` extension, which answers `/v1` in process as whoever
59
+ connected: the person, or an app process the launcher started. An app's
60
+ `tilo.workspace()` with no argument is the workspace it was started in.
61
+ - **A key, by URL.** `Tilo(key=...)` (or `TILO_API_KEY`) sends the same requests
62
+ to `TILO_API_URL` (`https://api.tilo.sh` unless set) with
63
+ `Authorization: Bearer <key>`. A key's client serves no workspace:
64
+ `tilo.workspace("jane-doe")` names one by its id or its name.
65
+
66
+ ```python
67
+ backend = Tilo()
68
+ made = await run(backend, {"path": "account/workspaces", "action": "create"}, {"name": "Jane Doe"})
69
+ workspace = made["result"]["workspace"]
70
+ minted = await run(backend, {"path": "account/keys", "action": "mint"}, {"workspace": workspace["id"]})
71
+ print(minted["result"]) # {token, …}: hand it to Jane's agent
72
+ ```
73
+
74
+ ## Actions
75
+
76
+ `ws.run_action({"path", "action"}, args)` is one request: `200` when it ran,
77
+ `202` with `status: "pending"` when it has not finished or waits for the
78
+ person. `run(ws, {"path", "action"}, args)` follows it until it finished
79
+ (`get_invocation` with `wait`), and the account's actions by asking again with
80
+ the same `Idempotency-Key`. Every mutating request carries one, so a request
81
+ asked again while the API is briefly unavailable (`503`) runs once.
82
+
83
+ `async with ws.invocation("Fill Jane's application") as group:` puts every
84
+ request inside into one invocation group (`Tilo-Invocation`,
85
+ `Tilo-Invocation-Title`): one undo step per app, named in History.
86
+ `group.links` (and `group.link` when one record changed) are the records it
87
+ changed; `await group.undo()` takes it back.
88
+
89
+ A refusal raises `Refused`: `code` is what a program branches on
90
+ (`not_permitted`, `key_revoked`, `surface_changed`, …), `error` the API's whole
91
+ refusal body, `status` the HTTP status.
92
+
93
+ ## Resources as objects
94
+
95
+ ```python
96
+ snippet = await ws.resource("snippets/Hello").load()
97
+ snippet.fields["title"] # a field, from the resource
98
+ snippet.title = "Hello there" # a field edit
99
+ await snippet.flush() # awaits the edits on their way
100
+ await snippet.action("star") # an action
101
+ ```
102
+
103
+ A method is the resource's action, its name in snake case from the app's id
104
+ (`read_form_fields()` runs `read-form-fields`) and answering what it produced;
105
+ `action("…")` runs one by its id where the types do not name it. An assignment
106
+ (or `snippet.edit(["title"], value="Hi")`) is the generic `field-edit` action
107
+ every resource publishes. `rows(ws, path=…)` reads every page of a listing;
108
+ `exported(ws)` reads every resource of a workspace whole.
109
+
110
+ The types of the built-in apps ship with the package: one module per app under
111
+ `tilo.types`. `tilo sdk gen --lang python -w <workspace>` writes a workspace's
112
+ own apps' types. A generated type names the app's surface in each call
113
+ (`Tilo-Surface`): a workspace whose app publishes another surface refuses it
114
+ (`surface_changed`) rather than running it into the wrong shape.
115
+
116
+ ## Files, events and the vault
117
+
118
+ - **Files.** `await ws.upload(bytes)` puts the bytes at their BLAKE3 address
119
+ (`putContent`, in `Content-Range` pieces when large) and answers the
120
+ `tilo.content:` reference an action takes; `await ws.download(reference)`
121
+ gives the bytes back.
122
+ - **Events.** `async for event in ws.events(path=…)` follows changes,
123
+ invocations and presence as server-sent events;
124
+ `ws.invocation_output(invocation)` follows one invocation until it ends.
125
+ `await events.aclose()` ends either at once.
126
+ - **The vault**, on a daemon's connection. `ws.vault.web_call(url, key)`
127
+ makes a request with a key the vault keeps, by `vault.item:` reference, and
128
+ answers the reply with the key struck out; `ws.vault.ask(kind, belongs_to)`
129
+ asks the person for a secret and answers the reference it is kept under.
130
+ `release` and `find` reach a vault item only from an app the daemon started,
131
+ and `ws.call_lane` carries an outside call into a workspace call for one.
132
+
133
+ ## Tests
134
+
135
+ ```sh
136
+ uv run --extra dev pytest # the transport-free tests
137
+ ```
138
+
139
+ `tests/test_daemon.py` drives a real daemon and skips unless
140
+ `TILO_RUNTIME_PROFILE` names one: `tools/ci/sdk-native.sh test <dir>` starts a
141
+ daemon in its own profile and runs it.
@@ -0,0 +1,128 @@
1
+ # tilo-sdk (Python SDK)
2
+
3
+ Drive Tilo workspaces from Python: the same resources, actions, invocations,
4
+ undo and attribution a person clicking or an agent gets. The SDK is a client of
5
+ Tilo's HTTP API, `/v1` ([the API](../../docs/developers/api.md)), and nothing
6
+ else.
7
+
8
+ ```sh
9
+ uv add tilo-sdk
10
+ ```
11
+
12
+ ```python
13
+ import asyncio
14
+ from tilo import Tilo, run
15
+
16
+ async def main():
17
+ async with Tilo() as tilo: # this computer's daemon
18
+ ws = tilo.workspace() # the workspace it serves
19
+
20
+ note = await run(ws, {"path": "notes", "action": "new-note"}, {"title": "Todo"})
21
+ print(note["result"]) # what the action produced
22
+
23
+ async for event in ws.events(): # changes, invocations and who is there
24
+ print(event["type"], event["data"])
25
+ break
26
+
27
+ asyncio.run(main())
28
+ ```
29
+
30
+ ## The client is the API
31
+
32
+ `Tilo` and `Workspace` are written from the API's description by `tilo sdk
33
+ gen`: one method per operation, its parameters, body and answer typed from the
34
+ description's schemas. `tilo.get_api()`, `tilo.list_account_resources(…)` and
35
+ `tilo.run_account_action(…)` are the account's; a workspace's are
36
+ `ws.list_resources`, `ws.read_resource`, `ws.view_resource`, `ws.run_action`,
37
+ `ws.get_invocation`, `ws.cancel_invocation`, `ws.undo_invocation`,
38
+ `ws.invocation_output`, `ws.ask_model`, `ws.run_program`, `ws.put_content`,
39
+ `ws.get_content` and `ws.events`. The types are built with the package and never
40
+ committed (`tools/ci/sdk-gen.sh`).
41
+
42
+ A request goes one of two ways:
43
+
44
+ - **This computer's daemon** (default). `Tilo()` reaches the daemon through the
45
+ `tilo._native` extension, which answers `/v1` in process as whoever
46
+ connected: the person, or an app process the launcher started. An app's
47
+ `tilo.workspace()` with no argument is the workspace it was started in.
48
+ - **A key, by URL.** `Tilo(key=...)` (or `TILO_API_KEY`) sends the same requests
49
+ to `TILO_API_URL` (`https://api.tilo.sh` unless set) with
50
+ `Authorization: Bearer <key>`. A key's client serves no workspace:
51
+ `tilo.workspace("jane-doe")` names one by its id or its name.
52
+
53
+ ```python
54
+ backend = Tilo()
55
+ made = await run(backend, {"path": "account/workspaces", "action": "create"}, {"name": "Jane Doe"})
56
+ workspace = made["result"]["workspace"]
57
+ minted = await run(backend, {"path": "account/keys", "action": "mint"}, {"workspace": workspace["id"]})
58
+ print(minted["result"]) # {token, …}: hand it to Jane's agent
59
+ ```
60
+
61
+ ## Actions
62
+
63
+ `ws.run_action({"path", "action"}, args)` is one request: `200` when it ran,
64
+ `202` with `status: "pending"` when it has not finished or waits for the
65
+ person. `run(ws, {"path", "action"}, args)` follows it until it finished
66
+ (`get_invocation` with `wait`), and the account's actions by asking again with
67
+ the same `Idempotency-Key`. Every mutating request carries one, so a request
68
+ asked again while the API is briefly unavailable (`503`) runs once.
69
+
70
+ `async with ws.invocation("Fill Jane's application") as group:` puts every
71
+ request inside into one invocation group (`Tilo-Invocation`,
72
+ `Tilo-Invocation-Title`): one undo step per app, named in History.
73
+ `group.links` (and `group.link` when one record changed) are the records it
74
+ changed; `await group.undo()` takes it back.
75
+
76
+ A refusal raises `Refused`: `code` is what a program branches on
77
+ (`not_permitted`, `key_revoked`, `surface_changed`, …), `error` the API's whole
78
+ refusal body, `status` the HTTP status.
79
+
80
+ ## Resources as objects
81
+
82
+ ```python
83
+ snippet = await ws.resource("snippets/Hello").load()
84
+ snippet.fields["title"] # a field, from the resource
85
+ snippet.title = "Hello there" # a field edit
86
+ await snippet.flush() # awaits the edits on their way
87
+ await snippet.action("star") # an action
88
+ ```
89
+
90
+ A method is the resource's action, its name in snake case from the app's id
91
+ (`read_form_fields()` runs `read-form-fields`) and answering what it produced;
92
+ `action("…")` runs one by its id where the types do not name it. An assignment
93
+ (or `snippet.edit(["title"], value="Hi")`) is the generic `field-edit` action
94
+ every resource publishes. `rows(ws, path=…)` reads every page of a listing;
95
+ `exported(ws)` reads every resource of a workspace whole.
96
+
97
+ The types of the built-in apps ship with the package: one module per app under
98
+ `tilo.types`. `tilo sdk gen --lang python -w <workspace>` writes a workspace's
99
+ own apps' types. A generated type names the app's surface in each call
100
+ (`Tilo-Surface`): a workspace whose app publishes another surface refuses it
101
+ (`surface_changed`) rather than running it into the wrong shape.
102
+
103
+ ## Files, events and the vault
104
+
105
+ - **Files.** `await ws.upload(bytes)` puts the bytes at their BLAKE3 address
106
+ (`putContent`, in `Content-Range` pieces when large) and answers the
107
+ `tilo.content:` reference an action takes; `await ws.download(reference)`
108
+ gives the bytes back.
109
+ - **Events.** `async for event in ws.events(path=…)` follows changes,
110
+ invocations and presence as server-sent events;
111
+ `ws.invocation_output(invocation)` follows one invocation until it ends.
112
+ `await events.aclose()` ends either at once.
113
+ - **The vault**, on a daemon's connection. `ws.vault.web_call(url, key)`
114
+ makes a request with a key the vault keeps, by `vault.item:` reference, and
115
+ answers the reply with the key struck out; `ws.vault.ask(kind, belongs_to)`
116
+ asks the person for a secret and answers the reference it is kept under.
117
+ `release` and `find` reach a vault item only from an app the daemon started,
118
+ and `ws.call_lane` carries an outside call into a workspace call for one.
119
+
120
+ ## Tests
121
+
122
+ ```sh
123
+ uv run --extra dev pytest # the transport-free tests
124
+ ```
125
+
126
+ `tests/test_daemon.py` drives a real daemon and skips unless
127
+ `TILO_RUNTIME_PROFILE` names one: `tools/ci/sdk-native.sh test <dir>` starts a
128
+ daemon in its own profile and runs it.