@macro-inc/sdk 0.4.0 → 0.5.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 (193) hide show
  1. package/CALLS.md +82 -0
  2. package/README.md +176 -7
  3. package/dist/chunk-2IVGAIGQ.js +80 -0
  4. package/dist/{chunk-PTX2RV2N.js → chunk-3SW6QVDV.js} +33 -0
  5. package/dist/{chunk-XFA7NCJ5.js → chunk-GT5EUYOR.js} +13 -15
  6. package/dist/{chunk-ZLBDES7U.js → chunk-HIW6KU2I.js} +490 -4
  7. package/dist/{chunk-AZJUIUIV.js → chunk-J2VK3NOR.js} +56 -0
  8. package/dist/{chunk-PZPTJI6F.js → chunk-UVJLWLSJ.js} +41 -2
  9. package/dist/generated/agent-fold/index.d.ts +8 -6
  10. package/dist/generated/agent-harness/index.d.ts +1 -1
  11. package/dist/generated/agent-harness/index.js +1 -1
  12. package/dist/generated/agent-harness/sdk.gen.d.ts +17 -1
  13. package/dist/generated/agent-harness/types.gen.d.ts +188 -3
  14. package/dist/generated/auth/index.js +1 -1
  15. package/dist/generated/auth/sdk.gen.d.ts +13 -15
  16. package/dist/generated/auth/types.gen.d.ts +36 -17
  17. package/dist/generated/cognition/index.d.ts +1 -1
  18. package/dist/generated/cognition/index.js +1 -1
  19. package/dist/generated/cognition/sdk.gen.d.ts +38 -1
  20. package/dist/generated/cognition/types.gen.d.ts +473 -4
  21. package/dist/generated/connection/types.gen.d.ts +1 -1
  22. package/dist/generated/notification/index.d.ts +1 -1
  23. package/dist/generated/notification/types.gen.d.ts +36 -1
  24. package/dist/generated/scheduled-action/index.d.ts +1 -1
  25. package/dist/generated/scheduled-action/index.js +1 -1
  26. package/dist/generated/scheduled-action/sdk.gen.d.ts +17 -2
  27. package/dist/generated/scheduled-action/types.gen.d.ts +642 -104
  28. package/dist/generated/storage/index.d.ts +1 -1
  29. package/dist/generated/storage/index.js +1 -1
  30. package/dist/generated/storage/sdk.gen.d.ts +204 -5
  31. package/dist/generated/storage/types.gen.d.ts +3969 -374
  32. package/dist/src/calls/browser.d.ts +14 -0
  33. package/dist/src/calls/browser.js +102 -0
  34. package/dist/src/calls/common.d.ts +18 -0
  35. package/dist/src/calls/node.d.ts +24 -0
  36. package/dist/src/calls/node.js +145 -0
  37. package/dist/src/calls/telemetry.d.ts +5 -0
  38. package/dist/src/entities/account-managers/grant.d.ts +28 -5
  39. package/dist/src/entities/account-managers/namespace.d.ts +15 -3
  40. package/dist/src/entities/activity/entity.d.ts +7 -0
  41. package/dist/src/entities/activity/namespace.d.ts +58 -0
  42. package/dist/src/entities/activity/namespace.test.d.ts +1 -0
  43. package/dist/src/entities/agent-sessions/activity.d.ts +10 -2
  44. package/dist/src/entities/agent-sessions/agent-session.d.ts +193 -18
  45. package/dist/src/entities/agent-sessions/code-execution.d.ts +15 -3
  46. package/dist/src/entities/agent-sessions/conversation.d.ts +46 -9
  47. package/dist/src/entities/agent-sessions/namespace.d.ts +71 -16
  48. package/dist/src/entities/agent-sessions/origin.d.ts +1 -1
  49. package/dist/src/entities/agent-sessions/queued-action.d.ts +17 -3
  50. package/dist/src/entities/agent-sessions/review.d.ts +55 -4
  51. package/dist/src/entities/agent-sessions/tool-approval.d.ts +5 -1
  52. package/dist/src/entities/agents/agent.d.ts +98 -3
  53. package/dist/src/entities/agents/namespace.d.ts +52 -8
  54. package/dist/src/entities/ai/namespace.d.ts +9 -1
  55. package/dist/src/entities/api-keys/api-key.d.ts +6 -1
  56. package/dist/src/entities/api-keys/namespace.d.ts +15 -3
  57. package/dist/src/entities/bots/bot.d.ts +38 -6
  58. package/dist/src/entities/bots/namespace.d.ts +13 -1
  59. package/dist/src/entities/bots/token.d.ts +6 -1
  60. package/dist/src/entities/calendar/booking-link.d.ts +7 -1
  61. package/dist/src/entities/calendar/booking-namespace.d.ts +13 -0
  62. package/dist/src/entities/calendar/booking.d.ts +15 -0
  63. package/dist/src/entities/calendar/calendar.d.ts +7 -1
  64. package/dist/src/entities/calendar/event.d.ts +59 -9
  65. package/dist/src/entities/calendar/namespace.d.ts +88 -10
  66. package/dist/src/entities/calendar/replacement.d.ts +19 -3
  67. package/dist/src/entities/calls/call-record.d.ts +90 -14
  68. package/dist/src/entities/calls/connection.d.ts +7 -1
  69. package/dist/src/entities/calls/message.d.ts +27 -5
  70. package/dist/src/entities/calls/namespace.d.ts +15 -3
  71. package/dist/src/entities/canvases/canvas.d.ts +324 -0
  72. package/dist/src/entities/channels/access-request.d.ts +10 -2
  73. package/dist/src/entities/channels/activity.d.ts +20 -4
  74. package/dist/src/entities/channels/channel.d.ts +130 -23
  75. package/dist/src/entities/channels/labels.d.ts +41 -7
  76. package/dist/src/entities/channels/message.d.ts +41 -7
  77. package/dist/src/entities/channels/namespace.d.ts +28 -3
  78. package/dist/src/entities/channels/post.test.d.ts +1 -0
  79. package/dist/src/entities/channels/thread.d.ts +19 -3
  80. package/dist/src/entities/chats/chat.d.ts +56 -6
  81. package/dist/src/entities/chats/generation.d.ts +11 -2
  82. package/dist/src/entities/chats/namespace.d.ts +10 -2
  83. package/dist/src/entities/connected-apps/connected-app.d.ts +14 -1
  84. package/dist/src/entities/connected-apps/connector.d.ts +3 -0
  85. package/dist/src/entities/connected-apps/namespace.d.ts +16 -0
  86. package/dist/src/entities/crm/company.d.ts +63 -15
  87. package/dist/src/entities/crm/contact.d.ts +60 -13
  88. package/dist/src/entities/crm/namespace.d.ts +85 -11
  89. package/dist/src/entities/crm/pipeline-entry.d.ts +102 -0
  90. package/dist/src/entities/crm/pipeline.d.ts +271 -27
  91. package/dist/src/entities/crm/pipelines.d.ts +39 -2
  92. package/dist/src/entities/databases/column.d.ts +54 -7
  93. package/dist/src/entities/databases/database.d.ts +126 -12
  94. package/dist/src/entities/databases/namespace.d.ts +16 -4
  95. package/dist/src/entities/databases/row.d.ts +2 -0
  96. package/dist/src/entities/databases/saved-query.d.ts +145 -0
  97. package/dist/src/entities/databases/table.d.ts +64 -10
  98. package/dist/src/entities/databases/view.d.ts +27 -5
  99. package/dist/src/entities/databases/webhook.d.ts +8 -1
  100. package/dist/src/entities/documents/ai-edit.d.ts +2 -0
  101. package/dist/src/entities/documents/anchor.d.ts +12 -2
  102. package/dist/src/entities/documents/comment.d.ts +29 -5
  103. package/dist/src/entities/documents/document.d.ts +243 -20
  104. package/dist/src/entities/documents/markdown.d.ts +25 -0
  105. package/dist/src/entities/documents/namespace.d.ts +132 -13
  106. package/dist/src/entities/documents/skills.test.d.ts +1 -0
  107. package/dist/src/entities/documents/system-skill.d.ts +21 -1
  108. package/dist/src/entities/documents/text-comment.d.ts +41 -0
  109. package/dist/src/entities/documents/text-comment.test.d.ts +1 -0
  110. package/dist/src/entities/documents/version.d.ts +5 -1
  111. package/dist/src/entities/email/attachment.d.ts +3 -0
  112. package/dist/src/entities/email/draft.d.ts +61 -9
  113. package/dist/src/entities/email/filter.d.ts +12 -2
  114. package/dist/src/entities/email/label.d.ts +7 -1
  115. package/dist/src/entities/email/link.d.ts +5 -1
  116. package/dist/src/entities/email/message.d.ts +55 -8
  117. package/dist/src/entities/email/namespace.d.ts +127 -21
  118. package/dist/src/entities/email/thread.d.ts +99 -16
  119. package/dist/src/entities/entity-mentions/mention.d.ts +6 -1
  120. package/dist/src/entities/entity-mentions/namespace.d.ts +5 -1
  121. package/dist/src/entities/entity.d.ts +56 -6
  122. package/dist/src/entities/external-chat/chat.d.ts +62 -11
  123. package/dist/src/entities/external-chat/message.d.ts +1 -1
  124. package/dist/src/entities/external-chat/namespace.d.ts +5 -1
  125. package/dist/src/entities/external-chat/send.d.ts +10 -2
  126. package/dist/src/entities/favorites/namespace.d.ts +20 -3
  127. package/dist/src/entities/foreign/foreign-entity.d.ts +5 -1
  128. package/dist/src/entities/foreign/namespace.d.ts +4 -0
  129. package/dist/src/entities/forms/form.d.ts +71 -13
  130. package/dist/src/entities/forms/namespace.d.ts +10 -2
  131. package/dist/src/entities/forms/question.d.ts +35 -7
  132. package/dist/src/entities/forms/response.d.ts +25 -5
  133. package/dist/src/entities/forms/section.d.ts +15 -3
  134. package/dist/src/entities/github-pull-requests/namespace.d.ts +5 -1
  135. package/dist/src/entities/github-pull-requests/pull-request.d.ts +15 -3
  136. package/dist/src/entities/harnesses/harness.d.ts +51 -3
  137. package/dist/src/entities/harnesses/namespace.d.ts +53 -7
  138. package/dist/src/entities/harnesses/pairing.d.ts +12 -2
  139. package/dist/src/entities/images/image.d.ts +16 -5
  140. package/dist/src/entities/images/namespace.d.ts +8 -1
  141. package/dist/src/entities/initiatives/initiative.d.ts +117 -3
  142. package/dist/src/entities/initiatives/initiative.test.d.ts +1 -0
  143. package/dist/src/entities/initiatives/namespace.d.ts +69 -7
  144. package/dist/src/entities/me/namespace.d.ts +27 -2
  145. package/dist/src/entities/meetings/meeting.d.ts +45 -8
  146. package/dist/src/entities/meetings/namespace.d.ts +20 -4
  147. package/dist/src/entities/memory/namespace.d.ts +49 -0
  148. package/dist/src/entities/memory/namespace.test.d.ts +1 -0
  149. package/dist/src/entities/messages/discussion.d.ts +84 -0
  150. package/dist/src/entities/messages/thread.d.ts +19 -5
  151. package/dist/src/entities/notifications/namespace.d.ts +40 -7
  152. package/dist/src/entities/notifications/notification.d.ts +29 -5
  153. package/dist/src/entities/pins/namespace.d.ts +23 -4
  154. package/dist/src/entities/projects/namespace.d.ts +29 -0
  155. package/dist/src/entities/projects/project.d.ts +47 -6
  156. package/dist/src/entities/properties/namespace.d.ts +67 -11
  157. package/dist/src/entities/properties/namespace.test.d.ts +1 -0
  158. package/dist/src/entities/properties/property-definition.d.ts +30 -5
  159. package/dist/src/entities/properties/property-option.d.ts +14 -2
  160. package/dist/src/entities/referrals/namespace.d.ts +8 -1
  161. package/dist/src/entities/routines/namespace.d.ts +128 -7
  162. package/dist/src/entities/routines/routine.d.ts +111 -25
  163. package/dist/src/entities/saved-views/namespace.d.ts +57 -0
  164. package/dist/src/entities/saved-views/saved-view.d.ts +78 -0
  165. package/dist/src/entities/search/namespace.d.ts +5 -1
  166. package/dist/src/entities/sharing/access.d.ts +50 -9
  167. package/dist/src/entities/spreadsheets/spreadsheet.d.ts +201 -0
  168. package/dist/src/entities/tasks/namespace.d.ts +13 -1
  169. package/dist/src/entities/tasks/task.d.ts +7 -1
  170. package/dist/src/entities/teams/invite.d.ts +3 -0
  171. package/dist/src/entities/teams/namespace.d.ts +10 -2
  172. package/dist/src/entities/teams/team.d.ts +7 -0
  173. package/dist/src/entities/unfurls/namespace.d.ts +12 -2
  174. package/dist/src/entities/users/namespace.d.ts +19 -1
  175. package/dist/src/entities/users/profile-picture.d.ts +29 -0
  176. package/dist/src/entities/users/profile-picture.test.d.ts +1 -0
  177. package/dist/src/entities/users/user.d.ts +52 -1
  178. package/dist/src/entities/web/namespace.d.ts +6 -0
  179. package/dist/src/entities/webhooks/namespace.d.ts +5 -0
  180. package/dist/src/entities/webhooks/webhook.d.ts +47 -7
  181. package/dist/src/entities/whatsapp/account.d.ts +5 -1
  182. package/dist/src/entities/whatsapp/chat.d.ts +9 -1
  183. package/dist/src/entities/whatsapp/namespace.d.ts +7 -1
  184. package/dist/src/entities/workspace/namespace.d.ts +7 -1
  185. package/dist/src/entities/workspace/query.d.ts +5 -1
  186. package/dist/src/events/hydrate/user.d.ts +14 -0
  187. package/dist/src/events/receiver.d.ts +2 -0
  188. package/dist/src/events/types.d.ts +2 -1
  189. package/dist/src/macro.d.ts +33 -5
  190. package/dist/src/macro.js +15635 -10132
  191. package/dist/src/utils/lazy.d.ts +7 -1
  192. package/package.json +32 -5
  193. package/dist/src/entities/crm/comment.d.ts +0 -64
