@retainer/extension 0.1.0 → 0.2.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.
@@ -0,0 +1,29 @@
1
+ import { type AgentResult, type AgentTaskRequest } from '@retainer/shared';
2
+ import type { ExecutionResult, Invocation } from './protocol.js';
3
+ /**
4
+ * Hands the workspace agent a task from an extension function (agent spec
5
+ * §9.2). The function can't replay, so it stages the task, returns
6
+ * `waitFor(taskId)` and ends; when the task finishes, Retainer calls the
7
+ * function again with the same input and `invocation.agentResult`, which
8
+ * `withAgentResult` routes to the function's `onAgentResult`.
9
+ *
10
+ * `start` only stages the task: nothing runs until Retainer accepts the
11
+ * function's `{ wait }`. A staged task the function doesn't wait for is
12
+ * dropped. Needs `uses: ['agent']` and `agent.tools` on the function, and the
13
+ * installation's grant.
14
+ */
15
+ export declare function agentClient(invocation: Pick<Invocation, 'apiOrigin' | 'runToken' | 'installationId'>, transport?: typeof fetch): {
16
+ start(request: AgentTaskRequest): Promise<{
17
+ taskId: string;
18
+ }>;
19
+ };
20
+ /** The outcome that parks the invocation on a staged task (agent spec §9.2). */
21
+ export declare function waitFor(taskId: string): ExecutionResult;
22
+ /**
23
+ * Routes an invocation: the answer of a task it waited for goes to
24
+ * `onAgentResult`, anything else to `run`.
25
+ */
26
+ export declare function withAgentResult(invocation: Invocation, handlers: {
27
+ run: (invocation: Invocation) => Promise<ExecutionResult>;
28
+ onAgentResult: (result: AgentResult, invocation: Invocation) => Promise<ExecutionResult>;
29
+ }): Promise<ExecutionResult>;
package/dist/agent.js ADDED
@@ -0,0 +1,49 @@
1
+ import { agentTaskRequestSchema } from '@retainer/shared';
2
+ /**
3
+ * Hands the workspace agent a task from an extension function (agent spec
4
+ * §9.2). The function can't replay, so it stages the task, returns
5
+ * `waitFor(taskId)` and ends; when the task finishes, Retainer calls the
6
+ * function again with the same input and `invocation.agentResult`, which
7
+ * `withAgentResult` routes to the function's `onAgentResult`.
8
+ *
9
+ * `start` only stages the task: nothing runs until Retainer accepts the
10
+ * function's `{ wait }`. A staged task the function doesn't wait for is
11
+ * dropped. Needs `uses: ['agent']` and `agent.tools` on the function, and the
12
+ * installation's grant.
13
+ */
14
+ export function agentClient(invocation, transport = fetch) {
15
+ return {
16
+ async start(request) {
17
+ const body = agentTaskRequestSchema.parse(request);
18
+ const response = await transport(new URL(`/v1/extensions/${invocation.installationId}/runtime/agent-tasks`, invocation.apiOrigin), {
19
+ method: 'POST',
20
+ headers: {
21
+ authorization: `Bearer ${invocation.runToken}`,
22
+ 'content-type': 'application/json',
23
+ },
24
+ body: JSON.stringify(body),
25
+ });
26
+ const json = (await response.json().catch(() => ({})));
27
+ if (response.status !== 201 || typeof json.taskId !== 'string')
28
+ throw Object.assign(new Error(`agent task refused: ${json.code ?? response.status}`), {
29
+ status: response.status,
30
+ code: json.code ?? 'agent_task_failed',
31
+ });
32
+ return { taskId: json.taskId };
33
+ },
34
+ };
35
+ }
36
+ /** The outcome that parks the invocation on a staged task (agent spec §9.2). */
37
+ export function waitFor(taskId) {
38
+ return { status: 'succeeded', wait: taskId };
39
+ }
40
+ /**
41
+ * Routes an invocation: the answer of a task it waited for goes to
42
+ * `onAgentResult`, anything else to `run`.
43
+ */
44
+ export function withAgentResult(invocation, handlers) {
45
+ return invocation.agentResult
46
+ ? handlers.onAgentResult(invocation.agentResult, invocation)
47
+ : handlers.run(invocation);
48
+ }
49
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAGnG;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CACzB,UAAyE,EACzE,SAAS,GAAiB,KAAK;IAE/B,OAAO;QACL,KAAK,CAAC,KAAK,CAAC,OAAyB;YACnC,MAAM,IAAI,GAAG,sBAAsB,CAAC,KAAK,CAAC,OAAO,CA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G,CAAC,UAAU,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export declare const gmailRegistrationId = "4c60fc8e-45f9-49c8-919e-5c05c947a9aa";
3
+ export declare class GmailProviderError extends Error {
4
+ readonly code: 'provider_unauthorized' | 'provider_forbidden' | 'provider_rate_limited' | 'provider_unavailable' | 'provider_invalid_request' | 'provider_invalid_response' | 'provider_content_too_large' | 'provider_identity_mismatch' | 'provider_connection_unavailable' | 'provider_scope_missing';
5
+ readonly retry: boolean;
6
+ constructor(code: 'provider_unauthorized' | 'provider_forbidden' | 'provider_rate_limited' | 'provider_unavailable' | 'provider_invalid_request' | 'provider_invalid_response' | 'provider_content_too_large' | 'provider_identity_mismatch' | 'provider_connection_unavailable' | 'provider_scope_missing', retry?: boolean);
7
+ }
8
+ export declare function readResponse<T>(response: Response, schema: z.ZodType<T>, signal: AbortSignal, limit?: number): Promise<T>;
9
+ export declare function gmailFailure(response: Response, signal: AbortSignal, mailboxRequest?: boolean): Promise<string>;
@@ -0,0 +1,73 @@
1
+ import { z } from 'zod';
2
+ export const gmailRegistrationId = '4c60fc8e-45f9-49c8-919e-5c05c947a9aa';
3
+ const maxResponseBytes = 4 * 1024 * 1024;
4
+ const apiError = z.object({
5
+ error: z.object({
6
+ code: z.union([z.number().int(), z.string()]).optional(),
7
+ errors: z.array(z.object({ reason: z.string() })).default([]),
8
+ }),
9
+ });
10
+ export class GmailProviderError extends Error {
11
+ code;
12
+ retry;
13
+ constructor(code, retry = false) {
14
+ super(code);
15
+ this.code = code;
16
+ this.retry = retry;
17
+ }
18
+ }
19
+ export async function readResponse(response, schema, signal, limit = maxResponseBytes) {
20
+ const reader = response.body?.getReader();
21
+ if (!reader)
22
+ throw new GmailProviderError('provider_invalid_response');
23
+ const chunks = [];
24
+ let bytes = 0;
25
+ try {
26
+ for (;;) {
27
+ const chunk = await reader.read();
28
+ if (chunk.done)
29
+ break;
30
+ bytes += chunk.value.length;
31
+ if (bytes > limit)
32
+ throw new GmailProviderError('provider_content_too_large');
33
+ chunks.push(chunk.value);
34
+ }
35
+ return schema.parse(JSON.parse(Buffer.concat(chunks).toString('utf8')));
36
+ }
37
+ catch (error) {
38
+ if (error instanceof GmailProviderError)
39
+ throw error;
40
+ if (signal.aborted)
41
+ throw new GmailProviderError('provider_unavailable', true);
42
+ // Provider bodies, URLs, and schema errors may carry mailbox data.
43
+ throw new GmailProviderError('provider_invalid_response');
44
+ }
45
+ finally {
46
+ await reader.cancel().catch(() => { });
47
+ reader.releaseLock();
48
+ }
49
+ }
50
+ export async function gmailFailure(response, signal, mailboxRequest = false) {
51
+ const body = await readResponse(response, apiError, signal, 64 * 1024).catch(() => undefined);
52
+ if (signal.aborted)
53
+ throw new GmailProviderError('provider_unavailable', true);
54
+ const code = body?.error.code;
55
+ if (response.status === 404 && mailboxRequest && code === 404)
56
+ return 'gmail_not_found';
57
+ if (response.status === 404 || response.status === 424 || code === 'invalid_credentials')
58
+ throw new GmailProviderError('provider_connection_unavailable');
59
+ if (response.status === 401 ||
60
+ (mailboxRequest &&
61
+ response.status === 403 &&
62
+ body?.error.errors.some(({ reason }) => reason === 'insufficientPermissions')))
63
+ throw new GmailProviderError('provider_unauthorized');
64
+ if (response.status === 429 ||
65
+ body?.error.errors.some(({ reason }) => ['rateLimitExceeded', 'userRateLimitExceeded'].includes(reason)))
66
+ throw new GmailProviderError('provider_rate_limited', true);
67
+ if (response.status === 403)
68
+ throw new GmailProviderError('provider_forbidden');
69
+ if (response.status >= 500)
70
+ throw new GmailProviderError('provider_unavailable', true);
71
+ throw new GmailProviderError('provider_invalid_request');
72
+ }
73
+ //# sourceMappingURL=gmail-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gmail-provider.js","sourceRoot":"","sources":["../src/gmail-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,mBAAmB,GAAG,sCAAsC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QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,qBAAqB;QACtF,MAAM,IAAI,kBAAkB,CAAC,iCAAiC,CAAC,CAAC;IAClE,IACE,QAAQ,CAAC,MAAM,KAAK,GAAG;QACvB,CAAC,cAAc;YACb,QAAQ,CAAC,MAAM,KAAK,GAAG;YACvB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,yBAAyB,CAAC,CAAC;QAEhF,MAAM,IAAI,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;IACxD,IACE,QAAQ,CAAC,MAAM,KAAK,GAAG;QACvB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CACrC,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAChE;QAED,MAAM,IAAI,kBAAkB,CAAC,uBAAuB,EAAE,IAAI,CAAC,CAAC;IAC9D,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG;QAAE,MAAM,IAAI,kBAAkB,CAAC,oBAAoB,CAAC,CAAC;IAChF,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG;QAAE,MAAM,IAAI,kBAAkB,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;IACvF,MAAM,IAAI,kBAAkB,CAAC,0BAA0B,CAAC,CAAC;AAC3D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
+ export type { InputSchema } from '@retainer/shared';
1
2
  export { nextOccurrence } from './cron.js';
