@dench.com/cli 3.2.4 → 3.4.0-staging.317

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
@@ -172,6 +172,20 @@ dench tool search "list recent gmail emails" --toolkit gmail
172
172
  dench tool run <composio_tool_slug> --args '{"key":"value"}' --json
173
173
  ```
174
174
 
175
+ `dench tool connect gmail`, `outlook`, `linkedin`, and `calendar` print Unipile
176
+ hosted-auth links using the same application, scopes, and callback as the web
177
+ app. Sign in with `dench signin` or use a member-owned Dench API key, then open
178
+ the returned link to authorize your account. New mailbox and LinkedIn
179
+ connections are private by default. An organization-only key cannot own a
180
+ personal connection.
181
+
182
+ Check the result with `dench tool status <toolkit> --json`. `calendar` shows
183
+ both Google and Outlook calendars; `google-calendar` (`googlecalendar`) and
184
+ `outlook-calendar` (`outlookcalendar`, `microsoft-calendar`) select one provider.
185
+ These status checks use Unipile-backed state without requiring Composio.
186
+ Other toolkits keep their existing connection provider. `--callback-url` is
187
+ only supported for Composio connections; Unipile uses Dench's managed callback.
188
+
175
189
  Start with compact `dench tool search` output. It lists ranked tools with slug,
176
190
  toolkit, connection status, and read-only/approval hints. Add `--json` only when
177
191
  you need full raw schemas or exact argument details.
package/app-sdk.d.ts CHANGED
@@ -1575,6 +1575,16 @@ export interface ApiRequests {
1575
1575
  /** Drop attendees not in this list. Default merges. */
1576
1576
  replace?: boolean;
1577
1577
  };
1578
+ /** Whether a meeting is shared with the whole workspace, and whether you may change that. — `dench meetings share` — GET /api/v1/meetings/{meetingEntryId}/sharing */
1579
+ "meetings.sharing.get": {
1580
+ meetingEntryId: string;
1581
+ };
1582
+ /** Share one meeting with the workspace, or take it back to owner + invitees. — `dench meetings share --workspace` — PUT /api/v1/meetings/{meetingEntryId}/sharing */
1583
+ "meetings.sharing.set": {
1584
+ meetingEntryId: string;
1585
+ /** true opens the meeting to every workspace member; false returns it to the owner plus the members who were on the invite. */
1586
+ shared: boolean;
1587
+ };
1578
1588
  /** Start Dench Emailing Service sender verification. — `dench email identity verify` — POST /api/v1/email/identities/verify */
1579
1589
  "email.identity.verify": {
1580
1590
  /** Identity scope. `domain` verifies via DNS (DKIM); `email` verifies a single mailbox via a confirmation email. */
@@ -4234,6 +4244,8 @@ export interface ApiResponses {
4234
4244
  "meetings.actionItems.delete": unknown;
4235
4245
  "meetings.participants.list": unknown;
4236
4246
  "meetings.participants.set": unknown;
4247
+ "meetings.sharing.get": unknown;
4248
+ "meetings.sharing.set": unknown;
4237
4249
  "email.identity.verify": {
4238
4250
  ok: boolean;
4239
4251
  identity: string;
@@ -6627,6 +6639,12 @@ export type DenchApiTree = {
6627
6639
  /** Record attendees by name/email; known members and existing people are linked, nobody is created. (`dench meetings participants set`) */
6628
6640
  set(args: Req<"meetings.participants.set">): Promise<Res<"meetings.participants.set">>;
6629
6641
  };
6642
+ sharing: {
6643
+ /** Whether a meeting is shared with the whole workspace, and whether you may change that. (`dench meetings share`) */
6644
+ get(args: Req<"meetings.sharing.get">): Promise<Res<"meetings.sharing.get">>;
6645
+ /** Share one meeting with the workspace, or take it back to owner + invitees. (`dench meetings share --workspace`) */
6646
+ set(args: Req<"meetings.sharing.set">): Promise<Res<"meetings.sharing.set">>;
6647
+ };
6630
6648
  transcript: {
6631
6649
  /** Append up to 500 transcript segments to a meeting (speakers with an email link to existing people). (`dench meetings transcript set`) */
6632
6650
  append(args: Req<"meetings.transcript.append">): Promise<Res<"meetings.transcript.append">>;
@@ -7051,6 +7069,10 @@ export interface DenchMeetings {
7051
7069
  setActionItemDone(itemId: string, done: boolean): Promise<Res<"meetings.actionItems.setDone">>;
7052
7070
  /** Participants of a meeting. Permission: `meetings:read`. Wraps `meetings.participants.list`. */
7053
7071
  participants(meetingEntryId: string): Promise<Res<"meetings.participants.list">>;
7072
+ /** Whether a meeting is shared with the whole workspace. Permission: `meetings:read`. Wraps `meetings.sharing.get`. */
7073
+ sharing(meetingEntryId: string): Promise<Res<"meetings.sharing.get">>;
7074
+ /** Share a meeting with the workspace, or take it back to owner + invitees. Permission: `meetings:write`. Wraps `meetings.sharing.set`. */
7075
+ setSharing(meetingEntryId: string, shared: boolean): Promise<Res<"meetings.sharing.set">>;
7054
7076
  }
7055
7077
 
7056
7078
  export interface DenchLists {
package/dench.ts CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  STAGING_HOST,
30
30
  } from "./host";
31
31
  import { resolveOrganizationBySelector } from "./lib/organizationSelector";
32
+ import { normalizeUnipileToolkitSlug } from "./lib/unipile-toolkits";
32
33
  import { formatApprovalOpenMessage, openUrl } from "./openUrl";
33
34
  import {
34
35
  explicitSessionKeyInput,
@@ -49,6 +50,7 @@ import {
49
50
  fetchConnectedAppsSummary,
50
51
  fetchUnipileConnections,
51
52
  runToolCommand,
53
+ toolHelp,
52
54
  } from "./tools";
53
55
 
54
56
  type JsonRecord = Record<string, unknown>;
@@ -546,7 +548,8 @@ CRM (Daytona-native rewrite):
546
548
  Help: dench crm help
547
549
 
548
550
  Meetings (CRM \`meeting\` records + their transcript, action items, attendance):
549
- dench meetings list [--limit N] | get <meetingId>
551
+ dench meetings list [--limit N] [--shared] | get <meetingId>
552
+ dench meetings share <meetingId> [--workspace | --private]
550
553
  dench meetings transcript get|set|clear <meetingId> [--text file | --jsonl file]
551
554
  dench meetings action-items list|add|set|done|delete ...
552
555
  dench meetings participants list|set <meetingId> [--people 'Name <email>; ...']
@@ -748,36 +751,6 @@ Advanced:
748
751
  `);
