tlnt-cli 1.5.2__tar.gz → 1.6.0__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 (55) hide show
  1. tlnt_cli-1.6.0/PKG-INFO +141 -0
  2. tlnt_cli-1.6.0/README.md +124 -0
  3. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/pyproject.toml +1 -2
  4. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/pyproject.toml.orig +1 -2
  5. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/approvals.py +10 -1
  6. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/attendance.py +3 -1
  7. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/login.py +2 -11
  8. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/logout.py +2 -1
  9. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/setup.py +2 -1
  10. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/timeoff.py +11 -1
  11. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/update.py +2 -0
  12. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/main.py +31 -33
  13. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/options.py +1 -14
  14. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/output.py +18 -0
  15. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/services/attendance.py +7 -5
  16. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/services/status.py +5 -4
  17. tlnt_cli-1.5.2/PKG-INFO +0 -314
  18. tlnt_cli-1.5.2/README.md +0 -296
  19. tlnt_cli-1.5.2/src/tlnt/cli/commands/mcp.py +0 -8
  20. tlnt_cli-1.5.2/src/tlnt/mcp/__init__.py +0 -0
  21. tlnt_cli-1.5.2/src/tlnt/mcp/main.py +0 -176
  22. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/LICENSE +0 -0
  23. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/__init__.py +0 -0
  24. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/__main__.py +0 -0
  25. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/browser/__init__.py +0 -0
  26. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/browser/login.py +0 -0
  27. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/browser/oauth.py +0 -0
  28. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/browser/scripted.py +0 -0
  29. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/__init__.py +0 -0
  30. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/avatars.py +0 -0
  31. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/__init__.py +0 -0
  32. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/calendar.py +0 -0
  33. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/notifications.py +0 -0
  34. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/profile.py +0 -0
  35. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/status.py +0 -0
  36. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/commands/version.py +0 -0
  37. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/cli/prompts.py +0 -0
  38. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/__init__.py +0 -0
  39. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/client.py +0 -0
  40. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/config.py +0 -0
  41. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/http_client.py +0 -0
  42. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/logs.py +0 -0
  43. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/mekari.py +0 -0
  44. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/models.py +0 -0
  45. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/play_store.py +0 -0
  46. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/services/__init__.py +0 -0
  47. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/services/calendar.py +0 -0
  48. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/services/login.py +0 -0
  49. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/services/logout.py +0 -0
  50. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/services/notifications.py +0 -0
  51. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/services/profile.py +0 -0
  52. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/services/setup.py +0 -0
  53. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/services/timeoff.py +0 -0
  54. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/session.py +0 -0
  55. {tlnt_cli-1.5.2 → tlnt_cli-1.6.0}/src/tlnt/core/user_agent.py +0 -0
