@2digits/tlo-mcp 0.1.38 → 1.0.0

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.
package/README.md CHANGED
@@ -1,102 +1,64 @@
1
1
  # @2digits/tlo-mcp
2
2
 
3
- MCP (Model Context Protocol) server for TeamLeader Orbit (TLO) - project management and time tracking.
3
+ Local MCP proxy for Teamleader Orbit. OAuth runs locally; your MCP client only needs stdio.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- pnpm add @2digits/tlo-mcp
8
+ vp add @2digits/tlo-mcp
9
9
  ```
10
10
 
11
11
  ## Usage
12
12
 
13
- ### As MCP Server
13
+ ### Login once
14
14
 
15
15
  ```bash
16
- TLO_COOKIE="your-session-cookie" npx @2digits/tlo-mcp
16
+ vp exec tlo-mcp login
17
17
  ```
18
18
 
19
- ### Configuration
19
+ Login opens your browser and listens on an ephemeral `127.0.0.1` callback. Each login uses fresh state and PKCE S256.
20
+ The proxy registers its own OAuth client; never reuse an existing authorization URL or another application's client ID.
20
21
 
21
- Set the `TLO_COOKIE` environment variable to your TeamLeader Orbit session cookie.
22
+ ### Start the MCP server
22
23
 
23
- ## Data Model
24
-
25
- ```text
26
- FOLDER (workspace, e.g., "2DIGITS | Projects")
27
- └── PROJECT (e.g., "I amsterdam | doorontwikkeling")
28
- ├── TASK (work items with budget/workload)
29
- │ └── ACTIVITY (time entries)
30
- └── BOARD (kanban)
31
- └── BOARDLIST (column)
32
- └── TODO (card)
24
+ ```bash
25
+ vp exec tlo-mcp
33
26
  ```
34
27
 
35
- ### Key IDs
36
-
37
- - `folderId` - Workspace containing projects
38
- - `projectId` - Project within a folder
39
- - `taskId` - Work item within project
40
- - `todoId` - Kanban card
41
- - `contactId` - User identifier
42
-
43
- ## Available Tools
44
-
45
- ### Projects
46
-
47
- | Tool | Description |
48
- | --------------------- | --------------------------------------------------- |
49
- | `get_projects` | List all projects with client, owner, dates, budget |
50
- | `get_project_details` | Get single project with billing rates |
51
- | `get_tasks` | Get tasks within a project |
52
- | `get_tasks_for_user` | Get tasks assigned to a user |
53
- | `set_task_state` | Change task state (DRAFT/OPEN/COMPLETED/CLOSED) |
54
-
55
- ### Time Tracking
28
+ Configure your MCP client to run `tlo-mcp` without arguments, or `node /absolute/path/to/dist/bin.mjs`.
29
+ No OAuth configuration, cookies or tokens belong in the client's config.
56
30
 
57
- | Tool | Description |
58
- | --------------------- | ------------------------------- |
59
- | `get_week_activities` | Get all time entries for a week |
60
- | `create_activity` | Log time against project/task |
61
- | `update_activity` | Modify existing time entry |
62
- | `delete_activity` | Remove time entry |
31
+ - Tools, descriptions, input/output schemas and annotations are discovered from the official MCP, including all pages.
32
+ - Access tokens refresh before expiry; rotated refresh tokens are saved before use.
33
+ - Official server instructions, tool content, structured results and `isError` are preserved.
34
+ - JSON and SSE responses are supported. Tool calls are never automatically replayed after failures or rate limits.
35
+ - Only tools are proxied; resources, prompts, sampling and upstream notification subscriptions are not currently forwarded.
36
+ - Tool discovery runs at startup; restart the proxy to discover changes upstream.
37
+ - Orbit's own availability and account permissions still apply.
63
38
 
64
- ### Kanban
39
+ ### Credentials and logout
65
40
 
66
- | Tool | Description |
67
- | ----------------- | -------------------------------------- |
68
- | `get_todo_detail` | Get kanban card with columns and links |
69
- | `move_todo` | Move card between columns |
41
+ macOS stores credentials in Keychain under `@2digits/tlo-mcp/orbit`; Keychain errors never fall back to plaintext.
42
+ Other platforms use `~/.config/2digits/tlo-mcp/session.json` with file mode `0600` and directory mode `0700`.
43
+ Windows ACL hardening is not provided; restrict access to your user profile.
44
+ Tokens never appear in process arguments or normal stdout. MCP diagnostics go to stderr.
70
45
 