@@ -0,0 +1,14 @@
1
+ import { Room } from 'livekit-client';
2
+ import { type CallTarget, type JoinOptions } from './common.js';
3
+ export type { CallConnection, CallTarget, JoinOptions } from './common.js';
4
+ export type ScreenShare = {
5
+ stop(): Promise<void>;
6
+ stopped: Promise<void>;
7
+ };
8
+ export type ScreenOptions = DisplayMediaStreamOptions;
9
+ export declare function connectRoom(target: CallTarget, options?: JoinOptions): Promise<{
10
+ room: Room;
11
+ connection: import("./common.js").CallConnection;
12
+ }>;
13
+ /** Publish a MediaStream, or open the browser's screen picker. */
14
+ export declare function publishScreen(room: Room, source?: MediaStream, options?: ScreenOptions): Promise<ScreenShare>;
@@ -0,0 +1,102 @@
1
+ import {
2
+ callIdForRoom,
3
+ connectRoomWith,
4
+ reportError,
5
+ withSpan
6
+ } from "../../chunk-2IVGAIGQ.js";
7
+
8
+ // src/calls/browser.ts
9
+ import { Room, RoomEvent, Track } from "livekit-client";
10
+ function connectRoom(target, options) {
11
+ const room = new Room({ publishDefaults: { dtx: false } });
12
+ return connectRoomWith(
13
+ target,
14
+ options,
15
+ room,
16
+ (room2, connection) => room2.connect(connection.url, connection.token),
17
+ (room2, callback) => room2.on(RoomEvent.Disconnected, callback)
18
+ );
19
+ }
20
+ async function publishScreen(room, source, options = {}) {
21
+ return withSpan("call.sdk.publish_screen", async (span) => {
22
+ const callId = callIdForRoom(room);
23
+ if (callId) span.setAttribute("call.id", callId);
24
+ span.setAttribute("call.sdk.source_kind", source ? "stream" : "picker");
25
+ const owned = !source;
26
+ const stream = source ?? await navigator.mediaDevices.getDisplayMedia({
27
+ video: true,
28
+ audio: true,
29
+ ...options
30
+ });
31
+ const video = stream.getVideoTracks()[0];
32
+ if (!video) {
33
+ if (owned)
34
+ stream.getTracks().forEach((track) => {
35
+ track.stop();
36
+ });
37
+ throw new Error("Screen stream has no video track");
38
+ }
39
+ const audio = stream.getAudioTracks()[0];
40
+ const settings = video.getSettings();
41
+ if (settings.width) span.setAttribute("call.sdk.width", settings.width);
42
+ if (settings.height) span.setAttribute("call.sdk.height", settings.height);
43
+ if (settings.frameRate)
44
+ span.setAttribute("call.sdk.fps", settings.frameRate);
45
+ let stopping;
46
+ let resolveStopped = () => {
47
+ };
48
+ const stoppedPromise = new Promise((resolve) => {
49
+ resolveStopped = resolve;
50
+ });
51
+ const published = [];
52
+ const stop = () => stopping ??= (async () => {
53
+ try {
54
+ for (const track of published) {
55
+ await room.localParticipant.unpublishTrack(track, false);
56
+ }
57
+ } finally {
58
+ if (owned)
59
+ stream.getTracks().forEach((track) => {
60
+ track.stop();
61
+ });
62
+ resolveStopped();
63
+ }
64
+ })();
65
+ video.addEventListener(
66
+ "ended",
67
+ () => {
68
+ stop().catch(
69
+ (error) => reportError("call.sdk.publish_screen", error, callId)
70
+ );
71
+ },
72
+ { once: true }
73
+ );
74
+ room.on(RoomEvent.Disconnected, () => {
75
+ stop().catch(
76
+ (error) => reportError("call.sdk.publish_screen", error, callId)
77
+ );
78
+ });
79
+ try {
80
+ await room.localParticipant.publishTrack(video, {
81
+ source: Track.Source.ScreenShare
82
+ });
83
+ published.push(video);
84
+ if (audio) {
85
+ await room.localParticipant.publishTrack(audio, {
86
+ source: Track.Source.ScreenShareAudio,
87
+ dtx: false
88
+ });
89
+ published.push(audio);
90
+ }
91
+ span.setAttribute("call.sdk.outcome", "published");
92
+ } catch (error) {
93
+ await stop();
94
+ throw error;
95
+ }
96
+ return { stop, stopped: stoppedPromise };
97
+ });
98
+ }
99
+ export {
100
+ connectRoom,
101
+ publishScreen
102
+ };
@@ -0,0 +1,18 @@
1
+ import type { CallConnection as CoreCallConnection, JoinOptions as CoreJoinOptions } from '../entities/calls/connection.js';
2
+ export type JoinOptions = CoreJoinOptions;
3
+ /** Structural connection accepted from the core SDK. */
4
+ export type CallConnection = Omit<Pick<CoreCallConnection, 'call' | 'url' | 'token' | 'identity' | 'roomName' | 'started' | 'leave'>, 'call'> & {
5
+ readonly call: {
6
+ readonly id: string;
7
+ };
8
+ };
9
+ export type CallTarget = {
10
+ join(options?: JoinOptions): Promise<CallConnection>;
11
+ } | {
12
+ startCall(options?: JoinOptions): Promise<CallConnection>;
13
+ };
14
+ export declare function callIdForRoom(room: object): string | undefined;
15
+ export declare function connectRoomWith<Room extends object>(target: CallTarget, options: JoinOptions | undefined, room: Room, connect: (room: Room, connection: CallConnection) => Promise<void>, onDisconnect: (room: Room, callback: (reason?: unknown) => void) => void): Promise<{
16
+ room: Room;
17
+ connection: CallConnection;
18
+ }>;
@@ -0,0 +1,24 @@
1
+ import { Room } from '@livekit/rtc-node';
2
+ import { type CallTarget, type JoinOptions } from './common.js';
3
+ export type { CallConnection, CallTarget, JoinOptions } from './common.js';
4
+ export type ScreenFrame = {
5
+ data: Uint8Array;
6
+ width: number;
7
+ height: number;
8
+ format: 'I420' | 'RGBA';
9
+ };
10
+ export type ScreenShare = {
11
+ stop(): Promise<void>;
12
+ stopped: Promise<void>;
13
+ };
14
+ export type ScreenOptions = {
15
+ fps?: number;
16
+ maxBitrate?: number;
17
+ name?: string;
18
+ };
19
+ export declare function connectRoom(target: CallTarget, options?: JoinOptions): Promise<{
20
+ room: Room;
21
+ connection: import("./common.js").CallConnection;
22
+ }>;
23
+ /** Publish caller-supplied I420 or RGBA frames as a screen share. */
24
+ export declare function publishScreen(room: Room, frames: AsyncIterable<ScreenFrame>, options?: ScreenOptions): Promise<ScreenShare>;
@@ -0,0 +1,145 @@
1
+ import {
2
+ callIdForRoom,
3
+ connectRoomWith,
4
+ reportError,
5
+ withSpan
6
+ } from "../../chunk-2IVGAIGQ.js";
7
+
8
+ // src/calls/node.ts
9
+ import {
10
+ LocalVideoTrack,
11
+ Room,
12
+ RoomEvent,
13
+ TrackKind,
14
+ TrackPublishOptions,
15
+ TrackSource,
16
+ VideoBufferType,
17
+ VideoFrame,
18
+ VideoSource
19
+ } from "@livekit/rtc-node";
20
+ function connectRoom(target, options) {
21
+ const room = new Room();
22
+ return connectRoomWith(
23
+ target,
24
+ options,
25
+ room,
26
+ async (room2, connection) => {
27
+ await room2.connect(connection.url, connection.token, {
28
+ autoSubscribe: true,
29
+ dynacast: false
30
+ });
31
+ const participant = room2.localParticipant;
32
+ if (!participant)
33
+ throw new Error("Room connected without a local participant");
34
+ const publish = participant.publishTrack.bind(participant);
35
+ participant.publishTrack = (track, publishOptions) => {
36
+ if (track.kind === TrackKind.KIND_AUDIO) publishOptions.dtx = false;
37
+ return publish(track, publishOptions);
38
+ };
39
+ },
40
+ (room2, callback) => room2.on(RoomEvent.Disconnected, callback)
41
+ );
42
+ }
43
+ async function publishScreen(room, frames, options = {}) {
44
+ return withSpan("call.sdk.publish_screen", async (span) => {
45
+ const callId = callIdForRoom(room);
46
+ if (callId) span.setAttribute("call.id", callId);
47
+ span.setAttribute("call.sdk.source_kind", "frames");
48
+ const iterator = frames[Symbol.asyncIterator]();
49
+ const first = await iterator.next();
50
+ if (first.done) throw new Error("Screen source produced no frames");
51
+ const { width, height } = first.value;
52
+ if (!Number.isInteger(width) || !Number.isInteger(height) || width < 1 || height < 1) {
53
+ throw new Error("Screen frames require positive integer dimensions");
54
+ }
55
+ span.setAttribute("call.sdk.width", width);
56
+ span.setAttribute("call.sdk.height", height);
57
+ span.setAttribute("call.sdk.fps", options.fps ?? 15);
58
+ const source = new VideoSource(width, height);
59
+ const track = LocalVideoTrack.createVideoTrack(
60
+ options.name ?? "screen",
61
+ source
62
+ );
63
+ const publishOptions = new TrackPublishOptions({
64
+ source: TrackSource.SOURCE_SCREENSHARE,
65
+ simulcast: false,
66
+ videoEncoding: {
67
+ maxBitrate: BigInt(options.maxBitrate ?? 25e5),
68
+ maxFramerate: options.fps ?? 15
69
+ }
70
+ });
71
+ let stopped = false;
72
+ let stopping;
73
+ let publicationSid;
74
+ let resolveStopped = () => {
75
+ };
76
+ const stoppedPromise = new Promise((resolve) => {
77
+ resolveStopped = resolve;
78
+ });
79
+ const stop = () => stopping ??= (async () => {
80
+ stopped = true;
81
+ try {
82
+ await iterator.return?.();
83
+ } finally {
84
+ try {
85
+ if (publicationSid)
86
+ await room.localParticipant?.unpublishTrack(
87
+ publicationSid,
88
+ false
89
+ );
90
+ } finally {
91
+ try {
92
+ await track.close();
93
+ } finally {
94
+ resolveStopped();
95
+ }
96
+ }
97
+ }
98
+ })();
99
+ try {
100
+ const participant = room.localParticipant;
101
+ if (!participant) throw new Error("Room is not connected");
102
+ const publication = await participant.publishTrack(track, publishOptions);
103
+ publicationSid = publication.sid;
104
+ span.setAttribute("call.sdk.outcome", "published");
105
+ } catch (error) {
106
+ await stop();
107
+ throw error;
108
+ }
109
+ const pump = async () => {
110
+ try {
111
+ let frame = first;
112
+ while (!stopped && !frame.done) {
113
+ const value = frame.value;
114
+ if (value.width !== width || value.height !== height) {
115
+ throw new Error("Screen frame dimensions changed");
116
+ }
117
+ source.captureFrame(
118
+ new VideoFrame(
119
+ value.data,
120
+ width,
121
+ height,
122
+ value.format === "I420" ? VideoBufferType.I420 : VideoBufferType.RGBA
123
+ )
124
+ );
125
+ frame = await iterator.next();
126
+ }
127
+ } finally {
128
+ await stop();
129
+ }
130
+ };
131
+ pump().catch(
132
+ (error) => reportError("call.sdk.publish_screen", error, callId)
133
+ );
134
+ room.on(RoomEvent.Disconnected, () => {
135
+ stop().catch(
136
+ (error) => reportError("call.sdk.publish_screen", error, callId)
137
+ );
138
+ });
139
+ return { stop, stopped: stoppedPromise };
140
+ });
141
+ }
142
+ export {
143
+ connectRoom,
144
+ publishScreen
145
+ };
@@ -0,0 +1,5 @@
1
+ import { type Span } from '@opentelemetry/api';
2
+ export declare function recordError(span: Span, error: unknown): void;
3
+ export declare function withSpan<T>(name: string, action: (span: Span) => Promise<T>): Promise<T>;
4
+ export declare function reportError(name: string, error: unknown, callId?: string): void;
5
+ export declare function startSpan(name: string): Span;
@@ -21,19 +21,42 @@ export declare class AccountManagerGrant extends MacroEntity<AccountManagerGrant
21
21
  readonly claimedAt: () => Promise<string | undefined>;
