@pptb/types 1.2.4-beta.5 → 1.2.4

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
@@ -21,6 +21,7 @@ TypeScript type definitions for Power Platform ToolBox APIs, plus a built-in CLI
21
21
  - [Inter-Tool Invocation](#inter-tool-invocation)
22
22
  - [Caller: launching another tool with prefill data](#caller-launching-another-tool-with-prefill-data)
23
23
  - [Caller: tag-based capability discovery](#caller-tag-based-capability-discovery)
24
+ - [Caller: tag-based capability discovery](#caller-tag-based-capability-discovery-1)
24
25
  - [Callee: reading prefill data and returning a result](#callee-reading-prefill-data-and-returning-a-result)
25
26
  - [Declaring your invocation contract](#declaring-your-invocation-contract)
26
27
  - [Dataverse API Examples](#dataverse-api-examples)
@@ -128,21 +129,26 @@ The validator checks every field that the official review pipeline inspects:
128
129
 
129
130
  In addition to `package.json`, the validator automatically checks a `pptb.config.json` file if one is present in the same directory. This file declares tool-to-tool communication contracts and other PPTB-specific metadata.
130
131
 
131
- | Field | Required | Rules |
132
- | ----------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
133
- | `invocation.version` | ✅\*\* | Must be a valid **semantic version** string (e.g. `"1.0.0"`). Tool developers own this version and bump it when the invocation contract changes. |
134
- | `invocation.capabilities` | ❌ | Array of non-empty string tags (e.g. `["entity-picker"]`). Used by callers to discover this tool via `findToolsByCapability`. |
135
- | `invocation.prefill` | ❌ | JSON-schema-style object describing data callers can pre-populate |
136
- | `invocation.prefill.properties` | ❌ | Map of property names to `{ type?, enum?, items? }` descriptors |
137
- | `invocation.returnTopic` | ❌ | JSON-schema-style object describing the data this tool returns to its caller |
138
- | `invocation.returnTopic.properties` | ❌ | Map of property names to `{ type?, enum?, items? }` descriptors |
132
+ | Field | Required | Rules |
133
+ | ----------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
134
+ | `invocation.version` | ✅\*\* | Must be a valid **semantic version** string (e.g. `"1.0.0"`). Tool developers own this version and bump it when the invocation contract changes. |
135
+ | `invocation.capabilities` | ❌ | Array of non-empty string tags (e.g. `["entity-picker"]`). Used by callers to discover this tool via `findToolsByCapability`. |
136
+ | `invocation.prefill` | ❌ | JSON-schema-style object describing data callers can pre-populate |
137
+ | `invocation.prefill.properties` | ❌ | Map of property names to `{ type?, enum?, items? }` descriptors |
138
+ | `invocation.returnTopic` | ❌ | JSON-schema-style object describing the data this tool returns to its caller |
139
+ | `invocation.returnTopic.properties` | ❌ | Map of property names to `{ type?, enum?, items? }` descriptors |
140
+ | `agents` | ❌ | Top-level agent contract for external automation; when present, must include `version` and may include `invokable`, `modes`, `defaultMode`, and `timeoutMS` |
141
+ | `agents.version` | ✅ | Must be a valid semantic version string (e.g. `1.0.0`) |
142
+ | `agents.invokable` | ❌ | Boolean indicating whether an external (non-PPTB) automation agent may launch this tool programmatically |
143
+ | `agents.modes` | ❌ | Array of supported invocation modes (`"one-way"`, `"two-way"`) |
144
+ | `agents.defaultMode` | ❌ | Default mode when the agent does not request one explicitly |
145
+ | `agents.timeoutMS` | ❌ | Optional timeout hint in milliseconds for two-way calls |
139
146
 
140
147
  > \*\* Required only when the `invocation` object is present.
141
148
 
142
149
  **Example `pptb.config.json`:**
143
150
 
144
151
  ```json
145
- {
146
152
  "invocation": {
147
153
  "version": "1.0.0",
148
154
  "capabilities": ["entity-picker"],
@@ -159,6 +165,13 @@ In addition to `package.json`, the validator automatically checks a `pptb.config
159
165
  "error": { "type": "string" }
160
166
  }
161
167
  }
168
+ },
169
+ "agents": {
170
+ "version": "1.0.0",
171
+ "invokable": true,
172
+ "modes": ["one-way", "two-way"],
173
+ "defaultMode": "two-way",
174
+ "timeoutMS": 12000
162
175
  }
163
176
  }
164
177
  ```
@@ -329,6 +342,21 @@ if (result !== null) {
329
342
 
330
343
  #### Caller: tag-based capability discovery
331
344
 
345
+ ```typescript
346
+ // Find all installed tools that declare the "entity-picker" capability
347
+ const pickers = await toolboxAPI.invocation.findToolsByCapability("entity-picker");
348
+ if (pickers.length > 0) {
349
+ const picker = pickers[0] as { id: string };
350
+ const result = await toolboxAPI.invocation.launchTool(picker.id, { entityName: "account" });
351
+ } else {
352
+ // User dismissed the picker (closed window or clicked "Return to Caller" banner)
353
+ }
354
+ ```
355
+
356
+ > **One-at-a-time**: only one active callee per caller is supported. A second `launchTool` call while a callee is open throws `"A callee invocation is already in progress"`.
357
+
358
+ #### Caller: tag-based capability discovery
359
+
332
360
  ```typescript
333
361
  // Find all installed tools that declare the "entity-picker" capability
334
362
  const pickers = await toolboxAPI.invocation.findToolsByCapability("entity-picker");
package/dataverseAPI.d.ts CHANGED
@@ -1544,6 +1544,12 @@ declare global {
1544
1544
  */
1545
1545
  dataverseAPI: DataverseAPI.API;
1546
1546
  }
1547
+ interface GlobalThis {
1548
+ /**
1549
+ * Dataverse Web API accessible to headless tools via globalThis
1550
+ */
1551
+ dataverseAPI: DataverseAPI.API;
1552
+ }
1547
1553
  }
1548
1554
 
1549
1555
  export = DataverseAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pptb/types",
3
- "version": "1.2.4-beta.5",
3
+ "version": "1.2.4",
4
4
  "description": "Type definitions for Power Platform ToolBox APIs and validity checks for tool packages",
5
5
  "main": "index.d.ts",
6
6
  "types": "index.d.ts",
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Power Platform ToolBox - Power Platform API Type Definitions
3
+ *
4
+ * Power Platform Admin APIs exposed to tools via window.powerplatformAPI
5
+ * https://learn.microsoft.com/en-us/rest/api/power-platform/
6
+ */
7
+
8
+ declare namespace PowerPlatformAPI {
9
+ /**
10
+ * Power Platform API category response type
11
+ */
12
+ export interface PowerPlatformResponse {
13
+ [key: string]: unknown;
14
+ }
15
+
16
+ /**
17
+ * Generic HTTP method type
18
+ */
19
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
20
+
21
+ /**
22
+ * Power Platform API category client interface
23
+ * Provides generic HTTP methods for each API category
24
+ */
25
+ export interface CategoryClient {
26
+ /**
27
+ * Make a GET request to the category endpoint
28
+ * @param path Relative path after the category base URL (e.g., "environments/{environmentId}/apps/{app}?api-version=2024-10-01")
29
+ * @param connectionTarget Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
30
+ * @param headers Optional custom headers
31
+ */
32
+ Get: (path?: string, connectionTarget?: "primary" | "secondary", headers?: Record<string, string>) => Promise<PowerPlatformResponse>;
33
+
34
+ /**
35
+ * Make a POST request to the category endpoint
36
+ * @param path Relative path after the category base URL
37
+ * @param body Optional request body
38
+ * @param connectionTarget Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
39
+ * @param headers Optional custom headers
40
+ */
41
+ Post: (path?: string, body?: unknown, connectionTarget?: "primary" | "secondary", headers?: Record<string, string>) => Promise<PowerPlatformResponse>;
42
+
43
+ /**
44
+ * Make a PUT request to the category endpoint
45
+ * @param path Relative path after the category base URL
46
+ * @param body Optional request body
47
+ * @param connectionTarget Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
48
+ * @param headers Optional custom headers
49
+ */
50
+ Put: (path?: string, body?: unknown, connectionTarget?: "primary" | "secondary", headers?: Record<string, string>) => Promise<PowerPlatformResponse>;
51
+
52
+ /**
53
+ * Make a PATCH request to the category endpoint
54
+ * @param path Relative path after the category base URL
55
+ * @param body Optional request body
56
+ * @param connectionTarget Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
57
+ * @param headers Optional custom headers
58
+ */
59
+ Patch: (path?: string, body?: unknown, connectionTarget?: "primary" | "secondary", headers?: Record<string, string>) => Promise<PowerPlatformResponse>;
60
+
61
+ /**
62
+ * Make a DELETE request to the category endpoint
63
+ * @param path Relative path after the category base URL
64
+ * @param connectionTarget Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
65
+ * @param headers Optional custom headers
66
+ * @param body Optional request body (for DELETE with payload)
67
+ */
68
+ Delete: (path?: string, connectionTarget?: "primary" | "secondary", headers?: Record<string, string>, body?: unknown) => Promise<PowerPlatformResponse>;
69
+ }
70
+
71
+ /**
72
+ * Power Platform Analytics API
73
+ * https://api.powerplatform.com/analytics
74
+ */
75
+ export interface Analytics extends CategoryClient {}
76
+
77
+ /**
78
+ * Power Platform App Management API
79
+ * https://api.powerplatform.com/appmanagement
80
+ */
81
+ export interface AppManagement extends CategoryClient {}
82
+
83
+ /**
84
+ * Power Platform Authorization API
85
+ * https://api.powerplatform.com/authorization
86
+ */
87
+ export interface Authorization extends CategoryClient {}
88
+
89
+ /**
90
+ * Power Platform Connectivity API
91
+ * https://api.powerplatform.com/connectivity
92
+ */
93
+ export interface Connectivity extends CategoryClient {}
94
+
95
+ /**
96
+ * Power Platform Copilot Studio API
97
+ * https://api.powerplatform.com/copilotstudio
98
+ */
99
+ export interface CopilotStudio extends CategoryClient {}
100
+
101
+ /**
102
+ * Power Platform Dynamics API
103
+ * https://api.powerplatform.com/dynamics
104
+ */
105
+ export interface Dynamics extends CategoryClient {}
106
+
107
+ /**
108
+ * Power Platform Environment Management API
109
+ * https://api.powerplatform.com/environmentmanagement
110
+ */
111
+ export interface EnvironmentManagement extends CategoryClient {}
112
+
113
+ /**
114
+ * Power Platform Governance API
115
+ * https://api.powerplatform.com/governance
116
+ */
117
+ export interface Governance extends CategoryClient {}
118
+
119
+ /**
120
+ * Power Platform Licensing API
121
+ * https://api.powerplatform.com/licensing
122
+ */
123
+ export interface Licensing extends CategoryClient {}
124
+
125
+ /**
126
+ * Power Platform Power Apps API
127
+ * https://api.powerplatform.com/powerapps
128
+ */
129
+ export interface PowerApps extends CategoryClient {}
130
+
131
+ /**
132
+ * Power Platform Power Automate API
133
+ * https://api.powerplatform.com/powerautomate
134
+ */
135
+ export interface PowerAutomate extends CategoryClient {}
136
+
137
+ /**
138
+ * Power Platform Power Pages API
139
+ * https://api.powerplatform.com/powerpages
140
+ */
141
+ export interface PowerPages extends CategoryClient {}
142
+
143
+ /**
144
+ * Power Platform Resource Query API
145
+ * https://api.powerplatform.com/resourcequery
146
+ */
147
+ export interface ResourceQuery extends CategoryClient {}
148
+
149
+ /**
150
+ * Power Platform User Management API
151
+ * https://api.powerplatform.com/usermanagement
152
+ */
153
+ export interface UserManagement extends CategoryClient {}
154
+
155
+ /**
156
+ * Power Platform Workflow Agents API
157
+ * https://api.powerplatform.com/workflowagents
158
+ */
159
+ export interface WorkflowAgents extends CategoryClient {}
160
+
161
+ /**
162
+ * Main Power Platform API interface
163
+ * Each category exposes generic HTTP methods (Get, Post, Put, Patch, Delete)
164
+ */
165
+ export interface API {
166
+ Analytics: Analytics;
167
+ AppManagement: AppManagement;
168
+ Authorization: Authorization;
169
+ Connectivity: Connectivity;
170
+ CopilotStudio: CopilotStudio;
171
+ Dynamics: Dynamics;
172
+ EnvironmentManagement: EnvironmentManagement;
173
+ Governance: Governance;
174
+ Licensing: Licensing;
175
+ PowerApps: PowerApps;
176
+ PowerAutomate: PowerAutomate;
177
+ PowerPages: PowerPages;
178
+ ResourceQuery: ResourceQuery;
179
+ UserManagement: UserManagement;
180
+ WorkflowAgents: WorkflowAgents;
181
+ }
182
+ }
183
+
184
+ /**
185
+ * Global window interface extension for Power Platform API
186
+ */
187
+ declare global {
188
+ interface GlobalThis {
189
+ /**
190
+ * Power Platform Admin API accessible to headless tools
191
+ */
192
+ powerplatformAPI: PowerPlatformAPI.API;
193
+ }
194
+
195
+ interface Window {
196
+ /**
197
+ * Power Platform Admin API accessible to tools
198
+ * @example
199
+ * // Get admin app from Power Apps
200
+ * const app = await powerplatformAPI.PowerApps.Get('environments/{environmentId}/apps/{app}?api-version=2024-10-01');
201
+ */
202
+ powerplatformAPI: PowerPlatformAPI.API;
203
+ }
204
+ }
205
+
206
+ export = PowerPlatformAPI;
207
+ export as namespace PowerPlatformAPI;
package/pptbConfig.d.ts CHANGED
@@ -25,6 +25,13 @@
25
25
  * "error": { "type": "string" }
26
26
  * }
27
27
  * }