71
- ### Messages
72
-
73
- | Tool | Description |
74
- | -------------- | ---------------------------------- |
75
- | `get_messages` | Get comments on project/board/todo |
76
- | `post_message` | Add comment to project/board/todo |
77
-
78
- ## Common Workflows
79
-
80
- ### View someone's week
81
-
82
- ```text
83
- get_week_activities(date: "2025-01-20", contactId: "1699127")
46
+ ```bash
47
+ vp exec tlo-mcp logout
84
48
  ```
85
49
 
86
- ### Log time
50
+ Logout deletes local credentials; it does not revoke the upstream grant (Orbit advertises no revocation endpoint).
51
+ Concurrent refresh/login is protected by a local lock. After a crashed process, confirm it is no longer running before
52
+ removing `~/.config/2digits/tlo-mcp/session.lock`. Do not remove a live process's lock.
87
53
 
88
- ```text
89
- 1. get_projects() → find folderId
90
- 2. get_tasks(projectId) → optionally find taskId
91
- 3. create_activity(folderId, startDate, durationMinutes, contactId)
92
- ```
54
+ ## Migrate from the cookie adapter
93
55
 
94
- ### Move kanban card
56
+ The cookie adapter, `legacy` command and hand-written tools have been removed, including their exported services,
57
+ schemas and layers. Only the official Orbit tools are available; discover their names and schemas through your MCP client.
95
58
 
96
- ```text
97
- 1. get_todo_detail(todoId) → get boardId and BOARDLISTS
98
- 2. move_todo(id, boardId, boardListId, sortIndex: 0)
99
- ```
59
+ Remove `legacy` from your command arguments and remove `TLO_SESSION_TOKEN`, `TLO_COOKIES` and `TLO_BASE_URL` from your
60
+ configuration. Run `tlo-mcp login`, then start `tlo-mcp` without arguments. Update workflows to use official Orbit tool
61
+ names and input schemas instead of the old snake_case tool names.
100
62
 
101
63
  ## License
102
64
 
package/dist/bin.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{T as e,_ as t,a as n,c as r,d as i,f as a,l as o,n as s,o as c,p as l,u,y as d}from"./TloLive-DHG59kAi.mjs";import*as f from"effect/Effect";import*as p from"effect/Layer";import*as m from"effect/Schema";import*as h from"@effect/platform-node/NodeRuntime";import*as g from"@effect/platform-node/NodeServices";import*as _ from"effect/cli/Command";import*as v from"effect/Logger";import*as y from"effect/ai/McpProtocol";import*as b from"effect/ai/McpServer";import*as x from"effect/ai/Toolkit";import*as S from"effect/ai/Tool";const C=m.Literals([`DRAFT`,`OPEN`,`COMPLETED`,`CLOSED`]),w=m.Literals([`TODO`,`BOARD`,`PROJECT`]),T=m.DateFromString.annotate({description:`ISO 8601 date string (e.g., 2025-01-20T10:00:00Z)`}),E=S.make(`get_projects`,{description:`List all projects. Returns projectId, folderId, client, owner, dates, and budget info. Use to discover projects before drilling into tasks or logging time. Data hierarchy: FOLDER → PROJECT → TASK → ACTIVITY.`,parameters:m.Struct({states:C.pipe(m.Array,m.optional).annotate({description:`Filter by project states: DRAFT, OPEN, COMPLETED, CLOSED. Defaults to DRAFT, OPEN, CLOSED`}),limit:m.optional(m.Finite).annotate({description:`Maximum number of projects to return. Defaults to 100`}),page:m.optional(m.Finite).annotate({description:`Page number for pagination. Defaults to 1`})}),success:m.Struct({projects:m.Array(o)}),failure:e,failureMode:`return`,dependencies:[c]}),D=S.make(`get_project_details`,{description:`Get single project with full details including billing rates and folder info. Requires projectId from get_projects.`,parameters:m.Struct({projectId:m.Finite.annotate({description:`Project ID from get_projects response`})}),success:m.Struct({project:o}),failure:e,failureMode:`return`,dependencies:[c]}),O=S.make(`get_messages`,{description:`Get comments/messages on a project, board, or todo. Use to read discussion history or context about work items.`,parameters:m.Struct({objectType:w.annotate({description:`Type of object: PROJECT (for project comments), BOARD (board-level), TODO (kanban card)`}),objectId:m.Finite.annotate({description:`ID of the project, board, or todo`}),onlyComments:m.optional(m.Boolean).annotate({description:`Only return user comments (exclude system messages). Defaults to true`}),hideInternal:m.optional(m.Boolean).annotate({description:`Hide internal/private messages. Defaults to true`}),limit:m.optional(m.Finite).annotate({description:`Maximum number of messages to return. Defaults to 100`})}),success:m.Struct({messages:m.Array(r)}),failure:e,failureMode:`return`,dependencies:[c]}),k=S.make(`set_task_state`,{description:`Change task state. Typical flow: DRAFT → OPEN → COMPLETED → CLOSED. Requires both projectId and taskId from get_tasks.`,parameters:m.Struct({projectId:m.Finite.annotate({description:`Project ID containing the task (from get_projects)`}),taskId:m.Finite.annotate({description:`Task ID to update (from get_tasks)`}),state:C.annotate({description:`New state: DRAFT, OPEN, COMPLETED, or CLOSED`})}),success:m.Void,failure:e,failureMode:`return`,dependencies:[c]}),A=S.make(`get_tasks`,{description:`Get tasks within a project. Tasks have budget (workload), remaining hours, and state. Use taskId when logging time to attribute work to specific deliverables.`,parameters:m.Struct({projectId:m.Finite.annotate({description:`Project ID from get_projects`}),states:C.pipe(m.Array,m.optional).annotate({description:`Filter by task states: DRAFT, OPEN, COMPLETED, CLOSED. Defaults to DRAFT, OPEN, CLOSED`}),limit:m.optional(m.Finite).annotate({description:`Maximum number of tasks to return. Defaults to 100`}),page:m.optional(m.Finite).annotate({description:`Page number for pagination. Defaults to 1`})}),success:m.Struct({tasks:m.Array(u)}),failure:e,failureMode:`return`,dependencies:[c]}),j=S.make(`get_tasks_for_user`,{description:`Get tasks assigned to a user for a date range. Returns tasks with REMAINING budget hours. Useful for finding what work is available to log time against.`,parameters:m.Struct({contactId:m.String.annotate({description:`User/contact ID to get tasks for`}),startDate:T.annotate({description:`Start date for the query (e.g., 2025-01-20T00:00:00Z)`}),period:m.Finite.annotate({description:`Number of days to include in the query`})}),success:m.Struct({tasks:m.Array(i)}),failure:e,failureMode:`return`,dependencies:[c]}),M=S.make(`get_todo_detail`,{description:`Get kanban card details. Response includes: BOARDLISTS (all columns with IDs for move_todo), LINKS (connected tasks), ACTIVITIES (time logged against this todo).`,parameters:m.Struct({id:m.Finite.annotate({description:`Todo/card ID to retrieve`})}),success:m.Struct({todo:a}),failure:e,failureMode:`return`,dependencies:[c]}),N=S.make(`get_board_todos`,{description:`List todos/cards from a kanban board. Use to find todo IDs by name for use with get_todo_detail. Get boardId from get_todo_detail BOARDID field or project board URL.`,parameters:m.Struct({boardId:m.Finite.annotate({description:`Board ID (from get_todo_detail TODO.BOARDID field or URL)`}),query:m.optional(m.String).annotate({description:`Filter todos by name (case-insensitive partial match)`}),boardListId:m.optional(m.Finite).annotate({description:`Filter by column ID (from BOARDLISTS in get_todo_detail)`}),limit:m.optional(m.Finite).annotate({description:`Maximum results. Defaults to 100`})}),success:m.Struct({todos:m.Array(l)}),failure:e,failureMode:`return`,dependencies:[c]}),P=S.make(`move_todo`,{description:`Move kanban card between columns. Get boardId and boardListId from get_todo_detail response (BOARDLISTS array contains column IDs).`,parameters:m.Struct({id:m.Finite.annotate({description:`Todo/card ID to move`}),boardId:m.Finite.annotate({description:`Board ID (from get_todo_detail)`}),boardListId:m.Finite.annotate({description:`Target column ID (from BOARDLISTS in get_todo_detail)`}),sortIndex:m.Finite.annotate({description:`Position within column (0 = top)`})}),success:m.Void,failure:e,failureMode:`return`,dependencies:[c]}),F=S.make(`post_message`,{description:`Add a comment to a project, board, or todo. Use to leave notes or updates on work items.`,parameters:m.Struct({objectType:w.annotate({description:`Type of object: PROJECT, BOARD, or TODO`}),objectId:m.Finite.annotate({description:`ID of the project, board, or todo to comment on`}),content:m.String.annotate({description:`Comment text to post`})}),success:m.Void,failure:e,failureMode:`return`,dependencies:[c]}),I=S.make(`get_week_activities`,{description:`Get all time entries for the week containing the given date. Returns project/task names, duration, and IDs. Use to review or summarize work. Response includes folderId which can be used for create_activity.`,parameters:m.Struct({date:T.annotate({description:`Any date within target week (e.g., 2025-01-20). Week is Mon-Sun.`}),contactId:m.String.annotate({description:`User/contact ID to get activities for`}),timezone:m.optional(m.String).annotate({description:`Timezone for week boundaries. Defaults to Europe/Amsterdam`})}),success:m.Struct({activities:m.Array(d)}),failure:e,failureMode:`return`,dependencies:[t]}),L=S.make(`create_activity`,{description:`Log time against a project/task. Get folderId from get_projects or get_week_activities. Duration examples: 60=1h, 90=1.5h, 120=2h. Optionally link to a taskId for specific work attribution or todoId for kanban card.`,parameters:m.Struct({folderId:m.String.annotate({description:`Folder/project ID to log time against (from get_projects or get_week_activities)`}),startDate:T.annotate({description:`Date and time of the activity (e.g., 2025-01-20T09:00:00Z). Time is for display.`}),durationMinutes:m.Finite.annotate({description:`Duration in minutes. Examples: 30, 60 (1h), 90 (1.5h), 120 (2h)`}),contactId:m.String.annotate({description:`User/contact ID who performed the work`}),taskId:m.optional(m.String).annotate({description:`Task ID to attribute time to (from get_tasks). Links time to specific deliverable.`}),todoId:m.optional(m.String).annotate({description:`Todo/kanban card ID to link this time entry to`}),description:m.optional(m.String).annotate({description:`Description of work performed`}),clientColor:m.optional(m.String).annotate({description:`Hex color code for display (e.g., #eeeeee)`})}),success:m.Struct({id:m.Finite.annotate({description:`ID of the created activity`})}),failure:e,failureMode:`return`,dependencies:[t]}),R=S.make(`update_activity`,{description:`Modify an existing time entry. Get activity ID from get_week_activities. Only specify fields you want to change.`,parameters:m.Struct({id:m.Finite.annotate({description:`Activity ID to update (from get_week_activities)`}),startDate:m.optional(T).annotate({description:`New date/time for the activity`}),durationMinutes:m.optional(m.Finite).annotate({description:`New duration in minutes`}),description:m.optional(m.String).annotate({description:`New description`})}),success:m.Void,failure:e,failureMode:`return`,dependencies:[t]}),z=S.make(`delete_activity`,{description:`Remove a time entry. Get activity ID from get_week_activities. This action cannot be undone.`,parameters:m.Struct({id:m.Finite.annotate({description:`Activity ID to delete (from get_week_activities)`})}),success:m.Void,failure:e,failureMode:`return`,dependencies:[t]}),B=x.make(E,D,O,A,j,M,N,P,F,k,I,L,R,z),V=B.toLayer({get_projects:f.fn(`TloToolkitHandlers.get_projects`)(function*(e){return{projects:yield*(yield*c).getProjects(e)}}),get_project_details:f.fn(`TloToolkitHandlers.get_project_details`)(function*(e){return{project:yield*(yield*c).getProjectDetails(e)}}),get_messages:f.fn(`TloToolkitHandlers.get_messages`)(function*(e){return{messages:yield*(yield*c).getMessages(e)}}),set_task_state:f.fn(`TloToolkitHandlers.set_task_state`)(function*(e){yield*(yield*c).setTaskState(e)}),get_tasks:f.fn(`TloToolkitHandlers.get_tasks`)(function*(e){return{tasks:yield*(yield*c).getTasks(e)}}),get_tasks_for_user:f.fn(`TloToolkitHandlers.get_tasks_for_user`)(function*(e){return{tasks:yield*(yield*c).getTasksForUser(e)}}),get_todo_detail:f.fn(`TloToolkitHandlers.get_todo_detail`)(function*(e){return{todo:yield*(yield*c).getTodoDetail(e)}}),get_board_todos:f.fn(`TloToolkitHandlers.get_board_todos`)(function*(e){return{todos:yield*(yield*c).getBoardTodos(e)}}),move_todo:f.fn(`TloToolkitHandlers.move_todo`)(function*(e){yield*(yield*c).moveTodo(e)}),post_message:f.fn(`TloToolkitHandlers.post_message`)(function*(e){yield*(yield*c).postMessage(e)}),get_week_activities:f.fn(`TloToolkitHandlers.get_week_activities`)(function*(e){return{activities:yield*(yield*t).getWeek(e.date,e.contactId,e.timezone)}}),create_activity:f.fn(`TloToolkitHandlers.create_activity`)(function*(e){return{id:yield*(yield*t).createActivity(e)}}),update_activity:f.fn(`TloToolkitHandlers.update_activity`)(function*(e){yield*(yield*t).updateActivity(e)}),delete_activity:f.fn(`TloToolkitHandlers.delete_activity`)(function*(e){yield*(yield*t).deleteActivity(e)})}),H=p.merge(v.layer([v.consolePretty()]),p.succeed(v.LogToStderr,!0));function U(e){return b.toolkit(B).pipe(p.provide(V),p.provide(b.layerStdio({...e,protocols:[y.v2025_06_18]})),p.provide(H))}const W=`tlo-mcp`,G=`0.0.0`,K=_.make(W,{},f.fn(`TloMcp.serve`)(function*(){return yield*U({name:W,version:G}).pipe(p.provide(s),p.provide(n),p.launch)}));f.fn(`TloMcp.run`)(function*(e){return yield*_.run(K,{version:G})})(process.argv).pipe(f.provide(g.layer),h.runMain);export{};
2
+ import{a as e,r as t,s as n,t as r}from"./proxy-BaBpBFTW.mjs";import*as i from"effect/Effect";import*as a from"effect/Layer";import*as o from"@effect/platform-node/NodeRuntime";import*as s from"@effect/platform-node/NodeServices";import*as c from"effect/cli/Command";const l=c.make(`login`,{},i.fn(`TloMcp.login`)(function*(){yield*(yield*e).login},i.provide(n),i.scoped)),u=c.make(`logout`,{},i.fn(`TloMcp.logout`)(function*(){yield*(yield*e).logout},i.provide(n),i.scoped)),d=c.make(`tlo-mcp`,{},()=>r.pipe(a.provide(t),a.provide(n),a.launch)).pipe(c.withSubcommands([l,u]));i.fn(`TloMcp.run`)(function*(e){return yield*c.runWith(d,{version:`0.1.38`})(e)})(process.argv.slice(2)).pipe(i.provide(s.layer),o.runMain);export{};
package/dist/index.d.mts CHANGED
@@ -1,513 +1,80 @@
1
+ import { OAuth } from "@yielded/oauth";
1
2
  import * as Context from "effect/Context";
3
+ import * as Crypto from "effect/Crypto";
2
4
  import * as Effect from "effect/Effect";
3
5
  import * as Layer from "effect/Layer";
4
6
  import * as Redacted from "effect/Redacted";
5
7
  import * as Schema from "effect/Schema";
6
- import * as Cookies from "effect/http/Cookies";
7
- import * as HttpClient from "effect/http/HttpClient";
8
- import * as Config from "effect/Config";
9
- import * as Brand from "effect/Brand";
10
- //#region src/services/TloConfig.d.ts
11
- interface TloConfigShape {
12
- readonly baseUrl: string;
13
- readonly sessionToken: Redacted.Redacted;
14
- readonly cookies: Cookies.Cookies;
15
- }
16
- declare const TloConfig_base: Context.ServiceClass<TloConfig, "@2digits/tlo-mcp/services/TloConfig", TloConfigShape>;
17
- export declare class TloConfig extends TloConfig_base {}
18
- //#endregion
19
- //#region src/schemas/errors.d.ts
20
- declare const TloApiError_base: Schema.Class<TloApiError, Schema.TaggedStruct<"TloApiError", {
21
- readonly message: Schema.String;
22
- readonly code: Schema.optional<Schema.String>;
23
- readonly endpoint: Schema.optional<Schema.String>;
24
- }>, import("effect/Cause").YieldableError>;
25
- /**
26
- * Error returned when the TLO API indicates failure. This occurs when success: false in the response envelope.
27
- */
28
- export declare class TloApiError extends TloApiError_base {}
29
- declare const TloAuthError_base: Schema.Class<TloAuthError, Schema.TaggedStruct<"TloAuthError", {
30
- readonly message: Schema.String;
31
- }>, import("effect/Cause").YieldableError>;
32
- /**
33
- * Error for authentication failures. Session token expired or invalid credentials.
34
- */
35
- export declare class TloAuthError extends TloAuthError_base {}
36
- declare const TloNetworkError_base: Schema.Class<TloNetworkError, Schema.TaggedStruct<"TloNetworkError", {
37
- readonly message: Schema.String;
38
- readonly cause: Schema.optional<Schema.Unknown>;
39
- readonly endpoint: Schema.optional<Schema.String>;
40
- }>, import("effect/Cause").YieldableError>;
41
- /**
42
- * Error for network/transport failures. Connection refused, timeout, etc.
43
- */
44
- export declare class TloNetworkError extends TloNetworkError_base {}
45
- declare const TloParseError_base: Schema.Class<TloParseError, Schema.TaggedStruct<"TloParseError", {
8
+ import { HttpClient } from "effect/http";
9
+ import { ChildProcessSpawner } from "effect/process";
10
+ import * as FileSystem from "effect/FileSystem";
11
+ import * as Path from "effect/Path";
12
+ import * as McpSchema from "effect/ai/McpSchema";
13
+ import * as Scope from "effect/Scope";
14
+ //#region src/oauth/session.d.ts
15
+ export declare const Session: Schema.Struct<{
16
+ readonly clientId: Schema.String;
17
+ readonly clientSecret: Schema.optionalKey<Schema.RedactedFromValue<Schema.String>>;
18
+ readonly accessToken: Schema.RedactedFromValue<Schema.String>;
19
+ readonly refreshToken: Schema.optionalKey<Schema.RedactedFromValue<Schema.String>>;
20
+ readonly expiresAt: Schema.optionalKey<Schema.Finite>;
21
+ }>;
22
+ export interface Session extends Schema.Schema.Type<typeof Session> {}
23
+ declare const OrbitAuthError_base: Schema.Class<OrbitAuthError, Schema.TaggedStruct<"OrbitAuthError", {
46
24
  readonly message: Schema.String;
47
- readonly cause: Schema.optional<Schema.Unknown>;
48
25
  }>, import("effect/Cause").YieldableError>;
49
- /**
50
- * Error when response parsing fails. Unexpected response format from TLO.
51
- */
52
- export declare class TloParseError extends TloParseError_base {}
53
- type TloError = TloApiError | TloAuthError | TloNetworkError | TloParseError;
26
+ export declare class OrbitAuthError extends OrbitAuthError_base {}
54
27
  //#endregion
55
- //#region src/services/TloHttpClient.d.ts
56
- interface TloHttpClientShape {
57
- readonly client: HttpClient.HttpClient;
58
- }
59
- declare const TloHttpClient_base: Context.ServiceClass<TloHttpClient, "@2digits/tlo-mcp/services/TloHttpClient", TloHttpClientShape>;
60
- declare class TloHttpClient extends TloHttpClient_base {}
61
- //#endregion
62
- //#region src/services/TeamLeaderClient.d.ts
63
- interface TeamLeaderClientShape {
64
- readonly post: <TSchema extends Schema.Constraint>(path: string, body: Record<string, string | number | boolean | undefined>, schema: TSchema) => Effect.Effect<TSchema['Type'], TloError, TSchema['DecodingServices']>;
65
- }
66
- declare const TeamLeaderClient_base: Context.ServiceClass<TeamLeaderClient, "@2digits/tlo-mcp/services/TeamLeaderClient", TeamLeaderClientShape>;
67
- export declare class TeamLeaderClient extends TeamLeaderClient_base {}
68
- export declare const TeamLeaderClientLive: Layer.Layer<TeamLeaderClient, never, TloConfig | TloHttpClient>;
69
- //#endregion
70
- //#region src/schemas/time.d.ts
28
+ //#region src/oauth/store.d.ts
29
+ interface SessionStoreShape {
30
+ readonly load: Effect.Effect<Session | undefined, OrbitAuthError>;
31
+ readonly save: (session: Session) => Effect.Effect<void, OrbitAuthError>;
32
+ readonly clear: Effect.Effect<void, OrbitAuthError>;
33
+ readonly lock: Effect.Effect<void, OrbitAuthError, Scope.Scope>;
34
+ }
35
+ declare const SessionStore_base: Context.ServiceClass<SessionStore, "@2digits/tlo-mcp/oauth/store/SessionStore", SessionStoreShape>;
36
+ export declare class SessionStore extends SessionStore_base {}
71
37
  /**
72
- * Raw activity from TLO API response. Field names match the API exactly.
38
+ * Keychain on macOS; private atomic files elsewhere. Credentials never enter argv.
39
+ *
40
+ * @param options
41
+ * @param options.directory
42
+ * @param options.platform
73
43
  */
74
- declare const ActivityRaw: Schema.Struct<{
75
- readonly ID: Schema.Finite;
76
- readonly FOLDERID: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Finite]>>;
77
- readonly PROJECT_ID: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Finite]>>;
78
- readonly TASKID: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.String, Schema.Finite]>>>;
79
- readonly TODOID: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.String, Schema.Finite]>>>;
80
- readonly TICKETID: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.String, Schema.Finite]>>>;
81
- readonly CONTACTID: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Finite]>>;
82
- readonly DESCRIPTION: Schema.NullOr<Schema.String>;
83
- readonly DT: Schema.String;
84
- readonly START_DT: Schema.optional<Schema.String>;
85
- readonly END_DT: Schema.optional<Schema.String>;
86
- readonly DURATION: Schema.Finite;
87
- readonly TYPE: Schema.optional<Schema.Finite>;
88
- readonly PROJECT_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
89
- readonly TASK_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
90
- readonly CLIENT_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
91
- readonly FOLDER_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
92
- readonly ENTITY_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
93
- readonly PROJECTOWNER_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
94
- readonly CLIENT_COLOR: Schema.optional<Schema.NullOr<Schema.String>>;
95
- readonly PROJECT_COLOR: Schema.optional<Schema.NullOr<Schema.String>>;
96
- readonly PROJECT_STATE: Schema.optional<Schema.NullOr<Schema.String>>;
97
- readonly TASK_STATE: Schema.optional<Schema.NullOr<Schema.String>>;
98
- readonly TIMESHEET_STATE: Schema.optional<Schema.NullOr<Schema.String>>;
99
- readonly BILLING_MODE: Schema.optional<Schema.NullOr<Schema.String>>;
100
- readonly NON_BILLABLE: Schema.optional<Schema.NullOr<Schema.Finite>>;
101
- readonly RATE: Schema.optional<Schema.NullOr<Schema.Finite>>;
102
- readonly VALUE: Schema.optional<Schema.NullOr<Schema.Finite>>;
103
- readonly PROJECT_START_DT: Schema.optional<Schema.NullOr<Schema.String>>;
104
- readonly PROJECT_END_DT: Schema.optional<Schema.NullOr<Schema.String>>;
105
- readonly TASK_START_DT: Schema.optional<Schema.NullOr<Schema.String>>;
106
- readonly TASK_END_DT: Schema.optional<Schema.NullOr<Schema.String>>;
107
- readonly READONLY: Schema.optional<Schema.NullOr<Schema.Finite>>;
108
- readonly TASK_WORKLOAD: Schema.optional<Schema.NullOr<Schema.Finite>>;
109
- }>;
110
- type ActivityRaw = typeof ActivityRaw.Type;
111
- declare const Activity_base: Schema.Class<Activity, Schema.Struct<{
112
- readonly id: Schema.Finite;
113
- readonly projectId: Schema.optional<Schema.String>;
114
- readonly folderId: Schema.optional<Schema.String>;
115
- readonly taskId: Schema.optional<Schema.NullOr<Schema.String>>;
116
- readonly todoId: Schema.optional<Schema.NullOr<Schema.String>>;
117
- readonly ticketId: Schema.optional<Schema.NullOr<Schema.String>>;
118
- readonly userId: Schema.optional<Schema.String>;
119
- readonly description: Schema.NullOr<Schema.String>;
120
- readonly startDate: Schema.String;
121
- readonly endDate: Schema.optional<Schema.String>;
122
- readonly durationMinutes: Schema.Finite;
123
- readonly projectName: Schema.optional<Schema.NullOr<Schema.String>>;
124
- readonly taskName: Schema.optional<Schema.NullOr<Schema.String>>;
125
- readonly clientName: Schema.optional<Schema.NullOr<Schema.String>>;
126
- readonly folderName: Schema.optional<Schema.NullOr<Schema.String>>;
127
- readonly entityName: Schema.optional<Schema.NullOr<Schema.String>>;
128
- readonly projectOwnerName: Schema.optional<Schema.NullOr<Schema.String>>;
129
- readonly projectState: Schema.optional<Schema.NullOr<Schema.String>>;
130
- readonly taskState: Schema.optional<Schema.NullOr<Schema.String>>;
131
- readonly timesheetState: Schema.optional<Schema.NullOr<Schema.String>>;
132
- readonly billingMode: Schema.optional<Schema.NullOr<Schema.String>>;
133
- readonly nonBillable: Schema.optional<Schema.NullOr<Schema.Finite>>;
134
- readonly rate: Schema.optional<Schema.NullOr<Schema.Finite>>;
135
- readonly value: Schema.optional<Schema.NullOr<Schema.Finite>>;
136
- readonly projectStartDate: Schema.optional<Schema.NullOr<Schema.String>>;
137
- readonly projectEndDate: Schema.optional<Schema.NullOr<Schema.String>>;
138
- readonly taskStartDate: Schema.optional<Schema.NullOr<Schema.String>>;
139
- readonly taskEndDate: Schema.optional<Schema.NullOr<Schema.String>>;
140
- readonly readOnly: Schema.optional<Schema.NullOr<Schema.Boolean>>;
141
- readonly taskWorkload: Schema.optional<Schema.NullOr<Schema.Finite>>;
142
- readonly projectColor: Schema.optional<Schema.String>;
143
- readonly clientColor: Schema.optional<Schema.String>;
144
- }>, {
145
- readonly brand: unique symbol;
146
- }>;
147
- export declare class Activity extends Activity_base {}
148
- export declare function activityFromRaw(raw: ActivityRaw): Activity;
149
- declare const GetWeekResponse: Schema.Struct<{
150
- readonly ACTIVITIES: Schema.$Array<Schema.Struct<{
151
- readonly ID: Schema.Finite;
152
- readonly FOLDERID: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Finite]>>;
153
- readonly PROJECT_ID: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Finite]>>;
154
- readonly TASKID: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.String, Schema.Finite]>>>;
155
- readonly TODOID: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.String, Schema.Finite]>>>;
156
- readonly TICKETID: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.String, Schema.Finite]>>>;
157
- readonly CONTACTID: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Finite]>>;
158
- readonly DESCRIPTION: Schema.NullOr<Schema.String>;
159
- readonly DT: Schema.String;
160
- readonly START_DT: Schema.optional<Schema.String>;
161
- readonly END_DT: Schema.optional<Schema.String>;
162
- readonly DURATION: Schema.Finite;
163
- readonly TYPE: Schema.optional<Schema.Finite>;
164
- readonly PROJECT_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
165
- readonly TASK_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
166
- readonly CLIENT_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
167
- readonly FOLDER_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
168
- readonly ENTITY_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
169
- readonly PROJECTOWNER_NAME: Schema.optional<Schema.NullOr<Schema.String>>;
170
- readonly CLIENT_COLOR: Schema.optional<Schema.NullOr<Schema.String>>;
171
- readonly PROJECT_COLOR: Schema.optional<Schema.NullOr<Schema.String>>;
172
- readonly PROJECT_STATE: Schema.optional<Schema.NullOr<Schema.String>>;
173
- readonly TASK_STATE: Schema.optional<Schema.NullOr<Schema.String>>;
174
- readonly TIMESHEET_STATE: Schema.optional<Schema.NullOr<Schema.String>>;
175
- readonly BILLING_MODE: Schema.optional<Schema.NullOr<Schema.String>>;
176
- readonly NON_BILLABLE: Schema.optional<Schema.NullOr<Schema.Finite>>;
177
- readonly RATE: Schema.optional<Schema.NullOr<Schema.Finite>>;
178
- readonly VALUE: Schema.optional<Schema.NullOr<Schema.Finite>>;
179
- readonly PROJECT_START_DT: Schema.optional<Schema.NullOr<Schema.String>>;
180
- readonly PROJECT_END_DT: Schema.optional<Schema.NullOr<Schema.String>>;
181
- readonly TASK_START_DT: Schema.optional<Schema.NullOr<Schema.String>>;
182
- readonly TASK_END_DT: Schema.optional<Schema.NullOr<Schema.String>>;
183
- readonly READONLY: Schema.optional<Schema.NullOr<Schema.Finite>>;
184
- readonly TASK_WORKLOAD: Schema.optional<Schema.NullOr<Schema.Finite>>;
185
- }>>;
186
- }>;
187
- type GetWeekResponse = typeof GetWeekResponse.Type;
188
- declare const SetActivityResponse: Schema.Struct<{
189
- readonly ID: Schema.Finite;
190
- readonly DURATION: Schema.optional<Schema.Finite>;
191
- readonly DT: Schema.optional<Schema.String>;
192
- readonly TYPE: Schema.optional<Schema.Finite>;
193
- readonly DESCRIPTION: Schema.optional<Schema.NullOr<Schema.String>>;
194
- readonly CLIENT_COLOR: Schema.optional<Schema.String>;
195
- readonly FOLDERID: Schema.optional<Schema.Union<readonly [Schema.String, Schema.Finite]>>;
196
- }>;
197
- type SetActivityResponse = typeof SetActivityResponse.Type;
198
- interface CreateActivityParams {
199
- readonly folderId: string;
200
- readonly taskId?: string;
201
- readonly todoId?: string;
202
- readonly startDate: Date;
203
- readonly durationMinutes: number;
204
- readonly description?: string;
205
- readonly contactId: string;
206
- readonly clientColor?: string;
207
- }
208
- interface UpdateActivityParams {
209
- readonly id: number;
210
- readonly startDate?: Date;
211
- readonly durationMinutes?: number;
212
- readonly description?: string;
213
- }
214
- interface DeleteActivityParams {
215
- readonly id: number;
216
- }
217
- //#endregion
218
- //#region src/services/TimeService.d.ts
219
- interface TimeServiceShape {
220
- readonly getWeek: (date: Date, contactId: string, timezone?: string) => Effect.Effect<ReadonlyArray<Activity>, TloError>;
221
- readonly createActivity: (params: CreateActivityParams) => Effect.Effect<number, TloError>;
222
- readonly updateActivity: (params: UpdateActivityParams) => Effect.Effect<void, TloError>;
223
- readonly deleteActivity: (params: DeleteActivityParams) => Effect.Effect<void, TloError>;
224
- }
225
- declare const TimeService_base: Context.ServiceClass<TimeService, "@2digits/tlo-mcp/services/TimeService", TimeServiceShape>;
226
- export declare class TimeService extends TimeService_base {}
227
- export declare const TimeServiceLive: Layer.Layer<TimeService, never, TeamLeaderClient>;
228
- //#endregion
229
- //#region src/schemas/board.d.ts
230
- type ProjectRaw = typeof ProjectRaw.Type;
231
- declare const ProjectRaw: Schema.Struct<{
232
- readonly ID: Schema.Finite;
233
- readonly PROJECT_NAME: Schema.optional<Schema.String>;
234
- readonly NAME: Schema.optional<Schema.String>;
235
- readonly STATE: Schema.optional<Schema.String>;
236
- readonly OWNER_NAME: Schema.optional<Schema.String>;
237
- readonly START_DT: Schema.optional<Schema.String>;
238
- readonly END_DT: Schema.optional<Schema.String>;
239
- readonly BILLING_BUDGET: Schema.optional<Schema.Finite>;
240
- readonly BILLING_MODE: Schema.optional<Schema.String>;
241
- readonly BILLING_REMAINING: Schema.optional<Schema.Finite>;
242
- readonly CLIENT_NAME: Schema.optional<Schema.String>;
243
- readonly CLIENT_ID: Schema.optional<Schema.Finite>;
244
- readonly FOLDERID: Schema.optional<Schema.Finite>;
245
- readonly FOLDER_NAME: Schema.optional<Schema.String>;
246
- readonly EXTID: Schema.optional<Schema.String>;
247
- readonly CALC_TOTAL: Schema.optional<Schema.Finite>;
248
- readonly CALC_DONE: Schema.optional<Schema.Finite>;
249
- readonly CALC_PLANNED: Schema.optional<Schema.Finite>;
250
- }>;
251
- declare const Project_base: Schema.Class<Project, Schema.Struct<{
252
- readonly id: Schema.Finite;
253
- readonly name: Schema.String;
254
- readonly state: Schema.optional<Schema.String>;
255
- readonly ownerName: Schema.optional<Schema.String>;
256
- readonly startDate: Schema.optional<Schema.String>;
257
- readonly endDate: Schema.optional<Schema.String>;
258
- readonly billingBudget: Schema.optional<Schema.Finite>;
259
- readonly billingMode: Schema.optional<Schema.String>;
260
- readonly billingRemaining: Schema.optional<Schema.Finite>;
261
- readonly clientName: Schema.optional<Schema.String>;
262
- readonly clientId: Schema.optional<Schema.Finite>;
263
- readonly folderId: Schema.optional<Schema.Finite>;
264
- readonly folderName: Schema.optional<Schema.String>;
265
- readonly extId: Schema.optional<Schema.String>;
266
- readonly calcTotal: Schema.optional<Schema.Finite>;
267
- readonly calcDone: Schema.optional<Schema.Finite>;
268
- readonly calcPlanned: Schema.optional<Schema.Finite>;
269
- }>, {
270
- readonly brand: unique symbol;
271
- }>;
272
- export declare class Project extends Project_base {}
273
- export declare function projectFromRaw(raw: ProjectRaw): Project;
274
- type MessageRaw = typeof MessageRaw.Type;
275
- declare const MessageRaw: Schema.Struct<{
276
- readonly ID: Schema.Finite;
277
- readonly OWNERID: Schema.optional<Schema.Finite>;
278
- readonly OWNER_NAME: Schema.optional<Schema.String>;
279
- readonly AVATAR: Schema.optional<Schema.String>;
280
- readonly CREATED_DT: Schema.optional<Schema.String>;
281
- readonly CONTENT: Schema.optional<Schema.String>;
282
- readonly SUBCONTENT: Schema.optional<Schema.String>;
283
- readonly OBJECTTYPE: Schema.optional<Schema.String>;
284
- readonly OBJECTID: Schema.optional<Schema.Finite>;
285
- readonly OBJECTNAME: Schema.optional<Schema.String>;
286
- readonly MSGTYPE: Schema.optional<Schema.String>;
287
- readonly LIKECNT: Schema.optional<Schema.Finite>;
288
- readonly REPLYCNT: Schema.optional<Schema.Finite>;
289
- readonly OUTQUEUEID: Schema.optional<Schema.String>;
290
- readonly INTERNAL: Schema.optional<Schema.Finite>;
291
- }>;
292
- declare const Message_base: Schema.Class<Message, Schema.Struct<{
293
- readonly id: Schema.Finite;
294
- readonly ownerId: Schema.optional<Schema.Finite>;
295
- readonly ownerName: Schema.optional<Schema.String>;
296
- readonly avatar: Schema.optional<Schema.String>;
297
- readonly createdAt: Schema.optional<Schema.String>;
298
- readonly content: Schema.optional<Schema.String>;
299
- readonly subcontent: Schema.optional<Schema.String>;
300
- readonly objectType: Schema.optional<Schema.String>;
301
- readonly objectId: Schema.optional<Schema.Finite>;
302
- readonly objectName: Schema.optional<Schema.String>;
303
- readonly messageType: Schema.optional<Schema.String>;
304
- readonly likeCount: Schema.optional<Schema.Finite>;
305
- readonly replyCount: Schema.optional<Schema.Finite>;
306
- readonly outQueueId: Schema.optional<Schema.String>;
307
- readonly internal: Schema.optional<Schema.Boolean>;
308
- }>, {
309
- readonly brand: unique symbol;
310
- }>;
311
- export declare class Message extends Message_base {}
312
- export declare function messageFromRaw(raw: MessageRaw): Message;
313
- type TaskState = 'OPEN' | 'COMPLETED' | 'DRAFT' | 'CLOSED';
314
- type TaskRaw = typeof TaskRaw.Type;
315
- declare const TaskRaw: Schema.Struct<{
316
- readonly ID: Schema.Finite;
317
- readonly PROJECTID: Schema.optional<Schema.Finite>;
318
- readonly NAME: Schema.optional<Schema.String>;
319
- readonly STATE: Schema.optional<Schema.String>;
320
- readonly OWNER_NAME: Schema.optional<Schema.String>;
321
- readonly START_DT: Schema.optional<Schema.String>;
322
- readonly END_DT: Schema.optional<Schema.String>;
323
- readonly BUDGET: Schema.optional<Schema.Finite>;
324
- }>;
325
- declare const Task_base: Schema.Class<Task, Schema.Struct<{
326
- readonly id: Schema.Finite;
327
- readonly projectId: Schema.optional<Schema.Finite>;
328
- readonly name: Schema.optional<Schema.String>;
329
- readonly state: Schema.optional<Schema.String>;
330
- readonly ownerName: Schema.optional<Schema.String>;
331
- readonly startDate: Schema.optional<Schema.String>;
332
- readonly endDate: Schema.optional<Schema.String>;
333
- readonly budget: Schema.optional<Schema.Finite>;
334
- }>, {
335
- readonly brand: unique symbol;
336
- }>;
337
- export declare class Task extends Task_base {}
338
- interface SetTaskStateParams {
339
- readonly projectId: number;
340
- readonly taskId: number;
341
- readonly state: TaskState;
342
- }
343
- interface GetMessagesParams {
344
- readonly objectType: 'TODO' | 'BOARD' | 'PROJECT';
345
- readonly objectId: number;
346
- readonly onlyComments?: boolean;
347
- readonly hideInternal?: boolean;
348
- readonly limit?: number;
349
- }
350
- interface GetProjectsParams {
351
- readonly states?: ReadonlyArray<TaskState>;
352
- readonly limit?: number;
353
- readonly page?: number;
354
- }
355
- type TaskForUserRaw = typeof TaskForUserRaw.Type;
356
- declare const TaskForUserRaw: Schema.Struct<{
357
- readonly ID: Schema.Finite;
358
- readonly WORKLOAD: Schema.optional<Schema.Finite>;
359
- readonly TOTAL: Schema.optional<Schema.Finite>;
360
- readonly REMAINING: Schema.optional<Schema.Finite>;
361
- readonly AVAIL: Schema.optional<Schema.Finite>;
362
- readonly CLIENTID: Schema.optional<Schema.Finite>;
363
- readonly PROJECTID: Schema.optional<Schema.Finite>;
364
- readonly PROJECT_START_DT: Schema.optional<Schema.String>;
365
- readonly PROJECT_END_DT: Schema.optional<Schema.String>;
366
- readonly START_DT: Schema.optional<Schema.String>;
367
- readonly END_DT: Schema.optional<Schema.String>;
368
- readonly STATE: Schema.optional<Schema.String>;
369
- }>;
370
- declare const TaskForUser_base: Schema.Class<TaskForUser, Schema.Struct<{
371
- readonly id: Schema.Finite;
372
- readonly workload: Schema.optional<Schema.Finite>;
373
- readonly total: Schema.optional<Schema.Finite>;
374
- readonly remaining: Schema.optional<Schema.Finite>;
375
- readonly avail: Schema.optional<Schema.Finite>;
376
- readonly clientId: Schema.optional<Schema.Finite>;
377
- readonly projectId: Schema.optional<Schema.Finite>;
378
- readonly projectStartDate: Schema.optional<Schema.String>;
379
- readonly projectEndDate: Schema.optional<Schema.String>;
380
- readonly startDate: Schema.optional<Schema.String>;
381
- readonly endDate: Schema.optional<Schema.String>;
382
- readonly state: Schema.optional<Schema.String>;
383
- }>, {
384
- readonly brand: unique symbol;
385
- }>;
386
- export declare class TaskForUser extends TaskForUser_base {}
387
- export type TodoDetail = typeof TodoDetail.Type;
388
- export declare const TodoDetail: Schema.$Record<Schema.String, Schema.Unknown>;
389
- type TodoSummaryRaw = typeof TodoSummaryRaw.Type;
390
- declare const TodoSummaryRaw: Schema.Struct<{
391
- readonly ID: Schema.Finite;
392
- readonly NAME: Schema.optional<Schema.String>;
393
- readonly BOARDLISTID: Schema.optional<Schema.Finite>;
394
- readonly BOARDID: Schema.optional<Schema.Finite>;
395
- readonly OWNERID: Schema.optional<Schema.Finite>;
396
- readonly EXTID: Schema.optional<Schema.String>;
397
- readonly STATE: Schema.optional<Schema.NullOr<Schema.String>>;
398
- readonly DUE_DT: Schema.optional<Schema.NullOr<Schema.String>>;
399
- readonly DESCRIPTION: Schema.optional<Schema.NullOr<Schema.String>>;
400
- }>;
401
- declare const TodoSummary_base: Schema.Class<TodoSummary, Schema.Struct<{
402
- readonly id: Schema.Finite;
403
- readonly name: Schema.optional<Schema.String>;
404
- readonly boardListId: Schema.optional<Schema.Finite>;
405
- readonly boardId: Schema.optional<Schema.Finite>;
406
- readonly ownerId: Schema.optional<Schema.Finite>;
407
- readonly extId: Schema.optional<Schema.String>;
408
- readonly state: Schema.optional<Schema.NullOr<Schema.String>>;
409
- readonly dueDate: Schema.optional<Schema.NullOr<Schema.String>>;
410
- readonly description: Schema.optional<Schema.NullOr<Schema.String>>;
411
- }>, {
412
- readonly brand: unique symbol;
413
- }>;
414
- export declare class TodoSummary extends TodoSummary_base {}
415
- export declare function todoSummaryFromRaw(raw: TodoSummaryRaw): TodoSummary;
416
- interface GetBoardTodosParams {
417
- readonly boardId: number;
418
- readonly boardListId?: number;
419
- readonly query?: string;
420
- readonly limit?: number;
421
- }
422
- interface GetTasksParams {
423
- readonly projectId: number;
424
- readonly states?: ReadonlyArray<TaskState>;
425
- readonly limit?: number;
426
- readonly page?: number;
427
- }
428
- interface GetProjectDetailsParams {
429
- readonly projectId: number;
430
- }
431
- interface GetTasksForUserParams {
432
- readonly contactId: string;
433
- readonly startDate: Date;
434
- readonly period: number;
435
- }
436
- interface GetTodoDetailParams {
437
- readonly id: number;
438
- }
439
- interface MoveTodoParams {
440
- readonly id: number;
441
- readonly boardId: number;
442
- readonly boardListId: number;
443
- readonly sortIndex: number;
444
- }
445
- interface PostMessageParams {
446
- readonly objectType: 'TODO' | 'BOARD' | 'PROJECT';
447
- readonly objectId: number;
448
- readonly content: string;
449
- }
450
- //#endregion
451
- //#region src/services/BoardService.d.ts
452
- interface BoardServiceShape {
453
- readonly getProjects: (params?: GetProjectsParams) => Effect.Effect<ReadonlyArray<Project>, TloError>;
454
- readonly getProjectDetails: (params: GetProjectDetailsParams) => Effect.Effect<Project, TloError>;
455
- readonly getMessages: (params: GetMessagesParams) => Effect.Effect<ReadonlyArray<Message>, TloError>;
456
- readonly getTasks: (params: GetTasksParams) => Effect.Effect<ReadonlyArray<Task>, TloError>;
457
- readonly getTasksForUser: (params: GetTasksForUserParams) => Effect.Effect<ReadonlyArray<TaskForUser>, TloError>;
458
- readonly getTodoDetail: (params: GetTodoDetailParams) => Effect.Effect<TodoDetail, TloError>;
459
- readonly getBoardTodos: (params: GetBoardTodosParams) => Effect.Effect<ReadonlyArray<TodoSummary>, TloError>;
460
- readonly moveTodo: (params: MoveTodoParams) => Effect.Effect<void, TloError>;
461
- readonly postMessage: (params: PostMessageParams) => Effect.Effect<void, TloError>;
462
- readonly setTaskState: (params: SetTaskStateParams) => Effect.Effect<void, TloError>;
463
- }
464
- declare const BoardService_base: Context.ServiceClass<BoardService, "@2digits/tlo-mcp/services/BoardService", BoardServiceShape>;
465
- export declare class BoardService extends BoardService_base {}
466
- export declare const BoardServiceLive: Layer.Layer<BoardService, never, TeamLeaderClient>;
44
+ export declare function makeSessionStoreLayer(options?: {
45
+ readonly directory?: string;
46
+ readonly platform?: string;
47
+ }): Layer.Layer<SessionStore, never, ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem | Path.Path>;
48
+ export declare const SessionStoreLive: Layer.Layer<SessionStore, never, ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem | Path.Path>;
467
49
  //#endregion