22
22
  /** When the token was last used, to the minute. */
23
23
  readonly lastUsedAt: () => Promise<string | undefined>;
24
- /** The account being managed. */
24
+ /**
25
+ * The account being managed.
26
+ *
27
+ * @readonly
28
+ */
25
29
  managed(): Promise<User>;
26
- /** The agent account doing the managing. */
30
+ /**
31
+ * The agent account doing the managing.
32
+ *
33
+ * @readonly
34
+ */
27
35
  manager(): Promise<User>;
28
- /** Approve a request you didn't make. Only the side that didn't ask can. */
36
+ /**
37
+ * Approve a request you didn't make. Only the side that didn't ask can.
38
+ *
39
+ * @destructive
40
+ */
29
41
  approve(): Promise<void>;
30
- /** Decline a request you didn't make. Only the side that didn't ask can. */
42
+ /**
43
+ * Decline a request you didn't make. Only the side that didn't ask can.
44
+ *
45
+ * @destructive
46
+ */
31
47
  decline(): Promise<void>;
32
48
  /**
33
49
  * Get the token for the managed account. Only the manager can, and only once:
34
50
  * save it now. Use it as the SDK's `token` to act as the managed account.
51
+ *
52
+ * @destructive
35
53
  */
36
54
  claimToken(): Promise<string>;
