ask-marcel-office-cli 0.5.5 → 1.4.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/CHANGELOG.md +92 -0
- package/README.md +147 -221
- package/dist/cli.js +99348 -14825
- package/dist/commands.json +5870 -789
- package/dist/composition/build-deps.d.ts +1 -0
- package/dist/composition/cli.d.ts +2 -0
- package/dist/domain/iso-datetime.d.ts +30 -0
- package/dist/index.js +97246 -13703
- package/dist/infra/auth.d.ts +61 -3
- package/dist/infra/browser-auth.d.ts +163 -1
- package/dist/infra/graph-client.d.ts +99 -2
- package/dist/infra/mammoth-adapter.d.ts +4 -0
- package/dist/infra/network-error.d.ts +9 -0
- package/dist/infra/sheetjs-adapter.d.ts +9 -0
- package/dist/infra/turndown-adapter.d.ts +4 -0
- package/dist/presenter/error-hints.d.ts +41 -0
- package/dist/presenter/output-text.d.ts +2 -0
- package/dist/presenter/output.d.ts +5 -2
- package/dist/use-cases/commands/build-command.d.ts +67 -1
- package/dist/use-cases/commands/command-types.d.ts +108 -3
- package/dist/use-cases/commands/convert-mail-attachment-to-markdown.d.ts +11 -0
- package/dist/use-cases/commands/convert-mail-attachment-to-pdf.d.ts +11 -0
- package/dist/use-cases/commands/convert-mail-to-markdown.d.ts +14 -0
- package/dist/use-cases/commands/docs-render.d.ts +10 -1
- package/dist/use-cases/commands/docs.d.ts +44 -1
- package/dist/use-cases/commands/docx-to-markdown.d.ts +11 -0
- package/dist/use-cases/commands/{download-drive-item-version-content.d.ts → download-drive-item-as-markdown.d.ts} +0 -1
- package/dist/use-cases/commands/download-drive-item-as-pdf.d.ts +11 -0
- package/dist/use-cases/commands/download-drive-item-version.d.ts +17 -0
- package/dist/use-cases/commands/download-onedrive-file-content.d.ts +2 -2
- package/dist/use-cases/commands/embedded-item-to-markdown.d.ts +59 -0
- package/dist/use-cases/commands/excel-error.d.ts +6 -0
- package/dist/use-cases/commands/extract-sharepoint-links-in-mail.d.ts +26 -0
- package/dist/use-cases/commands/fetch-raw-bytes.d.ts +56 -0
- package/dist/use-cases/commands/find-chats-with-user.d.ts +10 -0
- package/dist/use-cases/commands/format-zod-error.d.ts +14 -0
- package/dist/use-cases/commands/get-calendar-event.d.ts +1 -5
- package/dist/use-cases/commands/get-calendar-view.d.ts +1 -6
- package/dist/use-cases/commands/get-channel-files-folder.d.ts +4 -0
- package/dist/use-cases/commands/get-chat.d.ts +4 -0
- package/dist/use-cases/commands/get-current-user.d.ts +1 -3
- package/dist/use-cases/commands/get-drive-delta.d.ts +1 -6
- package/dist/use-cases/commands/get-drive-item-analytics.d.ts +9 -0
- package/dist/use-cases/commands/get-drive-item-created-by-user.d.ts +4 -0
- package/dist/use-cases/commands/get-drive-item-last-modified-by-user.d.ts +4 -0
- package/dist/use-cases/commands/get-drive-item-list-item.d.ts +4 -0
- package/dist/use-cases/commands/get-drive-item.d.ts +1 -6
- package/dist/use-cases/commands/get-drive-root-delta.d.ts +4 -0
- package/dist/use-cases/commands/get-drive-root-item.d.ts +1 -5
- package/dist/use-cases/commands/get-drive-special-folder.d.ts +4 -0
- package/dist/use-cases/commands/get-excel-range.d.ts +1 -1
- package/dist/use-cases/commands/get-excel-table.d.ts +1 -1
- package/dist/use-cases/commands/get-excel-used-range.d.ts +15 -0
- package/dist/use-cases/commands/get-group-calendar-view.d.ts +4 -0
- package/dist/use-cases/commands/get-group.d.ts +4 -0
- package/dist/use-cases/commands/get-mail-attachment.d.ts +4 -2
- package/dist/use-cases/commands/get-mail-message-mime.d.ts +8 -0
- package/dist/use-cases/commands/get-mail-message.d.ts +1 -5
- package/dist/use-cases/commands/get-mail-rule.d.ts +9 -0
- package/dist/use-cases/commands/get-mailbox-settings.d.ts +1 -1
- package/dist/use-cases/commands/get-my-calendar.d.ts +4 -0
- package/dist/use-cases/commands/get-my-manager.d.ts +9 -0
- package/dist/use-cases/commands/get-onenote-page-as-markdown.d.ts +10 -0
- package/dist/use-cases/commands/get-organization.d.ts +4 -0
- package/dist/use-cases/commands/get-shared-calendar-view.d.ts +4 -0
- package/dist/use-cases/commands/get-shared-mailbox-message.d.ts +4 -0
- package/dist/use-cases/commands/get-sharepoint-list-column.d.ts +4 -0
- package/dist/use-cases/commands/get-sharepoint-site-drive-by-id.d.ts +1 -6
- package/dist/use-cases/commands/get-sharepoint-site-list-item.d.ts +1 -7
- package/dist/use-cases/commands/get-sharepoint-site-list.d.ts +1 -6
- package/dist/use-cases/commands/get-sharepoint-site-onenote-page-content.d.ts +9 -0
- package/dist/use-cases/commands/get-sharepoint-site.d.ts +1 -5
- package/dist/use-cases/commands/get-site-analytics.d.ts +8 -0
- package/dist/use-cases/commands/get-specific-calendar-event.d.ts +1 -6
- package/dist/use-cases/commands/get-specific-calendar-view.d.ts +1 -7
- package/dist/use-cases/commands/get-team-channel.d.ts +3 -7
- package/dist/use-cases/commands/get-team-primary-channel.d.ts +4 -0
- package/dist/use-cases/commands/get-team.d.ts +1 -5
- package/dist/use-cases/commands/get-teams-chat-message.d.ts +9 -0
- package/dist/use-cases/commands/get-todo-task.d.ts +1 -6
- package/dist/use-cases/commands/get-user-manager.d.ts +10 -0
- package/dist/use-cases/commands/graph-scopes.d.ts +29 -0
- package/dist/use-cases/commands/inline-image-embedder.d.ts +20 -0
- package/dist/use-cases/commands/iso-datetime-schema.d.ts +21 -0
- package/dist/use-cases/commands/link-shape.d.ts +13 -0
- package/dist/use-cases/commands/list-all-onenote-sections.d.ts +1 -3
- package/dist/use-cases/commands/list-calendar-event-instances.d.ts +3 -9
- package/dist/use-cases/commands/list-calendar-events-delta.d.ts +5 -3
- package/dist/use-cases/commands/list-calendar-events.d.ts +1 -3
- package/dist/use-cases/commands/list-calendar-group-calendars.d.ts +4 -0
- package/dist/use-cases/commands/list-calendar-groups.d.ts +4 -0
- package/dist/use-cases/commands/list-calendar-view-delta.d.ts +5 -4
- package/dist/use-cases/commands/list-calendars.d.ts +1 -3
- package/dist/use-cases/commands/list-chat-members.d.ts +3 -6
- package/dist/use-cases/commands/list-chats.d.ts +4 -0
- package/dist/use-cases/commands/list-conversation-messages.d.ts +12 -0
- package/dist/use-cases/commands/list-drive-item-permissions.d.ts +1 -6
- package/dist/use-cases/commands/list-drive-item-thumbnails.d.ts +4 -0
- package/dist/use-cases/commands/list-drive-item-versions.d.ts +1 -6
- package/dist/use-cases/commands/list-drives.d.ts +1 -3
- package/dist/use-cases/commands/list-excel-comments.d.ts +5 -0
- package/dist/use-cases/commands/list-excel-defined-names.d.ts +5 -0
- package/dist/use-cases/commands/list-excel-table-rows.d.ts +2 -7
- package/dist/use-cases/commands/list-excel-tables.d.ts +2 -6
- package/dist/use-cases/commands/list-excel-worksheet-charts.d.ts +5 -0
- package/dist/use-cases/commands/list-excel-worksheet-pivot-tables.d.ts +5 -0
- package/dist/use-cases/commands/list-excel-worksheets.d.ts +2 -6
- package/dist/use-cases/commands/list-focused-inbox-overrides.d.ts +4 -0
- package/dist/use-cases/commands/list-folder-files.d.ts +1 -6
- package/dist/use-cases/commands/list-followed-drive-items.d.ts +4 -0
- package/dist/use-cases/commands/list-group-conversations.d.ts +4 -0
- package/dist/use-cases/commands/list-group-events.d.ts +4 -0
- package/dist/use-cases/commands/list-group-members.d.ts +4 -0
- package/dist/use-cases/commands/list-group-owners.d.ts +4 -0
- package/dist/use-cases/commands/list-group-threads.d.ts +4 -0
- package/dist/use-cases/commands/list-groups.d.ts +4 -0
- package/dist/use-cases/commands/list-incomplete-planner-tasks.d.ts +10 -3
- package/dist/use-cases/commands/list-incomplete-todo-tasks.d.ts +8 -2
- package/dist/use-cases/commands/list-mail-attachments.d.ts +8 -2
- package/dist/use-cases/commands/list-mail-child-folders.d.ts +1 -5
- package/dist/use-cases/commands/list-mail-folder-messages-delta.d.ts +4 -0
- package/dist/use-cases/commands/list-mail-folder-messages.d.ts +1 -5
- package/dist/use-cases/commands/list-mail-folders.d.ts +1 -3
- package/dist/use-cases/commands/list-mail-messages.d.ts +1 -3
- package/dist/use-cases/commands/list-mail-rules.d.ts +1 -1
- package/dist/use-cases/commands/list-my-direct-reports.d.ts +13 -0
- package/dist/use-cases/commands/list-my-memberships.d.ts +4 -0
- package/dist/use-cases/commands/list-my-transitive-memberships.d.ts +4 -0
- package/dist/use-cases/commands/list-onenote-notebook-sections.d.ts +1 -5
- package/dist/use-cases/commands/list-onenote-notebooks.d.ts +1 -3
- package/dist/use-cases/commands/list-onenote-section-pages.d.ts +1 -5
- package/dist/use-cases/commands/list-outlook-categories.d.ts +6 -0
- package/dist/use-cases/commands/list-plan-buckets.d.ts +1 -5
- package/dist/use-cases/commands/list-planner-plans.d.ts +1 -3
- package/dist/use-cases/commands/list-planner-tasks.d.ts +1 -3
- package/dist/use-cases/commands/list-recent-files.d.ts +4 -0
- package/dist/use-cases/commands/list-recently-used-insights.d.ts +4 -0
- package/dist/use-cases/commands/list-relevant-people.d.ts +4 -0
- package/dist/use-cases/commands/list-room-lists.d.ts +4 -0
- package/dist/use-cases/commands/list-rooms.d.ts +4 -0
- package/dist/use-cases/commands/list-sensitivity-labels.d.ts +4 -0
- package/dist/use-cases/commands/list-shared-calendar-events.d.ts +4 -0
- package/dist/use-cases/commands/list-shared-insights.d.ts +4 -0
- package/dist/use-cases/commands/list-shared-mailbox-folder-messages.d.ts +4 -0
- package/dist/use-cases/commands/list-shared-mailbox-messages.d.ts +4 -0
- package/dist/use-cases/commands/list-shared-with-me.d.ts +6 -0
- package/dist/use-cases/commands/list-sharepoint-list-columns.d.ts +4 -0
- package/dist/use-cases/commands/list-sharepoint-list-item-versions.d.ts +4 -0
- package/dist/use-cases/commands/list-sharepoint-site-drives.d.ts +1 -5
- package/dist/use-cases/commands/list-sharepoint-site-list-items.d.ts +1 -6
- package/dist/use-cases/commands/list-sharepoint-site-lists.d.ts +7 -2
- package/dist/use-cases/commands/list-sharepoint-site-onenote-notebook-sections.d.ts +5 -0
- package/dist/use-cases/commands/list-sharepoint-site-onenote-notebooks.d.ts +5 -0
- package/dist/use-cases/commands/list-sharepoint-site-onenote-section-pages.d.ts +5 -0
- package/dist/use-cases/commands/list-sharepoint-site-pages.d.ts +4 -0
- package/dist/use-cases/commands/list-site-columns.d.ts +4 -0
- package/dist/use-cases/commands/list-site-content-types.d.ts +4 -0
- package/dist/use-cases/commands/list-specific-calendar-events.d.ts +1 -5
- package/dist/use-cases/commands/list-team-channels.d.ts +1 -5
- package/dist/use-cases/commands/list-team-installed-apps.d.ts +8 -0
- package/dist/use-cases/commands/list-teams-chat-history.d.ts +16 -0
- package/dist/use-cases/commands/list-teams-chat-messages.d.ts +8 -0
- package/dist/use-cases/commands/list-teams-chats-with-messages.d.ts +9 -0
- package/dist/use-cases/commands/list-todo-linked-resources.d.ts +1 -6
- package/dist/use-cases/commands/list-todo-task-lists.d.ts +1 -3
- package/dist/use-cases/commands/list-todo-tasks-delta.d.ts +8 -0
- package/dist/use-cases/commands/list-todo-tasks.d.ts +8 -2
- package/dist/use-cases/commands/list-trending-insights.d.ts +4 -0
- package/dist/use-cases/commands/list-user-direct-reports.d.ts +4 -0
- package/dist/use-cases/commands/markdown-pipeline.d.ts +23 -0
- package/dist/use-cases/commands/microsoft-search-query.d.ts +8 -0
- package/dist/use-cases/commands/my-quick-context.d.ts +6 -0
- package/dist/use-cases/commands/next-page.d.ts +2 -2
- package/dist/use-cases/commands/odata-query.d.ts +90 -0
- package/dist/use-cases/commands/office-to-markdown.d.ts +6 -0
- package/dist/use-cases/commands/onenote-5k-limit.d.ts +3 -0
- package/dist/use-cases/commands/output-path.d.ts +37 -0
- package/dist/use-cases/commands/resolve-calendar-link.d.ts +8 -0
- package/dist/use-cases/commands/resolve-drive-share-link.d.ts +8 -0
- package/dist/use-cases/commands/resolve-mail-link.d.ts +8 -0
- package/dist/use-cases/commands/resolve-teams-link.d.ts +8 -0
- package/dist/use-cases/commands/scopes-check.d.ts +6 -0
- package/dist/use-cases/commands/search-mail-messages.d.ts +3 -6
- package/dist/use-cases/commands/search-my-documents.d.ts +1 -5
- package/dist/use-cases/commands/search-onedrive-files.d.ts +1 -8
- package/dist/use-cases/commands/search-onenote-pages.d.ts +7 -2
- package/dist/use-cases/commands/search-sharepoint-sites-by-name.d.ts +1 -5
- package/dist/use-cases/commands/sharepoint-link-extractor.d.ts +14 -0
- package/dist/use-cases/commands/text-passthrough.d.ts +24 -0
- package/dist/use-cases/commands/version-id.d.ts +19 -0
- package/dist/use-cases/commands/xlsx-to-markdown.d.ts +6 -0
- package/dist/use-cases/ports/filesystem.d.ts +8 -0
- package/docs/COMMANDS.md +243 -0
- package/docs/USAGE.md +249 -0
- package/docs/commands.json +5870 -789
- package/package.json +11 -2
- /package/dist/use-cases/commands/{search-sharepoint-sites.d.ts → list-mail-folders-delta.d.ts} +0 -0
package/dist/infra/auth.d.ts
CHANGED
|
@@ -2,22 +2,80 @@ import type { AccessToken } from '../domain/access-token.js';
|
|
|
2
2
|
import type { Result } from '../domain/result.js';
|
|
3
3
|
import type { FileSystem } from '../use-cases/ports/filesystem.js';
|
|
4
4
|
import type { Logger } from '../use-cases/ports/logger.js';
|
|
5
|
-
import type { BrowserAuth } from './browser-auth.js';
|
|
5
|
+
import type { BrowserAuth, ElevatedFailureReason } from './browser-auth.js';
|
|
6
6
|
type AuthError = {
|
|
7
7
|
type: 'auth_failed';
|
|
8
8
|
message: string;
|
|
9
9
|
} | {
|
|
10
10
|
type: 'auth_cancelled';
|
|
11
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* Outcome of the elevated-token capture leg of the most recent
|
|
14
|
+
* browser-acquired session. Read by `login.execute` to surface a
|
|
15
|
+
* `{ elevated: 'captured' | 'failed', elevatedReason?: ... }` field on
|
|
16
|
+
* the login response so an LLM consumer can predict whether the
|
|
17
|
+
* elevated-dependent commands (chat metadata, historical-version
|
|
18
|
+
* downloads) will work without invoking them. Login-fix round-1 Wave D.
|
|
19
|
+
*/
|
|
20
|
+
type ElevatedOutcome = {
|
|
21
|
+
captured: true;
|
|
22
|
+
} | {
|
|
23
|
+
captured: false;
|
|
24
|
+
reason: ElevatedFailureReason | 'unknown_error';
|
|
25
|
+
};
|
|
12
26
|
type AuthManager = {
|
|
13
27
|
getAccessToken: () => Promise<Result<AccessToken, AuthError>>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns a Graph token issued for an app on Microsoft's ODSP
|
|
30
|
+
* `logicalPermissions` allow-list. Falls through cache → re-capture
|
|
31
|
+
* via headless Playwright. Used by the 3 historical-version commands.
|
|
32
|
+
*/
|
|
33
|
+
getElevatedAccessToken: () => Promise<Result<AccessToken, AuthError>>;
|
|
34
|
+
/**
|
|
35
|
+
* Returns a chatsvcagg-audience token (same Teams web client identity
|
|
36
|
+
* as `getAccessToken`, but issued for the chatsvcagg resource). Falls
|
|
37
|
+
* through cache → re-capture via headless Playwright. Used by the
|
|
38
|
+
* `list-teams-chats-with-messages` family of commands.
|
|
39
|
+
*/
|
|
40
|
+
getChatsvcaggAccessToken: () => Promise<Result<AccessToken, AuthError>>;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the regional segment used to construct chatsvcagg substrate
|
|
43
|
+
* URLs (`teams.microsoft.com/api/csa/<region>/api/...`). Captured at
|
|
44
|
+
* login from the first such URL the chatsvcagg bearer rides on. Falls
|
|
45
|
+
* back to `DEFAULT_CHATSVCAGG_REGION` ('emea') when the cache is
|
|
46
|
+
* either absent or pre-2026-05-migration. Synchronous on cache; calls
|
|
47
|
+
* `getChatsvcaggAccessToken()` first if no cache exists so a region is
|
|
48
|
+
* available immediately after login.
|
|
49
|
+
*/
|
|
50
|
+
getChatsvcaggRegion: () => Promise<string>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns an IC3-audience bearer (Teams web client identity, aud
|
|
53
|
+
* `https://ic3.teams.office.com`). Falls through cache → re-capture
|
|
54
|
+
* via headless Playwright. Used by `list-teams-chat-history` to walk
|
|
55
|
+
* paginated chat-message history beyond the 200-message chatsvcagg cap.
|
|
56
|
+
*/
|
|
57
|
+
getIc3AccessToken: () => Promise<Result<AccessToken, AuthError>>;
|
|
14
58
|
logout: () => Promise<Result<void, AuthError>>;
|
|
59
|
+
/**
|
|
60
|
+
* Inspect the elevated-capture outcome from the most recent
|
|
61
|
+
* `acquireViaBrowser` invocation. Returns null if no browser-acquired
|
|
62
|
+
* session has happened in this process (cache hit / refresh-only).
|
|
63
|
+
* Login-fix round-1 Wave D.
|
|
64
|
+
*/
|
|
65
|
+
getLastElevatedOutcome: () => ElevatedOutcome | null;
|
|
66
|
+
/**
|
|
67
|
+
* Inspect the chatsvcagg-capture outcome from the most recent
|
|
68
|
+
* `acquireViaBrowser` invocation. Same shape and lifetime semantics
|
|
69
|
+
* as `getLastElevatedOutcome`.
|
|
70
|
+
*/
|
|
71
|
+
getLastChatsvcaggOutcome: () => ElevatedOutcome | null;
|
|
15
72
|
};
|
|
16
|
-
declare const createAuthManagerFromApi: (browserAuth: BrowserAuth, cachePath: string, logger: Logger, fs: FileSystem) => AuthManager;
|
|
73
|
+
declare const createAuthManagerFromApi: (browserAuth: BrowserAuth, cachePath: string, browserProfileDir: string, logger: Logger, fs: FileSystem) => AuthManager;
|
|
17
74
|
declare const createAuthManager: (deps: {
|
|
18
75
|
cachePath: string;
|
|
19
76
|
logger: Logger;
|
|
20
77
|
fs?: FileSystem;
|
|
78
|
+
browserProfileDir?: string;
|
|
21
79
|
}) => AuthManager;
|
|
22
80
|
export { createAuthManager, createAuthManagerFromApi };
|
|
23
|
-
export type { AuthError, AuthManager };
|
|
81
|
+
export type { AuthError, AuthManager, ElevatedOutcome };
|
|
@@ -5,8 +5,143 @@ type BrowserTokenResult = {
|
|
|
5
5
|
accessToken: AccessToken;
|
|
6
6
|
refreshToken: string | null;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Discriminated outcome of an elevated-token capture attempt. Distinct
|
|
10
|
+
* failure variants let the caller pick the right error message AND let
|
|
11
|
+
* the auto-heal in auth.ts decide whether a retry is worthwhile (a
|
|
12
|
+
* recoverable failure like `launch_timeout` or `sso_timeout` is worth
|
|
13
|
+
* one retry after wiping the profile; `navigation_failed` is a network
|
|
14
|
+
* issue, not worth retrying).
|
|
15
|
+
*
|
|
16
|
+
* Login-fix round-1: was previously `AccessToken | null`, which conflated
|
|
17
|
+
* "browser launch hung", "navigation broke", and "silent-SSO polling
|
|
18
|
+
* timed out" into a single null and made the error message inaccurate.
|
|
19
|
+
*/
|
|
20
|
+
type ElevatedFailureReason = 'launch_timeout' | 'navigation_failed' | 'sso_timeout';
|
|
21
|
+
type ElevatedTokenResult = {
|
|
22
|
+
readonly ok: true;
|
|
23
|
+
readonly token: AccessToken;
|
|
24
|
+
} | {
|
|
25
|
+
readonly ok: false;
|
|
26
|
+
readonly reason: ElevatedFailureReason;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* chatsvcagg capture result. Carries the same three failure modes as
|
|
30
|
+
* `ElevatedTokenResult` PLUS the parsed regional segment from the URL
|
|
31
|
+
* the bearer rode on (`emea` / `amer` / `apac` / etc.) — the new
|
|
32
|
+
* substrate host (`teams.microsoft.com/api/csa/<region>/api/...`) routes
|
|
33
|
+
* per region, so callers must persist this alongside the token to
|
|
34
|
+
* construct future URLs. See `gotcha_chatsvcagg_substrate_moved` in
|
|
35
|
+
* the project memory for the 2026-05 migration that made this
|
|
36
|
+
* necessary.
|
|
37
|
+
*/
|
|
38
|
+
type ChatsvcaggTokenResult = {
|
|
39
|
+
readonly ok: true;
|
|
40
|
+
readonly token: AccessToken;
|
|
41
|
+
readonly region: string;
|
|
42
|
+
} | {
|
|
43
|
+
readonly ok: false;
|
|
44
|
+
readonly reason: ElevatedFailureReason;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* IC3 capture result. The "next-gen" Teams chat-message substrate at
|
|
48
|
+
* `teams.microsoft.com/api/chatsvc/<region>/v1/users/ME/conversations/{id}/messages`
|
|
49
|
+
* — the path Teams web actually uses for chat scrollback (the existing
|
|
50
|
+
* chatsvcagg substrate at `/api/csa/<region>/api/v1/chats/{id}/messages`
|
|
51
|
+
* is the chat-list aggregator and caps at the 200 most recent messages
|
|
52
|
+
* with no working pagination cursor). The IC3 path supports `syncState`
|
|
53
|
+
* + `startTime` pagination, unlocking arbitrary-depth chat history.
|
|
54
|
+
*
|
|
55
|
+
* Bearer audience: `https://ic3.teams.office.com`. Standard `Bearer`
|
|
56
|
+
* authorization (NOT the purple-teams-documented `skype_token X`
|
|
57
|
+
* header — those forks predate Teams' move to OAuth bearer on this
|
|
58
|
+
* surface). Empirically discovered 2026-05-21 by widening the
|
|
59
|
+
* Playwright capture listener.
|
|
60
|
+
*/
|
|
61
|
+
type Ic3TokenResult = {
|
|
62
|
+
readonly ok: true;
|
|
63
|
+
readonly token: AccessToken;
|
|
64
|
+
readonly region: string;
|
|
65
|
+
} | {
|
|
66
|
+
readonly ok: false;
|
|
67
|
+
readonly reason: ElevatedFailureReason;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Combined outcome of capturing all four tokens (Teams basic / M365
|
|
71
|
+
* elevated / chatsvcagg substrate / IC3 substrate) inside one browser
|
|
72
|
+
* session. Login-fix round-2 introduced this for the basic+elevated
|
|
73
|
+
* pair; chatsvcagg was added next; IC3 is the most recent leg, capturing
|
|
74
|
+
* the bearer Teams web uses for unbounded chat-history reads.
|
|
75
|
+
*
|
|
76
|
+
* All four legs ride on the SAME `teams.microsoft.com` session, so
|
|
77
|
+
* adding capture legs is essentially free — MSAL multiplexes the
|
|
78
|
+
* audience-scoped bearers via silent acquisition.
|
|
79
|
+
*/
|
|
80
|
+
type BothTokensResult = {
|
|
81
|
+
readonly teams: BrowserTokenResult | null;
|
|
82
|
+
readonly elevated: ElevatedTokenResult;
|
|
83
|
+
readonly chatsvcagg: ChatsvcaggTokenResult;
|
|
84
|
+
readonly ic3: Ic3TokenResult;
|
|
85
|
+
};
|
|
8
86
|
type BrowserAuth = {
|
|
9
87
|
acquireToken: (scopes: string[], startUrl: string) => Promise<BrowserTokenResult | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Capture an "elevated" Graph access token by navigating to a
|
|
90
|
+
* different Microsoft web app whose first-party app identity is on
|
|
91
|
+
* Microsoft's allow-list for ODSP `logicalPermissions` (the scope our
|
|
92
|
+
* Teams web client token lacks for historical-version stream
|
|
93
|
+
* content). Reuses the persistent profile cookies — no second
|
|
94
|
+
* sign-in. Headless by default.
|
|
95
|
+
*
|
|
96
|
+
* Returns a discriminated union so the caller can distinguish the three
|
|
97
|
+
* failure modes (browser-launch hang, navigation failure, silent-SSO
|
|
98
|
+
* polling timeout). The caller decides whether the failure is fatal
|
|
99
|
+
* (it isn't for most commands; only the version + chat commands need
|
|
100
|
+
* this).
|
|
101
|
+
*
|
|
102
|
+
* Standalone fallback path: used by `getElevatedAccessToken` when the
|
|
103
|
+
* cached elevated token expires and the Teams session is already in
|
|
104
|
+
* the cache (no fresh sign-in needed). On `login`, use
|
|
105
|
+
* `acquireBothTokens` instead so the user sees only one browser.
|
|
106
|
+
*/
|
|
107
|
+
acquireElevatedToken: () => Promise<ElevatedTokenResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Capture a chatsvcagg-audience bearer (Teams basic identity, but the
|
|
110
|
+
* `chatsvcagg.teams.microsoft.com` resource instead of Graph) by
|
|
111
|
+
* navigating headless to `teams.microsoft.com/v2/`. The persistent
|
|
112
|
+
* profile's SSO cookies do the auth silently. Used by
|
|
113
|
+
* `getChatsvcaggAccessToken()` when the cached chatsvcagg token has
|
|
114
|
+
* expired and the basic Teams session is still warm.
|
|
115
|
+
*
|
|
116
|
+
* Same failure-mode shape as `acquireElevatedToken` — launch hang,
|
|
117
|
+
* navigation failure, silent SSO timeout — so the auth-manager can
|
|
118
|
+
* reuse the same auto-heal logic.
|
|
119
|
+
*/
|
|
120
|
+
acquireChatsvcaggToken: () => Promise<ChatsvcaggTokenResult>;
|
|
121
|
+
/**
|
|
122
|
+
* Capture an IC3-audience bearer (aud `https://ic3.teams.office.com`,
|
|
123
|
+
* same basic Teams appid). The bearer Teams web client uses to call
|
|
124
|
+
* `teams.microsoft.com/api/chatsvc/<region>/v1/users/ME/conversations/{id}/messages`
|
|
125
|
+
* — the chat-message substrate with proper `syncState` pagination,
|
|
126
|
+
* enabling reads beyond the 200-message chatsvcagg cap. Same failure
|
|
127
|
+
* modes as `acquireChatsvcaggToken`.
|
|
128
|
+
*/
|
|
129
|
+
acquireIc3Token: () => Promise<Ic3TokenResult>;
|
|
130
|
+
/**
|
|
131
|
+
* Login-fix round-2: capture BOTH tokens inside ONE browser session.
|
|
132
|
+
* After the Teams response listener intercepts the Teams token,
|
|
133
|
+
* navigate the SAME page to the elevated URL and harvest the
|
|
134
|
+
* M365ChatClient bearer from outgoing request headers. Cookies are
|
|
135
|
+
* live in memory, so federated SSO chains (e.g. Okta-fronted
|
|
136
|
+
* tenants) work without a second visible sign-in.
|
|
137
|
+
*
|
|
138
|
+
* Returns `teams: null` if no Teams token came back within the full
|
|
139
|
+
* `pollDeadlineMs` (5 min). Returns
|
|
140
|
+
* `elevated: { ok: false, reason: ... }` if the elevated capture
|
|
141
|
+
* failed inside the same session — caller decides whether to surface
|
|
142
|
+
* the partial success.
|
|
143
|
+
*/
|
|
144
|
+
acquireBothTokens: (scopes: string[], teamsUrl: string) => Promise<BothTokensResult>;
|
|
10
145
|
close: () => Promise<void>;
|
|
11
146
|
};
|
|
12
147
|
type ResponseLike = {
|
|
@@ -17,6 +152,7 @@ type ResponseLike = {
|
|
|
17
152
|
type ResponseHandler = (response: ResponseLike) => void;
|
|
18
153
|
type PageLike = {
|
|
19
154
|
on(event: 'response', handler: ResponseHandler): void;
|
|
155
|
+
on(event: 'request', handler: RequestHandler): void;
|
|
20
156
|
goto(url: string, options: {
|
|
21
157
|
waitUntil: 'domcontentloaded';
|
|
22
158
|
timeout: number;
|
|
@@ -35,6 +171,11 @@ type LaunchOptions = {
|
|
|
35
171
|
channel?: 'msedge' | 'chrome';
|
|
36
172
|
args: string[];
|
|
37
173
|
};
|
|
174
|
+
type RequestLike = {
|
|
175
|
+
url(): string;
|
|
176
|
+
headers(): Record<string, string>;
|
|
177
|
+
};
|
|
178
|
+
type RequestHandler = (request: RequestLike) => void;
|
|
38
179
|
type BrowserAuthApi = {
|
|
39
180
|
launchPersistentContext(profileDir: string, options: LaunchOptions): Promise<ContextLike>;
|
|
40
181
|
};
|
|
@@ -55,6 +196,27 @@ type BrowserAuthConfig = {
|
|
|
55
196
|
readonly pollIntervalMs?: number;
|
|
56
197
|
readonly pollDeadlineMs?: number;
|
|
57
198
|
readonly navigationTimeoutMs?: number;
|
|
199
|
+
/**
|
|
200
|
+
* Deadline for the SILENT elevated-token recapture flow (no user
|
|
201
|
+
* interaction expected — persistent profile cookies do the SSO).
|
|
202
|
+
* Defaults to 20s. The audit (v1.0.0 §1.1) flagged that reusing the
|
|
203
|
+
* 5-minute interactive `pollDeadlineMs` for this silent path made
|
|
204
|
+
* `list-chats` etc. hang for minutes when cookies were stale, blowing
|
|
205
|
+
* the LLM tool-call window. With a tight cap, the flow either yields
|
|
206
|
+
* a token quickly or fails with `auth_failed: elevated token capture
|
|
207
|
+
* timed out — run `ask-marcel login` to refresh.`
|
|
208
|
+
*/
|
|
209
|
+
readonly elevatedRecaptureTimeoutMs?: number;
|
|
210
|
+
/**
|
|
211
|
+
* Hard deadline on `launchPersistentContext` + `newPage` for the
|
|
212
|
+
* elevated capture path. Defaults to 15s. Distinct from
|
|
213
|
+
* `elevatedRecaptureTimeoutMs` so the error message can name which
|
|
214
|
+
* step hung — launch vs polling. Audit login-fix round-1: previously
|
|
215
|
+
* unguarded, so a hung Playwright launch (corrupt persistent profile
|
|
216
|
+
* with stale `Singleton*` locks, or a slow browser binary) would
|
|
217
|
+
* block the whole command indefinitely.
|
|
218
|
+
*/
|
|
219
|
+
readonly elevatedLaunchTimeoutMs?: number;
|
|
58
220
|
};
|
|
59
221
|
declare const createPlaywrightApi: (loader: PlaywrightLoader) => BrowserAuthApi;
|
|
60
222
|
declare const createBrowserAuthFromApi: (api: BrowserAuthApi, config: BrowserAuthConfig) => BrowserAuth;
|
|
@@ -63,4 +225,4 @@ declare const createBrowserAuth: (deps: {
|
|
|
63
225
|
fs?: FileSystem;
|
|
64
226
|
}) => BrowserAuth;
|
|
65
227
|
export { createBrowserAuth, createBrowserAuthFromApi, createPlaywrightApi };
|
|
66
|
-
export type { BrowserAuth, BrowserAuthApi, BrowserAuthConfig, BrowserTokenResult, ChromiumLike, ContextLike, PageLike, PlaywrightLoader, ResponseLike };
|
|
228
|
+
export type { BothTokensResult, BrowserAuth, BrowserAuthApi, BrowserAuthConfig, BrowserTokenResult, ChatsvcaggTokenResult, Ic3TokenResult, ChromiumLike, ContextLike, ElevatedFailureReason, ElevatedTokenResult, PageLike, PlaywrightLoader, RequestLike, ResponseLike, };
|
|
@@ -4,19 +4,116 @@ type GraphError = {
|
|
|
4
4
|
type: 'api_error';
|
|
5
5
|
status: number;
|
|
6
6
|
message: string;
|
|
7
|
+
code?: string;
|
|
7
8
|
} | {
|
|
8
9
|
type: 'auth_failed';
|
|
9
10
|
message: string;
|
|
11
|
+
code?: string;
|
|
10
12
|
} | {
|
|
11
13
|
type: 'network_error';
|
|
12
14
|
message: string;
|
|
15
|
+
code?: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: 'validation_error';
|
|
18
|
+
message: string;
|
|
19
|
+
code?: string;
|
|
13
20
|
};
|
|
14
21
|
type GraphClient = {
|
|
15
|
-
|
|
22
|
+
/**
|
|
23
|
+
* `extraHeaders` lets a caller add request headers Graph requires on
|
|
24
|
+
* specific endpoints — currently the only documented use is
|
|
25
|
+
* `Prefer: odata.maxpagesize=N` on the calendar/mail delta endpoints,
|
|
26
|
+
* which reject `$top` as a query parameter. Auth + content-type are
|
|
27
|
+
* always set internally.
|
|
28
|
+
*/
|
|
29
|
+
get: (path: string, extraHeaders?: Record<string, string>) => Promise<Result<unknown, GraphError>>;
|
|
30
|
+
/**
|
|
31
|
+
* Same JSON-GET shape as `get`, but signs the request with the
|
|
32
|
+
* elevated Graph token (M365ChatClient). Used by commands the Teams
|
|
33
|
+
* web client token cannot reach — currently `list-chats` and
|
|
34
|
+
* `get-chat`, which need `Chat.ReadBasic` (only present on the
|
|
35
|
+
* elevated token).
|
|
36
|
+
*/
|
|
37
|
+
getElevated: (path: string) => Promise<Result<unknown, GraphError>>;
|
|
38
|
+
/**
|
|
39
|
+
* JSON-GET against the Teams chat substrate (post-2026-05:
|
|
40
|
+
* `teams.microsoft.com/api/csa/<region>/api/v{N}/...` — see
|
|
41
|
+
* `gotcha_chatsvcagg_substrate_moved` in memory for the migration
|
|
42
|
+
* away from `chatsvcagg.teams.microsoft.com`). Signs the request
|
|
43
|
+
* with the chatsvcagg-audience bearer captured at login (same Teams
|
|
44
|
+
* web client identity as `get`, different audience), and injects the
|
|
45
|
+
* cached substrate region between the host and `path`. Used by
|
|
46
|
+
* commands that need to read chat message BODIES, which the basic
|
|
47
|
+
* Graph token cannot reach (`Chat.Read*` scopes are missing).
|
|
48
|
+
*
|
|
49
|
+
* `path` MUST start with `/api/v{N}/...` — the host + `/api/csa/<region>`
|
|
50
|
+
* prefix are added by this client.
|
|
51
|
+
*/
|
|
52
|
+
teamsChat: (path: string) => Promise<Result<unknown, GraphError>>;
|
|
53
|
+
/**
|
|
54
|
+
* JSON-GET against the Teams IC3 chat-message substrate at
|
|
55
|
+
* `teams.microsoft.com/api/chatsvc/<region>/v1/...`. Same host as
|
|
56
|
+
* `teamsChat` but a DIFFERENT path prefix AND a different bearer
|
|
57
|
+
* audience (`https://ic3.teams.office.com` instead of
|
|
58
|
+
* `https://chatsvcagg.teams.microsoft.com`). The path supports
|
|
59
|
+
* `syncState` + `startTime` pagination — unlocking arbitrary-depth
|
|
60
|
+
* chat-history reads beyond the chatsvcagg 200-message cap (see
|
|
61
|
+
* `gotcha_chatsvcagg_substrate_moved` in memory). Used by
|
|
62
|
+
* `list-teams-chat-history`.
|
|
63
|
+
*
|
|
64
|
+
* `path` MUST start with `/v1/...` (e.g. `/v1/users/ME/conversations/{id}/messages?startTime=...`)
|
|
65
|
+
* — the host + `/api/chatsvc/<region>` prefix are added here.
|
|
66
|
+
*/
|
|
67
|
+
teamsChatIc3: (path: string) => Promise<Result<unknown, GraphError>>;
|
|
16
68
|
post: (path: string, body: unknown) => Promise<Result<unknown, GraphError>>;
|
|
17
69
|
getBinary: (path: string) => Promise<Result<unknown, GraphError>>;
|
|
70
|
+
/**
|
|
71
|
+
* Same shape as `getBinary` but signs the request with an "elevated"
|
|
72
|
+
* Graph token (issued for an app on Microsoft's ODSP
|
|
73
|
+
* `logicalPermissions` allow-list — e.g., M365ChatClient). Used by
|
|
74
|
+
* the historical-version commands which the Teams web client token
|
|
75
|
+
* cannot fetch (403 logicalPermissionAccessDenied).
|
|
76
|
+
*/
|
|
77
|
+
getBinaryElevated: (path: string) => Promise<Result<unknown, GraphError>>;
|
|
78
|
+
/**
|
|
79
|
+
* Auth-less fetch of an arbitrary URL whose host MUST be on the
|
|
80
|
+
* Microsoft allow-list. Used to follow `@microsoft.graph.downloadUrl`
|
|
81
|
+
* 302 redirects (CDN-signed URLs) that the format-conversion
|
|
82
|
+
* commands sometimes get back from Graph instead of inline bytes.
|
|
83
|
+
*/
|
|
84
|
+
fetchUrl: (url: string) => Promise<Result<unknown, GraphError>>;
|
|
85
|
+
/**
|
|
86
|
+
* Upload bytes to a drive item. `basePath` is the bare driveItem
|
|
87
|
+
* path (e.g. `/me/drive/root:/.ask-marcel-temp/abc.rtf`) — `put()`
|
|
88
|
+
* appends `:/content` for the simple ≤4 MiB sync path or
|
|
89
|
+
* `:/createUploadSession` for the chunked-session path internally
|
|
90
|
+
* based on `body.byteLength`. No upper file-size limit beyond the
|
|
91
|
+
* user's OneDrive quota.
|
|
92
|
+
*/
|
|
93
|
+
put: (basePath: string, body: Uint8Array, contentType?: string) => Promise<Result<unknown, GraphError>>;
|
|
94
|
+
delete: (path: string) => Promise<Result<unknown, GraphError>>;
|
|
95
|
+
/**
|
|
96
|
+
* Decode the cached basic Teams token's JWT and return its scopes /
|
|
97
|
+
* audience / expiry. Used by the `scopes-check` self-test command so the
|
|
98
|
+
* LLM can predict `accessDenied` instead of discovering it on the next
|
|
99
|
+
* Graph call. No network IO — operates on the cached token only.
|
|
100
|
+
*/
|
|
101
|
+
getCachedTokenInfo: () => Promise<Result<TokenInfo, GraphError>>;
|
|
102
|
+
};
|
|
103
|
+
type TokenInfo = {
|
|
104
|
+
readonly scopes: ReadonlyArray<string>;
|
|
105
|
+
readonly audience: string | undefined;
|
|
106
|
+
readonly expiresAt: string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Seconds remaining until the cached token's `exp` claim — derived from
|
|
109
|
+
* `expiresAt - now`. Negative when the token has already expired. Absent
|
|
110
|
+
* when the JWT did not carry an `exp` claim. Audit Hervé-session §4: lets
|
|
111
|
+
* an LLM decide pre-emptively to run `ask-marcel login` (re-auth typically
|
|
112
|
+
* worth doing under ~5 minutes) without parsing the ISO string itself.
|
|
113
|
+
*/
|
|
114
|
+
readonly expiresInSeconds: number | undefined;
|
|
18
115
|
};
|
|
19
116
|
type FetchFn = (url: string, init?: RequestInit) => Promise<Response>;
|
|
20
117
|
declare const createGraphClient: (auth: AuthManager, fetchFn?: FetchFn) => GraphClient;
|
|
21
118
|
export { createGraphClient };
|
|
22
|
-
export type { FetchFn, GraphClient, GraphError };
|
|
119
|
+
export type { FetchFn, GraphClient, GraphError, TokenInfo };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const REQUEST_TIMEOUT_MS = 60000;
|
|
2
|
+
export declare const BINARY_TRANSFER_TIMEOUT_MS: number;
|
|
3
|
+
export declare const REQUEST_TIMEOUT_LABEL = "60s";
|
|
4
|
+
export declare const BINARY_TRANSFER_TIMEOUT_LABEL = "5min";
|
|
5
|
+
export declare const networkErrorMessage: (e: unknown, label: string, timeoutLabel: string) => string;
|
|
6
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
7
|
+
export type TimeoutTier = 'json' | 'binary';
|
|
8
|
+
export declare const timeoutLabelFor: (tier: TimeoutTier) => string;
|
|
9
|
+
export declare const timeoutMsFor: (tier: TimeoutTier) => number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Result } from '../domain/result.js';
|
|
2
|
+
import type { GraphError } from './graph-client.js';
|
|
3
|
+
type SheetCsv = {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly csv: string;
|
|
6
|
+
};
|
|
7
|
+
declare const readSheetsAsCsv: (bytes: Uint8Array) => Result<ReadonlyArray<SheetCsv>, GraphError>;
|
|
8
|
+
export { readSheetsAsCsv };
|
|
9
|
+
export type { SheetCsv };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Translate Graph / substrate / CLI / validation errors into actionable hints.
|
|
3
|
+
*
|
|
4
|
+
* Audit Hervé-session §2: bare `error: ErrorInvalidIdMalformed: Id is
|
|
5
|
+
* malformed.` had no remedy for the LLM — it had to guess where the bad ID
|
|
6
|
+
* came from. This module is the centralised "what should I do about this"
|
|
7
|
+
* lookup: pattern-match the error code (or, as a fallback, a substring of
|
|
8
|
+
* the message) and surface a one-line hint plus a `source` classifier so
|
|
9
|
+
* the LLM can branch on whether the failure is server-side, substrate-side,
|
|
10
|
+
* CLI-side, or a Zod validation rejection. Surfaced through the standard
|
|
11
|
+
* error envelope in both `--output json` (as `hint` / `source` fields) and
|
|
12
|
+
* `--output text` (as `hint:` / `source:` lines under the existing `error:`
|
|
13
|
+
* line).
|
|
14
|
+
*
|
|
15
|
+
* Audit Hervé-session §2 follow-up: the four error-envelope variants are
|
|
16
|
+
* - `graph` — public Microsoft Graph API at /v1.0/
|
|
17
|
+
* - `substrate` — Microsoft-internal chat substrates (chatsvcagg / IC3).
|
|
18
|
+
* Tagged at the infra layer with `substrateHttp{N}_{name}`.
|
|
19
|
+
* - `cli` — CLI itself (Commander parser, CLI rewrites of Graph
|
|
20
|
+
* errors via `cli_rewrite_*` and `cli_reject_*` codes)
|
|
21
|
+
* - `validation` — Zod schema validation from use-cases (no `code` — pure
|
|
22
|
+
* message-pattern fallback)
|
|
23
|
+
*
|
|
24
|
+
* Rule precedence: specific code matchers run FIRST, then message-pattern
|
|
25
|
+
* fallbacks. The generic-validation rule sits LAST so it never overrides a
|
|
26
|
+
* code-based remedy.
|
|
27
|
+
*
|
|
28
|
+
* The table is intentionally small and biased toward HIGH-FREQUENCY errors
|
|
29
|
+
* an LLM actually hits. Adding more entries is cheap; the lookup is O(n)
|
|
30
|
+
* on a tiny n.
|
|
31
|
+
*/
|
|
32
|
+
export type ErrorSource = 'graph' | 'substrate' | 'cli' | 'validation';
|
|
33
|
+
export type ErrorHint = {
|
|
34
|
+
readonly hint: string;
|
|
35
|
+
readonly source: ErrorSource;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* First matching rule wins. Returns `undefined` when nothing in the table
|
|
39
|
+
* matches — caller renders the bare error (the historical shape).
|
|
40
|
+
*/
|
|
41
|
+
export declare const findErrorHint: (message: string, code: string | undefined) => ErrorHint | undefined;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '../use-cases/ports/logger.js';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { ErrorSource } from './error-hints.js';
|
|
3
|
+
type OutputFormat = 'text' | 'json';
|
|
4
|
+
declare const render: (data: unknown, logger: Logger, format: OutputFormat) => void;
|
|
5
|
+
declare const renderError: (message: string, format: OutputFormat, errorCode?: string, explicitSource?: ErrorSource) => void;
|
|
4
6
|
export { render, renderError };
|
|
7
|
+
export type { OutputFormat };
|
|
@@ -1,4 +1,70 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
2
|
import type { Command } from './command-types.js';
|
|
3
|
+
import { type ODataKey } from './odata-query.js';
|
|
4
|
+
/**
|
|
5
|
+
* Options accepted by every builder that knows about `$select` (i.e. every
|
|
6
|
+
* builder except `buildCommand` / `buildElevatedCommand`, which take no OData
|
|
7
|
+
* passthroughs at all). `defaultSelect`, when set and the user did NOT pass
|
|
8
|
+
* `--select`, is injected into the OData query string so default invocations
|
|
9
|
+
* return a slim projection instead of a 50 KB resource. User-supplied
|
|
10
|
+
* `--select` always wins. Audit Hervé-session §A: pairs the `list-mail-attachments`
|
|
11
|
+
* pattern with the builder layer so the 6 heaviest endpoints stop returning
|
|
12
|
+
* the full Graph resource by default.
|
|
13
|
+
*/
|
|
14
|
+
type SelectDefaults = {
|
|
15
|
+
readonly defaultSelect?: string;
|
|
16
|
+
};
|
|
3
17
|
declare const buildCommand: (pathFn: (params: Record<string, string>) => string, schema: z.ZodType) => Pick<Command, "schema" | "execute">;
|
|
4
|
-
|
|
18
|
+
declare const buildElevatedCommand: (pathFn: (params: Record<string, string>) => string, schema: z.ZodType) => Pick<Command, "schema" | "execute">;
|
|
19
|
+
declare const buildListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
20
|
+
declare const buildElevatedListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
21
|
+
/**
|
|
22
|
+
* Single-resource GET that supports the OData `$select` and `$expand` query
|
|
23
|
+
* parameters. Mirrors `buildListCommand` but exposes only the two flags that
|
|
24
|
+
* make sense on a non-paginated resource — no `$top`/`$skip`/`$filter`/
|
|
25
|
+
* `$orderby` since there's no collection to slice. Lets an LLM ask only for
|
|
26
|
+
* the fields it needs (e.g. `--select id,subject`) instead of swallowing a
|
|
27
|
+
* 50 KB resource just to read a subject line.
|
|
28
|
+
*/
|
|
29
|
+
declare const buildSelectableCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
30
|
+
/**
|
|
31
|
+
* Elevated-token twin of `buildSelectableCommand`. Use for single-resource
|
|
32
|
+
* GETs on endpoints that require the M365ChatClient identity (e.g. `/chats/{id}`)
|
|
33
|
+
* AND benefit from `$select`/`$expand` projection. The basic `buildElevatedCommand`
|
|
34
|
+
* builder takes no OData passthroughs — use this when the endpoint honours
|
|
35
|
+
* field projection, so an LLM can avoid pulling the whole resource just to
|
|
36
|
+
* read a topic or chatType.
|
|
37
|
+
*/
|
|
38
|
+
declare const buildElevatedSelectableCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
39
|
+
/**
|
|
40
|
+
* Collection GET that supports ONLY `$filter` and `$select` — for endpoints
|
|
41
|
+
* Microsoft documents as rejecting the other OData passthroughs (`/teams/{id}/channels`
|
|
42
|
+
* is the canonical case: Graph returns BadRequest on `$top`, `$skip`, `$orderby`,
|
|
43
|
+
* `$expand`). Advertising the unsupported flags would be a usability lie.
|
|
44
|
+
*/
|
|
45
|
+
declare const buildFilterSelectListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
46
|
+
/**
|
|
47
|
+
* Collection GET on an endpoint that supports the usual OData passthroughs
|
|
48
|
+
* EXCEPT `$skip` (e.g. `/me/drive/recent`, `/sites/{id}/lists`,
|
|
49
|
+
* `/me/drive/search`). Graph rejects `$skip` with
|
|
50
|
+
* `invalidRequest: $skip is not supported on this API.`; the CLI mirrors
|
|
51
|
+
* by dropping `--skip` from the advertised flag set.
|
|
52
|
+
*/
|
|
53
|
+
declare const buildNoSkipListCommand: <Shape extends z.ZodRawShape>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
54
|
+
/**
|
|
55
|
+
* Collection GET that supports an EXPLICIT subset of OData passthroughs.
|
|
56
|
+
* Use for endpoints where Graph silently drops some flags — passing
|
|
57
|
+
* `keys: ['top', 'select']` advertises only `--top` and `--select` and
|
|
58
|
+
* keeps the manifest honest. The other narrower builders
|
|
59
|
+
* (`buildNoSkipListCommand`, `buildFilterSelectListCommand`) are
|
|
60
|
+
* specializations; this is the generic escape hatch.
|
|
61
|
+
*/
|
|
62
|
+
declare const buildPickODataListCommand: <Shape extends z.ZodRawShape, K extends ODataKey>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, keys: ReadonlyArray<K>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
63
|
+
/**
|
|
64
|
+
* Elevated-token twin of `buildPickODataListCommand`. Use for endpoints that
|
|
65
|
+
* require the M365ChatClient identity (e.g. `/me/chats`, `/chats/{}/members`)
|
|
66
|
+
* AND honour only a subset of OData passthroughs — the chats family rejects
|
|
67
|
+
* `$orderby` / `$expand` with `BadRequest`, so the picker is the right tool.
|
|
68
|
+
*/
|
|
69
|
+
declare const buildElevatedPickODataListCommand: <Shape extends z.ZodRawShape, K extends ODataKey>(pathFn: (params: z.infer<z.ZodObject<Shape>>) => string, schema: z.ZodObject<Shape>, keys: ReadonlyArray<K>, options?: SelectDefaults) => Pick<Command, "schema" | "execute">;
|
|
70
|
+
export { buildCommand, buildElevatedCommand, buildElevatedListCommand, buildElevatedPickODataListCommand, buildElevatedSelectableCommand, buildFilterSelectListCommand, buildListCommand, buildNoSkipListCommand, buildPickODataListCommand, buildSelectableCommand, };
|