468
- //#region src/layers/TloConfigLive.d.ts
469
- export declare const TloConfigFromEnv: Effect.Effect<TloConfigShape, Config.ConfigError | Cookies.CookiesError>;
470
- export declare const TloConfigLive: Layer.Layer<TloConfig, Config.ConfigError | Cookies.CookiesError>;
50
+ //#region src/oauth/OrbitAuth.d.ts
51
+ interface OrbitAuthShape {
52
+ readonly login: Effect.Effect<void, OrbitAuthError>;
53
+ readonly logout: Effect.Effect<void, OrbitAuthError>;
54
+ readonly accessToken: Effect.Effect<Redacted.Redacted, OrbitAuthError>;
55
+ }
56
+ declare const OrbitAuth_base: Context.ServiceClass<OrbitAuth, "@2digits/tlo-mcp/oauth/OrbitAuth", OrbitAuthShape>;
57
+ export declare class OrbitAuth extends OrbitAuth_base {}
58
+ export declare const OrbitAuthLayer: Layer.Layer<OrbitAuth, never, ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto | HttpClient.HttpClient | SessionStore>;
59
+ export declare const OrbitAuthLive: Layer.Layer<OrbitAuth, never, ChildProcessSpawner.ChildProcessSpawner | Crypto.Crypto | import("effect/FileSystem").FileSystem | import("effect/Path").Path>;
471
60
  //#endregion