28
+ * },
29
+ * "agents": {
30
+ * "version": "1.0.0",
31
+ * "invokable": true,
32
+ * "modes": ["one-way", "two-way"],
33
+ * "defaultMode": "two-way",
34
+ * "timeoutMS": 12000
28
35
  * }
29
36
  * }
30
37
  * ```
@@ -49,14 +56,7 @@
49
56
  * | `plugin-inspector` | Inspect or manage plugins and assemblies |
50
57
  * | `pcf-control-builder`| Build or scaffold PCF controls |
51
58
  */
52
- export type KnownCapabilityTag =
53
- | "fetchxml"
54
- | "entity-picker"
55
- | "record-selector"
56
- | "solution-selector"
57
- | "webresource-editor"
58
- | "plugin-inspector"
59
- | "pcf-control-builder";
59
+ export type KnownCapabilityTag = "fetchxml" | "entity-picker" | "record-selector" | "solution-selector" | "webresource-editor" | "plugin-inspector" | "pcf-control-builder";
60
60
 
61
61
  /**
62
62
  * A capability tag string accepted by `invocation.capabilities` and
@@ -72,7 +72,7 @@ export type KnownCapabilityTag =
72
72
  * { "invocation": { "version": "1.0.0", "capabilities": ["fetchxml", "entity-picker"] } }
73
73
  * ```
