@introspection-ai/recipes 0.49.0 → 0.50.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.
Files changed (124) hide show
  1. package/dist/api/mcp.d.ts +1 -0
  2. package/dist/api/mcp.d.ts.map +1 -1
  3. package/dist/api/mcp.js +1 -0
  4. package/dist/api/mcp.js.map +1 -1
  5. package/dist/channels/tools.d.ts.map +1 -1
  6. package/dist/channels/tools.js +2 -17
  7. package/dist/channels/tools.js.map +1 -1
  8. package/dist/command-parameters.d.ts +10 -0
  9. package/dist/command-parameters.d.ts.map +1 -0
  10. package/dist/command-parameters.js +25 -0
  11. package/dist/command-parameters.js.map +1 -0
  12. package/dist/connector-tools.d.ts +1 -1
  13. package/dist/connector-tools.d.ts.map +1 -1
  14. package/dist/connector-tools.js +12 -1
  15. package/dist/connector-tools.js.map +1 -1
  16. package/dist/documents/module.js +1 -1
  17. package/dist/documents/module.js.map +1 -1
  18. package/dist/documents/profile.d.ts +1 -1
  19. package/dist/documents/profile.js +1 -1
  20. package/dist/extensions.d.ts +1 -1
  21. package/dist/extensions.d.ts.map +1 -1
  22. package/dist/extensions.js +23 -2
  23. package/dist/extensions.js.map +1 -1
  24. package/dist/introspection-open.d.ts +46 -0
  25. package/dist/introspection-open.d.ts.map +1 -0
  26. package/dist/introspection-open.js +278 -0
  27. package/dist/introspection-open.js.map +1 -0
  28. package/dist/mcp/index.d.ts +37 -0
  29. package/dist/mcp/index.d.ts.map +1 -1
  30. package/dist/mcp/index.js +14 -4
  31. package/dist/mcp/index.js.map +1 -1
  32. package/dist/mcp/pi-client.d.ts +97 -0
  33. package/dist/mcp/pi-client.d.ts.map +1 -0
  34. package/dist/mcp/pi-client.js +342 -0
  35. package/dist/mcp/pi-client.js.map +1 -0
  36. package/dist/mcp/policy.d.ts +2 -0
  37. package/dist/mcp/policy.d.ts.map +1 -1
  38. package/dist/mcp/policy.js +6 -0
  39. package/dist/mcp/policy.js.map +1 -1
  40. package/dist/mcp-chunks/{chunk-3M4OCQR5.js → chunk-PO2SOBEN.js} +1 -0
  41. package/dist/mcp-daemon.js +1 -1
  42. package/dist/mcp-run-worker.js +1 -1
  43. package/dist/open.d.ts +82 -0
  44. package/dist/open.d.ts.map +1 -0
  45. package/dist/open.js +152 -0
  46. package/dist/open.js.map +1 -0
  47. package/dist/pi-extension.d.ts.map +1 -1
  48. package/dist/pi-extension.js +99 -8
  49. package/dist/pi-extension.js.map +1 -1
  50. package/dist/productivity/content.d.ts +25 -0
  51. package/dist/productivity/content.d.ts.map +1 -0
  52. package/dist/productivity/content.js +94 -0
  53. package/dist/productivity/content.js.map +1 -0
  54. package/dist/productivity/handles.d.ts +72 -0
  55. package/dist/productivity/handles.d.ts.map +1 -0
  56. package/dist/productivity/handles.js +111 -0
  57. package/dist/productivity/handles.js.map +1 -0
  58. package/dist/productivity/http.d.ts +35 -0
  59. package/dist/productivity/http.d.ts.map +1 -0
  60. package/dist/productivity/http.js +216 -0
  61. package/dist/productivity/http.js.map +1 -0
  62. package/dist/productivity/index.d.ts +11 -0
  63. package/dist/productivity/index.d.ts.map +1 -0
  64. package/dist/productivity/index.js +7 -0
  65. package/dist/productivity/index.js.map +1 -0
  66. package/dist/productivity/module.d.ts +63 -0
  67. package/dist/productivity/module.d.ts.map +1 -0
  68. package/dist/productivity/module.js +121 -0
  69. package/dist/productivity/module.js.map +1 -0
  70. package/dist/productivity/paging.d.ts +32 -0
  71. package/dist/productivity/paging.d.ts.map +1 -0
  72. package/dist/productivity/paging.js +42 -0
  73. package/dist/productivity/paging.js.map +1 -0
  74. package/dist/productivity/tools.d.ts +40 -0
  75. package/dist/productivity/tools.d.ts.map +1 -0
  76. package/dist/productivity/tools.js +969 -0
  77. package/dist/productivity/tools.js.map +1 -0
  78. package/dist/productivity/types.d.ts +538 -0
  79. package/dist/productivity/types.d.ts.map +1 -0
  80. package/dist/productivity/types.js +119 -0
  81. package/dist/productivity/types.js.map +1 -0
  82. package/dist/recipe/agent.d.ts +6 -1
  83. package/dist/recipe/agent.d.ts.map +1 -1
  84. package/dist/recipe/agent.js +48 -7
  85. package/dist/recipe/agent.js.map +1 -1
  86. package/dist/recipe/companions.d.ts.map +1 -1
  87. package/dist/recipe/companions.js +5 -4
  88. package/dist/recipe/companions.js.map +1 -1
  89. package/dist/recipe/manifest.generated.d.ts +3 -1
  90. package/dist/recipe/manifest.generated.d.ts.map +1 -1
  91. package/dist/recipe/manifest.generated.js +4 -2
  92. package/dist/recipe/manifest.generated.js.map +1 -1
  93. package/dist/recipe/package.d.ts +12 -0
  94. package/dist/recipe/package.d.ts.map +1 -1
  95. package/dist/recipe/package.js +93 -0
  96. package/dist/recipe/package.js.map +1 -1
  97. package/dist/review.d.ts +1 -0
  98. package/dist/review.d.ts.map +1 -1
  99. package/dist/review.js +1 -0
  100. package/dist/review.js.map +1 -1
  101. package/dist/session.d.ts.map +1 -1
  102. package/dist/session.js +175 -15
  103. package/dist/session.js.map +1 -1
  104. package/dist/skill-progress.d.ts.map +1 -1
  105. package/dist/skill-progress.js +5 -1
  106. package/dist/skill-progress.js.map +1 -1
  107. package/dist/tool-search.d.ts +2 -2
  108. package/dist/tool-search.d.ts.map +1 -1
  109. package/dist/tool-search.js +4 -2
  110. package/dist/tool-search.js.map +1 -1
  111. package/docs/{index.md → README.md} +9 -3
  112. package/docs/{slack.md → channels/slack.md} +1 -1
  113. package/docs/{documents.md → documents/README.md} +4 -4
  114. package/docs/interactions.md +90 -31
  115. package/docs/mcp-configuration.md +76 -2
  116. package/docs/productivity/README.md +360 -0
  117. package/docs/productivity/google.md +226 -0
  118. package/docs/productivity/microsoft.md +143 -0
  119. package/docs/recipe-format.md +24 -3
  120. package/package.json +14 -8
  121. package/skills/README.md +12 -0
  122. package/skills/productivity/SKILL.md +76 -0
  123. /package/docs/{channels.md → channels/README.md} +0 -0
  124. /package/{documents → skills/documents}/SKILL.md +0 -0