2
3
  export { compareVersions, newestReleases, parseServerRange, satisfiesServerRange, } from './semver.js';
3
- import { type Actor } from '@retainer/shared';
4
+ import { type Actor, type InputSchema } from '@retainer/shared';
4
5
  import { z } from 'zod';
5
6
  /** The icons a sidebar link may name; the web app draws each. */
6
7
  export declare const SIDEBAR_ICONS: readonly ['app', 'calendar', 'clock', 'mail', 'chart', 'file', 'users'];
7
8
  export type SidebarIcon = (typeof SIDEBAR_ICONS)[number];
8
9
  /** The query parameter a sidebar link carries, naming the installation, for the app's sign-in. */
9
10
  export declare const SIDEBAR_INSTALLATION_PARAM = "retainer_installation";
10
- /** Capabilities a function may declare in `uses`; open for later ones (model calls spec 11). */
11
- export declare const EXTENSION_USES: readonly ['model'];
11
+ export declare const EXTENSION_USES: readonly ["model", "agent", "calendar_participants", "calendar_all"];
12
12
  export type ExtensionUse = (typeof EXTENSION_USES)[number];
13
13
  /**
14
14
  * What approving `model` means, in plain words, wherever access is shown
@@ -16,6 +16,11 @@ export type ExtensionUse = (typeof EXTENSION_USES)[number];
16
16
  * use, not a particular extent of it.
17
17
  */
