thinqos 1.0.0__py3-none-any.whl

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.
@@ -0,0 +1,247 @@
1
+ Metadata-Version: 2.4
2
+ Name: thinqos
3
+ Version: 1.0.0
4
+ Summary: Connect Claude Code and Codex to your thinqOS Mind.
5
+ Project-URL: Homepage, https://thinqos.com
6
+ Project-URL: Repository, https://github.com/AI4Outcomes/thinqos
7
+ Author-email: AI4Outcomes <support@thinqos.com>
8
+ License: MIT
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Requires-Python: >=3.13
16
+ Requires-Dist: click>=8.4
17
+ Requires-Dist: httpx>=0.28
18
+ Description-Content-Type: text/markdown
19
+
20
+ # thinqOS CLI
21
+
22
+ Mind-as-observer probe for [thinqOS](https://thinqos.com). Ships Claude Code and Codex sessions into your thinqOS Mind as captured Episodes, so the Mind learns from where you actually do your work - without sitting in the request path.
23
+
24
+ Pattern: **observer, not proxy.** The probe reads session JSONL from disk, normalizes it to the public [external ingest v1 contract](https://thinqos.com/docs/api/external-ingest/v1/schema.json), and POSTs it to `/api/ingest/external/v1` on your thinqOS instance. Claude Code and Codex can call it from Stop hooks; Codex Desktop, VS Code Codex, and Codex CLI can also be swept from the shared `~/.codex` session store for backfill.
25
+
26
+ ## Install
27
+
28
+ The hook command needs [uv](https://docs.astral.sh/uv/) on PATH:
29
+
30
+ ```bash
31
+ curl -LsSf https://astral.sh/uv/install.sh | sh
32
+ ```
33
+
34
+ Verify the install works:
35
+
36
+ ```bash
37
+ uvx thinqos --help
38
+ ```
39
+
40
+ ## Wire up
41
+
42
+ One command makes thinqOS your default memory across Claude Code **and** Codex:
43
+
44
+ ```bash
45
+ uvx thinqos install --pat tq_xxxx... --repair
46
+ ```
47
+
48
+ `install` does five things, idempotently:
49
+
50
+ 1. **Installs the thinqOS command** and wires hooks to
51
+ the installed binary by absolute path - so a stale `uvx` cache never pins an
52
+ old version, and a daily `uv tool upgrade` keeps it current.
53
+ 2. **Wires the memory hooks** - **capture** (after each session), **incremental
54
+ capture** (debounced mid-session snapshots at PostToolUse, so a mid-turn
55
+ crash still lands the work), **reflexive retrieve** (before each turn),
56
+ **resume** ("where you left off" at session start), and **self-update** (the
57
+ daily background upgrade).
58
+ 3. **Bootstraps your existing native memory** into the Mind in the **background** -
59
+ the per-fact Claude memory files and the legacy Codex `MEMORY.md`, as durable
60
+ native-memory Mind sources. The server queues extraction for the worker, so
61
+ `install` spawns a detached drain that stores them in parallel and returns
62
+ immediately; progress is logged to `~/.config/thinqos/import.log`. A
63
+ content-hash manifest makes it resumable; server-side source IDs make imports
64
+ idempotent; `--no-import-memory`
65
+ skips it. Run `thinqos import-memory` anytime to drain or resume.
66
+ 4. **Adds a write-redirect** so your agents persist *new* durable learnings into
67
+ thinqOS: a one-line reminder in Claude's recall block, and a marker-delimited
68
+ block in `~/.codex/AGENTS.md` (the only channel Codex honors). After this,
69
+ native memory should contain only always-fire hard rules; thinqOS
70
+ `search_mind` + `recall_mind` are the durable memory source of truth.
71
+ 5. **Verifies the product contract** with `doctor`: managed hooks, Claude MCP
72
+ registration, required Mind tools (`search_mind`, `recall_mind`, `consult_mind`, `observe`,
73
+ `believe`), replay queue, server captures, installed binary, and auto-update
74
+ status.
75
+
76
+ - **Mint a key** at <https://thinqos.com/api-keys> (*Create* -> copy the
77
+ `tq_...`). Already connected the thinqOS MCP server? Omit `--pat` and the key
78
+ is read from that registration.
79
+ - Scope to one client with `--client claude` or `--client codex` (default: both,
80
+ whichever has a config directory).
81
+ - Add `--repair` when installing or re-running setup. It prints local health
82
+ guidance and drains at most 25 queued replay payloads, so a stale offline queue
83
+ cannot unexpectedly flush an unbounded backlog.
84
+ - **Safe to re-run.** Existing thinqOS hooks are detected, migrated, and never
85
+ duplicated; your other hooks (coordinator, etc.) and AGENTS.md content are left
86
+ untouched.
87
+ - Needs [uv](https://docs.astral.sh/uv/) on PATH (the same `uv`/`uvx` you used to
88
+ run this command).
89
+
90
+ Open a new session (or restart your agent) and it will auto-capture, reflexively
91
+ retrieve your Mind/corpus, consult the Mind for high-stakes work, and greet you
92
+ with where you left off.
93
+
94
+ **Smoke test:** start a session, type one prompt, exit normally, then run
95
+ `uvx thinqos doctor` - it should show managed Claude hooks, the thinqOS
96
+ MCP registration, replay queue depth, and recent server captures without
97
+ printing your key. The final `health:` line should be `pass` or explain the
98
+ specific repair step.
99
+
100
+ ## Repair, health, and uninstall
101
+
102
+ Repair is safe to run any time:
103
+
104
+ ```bash
105
+ thinqos install --client claude --repair
106
+ thinqos doctor
107
+ ```
108
+
109
+ `--repair` migrates stale managed hooks, refreshes the installed package path,
110
+ preserves unknown hand-authored hooks, and drains at most 25 queued replay
111
+ payloads so an old offline queue cannot unexpectedly flush without bounds.
112
+
113
+ Doctor is the local source of truth for install health:
114
+
115
+ ```bash
116
+ thinqos doctor
117
+ ```
118
+
119
+ It prints the installed version/binary, auto-update status, hook inventory, MCP
120
+ registration, required Mind tool availability, last hook status, replay queue by
121
+ source, and recent server captures. It ends with `doctor_checks:` and `health:`.
122
+
123
+ Uninstall removes local managed integration artifacts only:
124
+
125
+ ```bash
126
+ thinqos uninstall --client claude
127
+ ```
128
+
129
+ By default it removes managed Claude hooks and the `thinqos` Claude MCP
130
+ registration, preserves hand-authored hooks, preserves logs and queued replay
131
+ payloads under `~/.config/thinqos/`, and does **not** delete existing
132
+ server-side captures or Mind knowledge. Add `--dry-run` to preview changes,
133
+ `--remove-state` to delete local logs/queue/manifest, or `--remove-foreign-hooks`
134
+ only when you intentionally want to remove custom thinqOS hooks too.
135
+
136
+ ## Fresh-machine continuity
137
+
138
+ On a second computer, run the same install command with an observer key for your
139
+ identity, restart Claude Code, and run `thinqos doctor`. thinqOS remains
140
+ the durable source of truth; local native memory is only for always-fire hard
141
+ rules. The session prime and resume hooks retrieve relevant Mind/project context
142
+ from thinqOS so Claude Code can continue from your accumulated history.
143
+
144
+ ## Uninstall
145
+
146
+ Remove the managed local hooks with:
147
+
148
+ ```bash
149
+ thinqos uninstall --client both
150
+ ```
151
+
152
+ Use `--client claude` or `--client codex` to remove only one integration. The
153
+ uninstaller removes hooks previously emitted by `thinqos install`,
154
+ recognized legacy thinqOS wrapper hooks, and the managed Codex write-redirect
155
+ block from `~/.codex/AGENTS.md`. It preserves unrelated hooks and unrecognized
156
+ hand-curated thinqOS wrapper commands so it does not destroy local automation
157
+ you wrote yourself.
158
+
159
+ This is local cleanup only. It does not delete server-side captures, revoke API
160
+ keys, or forget extracted knowledge. Use `thinqos forget <session_id>`
161
+ for captured sessions and revoke the observer key in thinqOS if the machine
162
+ should no longer connect. Add `--remove-tool` to remove the local `thinqos`
163
+ command too.
164
+
165
+ ### Manual wiring (advanced)
166
+
167
+ To hand-place the hooks instead, set `THINQOS_BASE_URL` and `INGEST_API_KEY` in
168
+ your shell rc, then run `uvx thinqos install-hook` (add
169
+ `--source openai.com/codex` for Codex). It prints a capture-only JSON snippet to
170
+ paste into `~/.claude/settings.json` (or `~/.codex/hooks.json`) under the
171
+ top-level `"hooks"` object, and warns rather than overwriting an existing `Stop`
172
+ hook.
173
+
174
+ ## Codex
175
+
176
+ `install` already wires Codex. Codex Desktop, VS Code Codex, and Codex CLI write
177
+ rollout JSONL files under `~/.codex/sessions/YYYY/MM/DD/`; older files may live
178
+ under `~/.codex/archived_sessions/`. The Codex adapter reads both locations.
179
+ Codex passes the current `transcript_path` to the hook; the hook uploads the
180
+ completed turn and exits 0 so it does not block Codex.
181
+
182
+ For a one-time backfill of past Codex sessions, run:
183
+
184
+ ```bash
185
+ thinqos run --sources openai.com/codex --since 2026-05-01T00:00:00 --batch-size 5
186
+ ```
187
+
188
+ Prefer a bounded backfill such as the last 7 days. `run` chunks uploads by
189
+ default so large local histories do not exceed server request limits.
190
+
191
+ For a one-shot run without installing the package globally:
192
+
193
+ ```bash
194
+ THINQOS_BASE_URL=https://thinqos.com \
195
+ INGEST_API_KEY=tq_xxxx... \
196
+ uvx thinqos run --sources openai.com/codex --since 2026-05-01T00:00:00 --batch-size 5
197
+ ```
198
+
199
+ Omit `--sources` to sweep all registered adapters.
200
+
201
+ ## CLI
202
+
203
+ | Command | What it does |
204
+ | --- | --- |
205
+ | `thinqos install [--client ...] [--no-import-memory] [--repair]` | One-shot setup: install the tool, wire hooks, bootstrap legacy native memory, add the write-redirect. Safe to re-run; `--repair` drains up to 25 queued replay payloads. |
206
+ | `thinqos uninstall [--client ...] [--remove-tool] [--remove-state] [--dry-run]` | Remove managed local hooks/MCP config safely. Preserves hand-authored hooks and server-side captures by default. |
207
+ | `thinqos import-memory [--concurrency N] [--dry-run] [--claude-limit N] [--codex-limit N]` | Queue legacy native Claude/Codex memory as durable Mind sources, most-recent first, `N` in parallel (default 5). Idempotent server-side and resumable by content-hash manifest; `0` limit = all pending. |
208
+ | `thinqos list [--limit N]` | List your captured sessions newest-first. |
209
+ | `thinqos forget <session_id>` | Delete one captured session by id (irreversible). |
210
+ | `thinqos install-hook [--source SOURCE]` | Print the JSON hook snippet for Claude Code or Codex (advanced manual wiring). |
211
+ | `thinqos run [--sources SOURCE] [--since TIMESTAMP] [--batch-size N] [--no-drain-pending]` | Manual sweep - discover any sessions not yet shipped and POST them in chunks. Use for bounded Codex or Claude Code backfill after a long offline period. |
212
+ | `thinqos hook capture [--source SOURCE]` | Hook entry point - reads `transcript_path` from stdin JSON. You should not run this directly; Claude Code and Codex hooks do. |
213
+ | `thinqos hook capture-incremental [--source SOURCE]` | Hook entry point - mid-session snapshot wired at PostToolUse, debounced per session (`THINQOS_INCREMENTAL_MIN_INTERVAL_S`, default 90s) and shipped non-final. Fail-open; do not run directly. |
214
+ | `thinqos hook self-update` | Hook entry point - daily-gated background update. Wired at SessionStart; do not run directly. |
215
+ | `thinqos doctor` | Prove authenticated thinqOS MCP connectivity and the SLA independently from hook/replay health; exits non-zero only when connectivity fails. |
216
+
217
+ ## Denylists
218
+
219
+ Two opt-out layers, both edited at `~/.config/thinqos/`:
220
+
221
+ - **`denylist.txt`** - newline-delimited substrings; any session whose `cwd` contains a substring is skipped entirely. Example: add `personal-taxes` to skip captures from `~/Documents/personal-taxes/`.
222
+ - **Content denylist** is hard-coded: turns containing `.env`, `api_key=…`, `sk-…`, or matching `(api_key|secret|password|token)=<16+ chars>` are dropped before POST. Oversized `tool_result` content (>32KB) is also dropped.
223
+
224
+ ## Reliability
225
+
226
+ - Hook capture always exits 0; never blocks a Claude Code or Codex session even on bug or network failure.
227
+ - Hook health is written to `~/.config/thinqos/status.json`; detailed hook output goes to `~/.config/thinqos/hook.log`.
228
+ - Failed POSTs spool to `~/.config/thinqos/pending/<uuid>.json` and drain on the next `run` by default. Use `--no-drain-pending` for a tightly scoped backfill.
229
+ - Server-side dedup keyed by `(source, source_external_id)`; re-shipping the same session is idempotent. Claude Code captures include a monotonic `session_revision` so a later hook can replace an earlier partial capture.
230
+
231
+ ## Forgetting a capture
232
+
233
+ ```bash
234
+ thinqos forget <session_id>
235
+ ```
236
+
237
+ Where `<session_id>` is the value `thinqos list` shows in the last column. This deletes the Episode on the server side and cascades to any extracted knowledge. For Codex captures, pass `--source openai.com/codex`.
238
+
239
+ For a per-turn / per-content scrub (rather than whole-session delete), contact support. It's a deliberate Phase-A non-goal but ship-able if asked for.
240
+
241
+ ## Privacy posture
242
+
243
+ Opt-out, not opt-in. Adapter ships everything that isn't denied. If you'd rather have explicit opt-in per session, this probe is the wrong tool for you - the design decision is explicit in the [spec](https://github.com/AI4Outcomes/thinqos/blob/main/docs/superpowers/specs/2026-05-26-mind-observer-pattern-design.md).
244
+
245
+ ## Versioning
246
+
247
+ Tagged `tools/thinqos-vX.Y.Z` in the thinqos monorepo. A push to a matching tag triggers the publish workflow.
@@ -0,0 +1,25 @@
1
+ thinqos_capture/__init__.py,sha256=PPdnUkxXW8C9H2cdRmCP8Nyhf_N1WyDx2M4Cg548FVU,488
2
+ thinqos_capture/__main__.py,sha256=nwCDvPZFr73oh9vw8Iq5hgRF8UUePXytNIZ_B_8rvH4,174
3
+ thinqos_capture/attribution.py,sha256=0KJG4OlDeybZq6WYGyLbzyyUEgKrS__2Wq8lLXWWoGM,551
4
+ thinqos_capture/cli.py,sha256=R_Kl2soQ-GpkgY6ZuSkaXNR5ZoJrgzeaWKyY8JEK3yM,107533
5
+ thinqos_capture/client.py,sha256=XTuWkiRO-KGHymSS41EdWcIIT148kXpZnHxDLTv1cbA,16050
6
+ thinqos_capture/denylist.py,sha256=hk5pvRha7HUm1g72SoqsO9___aTQ-_z9TiD6QizUgYc,1497
7
+ thinqos_capture/filelock.py,sha256=ojwyhCOo1JWAebfmRiPaxnE_3IP8xqKizF0hpOGnmpg,1867
8
+ thinqos_capture/hook.py,sha256=_gxpHsK29Fjx3GZHURvaYgYeN2sRfv96PGH1HnWSGY0,66505
9
+ thinqos_capture/importer.py,sha256=p6nDCALLNI1ye72ZGOjQaPVQiiJTmNzdSw9gCmJR3uk,8127
10
+ thinqos_capture/incremental.py,sha256=CBMwPnjt5a_TYLGoM23jnlc67gYL0gU6we11eb9wNL8,6441
11
+ thinqos_capture/logsetup.py,sha256=3ggJqHAFy2wmujtctq9nXtZJiJeNFrI9AxoZxumm7Vo,2298
12
+ thinqos_capture/primecache.py,sha256=1fV-s5iWNHHLnRJz3jK5wK3dIz65YZ2A1Xt-WmmrpbI,10568
13
+ thinqos_capture/secretstore.py,sha256=5a1w3pvHKe3a4Xoe_lBfga1jzdEbAlioEU5wuLld3qY,2984
14
+ thinqos_capture/selfupdate.py,sha256=eD2M1VgYskEYmpFgYZarPzHuO4ScHLsGamh1zHZx3rU,6583
15
+ thinqos_capture/shim.py,sha256=gUg3_GMHbQuLN8JdiGU5rP6cC8OXbqjs_7Lk8XUlS5M,3665
16
+ thinqos_capture/state.py,sha256=vPVveVBBWESal4QwQj9d-AN0EXw_YcUqXYHlfpan_Qs,19805
17
+ thinqos_capture/taskstate.py,sha256=Pr_R0ad0IDLzsqjRTtDNDFSIbhC2Gr2RkkTrMxOHQYo,9017
18
+ thinqos_capture/writeredirect.py,sha256=oMowooPORtjkOnAxcp00niSRse8O8kg6zUl6Fg2P4VE,6616
19
+ thinqos_capture/adapters/__init__.py,sha256=objt2GdG4j_EYUIrZx3ARiw8g9_5dRluQ5BONGBKpLA,353
20
+ thinqos_capture/adapters/claude_code.py,sha256=9_0OAK4adEPD1rFhUP2J0PbuEbB5xK48MS0uq7Z1Kyg,14842
21
+ thinqos_capture/adapters/codex.py,sha256=PIkPXje0bgan8ET-HQBDWv0cEJHzG0OLv_BRHnMYdgU,11931
22
+ thinqos-1.0.0.dist-info/METADATA,sha256=eiNODGKloL7w1tjD37-wLfSDaiUEQ9TmBKXxJuXtsdA,12756
23
+ thinqos-1.0.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
24
+ thinqos-1.0.0.dist-info/entry_points.txt,sha256=zZXK3-SAsyiwCRwY6pwdNsS6HGRwdRlA0ep2OLXdaAs,53
25
+ thinqos-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ thinqos = thinqos_capture.cli:main
@@ -0,0 +1,12 @@
1
+ """Reference client SDK for thinqOS external conversation capture.
2
+
3
+ This package ships alongside thinqOS as a reference implementation of the
4
+ v1 ingest contract published at ``docs/api/external-ingest/v1/``. It is
5
+ *not* the only way to ingest - anyone can POST a valid JSON payload with
6
+ any HTTP client - but it saves new capturer authors the work of watermark
7
+ tracking, batching, retry, schema validation, and hook wiring.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ __version__ = "0.31.4"
@@ -0,0 +1,8 @@
1
+ """Module entry point: ``python -m thinqos_capture ...``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from thinqos_capture.cli import main
6
+
7
+ if __name__ == "__main__":
8
+ main()
@@ -0,0 +1,9 @@
1
+ """Reference adapters.
2
+
3
+ Each adapter knows how to walk one specific source's on-disk representation
4
+ (Claude Code JSONL, Codex session files, future Obsidian/Signal/etc.) and
5
+ normalize it into the v1 ingest contract payload. Adapters are optional -
6
+ the contract is the real API; Python adapters are a convenience.
7
+ """
8
+
9
+ from __future__ import annotations