37
- /** End the grant, stopping its token immediately. Either side can. */
55
+ /**
56
+ * End the grant, stopping its token immediately. Either side can.
57
+ *
58
+ * @destructive
59
+ * @idempotent
60
+ */
38
61
  revoke(): Promise<void>;
39
62
  }
@@ -7,11 +7,23 @@ export declare class AccountManagerNamespace {
7
7
  constructor(client: MacroClient);
8
8
  /** Construct a lazy grant handle. */
9
9
  byId(id: string): AccountManagerGrant;
10
- /** List the approved and active managers of the caller's account. */
10
+ /**
11
+ * List the approved and active managers of the caller's account.
12
+ *
13
+ * @readonly
14
+ */
11
15
  list(): Promise<AccountManagerGrant[]>;
12
- /** Ask to manage `user`'s account, in your DM. The caller must be an agent account and `user` a person. */
16
+ /**
17
+ * Ask to manage `user`'s account, in your DM. The caller must be an agent account and `user` a person.
18
+ *
19
+ * @write
20
+ */
13
21
  askToManage(user: User): Promise<AccountManagerGrant>;
14
- /** Ask `user`, an agent account, to manage the caller's account, in your DM. The caller must be a person. */
22
+ /**
23
+ * Ask `user`, an agent account, to manage the caller's account, in your DM. The caller must be a person.
24
+ *
25
+ * @write
26
+ */
15
27
  askToBeManagedBy(user: User): Promise<AccountManagerGrant>;
16
28
  private request;
17
29
  }