@@ -0,0 +1,141 @@
1
+ Metadata-Version: 2.4
2
+ Name: tlnt-cli
3
+ Version: 1.6.0
4
+ Summary: CLI wrapper for HRIS attendance and employment workflows.
5
+ Author: Fathiraz Arthuro
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Dist: httpx>=0.28,<0.29
9
+ Requires-Dist: loguru>=0.7,<1
10
+ Requires-Dist: platformdirs>=4.3,<5
11
+ Requires-Dist: playwright>=1.50,<2
12
+ Requires-Dist: rich>=14,<16
13
+ Requires-Dist: rich-pixels>=3,<4
14
+ Requires-Dist: typer>=0.20,<1
15
+ Requires-Python: >=3.11, <3.15
16
+ Description-Content-Type: text/markdown
17
+
18
+ ![tlnt CLI logo](assets/logo.png)
19
+
20
+ # tlnt
21
+
22
+ ![CI](https://github.com/fathirazarthuro/tlnt/actions/workflows/ci.yml/badge.svg)
23
+ ![License](https://img.shields.io/github/license/fathirazarthuro/tlnt)
24
+
25
+ `tlnt` is a Python CLI wrapper for Mekari Talenta employment data,
26
+ notifications, attendance summaries and previews, and human-confirmed attendance actions.
27
+
28
+ > [!WARNING]
29
+ > `tlnt` is an unofficial, independent research and educational project. It
30
+ > is not affiliated with Mekari or Talenta. Use it only when your account and
31
+ > the actions you perform are authorized. Read the [full bilingual
32
+ > disclaimer](docs/index.md#disclaimer) before using it.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ uv tool install tlnt-cli
38
+ ```
39
+
40
+ Or use `pipx install tlnt-cli` or `pip install tlnt-cli`. PyPI refuses the name
41
+ `tlnt` as too similar to an existing project, so the package is `tlnt-cli`; the
42
+ command is still `tlnt`. It requires Python 3.11–3.14, with uv as the recommended
43
+ package manager. Browser login requires Google Chrome or Microsoft Edge, or a
44
+ compatible running browser over CDP.
45
+
46
+ Run `tlnt update` to install the latest release. See [Install](docs/install.md)
47
+ for other install methods, the version notices, and upgrading from tlnt 1.5.0
48
+ or earlier.
49
+
50
+ ## Quick start
51
+
52
+ ```bash
53
+ tlnt setup # create config.json, then set client_id in it
54
+ tlnt login # sign in through Chrome or Edge
55
+ tlnt status --json
56
+ tlnt profile
57
+ tlnt attendance clock-in --dry-run --latitude LATITUDE --longitude LONGITUDE
58
+ ```
59
+
60
+ Ask the project maintainers for `client_id`. [Setup](docs/setup.md) covers the
61
+ config keys and every way to sign in: through a browser you already run
62
+ (`--cdp`), from the terminal (`--email`), and on a host with no display
63
+ (`--headless`).
64
+
65
+ ## Use tlnt from scripts and agents
66
+
67
+ Human-readable tables are the default. Add `--json` to write one result object
68
+ to stdout; version notices and diagnostics go to stderr. Exit code `0` means
69
+ success, `1` an operational failure, and `2` invalid arguments. Check `code`
70
+ before reading `data`; the codes are listed in
71
+ [Overview](docs/overview.md#stable-result-codes).
72
+
73
+ Set `TALENTA_READONLY=1` when a script or an agent must never change anything:
74
+ every write then stops with `read_only_mode` before any prompt or request.
75
+
76
+ ```bash
77
+ TALENTA_READONLY=1 tlnt notification attendance-list --json
78
+ ```
79
+
80
+ Agents should install the [agent skill](skills/tlnt-cli/SKILL.md) and read
81
+ [Integrations](docs/integrations.md), which also shows how to call tlnt from
82
+ an MCP client.
83
+
84
+ ## Commands
85
+
86
+ | Area | What it covers |
87
+ | --- | --- |
88
+ | [Session](docs/session.md) | `setup`, `login`, `logout`, `status`, `profile`. |
89
+ | [Attendance](docs/attendance.md) | Clock-in and clock-out previews and actions, summaries, approval. |
90
+ | [Notification](docs/notification.md) | Inbox counts, lists and details. |
91
+ | [Time off](docs/timeoff.md) | Balances, requests, cancellations and approval. |
92
+ | [Calendar](docs/calendar.md) | Holidays, time off, birthdays and activity. |
93
+ | [Install](docs/install.md) | `update` and the version notices. |
94
+
95
+ The full command map, global options and output modes are in
96
+ [Overview](docs/overview.md), or run `tlnt --help`.
97
+
98
+ ## Safety contract
99
+
100
+ - Do not open the login flow automatically.
101
+ - Never ask the user for their Mekari password. Only they start
102
+ `tlnt login --email`, and the password comes from a hidden prompt or from
103
+ `TALENTA_PASSWORD` in the host's own environment.
104
+ - Live clock-in, clock-out, approval, time-off requests, and cancellations
105
+ always ask for confirmation. The prompt reads standard input, so it guards
106
+ against mistakes, not scripts; use `TALENTA_READONLY=1` for that.
107
+ - `--dry-run` never submits attendance.
108
+ - `TALENTA_READONLY=1` refuses every command that would change Talenta or
109
+ local state.
110
+ - The version checks only read public listings (PyPI and Google Play), never
111
+ send your session or config, and never log out, log in, or update for you.
112
+ - Never print passwords, bearer tokens, cookies, authorization codes, request
113
+ bodies, selfie contents, or real employee data.
114
+ - If `status` returns `session_missing`, `session_invalid`,
115
+ `mobile_token_missing`, or `mobile_token_expired`, ask
116
+ the user to run login explicitly.
117
+
118
+ ## Documentation
119
+
120
+ - [Docs site](https://tlnt-docs.vercel.app)
121
+ - [Install](docs/install.md) and [Setup](docs/setup.md)
122
+ - [Overview](docs/overview.md): commands and the JSON contract
123
+ - [Workflows](docs/workflows.md)
124
+ - [AI agent integrations](docs/integrations.md)
125
+ - [Security](docs/security.md)
126
+ - [Contributing](docs/contributing.md)
127
+ - [Agent skill](skills/tlnt-cli/SKILL.md)
128
+
129
+ ## Development
130
+
131
+ ```bash
132
+ uv sync --group dev --group docs
133
+ uv run pytest
134
+ uv run --group docs mkdocs build --strict
135
+ ```
136
+
137
+ Read [Contributing](docs/contributing.md) before changing public behavior.
138
+
139
+ ## License
140
+
141
+ `tlnt` is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,124 @@
1
+ ![tlnt CLI logo](assets/logo.png)
2
+
3
+ # tlnt
4
+
5
+ ![CI](https://github.com/fathirazarthuro/tlnt/actions/workflows/ci.yml/badge.svg)
6
+ ![License](https://img.shields.io/github/license/fathirazarthuro/tlnt)
7
+
8
+ `tlnt` is a Python CLI wrapper for Mekari Talenta employment data,
9
+ notifications, attendance summaries and previews, and human-confirmed attendance actions.
10
+
11
+ > [!WARNING]
12
+ > `tlnt` is an unofficial, independent research and educational project. It
13
+ > is not affiliated with Mekari or Talenta. Use it only when your account and
14
+ > the actions you perform are authorized. Read the [full bilingual
15
+ > disclaimer](docs/index.md#disclaimer) before using it.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ uv tool install tlnt-cli
21
+ ```
22
+
23
+ Or use `pipx install tlnt-cli` or `pip install tlnt-cli`. PyPI refuses the name
24
+ `tlnt` as too similar to an existing project, so the package is `tlnt-cli`; the
25
+ command is still `tlnt`. It requires Python 3.11–3.14, with uv as the recommended
26
+ package manager. Browser login requires Google Chrome or Microsoft Edge, or a
27
+ compatible running browser over CDP.
28
+
29
+ Run `tlnt update` to install the latest release. See [Install](docs/install.md)
30
+ for other install methods, the version notices, and upgrading from tlnt 1.5.0
31
+ or earlier.
32
+
33
+ ## Quick start
34
+
35
+ ```bash
36
+ tlnt setup # create config.json, then set client_id in it
37
+ tlnt login # sign in through Chrome or Edge
38
+ tlnt status --json
39
+ tlnt profile
40
+ tlnt attendance clock-in --dry-run --latitude LATITUDE --longitude LONGITUDE
41
+ ```
42
+
43
+ Ask the project maintainers for `client_id`. [Setup](docs/setup.md) covers the
44
+ config keys and every way to sign in: through a browser you already run
45
+ (`--cdp`), from the terminal (`--email`), and on a host with no display
46
+ (`--headless`).
47
+
48
+ ## Use tlnt from scripts and agents
49
+
50
+ Human-readable tables are the default. Add `--json` to write one result object
51
+ to stdout; version notices and diagnostics go to stderr. Exit code `0` means
52
+ success, `1` an operational failure, and `2` invalid arguments. Check `code`
53
+ before reading `data`; the codes are listed in
54
+ [Overview](docs/overview.md#stable-result-codes).
55
+
56
+ Set `TALENTA_READONLY=1` when a script or an agent must never change anything:
57
+ every write then stops with `read_only_mode` before any prompt or request.
58
+
59
+ ```bash
60
+ TALENTA_READONLY=1 tlnt notification attendance-list --json
61
+ ```
62
+
63
+ Agents should install the [agent skill](skills/tlnt-cli/SKILL.md) and read
64
+ [Integrations](docs/integrations.md), which also shows how to call tlnt from
65
+ an MCP client.
66
+
67
+ ## Commands
68
+
69
+ | Area | What it covers |
70
+ | --- | --- |
71
+ | [Session](docs/session.md) | `setup`, `login`, `logout`, `status`, `profile`. |
72
+ | [Attendance](docs/attendance.md) | Clock-in and clock-out previews and actions, summaries, approval. |
73
+ | [Notification](docs/notification.md) | Inbox counts, lists and details. |
74
+ | [Time off](docs/timeoff.md) | Balances, requests, cancellations and approval. |
75
+ | [Calendar](docs/calendar.md) | Holidays, time off, birthdays and activity. |
76
+ | [Install](docs/install.md) | `update` and the version notices. |
77
+
78
+ The full command map, global options and output modes are in
79
+ [Overview](docs/overview.md), or run `tlnt --help`.
80
+
81
+ ## Safety contract
82
+
83
+ - Do not open the login flow automatically.
84
+ - Never ask the user for their Mekari password. Only they start
85
+ `tlnt login --email`, and the password comes from a hidden prompt or from
86
+ `TALENTA_PASSWORD` in the host's own environment.
87
+ - Live clock-in, clock-out, approval, time-off requests, and cancellations
88
+ always ask for confirmation. The prompt reads standard input, so it guards
89
+ against mistakes, not scripts; use `TALENTA_READONLY=1` for that.
90
+ - `--dry-run` never submits attendance.
91
+ - `TALENTA_READONLY=1` refuses every command that would change Talenta or
92
+ local state.
93
+ - The version checks only read public listings (PyPI and Google Play), never
94
+ send your session or config, and never log out, log in, or update for you.
95
+ - Never print passwords, bearer tokens, cookies, authorization codes, request
96
+ bodies, selfie contents, or real employee data.
97
+ - If `status` returns `session_missing`, `session_invalid`,
98
+ `mobile_token_missing`, or `mobile_token_expired`, ask
99
+ the user to run login explicitly.
100
+
101
+ ## Documentation
102
+
103
+ - [Docs site](https://tlnt-docs.vercel.app)
104
+ - [Install](docs/install.md) and [Setup](docs/setup.md)
105
+ - [Overview](docs/overview.md): commands and the JSON contract
106
+ - [Workflows](docs/workflows.md)
107
+ - [AI agent integrations](docs/integrations.md)
108
+ - [Security](docs/security.md)
109
+ - [Contributing](docs/contributing.md)
110
+ - [Agent skill](skills/tlnt-cli/SKILL.md)
111
+
112
+ ## Development
113
+
114
+ ```bash
115
+ uv sync --group dev --group docs
116
+ uv run pytest
117
+ uv run --group docs mkdocs build --strict
118
+ ```
119
+
120
+ Read [Contributing](docs/contributing.md) before changing public behavior.
121
+
122
+ ## License
123
+
124
+ `tlnt` is licensed under the [MIT License](LICENSE).
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "tlnt-cli"
7
- version = "1.5.2"
7
+ version = "1.6.0"
8
8
  description = "CLI wrapper for HRIS attendance and employment workflows."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -13,7 +13,6 @@ requires-python = ">=3.11,<3.15"
13
13
  dependencies = [
14
14
  "httpx>=0.28,<0.29",
15
15
  "loguru>=0.7,<1",
16
- "mcp>=2.0,<3",
17
16
  "platformdirs>=4.3,<5",
18
17
  "playwright>=1.50,<2",
19
18
  "rich>=14,<16",
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "tlnt-cli"
7
- version = "1.5.2"
7
+ version = "1.6.0"
8
8
  description = "CLI wrapper for HRIS attendance and employment workflows."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -14,7 +14,6 @@ requires-python = ">=3.11,<3.15"
14
14
  dependencies = [
15
15
  "httpx>=0.28,<0.29",
16
16
  "loguru>=0.7,<1",
17
- "mcp>=2.0,<3",
18
17
  "platformdirs>=4.3,<5",
19
18
  "playwright>=1.50,<2",
20
19
  "rich>=14,<16",
@@ -7,7 +7,15 @@ from collections.abc import Callable
7
7
  import typer
8
8
 
9
9
  from tlnt.cli import prompts
10
- from tlnt.cli.output import action_banner, confirm, console, dig, emit, spinner
10
+ from tlnt.cli.output import (
11
+ action_banner,
12
+ confirm,
13
+ console,
14
+ dig,
15
+ emit,
16
+ require_writable,
17
+ spinner,
18
+ )
11
19
  from tlnt.core.models import Result
12
20
 
13
21
 
@@ -33,6 +41,7 @@ def run_approval(
33
41
  submit: Callable[[int, int, str, str], Result],
34
42
  ) -> None:
35
43
  """Show one inbox request and approve it only after terminal confirmation."""
44
+ require_writable(json_output)
36
45
  if interactive:
37
46
  unavailable = prompts.guard(json_output, title=f"Approve {noun}")
38
47
  if unavailable is not None:
@@ -9,7 +9,7 @@ import typer
9
9
 
10
10
  from tlnt.cli import prompts
11
11
  from tlnt.cli.approvals import run_approval
12
- from tlnt.cli.output import action_banner, confirm, emit, spinner
12
+ from tlnt.cli.output import action_banner, confirm, emit, require_writable, spinner
13
13
  from tlnt.cli.options import (
14
14
  AvatarsOption,
15
15
  InteractiveOption,
@@ -48,6 +48,8 @@ def _run_attendance(
48
48
  verbose: bool = False,
49
49
  avatars: bool = False,
50
50
  ) -> None:
51
+ if not dry_run:
52
+ require_writable(json_output)
51
53
  if interactive:
52
54
  unavailable = prompts.guard(json_output, title=action_label)
53
55
  if unavailable is not None:
@@ -16,7 +16,7 @@ from tlnt.browser.login import (
16
16
  )
17
17
  from tlnt.browser.scripted import LABELS
18
18
  from tlnt.cli import prompts
19
- from tlnt.cli.output import banner, deadline_bar, emit
19
+ from tlnt.cli.output import banner, deadline_bar, emit, require_writable
20
20
  from tlnt.cli.options import JsonOption, VerboseOption
21
21
  from tlnt.core import config
22
22
  from tlnt.core import mekari as mekari_constants
@@ -100,10 +100,6 @@ def _credentials(email: str) -> Credentials | Result:
100
100
 
101
101
  def login(
102
102
  json_output: JsonOption = False,
103
- store_password: Annotated[
104
- bool,
105
- typer.Option("--store-password", hidden=True),
106
- ] = False,
107
103
  browser: Annotated[
108
104
  Browser | None,
109
105
  typer.Option(
@@ -144,6 +140,7 @@ def login(
144
140
  verbose: VerboseOption = False,
145
141
  ) -> None:
146
142
  """Reuse valid session or sign in through your browser."""
143
+ require_writable(json_output)
147
144
  backend, endpoint = _resolve_backend(browser, cdp)
148
145
  email = (email or "").strip() or None
149
146
  if email and backend in (Browser.ego, Browser.yab):
@@ -156,12 +153,6 @@ def login(
156
153
  )
157
154
  if headless and not email:
158
155
  raise typer.BadParameter("--headless needs --email", param_hint="--headless")
159
- if store_password:
160
- typer.echo(
161
- "--store-password is deprecated and does nothing; "
162
- "it will be removed in 2.0.",
163
- err=True,
164
- )
165
156
  current = status_action()
166
157
  if current.ok:
167
158
  expiry_known = isinstance(current.data, dict) and bool(
@@ -1,4 +1,4 @@
1
- from tlnt.cli.output import run
1
+ from tlnt.cli.output import require_writable, run
2
2
  from tlnt.cli.options import JsonOption, VerboseOption
3
3
  from tlnt.core.services.logout import logout as logout_action
4
4
 
@@ -8,4 +8,5 @@ def logout(
8
8
  verbose: VerboseOption = False,
9
9
  ) -> None:
10
10
  """Log out of Talenta and remove the saved session."""
11
+ require_writable(json_output)
11
12
  run("Signing out...", logout_action, json_output, verbose)
@@ -1,4 +1,4 @@
1
- from tlnt.cli.output import run
1
+ from tlnt.cli.output import require_writable, run
2
2
  from tlnt.cli.options import JsonOption, VerboseOption
3
3
  from tlnt.core.services.setup import setup as setup_action
4
4
 
@@ -8,4 +8,5 @@ def setup(
8
8
  verbose: VerboseOption = False,
9
9
  ) -> None:
10
10
  """Create config.json, or add new keys to it and drop old ones."""
11
+ require_writable(json_output)
11
12
  run("Writing config...", setup_action, json_output, verbose)
@@ -10,7 +10,15 @@ from rich.prompt import Prompt
10
10
  from tlnt.cli import prompts
11
11
  from tlnt.cli.approvals import run_approval
12
12
  from tlnt.cli.options import InteractiveOption, JsonOption, VerboseOption
13
- from tlnt.cli.output import action_banner, confirm, console, dig, emit, run
13
+ from tlnt.cli.output import (
14
+ action_banner,
15
+ confirm,
16
+ console,
17
+ dig,
18
+ emit,
19
+ require_writable,
20
+ run,
21
+ )
14
22
  from tlnt.core.models import Result, iso_date
15
23
  from tlnt.core.services import positive_id
16
24
  from tlnt.core.services import timeoff as timeoff_service
@@ -330,6 +338,7 @@ def timeoff_request(
330
338
  verbose: VerboseOption = False,
331
339
  ) -> None:
332
340
  """Request a full-day or half-day time off."""
341
+ require_writable(json_output)
333
342
  if interactive:
334
343
  unavailable = prompts.guard(json_output, title="Time-off request")
335
344
  if unavailable is not None:
@@ -391,6 +400,7 @@ def timeoff_cancel(
391
400
  verbose: VerboseOption = False,
392
401
  ) -> None:
393
402
  """Cancel a time-off request after confirmation."""
403
+ require_writable(json_output)
394
404
  if interactive:
395
405
  unavailable = prompts.guard(json_output, title="Cancel time-off")
396
406
  if unavailable is not None:
@@ -10,6 +10,7 @@ import httpx
10
10
  import typer
11
11
 
12
12
  from tlnt import DISTRIBUTION
13
+ from tlnt.cli.output import require_writable
13
14
  from tlnt.core import play_store
14
15
 
15
16
  PYPI_URL = f"https://pypi.org/pypi/{DISTRIBUTION}/json"
@@ -67,6 +68,7 @@ def _install_release(installed: str, latest: str) -> int:
67
68
 
68
69
  def update() -> None:
69
70
  """Update tlnt to the latest PyPI release."""
71
+ require_writable(json_output=False)
70
72
  installed = metadata.version(DISTRIBUTION)
71
73
  try:
72
74
  latest = latest_release_version()
@@ -24,7 +24,6 @@ from tlnt.cli.commands.calendar import (
24
24
  )
25
25
  from tlnt.cli.commands.login import login
26
26
  from tlnt.cli.commands.logout import logout
27
- from tlnt.cli.commands.mcp import mcp
28
27
  from tlnt.cli.commands.notifications import (
29
28
  notification_attendance_list,
30
29
  notification_count,
@@ -48,7 +47,7 @@ from tlnt.cli.commands.status import status
48
47
  from tlnt.cli.commands import update as update_command
49
48
  from tlnt.cli.commands.update import update
50
49
  from tlnt.cli.commands.version import print_version
51
- from tlnt.cli.options import TlntCommand, VerboseOption
50
+ from tlnt.cli.options import VerboseOption
52
51
  from tlnt.core import config, play_store
53
52
  from tlnt.core import mekari as mekari_constants
54
53
  from tlnt.core.logs import configure_logging
@@ -73,46 +72,45 @@ timeoff_app = typer.Typer(no_args_is_help=True, help="Manage time-off data and r
73
72
  calendar_app = typer.Typer(no_args_is_help=True, help="Read calendar data.")
74
73
 
75
74
  # Add root commands to the main app
76
- app.command(rich_help_panel="Session", cls=TlntCommand)(setup)
77
- app.command(rich_help_panel="Session", cls=TlntCommand)(login)
78
- app.command(rich_help_panel="Session", cls=TlntCommand)(logout)
79
- app.command(rich_help_panel="Session", cls=TlntCommand)(status)
80
- app.command(rich_help_panel="Session", cls=TlntCommand)(profile)
75
+ app.command(rich_help_panel="Session")(setup)
76
+ app.command(rich_help_panel="Session")(login)
77
+ app.command(rich_help_panel="Session")(logout)
78
+ app.command(rich_help_panel="Session")(status)
79
+ app.command(rich_help_panel="Session")(profile)
81
80
  app.command(rich_help_panel="Session")(update)
82
- app.command(rich_help_panel="Integrations")(mcp)
83
81
 
84
82
  # Add commands to the attendance sub-app
85
- attendance_app.command(name="clock-in", cls=TlntCommand)(attendance_clockin)
86
- attendance_app.command(name="clock-out", cls=TlntCommand)(attendance_clockout)
87
- attendance_app.command(name="summary-list", cls=TlntCommand)(attendance_summary_list)
88
- attendance_app.command(name="summary-metrics", cls=TlntCommand)(attendance_summary_metrics)
89
- attendance_app.command(name="approve", cls=TlntCommand)(attendance_approve)
83
+ attendance_app.command(name="clock-in")(attendance_clockin)
84
+ attendance_app.command(name="clock-out")(attendance_clockout)
85
+ attendance_app.command(name="summary-list")(attendance_summary_list)
86
+ attendance_app.command(name="summary-metrics")(attendance_summary_metrics)
87
+ attendance_app.command(name="approve")(attendance_approve)
90
88
  app.add_typer(attendance_app, name="attendance", rich_help_panel="Workflows")
91
89
 
92
90
  # Add commands to the notification sub-app
93
- notification_app.command(name="count", cls=TlntCommand)(notification_count)
94
- notification_app.command(name="list", cls=TlntCommand)(notification_list)
95
- notification_app.command(name="attendance-list", cls=TlntCommand)(notification_attendance_list)
96
- notification_app.command(name="timeoff-list", cls=TlntCommand)(notification_timeoff_list)
97
- notification_app.command(name="detail", cls=TlntCommand)(notification_detail)
91
+ notification_app.command(name="count")(notification_count)
92
+ notification_app.command(name="list")(notification_list)
93
+ notification_app.command(name="attendance-list")(notification_attendance_list)
94
+ notification_app.command(name="timeoff-list")(notification_timeoff_list)
95
+ notification_app.command(name="detail")(notification_detail)
98
96
  app.add_typer(notification_app, name="notification", rich_help_panel="Workflows")
99
97
 
100
- timeoff_app.command(name="types-list", cls=TlntCommand)(timeoff_types_list)
101
- timeoff_app.command(name="balance", cls=TlntCommand)(timeoff_balance)
102
- timeoff_app.command(name="delegation-list", cls=TlntCommand)(timeoff_delegation_list)
103
- timeoff_app.command(name="list", cls=TlntCommand)(timeoff_list)
104
- timeoff_app.command(name="detail", cls=TlntCommand)(timeoff_detail)
105
- timeoff_app.command(name="request", cls=TlntCommand)(timeoff_request)
106
- timeoff_app.command(name="cancel", cls=TlntCommand)(timeoff_cancel)
107
- timeoff_app.command(name="approve", cls=TlntCommand)(timeoff_approve)
98
+ timeoff_app.command(name="types-list")(timeoff_types_list)
99
+ timeoff_app.command(name="balance")(timeoff_balance)
100
+ timeoff_app.command(name="delegation-list")(timeoff_delegation_list)
101
+ timeoff_app.command(name="list")(timeoff_list)
102
+ timeoff_app.command(name="detail")(timeoff_detail)
103
+ timeoff_app.command(name="request")(timeoff_request)
104
+ timeoff_app.command(name="cancel")(timeoff_cancel)
105
+ timeoff_app.command(name="approve")(timeoff_approve)
108
106
  app.add_typer(timeoff_app, name="timeoff", rich_help_panel="Workflows")
109
107
 
110
- calendar_app.command(name="holiday", cls=TlntCommand)(calendar_holiday)
111
- calendar_app.command(name="timeoff", cls=TlntCommand)(calendar_timeoff)
112
- calendar_app.command(name="index", cls=TlntCommand)(calendar_index)
113
- calendar_app.command(name="my-birthday", cls=TlntCommand)(calendar_my_birthday)
114
- calendar_app.command(name="birthday", cls=TlntCommand)(calendar_birthday)
115
- calendar_app.command(name="activity", cls=TlntCommand)(calendar_activity)
108
+ calendar_app.command(name="holiday")(calendar_holiday)
109
+ calendar_app.command(name="timeoff")(calendar_timeoff)
110
+ calendar_app.command(name="index")(calendar_index)
111
+ calendar_app.command(name="my-birthday")(calendar_my_birthday)
112
+ calendar_app.command(name="birthday")(calendar_birthday)
113
+ calendar_app.command(name="activity")(calendar_activity)
116
114
  app.add_typer(calendar_app, name="calendar", rich_help_panel="Workflows")
117
115
 
118
116
 
@@ -141,7 +139,7 @@ def main_callback(
141
139
  ) -> None:
142
140
  config.set_config_path(config_path)
143
141
  configure_logging(verbose)
144
- if ctx.invoked_subcommand not in (None, "mcp", "update"):
142
+ if ctx.invoked_subcommand not in (None, "update"):
145
143
  for warning in (
146
144
  update_command.update_warning(),
147
145
  play_store.app_version_warning(mekari_constants.app_version()),
@@ -1,9 +1,8 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Annotated, Any
3
+ from typing import Annotated
4
4
 
5
5
  import typer
6
- from typer.core import TyperCommand, TyperOption
7
6
 
8
7
  from tlnt.core.logs import configure_logging
9
8
 
@@ -46,15 +45,3 @@ InteractiveOption = Annotated[
46
45
  rich_help_panel="Output",
47
46
  ),
48
47
  ]
49
-
50
-
51
- class TlntCommand(TyperCommand):
52
- """Accepts the retired --table flag on every command and ignores it."""
53
-
54
- def __init__(self, *args: Any, **kwargs: Any) -> None:
55
- super().__init__(*args, **kwargs)
56
- self.params.append(
57
- TyperOption(
58
- param_decls=["--table"], is_flag=True, hidden=True, expose_value=False
59
- )
60
- )
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import json
4
+ import os
4
5
  import re
5
6
  import threading
6
7
  from contextlib import contextmanager
@@ -229,6 +230,23 @@ def emit(
229
230
  raise typer.Exit(1)
230
231
 
231
232
 
233
+ # Fail closed: a typo such as TALENTA_READONLY=y must not re-enable writes.
234
+ WRITABLE_VALUES = frozenset({"", "0", "false", "no", "off"})
235
+
236
+
237
+ def require_writable(json_output: bool) -> None:
238
+ """Refuse a command that changes Talenta or local state under TALENTA_READONLY."""
239
+ if os.environ.get("TALENTA_READONLY", "").strip().lower() not in WRITABLE_VALUES:
240
+ emit(
241
+ Result(
242
+ False,
243
+ "read_only_mode",
244
+ "TALENTA_READONLY is set; this command would change Talenta or local state",
245
+ ),
246
+ json_output,
247
+ )
248
+
249
+
232
250
  def confirm(question: str, *, default: bool = False, err: bool = False) -> bool | None:
233
251
  """Rich confirm on the stream typer.confirm used. None when stdin is at EOF."""
234
252
  target = err_console if err else console
@@ -53,18 +53,20 @@ def _with_company(
53
53
  """Run call(client, token, company_id, profile) for the signed-in company.
54
54
 
55
55
  profile is the employment info fetched when the session has no company
56
- id, else None. A missing session or token returns before a client opens.
56
+ id, else None. A missing token returns before a client opens; with
57
+ TALENTA_BEARER set, the session file is optional.
57
58
  """
58
- session = load_session(store)
59
- if isinstance(session, Result):
60
- return session
59
+ loaded = load_session(store)
60
+ session = loaded if not isinstance(loaded, Result) else None
61
61
  token = mobile_token(store, session=session)
62
62
  if isinstance(token, Result):
63
63
  return token
64
64
 
65
65
  with owned_client(client) as mekari:
66
66
  company_id = (
67
- session.profile.company_id.strip() if session.profile is not None else ""
67
+ session.profile.company_id.strip()
68
+ if session is not None and session.profile is not None
69
+ else ""
68
70
  )
69
71
  profile = None
70
72
  if not company_id:
@@ -5,16 +5,17 @@ from tlnt.core.session import SessionStore, load_session, mobile_token
5
5
 
6
6
 
7
7
  def status(store: SessionStore | None = None) -> Result:
8
- session = load_session(store)
9
- if isinstance(session, Result):
10
- return session
8
+ loaded = load_session(store)
9
+ session = loaded if not isinstance(loaded, Result) else None
11
10
  token = mobile_token(store, session)
12
11
  if isinstance(token, Result):
13
12
  return token
14
13
  # Expiry applies only to the saved token, never to TALENTA_BEARER.
15
14
  saved = (
16
15
  session.mobile
17
- if session.mobile is not None and session.mobile.access_token == token
16
+ if session is not None
17
+ and session.mobile is not None
18
+ and session.mobile.access_token == token
18
19
  else None
19
20
  )
20
21
  if saved is not None and saved.is_expired(datetime.now(timezone.utc)):