@kamilio/wire 0.1.71 → 0.1.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/adapters/root.d.ts +6 -0
  2. package/dist/adapters/root.d.ts.map +1 -1
  3. package/dist/adapters/root.js +51 -1
  4. package/dist/adapters/root.js.map +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +5 -1
  7. package/dist/cli.js.map +1 -1
  8. package/dist/executable.js +4 -4
  9. package/dist/executable.js.map +1 -1
  10. package/node_modules/provider-asana/dist/asana-task.d.ts +4 -0
  11. package/node_modules/provider-asana/dist/asana-task.d.ts.map +1 -1
  12. package/node_modules/provider-asana/dist/asana-task.js +11 -1
  13. package/node_modules/provider-asana/dist/asana-task.js.map +1 -1
  14. package/node_modules/provider-asana/dist/index.d.ts +1 -1
  15. package/node_modules/provider-asana/dist/index.d.ts.map +1 -1
  16. package/node_modules/provider-asana/dist/index.js +1 -1
  17. package/node_modules/provider-asana/dist/index.js.map +1 -1
  18. package/node_modules/provider-asana/src/asana-task.ts +9 -1
  19. package/node_modules/provider-asana/src/index.ts +1 -1
  20. package/node_modules/provider-notion/dist/index.d.ts +1 -1
  21. package/node_modules/provider-notion/dist/index.d.ts.map +1 -1
  22. package/node_modules/provider-notion/dist/index.js +1 -1
  23. package/node_modules/provider-notion/dist/index.js.map +1 -1
  24. package/node_modules/provider-notion/dist/notion-sync.d.ts +21 -0
  25. package/node_modules/provider-notion/dist/notion-sync.d.ts.map +1 -1
  26. package/node_modules/provider-notion/dist/notion-sync.js +59 -1
  27. package/node_modules/provider-notion/dist/notion-sync.js.map +1 -1
  28. package/node_modules/provider-notion/src/index.ts +1 -1
  29. package/node_modules/provider-notion/src/notion-sync.ts +56 -1
  30. package/package.json +1 -1
  31. package/src/adapters/root.ts +53 -2
  32. package/src/cli.ts +3 -1
  33. package/src/executable.ts +4 -4
@@ -3,6 +3,7 @@ import { UserError, defineCommand, defineGroup, S, type Group } from "toolcraft"
3
3
 
4
4
  import { defaultWireBackend, registryPathForBackend, type JsonObject, type FetchedDocument, type InitializedWire, type Resource, type SwitchedWireBackend, type Wire, type WireBackend, type WireResult, type WireWatchSession } from "wire-core";
5
5
  import type { listAsanaProjects, listAsanaTasks, moveAsanaTask, showAsanaProject } from "provider-asana";
6
+ import type { searchNotion } from "provider-notion";
6
7
  import type { zoomProvider } from "provider-zoom";
7
8
  import type { SlackSentMessage } from "provider-slack";
8
9
  import type { Auth, AuthResult, AuthService } from "../auth.js";
@@ -14,7 +15,7 @@ import { formatDocComments, type listDocComments, type changeDocComment } from "
14
15
  type Comments = { comments?: Awaited<ReturnType<typeof listDocComments>> };
15
16
  export type WireRoot = Group;
16
17
  export type TextInputReader = () => Promise<string>;
