@ubiquity-os/plugin-sdk 3.7.0 → 3.8.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/README.md CHANGED
@@ -15,10 +15,16 @@ The `createActionsPlugin` function allows users to create plugins that will be a
15
15
 
16
16
  ### `createPlugin`
17
17
 
18
- The `createPlugin` function enables users to create a plugin that will run on Cloudflare Workers environment.
18
+ The `createPlugin` function enables users to create a plugin that will run on Cloudflare Workers environment. It accepts a handler and a manifest.
19
19
 
20
20
  ### `postComment`
21
21
 
22
+ Use `context.commentHandler.postComment` to write or update a comment on the triggering issue or pull request.
23
+
24
+ ```typescript
25
+ await context.commentHandler.postComment(context, context.logger.ok("Done"));
26
+ ```
27
+
22
28
  ### `callLlm`
23
29
 
24
30
  The `callLlm` function allows plugins to securely call the ai.ubq.fi LLM endpoint using inherited GitHub authentication.
@@ -26,33 +32,43 @@ The `callLlm` function allows plugins to securely call the ai.ubq.fi LLM endpoin
26
32
  #### Usage
27
33
 
28
34
  ```typescript
29
- import { PluginInput, createPlugin, callLlm } from '@ubiquity-os/plugin-sdk';
30
-
31
- export default createPlugin({
32
- async onCommand(input: PluginInput) {
33
- // Non-streaming: resolves to ChatCompletion.
34
- const result = await callLlm(
35
- {
36
- messages: [{ role: 'user', content: 'Hello, world!' }]
37
- },
38
- input
39
- );
40
-
41
- // Streaming: returns AsyncIterable<ChatCompletionChunk>.
42
- const stream = await callLlm(
43
- {
44
- messages: [{ role: 'user', content: 'Hello, world!' }],
45
- stream: true
46
- },
47
- input
48
- );
49
- for await (const chunk of stream) {
50
- const delta = chunk.choices?.[0]?.delta?.content ?? '';
51
- // handle delta
52
- }
53
- return { success: true };
35
+ import { createPlugin, callLlm, type Manifest } from '@ubiquity-os/plugin-sdk';
36
+
37
+ const manifest: Manifest = {
38
+ name: "llm-plugin",
39
+ short_name: "llm",
40
+ description: "LLM demo",
41
+ commands: {
42
+ llm: {
43
+ description: "Query the LLM",
44
+ "ubiquity:example": "/llm hello",
45
+ },
46
+ },
47
+ };
48
+
49
+ export default createPlugin(async (context) => {
50
+ // Non-streaming: resolves to ChatCompletion.
51
+ const result = await callLlm(
52
+ {
53
+ messages: [{ role: "user", content: "Hello, world!" }],
54
+ },
55
+ context
56
+ );
57
+
58
+ // Streaming: returns AsyncIterable<ChatCompletionChunk>.
59
+ const stream = await callLlm(
60
+ {
61
+ messages: [{ role: "user", content: "Hello, world!" }],
62
+ stream: true,
63
+ },
64
+ context
65
+ );
66
+ for await (const chunk of stream) {
67
+ const delta = chunk.choices?.[0]?.delta?.content ?? "";
68
+ // handle delta
54
69
  }
55
- });
70
+ return { success: true };
71
+ }, manifest);
56
72
  ```
57
73
 
58
74
  Automatically extracts `authToken`, `owner`, `repo` from input and passes to ai.ubq.fi with proper headers for secure, repo-scoped access.
@@ -11,7 +11,7 @@ import './octokit.mjs';
11
11
  import '@octokit/core/types';
12
12
  import '@octokit/plugin-paginate-graphql';
13
13
  import '@octokit/plugin-paginate-rest';
14
- import '@octokit/request-error';
14
+ import '@octokit/webhooks/node_modules/@octokit/request-error';
15
15
  import '@octokit/core';
16
16
 
17
17
  type GithubPlugin = {
@@ -125,8 +125,8 @@ declare class ConfigurationHandler {
125
125
  private _parseYaml;
126
126
  protected mergeConfigurations(configuration1: PluginConfiguration, configuration2: PluginConfiguration): PluginConfiguration;
127
127
  getManifest(plugin: GithubPlugin): Promise<{
128
- description?: string | undefined;
129
128
  skipBotEvents?: boolean | undefined;
129
+ description?: string | undefined;
130
130
  commands?: {
131
131
  [x: string]: {
132
132
  parameters?: {
@@ -11,7 +11,7 @@ import './octokit.js';
11
11
  import '@octokit/core/types';
12
12
  import '@octokit/plugin-paginate-graphql';
13
13
  import '@octokit/plugin-paginate-rest';
14
- import '@octokit/request-error';
14
+ import '@octokit/webhooks/node_modules/@octokit/request-error';
15
15
  import '@octokit/core';
16
16
 
17
17
  type GithubPlugin = {
@@ -125,8 +125,8 @@ declare class ConfigurationHandler {
125
125
  private _parseYaml;
126
126
  protected mergeConfigurations(configuration1: PluginConfiguration, configuration2: PluginConfiguration): PluginConfiguration;
127
127
  getManifest(plugin: GithubPlugin): Promise<{
128
- description?: string | undefined;
129
128
  skipBotEvents?: boolean | undefined;
129
+ description?: string | undefined;
130
130
  commands?: {
131
131
  [x: string]: {
132
132
  parameters?: {