74
74
  */
75
- export type CapabilityTag = KnownCapabilityTag | (string & {});
75
+ export type CapabilityTag = KnownCapabilityTag | string;
76
76
 
77
77
  /** A JSON-schema-style property descriptor used inside invocation definitions. */
78
78
  export interface JsonSchemaProperty {
@@ -101,6 +101,30 @@ export interface JsonSchemaObject {
101
101
  * - `returnTopic` describes the data this tool will resolve back to its caller
102
102
  * when it finishes.
103
103
  */
104
+ export type AgentInvocationMode = "one-way" | "two-way";
105
+
106
+ /**
107
+ * Agent-specific launch contract for external automation callers.
108
+ *
109
+ * - `version`: semantic version for the agent-facing contract.
110
+ * - `invokable`: opt-in flag that exposes the tool to the MCP server.
111
+ * - `modes`: supported MCP invocation modes for this tool.
112
+ * - `defaultMode`: fallback mode when the caller does not specify one.
113
+ * - `timeoutMS`: optional timeout hint, in milliseconds, for two-way calls.
114
+ */
115
+ export interface AgentsConfig {
116
+ /** Semantic version of this agent contract. */
117
+ version: string;
118
+ /** Whether the tool may be invoked by an external agent. */
119
+ invokable?: boolean;
120
+ /** Invocation modes supported by the tool when called by an agent. */
121
+ modes?: AgentInvocationMode[];
122
+ /** Default mode used when an agent does not request a mode explicitly. */
123
+ defaultMode?: AgentInvocationMode;
124
+ /** Optional timeout hint, in milliseconds, for agent-driven two-way calls. */
125
+ timeoutMS?: number;
126
+ }
127
+
104
128
  export interface InvocationConfig {
105
129
  /**
106
130
  * Semantic version of this invocation contract (e.g. "1.0.0").
@@ -142,4 +166,6 @@ export interface InvocationConfig {
142
166
  export interface PPTBConfig {
143
167
  /** Invocation contract – how this tool can be called by other tools. */
144
168
  invocation?: InvocationConfig;
169
+ /** Agent contract – how this tool can be called by external automation. */
170
+ agents?: AgentsConfig;
145
171
  }
package/toolboxAPI.d.ts CHANGED
@@ -16,6 +16,18 @@ declare namespace ToolBoxAPI {
16
16
  connectionId?: string | null;
17
17
  secondaryConnectionUrl?: string | null;
18
18
  secondaryConnectionId?: string | null;
19
+ /**
20
+ * Invocation metadata injected by PPTB when the tool is launched by another
21
+ * tool or by the MCP server. Tools should treat this as optional and
22
+ * branch on `source`/`mode` rather than assuming it is always present.
23
+ */
24
+ invocationContext?: {
25
+ source?: "tool" | "mcp";
26
+ mode?: "one-way" | "two-way";
27
+ correlationId?: string;
28
+ timeoutMs?: number;
29
+ expectsResponse?: boolean;
30
+ };
19
31
  }
20
32
 
21
33
  /**
@@ -86,6 +98,7 @@ declare namespace ToolBoxAPI {
86
98
  environmentColor?: string;
87
99
  categoryColor?: string;
88
100
  enabledForPowerPlatformAPI?: boolean;
101
+ scopesForPowerPlatformAPI?: string[];
89
102
  createdAt?: string;
90
103
  lastUsedAt?: string;
91
104
  /**
@@ -461,16 +474,15 @@ declare namespace ToolBoxAPI {
461
474
  getLaunchContext: () => Promise<Record<string, unknown> | null>;
462
475
 
463
476
  /**
464
- * Returns data back to the caller tool that launched this tool.
465
- *
466
- * The value resolves the `Promise` returned by the caller's
467
- * `invocation.launchTool()` call. **After calling `returnData`, PPTB
468
- * automatically closes the callee window** — the callee does not need to
469
- * close itself.
477
+ * Return data back to the tool that launched this one. If the tool was not
478
+ * launched by another tool, this is a no-op.
470
479
  *
471
- * If this tool was not launched by another tool, the call is a no-op.
480
+ * For MCP launches, one-way mode may omit a payload entirely from the
481
+ * caller's response lifecycle, but the tool can still call `returnData()` to
482
+ * complete a local flow if it wants to.
472
483
  *
473
484
  * @param returnData The data to pass back to the caller
485
+ * @returns Promise that resolves when the data has been handed off
474
486
  */
475
487
  returnData: (returnData: Record<string, unknown>) => Promise<void>;
476
488
 
@@ -557,6 +569,19 @@ declare namespace ToolBoxAPI {
557
569
  * Global window interface extension for ToolBox tools
558
570
  */
559
571
  declare global {
572
+ interface GlobalThis {
573
+ /**
574
+ * The organized ToolBox API for headless tools.
575
+ * Windowed tools should continue to use window.toolboxAPI.
576
+ */
577
+ toolboxAPI: ToolBoxAPI.API;
578
+
579
+ /**
580
+ * Tool context available at startup
581
+ */
582
+ TOOLBOX_CONTEXT?: ToolBoxAPI.ToolContext;
583
+ }
584
+
560
585
  interface Window {
561
586
  /**
562
587
  * The organized ToolBox API for tools