18
18
  export declare const MODEL_USE_NOTICE = "When this extension uses a model, it sends the workspace data involved to Anthropic for processing.";
19
+ /**
20
+ * What approving `agent` means (agent spec §9.4): the agent's tool groups in
21
+ * plain words, then the model notice, since what it reads goes to Anthropic.
22
+ */
23
+ export declare function agentUseNotice(tools: readonly string[]): string;
19
24
  export declare const TAMLOOT_REGISTRATION_ID = "54326882-cc28-4983-a5fe-cf0298520b68";
20
25
  /**
21
26
  * The installation setting that chooses what happens when the source deletes
@@ -29,16 +34,8 @@ export declare function sourceDeletePolicy(manifest: Pick<ExtensionManifest, 'on
29
34
  * wherever they are chosen or shown.
30
35
  */
31
36
  export declare const POLICY_OPTION_LABELS: Record<string, Record<string, string>>;
32
- export type InputSchema = {
33
- type: 'object' | 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'null';
34
- description?: string;
35
- properties?: Record<string, InputSchema>;
36
- required?: string[];
37
- additionalProperties?: false;
38
- items?: InputSchema;
39
- maxLength?: number;
40
- maxItems?: number;
41
- };
37
+ /** Server-provided input for a record button. */
38
+ export declare const recordButtonInputSchema: InputSchema;
42
39
  export declare const bindingKeySchema: z.ZodString;
