@astera-app/plugin-sdk 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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  `@astera-app/plugin-sdk` is versioned apart from the Astera app. [docs/plugins.md](https://github.com/parsingk/Astera/blob/main/docs/plugins.md)
4
4
  is the guide.
5
5
 
6
+ ## 0.2.0
7
+
8
+ - `onEvent` on a plugin: the `event` capability, which hands the plugin each of Astera's events in order, from where
9
+ it left off, and tries an event again when the handler throws.
10
+ - `defineNotificationProvider` and its `send`: the `notification` capability, which hands the plugin each thing worth
11
+ telling a person (a question, a session waiting, a failed or finished Run, a usage limit), worded by Astera in the
12
+ person's language. `NOTIFICATION_KINDS` lists the kinds, for a provider's setting of the ones it leaves out.
13
+ - `defineJobSourceProvider` and its `listItems`, `getItem` and `buildJobContext`, with the types they answer
14
+ (`JobSourceItem`, `JobSourcePage`, `JobSourceItemDetail`, `JobSourceContext`): the `job-source` capability, from
15
+ which a person, the `astera sources` commands and MCP clients pick a ticket to make a Job from. The Job is named by
16
+ the first line of the context's `objective`, so a provider starts it with the item's title.
17
+ - `defineCompletionCheckProvider` and its `runCheck`, with the types it is asked with and answers
18
+ (`CompletionCheckInput`, `CompletionCheckResult`, `CompletionCheckDiagnostic`): the `completion-check` capability,
19
+ which a Task names among its checks as `plugin:<id>`. Its `failed` goes to the Task's repair loop with its findings
20
+ (Astera keeps the first 20; a check that found more sends 20 and its own `diagnosticsTotal`); its `error` is asked
21
+ once more, then put to a person.
22
+ - In a handler (`onEvent`, `send`, `listItems`, `getItem`, `buildJobContext`, `runCheck`), `ctx.signal` is that call's:
23
+ it also aborts when Astera stops waiting for the call, so a handler can stop the work it started.
24
+
25
+ All five need Astera 1.4.14 or later. The plugin SDK needs `@astera-app/client` 0.2.0 or later, whose events include the
26
+ session events.
27
+
6
28
  ## 0.1.0
7
29
 
8
30
  The first release on npm: `definePlugin` and the types of the plugin context, for Plugin API 1, which Astera 1.4.12
package/README.md CHANGED
@@ -26,7 +26,17 @@ export default definePlugin({
26
26
 
27
27
  A plugin is a folder with a `package.json` whose `astera` field names its entry file, the Plugin API it is written for
28
28
  (`"1"`) and the permissions it asks for. `ctx.astera` is a client from `@astera-app/client`, answered within the
29
- permissions the person granted.
29
+ permissions the person granted. A plugin that names the `event` capability gets each of Astera's events, in order, in
30
+ its `onEvent` ([event plugins](https://github.com/parsingk/Astera/blob/main/docs/plugins.md#event-plugins)), and one
31
+ that names the `notification` capability gets each notification, worded for a person, in its `send`
32
+ ([notification plugins](https://github.com/parsingk/Astera/blob/main/docs/plugins.md#notification-plugins)), which
33
+ `defineNotificationProvider` types. One that names the `job-source` capability is asked for tickets a Job can be made
34
+ from, in its `listItems`, `getItem` and `buildJobContext`
35
+ ([job source plugins](https://github.com/parsingk/Astera/blob/main/docs/plugins.md#job-source-plugins)), which
36
+ `defineJobSourceProvider` types. One that names the `completion-check` capability is asked whether a Task's work
37
+ passes, in its `runCheck`
38
+ ([completion check plugins](https://github.com/parsingk/Astera/blob/main/docs/plugins.md#completion-check-plugins)),
39
+ which `defineCompletionCheckProvider` types.
30
40
 
31
41
  Plugins run trusted code on the person's machine: a plugin can do anything they can, and its permissions limit only
32
42
  what it asks Astera for.
@@ -1,4 +1,4 @@
1
- import type { AsteraClient } from '@astera-app/client';
1
+ import type { AsteraClient, AsteraEvent, EventGap } from '@astera-app/client';
2
2
  /** The Plugin API this package is written for: the manifest's `astera.apiVersion` (spec §28). */
3
3
  export declare const PLUGIN_API_VERSION = "1";
4
4
  /** Lines to the plugin's log, which `astera plugins logs` reads. Anything the plugin prints goes there too. */
@@ -31,7 +31,9 @@ export interface PluginContext {
31
31
  /** The permissions the person granted, a subset of those the manifest asks for. */
32
32
  permissions: readonly string[];
33
33
  log: PluginLog;
34
- /** Aborted when Astera stops the plugin: disabled, removed, updated, or the Host leaving. */
34
+ /** Aborted when Astera stops the plugin: disabled, removed, updated, or the Host leaving. In a handler (`onEvent`,
35
+ * `send`, `listItems`, `getItem`, `buildJobContext`, `runCheck`) it is that call's: it also aborts when Astera stops
36
+ * waiting for the call (30 seconds for an event or a notification, 15 for a job source, 30 minutes for a check). */
35
37
  signal: AbortSignal;
36
38
  }
37
39
  export interface PluginDefinition {
@@ -39,6 +41,155 @@ export interface PluginDefinition {
39
41
  activate?(ctx: PluginContext): void | Promise<void>;
40
42
  /** Called before the plugin is stopped, with a few seconds to finish. */
41
43
  deactivate?(): void | Promise<void>;
44
+ /** The `event` capability (`astera.capabilities: ["event"]`, with the `events.subscribe` permission): each of
45
+ * Astera's events, in order, one at a time, from where this plugin left off, once `activate` has resolved. A
46
+ * `{ type: 'gap' }` first means events were lost before the next one. Throw or reject to have the same event handed
47
+ * over again (after 1 s, doubling to 5 min, for an hour). It must settle within 30 s: past that the call's
48
+ * `ctx.signal` aborts, and a handler that does not stop runs beside the event's next try. An event can come twice: `event.id` never repeats, so drop one
49
+ * you have seen. A property rather than a method, so a handler that takes only `AsteraEvent` does not typecheck:
50
+ * it would throw on a gap. */
51
+ onEvent?: (event: AsteraEvent | EventGap, ctx: PluginContext) => void | Promise<void>;
42
52
  }
43
53
  /** The plugin an entry file exports as its default. */
44
54
  export declare function definePlugin<T extends PluginDefinition>(definition: T): T;
55
+ /** The kinds of notification Astera sends a `notification` plugin, most pressing first. A provider offers a setting
56
+ * for the ones it leaves out; Astera sends all of them. Astera's own copy of this list is checked against this one. */
57
+ export declare const NOTIFICATION_KINDS: readonly ['question.created', 'session.input_needed', 'run.failed', 'completion.exhausted', 'session.limit_waiting', 'run.completed', 'session.account_switched'];
58
+ export type NotificationKind = (typeof NOTIFICATION_KINDS)[number];
59
+ /** How much it matters: `action` waits on the person, `error` failed, `warning` stopped for now, `info` went on. */
60
+ export type NotificationLevel = 'action' | 'error' | 'warning' | 'info';
61
+ /** Something worth telling a person, already worded by Astera in the language the app is set to: post `title` and
62
+ * `body` as they are. */
63
+ export interface AsteraNotification {
64
+ /** The event's id: a notification can come twice, so drop one you have seen. */
65
+ readonly id: string;
66
+ /** The event's type. A later Astera may send a kind this list does not name yet: post it by its title and body. */
67
+ readonly kind: NotificationKind | (string & {});
68
+ /** How much it matters. A later Astera may add a level: post it as the nearest one you know. */
69
+ readonly level: NotificationLevel | (string & {});
70
+ /** What it is about: a Job's objective, or a session's title. */
71
+ readonly title: string;
72
+ /** One sentence. */
73
+ readonly body: string;
74
+ readonly occurredAt: string;
75
+ /** The whole event, for its ids and detail. */
76
+ readonly event: AsteraEvent;
77
+ }
78
+ /** A plugin of the `notification` capability (`astera.capabilities: ["notification"]`, with the `events.subscribe`
79
+ * permission). */
80
+ export interface NotificationProvider extends PluginDefinition {
81
+ /** Each notification, in order, one at a time, once `activate` has resolved. Throw or reject to have it sent again
82
+ * (after 1 s, doubling to 5 min, for an hour); it must settle within 30 s. A notification older than an hour when
83
+ * its turn comes is not sent. */
84
+ send: (notification: AsteraNotification, ctx: PluginContext) => void | Promise<void>;
85
+ }
86
+ /** The provider an entry file exports as its default. */
87
+ export declare function defineNotificationProvider<T extends NotificationProvider>(provider: T): T;
88
+ /** What `listItems` is asked: the person's search, and the cursor of the page before when there is one. */
89
+ export interface JobSourceQuery {
90
+ query?: string;
91
+ cursor?: string;
92
+ }
93
+ /** One item of a job source: a ticket, an issue. Astera refuses an item whose `id` is not 1 to 200 characters with no
94
+ * control characters (it is your own, opaque id, `ENG-123` say), cuts `title` at 300 characters, `status` at 100 and
95
+ * `summary` at 1,000, and keeps `url` only when it is http or https. */
96
+ export interface JobSourceItem {
97
+ id: string;
98
+ title: string;
99
+ status?: string;
100
+ url?: string;
101
+ summary?: string;
102
+ }
103
+ /** A page of items: at most 100 are kept, and `nextCursor` (at most 2,000 characters) is handed back to `listItems`
104
+ * for the next page. No `nextCursor` means this is the last page. */
105
+ export interface JobSourcePage {
106
+ items: JobSourceItem[];
107
+ nextCursor?: string;
108
+ }
109
+ /** One item read whole: `body` cut at 20,000 characters, and at most 50 `fields` of short text (100 characters a name,
110
+ * 1,000 a value), shown beside it. */
111
+ export interface JobSourceItemDetail extends JobSourceItem {
112
+ body?: string;
113
+ fields?: Record<string, string>;
114
+ }
115
+ /** What a Job made from an item is to do. Astera writes the Job's objective itself: a first line naming
116
+ * `sourceLabel` (`Linear ENG-123`, at most 200 characters) and `sourceUrl`, then your `objective` (at most 20,000), each
117
+ * `evidence` entry under its label (at most 20 entries, 20,000 characters each and 100,000 in all) and the `metadata`
118
+ * (at most 50 pairs), quoted as data the Job's agent does not take orders from. The Job keeps the item as its source,
119
+ * and is named, in the app, the CLI and notifications, by the first line of your `objective` (at most 300 characters):
120
+ * start it with the item's title. */
121
+ export interface JobSourceContext {
122
+ objective: string;
123
+ sourceLabel: string;
124
+ sourceUrl?: string;
125
+ evidence?: Array<{
126
+ label: string;
127
+ content: string;
128
+ }>;
129
+ metadata?: Record<string, string>;
130
+ }
131
+ /** A plugin of the `job-source` capability (`astera.capabilities: ["job-source"]`, with no permission): Astera asks it
132
+ * for items when a person, the `astera sources` commands or an MCP client looks for a ticket to make a Job from. Each
133
+ * call has 15 seconds. Throw or reject to say why there is no answer ("401 Unauthorized"): the person reads that
134
+ * sentence, and Astera tries nothing again. A plugin missing any of the three does not start. */
135
+ export interface JobSourceProvider extends PluginDefinition {
136
+ /** A page of items, searched with `input.query`, from `input.cursor` on. */
137
+ listItems: (input: JobSourceQuery, ctx: PluginContext) => JobSourcePage | Promise<JobSourcePage>;
138
+ /** One item read whole, by the id `listItems` gave it. Throw for an id you do not know. */
139
+ getItem: (id: string, ctx: PluginContext) => JobSourceItemDetail | Promise<JobSourceItemDetail>;
140
+ /** What a Job made from the item is to do, by the id `listItems` gave it. */
141
+ buildJobContext: (id: string, ctx: PluginContext) => JobSourceContext | Promise<JobSourceContext>;
142
+ }
143
+ /** The provider an entry file exports as its default. */
144
+ export declare function defineJobSourceProvider<T extends JobSourceProvider>(provider: T): T;
145
+ /** What a completion check is asked about: the Task and the folder its checks run in. `root` is the Task's worktree, or
146
+ * the project folder; `base` is the commit the Task's work started from and `head` the one its last attempt reached,
147
+ * when Astera recorded them, so a check can look at what the Task changed. `branch` is not sent by this Astera: a
148
+ * check that needs it asks git in `root`. A check configured per project reads the project's own files under `root`;
149
+ * the plugin's settings are the rest of its configuration. */
150
+ export interface CompletionCheckInput {
151
+ projectId?: string;
152
+ jobId: string;
153
+ runId: string;
154
+ taskId: string;
155
+ task: {
156
+ title: string;
157
+ };
158
+ workspace: {
159
+ root: string;
160
+ base?: string;
161
+ head?: string;
162
+ branch?: string;
163
+ };
164
+ }
165
+ /** One finding. Astera keeps a `message` (required) of up to 1,000 characters, a `file` of up to 500, a `line` that is a
166
+ * positive integer and a `severity` that is one of the two, and drops what is not. */
167
+ export interface CompletionCheckDiagnostic {
168
+ file?: string;
169
+ line?: number;
170
+ message: string;
171
+ severity?: 'error' | 'warning';
172
+ }
173
+ /** A check's answer. `passed` lets the Task's next check run. `failed` is the code's fault: the Task's repair request
174
+ * carries your summary, your first 20 findings as `file:line message` and your link, and the Task fails where its Job
175
+ * repairs nothing. `error` says the check could not be made (a service down, a missing token): Astera asks once more,
176
+ * then puts it to a person, and no repair is spent on it. `summary` is cut at 1,000 characters (the status word when
177
+ * there is none), `diagnostics` keep the first 20 (Astera counts the rest, and keeps none of a `passed` check's: give
178
+ * the whole report as `externalUrl`), and `externalUrl` is kept when it is http or https within 2,048. */
179
+ export interface CompletionCheckResult {
180
+ status: 'passed' | 'failed' | 'error';
181
+ summary?: string;
182
+ diagnostics?: CompletionCheckDiagnostic[];
183
+ /** How many findings there are, when you send fewer: send the first 20 and the count, not thousands to be cut. */
184
+ diagnosticsTotal?: number;
185
+ externalUrl?: string;
186
+ }
187
+ /** A plugin of the `completion-check` capability (`astera.capabilities: ["completion-check"]`, with no permission):
188
+ * Astera asks it when a Task whose checks name `plugin:<its id>` is done, in the order the Task lists its checks. A
189
+ * call has 30 minutes. Throw or reject to say the check could not be made: it counts as `error`, with your message. A
190
+ * plugin missing `runCheck` does not start. */
191
+ export interface CompletionCheckProvider extends PluginDefinition {
192
+ runCheck: (input: CompletionCheckInput, ctx: PluginContext) => CompletionCheckResult | Promise<CompletionCheckResult>;
193
+ }
194
+ /** The provider an entry file exports as its default. */
195
+ export declare function defineCompletionCheckProvider<T extends CompletionCheckProvider>(provider: T): T;
package/dist/cjs/index.js CHANGED
@@ -1,10 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PLUGIN_API_VERSION = void 0;
3
+ exports.NOTIFICATION_KINDS = exports.PLUGIN_API_VERSION = void 0;
4
4
  exports.definePlugin = definePlugin;
5
+ exports.defineNotificationProvider = defineNotificationProvider;
6
+ exports.defineJobSourceProvider = defineJobSourceProvider;
7
+ exports.defineCompletionCheckProvider = defineCompletionCheckProvider;
5
8
  /** The Plugin API this package is written for: the manifest's `astera.apiVersion` (spec §28). */
6
9
  exports.PLUGIN_API_VERSION = '1';
7
10
  /** The plugin an entry file exports as its default. */
8
11
  function definePlugin(definition) {
9
12
  return definition;
10
13
  }
14
+ /** The kinds of notification Astera sends a `notification` plugin, most pressing first. A provider offers a setting
15
+ * for the ones it leaves out; Astera sends all of them. Astera's own copy of this list is checked against this one. */
16
+ exports.NOTIFICATION_KINDS = [
17
+ 'question.created',
18
+ 'session.input_needed',
19
+ 'run.failed',
20
+ 'completion.exhausted',
21
+ 'session.limit_waiting',
22
+ 'run.completed',
23
+ 'session.account_switched'
24
+ ];
25
+ /** The provider an entry file exports as its default. */
26
+ function defineNotificationProvider(provider) {
27
+ return provider;
28
+ }
29
+ /** The provider an entry file exports as its default. */
30
+ function defineJobSourceProvider(provider) {
31
+ return provider;
32
+ }
33
+ /** The provider an entry file exports as its default. */
34
+ function defineCompletionCheckProvider(provider) {
35
+ return provider;
36
+ }
@@ -1,4 +1,4 @@
1
- import type { AsteraClient } from '@astera-app/client';
1
+ import type { AsteraClient, AsteraEvent, EventGap } from '@astera-app/client';
2
2
  /** The Plugin API this package is written for: the manifest's `astera.apiVersion` (spec §28). */
3
3
  export declare const PLUGIN_API_VERSION = "1";
4
4
  /** Lines to the plugin's log, which `astera plugins logs` reads. Anything the plugin prints goes there too. */
@@ -31,7 +31,9 @@ export interface PluginContext {
31
31
  /** The permissions the person granted, a subset of those the manifest asks for. */
32
32
  permissions: readonly string[];
33
33
  log: PluginLog;
34
- /** Aborted when Astera stops the plugin: disabled, removed, updated, or the Host leaving. */
34
+ /** Aborted when Astera stops the plugin: disabled, removed, updated, or the Host leaving. In a handler (`onEvent`,
35
+ * `send`, `listItems`, `getItem`, `buildJobContext`, `runCheck`) it is that call's: it also aborts when Astera stops
36
+ * waiting for the call (30 seconds for an event or a notification, 15 for a job source, 30 minutes for a check). */
35
37
  signal: AbortSignal;
36
38
  }
37
39
  export interface PluginDefinition {
@@ -39,6 +41,155 @@ export interface PluginDefinition {
39
41
  activate?(ctx: PluginContext): void | Promise<void>;
40
42
  /** Called before the plugin is stopped, with a few seconds to finish. */
41
43
  deactivate?(): void | Promise<void>;
44
+ /** The `event` capability (`astera.capabilities: ["event"]`, with the `events.subscribe` permission): each of
45
+ * Astera's events, in order, one at a time, from where this plugin left off, once `activate` has resolved. A
46
+ * `{ type: 'gap' }` first means events were lost before the next one. Throw or reject to have the same event handed
47
+ * over again (after 1 s, doubling to 5 min, for an hour). It must settle within 30 s: past that the call's
48
+ * `ctx.signal` aborts, and a handler that does not stop runs beside the event's next try. An event can come twice: `event.id` never repeats, so drop one
49
+ * you have seen. A property rather than a method, so a handler that takes only `AsteraEvent` does not typecheck:
50
+ * it would throw on a gap. */
51
+ onEvent?: (event: AsteraEvent | EventGap, ctx: PluginContext) => void | Promise<void>;
42
52
  }
43
53
  /** The plugin an entry file exports as its default. */
44
54
  export declare function definePlugin<T extends PluginDefinition>(definition: T): T;
55
+ /** The kinds of notification Astera sends a `notification` plugin, most pressing first. A provider offers a setting
56
+ * for the ones it leaves out; Astera sends all of them. Astera's own copy of this list is checked against this one. */
57
+ export declare const NOTIFICATION_KINDS: readonly ['question.created', 'session.input_needed', 'run.failed', 'completion.exhausted', 'session.limit_waiting', 'run.completed', 'session.account_switched'];
58
+ export type NotificationKind = (typeof NOTIFICATION_KINDS)[number];
59
+ /** How much it matters: `action` waits on the person, `error` failed, `warning` stopped for now, `info` went on. */
60
+ export type NotificationLevel = 'action' | 'error' | 'warning' | 'info';
61
+ /** Something worth telling a person, already worded by Astera in the language the app is set to: post `title` and
62
+ * `body` as they are. */
63
+ export interface AsteraNotification {
64
+ /** The event's id: a notification can come twice, so drop one you have seen. */
65
+ readonly id: string;
66
+ /** The event's type. A later Astera may send a kind this list does not name yet: post it by its title and body. */
67
+ readonly kind: NotificationKind | (string & {});
68
+ /** How much it matters. A later Astera may add a level: post it as the nearest one you know. */
69
+ readonly level: NotificationLevel | (string & {});
70
+ /** What it is about: a Job's objective, or a session's title. */
71
+ readonly title: string;
72
+ /** One sentence. */
73
+ readonly body: string;
74
+ readonly occurredAt: string;
75
+ /** The whole event, for its ids and detail. */
76
+ readonly event: AsteraEvent;
77
+ }
78
+ /** A plugin of the `notification` capability (`astera.capabilities: ["notification"]`, with the `events.subscribe`
79
+ * permission). */
80
+ export interface NotificationProvider extends PluginDefinition {
81
+ /** Each notification, in order, one at a time, once `activate` has resolved. Throw or reject to have it sent again
82
+ * (after 1 s, doubling to 5 min, for an hour); it must settle within 30 s. A notification older than an hour when
83
+ * its turn comes is not sent. */
84
+ send: (notification: AsteraNotification, ctx: PluginContext) => void | Promise<void>;
85
+ }
86
+ /** The provider an entry file exports as its default. */
87
+ export declare function defineNotificationProvider<T extends NotificationProvider>(provider: T): T;
88
+ /** What `listItems` is asked: the person's search, and the cursor of the page before when there is one. */
89
+ export interface JobSourceQuery {
90
+ query?: string;
91
+ cursor?: string;
92
+ }
93
+ /** One item of a job source: a ticket, an issue. Astera refuses an item whose `id` is not 1 to 200 characters with no
94
+ * control characters (it is your own, opaque id, `ENG-123` say), cuts `title` at 300 characters, `status` at 100 and
95
+ * `summary` at 1,000, and keeps `url` only when it is http or https. */
96
+ export interface JobSourceItem {
97
+ id: string;
98
+ title: string;
99
+ status?: string;
100
+ url?: string;
101
+ summary?: string;
102
+ }
103
+ /** A page of items: at most 100 are kept, and `nextCursor` (at most 2,000 characters) is handed back to `listItems`
104
+ * for the next page. No `nextCursor` means this is the last page. */
105
+ export interface JobSourcePage {
106
+ items: JobSourceItem[];
107
+ nextCursor?: string;
108
+ }
109
+ /** One item read whole: `body` cut at 20,000 characters, and at most 50 `fields` of short text (100 characters a name,
110
+ * 1,000 a value), shown beside it. */
111
+ export interface JobSourceItemDetail extends JobSourceItem {
112
+ body?: string;
113
+ fields?: Record<string, string>;
114
+ }
115
+ /** What a Job made from an item is to do. Astera writes the Job's objective itself: a first line naming
116
+ * `sourceLabel` (`Linear ENG-123`, at most 200 characters) and `sourceUrl`, then your `objective` (at most 20,000), each
117
+ * `evidence` entry under its label (at most 20 entries, 20,000 characters each and 100,000 in all) and the `metadata`
118
+ * (at most 50 pairs), quoted as data the Job's agent does not take orders from. The Job keeps the item as its source,
119
+ * and is named, in the app, the CLI and notifications, by the first line of your `objective` (at most 300 characters):
120
+ * start it with the item's title. */
121
+ export interface JobSourceContext {
122
+ objective: string;
123
+ sourceLabel: string;
124
+ sourceUrl?: string;
125
+ evidence?: Array<{
126
+ label: string;
127
+ content: string;
128
+ }>;
129
+ metadata?: Record<string, string>;
130
+ }
131
+ /** A plugin of the `job-source` capability (`astera.capabilities: ["job-source"]`, with no permission): Astera asks it
132
+ * for items when a person, the `astera sources` commands or an MCP client looks for a ticket to make a Job from. Each
133
+ * call has 15 seconds. Throw or reject to say why there is no answer ("401 Unauthorized"): the person reads that
134
+ * sentence, and Astera tries nothing again. A plugin missing any of the three does not start. */
135
+ export interface JobSourceProvider extends PluginDefinition {
136
+ /** A page of items, searched with `input.query`, from `input.cursor` on. */
137
+ listItems: (input: JobSourceQuery, ctx: PluginContext) => JobSourcePage | Promise<JobSourcePage>;
138
+ /** One item read whole, by the id `listItems` gave it. Throw for an id you do not know. */
139
+ getItem: (id: string, ctx: PluginContext) => JobSourceItemDetail | Promise<JobSourceItemDetail>;
140
+ /** What a Job made from the item is to do, by the id `listItems` gave it. */
141
+ buildJobContext: (id: string, ctx: PluginContext) => JobSourceContext | Promise<JobSourceContext>;
142
+ }
143
+ /** The provider an entry file exports as its default. */
144
+ export declare function defineJobSourceProvider<T extends JobSourceProvider>(provider: T): T;
145
+ /** What a completion check is asked about: the Task and the folder its checks run in. `root` is the Task's worktree, or
146
+ * the project folder; `base` is the commit the Task's work started from and `head` the one its last attempt reached,
147
+ * when Astera recorded them, so a check can look at what the Task changed. `branch` is not sent by this Astera: a
148
+ * check that needs it asks git in `root`. A check configured per project reads the project's own files under `root`;
149
+ * the plugin's settings are the rest of its configuration. */
150
+ export interface CompletionCheckInput {
151
+ projectId?: string;
152
+ jobId: string;
153
+ runId: string;
154
+ taskId: string;
155
+ task: {
156
+ title: string;
157
+ };
158
+ workspace: {
159
+ root: string;
160
+ base?: string;
161
+ head?: string;
162
+ branch?: string;
163
+ };
164
+ }
165
+ /** One finding. Astera keeps a `message` (required) of up to 1,000 characters, a `file` of up to 500, a `line` that is a
166
+ * positive integer and a `severity` that is one of the two, and drops what is not. */
167
+ export interface CompletionCheckDiagnostic {
168
+ file?: string;
169
+ line?: number;
170
+ message: string;
171
+ severity?: 'error' | 'warning';
172
+ }
173
+ /** A check's answer. `passed` lets the Task's next check run. `failed` is the code's fault: the Task's repair request
174
+ * carries your summary, your first 20 findings as `file:line message` and your link, and the Task fails where its Job
175
+ * repairs nothing. `error` says the check could not be made (a service down, a missing token): Astera asks once more,
176
+ * then puts it to a person, and no repair is spent on it. `summary` is cut at 1,000 characters (the status word when
177
+ * there is none), `diagnostics` keep the first 20 (Astera counts the rest, and keeps none of a `passed` check's: give
178
+ * the whole report as `externalUrl`), and `externalUrl` is kept when it is http or https within 2,048. */
179
+ export interface CompletionCheckResult {
180
+ status: 'passed' | 'failed' | 'error';
181
+ summary?: string;
182
+ diagnostics?: CompletionCheckDiagnostic[];
183
+ /** How many findings there are, when you send fewer: send the first 20 and the count, not thousands to be cut. */
184
+ diagnosticsTotal?: number;
185
+ externalUrl?: string;
186
+ }
187
+ /** A plugin of the `completion-check` capability (`astera.capabilities: ["completion-check"]`, with no permission):
188
+ * Astera asks it when a Task whose checks name `plugin:<its id>` is done, in the order the Task lists its checks. A
189
+ * call has 30 minutes. Throw or reject to say the check could not be made: it counts as `error`, with your message. A
190
+ * plugin missing `runCheck` does not start. */
191
+ export interface CompletionCheckProvider extends PluginDefinition {
192
+ runCheck: (input: CompletionCheckInput, ctx: PluginContext) => CompletionCheckResult | Promise<CompletionCheckResult>;
193
+ }
194
+ /** The provider an entry file exports as its default. */
195
+ export declare function defineCompletionCheckProvider<T extends CompletionCheckProvider>(provider: T): T;
package/dist/esm/index.js CHANGED
@@ -4,3 +4,26 @@ export const PLUGIN_API_VERSION = '1';
4
4
  export function definePlugin(definition) {
5
5
  return definition;
6
6
  }
7
+ /** The kinds of notification Astera sends a `notification` plugin, most pressing first. A provider offers a setting
8
+ * for the ones it leaves out; Astera sends all of them. Astera's own copy of this list is checked against this one. */
9
+ export const NOTIFICATION_KINDS = [
10
+ 'question.created',
11
+ 'session.input_needed',
12
+ 'run.failed',
13
+ 'completion.exhausted',
14
+ 'session.limit_waiting',
15
+ 'run.completed',
16
+ 'session.account_switched'
17
+ ];
18
+ /** The provider an entry file exports as its default. */
19
+ export function defineNotificationProvider(provider) {
20
+ return provider;
21
+ }
22
+ /** The provider an entry file exports as its default. */
23
+ export function defineJobSourceProvider(provider) {
24
+ return provider;
25
+ }
26
+ /** The provider an entry file exports as its default. */
27
+ export function defineCompletionCheckProvider(provider) {
28
+ return provider;
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astera-app/plugin-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Write Astera plugins: definePlugin and the plugin context's types.",
5
5
  "keywords": [
6
6
  "astera",
@@ -43,7 +43,7 @@
43
43
  "prepublishOnly": "node ../../scripts/build-packages.mjs"
44
44
  },
45
45
  "peerDependencies": {
46
- "@astera-app/client": ">=0.1.0"
46
+ "@astera-app/client": ">=0.2.0 <1"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"