749
752
  }
750
753
 
751
- function toolHelp() {
752
- console.log(`Dench tool commands
753
-
754
- Usage:
755
- dench integrations [--json]
756
- dench tool status [toolkit] [--json]
757
- dench tool connect <toolkit> [--callback-url <url>] [--json]
758
- dench tool search "create github issue" [--toolkit github] [--limit 20] [--compact] [--json]
759
- dench tool run <composio_tool_slug> --args '{"key":"value"}' [--account <connectedAccountId>] [--json]
760
- dench tool disconnect <connectionId> [--json]
761
-
762
- Auth:
763
- All commands authenticate with the active \`dench signin\` agent
764
- session OR with DENCH_API_KEY (Bearer), whichever is set. Inside a
765
- Dench sandbox DENCH_API_KEY is baked into the env automatically; on
766
- a developer machine \`dench signin\` to a paid workspace works the
767
- same way (the CLI exchanges the session for a gateway key on demand).
768
-
769
- Notes:
770
- dench integrations is an alias for dench tool status.
771
- dench tool connect prints the OAuth redirect URL for the human to open.
772
- Slack is Dench's IN-HOUSE integration (never Composio): \`dench tool connect
773
- slack\` prints the first-party install URL, and SLACK_* tools (send with
774
- Block Kit blocks/buttons, read history, list channels/users) run through
775
- the org's own Slack app and can post to / read any channel.
776
- dench tool run output is redacted for display; pass --json for raw JSON.
777
- Override the gateway base with DENCH_GATEWAY_URL or GATEWAY_URL.
778
- `);
779
- }
780
-
781
754
  function contextHelp() {
782
755
  console.log(`Dench context
783
756
 
@@ -956,14 +929,17 @@ Lists every app connected to this organization, from both brokers:
956
929
  connected-account id, but they run through the SAME \`dench tool
957
930
  search\` / \`dench tool run\` — find the slug and run it. \`dench tool
958
931
  connect slack\` prints the in-house Slack install URL (org admin);
959
- a human connects the other four from the workspace Marketplace.
932
+ \`dench tool connect <gmail|outlook|linkedin|calendar>\` prints a
933
+ Unipile hosted-auth link using the web app's configuration. Open
934
+ that link to authorize the account, then check \`dench tool status\`.
960
935
  Slack is ALWAYS in-house (never Composio): SLACK_* tools can post
961
936
  to / read any channel, with Block Kit blocks and buttons.
962
937
  For reading, the CRM is usually better: calendar events sync into
963
938
  \`calendar_event\` and recordings into \`meeting\`.
964
939
 
965
- Composio does not broker those five, so they appear ONLY here — a
966
- missing calendar in this list means it is genuinely not connected.
940
+ Other toolkits connect through Composio. If \`unipileAvailable\` is
941
+ false, native status could not be checked; do not assume an account
942
+ is disconnected. Any Composio lookup failure is reported separately.
967
943
 
968
944
  Authenticates with the active \`dench signin\` agent session or
969
945
  DENCH_API_KEY (Bearer), whichever is set. Same output as
@@ -2884,6 +2860,17 @@ function gatewayAuthError(
2884
2860
  });
2885
2861
  }
2886
2862
 
2863
+ function gatewayAuthFailureReason(error: unknown): string {
2864
+ const nextActions =
2865
+ error instanceof CliError ? error.payload.nextActions : [];
2866
+ return [
2867
+ errorMessage(error),
2868
+ ...(Array.isArray(nextActions)
2869
+ ? nextActions.filter((action) => typeof action === "string")
2870
+ : []),
2871
+ ].join(" ");
2872
+ }
2873
+
2887
2874
  async function resolveGatewayCommandAuth(
2888
2875
  runtime: Runtime,
2889
2876
  command: string,
@@ -4828,16 +4815,19 @@ async function main() {
4828
4815
  // search/run/connect stay under `dench tool`.
4829
4816
  if (command === "integrations") {
4830
4817
  const runtime = await getRuntime();
4818
+ let gatewayAuthError: string | undefined;
4831
4819
  const gatewayAuth = await resolveGatewayCommandAuth(
4832
4820
  runtime,
4833
4821
  "dench integrations",
4834
- );
4822
+ ).catch((error) => {
4823
+ gatewayAuthError = gatewayAuthFailureReason(error);
4824
+ return null;
4825
+ });
4835
4826
  await runToolCommand({
4836
4827
  args: ["status"],
4837
4828
  jsonOutput: json,
4838
- bearerToken: gatewayAuth.bearerToken,
4839
- gatewayBaseUrl: gatewayAuth.gatewayBaseUrl,
4840
- gatewayHeaders: gatewayAuth.gatewayHeaders,
4829
+ ...(gatewayAuth ?? {}),
4830
+ gatewayAuthError,
4841
4831
  ...unipileQueryAuth(runtime),
4842
4832
  });
4843
4833
  return;
@@ -4879,19 +4869,28 @@ async function main() {
4879
4869
  return;
4880
4870
  }
4881
4871
  const runtime = await getRuntime();
4882
- // `connect slack` never touches the gateway — it prints the in-house
4883
- // install URL — so don't fail the whole command on gateway auth there.
4884
4872
  const isSlackConnect =
4885
4873
  sub === "connect" &&
4886
4874
  ["slack", "slackbot"].includes(
4887
4875
  (filteredSubArgs[1] ?? "").trim().toLowerCase(),
4888
4876
  );
4889
- const gatewayAuth = isSlackConnect
4890
- ? null
4891
- : await resolveGatewayCommandAuth(runtime, "dench tool");
4877
+ const isUnipileCommand =
4878
+ (sub === "connect" || sub === "status") &&
4879
+ normalizeUnipileToolkitSlug(filteredSubArgs[1] ?? "") !== null;
4880
+ let gatewayAuth: GatewayCommandAuth | null = null;
4881
+ let gatewayAuthError: string | undefined;
4882
+ if (!isSlackConnect && !isUnipileCommand) {
4883
+ try {
4884
+ gatewayAuth = await resolveGatewayCommandAuth(runtime, "dench tool");
4885
+ } catch (error) {
4886
+ if (sub !== "status") throw error;
4887
+ gatewayAuthError = gatewayAuthFailureReason(error);
4888
+ }
4889
+ }
4892
4890
  await runToolCommand({
4893
4891
  args: filteredSubArgs,
4894
4892
  jsonOutput: json,
4893
+ gatewayAuthError,
4895
4894
  ...(gatewayAuth
4896
4895
  ? {
4897
4896
  bearerToken: gatewayAuth.bearerToken,
@@ -3002,6 +3002,15 @@ export const requestSchemas: Record<string, ZodTypeAny> = {
3002
3002
  done: z.boolean(),
3003
3003
  }),
3004
3004
  "meetings.actionItems.delete": z.object({ itemId: z.string() }),
3005
+ "meetings.sharing.get": z.object({ meetingEntryId: z.string() }),
3006
+ "meetings.sharing.set": z.object({
3007
+ meetingEntryId: z.string(),
3008
+ shared: z
3009
+ .boolean()
3010
+ .describe(
3011
+ "true opens the meeting to every workspace member; false returns it to the owner plus the members who were on the invite.",
3012
+ ),
3013
+ }),
3005
3014
  "meetings.participants.list": z.object({ meetingEntryId: z.string() }),
3006
3015
  "meetings.participants.set": z.object({
3007
3016
  meetingEntryId: z.string(),
@@ -268,6 +268,8 @@ export const APP_SDK_OPERATIONS: readonly AppSdkOperationInfo[] = [
268
268
  {"id":"meetings.actionItems.delete","group":"meetings","summary":"Delete one action item.","cli":"dench meetings action-items delete","method":"DELETE","path":"/meetings/action-items/{itemId}","permission":"meetings:write","pathParams":["itemId"]},
269
269
  {"id":"meetings.participants.list","group":"meetings","summary":"Who was in the meeting, merged with the linked calendar invite.","cli":"dench meetings participants list","method":"GET","path":"/meetings/{meetingEntryId}/participants","permission":"meetings:read","pathParams":["meetingEntryId"]},
270
270
  {"id":"meetings.participants.set","group":"meetings","summary":"Record attendees by name/email; known members and existing people are linked, nobody is created.","cli":"dench meetings participants set","method":"PUT","path":"/meetings/{meetingEntryId}/participants","permission":"meetings:write","pathParams":["meetingEntryId"]},
271
+ {"id":"meetings.sharing.get","group":"meetings","summary":"Whether a meeting is shared with the whole workspace, and whether you may change that.","cli":"dench meetings share","method":"GET","path":"/meetings/{meetingEntryId}/sharing","permission":"meetings:read","pathParams":["meetingEntryId"]},
272
+ {"id":"meetings.sharing.set","group":"meetings","summary":"Share one meeting with the workspace, or take it back to owner + invitees.","cli":"dench meetings share --workspace","method":"PUT","path":"/meetings/{meetingEntryId}/sharing","permission":"meetings:write","pathParams":["meetingEntryId"]},
271
273
  {"id":"email.identity.verify","group":"email","summary":"Start Dench Emailing Service sender verification.","cli":"dench email identity verify","method":"POST","path":"/email/identities/verify","permission":"email:write","pathParams":[]},
272
274
  {"id":"email.identity.create","group":"email","summary":"Create a durable Dench email sending identity record.","cli":"dench email identity verify","method":"POST","path":"/email/sending-identities","permission":"email:write","pathParams":[]},
273
275
  {"id":"email.identity.refresh","group":"email","summary":"Refresh a Dench Emailing Service sender verification status.","cli":"dench email identity status --identity-id","method":"POST","path":"/email/sending-identities/{identityId}/status","permission":"email:write","pathParams":["identityId"]},
@@ -499,6 +501,8 @@ export const APP_SDK_METHODS: Readonly<Record<string, AppSdkMethodInfo>> = {
499
501
  "meetings.addActionItems": {"kind":"op","permission":"meetings:write","op":"meetings.actionItems.add","doc":"Add action items to a meeting."},
500
502
  "meetings.setActionItemDone": {"kind":"op","permission":"meetings:write","op":"meetings.actionItems.setDone","doc":"Check or uncheck an action item."},
501
503
  "meetings.participants": {"kind":"op","permission":"meetings:read","op":"meetings.participants.list","doc":"Participants of a meeting."},
504
+ "meetings.sharing": {"kind":"op","permission":"meetings:read","op":"meetings.sharing.get","doc":"Whether a meeting is shared with the whole workspace."},
505
+ "meetings.setSharing": {"kind":"op","permission":"meetings:write","op":"meetings.sharing.set","doc":"Share a meeting with the workspace, or take it back to owner + invitees."},
502
506
  "lists.list": {"kind":"op","permission":"lists:read","op":"lists.list","doc":"Saved lead lists."},
503
507
  "lists.get": {"kind":"op","permission":"lists:read","op":"lists.get","doc":"One saved list with its rows."},
504
508
  "lists.rename": {"kind":"op","permission":"lists:write","op":"lists.rename","doc":"Rename a list."},
@@ -587,6 +587,18 @@ export const APP_SDK_SURFACE: AppSdkSurface = {
587
587
  args: "meetingEntryId: string",
588
588
  returns: R("meetings.participants.list"),
589
589
  },
590
+ sharing: {
591
+ op: "meetings.sharing.get",
592
+ doc: "Whether a meeting is shared with the whole workspace.",
593
+ args: "meetingEntryId: string",
594
+ returns: R("meetings.sharing.get"),
595
+ },
596
+ setSharing: {
597
+ op: "meetings.sharing.set",
598
+ doc: "Share a meeting with the workspace, or take it back to owner + invitees.",
599
+ args: "meetingEntryId: string, shared: boolean",
600
+ returns: R("meetings.sharing.set"),
601
+ },
590
602
  },
591
603
 
592
604
  lists: {
@@ -2636,6 +2636,30 @@ const rawApiOperations = [
2636
2636
  responseSchema: anyResponse,
2637
2637
  backend: convex("mutation", "functions/meetings/importer:setParticipants"),
2638
2638
  }),
2639
+ op({
2640
+ id: "meetings.sharing.get",
2641
+ group: "meetings",
2642
+ summary:
2643
+ "Whether a meeting is shared with the whole workspace, and whether you may change that.",
2644
+ cli: "dench meetings share",
2645
+ method: "GET",
2646
+ path: "/meetings/{meetingEntryId}/sharing",
2647
+ requestSchema: noBody,
2648
+ responseSchema: anyResponse,
2649
+ backend: convex("query", "functions/meetings/sharing:getMeetingSharing"),
2650
+ }),
2651
+ op({
2652
+ id: "meetings.sharing.set",
2653
+ group: "meetings",
2654
+ summary:
2655
+ "Share one meeting with the workspace, or take it back to owner + invitees.",
2656
+ cli: "dench meetings share --workspace",
2657
+ method: "PUT",
2658
+ path: "/meetings/{meetingEntryId}/sharing",
2659
+ requestSchema: anyObject,
2660
+ responseSchema: anyResponse,
2661
+ backend: convex("mutation", "functions/meetings/sharing:setMeetingSharing"),
2662
+ }),
2639
2663
  op({
2640
2664
  id: "meetings.import",
2641
2665
  group: "local",
@@ -0,0 +1,55 @@
1
+ export type UnipileToolkitSlug =
2
+ | "gmail"
3
+ | "outlook"
4
+ | "linkedin"
5
+ | "calendar"
6
+ | "google-calendar"
7
+ | "outlook-calendar";
8
+
9
+ const TOOLKIT_ALIASES: Record<string, UnipileToolkitSlug> = {
10
+ gmail: "gmail",
11
+ outlook: "outlook",
12
+ outlook365: "outlook",
13
+ microsoftoutlook: "outlook",
14
+ microsoft365: "outlook",
15
+ office365: "outlook",
16
+ linkedin: "linkedin",
17
+ calendar: "calendar",
18
+ googlecalendar: "google-calendar",
19
+ outlookcalendar: "outlook-calendar",
20
+ microsoftcalendar: "outlook-calendar",
21
+ };
22
+
23
+ export function normalizeUnipileToolkitSlug(
24
+ slug: string,
25
+ ): UnipileToolkitSlug | null {
26
+ const normalized = slug
27
+ .trim()
28
+ .toLowerCase()
29
+ .replace(/[\s_-]+/g, "");
30
+ return Object.hasOwn(TOOLKIT_ALIASES, normalized)
31
+ ? TOOLKIT_ALIASES[normalized]
32
+ : null;
33
+ }
34
+
35
+ export type UnipileConnectKind =
36
+ | { kind: "mailbox"; provider: "gmail" | "outlook" }
37
+ | { kind: "calendar" }
38
+ | { kind: "linkedin" };
39
+
40
+ export function unipileConnectKindFromToolkitSlug(
41
+ slug: string,
42
+ ): UnipileConnectKind | null {
43
+ const toolkit = normalizeUnipileToolkitSlug(slug);
44
+ if (toolkit === "gmail" || toolkit === "outlook") {
45
+ return { kind: "mailbox", provider: toolkit };
46
+ }
47
+ if (
48
+ toolkit === "calendar" ||
49
+ toolkit === "google-calendar" ||
50
+ toolkit === "outlook-calendar"
51
+ ) {
52
+ return { kind: "calendar" };
53
+ }
54
+ return toolkit === "linkedin" ? { kind: "linkedin" } : null;
55
+ }
package/meetings.ts CHANGED
@@ -74,6 +74,14 @@ const api = {
74
74
  "functions/meetings/participantLinks:listMeetingParticipantRoster",
75
75
  ),
76
76
  },
77
+ sharing: {
78
+ get: makeFunctionReference<"query">(
79
+ "functions/meetings/sharing:getMeetingSharing",
80
+ ),
81
+ set: makeFunctionReference<"mutation">(
82
+ "functions/meetings/sharing:setMeetingSharing",
83
+ ),
84
+ },
77
85
  importer: {
78
86
  clearTranscript: makeFunctionReference<"mutation">(
79
87
  "functions/meetings/importer:clearTranscript",
@@ -130,6 +138,8 @@ export async function runMeetingsCommand(opts: {
130
138
  case "participants":
131
139
  case "attendees":
132
140
  return await runParticipants(ctx);
141
+ case "share":
142
+ return await runShare(ctx);
133
143
  case "import":
134
144
  return await runImport(ctx);
135
145
  default:
@@ -143,6 +153,7 @@ export async function runMeetingsCommand(opts: {
143
153
 
144
154
  async function runList(ctx: CrmCliContext): Promise<void> {
145
155
  const limitRaw = getFlag(ctx.args, "--limit");
156
+ const sharedOnly = hasFlag(ctx.args, "--shared");
146
157
  assertNoUnknownFlags(ctx.args, "meetings list");
147
158
  const numItems = limitRaw ? Number(limitRaw) : 50;
148
159
  if (!Number.isFinite(numItems) || numItems <= 0) {
@@ -150,6 +161,7 @@ async function runList(ctx: CrmCliContext): Promise<void> {
150
161
  }
151
162
  const result = (await callQuery(ctx, api.library.listMeetings, {
152
163
  paginationOpts: { numItems, cursor: null },
164
+ ...(sharedOnly ? { sharedOnly: true } : {}),
153
165
  })) as { page?: unknown[] } | null;
154
166
  out(ctx, result?.page ?? []);
155
167
  }
@@ -165,6 +177,64 @@ async function runGet(ctx: CrmCliContext): Promise<void> {
165
177
  out(ctx, entry);
166
178
  }
167
179
 
180
+ // ── share ──────────────────────────────────────────────────────────────────
181
+
182
+ /**
183
+ * `dench meetings share <id> [--workspace|--private]`
184
+ *
185
+ * With no flag this READS the current state rather than guessing a
186
+ * direction: "share" is a permission change, and a bare command that
187
+ * silently published a call would be the wrong default for a verb someone
188
+ * might run to check what a meeting is.
189
+ */
190
+ async function runShare(ctx: CrmCliContext): Promise<void> {
191
+ const meetingEntryId = shift(ctx.args, "meeting id");
192
+ const toWorkspace = hasFlag(ctx.args, "--workspace");
193
+ const toPrivate = hasFlag(ctx.args, "--private");
194
+ assertNoUnknownFlags(ctx.args, "meetings share");
195
+ if (toWorkspace && toPrivate) {
196
+ throw new CrmCliError(
197
+ "Pass either --workspace or --private, not both. With neither, the current sharing is printed.",
198
+ );
199
+ }
200
+
201
+ if (!toWorkspace && !toPrivate) {
202
+ const current = (await callQuery(ctx, api.sharing.get, {
203
+ meetingEntryId,
204
+ })) as { sharedWithWorkspace: boolean; canShare: boolean } | null;
205
+ if (!current) throw new CrmCliError(`Meeting not found: ${meetingEntryId}`);
206
+ if (ctx.jsonOutput) {
207
+ out(ctx, current);
208
+ return;
209
+ }
210
+ console.log(
211
+ current.sharedWithWorkspace
212
+ ? "Shared with the workspace — every member can read this meeting."
213
+ : "Private — the owner plus the members who were on the invite.",
214
+ );
215
+ if (!current.canShare) {
216
+ console.log(
217
+ "You cannot change this: only the meeting's owner or a workspace admin can.",
218
+ );
219
+ }
220
+ return;
221
+ }
222
+
223
+ const result = (await callMutation(ctx, api.sharing.set, {
224
+ meetingEntryId,
225
+ shared: toWorkspace,
226
+ })) as { sharedWithWorkspace: boolean };
227
+ if (ctx.jsonOutput) {
228
+ out(ctx, result);
229
+ return;
230
+ }
231
+ console.log(
232
+ result.sharedWithWorkspace
233
+ ? "Shared with the workspace."
234
+ : "Made private — the owner plus the members who were on the invite.",
235
+ );
236
+ }
237
+
168
238
  // ── transcript ─────────────────────────────────────────────────────────────
169
239
 
170
240
  async function runTranscript(ctx: CrmCliContext): Promise<void> {
@@ -658,9 +728,20 @@ create, update and delete it with \`dench crm entries … meeting\`, query it
658
728
  with \`dench crm query meeting\`, list its fields with \`dench crm fields list
659
729
  meeting\`. These verbs add the parts that live beside the record:
660
730
 
661
- dench meetings list [--limit N] [--json]
731
+ dench meetings list [--limit N] [--shared] [--json]
662
732
  dench meetings get <meetingId> [--json]
663
733
 
734
+ You see a meeting if you own it, if you were on the invite, or if it has
735
+ been shared with the workspace. \`--shared\` narrows the list to the last of
736
+ those — the calls anyone on the team can read.
737
+
738
+ Sharing:
739
+ dench meetings share <meetingId> print who can read it
740
+ dench meetings share <meetingId> --workspace open it to every member
741
+ dench meetings share <meetingId> --private back to owner + invitees
742
+ Only the meeting's owner or a workspace admin can change this. To
743
+ change the default for NEW recordings, use Settings › Meetings.
744
+
664
745
  Transcript (meetingTranscriptSegments):
665
746
  dench meetings transcript get <meetingId> [--json|--text]
666
747
  dench meetings transcript set <meetingId> --text notes.txt | --jsonl segments.jsonl | --file segments.json [--append]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dench.com/cli",
3
- "version": "3.2.4",
3
+ "version": "3.4.0-staging.317",
4
4
  "description": "Dench agent workspace CLI.",
5
5
  "type": "module",
6
6
  "bin": {
package/tools.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  * paid-workspace gateway key resolved from the active agent session by
8
8
  * the top-level dispatcher.
9
9
  *
10
- * Two exceptions are not pure gateway passthroughs:
10
+ * Dench-brokered connections are not pure gateway passthroughs:
11
11
  * - the connection LISTING: Gmail, Outlook, Calendar and LinkedIn (Unipile)
12
12
  * and Slack (Dench's in-house Slack app) are brokered by Dench, not
13
13
  * Composio, so `status` also reads them from Convex and merges the two
@@ -15,6 +15,8 @@
15
15
  * - `connect slack`: prints the in-house Slack install URL
16
16
  * (`/api/slack/install?slug=…`) instead of a Composio OAuth redirect —
17
17
  * the in-house connection always takes preference over Composio Slack.
18
+ * - Gmail, Outlook, Calendar and LinkedIn connect through the same Unipile
19
+ * hosted-auth actions as the web app, authenticated by the Dench session.
18
20
  *
19
21
  * Subcommands:
20
22
  *
@@ -51,6 +53,10 @@ import {
51
53
  parseJson,
52
54
  shift as shiftRaw,
53
55
  } from "./lib/cli-args";
56
+ import {
57
+ normalizeUnipileToolkitSlug,
58
+ unipileConnectKindFromToolkitSlug,
59
+ } from "./lib/unipile-toolkits";
54
60
 
55
61
  // ---------------------------------------------------------------------------
56
62
  // Public dispatcher
@@ -62,6 +68,7 @@ export type ToolCliContext = {
62
68
  bearerToken?: string;
63
69
  gatewayBaseUrl?: string;
64
70
  gatewayHeaders?: Record<string, string>;
71
+ gatewayAuthError?: string;
65
72
  /**
66
73
  * Convex client + bearer for the Unipile half of the list. Absent on the
67
74
  * help path and whenever the caller could not be authenticated, in which
@@ -80,7 +87,7 @@ export type ToolCliContext = {
80
87
 
81
88
  type GatewayAuthContext = Pick<
82
89
  ToolCliContext,
83
- "bearerToken" | "gatewayBaseUrl" | "gatewayHeaders"
90
+ "bearerToken" | "gatewayBaseUrl" | "gatewayHeaders" | "gatewayAuthError"
84
91
  >;
85
92
 
86
93
  type UnipileAuthContext = Pick<ToolCliContext, "convex" | "sessionToken">;
@@ -129,6 +136,15 @@ const getUnipileToolRef = makeFunctionReference<"query">(
129
136
  const runUnipileToolRef = makeFunctionReference<"action">(
130
137
  "functions/unipileToolsNode:runTool",
131
138
  );
139
+ const connectMailboxRef = makeFunctionReference<"action">(
140
+ "functions/emailMailboxUnipileNode:createHostedAuthLink",
141
+ );
142
+ const connectLinkedinRef = makeFunctionReference<"action">(
143
+ "functions/linkedinUnipileNode:createHostedAuthLink",
144
+ );
145
+ const connectCalendarRef = makeFunctionReference<"action">(
146
+ "functions/calendarUnipileNode:createCalendarHostedAuthLink",
147
+ );
132
148
 
133
149
  /**
134
150
  * Gmail, Outlook, Calendar and LinkedIn are brokered by Dench, and Composio
@@ -234,6 +250,15 @@ export async function fetchConnectedAppsSummary(
234
250
  unipileAvailable: unipile.available,
235
251
  ...(unipile.error ? { unipileError: unipile.error } : {}),
236
252
  };
253
+ if (ctx.gatewayAuthError) {
254
+ return {
255
+ available: false,
256
+ count: unipile.connections.length,
257
+ connections: unipile.connections,
258
+ ...unipileFields,
259
+ reason: ctx.gatewayAuthError,
260
+ };
261
+ }
237
262
  let payload: unknown;
238
263
  try {
239
264
  payload = await callGateway(ctx, "GET", "/v1/composio/connections");
@@ -251,7 +276,9 @@ export async function fetchConnectedAppsSummary(
251
276
  : { ...failure, error: errorMessage(error) };
252
277
  }
253
278
  const connections = [
254
- ...extractConnections(payload).map(compactConnection),
279
+ ...extractConnections(payload)
280
+ .map(compactConnection)
281
+ .filter((connection) => !normalizeUnipileToolkitSlug(connection.toolkit)),
255
282
  ...unipile.connections,
256
283
  ];
257
284
  return {
@@ -267,12 +294,30 @@ export async function fetchConnectedAppsSummary(
267
294
  // ---------------------------------------------------------------------------
268
295
 
269
296
  async function runStatusSubcommand(ctx: ToolCliContext): Promise<void> {
270
- const filterToolkit = ctx.args[0]?.startsWith("--") ? undefined : ctx.args[0];
271
- if (filterToolkit) ctx.args.shift();
272
-
273
- const connectionsSummary = await fetchConnectedAppsSummary(ctx);
297
+ const requestedToolkit = ctx.args[0]?.startsWith("--")
298
+ ? undefined
299
+ : ctx.args[0];
300
+ if (requestedToolkit) ctx.args.shift();
301
+ const unipileToolkit = requestedToolkit
302
+ ? normalizeUnipileToolkitSlug(requestedToolkit)
303
+ : null;
304
+ const filterToolkit = unipileToolkit ?? requestedToolkit;
305
+
306
+ let connectionsSummary: Awaited<ReturnType<typeof fetchConnectedAppsSummary>>;
307
+ if (unipileToolkit) {
308
+ const unipile = await fetchUnipileConnections(ctx);
309
+ connectionsSummary = {
310
+ available: unipile.available,
311
+ count: unipile.connections.length,
312
+ connections: unipile.connections,
313
+ unipileAvailable: unipile.available,
314
+ ...(unipile.error ? { unipileError: unipile.error } : {}),
315
+ };
316
+ } else {
317
+ connectionsSummary = await fetchConnectedAppsSummary(ctx);
318
+ }
274
319
  let toolkitsPayload: unknown = null;
275
- if (filterToolkit && connectionsSummary.available) {
320
+ if (filterToolkit && !unipileToolkit && connectionsSummary.available) {
276
321
  const search = encodeURIComponent(filterToolkit);
277
322
  toolkitsPayload = await callGateway(
278
323
  ctx,
@@ -286,12 +331,15 @@ async function runStatusSubcommand(ctx: ToolCliContext): Promise<void> {
286
331
  // with the Unipile mailbox instead of nothing.
287
332
  const filteredConnections = filterToolkit
288
333
  ? allConnections.filter(
289
- (conn) => conn.toolkit.toLowerCase() === filterToolkit.toLowerCase(),
334
+ (conn) =>
335
+ conn.toolkit.toLowerCase() === filterToolkit.toLowerCase() ||
336
+ (unipileToolkit === "calendar" &&
337
+ ["google-calendar", "outlook-calendar"].includes(conn.toolkit)),
290
338
  )
291
339
  : allConnections;
292
340
 
293
341
  const summary = {
294
- ok: true,
342
+ ok: unipileToolkit ? connectionsSummary.unipileAvailable : true,
295
343
  available: connectionsSummary.available,
296
344
  toolkit: filterToolkit ?? null,
297
345
  count: filteredConnections.length,
@@ -642,6 +690,57 @@ async function runConnectSubcommand(ctx: ToolCliContext): Promise<void> {
642
690
  await runSlackConnectSubcommand(ctx, normalizedToolkit);
643
691
  return;
644
692
  }
693
+ const unipile = unipileConnectKindFromToolkitSlug(toolkit);
694
+ if (unipile) {
695
+ if (!ctx.convex || !ctx.sessionToken) {
696
+ throw new ToolCliError(
697
+ "Sign in with `dench signin` or use a member-owned Dench API key to connect this integration.",
698
+ );
699
+ }
700
+ if (ctx.args.includes("--callback-url")) {
701
+ throw new ToolCliError(
702
+ "Unipile connections use Dench's managed callback. --callback-url is only supported for Composio integrations.",
703
+ );
704
+ }
705
+ const result = asRecord(
706
+ await ctx.convex.action(
707
+ unipile.kind === "mailbox"
708
+ ? connectMailboxRef
709
+ : unipile.kind === "linkedin"
710
+ ? connectLinkedinRef
711
+ : connectCalendarRef,
712
+ {
713
+ sessionToken: ctx.sessionToken,
714
+ ...(unipile.kind === "mailbox" ? { provider: unipile.provider } : {}),
715
+ },
716
+ ),
717
+ );
718
+ const redirectUrl = stringField(result, "link");
719
+ if (!redirectUrl) {
720
+ throw new ToolCliError("Unipile did not return a connection link.");
721
+ }
722
+ const message = `Connect ${toolkit} here: ${redirectUrl}`;
723
+ if (ctx.jsonOutput) {
724
+ console.log(
725
+ JSON.stringify(
726
+ {
727
+ ok: true,
728
+ source: "unipile",
729
+ toolkit: normalizeUnipileToolkitSlug(toolkit),
730
+ redirectUrl,
731
+ expiresAt: result?.expiresAt,
732
+ connectionId: null,
733
+ message,
734
+ },
735
+ null,
736
+ 2,
737
+ ),
738
+ );
739
+ } else {
740
+ console.log(message);
741
+ }
742
+ return;
743
+ }
645
744
  const callbackUrl =
646
745
  getFlag(ctx.args, "--callback-url") ??
647
746
  process.env.DENCH_OAUTH_CALLBACK_URL?.trim() ??
@@ -1075,6 +1174,8 @@ function formatStatusSummary(summary: {
1075
1174
  connections: CompactConnection[];
1076
1175
  unipileAvailable?: boolean;
1077
1176
  unipileError?: string;
1177
+ reason?: string;
1178
+ error?: string;
1078
1179
  }): string {
1079
1180
  const lines: string[] = [];
1080
1181
  if (summary.toolkit) {
@@ -1096,6 +1197,11 @@ function formatStatusSummary(summary: {
1096
1197
  })`,
1097
1198
  );
1098
1199
  }
