@cef-ai/widget-runtime 2.2.2 → 2.3.1

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { buildWidgetManifest, type BuildManifestInput } from './manifest.js';
2
2
  export { injectWidgetBridge, type BridgeInput } from './bridge.js';
3
- export type { WidgetManifest, WidgetRuntimeApi, Identity, QueryResult } from './types.js';
3
+ export type { WidgetManifest, WidgetRuntimeApi, Identity, QueryResult, PublishOptions } from './types.js';
4
4
  export { AgentNotConnectedError } from './types.js';
5
5
  export { validateConfig } from './validate-config.js';
6
6
  export { mountKind } from './mount.js';
package/dist/runtime.js CHANGED
@@ -37,7 +37,7 @@ export function createWidgetRuntime(manifest, deps) {
37
37
  }
38
38
  return {
39
39
  async query(ref, params) { return (await ensureClient()).query(ref, params); },
40
- async publish(type, payload, context) { return (await ensureClient()).publish(type, payload, context); },
40
+ async publish(type, payload, context, options) { return (await ensureClient()).publish(type, payload, context, options); },
41
41
  async identity() {
42
42
  await ensureClient();
43
43
  return { publicKey, status, ...(context ? { context } : {}) };
package/dist/types.d.ts CHANGED
@@ -108,9 +108,21 @@ export interface QueryResult {
108
108
  rowCount: number;
109
109
  };
110
110
  }
111
+ export interface PublishOptions {
112
+ /** The one agent this event is for, `<asPubkey>:<name>`. */
113
+ target?: string;
114
+ }
111
115
  export interface WidgetRuntimeApi {
112
116
  query(ref: string, params?: unknown[]): Promise<QueryResult>;
113
- publish(type: string, payload: unknown, context?: string): Promise<{
117
+ /**
118
+ * Publish an event into the widget's scope.
119
+ *
120
+ * `target` addresses one agent (`<asPubkey>:<name>`). A workflow is started
121
+ * this way: its manifest handles the runner's fixed set (`workflow.start`,
122
+ * …), never the trigger's own event type, so an untargeted `workflow.start`
123
+ * would start every workflow connected in the scope.
124
+ */
125
+ publish(type: string, payload: unknown, context?: string, options?: PublishOptions): Promise<{
114
126
  eventId: string;
115
127
  }>;
116
128
  identity(): Promise<Identity>;
@@ -1,4 +1,4 @@
1
- import { type QueryResult, type WidgetManifest } from './types.js';
1
+ import { type QueryResult, type WidgetManifest, type PublishOptions } from './types.js';
2
2
  export interface VaultSdkLike {
3
3
  vault: {
4
4
  ensure: (opts?: {
@@ -115,7 +115,7 @@ interface AgentHandleLike {
115
115
  }
116
116
  export interface VaultClient {
117
117
  query(ref: string, params?: unknown[]): Promise<QueryResult>;
118
- publish(type: string, payload: unknown, context?: string): Promise<{
118
+ publish(type: string, payload: unknown, context?: string, options?: PublishOptions): Promise<{
119
119
  eventId: string;
120
120
  }>;
121
121
  connectAgent(): Promise<void>;
@@ -218,9 +218,14 @@ hostVaultId) {
218
218
  }
219
219
  return normaliseQueryResult(await queryService(decl ?? { id: ref, label: ref, sql: ref }, params ?? []));
220
220
  },
221
- async publish(type, payload, context) {
221
+ async publish(type, payload, context, options) {
222
222
  const vault = await getVault();
223
- return vault.scope(manifest.scope).publish({ type, context: context ?? '', payload });
223
+ return vault.scope(manifest.scope).publish({
224
+ type,
225
+ context: context ?? '',
226
+ payload,
227
+ ...(options?.target ? { target: options.target } : {}),
228
+ });
224
229
  },
225
230
  async connectAgent() {
226
231
  const vault = await getVault();