17
- export type WireRootOptions = Readonly<{ allowPaste: boolean; codeSignalEdit?: (url: string, path: string, file: string) => ReturnType<typeof editCodeSignal>; codeSignalRun?: (url: string) => ReturnType<typeof runCodeSignal>; shareNotionWithOrg?: (id: string) => Promise<string>; scrapeClaude?: () => Promise<string>; listDocComments?: (url: string) => ReturnType<typeof listDocComments>; changeDocComment?: (action: Parameters<typeof changeDocComment>[1], url: string, value?: string) => ReturnType<typeof changeDocComment>; ashby?: (action: string, arg?: string) => Promise<string>; previewDrive?: (url: string) => Promise<string>; scrapeDrive?: (url?: string, deleteVerifiedPdfs?: boolean, deleteVerifiedDocx?: boolean) => Promise<string>; calendarAgenda?: (date?: string, calendarId?: string) => ReturnType<typeof readAgenda>; latticeSync?: (url: string | undefined, file?: string) => Promise<string>; latticeRequests?: (url: string) => Promise<string>; latticeTemplate?: (url: string) => Promise<string>; latticeFill?: (url: string, file: string) => Promise<string>; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
18
+ export type WireRootOptions = Readonly<{ allowPaste: boolean; searchNotion?: (query: string, options: Parameters<typeof searchNotion>[2]) => ReturnType<typeof searchNotion>; codeSignalEdit?: (url: string, path: string, file: string) => ReturnType<typeof editCodeSignal>; codeSignalRun?: (url: string) => ReturnType<typeof runCodeSignal>; shareNotionWithOrg?: (id: string) => Promise<string>; scrapeClaude?: () => Promise<string>; listDocComments?: (url: string) => ReturnType<typeof listDocComments>; changeDocComment?: (action: Parameters<typeof changeDocComment>[1], url: string, value?: string) => ReturnType<typeof changeDocComment>; ashby?: (action: string, arg?: string) => Promise<string>; previewDrive?: (url: string) => Promise<string>; scrapeDrive?: (url?: string, deleteVerifiedPdfs?: boolean, deleteVerifiedDocx?: boolean) => Promise<string>; calendarAgenda?: (date?: string, calendarId?: string) => ReturnType<typeof readAgenda>; latticeSync?: (url: string | undefined, file?: string) => Promise<string>; latticeRequests?: (url: string) => Promise<string>; latticeTemplate?: (url: string) => Promise<string>; latticeFill?: (url: string, file: string) => Promise<string>; scrapeZoom?: () => ReturnType<typeof zoomProvider.scrape> }>;
18
19
 
19
20
  const authServices = ["ashby", "asana", "chatgpt", "codesignal", "gmail", "google-docs", "notion", "slack", "zoom"] as const;
20
21
  const removedCliCommandNames = Object.freeze({
@@ -440,6 +441,7 @@ type AsanaExplorer = {
440
441
  tasks(project: string): ReturnType<typeof listAsanaTasks>;
441
442
  show(task: string): Promise<FetchedDocument>;
442
443
  writes?: {
444
+ depend?(task: string, dependency: string): Promise<{ task: string; dependency: string }>;
443
445
  create?(project: string, title: string, section: string, body?: string, assignee?: string): Promise<JsonObject>;
444
446
  move(task: string, project: string, section: string): ReturnType<typeof moveAsanaTask>;
445
447
  edit(task: string, fields: JsonObject): Promise<JsonObject>;
@@ -554,8 +556,52 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
554
556
  return service === "slack" ? `${user["id"]} ${user["real_name"] ?? user["name"]} ${profile?.["email"] ?? ""}` : `${user["userId"]} ${user["name"] ?? ""} ${(user["aliases"] as readonly string[] | undefined ?? []).join(", ")}`;
555
557
  }).join("\n")),
556
558
  })] })];