472
- //#region src/layers/TloLive.d.ts
473
- export declare const TloServicesLive: Layer.Layer<BoardService | TimeService, never, TeamLeaderClient>;
474
- export declare const TloClientLive: Layer.Layer<TeamLeaderClient, never, TloConfig>;
475
- export declare const TloLive: Layer.Layer<TimeService | BoardService, never, TloConfig>;
476
- //#endregion
477
- //#region src/schemas/common.d.ts
478
- /**
479
- * TeamLeader Orbit uses YYYYMMDDHHMMSS format for dates. Example: "20251117143000" = Nov 17, 2025 14:30:00.
480
- */
481
- export declare const TloDateString: Schema.brand<Schema.String, "TloDateString">;
482
- export type TloDateString = typeof TloDateString.Type;
483
- /**
484
- * Format Date to YYYYMMDDHHMMSS string.
485
- *
486
- * @param date - Date to format.
487
- */
488
- declare function formatTloDate(date: Date): TloDateString;
489
- /**
490
- * Transform between TLO date strings and JavaScript Date objects.
491
- */
492
- export declare const TloDate: Schema.decodeTo<Schema.Date, Schema.brand<Schema.String, "TloDateString">, never, never>;
493
- export type TloDate = typeof TloDate.Type;
494
- /**
495
- * TLO entity IDs are numeric strings.
496
- */
497
- export type TloId = string & Brand.Brand<'TloId'>;
498
- export declare const TloId: Brand.Constructor<TloId>;
499
- export declare const TloIdSchema: Schema.brand<Schema.String, "TloId">;
61
+ //#region src/mcp/OrbitClient.d.ts
62
+ declare const OrbitMcpError_base: Schema.Class<OrbitMcpError, Schema.TaggedStruct<"OrbitMcpError", {
63
+ readonly message: Schema.String;
64
+ }>, import("effect/Cause").YieldableError>;
65
+ export declare class OrbitMcpError extends OrbitMcpError_base {}
66
+ interface OrbitClientShape {
67
+ readonly tools: ReadonlyArray<McpSchema.Tool>;
68
+ readonly instructions: string | undefined;
69
+ readonly callTool: (name: string, arguments_: Schema.JsonObject) => Effect.Effect<McpSchema.CallToolResult, OrbitMcpError>;
70
+ }
71
+ declare const OrbitClient_base: Context.ServiceClass<OrbitClient, "@2digits/tlo-mcp/mcp/OrbitClient", OrbitClientShape>;
72
+ export declare class OrbitClient extends OrbitClient_base {}
500
73
  /**
501
- * Standard TLO API response envelope schema. Note: Most endpoints return data directly without this wrapper. Kept for
502
- * potential use with endpoints that do use the envelope pattern.
503
- *
504
- * @param dataSchema - Data schema to wrap.
74
+ * Streamable HTTP request/response transport; no retry of possibly committed tool calls.
505
75
  */