43
40
  export declare const functionSchema: z.ZodObject<{
44
41
  universalId: z.ZodUUID;
@@ -70,6 +67,10 @@ export declare const functionSchema: z.ZodObject<{
70
67
  workspace: "workspace";
71
68
  }>;
72
69
  outputSchema: z.ZodType<InputSchema, unknown, z.core.$ZodTypeInternals<InputSchema, unknown>>;
70
+ }, z.core.$strict>, z.ZodObject<{
71
+ kind: z.ZodLiteral<"recordButton">;
72
+ binding: z.ZodString;
73
+ label: z.ZodString;
73
74
  }, z.core.$strict>, z.ZodObject<{
74
75
  kind: z.ZodLiteral<"route">;
75
76
  route: z.ZodString;
@@ -99,8 +100,16 @@ export declare const functionSchema: z.ZodObject<{
99
100
  }>>>;
100
101
  mappedWrite: z.ZodOptional<z.ZodString>;
101
102
  uses: z.ZodOptional<z.ZodArray<z.ZodEnum<{
103
+ agent: "agent";
102
104
  model: "model";
103
105
  }>>>;
106
+ agent: z.ZodOptional<z.ZodObject<{
107
+ tools: z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
108
+ "retainer.read": "retainer.read";
109
+ "retainer.write": "retainer.write";
110
+ "web.search": "web.search";
111
+ }>, z.ZodType<`tools.${string}`, unknown, z.core.$ZodTypeInternals<`tools.${string}`, unknown>>]>>;
112
+ }, z.core.$strict>>;
104
113
  }, z.core.$strict>;