@@ -0,0 +1,63 @@
1
+ import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
2
+ import { type RecipePackageProductivity } from "../recipe/package.js";
3
+ import { type ProductivityCapabilities, type ProductivityFetch, type ProductivitySession, type ProductivitySessionOptions } from "./types.js";
4
+ /**
5
+ * The productivity contract this host implements. A provider module declares
6
+ * the version it was written against, and the host refuses one that differs;
7
+ * bump it on any breaking change to `RecipeProductivityModule` or the session
8
+ * interfaces in `types.ts`.
9
+ */
10
+ export declare const PRODUCTIVITY_MODULE_API_VERSION: 1;
11
+ /**
12
+ * What a provider package exports as its default: a plain descriptor. The host
13
+ * builds the `mail`, `calendar` and `drive` tools from `capabilities` and calls
14
+ * `createSession` for one person's connection, so a provider package needs no
15
+ * run-time import of `@introspection-ai/recipes`, only its types.
16
+ */
17
+ export interface RecipeProductivityModule {
18
+ readonly kind: "productivity";
19
+ /** The contract version, `PRODUCTIVITY_MODULE_API_VERSION` when written. */
20
+ readonly apiVersion: typeof PRODUCTIVITY_MODULE_API_VERSION;
21
+ /** Served as `@introspection-ai/recipe-productivity-<provider>`. */
22
+ readonly provider: string;
23
+ /** Static, so the loader can build the tools before any session exists. */
24
+ readonly capabilities: ProductivityCapabilities;
25
+ /**
26
+ * The transport for one person's connection. Called once per run, on the
27
+ * first command, so a run that never uses the tools never needs a
28
+ * connection.
29
+ */
30
+ createSession(options: ProductivitySessionOptions): ProductivitySession | Promise<ProductivitySession>;
31
+ }
32
+ /** The core `productivity` skill, offered to every agent that selects `mail`, `calendar` or `drive`. It ships beside `dist/`. */
33
+ export declare const PRODUCTIVITY_SKILL: string;
34
+ /** Where fetched attachments and downloads go: the runtime files folder, else `files/` in the workspace. */
35
+ export declare function productivityDownloadRoot(provider: string, env: NodeJS.ProcessEnv, cwd: string): string;
36
+ export interface LoadedRecipeProductivity {
37
+ extension?: {
38
+ owner: string;
39
+ factory: ExtensionFactory;
40
+ };
41
+ toolNames: string[];
42
+ /** The core `productivity` skill, when the agent selects one of the tools. */
43
+ skillPaths?: string[];
44
+ }
45
+ /**
46
+ * Load the Recipe's `pi.productivity` provider and, for the tools the agent
47
+ * selects, one extension registering them for one person's connection and
48
+ * offering the core `productivity` skill.
49
+ *
50
+ * One provider per Recipe. The declaration's per-tool allowlists narrow what
51
+ * the provider supports; an unknown or unsupported command fails here, and an
52
+ * agent selecting a tool the declaration does not enable fails too.
53
+ */
54
+ export declare function loadRecipeProductivity(declarations: readonly RecipePackageProductivity[], agentTools: readonly string[], options: {
55
+ recipeDir: string;
56
+ env?: NodeJS.ProcessEnv;
57
+ cwd?: string;
58
+ /** Where companion packages resolve from. Default: where `@introspection-ai/recipes` is installed. */
59
+ hostDir?: string;
60
+ /** The `fetch` providers use; a host attaching credentials with a request hook passes its own. */
61
+ fetch?: ProductivityFetch;
62
+ }): Promise<LoadedRecipeProductivity>;
63
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/productivity/module.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,OAAO,EAEL,KAAK,yBAAyB,EAC/B,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAGL,KAAK,wBAAwB,EAE7B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAEhC,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,EAAG,CAAU,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,EAAE,OAAO,+BAA+B,CAAC;IAC5D,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,YAAY,EAAE,wBAAwB,CAAC;IAChD;;;;OAIG;IACH,aAAa,CACX,OAAO,EAAE,0BAA0B,GAClC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACvD;AAED,iIAAiI;AACjI,eAAO,MAAM,kBAAkB,QAE9B,CAAC;AAEF,4GAA4G;AAC5G,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,GAAG,EAAE,MAAM,GACV,MAAM,CAGR;AA0BD,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,gBAAgB,CAAA;KAAE,CAAC;IACzD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,SAAS,yBAAyB,EAAE,EAClD,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,OAAO,EAAE;IACP,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,sGAAsG;IACtG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kGAAkG;IAClG,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B,GACA,OAAO,CAAC,wBAAwB,CAAC,CAgGnC"}
@@ -0,0 +1,121 @@
1
+ import { resolve } from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { loadRecipePackageModule } from "../recipe/companions.js";
4
+ import { recipeProductivityPackageName, } from "../recipe/package.js";
5
+ import { createProductivityHttp } from "./http.js";
6
+ import { productivityCapabilitiesProblem, productivityCommandsFor, registerProductivityTools, } from "./tools.js";
7
+ import { PRODUCTIVITY_COMMANDS, PRODUCTIVITY_TOOLS, } from "./types.js";
8
+ /**
9
+ * The productivity contract this host implements. A provider module declares
10
+ * the version it was written against, and the host refuses one that differs;
11
+ * bump it on any breaking change to `RecipeProductivityModule` or the session
12
+ * interfaces in `types.ts`.
13
+ */
14
+ export const PRODUCTIVITY_MODULE_API_VERSION = 1;
15
+ /** The core `productivity` skill, offered to every agent that selects `mail`, `calendar` or `drive`. It ships beside `dist/`. */
16
+ export const PRODUCTIVITY_SKILL = fileURLToPath(new URL("../../skills/productivity/SKILL.md", import.meta.url));
17
+ /** Where fetched attachments and downloads go: the runtime files folder, else `files/` in the workspace. */
18
+ export function productivityDownloadRoot(provider, env, cwd) {
19
+ const runtimeFiles = env.INTROSPECTION_RUNTIME_FILES_DIR?.trim();
20
+ return resolve(runtimeFiles || resolve(cwd, "files"), provider);
21
+ }
22
+ function parseProductivityModule(value, declaration) {
23
+ const packageName = recipeProductivityPackageName(declaration.provider);
24
+ const module = (value && typeof value === "object" && "default" in value
25
+ ? value.default
26
+ : value);
27
+ const problem = !module ||
28
+ module.kind !== "productivity" ||
29
+ module.provider !== declaration.provider ||
30
+ typeof module.createSession !== "function"
31
+ ? "has an invalid module contract"
32
+ : productivityCapabilitiesProblem(module.capabilities);
33
+ if (problem)
34
+ throw new Error(`Recipe productivity package ${packageName} ${problem.startsWith("has") ? problem : `has an invalid descriptor: ${problem}`}`);
35
+ return module;
36
+ }
37
+ /**
38
+ * Load the Recipe's `pi.productivity` provider and, for the tools the agent
39
+ * selects, one extension registering them for one person's connection and
40
+ * offering the core `productivity` skill.
41
+ *
42
+ * One provider per Recipe. The declaration's per-tool allowlists narrow what
43
+ * the provider supports; an unknown or unsupported command fails here, and an
44
+ * agent selecting a tool the declaration does not enable fails too.
45
+ */
46
+ export async function loadRecipeProductivity(declarations, agentTools, options) {
47
+ if (declarations.length === 0)
48
+ return { toolNames: [] };
49
+ if (declarations.length > 1)
50
+ throw new Error(`A Recipe declares one productivity provider; pi.productivity names ${declarations
51
+ .map((declaration) => `'${declaration.provider}'`)
52
+ .join(" and ")}`);
53
+ const declaration = declarations[0];
54
+ const imported = await loadRecipePackageModule(options.recipeDir, recipeProductivityPackageName(declaration.provider), {
55
+ what: `Recipe productivity provider '${declaration.provider}'`,
56
+ api: {
57
+ name: "productivity module",
58
+ version: PRODUCTIVITY_MODULE_API_VERSION,
59
+ },
60
+ ...(options.hostDir !== undefined ? { hostDir: options.hostDir } : {}),
61
+ });
62
+ const module = parseProductivityModule(imported, declaration);
63
+ const enabled = {};
64
+ for (const tool of Object.keys(declaration.tools ?? {})) {
65
+ if (!PRODUCTIVITY_TOOLS.includes(tool))
66
+ throw new Error(`Unknown productivity tool in pi.productivity: ${tool}`);
67
+ }
68
+ for (const tool of PRODUCTIVITY_TOOLS) {
69
+ const supported = productivityCommandsFor(module.capabilities, tool);
70
+ const allowed = declaration.tools?.[tool];
71
+ for (const command of allowed ?? []) {
72
+ if (!PRODUCTIVITY_COMMANDS[tool].includes(command))
73
+ throw new Error(`Unknown ${tool} command in pi.productivity allowlist: ${command}`);
74
+ if (!supported.includes(command))
75
+ throw new Error(`Productivity provider '${declaration.provider}' does not support ${tool} ${command}`);
76
+ }
77
+ const commands = allowed === undefined
78
+ ? supported
79
+ : supported.filter((command) => allowed.includes(command));
80
+ if (commands.length > 0)
81
+ enabled[tool] = commands;
82
+ }
83
+ const selected = PRODUCTIVITY_TOOLS.filter((tool) => agentTools.includes(tool));
84
+ const disabled = selected.filter((tool) => !enabled[tool]);
85
+ if (disabled.length > 0)
86
+ throw new Error(`The agent selects ${disabled.join(", ")}, which pi.productivity provider '${declaration.provider}' does not enable`);
87
+ if (selected.length === 0)
88
+ return { toolNames: [] };
89
+ const skillPaths = [PRODUCTIVITY_SKILL];
90
+ const tools = Object.fromEntries(selected.map((tool) => [tool, enabled[tool]]));
91
+ return {
92
+ toolNames: [...selected],
93
+ skillPaths,
94
+ extension: {
95
+ owner: `<productivity:${declaration.provider}>`,
96
+ factory: (pi) => {
97
+ const env = options.env ?? process.env;
98
+ const cwd = options.cwd ?? process.cwd();
99
+ registerProductivityTools(pi, {
100
+ provider: declaration.provider,
101
+ capabilities: module.capabilities,
102
+ tools,
103
+ cwd,
104
+ downloadsDir: productivityDownloadRoot(declaration.provider, env, cwd),
105
+ session: () => module.createSession({
106
+ config: { provider: declaration.provider, tools: enabled },
107
+ env,
108
+ cwd,
109
+ http: createProductivityHttp({
110
+ provider: declaration.provider,
111
+ env,
112
+ ...(options.fetch ? { fetch: options.fetch } : {}),
113
+ }),
114
+ }),
115
+ });
116
+ pi.on("resources_discover", () => ({ skillPaths }));
117
+ },
118
+ },
119
+ };
120
+ }
121
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/productivity/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EACL,6BAA6B,GAE9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,GAE1B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,kBAAkB,GAOnB,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAU,CAAC;AA0B1D,iIAAiI;AACjI,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAC7C,IAAI,GAAG,CAAC,oCAAoC,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAC/D,CAAC;AAEF,4GAA4G;AAC5G,MAAM,UAAU,wBAAwB,CACtC,QAAgB,EAChB,GAAsB,EACtB,GAAW;IAEX,MAAM,YAAY,GAAG,GAAG,CAAC,+BAA+B,EAAE,IAAI,EAAE,CAAC;IACjE,OAAO,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,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AAK,EAAE,iBAAiB,WAAW,CAAC,QAAQ,GAAG;YAC/C,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE;gBACd,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;gBACvC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;gBACzC,yBAAyB,CAAC,EAAE,EAAE;oBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;oBAC9B,YAAY,EAAE,MAAM,CAAC,YAAY;oBACjC,KAAK;oBACL,GAAG;oBACH,YAAY,EAAE,wBAAwB,CACpC,WAAW,CAAC,QAAQ,EACpB,GAAG,EACH,GAAG,CACJ;oBACD,OAAO,EAAE,GAAG,EAAE,CACZ,MAAM,CAAC,aAAa,CAAC;wBACnB,MAAM,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE;wBAC1D,GAAG;wBACH,GAAG;wBACH,IAAI,EAAE,sBAAsB,CAAC;4BAC3B,QAAQ,EAAE,WAAW,CAAC,QAAQ;4BAC9B,GAAG;4BACH,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;yBACnD,CAAC;qBACH,CAAC;iBACL,CAAC,CAAC;gBACH,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;YACtD,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { ProductivityHandleStore } from "./handles.js";
2
+ /** What a provider returned for one page: possibly more items than asked for. */
3
+ export interface ProviderPage<T> {
4
+ readonly items: readonly T[];
5
+ readonly cursor?: string;
6
+ }
7
+ /** At most `limit` items, and a cursor handle when more remain. */
8
+ export interface HostPage<T> {
9
+ readonly items: T[];
10
+ readonly cursor?: string;
11
+ }
12
+ /**
13
+ * One page of a listing for the model, never longer than `limit`.
14
+ *
15
+ * A provider may return more items than it was asked for (a provider page it
16
+ * cannot cut, a server that ignores the page size). The items past `limit`
17
+ * are kept in the cursor handle beside the provider's own cursor, and the next
18
+ * call with that handle serves them first, so nothing a provider returned is
19
+ * skipped and the provider's cursor only ever resumes after the last item it
20
+ * returned. A provider that filters its own pages may return fewer items
21
+ * than asked for with a cursor; the page is filled from the next call, up to
22
+ * `MAX_FETCHES_PER_PAGE` calls, so a short page still means more may follow
23
+ * only when it carries a cursor.
24
+ */
25
+ export declare function collectPage<T>(handles: ProductivityHandleStore, scope: string, request: {
26
+ readonly limit: number;
27
+ readonly cursor?: string;
28
+ }, fetch: (page: {
29
+ limit: number;
30
+ cursor?: string;
31
+ }) => Promise<ProviderPage<T>>): Promise<HostPage<T>>;
32
+ //# sourceMappingURL=paging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paging.d.ts","sourceRoot":"","sources":["../../src/productivity/paging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAK5D,iFAAiF;AACjF,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,mEAAmE;AACnE,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EAC7D,KAAK,EAAE,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAC5E,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAiCtB"}
@@ -0,0 +1,42 @@
1
+ /** Provider calls one page may make, when a provider filters its pages short. */
2
+ const MAX_FETCHES_PER_PAGE = 5;
3
+ /**
4
+ * One page of a listing for the model, never longer than `limit`.
5
+ *
6
+ * A provider may return more items than it was asked for (a provider page it
7
+ * cannot cut, a server that ignores the page size). The items past `limit`
8
+ * are kept in the cursor handle beside the provider's own cursor, and the next
9
+ * call with that handle serves them first, so nothing a provider returned is
10
+ * skipped and the provider's cursor only ever resumes after the last item it
11
+ * returned. A provider that filters its own pages may return fewer items
12
+ * than asked for with a cursor; the page is filled from the next call, up to
13
+ * `MAX_FETCHES_PER_PAGE` calls, so a short page still means more may follow
14
+ * only when it carries a cursor.
15
+ */
16
+ export async function collectPage(handles, scope, request, fetch) {
17
+ const resumed = request.cursor !== undefined
18
+ ? handles.resolveCursor(request.cursor, scope)
19
+ : undefined;
20
+ const items = [...(resumed?.overflow ?? [])];
21
+ let cursor = resumed?.value;
22
+ let more = !resumed || cursor !== undefined;
23
+ for (let fetches = 0; more && items.length < request.limit && fetches < MAX_FETCHES_PER_PAGE; fetches += 1) {
24
+ const page = await fetch({
25
+ limit: request.limit - items.length,
26
+ ...(cursor !== undefined ? { cursor } : {}),
27
+ });
28
+ items.push(...page.items);
29
+ cursor = page.cursor || undefined;
30
+ more = cursor !== undefined;
31
+ }
32
+ const overflow = items.splice(request.limit);
33
+ return {
34
+ items,
35
+ ...(cursor !== undefined || overflow.length > 0
36
+ ? {
37
+ cursor: handles.cursor({ ...(cursor !== undefined ? { value: cursor } : {}), overflow }, scope),
38
+ }
39
+ : {}),
40
+ };
41
+ }
42
+ //# sourceMappingURL=paging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paging.js","sourceRoot":"","sources":["../../src/productivity/paging.ts"],"names":[],"mappings":"AAEA,iFAAiF;AACjF,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAc/B;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAgC,EAChC,KAAa,EACb,OAA6D,EAC7D,KAA6E;IAE7E,MAAM,OAAO,GACX,OAAO,CAAC,MAAM,KAAK,SAAS;QAC1B,CAAC,CAAC,OAAO,CAAC,aAAa,CAAI,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC;QACjD,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,KAAK,GAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC;IAClD,IAAI,MAAM,GAAG,OAAO,EAAE,KAAK,CAAC;IAC5B,IAAI,IAAI,GAAG,CAAC,OAAO,IAAI,MAAM,KAAK,SAAS,CAAC;IAC5C,KACE,IAAI,OAAO,GAAG,CAAC,EACf,IAAI,IAAI,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,GAAG,oBAAoB,EACtE,OAAO,IAAI,CAAC,EACZ,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC;YACvB,KAAK,EAAE,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM;YACnC,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5C,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,SAAS,CAAC;QAClC,IAAI,GAAG,MAAM,KAAK,SAAS,CAAC;IAC9B,CAAC;IACD,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7C,OAAO;QACL,KAAK;QACL,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;YAC7C,CAAC,CAAC;gBACE,MAAM,EAAE,OAAO,CAAC,MAAM,CACpB,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,EAChE,KAAK,CACN;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import { ProductivityHandleStore } from "./handles.js";
3
+ import type { ProductivityCapabilities, ProductivityCommand, ProductivitySession, ProductivityTool } from "./types.js";
4
+ /** The largest file `fetch_attachment`, `download` and `upload` move. */
5
+ export declare const PRODUCTIVITY_FILE_LIMIT_BYTES: number;
6
+ /** The commands a provider's descriptor supports for one tool, in vocabulary order. */
7
+ export declare function productivityCommandsFor<T extends ProductivityTool>(capabilities: ProductivityCapabilities, tool: T): ProductivityCommand<T>[];
8
+ /**
9
+ * Why a descriptor is invalid, or undefined. Every command's effect must be
10
+ * its fixed effect, and every backend `mcp` or `rest`.
11
+ */
12
+ export declare function productivityCapabilitiesProblem(capabilities: unknown): string | undefined;
13
+ /** Host surface used here. Opaque so Pi's TypeBox copy stays behind this seam. */
14
+ export interface ProductivityToolHost {
15
+ registerTool(...args: never[]): unknown;
16
+ on: ExtensionAPI["on"];
17
+ }
18
+ export interface RegisterProductivityToolsOptions {
19
+ provider: string;
20
+ capabilities: ProductivityCapabilities;
21
+ /** The tools to register, each with the commands it exposes (supported and allowed). */
22
+ tools: Partial<{
23
+ [T in ProductivityTool]: readonly ProductivityCommand<T>[];
24
+ }>;
25
+ /** One person's connection, created on the first command. */
26
+ session: () => ProductivitySession | Promise<ProductivitySession>;
27
+ /** The task workspace: `drive upload` reads only under its `outputs/`. */
28
+ cwd: string;
29
+ /** Where fetched attachments and downloads are written. */
30
+ downloadsDir: string;
31
+ handles?: ProductivityHandleStore;
32
+ }
33
+ /**
34
+ * Register `mail`, `calendar` and `drive` for ONE person's connection. Each
35
+ * tool has a `command` discriminator whose schema holds only the commands
36
+ * the provider supports and the Recipe allows; every item is addressed by a
37
+ * handle this session minted.
38
+ */
39
+ export declare function registerProductivityTools(pi: ProductivityToolHost, options: RegisterProductivityToolsOptions): void;
40
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/productivity/tools.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAWpE,OAAO,EAEL,uBAAuB,EAExB,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAiBV,wBAAwB,EACxB,mBAAmB,EAKnB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,yEAAyE;AACzE,eAAO,MAAM,6BAA6B,QAAoB,CAAC;AAK/D,uFAAuF;AACvF,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,EAChE,YAAY,EAAE,wBAAwB,EACtC,IAAI,EAAE,CAAC,GACN,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAM1B;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAC7C,YAAY,EAAE,OAAO,GACpB,MAAM,GAAG,SAAS,CAwCpB;AAED,kFAAkF;AAClF,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IACxC,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,EAAE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