@@ -0,0 +1,7 @@
1
+ import type { MacroClient } from '../../utils/client';
2
+ import type { EntityReference } from '../reference';
3
+ /**
4
+ * @internal A handle for an activity row's entity, or `undefined` for kinds
5
+ * addressed by more than their own id (channel messages, database rows).
6
+ */
7
+ export declare function activityEntity(client: MacroClient, type: string, id: string): EntityReference | undefined;
@@ -0,0 +1,58 @@
1
+ import type { ToolActivityAction } from '../../../generated/cognition/types.gen';
2
+ import type { MacroClient } from '../../utils/client';
3
+ import type { EntityReference } from '../reference';
4
+ import { User } from '../users/user';
5
+ /** What an activity event did; property changes carry readable `propertyName` and option labels. */
6
+ export type ActivityAction = ToolActivityAction;
7
+ /** One action attributed to the acting user. */
8
+ export interface ActivityEvent {
9
+ /** Who mechanically acted: the user, or an agent acting for them. */
10
+ actor: User;
11
+ /** The kind of item acted on, e.g. `document`, `channel`, `email_thread`. */
12
+ entityType: string;
13
+ /** The item acted on; `undefined` for kinds without a standalone handle (channel messages, database rows). */
14
+ entity: EntityReference | undefined;
15
+ /** What was done. */
16
+ action: ActivityAction;
17
+ /** When it happened, RFC 3339. */
18
+ occurredAt: string;
19
+ }
20
+ /** A bounded slice of the acting user's activity. */
21
+ export interface ActivityRange {
22
+ /** Matching events, newest first, at most 100. */
23
+ activities: ActivityEvent[];
24
+ /** More than 100 events matched; narrow the range to see the rest. */
25
+ truncated: boolean;
26
+ }
27
+ /**
28
+ * The acting user's own action history across Macro.
29
+ *
30
+ * @routing Use when reading what the user did, opened, edited or sent in a time range, or a teammate's or project's history; not everything that changed in the workspace (`macro.workspace`).
31
+ *
32
+ * @agent `macro.activity.mine` lists the user's own raw actions (opened,
33
+ * edited, sent), including actions agents took for them; `User.activity`
34
+ * reads privacy-reviewed daily, weekly and monthly summaries of the user's
35
+ * or a teammate's work; `Initiative.activity` reads one project's history.
36
+ * Answer with item names and readable property labels, never ids:
37
+ * read names through the returned handles. A range returns at most 100
38
+ * events; when `truncated` is true, split the range and read each part.
39
+ */
40
+ export declare class ActivityNamespace {
41
+ private readonly client;
42
+ constructor(client: MacroClient);
43
+ /**
44
+ * The acting user's actions in `[from, to)`, newest first, at most 100; when
45
+ * `truncated` is true, split the range and read each part.
46
+ *
47
+ * @example
48
+ * const to = new Date();
49
+ * const from = new Date(to.getTime() - 7 * 24 * 60 * 60 * 1000);
50
+ * const { activities, truncated } = await macro.activity.mine({ from, to });
51
+ *
52
+ * @readonly
53
+ */
54
+ mine(range: {
55
+ from: Date | string;
56
+ to: Date | string;
57
+ }): Promise<ActivityRange>;
58
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -16,9 +16,17 @@ export declare class AgentInvocation {
16
16
  private constructor();
17
17
  /** Construct a handle without making a request. */
18
18
  static byId(client: MacroClient, session: AgentSession, id: string): AgentInvocation;
19
- /** The session that owns this invocation. */
19
+ /**
20
+ * The session that owns this invocation.
21
+ *
22
+ * @readonly
23
+ */
20
24
  session(): AgentSession;
21
- /** Recorded activity caused by this invocation, lazily paginated. */
25
+ /**
26
+ * Recorded activity caused by this invocation, lazily paginated.
27
+ *
28
+ * @readonly
29
+ */
22
30
  activity(options?: Omit<AgentActivityOptions, 'invocation'>): AsyncGenerator<AgentActivity, any, any>;
23
31
  /** Safe identity without an authenticated client. */
24
32
  toJSON(): {