105
114
  declare const bindingSchema: z.ZodObject<{
106
115
  key: z.ZodString;
@@ -385,10 +394,11 @@ declare const manifestSchema: z.ZodObject<{
385
394
  keep: "keep";
386
395
  retract: "retract";
387
396
  }>;
388
- lastContact: z.ZodOptional<z.ZodObject<{
389
- functionIds: z.ZodArray<z.ZodUUID>;
390
- events: z.ZodString;
391
- destinations: z.ZodArray<z.ZodString>;
397
+ calendar: z.ZodOptional<z.ZodObject<{
398
+ qualify: z.ZodEnum<{
399
+ all: "all";
400
+ participants: "participants";
401
+ }>;
392
402
  }, z.core.$strict>>;
393
403
  source: z.ZodOptional<z.ZodObject<{
394
404
  provider: z.ZodString;
@@ -626,6 +636,10 @@ declare const manifestSchema: z.ZodObject<{
626
636
  workspace: "workspace";
627
637
  }>;
628
638
  outputSchema: z.ZodType<InputSchema, unknown, z.core.$ZodTypeInternals<InputSchema, unknown>>;
639
+ }, z.core.$strict>, z.ZodObject<{
640
+ kind: z.ZodLiteral<"recordButton">;
641
+ binding: z.ZodString;
642
+ label: z.ZodString;
629
643
  }, z.core.$strict>, z.ZodObject<{
630
644
  kind: z.ZodLiteral<"route">;
631
645
  route: z.ZodString;
@@ -655,8 +669,16 @@ declare const manifestSchema: z.ZodObject<{
655
669
  }>>>;
656
670
  mappedWrite: z.ZodOptional<z.ZodString>;
657
671
  uses: z.ZodOptional<z.ZodArray<z.ZodEnum<{
672
+ agent: "agent";
658
673
  model: "model";
659
674
  }>>>;
675
+ agent: z.ZodOptional<z.ZodObject<{
676
+ tools: z.ZodArray<z.ZodUnion<readonly [z.ZodEnum<{
677
+ "retainer.read": "retainer.read";
678
+ "retainer.write": "retainer.write";
679
+ "web.search": "web.search";
680
+ }>, z.ZodType<`tools.${string}`, unknown, z.core.$ZodTypeInternals<`tools.${string}`, unknown>>]>>;
681
+ }, z.core.$strict>>;
660
682
  }, z.core.$strict>>;
661
683
  oauth: z.ZodOptional<z.ZodObject<{
662
684
  verifierSetting: z.ZodString;
@@ -695,12 +717,19 @@ export declare function functionScopes(manifest: Pick<ExtensionManifest, 'scopes
695
717
  /** The capabilities a function's run may receive, before the installation's grant (spec 3.1). */
696
718
  export declare function functionUses(fn: Pick<FunctionDefinition, 'uses'>): ExtensionUse[];
697
719
  /** A release's uses: the union of its functions'. Approved with its access. */
698
- export declare function releaseUses(manifest: Pick<ExtensionManifest, 'functions'>): ExtensionUse[];
720
+ export declare function releaseUses(manifest: Pick<ExtensionManifest, 'functions' | 'calendar'>): ExtensionUse[];
699
721
  /** Tamloot can install with manual mappings when only its configure hook needs a model. */
700
722
  export declare function hasOptionalSetupModel(manifest: ExtensionManifest): boolean;
701
723
  /** Whether a release supports this server: inside its range, or in its exact list. */
702
724
  export declare function supportsServer(manifest: Pick<ExtensionManifest, 'serverRange' | 'serverVersions'>, serverVersion: string): boolean;
703
- export declare function defineExtension(value: unknown): ExtensionManifest;
725
+ /**
726
+ * Validates a release manifest. With `retained`, used for a catalog's older
727
+ * releases that installations still run, a release published before
728
+ * descriptions were required loads as it was published.
729
+ */
730
+ export declare function defineExtension(value: unknown, options?: {
731
+ retained?: boolean;
732
+ }): ExtensionManifest;
704
733
  export declare function defineFunction(value: unknown): {
705
734
  universalId: string;
706
735
  name: string;
@@ -724,6 +753,10 @@ export declare function defineFunction(value: unknown): {
724
753
  effect: "read" | "send" | "write";
725
754
  connection: "member" | "workspace";
726
755
  outputSchema: InputSchema;
756
+ } | {
757
+ kind: "recordButton";
758
+ binding: string;
759
+ label: string;
727
760
  } | {
728
761
  kind: "route";
729
762
  route: string;
@@ -746,7 +779,10 @@ export declare function defineFunction(value: unknown): {
746
779
  secrets?: string[] | undefined;
747
780
  scopes?: ("read" | "write")[] | undefined;
748
781
  mappedWrite?: string | undefined;
749
- uses?: "model"[] | undefined;
782
+ uses?: ("agent" | "model")[] | undefined;
783
+ agent?: {
784
+ tools: ("retainer.read" | "retainer.write" | "web.search" | `tools.${string}`)[];
785
+ } | undefined;
750
786
  };
751
787
  export declare function defineTool(value: unknown): {
752
788
  universalId: string;
@@ -757,7 +793,10 @@ export declare function defineTool(value: unknown): {
757
793
  secrets?: string[] | undefined;
758
794
  scopes?: ("read" | "write")[] | undefined;
759
795
  mappedWrite?: string | undefined;
760
- uses?: "model"[] | undefined;
796
+ uses?: ("agent" | "model")[] | undefined;
797
+ agent?: {
798
+ tools: ("retainer.read" | "retainer.write" | "web.search" | `tools.${string}`)[];
799
+ } | undefined;
761
800
  name: string;
762
801
  trigger: {
763
802
  kind: 'tool';
@@ -783,6 +822,8 @@ export type ExtensionInstallInput = {
783
822
  turnOn?: boolean;
784
823
  /** Set for an upgrade preview and commit. */
785
824
  installationId?: string;
825
+ /** Upgrade only if the approved destinations can be carried forward as-is. */
826
+ retainBindings?: boolean;
786
827
  /** Explicitly review a new credential/account connection on the current release. */
787
828
  reconnect?: boolean;
788
829
  /** Retire the old source binding and callback addresses; retained evidence keeps its namespace. */
@@ -884,9 +925,48 @@ export type ExtensionInstallation = {
884
925
  connectionId: string;
885
926
  at: string;
886
927
  } | null;
928
+ /**
929
+ * A newer release this server can run, as the automatic upgrade pass sees
930
+ * it. Absent when there is nothing newer to move to (or nothing to move:
931
+ * the installation is being set up, changing state or uninstalled).
932
+ */
933
+ availableUpgrade?: ExtensionAvailableUpgrade;
934
+ };
935
+ /**
936
+ * Why an upgrade waits for an admin. `release_changes`: the new release asks
937
+ * for something different (access, settings, schema, views, bindings,
938
+ * triggers or source). `schema_changes`, `view_changes`, `binding_changes`:
939
+ * the release is the same but applying it would change this workspace.
940
+ * `downgraded`: an admin moved back to an older release. `not_active`: the
941
+ * installation is off, so nothing upgrades it on its own.
942
+ * `previous_release_unavailable`: the installed release is gone from this
943
+ * server, so nothing can be compared. Any other value is the code of an
944
+ * error that stopped the upgrade (for example more access than allowed).
945
+ */
946
+ export type ExtensionUpgradeHoldReason = 'release_changes' | 'schema_changes' | 'view_changes' | 'binding_changes' | 'downgraded' | 'not_active' | 'previous_release_unavailable' | (string & {});
947
+ export type ExtensionAvailableUpgrade = {
948
+ version: string;
949
+ digest: string;
950
+ /**
951
+ * `automatic`: the background pass applies it within about a minute.
952
+ * `needs_approval`: an admin reviews and applies it.
953
+ */
954
+ mode: 'automatic' | 'needs_approval';
955
+ /** Why it needs approval, when known. Only with `needs_approval`. */
956
+ reason?: ExtensionUpgradeHoldReason;
887
957
  };
888
958
  export type ExtensionConnectionMethod = 'oauth' | 'key';
889
959
  /** A standalone app's sidebar link, for a member of a workspace where it is active (spec 8). */
960
+ export type ExtensionRecordButton = {
961
+ installationId: string;
962
+ functionId: string;
963
+ label: string;
964
+ };
965
+ export type ExtensionRecordButtonRun = {
966
+ id: string;
967
+ status: string;
968
+ code: string | null;
969
+ };
890
970
  export type ExtensionAppLink = {
891
971
  installationId: string;
892
972
  name: string;
@@ -895,7 +975,7 @@ export type ExtensionAppLink = {
895
975
  /** The app's page; it names the installation in `retainer_installation`. */
896
976
  url: string;
897
977
  };
898
- export * from './model.js';
978
+ export * from './agent.js';
899
979
  export * from './protocol.js';
900
980
  export * from './webhook.js';
901
981
  /** A person's credential boundary beneath the installation's approved workspace grant. */
@@ -973,7 +1053,6 @@ export type SourceTaskBatchResult = {
973
1053
  removed: number;
974
1054
  detached: number;
975
1055
  unchanged: number;
976
- erased: number;
977
1056
  hasMore: boolean;
978
1057
  checkpoint: number;
979
1058
  bindingStatus: 'ok' | 'degraded';