1200
+ if (summary.reason || summary.error) {
1201
+ lines.push(
1202
+ ` (could not check Composio integrations: ${summary.reason ?? summary.error})`,
1203
+ );
1204
+ }
1099
1205
  return lines.join("\n");
1100
1206
  }
1101
1207
 
@@ -1242,7 +1348,7 @@ function redactForDisplay(value: unknown, key?: string): unknown {
1242
1348
  // Help text
1243
1349
  // ---------------------------------------------------------------------------
1244
1350
 
1245
- function toolHelp() {
1351
+ export function toolHelp() {
1246
1352
  console.log(`Dench tool commands
1247
1353
 
1248
1354
  Usage:
@@ -1255,14 +1361,18 @@ Usage:
1255
1361
 
1256
1362
  Notes:
1257
1363
  All commands authenticate with DENCH_API_KEY or the active \`dench signin\`
1258
- agent session. Agent sessions require a paid workspace.
1364
+ agent session. Composio commands use paid-workspace gateway credentials.
1365
+ Native Gmail/Outlook/Calendar/LinkedIn connect/status need no gateway key;
1366
+ connect requires a workspace member or a member-owned Dench API key.
1259
1367
  Results carry a "source". "composio" rows are brokered by Composio; "unipile"
1260
1368
  rows (gmail, outlook, calendar, linkedin) and "dench" rows (slack) are
1261
1369
  connected by Dench itself. ALL of them run through \`dench tool run\` with the
1262
1370
  same slug + --args contract. \`dench tool connect slack\` prints the in-house
1263
- Slack install URL (org admin, one click); gmail/outlook/calendar/linkedin are
1264
- connected by a human from the workspace Marketplace; every other toolkit
1265
- connects through Composio's OAuth redirect.
1371
+ Slack install URL (org admin, one click). For gmail/outlook/calendar/linkedin,
1372
+ connect prints a Unipile hosted-auth link using the web app's configuration.
1373
+ Sign in as a workspace member and open the link to authorize the account.
1374
+ Calendar status accepts calendar, google-calendar, or outlook-calendar.
1375
+ Other toolkits connect through Composio; --callback-url applies only to them.
1266
1376
  Slack is ALWAYS in-house: SLACK_* slugs (SLACK_SEND_MESSAGE with Block Kit
1267
1377
  blocks/buttons, SLACK_FETCH_HISTORY, SLACK_LIST_CHANNELS, …) run through the
1268
1378
  org's own Slack app install and can post to / read any channel.