506
- export declare function TloResponse<T>(dataSchema: Schema.Schema<T>): Schema.Struct<{
507
- readonly success: Schema.Boolean;
508
- readonly ID: Schema.optional<Schema.Finite>;
509
- readonly OBJ: Schema.Schema<T>;
510
- readonly err: Schema.optional<Schema.String>;
511
- }>;
76
+ export declare const OrbitClientLive: Layer.Layer<OrbitClient, OrbitMcpError | Schema.SchemaError, OrbitAuth>;
512
77
  //#endregion
513
- export { type ActivityRaw, type BoardServiceShape, type CreateActivityParams, type DeleteActivityParams, type GetBoardTodosParams, type GetMessagesParams, type GetProjectDetailsParams, type GetProjectsParams, type GetTasksForUserParams, type GetTodoDetailParams, type GetWeekResponse, type MessageRaw, type MoveTodoParams, type PostMessageParams, type ProjectRaw, type SetActivityResponse, type SetTaskStateParams, type TaskForUserRaw, type TaskRaw, type TaskState, type TeamLeaderClientShape, type TimeServiceShape, type TloConfigShape, type TloError, type UpdateActivityParams, formatTloDate };
78
+ //#region src/mcp/proxy.d.ts
79
+ export declare const OrbitProxyLive: Layer.Layer<never, import("effect/Cause").IllegalArgumentError, OrbitClient | import("effect/Stdio").Stdio>;
80
+ //#endregion
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{C as e,D as t,E as n,O as r,S as i,_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S,v as C,w,x as T,y as E}from"./TloLive-DHG59kAi.mjs";import*as D from"effect/Schema";import*as O from"effect/Brand";import*as k from"effect/DateTime";import*as A from"effect/SchemaTransformation";const j=D.String.pipe(D.check(D.isPattern(/^\d{14}$/)),D.brand(`TloDateString`));function M(e){let t=Number.parseInt(e.slice(0,4),10),n=Number.parseInt(e.slice(4,6),10),r=Number.parseInt(e.slice(6,8),10),i=Number.parseInt(e.slice(8,10),10),a=Number.parseInt(e.slice(10,12),10),o=Number.parseInt(e.slice(12,14),10);return k.makeZonedUnsafe({year:t<=99?t+1900:t,month:n,day:r,hour:i,minute:a,second:o},{timeZone:k.zoneMakeLocal(),adjustForTimeZone:!0}).pipe(k.toDateUtc)}function N(e){let t=e.getFullYear().toString().padStart(4,`0`),n=(e.getMonth()+1).toString().padStart(2,`0`),r=e.getDate().toString().padStart(2,`0`),i=e.getHours().toString().padStart(2,`0`),a=e.getMinutes().toString().padStart(2,`0`),o=e.getSeconds().toString().padStart(2,`0`);return j.make(`${t}${n}${r}${i}${a}${o}`)}const P=j.pipe(D.decodeTo(D.Date,A.transform({decode:M,encode:N}))),F=O.nominal(),I=D.String.pipe(D.fromBrand(`TloId`,F));function L(e){return D.Struct({success:D.Boolean,ID:D.optional(D.Finite),OBJ:e,err:D.optional(D.String)})}export{E as Activity,_ as BoardService,b as BoardServiceLive,c as Message,m as Project,S as Task,l as TaskForUser,T as TeamLeaderClient,i as TeamLeaderClientLive,a as TimeService,C as TimeServiceLive,e as TloApiError,w as TloAuthError,x as TloClientLive,r as TloConfig,p as TloConfigFromEnv,o as TloConfigLive,P as TloDate,j as TloDateString,F as TloId,I as TloIdSchema,g as TloLive,n as TloNetworkError,t as TloParseError,L as TloResponse,y as TloServicesLive,u as TodoDetail,v as TodoSummary,s as activityFromRaw,N as formatTloDate,h as messageFromRaw,f as projectFromRaw,d as todoSummaryFromRaw};
1
+ import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,r as c,s as l,t as u,u as d}from"./proxy-BaBpBFTW.mjs";export{e as OrbitAuth,n as OrbitAuthError,s as OrbitAuthLayer,l as OrbitAuthLive,o as OrbitClient,c as OrbitClientLive,i as OrbitMcpError,u as OrbitProxyLive,r as Session,t as SessionStore,a as SessionStoreLive,d as makeSessionStoreLayer};
@@ -0,0 +1,2 @@
1
+ import{OAuth as e,Pkce as t}from"@yielded/oauth";import*as n from"effect/Clock";import*as r from"effect/Context";import*as i from"effect/Crypto";import*as a from"effect/Effect";import*as o from"effect/Equal";import*as s from"effect/Exit";import*as c from"effect/Layer";import*as l from"effect/Match";import*as u from"effect/Redacted";import*as d from"effect/Schema";import*as f from"effect/Semaphore";import{FetchHttpClient as p,HttpClient as m,HttpClientRequest as h,HttpClientResponse as g,HttpRouter as _,HttpServer as v,HttpServerRequest as y,HttpServerResponse as b}from"effect/http";import{ChildProcess as x,ChildProcessSpawner as S}from"effect/process";import{timingSafeEqual as C}from"node:crypto";import{createServer as w}from"node:http";import*as T from"@effect/platform-node/NodeHttpServer";import*as E from"effect/Deferred";import*as ee from"effect/Predicate";import{homedir as te}from"node:os";import*as ne from"effect/FileSystem";import*as re from"effect/Path";import*as D from"effect/Stream";import*as O from"effect/Option";import*as k from"effect/Struct";import*as A from"effect/ai/McpProtocol";import*as j from"effect/ai/McpSchema";import*as ie from"effect/encoding/Sse";import*as M from"effect/ai/McpServer";import*as N from"effect/Logger";const P=`https://api.orbit.teamleader.eu`,F=`${P}/mcp`,I=d.RedactedFromValue(d.String.check(d.isMinLength(1))),L=d.Struct({clientId:d.String.check(d.isMinLength(1)),clientSecret:d.optionalKey(I),accessToken:I,refreshToken:d.optionalKey(I),expiresAt:d.optionalKey(d.Finite)});var R=class extends d.TaggedError()(`OrbitAuthError`,{message:d.String}){};function z(e,t,n){let r=t.refreshToken??e.refreshToken;return{clientId:e.clientId,...e.clientSecret===void 0?{}:{clientSecret:e.clientSecret},accessToken:t.accessToken,...r===void 0?{}:{refreshToken:r},...t.expiresIn===void 0?{}:{expiresAt:n+t.expiresIn*1e3}}}function B(e,t){return e.expiresAt===void 0||e.expiresAt<=t+6e4}function V(e){return e.clientSecret===void 0?{method:`none`,publicClient:!0}:{method:`client_secret_post`,secret:e.clientSecret.pipe(u.value,u.make)}}function ae(e,t){let n=e.searchParams.get(`state`);if(n===null||e.pathname!==`/callback`||e.searchParams.getAll(`state`).length!==1)return;let r=Buffer.from(t),i=Buffer.from(n);if(r.length!==i.length||!C(r,i))return;if(e.searchParams.has(`error`))throw Error(`Orbit authorization was denied.`);let a=e.searchParams.get(`code`);if(a!==null&&a.length!==0&&e.searchParams.getAll(`code`).length===1)return a}const oe=a.fn(`OrbitAuth.listenForLogin`)(function*(e){let t=yield*E.make(),n=yield*a.sync(w),r=yield*T.make(()=>n,{port:0,host:`127.0.0.1`}).pipe(a.mapError(()=>R.make({message:`Could not bind OAuth callback.`})));if(!ee.isTagged(r.address,`InetAddressV4`))return yield*R.make({message:`Could not bind OAuth callback.`});let i=`127.0.0.1:${r.address.port}`,o=`http://${i}/callback`,s={"content-type":`text/plain; charset=utf-8`,"cache-control":`no-store`,"referrer-policy":`no-referrer`,"content-security-policy":`default-src 'none'`},c=b.text(`Invalid callback.`,{status:400,headers:s}),l=b.text(`Authorization received. Return to your terminal to complete login.`,{headers:s}),u=b.text(`Authorization denied. Return to your terminal.`,{status:400,headers:s}),d=a.fn(`OrbitAuth.handleCallback`)(function*(){let n=yield*y.HttpServerRequest;return n.method!==`GET`||n.headers.host!==i||(yield*E.isDone(t))?c:yield*a.try({try:()=>ae(new URL(n.url,o),e),catch:()=>R.make({message:`Orbit authorization was denied.`})}).pipe(a.matchEffect({onFailure:e=>E.fail(t,e).pipe(a.map(e=>e?u:c)),onSuccess:e=>e===void 0?a.succeed(c):E.succeed(t,e).pipe(a.map(e=>e?l:c))}))}),f=yield*_.toHttpEffect(_.add(`*`,`*`,d()));return yield*v.serveEffect(f).pipe(a.provideService(v.HttpServer,r)),yield*a.addFinalizer(()=>a.sync(()=>n.closeAllConnections())),{redirectUri:o,code:E.await(t).pipe(a.timeout(`3 minutes`),a.mapError(()=>R.make({message:`Login denied or timed out. Run tlo-mcp login again.`})))}}),H=d.fromJsonString(L),U=`@2digits/tlo-mcp/orbit`;var W=class extends r.Service()(`@2digits/tlo-mcp/oauth/store/SessionStore`){};function G(e){return`"${e.replaceAll(`\\`,String.raw`\\`).replaceAll(`"`,String.raw`\"`)}"`}function K(e={}){return c.effect(W,a.gen(function*(){let t=yield*ne.FileSystem,n=yield*re.Path,r=yield*S.ChildProcessSpawner,i=e.platform??process.platform,o=e.directory??n.join(te(),`.config`,`2digits`,`tlo-mcp`),s=n.join(o,`session.json`),c=n.join(o,`session.lock`),l=t.makeDirectory(o,{recursive:!0,mode:448}).pipe(a.andThen(t.chmod(o,448))),u=a.fn(`SessionStore.security`)(function*(e,t){let n=yield*r.spawn(x.make(`/usr/bin/security`,e,{stdin:t===void 0?`ignore`:D.succeed(new TextEncoder().encode(t)),stderr:`ignore`}));return yield*a.all({output:n.stdout.pipe(D.decodeText(),D.mkString),exitCode:n.exitCode},{concurrency:`unbounded`})},a.scoped),f=a.fn(`SessionStore.load`)(function*(){let e;if(i===`darwin`){let t=yield*u([`find-generic-password`,`-a`,`orbit`,`-s`,U,`-w`]);if(t.exitCode===44)return;if(t.exitCode!==0)return yield*R.make({message:`Could not read macOS Keychain.`});e=t.output.trim()}else{let n=yield*t.readFileString(s).pipe(a.catchReason(`PlatformError`,`NotFound`,()=>a.void));if(n===void 0)return;e=n}return yield*d.decodeEffect(H)(e)},a.mapError(()=>R.make({message:`Could not read credentials. Run tlo-mcp login again.`}))),p=a.fn(`SessionStore.save`)(function*(e){let r=yield*d.encodeEffect(H)(e);if(i===`darwin`){if((yield*u([`-q`,`-i`],`add-generic-password -U -a orbit -s ${G(U)} -w ${G(r)}\n`)).exitCode!==0)return yield*R.make({message:`Could not save macOS Keychain credentials.`})}else{yield*l;let e=yield*t.makeTempDirectoryScoped({directory:o,prefix:`session-`}),i=n.join(e,`session.json`);yield*t.writeFileString(i,r,{mode:384}),yield*t.rename(i,s)}},a.scoped,a.mapError(()=>R.make({message:`Could not persist OAuth credentials. Run tlo-mcp login again.`}))),m=a.fn(`SessionStore.clear`)(function*(){if(i===`darwin`){let e=yield*u([`delete-generic-password`,`-a`,`orbit`,`-s`,U]);if(e.exitCode!==0&&e.exitCode!==44)return yield*R.make({message:`Could not remove Keychain credentials.`})}else yield*t.remove(s,{force:!0})},a.mapError(()=>R.make({message:`Could not remove OAuth credentials.`}))),h=a.fn(`SessionStore.lock`)(function*(){yield*l,yield*a.acquireRelease(t.writeFileString(c,String(process.pid),{flag:`wx`,mode:384}).pipe(a.catchReason(`PlatformError`,`AlreadyExists`,()=>R.make({message:`OAuth credentials locked. Close other login/refresh processes. After a crash only, remove ${c}.`}))),()=>t.remove(c).pipe(a.orDie))},a.mapError(e=>d.is(R)(e)?e:R.make({message:`Could not acquire OAuth credential lock. Check directory permissions.`})));return W.of({load:f(),save:p,clear:m(),lock:h()})}))}const q=K(),se=d.Struct({client_id:d.String.check(d.isMinLength(1)),client_secret:d.String.check(d.isMinLength(1)).pipe(d.RedactedFromValue,d.optionalKey)});var J=class extends r.Service()(`@2digits/tlo-mcp/oauth/OrbitAuth`){};const Y=c.effect(J,a.gen(function*(){let r=yield*W,c=yield*i.Crypto,g=yield*m.HttpClient,_=yield*S.ChildProcessSpawner,v=yield*f.make(1),y=yield*a.fn(`OrbitAuth.discover`)(function*(){let t=yield*m.withScope(g).get(`${P}/.well-known/oauth-authorization-server`);if(t.status!==200)return yield*R.make({message:`Could not discover Orbit OAuth endpoints.`});let n=yield*t.json.pipe(a.flatMap(d.decodeUnknownEffect(e.Metadata)));return n.issuer!==`https://api.orbit.teamleader.eu`||n.authorization_endpoint!==`https://api.orbit.teamleader.eu/oauth2/Authorize`||n.token_endpoint!==`https://api.orbit.teamleader.eu/oauth2/access_token`?yield*R.make({message:`Unexpected Orbit endpoints; refusing to send credentials.`}):n},a.scoped,a.timeout(`15 seconds`),a.mapError(()=>R.make({message:`Invalid or unavailable Orbit OAuth metadata.`})))().pipe(a.cachedWithTTL(e=>s.isSuccess(e)?1/0:0)),b=a.fn(`OrbitAuth.accessToken`)(function*(){let t=yield*r.load;if(t===void 0)return yield*R.make({message:`Not authenticated. Run tlo-mcp login first.`});if(!B(t,yield*n.currentTimeMillis))return t.accessToken;if(t.refreshToken===void 0)return t.expiresAt===void 0?t.accessToken:yield*R.make({message:`Orbit session expired without a refresh token. Run tlo-mcp login.`});let i=yield*y,o=z(t,yield*(yield*e.make({metadata:i,clientId:t.clientId,authentication:V(t),timeoutMs:15e3})).refreshGrant({refreshToken:t.refreshToken,resources:[F]}).pipe(a.flatMap(e.tokens)),yield*n.currentTimeMillis);return yield*r.save(o),o.accessToken}),C=a.fn(`OrbitAuth.register`)(function*(e){let t=yield*h.post(`${P}/oauth2/register`).pipe(h.bodyJson({client_name:`@2digits/tlo-mcp`,redirect_uris:[e],response_types:[`code`],grant_types:[`authorization_code`,`refresh_token`],token_endpoint_auth_method:`none`}),a.flatMap(m.withScope(g).execute));return t.status!==200&&t.status!==201?yield*R.make({message:`Orbit client registration failed (HTTP ${t.status}).`}):yield*t.json.pipe(a.flatMap(d.decodeUnknownEffect(se)))},a.scoped,a.timeout(`15 seconds`)),w=a.fn(`OrbitAuth.openBrowser`)(function*(e){return yield*(yield*l.value(process.platform).pipe(l.when(`darwin`,()=>x.make({stdout:`ignore`,stderr:`ignore`,forceKillAfter:`1 second`})`open ${u.value(e)}`),l.when(`win32`,()=>x.make({stdout:`ignore`,stderr:`ignore`,forceKillAfter:`1 second`})`rundll32 url.dll,FileProtocolHandler ${u.value(e)}`),l.orElse(()=>x.make({stdout:`ignore`,stderr:`ignore`,forceKillAfter:`1 second`})`xdg-open ${u.value(e)}`))).exitCode},a.scoped,a.timeout(`5 seconds`),a.filterOrFail(o.equals(S.ExitCode(0)),()=>R.make({message:`Could not open browser.`})),(e,t)=>e.pipe(a.catch(()=>a.sync(()=>{process.stderr.write(`Open this URL in your browser:\n${u.value(t)}\n`)})))),T=a.fn(`OrbitAuth.login`)(function*(){let i=yield*y,o=yield*t.random(),s=yield*t.make(),c=yield*o.pipe(u.value,oe),l=yield*C(c.redirectUri),d={clientId:l.client_id,...l.client_secret===void 0?{}:{clientSecret:l.client_secret}},f=yield*e.make({metadata:i,...d,authentication:V(d),timeoutMs:15e3}),p=yield*f.authorizationUrl({redirectUri:c.redirectUri,scopes:[],state:o,codeChallenge:s.challenge,resources:[F]});yield*w(p);let m=yield*c.code,h=yield*f.codeGrant({code:u.make(m),redirectUri:c.redirectUri,pkceVerifier:s.verifier,resources:[F]}).pipe(a.flatMap(e.tokens));yield*r.save(z(d,h,yield*n.currentTimeMillis)),yield*a.sync(()=>{process.stderr.write(`Orbit login complete.
2
+ `)})}),E=a.fn(`OrbitAuth.locked`)(function*(e){return yield*r.lock,yield*e},a.scoped,v.withPermit,a.provideService(m.HttpClient,g),a.provideService(i.Crypto,c),a.provideService(S.ChildProcessSpawner,_),a.provideService(p.RequestInit,{redirect:`error`}),a.mapError(e=>d.is(R)(e)?e:R.make({message:`Orbit authentication unavailable. Check connectivity or run tlo-mcp login again.`})));return J.of({accessToken:E(b()),login:E(T()),logout:E(r.clear)})})),ce=Y.pipe(c.provide(q),c.provide(p.layer)),X=d.Union([d.Struct({jsonrpc:d.Literal(`2.0`),id:j.RequestId,result:d.Unknown}),d.Struct({jsonrpc:d.Literal(`2.0`),id:d.NullOr(j.RequestId),error:j.McpErrorBase}),d.Struct({jsonrpc:d.Literal(`2.0`),method:d.String,params:d.optionalKey(d.Unknown)})]),le=d.fromJsonString(X),Z=A.v2025_06_18.protocolVersion;var Q=class extends d.TaggedError()(`OrbitMcpError`,{message:d.String}){},$=class extends r.Service()(`@2digits/tlo-mcp/mcp/OrbitClient`){};const ue=c.effect($,a.gen(function*(){let e=yield*J,t=(yield*m.HttpClient).pipe(m.withScope,m.transformResponse(a.flatMap(g.matchStatus({"2xx":e=>a.succeed(e),401:e=>Q.make({message:`Orbit HTTP ${e.status}: authorization rejected. Run tlo-mcp login; a 403 can also mean insufficient rights.`}),403:e=>Q.make({message:`Orbit HTTP ${e.status}: authorization rejected. Run tlo-mcp login; a 403 can also mean insufficient rights.`}),429:e=>Q.make({message:`Orbit rate limited. Retry after ${e.headers[`retry-after`]??`the server cooldown`}; request not replayed.`}),orElse:e=>Q.make({message:`Orbit HTTP ${e.status}. Request not replayed.`})})))),n=0,r,i=a.fn(`OrbitClient.send`)(function*(i,o,s=!1){let c=++n,l=yield*e.accessToken,u=yield*h.post(F).pipe(h.bearerToken(l),h.setHeader(`accept`,`application/json, text/event-stream`),h.setHeader(`mcp-protocol-version`,Z),e=>r===void 0?e:h.setHeader(e,`mcp-session-id`,r),h.bodyJson({jsonrpc:`2.0`,...s?{}:{id:c},method:i,params:o})),f=yield*t.execute(u),p=f.headers[`mcp-session-id`];if(i===`initialize`&&(r=p),s)return;let m=f.headers[`content-type`]?.startsWith(`text/event-stream`)?yield*f.stream.pipe(D.decodeText(),D.pipeThroughChannel(ie.decode({maxEventSize:10485760})),D.filter(e=>e.event===`message`||e.event===``),D.map(k.get(`data`)),D.mapEffect(e=>d.decodeEffect(le)(e)),D.filter(e=>`id`in e&&e.id===c),D.runHead,a.flatMap(e=>O.isSome(e)?a.succeed(e.value):Q.make({message:`Orbit stream ended before replying.`}))):yield*g.schemaBodyJson(X)(f);return!(`id`in m)||m.id!==c?yield*Q.make({message:`Unexpected Orbit response ID.`}):`error`in m?yield*Q.make({message:m.error.message}):m.result},a.timeout(`120 seconds`),a.scoped,a.provideService(p.RequestInit,{redirect:`error`}),a.mapError(e=>d.is(Q)(e)?e:Q.make({message:`Orbit connection or response failed. Request not replayed.`}))),o=yield*i(`initialize`,{protocolVersion:Z,capabilities:{},clientInfo:{name:`@2digits/tlo-mcp`,version:`0.1.38`}}).pipe(a.flatMap(d.decodeUnknownEffect(j.InitializeResult)));if(o.protocolVersion!==Z)return yield*Q.make({message:`Unsupported upstream MCP protocol: ${o.protocolVersion}.`});yield*i(`notifications/initialized`,{},!0);let s=/* @__PURE__ */ new Set,c=yield*D.paginate(void 0,a.fn(`OrbitClient.listToolsPage`)(function*(e){let t=yield*i(`tools/list`,e===void 0?{}:{cursor:e}).pipe(a.flatMap(d.decodeUnknownEffect(j.ListToolsResult)));if(t.nextCursor!==void 0){if(s.has(t.nextCursor))return yield*Q.make({message:`Orbit returned a repeated tools cursor.`});s.add(t.nextCursor)}return[t.tools,O.fromUndefinedOr(t.nextCursor)]})).pipe(D.runCollect);return $.of({tools:c,instructions:o.instructions,callTool:a.fn(`OrbitClient.callTool`)(function*(e,t){return yield*i(`tools/call`,{name:e,arguments:t})},a.flatMap(d.decodeUnknownEffect(j.CallToolResult)),a.catchTag(`SchemaError`,()=>Q.make({message:`Invalid Orbit tool result. Request not replayed.`})))})})).pipe(c.provide(p.layer)),de=c.merge(N.layer([N.consolePretty()]),c.succeed(N.LogToStderr,!0)),fe=c.unwrap(a.gen(function*(){let e=yield*$;return c.effectDiscard(a.gen(function*(){let t=yield*M.McpServer;yield*a.forEach(e.tools,a.fn(`OrbitProxyLive.tool`)(function*(n){yield*t.addTool({tool:n,annotations:r.empty(),handle:a.fn(`handle`)(function*(e){return yield*d.decodeUnknownEffect(d.JsonObject)(e)},a.mapError(e=>j.InvalidParams.make({message:`Tool arguments must be a JSON object.`,data:e})),a.flatMap(t=>e.callTool(n.name,t).pipe(a.mapError(e=>j.InternalError.make({message:e.message})))))})}),{discard:!0})})).pipe(c.provide(M.layerStdio({name:`tlo-mcp`,version:`0.1.38`,instructions:e.instructions,protocols:[A.v2025_11_25,A.v2025_06_18,A.v2025_03_26]})),c.provide(de))}));export{J as a,W as c,R as d,L as f,Q as i,q as l,$ as n,Y as o,ue as r,ce as s,fe as t,K as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2digits/tlo-mcp",
3
- "version": "0.1.38",
3
+ "version": "1.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/2digits-agency/configs.git",
@@ -25,21 +25,24 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@effect/platform-node": "4.0.1",
28
+ "@yielded/oauth": "0.1.0-beta.28",
28
29
  "effect": "4.0.1"
29
30
  },
30
31
  "devDependencies": {
31
- "@2digits/tsconfig": "0.9.1",
32
+ "@2digits/tsconfig": "0.9.2",
32
33
  "@arethetypeswrong/core": "0.18.5",
33
34
  "@effect/vitest": "4.0.1",
35
+ "@oxc-node/cli": "0.1.4",
34
36
  "publint": "0.3.25",
35
37
  "typescript": "7.0.2",
36
- "vite-plus": "1.0.0",
38
+ "vite-plus": "1.1.0",
37
39
  "vitest": "5.0.3"
38
40
  },
39
41
  "public": true,
40
42
  "scripts": {
41
43
  "build": "vp pack --minify --config-loader unconfig",
42
44
  "dev": "vp pack --watch --config-loader unconfig",
45
+ "run": "oxnode ./src/bin.ts",
43
46
  "test": "vitest run",
44
47
  "test:watch": "vitest",
45
48
  "types": "tsc --noEmit"
@@ -1 +0,0 @@
1
- import*as e from"effect/Context";import*as t from"effect/Effect";import*as n from"effect/Layer";import*as r from"effect/Match";import*as i from"effect/Option";import*as a from"effect/Record";import*as ee from"effect/Redacted";import*as o from"effect/Schema";import*as s from"effect/http/HttpBody";import*as te from"effect/http/UrlParams";import*as c from"effect/http/Cookies";import*as l from"effect/http/HttpClient";import*as u from"effect/http/HttpClientRequest";import*as d from"effect/Array";import*as f from"effect/String";import*as p from"effect/Config";import*as m from"effect/http/FetchHttpClient";var h=class extends e.Service()(`@2digits/tlo-mcp/services/TloConfig`){},g=class extends o.TaggedError()(`TloApiError`,{message:o.String,code:o.optional(o.String),endpoint:o.optional(o.String)}){},_=class extends o.TaggedError()(`TloAuthError`,{message:o.String}){},v=class extends o.TaggedError()(`TloNetworkError`,{message:o.String,cause:o.optional(o.Unknown),endpoint:o.optional(o.String)}){},y=class extends o.TaggedError()(`TloParseError`,{message:o.String,cause:o.optional(o.Unknown)}){};const ne=o.Union([g,_,v,y]);var b=class extends e.Service()(`@2digits/tlo-mcp/services/TloHttpClient`){};const x=n.effect(b,t.gen(function*(){let e=yield*h,t=yield*l.HttpClient,n=c.toCookieHeader(e.cookies),r=t.pipe(l.mapRequest(u.prependUrl(e.baseUrl)),l.mapRequest(u.setHeader(`Cookie`,n)),l.filterStatusOk);return b.of({client:r})}));var S=class extends e.Service()(`@2digits/tlo-mcp/services/TeamLeaderClient`){};const re=o.Struct({MSG:o.String,err:o.Finite}),ie=o.fromJsonString(o.Unknown),ae=/\{MSG:'([^']*)',\s*err:(\d+)\}/;function oe(e){let t=ae.exec(e);return r.value(t).pipe(r.when(r.defined,e=>i.some({MSG:e[1]??`Unknown error`,err:Number(e[2])})),r.orElse(()=>i.none()))}const C=n.effect(S,t.gen(function*(){let e=yield*h,{client:n}=yield*b;return S.of({post:t.fn(`TeamLeaderClient.post`)(function*(i,c,l){let u=a.set(c,`t`,ee.value(e.sessionToken)),d=te.fromInput(u),f=yield*(yield*n.post(i,{body:s.urlParams(d)})).text,p=oe(f);yield*r.value(p).pipe(r.tag(`Some`,({value:e})=>e.err===0?t.void:g.make({message:e.MSG,endpoint:i})),r.tag(`None`,()=>t.void),r.exhaustive);let m=yield*o.decodeEffect(ie)(f).pipe(t.mapError(e=>y.make({message:`Invalid JSON response`,cause:e})));return yield*r.value(m).pipe(r.when(o.is(re),e=>e.err===0?t.void:g.make({message:e.MSG,endpoint:i})),r.orElse(()=>t.void)),yield*o.decodeUnknownEffect(l)(m).pipe(t.mapError(e=>y.make({message:`Failed to parse response`,cause:e})))},t.scoped,(e,n)=>e.pipe(t.mapError(e=>r.value(e).pipe(r.when(o.is(g),e=>e),r.when(o.is(y),e=>e),r.orElse(e=>v.make({message:e.response===void 0?`Request failed: ${e.message}`:`HTTP ${e.response.status}`,cause:e,endpoint:n}))))))})})),w=o.Struct({ID:o.Finite,FOLDERID:o.optional(o.Union([o.String,o.Finite])),PROJECT_ID:o.optional(o.Union([o.String,o.Finite])),TASKID:o.Union([o.String,o.Finite]).pipe(o.NullOr,o.optional),TODOID:o.Union([o.String,o.Finite]).pipe(o.NullOr,o.optional),TICKETID:o.Union([o.String,o.Finite]).pipe(o.NullOr,o.optional),CONTACTID:o.optional(o.Union([o.String,o.Finite])),DESCRIPTION:o.NullOr(o.String),DT:o.String,START_DT:o.optional(o.String),END_DT:o.optional(o.String),DURATION:o.Finite,TYPE:o.optional(o.Finite),PROJECT_NAME:o.String.pipe(o.NullOr,o.optional),TASK_NAME:o.String.pipe(o.NullOr,o.optional),CLIENT_NAME:o.String.pipe(o.NullOr,o.optional),FOLDER_NAME:o.String.pipe(o.NullOr,o.optional),ENTITY_NAME:o.String.pipe(o.NullOr,o.optional),PROJECTOWNER_NAME:o.String.pipe(o.NullOr,o.optional),CLIENT_COLOR:o.String.pipe(o.NullOr,o.optional),PROJECT_COLOR:o.String.pipe(o.NullOr,o.optional),PROJECT_STATE:o.String.pipe(o.NullOr,o.optional),TASK_STATE:o.String.pipe(o.NullOr,o.optional),TIMESHEET_STATE:o.String.pipe(o.NullOr,o.optional),BILLING_MODE:o.String.pipe(o.NullOr,o.optional),NON_BILLABLE:o.Finite.pipe(o.NullOr,o.optional),RATE:o.Finite.pipe(o.NullOr,o.optional),VALUE:o.Finite.pipe(o.NullOr,o.optional),PROJECT_START_DT:o.String.pipe(o.NullOr,o.optional),PROJECT_END_DT:o.String.pipe(o.NullOr,o.optional),TASK_START_DT:o.String.pipe(o.NullOr,o.optional),TASK_END_DT:o.String.pipe(o.NullOr,o.optional),READONLY:o.Finite.pipe(o.NullOr,o.optional),TASK_WORKLOAD:o.Finite.pipe(o.NullOr,o.optional)});var T=class extends o.Class(`Activity`)({id:o.Finite,projectId:o.optional(o.String),folderId:o.optional(o.String),taskId:o.String.pipe(o.NullOr,o.optional),todoId:o.String.pipe(o.NullOr,o.optional),ticketId:o.String.pipe(o.NullOr,o.optional),userId:o.optional(o.String),description:o.NullOr(o.String),startDate:o.String,endDate:o.optional(o.String),durationMinutes:o.Finite,projectName:o.String.pipe(o.NullOr,o.optional),taskName:o.String.pipe(o.NullOr,o.optional),clientName:o.String.pipe(o.NullOr,o.optional),folderName:o.String.pipe(o.NullOr,o.optional),entityName:o.String.pipe(o.NullOr,o.optional),projectOwnerName:o.String.pipe(o.NullOr,o.optional),projectState:o.String.pipe(o.NullOr,o.optional),taskState:o.String.pipe(o.NullOr,o.optional),timesheetState:o.String.pipe(o.NullOr,o.optional),billingMode:o.String.pipe(o.NullOr,o.optional),nonBillable:o.Finite.pipe(o.NullOr,o.optional),rate:o.Finite.pipe(o.NullOr,o.optional),value:o.Finite.pipe(o.NullOr,o.optional),projectStartDate:o.String.pipe(o.NullOr,o.optional),projectEndDate:o.String.pipe(o.NullOr,o.optional),taskStartDate:o.String.pipe(o.NullOr,o.optional),taskEndDate:o.String.pipe(o.NullOr,o.optional),readOnly:o.Boolean.pipe(o.NullOr,o.optional),taskWorkload:o.Finite.pipe(o.NullOr,o.optional),projectColor:o.optional(o.String),clientColor:o.optional(o.String)}){};function E(e){return T.make({id:e.ID,projectId:e.PROJECT_ID===void 0?e.FOLDERID===void 0?void 0:String(e.FOLDERID):String(e.PROJECT_ID),folderId:e.FOLDERID===void 0?void 0:String(e.FOLDERID),taskId:e.TASKID!==void 0&&e.TASKID!==null?String(e.TASKID):null,todoId:e.TODOID!==void 0&&e.TODOID!==null?String(e.TODOID):null,ticketId:e.TICKETID!==void 0&&e.TICKETID!==null?String(e.TICKETID):null,userId:e.CONTACTID===void 0?void 0:String(e.CONTACTID),description:e.DESCRIPTION,startDate:e.DT,endDate:e.END_DT,durationMinutes:e.DURATION,projectName:e.PROJECT_NAME,taskName:e.TASK_NAME,clientName:e.CLIENT_NAME,folderName:e.FOLDER_NAME,entityName:e.ENTITY_NAME,projectOwnerName:e.PROJECTOWNER_NAME,projectState:e.PROJECT_STATE,taskState:e.TASK_STATE,timesheetState:e.TIMESHEET_STATE,billingMode:e.BILLING_MODE,nonBillable:e.NON_BILLABLE,rate:e.RATE,value:e.VALUE,projectStartDate:e.PROJECT_START_DT,projectEndDate:e.PROJECT_END_DT,taskStartDate:e.TASK_START_DT,taskEndDate:e.TASK_END_DT,readOnly:e.READONLY===void 0||e.READONLY===null?void 0:e.READONLY!==0,taskWorkload:e.TASK_WORKLOAD,projectColor:e.PROJECT_COLOR??void 0,clientColor:e.CLIENT_COLOR??void 0})}const se=o.Struct({ACTIVITIES:o.Array(w)}),D=o.Struct({ID:o.Finite,DURATION:o.optional(o.Finite),DT:o.optional(o.String),TYPE:o.optional(o.Finite),DESCRIPTION:o.String.pipe(o.NullOr,o.optional),CLIENT_COLOR:o.optional(o.String),FOLDERID:o.optional(o.Union([o.String,o.Finite]))});function O(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}`}var k=class extends e.Service()(`@2digits/tlo-mcp/services/TimeService`){};const A=n.effect(k,t.gen(function*(){let e=yield*S;return k.of({getWeek:t.fn(`TimeService.getWeek`)(function*(t,n,r=`Europe/Amsterdam`){let i=yield*e.post(`/ajax/pln/GetWeek`,{DT:O(t),CONTACTID:n,tmz:r},se);return d.map(E)(i.ACTIVITIES)}),createActivity:t.fn(`TimeService.createActivity`)(function*(t){return(yield*e.post(`/ajax/pln/SetActivity`,{ID:0,ACTION:`CREATE`,DT:O(t.startDate),DURATION:t.durationMinutes,FOLDERID:t.folderId,TASKID:t.taskId,TODOID:t.todoId,CONTACTID:t.contactId,CLIENT_COLOR:t.clientColor,DESCRIPTION:t.description},D)).ID}),updateActivity:t.fn(`TimeService.updateActivity`)(function*(t){yield*e.post(`/ajax/pln/SetActivity`,{ID:t.id,ACTION:`MOVE`,DT:t.startDate===void 0?void 0:O(t.startDate),DURATION:t.durationMinutes,DESCRIPTION:t.description},D)}),deleteActivity:t.fn(`TimeService.deleteActivity`)(function*(t){yield*e.post(`/ajax/pln/SetActivity`,{ID:t.id,ACTION:`DELETE`},D)})})})),j=o.Struct({ID:o.Finite,PROJECT_NAME:o.optional(o.String),NAME:o.optional(o.String),STATE:o.optional(o.String),OWNER_NAME:o.optional(o.String),START_DT:o.optional(o.String),END_DT:o.optional(o.String),BILLING_BUDGET:o.optional(o.Finite),BILLING_MODE:o.optional(o.String),BILLING_REMAINING:o.optional(o.Finite),CLIENT_NAME:o.optional(o.String),CLIENT_ID:o.optional(o.Finite),FOLDERID:o.optional(o.Finite),FOLDER_NAME:o.optional(o.String),EXTID:o.optional(o.String),CALC_TOTAL:o.optional(o.Finite),CALC_DONE:o.optional(o.Finite),CALC_PLANNED:o.optional(o.Finite)}),ce=o.Struct({Records:o.Array(j),RecordCount:o.optional(o.Finite)}),le=o.Union([j,o.Struct({Record:j})]);var M=class extends o.Class(`Project`)({id:o.Finite,name:o.String,state:o.optional(o.String),ownerName:o.optional(o.String),startDate:o.optional(o.String),endDate:o.optional(o.String),billingBudget:o.optional(o.Finite),billingMode:o.optional(o.String),billingRemaining:o.optional(o.Finite),clientName:o.optional(o.String),clientId:o.optional(o.Finite),folderId:o.optional(o.Finite),folderName:o.optional(o.String),extId:o.optional(o.String),calcTotal:o.optional(o.Finite),calcDone:o.optional(o.Finite),calcPlanned:o.optional(o.Finite)}){};function N(e){return M.make({id:e.ID,name:e.PROJECT_NAME??e.NAME??``,state:e.STATE,ownerName:e.OWNER_NAME,startDate:e.START_DT,endDate:e.END_DT,billingBudget:e.BILLING_BUDGET,billingMode:e.BILLING_MODE,billingRemaining:e.BILLING_REMAINING,clientName:e.CLIENT_NAME,clientId:e.CLIENT_ID,folderId:e.FOLDERID,folderName:e.FOLDER_NAME,extId:e.EXTID,calcTotal:e.CALC_TOTAL,calcDone:e.CALC_DONE,calcPlanned:e.CALC_PLANNED})}const P=o.Struct({ID:o.Finite,OWNERID:o.optional(o.Finite),OWNER_NAME:o.optional(o.String),AVATAR:o.optional(o.String),CREATED_DT:o.optional(o.String),CONTENT:o.optional(o.String),SUBCONTENT:o.optional(o.String),OBJECTTYPE:o.optional(o.String),OBJECTID:o.optional(o.Finite),OBJECTNAME:o.optional(o.String),MSGTYPE:o.optional(o.String),LIKECNT:o.optional(o.Finite),REPLYCNT:o.optional(o.Finite),OUTQUEUEID:o.optional(o.String),INTERNAL:o.optional(o.Finite)}),F=o.Array(P);var I=class extends o.Class(`Message`)({id:o.Finite,ownerId:o.optional(o.Finite),ownerName:o.optional(o.String),avatar:o.optional(o.String),createdAt:o.optional(o.String),content:o.optional(o.String),subcontent:o.optional(o.String),objectType:o.optional(o.String),objectId:o.optional(o.Finite),objectName:o.optional(o.String),messageType:o.optional(o.String),likeCount:o.optional(o.Finite),replyCount:o.optional(o.Finite),outQueueId:o.optional(o.String),internal:o.optional(o.Boolean)}){};function L(e){return I.make({id:e.ID,ownerId:e.OWNERID,ownerName:e.OWNER_NAME,avatar:e.AVATAR,createdAt:e.CREATED_DT,content:e.CONTENT,subcontent:e.SUBCONTENT,objectType:e.OBJECTTYPE,objectId:e.OBJECTID,objectName:e.OBJECTNAME,messageType:e.MSGTYPE,likeCount:e.LIKECNT,replyCount:e.REPLYCNT,outQueueId:e.OUTQUEUEID,internal:e.INTERNAL===void 0?void 0:e.INTERNAL!==0})}const R=o.Struct({ID:o.Finite,PROJECTID:o.optional(o.Finite),NAME:o.optional(o.String),STATE:o.optional(o.String),OWNER_NAME:o.optional(o.String),START_DT:o.optional(o.String),END_DT:o.optional(o.String),BUDGET:o.optional(o.Finite)}),z=o.Struct({Records:o.Array(R),RecordCount:o.optional(o.Finite)});var B=class extends o.Class(`Task`)({id:o.Finite,projectId:o.optional(o.Finite),name:o.optional(o.String),state:o.optional(o.String),ownerName:o.optional(o.String),startDate:o.optional(o.String),endDate:o.optional(o.String),budget:o.optional(o.Finite)}){};function V(e){return B.make({id:e.ID,projectId:e.PROJECTID,name:e.NAME,state:e.STATE,ownerName:e.OWNER_NAME,startDate:e.START_DT,endDate:e.END_DT,budget:e.BUDGET})}const H=o.Struct({ID:o.Finite,WORKLOAD:o.optional(o.Finite),TOTAL:o.optional(o.Finite),REMAINING:o.optional(o.Finite),AVAIL:o.optional(o.Finite),CLIENTID:o.optional(o.Finite),PROJECTID:o.optional(o.Finite),PROJECT_START_DT:o.optional(o.String),PROJECT_END_DT:o.optional(o.String),START_DT:o.optional(o.String),END_DT:o.optional(o.String),STATE:o.optional(o.String)}),U=o.Struct({Records:o.Array(H)});var W=class extends o.Class(`TaskForUser`)({id:o.Finite,workload:o.optional(o.Finite),total:o.optional(o.Finite),remaining:o.optional(o.Finite),avail:o.optional(o.Finite),clientId:o.optional(o.Finite),projectId:o.optional(o.Finite),projectStartDate:o.optional(o.String),projectEndDate:o.optional(o.String),startDate:o.optional(o.String),endDate:o.optional(o.String),state:o.optional(o.String)}){};function ue(e){return W.make({id:e.ID,workload:e.WORKLOAD,total:e.TOTAL,remaining:e.REMAINING,avail:e.AVAIL,clientId:e.CLIENTID,projectId:e.PROJECTID,projectStartDate:e.PROJECT_START_DT,projectEndDate:e.PROJECT_END_DT,startDate:e.START_DT,endDate:e.END_DT,state:e.STATE})}const G=o.Record(o.String,o.Unknown),de=o.Struct({ID:o.Finite,NAME:o.optional(o.String),BOARDLISTID:o.optional(o.Finite),BOARDID:o.optional(o.Finite),OWNERID:o.optional(o.Finite),EXTID:o.optional(o.String),STATE:o.String.pipe(o.NullOr,o.optional),DUE_DT:o.String.pipe(o.NullOr,o.optional),DESCRIPTION:o.String.pipe(o.NullOr,o.optional)}),K=o.Struct({Records:o.Array(de),RecordCount:o.optional(o.Finite)});var q=class extends o.Class(`TodoSummary`)({id:o.Finite,name:o.optional(o.String),boardListId:o.optional(o.Finite),boardId:o.optional(o.Finite),ownerId:o.optional(o.Finite),extId:o.optional(o.String),state:o.String.pipe(o.NullOr,o.optional),dueDate:o.String.pipe(o.NullOr,o.optional),description:o.String.pipe(o.NullOr,o.optional)}){};function J(e){return q.make({id:e.ID,name:e.NAME,boardListId:e.BOARDLISTID,boardId:e.BOARDID,ownerId:e.OWNERID,extId:e.EXTID,state:e.STATE,dueDate:e.DUE_DT,description:e.DESCRIPTION})}var Y=class extends e.Service()(`@2digits/tlo-mcp/services/BoardService`){};function fe(e){return`${e.getFullYear()}-${(e.getMonth()+1).toString().padStart(2,`0`)}-${e.getDate().toString().padStart(2,`0`)}`}const X=n.effect(Y,t.gen(function*(){let e=yield*S;return Y.of({getProjects:t.fn(`BoardService.getProjects`)(function*(t={}){let n=t.states??[`DRAFT`,`OPEN`,`CLOSED`],r=yield*e.post(`/ajax/pln/GetProjects`,{STATE:d.join(n,`|`),COLUMNS:`ID|PROJECT_NAME|NAME|STATE|OWNER_NAME|START_DT|END_DT|BILLING_BUDGET|BILLING_MODE|BILLING_REMAINING|CLIENT_NAME|CLIENT_ID|FOLDERID|FOLDER_NAME|EXTID|CALC_TOTAL|CALC_DONE|CALC_PLANNED`,limit:t.limit??100,page:t.page??1},ce);return d.map(N)(r.Records)}),getProjectDetails:t.fn(`BoardService.getProjectDetails`)(function*(t){let n=yield*e.post(`/ajax/pln/GetProjectDetails`,{ID:t.projectId},le);return N(r.value(n).pipe(r.when({Record:r.any},({Record:e})=>e),r.orElse(e=>e)))}),getMessages:t.fn(`BoardService.getMessages`)(function*(t){let n=yield*e.post(`/ajax/board/ProcessMessage`,{OBJECTTYPE:t.objectType,OBJECTID:t.objectId,ONLYCOMMENTS:t.onlyComments===!1?0:1,HIDEINTERNAL:t.hideInternal===!1?0:1,PAGETYPE:`SEQID`,MINID:0,limit:t.limit??100},F);return d.map(L)(n)}),getTasks:t.fn(`BoardService.getTasks`)(function*(t){let n=t.states??[`DRAFT`,`OPEN`,`CLOSED`],r=yield*e.post(`/ajax/pln/GetTasks`,{PROJECTID:t.projectId,STATE:d.join(n,`|`),COLUMNS:`ID|PROJECTID|NAME|STATE|OWNER_NAME|START_DT|END_DT|BUDGET`,limit:t.limit??100,page:t.page??1},z);return d.map(V)(r.Records)}),getTasksForUser:t.fn(`BoardService.getTasksForUser`)(function*(t){let n=yield*e.post(`/ajax/pln/GetTasksForUser`,{CONTACTID:t.contactId,START_DT:fe(t.startDate),PERIOD:t.period},U);return d.map(ue)(n.Records)}),getTodoDetail:t.fn(`BoardService.getTodoDetail`)(function*(t){return yield*e.post(`/ajax/board/GetTodoDetail`,{ID:t.id},G)}),getBoardTodos:t.fn(`BoardService.getBoardTodos`)(function*(t){let n=yield*e.post(`/ajax/board/GetTodos`,{BOARDID:t.boardId,BOARDLISTID:t.boardListId,limit:t.limit??100},K),i=d.map(J)(n.Records);return r.value(t.query).pipe(r.when(r.nonEmptyString,e=>{let t=f.toLowerCase(e);return d.filter(i,e=>e.name!==void 0&&f.includes(t)(f.toLowerCase(e.name)))}),r.orElse(()=>i))}),moveTodo:t.fn(`BoardService.moveTodo`)(function*(t){yield*e.post(`/ajax/board/MoveTodo`,{ID:t.id,BOARDID:t.boardId,BOARDLISTID:t.boardListId,SORTINDEX:t.sortIndex},o.Unknown)}),postMessage:t.fn(`BoardService.postMessage`)(function*(t){yield*e.post(`/ajax/board/ProcessMessage`,{ACTION:`ADD`,OBJECTTYPE:t.objectType,OBJECTID:t.objectId,CONTENT:t.content},o.Unknown)}),setTaskState:t.fn(`BoardService.setTaskState`)(function*(t){yield*e.post(`/ajax/pln/SetTaskState`,{PROJECTID:t.projectId,ID:t.taskId,STATE:t.state},o.Unknown)})})})),Z=t.gen(function*(){let e=yield*p.Redacted(`TLO_SESSION_TOKEN`),n=yield*p.String(`TLO_BASE_URL`).pipe(p.withDefault(`https://socialbrothers.orbit.teamleader.eu`)),r=yield*p.String(`TLO_COOKIES`).pipe(p.withDefault(``));return{baseUrl:n,sessionToken:e,cookies:yield*t.fromResult(c.setAll(c.empty,a.toEntries(c.parseHeader(r))))}}),pe=n.effect(h,Z),Q=n.mergeAll(A,X),$=C.pipe(n.provide(x.pipe(n.provide(m.layer)))),me=Q.pipe(n.provide($));export{g as C,y as D,v as E,h as O,C as S,ne as T,k as _,pe as a,E as b,I as c,W as d,G as f,J as g,N as h,Z as i,M as l,L as m,me as n,Y as o,q as p,Q as r,X as s,$ as t,B as u,A as v,_ as w,S as x,T as y};