559
+ if (service === "notion" && options.searchNotion) return defineGroup({ ...group, description: "Search Notion pages, find people, and manage login.", children: [...group.children, ...users, defineCommand({
560
+ name: "search", description: "Search page titles and content with Notion's native matching and ranking. Does not save files.", positional: ["query"],
561
+ params: S.Object({
562
+ query: S.String({ description: "Search text. Use an empty string to search by filters alone." }),
563
+ "created-by": S.Optional(S.Array(S.String(), { description: "Authors: names, exact emails, or Notion user IDs. Repeat for multiple people (OR)." })),
564
+ "edited-by": S.Optional(S.Array(S.String(), { description: "Editors: names, exact emails, or Notion user IDs. Repeat for multiple people (OR)." })),
565
+ "title-only": S.Optional(S.Boolean({ description: "Search page titles only." })),
566
+ in: S.Optional(S.Array(S.String(), { description: "Search within these parent page IDs." })),
567
+ teamspace: S.Optional(S.Array(S.String(), { description: "Filter by Notion teamspace IDs." })),
568
+ "created-after": S.Optional(S.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Creation range start, YYYY-MM-DD." })),
569
+ "created-before": S.Optional(S.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Creation range end, YYYY-MM-DD." })),
570
+ "edited-after": S.Optional(S.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Last-edited range start, YYYY-MM-DD." })),
571
+ "edited-before": S.Optional(S.String({ pattern: "^\\d{4}-\\d{2}-\\d{2}$", description: "Last-edited range end, YYYY-MM-DD." })),
572
+ "content-status": S.Optional(S.Enum(["all_without_archived", "all_with_archived", "verified_only", "archived_only"], { default: "all_without_archived", description: "Notion content status filter." })),
573
+ sort: S.Optional(S.Enum(["relevance", "lastEdited", "created"], { default: "relevance", description: "Notion sort field." })),
574
+ direction: S.Optional(S.Enum(["asc", "desc"], { default: "desc", description: "Date sort order. Ignored for relevance." })),
575
+ limit: S.Optional(S.Number({ jsonType: "integer", minimum: 1, maximum: 100, default: 20, description: "Maximum results per workspace, 1–100." })),
576
+ space: S.Optional(S.String({ description: "Workspace ID. Searches all accessible workspaces when omitted." })),
577
+ }),
578
+ handler: ({ params }) => userFacing(() => {
579
+ const dateRange = (start: string | undefined, end: string | undefined) => ({
580
+ ...(start === undefined ? {} : { starting: { type: "date", start_date: start } }),
581
+ ...(end === undefined ? {} : { ending: { type: "date", start_date: end } }),
582
+ });
583
+ const field = params.sort ?? "relevance";
584
+ return options.searchNotion!(params.query, {
585
+ filters: { createdBy: params["created-by"] ?? [], editedBy: params["edited-by"] ?? [], navigableBlockContentOnly: params["title-only"] ?? false,
586
+ ancestors: params.in ?? [], inTeams: params.teamspace ?? [], contentStatusFilter: params["content-status"] ?? "all_without_archived",
587
+ createdTime: dateRange(params["created-after"], params["created-before"]), lastEditedTime: dateRange(params["edited-after"], params["edited-before"]),
588
+ },
589
+ sort: field === "relevance" ? { field } : { field, direction: params.direction ?? "desc" },
590
+ limit: params.limit ?? 20, ...(params.space === undefined ? {} : { spaceId: params.space }),
591
+ });
592
+ }),
593
+ render: render<Awaited<ReturnType<typeof searchNotion>>>((searches) => searches.map((search) => [
594
+ `Workspace ${search.spaceId}: ${search.results.length} returned (Notion total: ${search.total}${search.total === 100 ? "+" : ""})`,
595
+ ...search.results.map((page) => [
596
+ `- [${lineText(page.title || "Untitled").replace(/[\\\[\]]/g, "\\$&")}](${page.url})`,
597
+ ` Created by ${page.created_by ?? page.created_by_id} · Edited by ${page.last_edited_by ?? page.last_edited_by_id}`,
598
+ ...(page.excerpt === "" ? [] : [` ${lineText(page.excerpt)}`]),
599
+ ].join("\n")),
600
+ ].join("\n\n")).join("\n\n") || "No accessible Notion workspaces"),
601
+ })] });
557
602
  const writes = asana?.writes;
558
603
  const createTask = writes?.create;
604
+ const depend = writes?.depend;
559
605
  if (service === "asana" && asana !== undefined) return defineGroup({ ...group, description: "Browse Asana projects, edit tasks and comments, and manage login.", children: [...group.children, ...users,
560
606
  defineGroup({ name: "projects", description: "Browse projects.", children: [defineCommand({
561
607
  name: "list", description: "List active projects by workspace and team.", params: S.Object({}),
@@ -583,7 +629,12 @@ export function createRoot(wire: Wire, currentDirectory: string, auth?: Auth, re
583
629
  name: "show", description: "Show a task's properties, custom field IDs, Markdown description, comments, and activity.", positional: ["task"],
584
630
  params: S.Object({ task: S.String({ description: "Asana task ID." }) }),
585
631
  handler: ({ params }) => userFacing(() => asana.show(params.task)), render: wirePresentation.view,
586
- }), ...(createTask ? [defineCommand({
632
+ }), ...(depend ? [defineCommand({
633
+ name: "depend", description: "Make a task depend on another task without changing existing dependencies.", positional: ["task"],
634
+ params: S.Object({ task: S.String({ description: "Task that must wait." }), on: S.String({ description: "Task that must finish first." }) }),
635
+ handler: ({ params }) => userFacing(() => depend(params.task, params.on)),
636
+ render: render<{ task: string; dependency: string }>((result) => `Task ${result.task} depends on ${result.dependency}.`),
637
+ })] : []), ...(createTask ? [defineCommand({
587
638
  name: "create", description: "Create a task in a project section. List sections with wire asana projects show <project>.", positional: ["project"],
588
639
  params: S.Object({
589
640
  project: S.String({ description: "Asana project ID." }),
package/src/cli.ts CHANGED
@@ -246,6 +246,7 @@ function excessPositionals(argv: readonly string[]): Readonly<{ commandPath: str
246
246
  const command = words[0]!;
247
247
  if (command in fixedCommandPositionals) return Object.freeze({ commandPath: command, expected: fixedCommandPositionals[command as keyof typeof fixedCommandPositionals].expected, received: words.length - 1 });
248
248
  if (command === "asana" && (words[1] === "projects" || words[1] === "tasks") && (words[2] === "list" || words[2] === "show")) return { commandPath: words.slice(0, 3).join(" "), expected: words[1] === "projects" && words[2] === "list" ? 0 : 1, received: words.length - 3 };
249
+ if (command === "notion" && words[1] === "search") return { commandPath: "notion search", expected: 1, received: words.length - 2 };
249
250
  if (command === "slack" && slackResourceCommands.has(words[1]!)) return { commandPath: `slack ${words[1]}`, expected: 1, received: words.length - 2 };
250
251
  if ((command === "slack" || command === "notion" || command === "asana") && words[1] === "users" && words[2] === "lookup") return { commandPath: `${command} users lookup`, expected: 1, received: words.length - 3 };
251
252
  if (command === "slack" && (words[1] === "send" || words[1] === "edit")) return { commandPath: `slack ${words[1]}`, expected: 2, received: words.length - 2 };
@@ -269,6 +270,7 @@ function missingPositionals(argv: readonly string[]): Readonly<{ commandPath: st
269
270
  const command = words[0]!;
270
271
  if (command === "asana" && words[1] === "projects" && words[2] === "show" && words.length === 3) return { commandPath: words.join(" "), name: "project" };
271
272
  if (command === "asana" && words[1] === "tasks" && (words[2] === "list" || words[2] === "show") && words.length === 3) return { commandPath: words.join(" "), name: words[2] === "list" ? "project" : "task" };
273
+ if (command === "notion" && words[1] === "search" && words.length < 3) return { commandPath: "notion search", name: "query" };
272
274
  if (command === "slack" && slackResourceCommands.has(words[1]!) && words.length < 3) return { commandPath: `slack ${words[1]}`, name: words[1] === "sync" ? "resource" : "url" };
273
275
  if ((command === "slack" || command === "notion" || command === "asana") && words[1] === "users" && words[2] === "lookup" && words.length < 4) return { commandPath: `${command} users lookup`, name: "query" };
274
276
  if (command === "slack" && (words[1] === "send" || words[1] === "edit") && words.length < 4) return { commandPath: `slack ${words[1]}`, name: words.length === 2 ? words[1] === "send" ? "destination" : "url" : "markdown" };
@@ -308,7 +310,7 @@ function renderRemovedCommand(argv: readonly string[]): boolean {
308
310
  function renderUnknownAuthCommand(argv: readonly string[]): boolean {
309
311
  if (hasRootSeparator(argv)) return false;
310
312
  const words = positionalWords(argv);
311
- if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || (words[0] === "ashby" && ["interviews","pending","latest","prep","template","sync"].includes(words[1]!)) || (words[0] === "codesignal" && ["edit", "run"].includes(words[1]!)) || (words[0] === "google-docs" && words[1] === "comments") || (words[0] === "zoom" && words[1] === "scrape") || words[0] === "asana" && (words[1] === "projects" || words[1] === "tasks" || words[1] === "comments") || (words[0] === "slack" || words[0] === "notion" || words[0] === "asana") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
313
+ if (words === null || words.length < 2 || !authServices.has(words[0]!) || authCommands.has(words[1]!) || (words[0] === "ashby" && ["interviews","pending","latest","prep","template","sync"].includes(words[1]!)) || (words[0] === "codesignal" && ["edit", "run"].includes(words[1]!)) || (words[0] === "notion" && words[1] === "search") || (words[0] === "google-docs" && words[1] === "comments") || (words[0] === "zoom" && words[1] === "scrape") || words[0] === "asana" && (words[1] === "projects" || words[1] === "tasks" || words[1] === "comments") || (words[0] === "slack" || words[0] === "notion" || words[0] === "asana") && words[1] === "users" || words[0] === "slack" && (words[1] === "send" || words[1] === "edit" || slackResourceCommands.has(words[1]!))) return false;
312
314
  renderCliError(argv, `Unknown command: ${words[1]}`, `wire ${words[0]} --help`, `Unknown command: ${cliValue(words[1]!)}`);
313
315
  return true;
314
316
  }
package/src/executable.ts CHANGED
@@ -2,12 +2,12 @@ import { existsSync, readFileSync, statSync } from "node:fs";
2
2
  import { mkdir, writeFile } from "node:fs/promises";
3
3
  import { dirname, isAbsolute, join, resolve } from "node:path";
4
4
 
5
- import { addAsanaComment, createAsanaTask, editAsanaComment, editAsanaTask, listAsanaProjects, listAsanaTasks, lookupAsanaUsers, moveAsanaTask, showAsanaProject, showAsanaTask } from "provider-asana";
5
+ import { addAsanaComment, addAsanaDependency, createAsanaTask, editAsanaComment, editAsanaTask, listAsanaProjects, listAsanaTasks, lookupAsanaUsers, moveAsanaTask, showAsanaProject, showAsanaTask } from "provider-asana";
6
6
  import { sendSlackMessage, editSlackMessage, lookupSlackUsers } from "provider-slack";
7
7
 
8
8
  import { listLatticeReviewRequests, latticeReviewDraft, syncLatticeDrafts } from "provider-lattice";
9
9
  import { zoomProvider } from "provider-zoom";
10
- import { lookupNotionUsers, shareNotionWithOrg } from "provider-notion";
10
+ import { lookupNotionUsers, searchNotion, shareNotionWithOrg } from "provider-notion";
11
11
 
12
12
  import { changeDocComment, listDocComments } from "./adapters/doc-comments.js";
13
13
  import { previewDrive, scrapeDrive } from "./adapters/gdrive.js";
@@ -150,9 +150,9 @@ export function createExecutableRoot(environment: NodeEnvironment, currentDirect
150
150
  switchBackend: baseWire.switchBackend,
151
151
  });
152
152
  const wire = withWireHooks(configuredWire, { currentDirectory, home, environment: configuredEnvironment() });
153
- return createRoot(wire, currentDirectory, auth, readStandardInput, { ...options, codeSignalEdit: async (url,path,file) => editCodeSignal(runtime,url,path,await filesystem.readText(resolve(currentDirectory,file))), codeSignalRun: url => runCodeSignal(runtime,url), shareNotionWithOrg: id => shareNotionWithOrg(runtime, id), scrapeClaude: () => scrapeClaude(processCapability, currentDirectory), listDocComments: url => listDocComments(runtime,url), changeDocComment: (action,url,value) => changeDocComment(runtime,action,url,value), ashby: (action,arg) => ashby(runtime,action,action === "sync" ? resolve(currentDirectory,arg!) : arg), previewDrive: url => previewDrive(runtime,url), scrapeDrive: (url, deleteVerifiedPdfs, deleteVerifiedDocx) => scrapeDrive(runtime, currentDirectory, url, deleteVerifiedPdfs, deleteVerifiedDocx), calendarAgenda: (date, id) => readAgenda(processCapability, configuration.get("WIRE_REPOSITORY_ROOT"), date, id), latticeSync: (url,file) => syncLatticeDrafts(runtime,url,currentDirectory,file), latticeRequests: url => listLatticeReviewRequests(runtime,url), latticeTemplate: url => latticeReviewDraft(runtime,url), latticeFill: async (url,file) => latticeReviewDraft(runtime,url,await runtime.filesystem.readText(resolve(currentDirectory,file))), scrapeZoom: () => zoomProvider.scrape(runtime, currentDirectory) }, (destination, markdown) => sendSlackMessage(runtime, destination, markdown), (query) => lookupSlackUsers(runtime, query), (url, markdown) => editSlackMessage(runtime, url, markdown), (query) => lookupNotionUsers(runtime, query), {
153
+ return createRoot(wire, currentDirectory, auth, readStandardInput, { ...options, searchNotion: (query, searchOptions) => searchNotion(runtime, query, searchOptions), codeSignalEdit: async (url,path,file) => editCodeSignal(runtime,url,path,await filesystem.readText(resolve(currentDirectory,file))), codeSignalRun: url => runCodeSignal(runtime,url), shareNotionWithOrg: id => shareNotionWithOrg(runtime, id), scrapeClaude: () => scrapeClaude(processCapability, currentDirectory), listDocComments: url => listDocComments(runtime,url), changeDocComment: (action,url,value) => changeDocComment(runtime,action,url,value), ashby: (action,arg) => ashby(runtime,action,action === "sync" ? resolve(currentDirectory,arg!) : arg), previewDrive: url => previewDrive(runtime,url), scrapeDrive: (url, deleteVerifiedPdfs, deleteVerifiedDocx) => scrapeDrive(runtime, currentDirectory, url, deleteVerifiedPdfs, deleteVerifiedDocx), calendarAgenda: (date, id) => readAgenda(processCapability, configuration.get("WIRE_REPOSITORY_ROOT"), date, id), latticeSync: (url,file) => syncLatticeDrafts(runtime,url,currentDirectory,file), latticeRequests: url => listLatticeReviewRequests(runtime,url), latticeTemplate: url => latticeReviewDraft(runtime,url), latticeFill: async (url,file) => latticeReviewDraft(runtime,url,await runtime.filesystem.readText(resolve(currentDirectory,file))), scrapeZoom: () => zoomProvider.scrape(runtime, currentDirectory) }, (destination, markdown) => sendSlackMessage(runtime, destination, markdown), (query) => lookupSlackUsers(runtime, query), (url, markdown) => editSlackMessage(runtime, url, markdown), (query) => lookupNotionUsers(runtime, query), {
154
154
  lookup: (query) => lookupAsanaUsers(runtime, query), projects: () => listAsanaProjects(runtime), project: (project) => showAsanaProject(runtime, project), tasks: (project) => listAsanaTasks(runtime, project), show: (task) => showAsanaTask(runtime, task),
155
- writes: { move: (task, project, section) => moveAsanaTask(runtime, task, project, section), create: (project, title, section, body, assignee) => createAsanaTask(runtime, project, title, section, body, assignee), edit: (task, fields) => editAsanaTask(runtime, task, fields), comment: (task, body) => addAsanaComment(runtime, task, body), editComment: (comment, body) => editAsanaComment(runtime, comment, body) },
155
+ writes: { depend: (task, dependency) => addAsanaDependency(runtime, task, dependency), move: (task, project, section) => moveAsanaTask(runtime, task, project, section), create: (project, title, section, body, assignee) => createAsanaTask(runtime, project, title, section, body, assignee), edit: (task, fields) => editAsanaTask(runtime, task, fields), comment: (task, body) => addAsanaComment(runtime, task, body), editComment: (comment, body) => editAsanaComment(runtime, comment, body) },
156
156
  }, async () => {
157
157
  const domains = new Set((await runtime.cookies.load("latticehq")).map(c => c.domain.replace(/^\./,"")).filter(d => /^[a-z0-9-]+\.latticehq\.com$/.test(d)));
158
158
  if (domains.size !== 1) throw new Error("Use wire download with your Lattice workspace URL.");