@matatbread/matbot-core 0.2.0 → 0.2.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/package.json +2 -2
- package/src/index.ts +13 -3
- package/src/loader.ts +3 -3
- package/src/security/vault.ts +2 -2
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"node",
|
|
5
5
|
"browser"
|
|
6
6
|
],
|
|
7
|
-
"version": "0.2.
|
|
7
|
+
"version": "0.2.1",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=24.0.0"
|
|
10
10
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@matatbread/matbot-plugin-api": "^0.2.
|
|
38
|
+
"@matatbread/matbot-plugin-api": "^0.2.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"typescript": "^5.8.0"
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
export type * from './types.js';
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
2
|
+
// matbot's typed errors are duck-typed: factory `xError()` builders + `isXError()` brand guards are
|
|
3
|
+
// runtime values (re-exported here, since the `export type *` above would strip their value meaning),
|
|
4
|
+
// while the `XError` shapes are types (re-exported below). StoreQueryError is still a class value.
|
|
5
|
+
export {
|
|
6
|
+
missingSecretError, isMissingSecretError,
|
|
7
|
+
incompatibleRuntimeError, isIncompatibleRuntimeError,
|
|
8
|
+
notAPluginError, isNotAPluginError,
|
|
9
|
+
promptCancelledError, isPromptCancelledError,
|
|
10
|
+
StoreQueryError,
|
|
11
|
+
} from '@matatbread/matbot-plugin-api';
|
|
12
|
+
export type {
|
|
13
|
+
MissingSecretError, IncompatibleRuntimeError, NotAPluginError, PromptCancelledError, MatbotErrorKind,
|
|
14
|
+
} from '@matatbread/matbot-plugin-api';
|
|
5
15
|
export { applyCreateSecret } from '@matatbread/matbot-plugin-api';
|
|
6
16
|
// unifyServices is a runtime fn; the `export type *` above would otherwise strip its value meaning.
|
|
7
17
|
export { unifyServices } from '@matatbread/matbot-plugin-api';
|
package/src/loader.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MatbotPlugin, MatbotPluginSpec, MatbotMachine, PluginSource, Runtime } from './plugin.js';
|
|
2
2
|
import type { PromptFn } from './types.js';
|
|
3
|
-
import {
|
|
3
|
+
import { incompatibleRuntimeError, notAPluginError } from '@matatbread/matbot-plugin-api';
|
|
4
4
|
import { registerPlugin, setupPlugin, unloadPlugin } from './registry.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -124,7 +124,7 @@ export async function loadPlugins(
|
|
|
124
124
|
const runtimes = declared[i];
|
|
125
125
|
if (runtimes !== undefined && runtimes.length > 0 && !runtimes.includes(CURRENT_RUNTIME)) {
|
|
126
126
|
if (onLoadError === 'throw') {
|
|
127
|
-
throw
|
|
127
|
+
throw incompatibleRuntimeError(spec, runtimes, CURRENT_RUNTIME);
|
|
128
128
|
}
|
|
129
129
|
console.warn(`[matbot] Skipping plugin "${spec}": declares matbotRuntime [${runtimes.join(', ')}], host runtime is "${CURRENT_RUNTIME}".`);
|
|
130
130
|
continue;
|
|
@@ -152,7 +152,7 @@ export async function loadPlugins(
|
|
|
152
152
|
// permanently-not-a-plugin: it throws NotAPluginError so the `add` flow can roll back the config
|
|
153
153
|
// write, where an import failure may be a fixable typo and is left in config.
|
|
154
154
|
const failLoad = (spec: string, reason: string, kind: 'load' | 'shape' = 'load'): void => {
|
|
155
|
-
if (onLoadError === 'throw') throw kind === 'shape' ?
|
|
155
|
+
if (onLoadError === 'throw') throw kind === 'shape' ? notAPluginError(spec, reason) : new Error(reason);
|
|
156
156
|
console.warn(`[matbot] Skipping plugin "${spec}": ${reason}`);
|
|
157
157
|
};
|
|
158
158
|
|
package/src/security/vault.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Vault } from '@matatbread/matbot-plugin-api';
|
|
2
|
-
import {
|
|
2
|
+
import { missingSecretError, applyCreateSecret } from '@matatbread/matbot-plugin-api';
|
|
3
3
|
|
|
4
4
|
const REF_RE = /\$\{([^}]+)\}/g;
|
|
5
5
|
|
|
@@ -59,7 +59,7 @@ export class VaultImpl implements Vault {
|
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
if (errors.length > 0) {
|
|
62
|
-
throw
|
|
62
|
+
throw missingSecretError(errors);
|
|
63
63
|
}
|
|
64
64
|
return result;
|
|
65
65
|
}
|