aamp-openclaw-plugin 0.1.18 → 0.1.19-alpha.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.
@@ -46,11 +46,12 @@ function normalizeBaseUrl(url) {
46
46
  return `https://${url.replace(/\/$/, '')}`
47
47
  }
48
48
 
49
- function ensurePluginConfig(config, pluginConfig) {
49
+ function ensurePluginConfig(config, pluginConfig, installRecord) {
50
50
  const next = config && typeof config === 'object' ? structuredClone(config) : {}
51
51
  if (!next.plugins || typeof next.plugins !== 'object') next.plugins = {}
52
52
  if (!Array.isArray(next.plugins.allow)) next.plugins.allow = []
53
53
  if (!next.plugins.entries || typeof next.plugins.entries !== 'object') next.plugins.entries = {}
54
+ if (!next.plugins.installs || typeof next.plugins.installs !== 'object') next.plugins.installs = {}
54
55
 
55
56
  if (!next.plugins.allow.includes(PLUGIN_ID)) {
56
57
  next.plugins.allow.push(PLUGIN_ID)
@@ -76,6 +77,14 @@ function ensurePluginConfig(config, pluginConfig) {
76
77
  delete next.plugins.entries.aamp
77
78
  }
78
79
 
80
+ if (next.plugins.installs.aamp) {
81
+ delete next.plugins.installs.aamp
82
+ }
83
+
84
+ if (installRecord) {
85
+ next.plugins.installs[PLUGIN_ID] = installRecord
86
+ }
87
+
79
88
  return next
80
89
  }
81
90
 
@@ -147,7 +156,7 @@ function installPluginFiles(credentialsFile = DEFAULT_CREDENTIALS_FILE) {
147
156
  writeFileSync(credentialsPath, existingCredentials)
148
157
  }
149
158
 
150
- return extensionDir
159
+ return { extensionDir, packageJson, packageRoot }
151
160
  }
152
161
 
153
162
  function restartGateway() {
@@ -331,14 +340,27 @@ async function runInit() {
331
340
  }
332
341
 
333
342
  output.write('\nInstalling OpenClaw plugin files...\n')
334
- const extensionDir = installPluginFiles(previousCredentialsFile)
343
+ const { extensionDir, packageJson, packageRoot } = installPluginFiles(previousCredentialsFile)
344
+ const nowIso = new Date().toISOString()
345
+ const installRecord = {
346
+ source: 'npm',
347
+ spec: packageJson.name,
348
+ sourcePath: packageRoot,
349
+ installPath: extensionDir,
350
+ version: packageJson.version,
351
+ resolvedName: packageJson.name,
352
+ resolvedVersion: packageJson.version,
353
+ resolvedSpec: `${packageJson.name}@${packageJson.version}`,
354
+ installedAt: nowIso,
355
+ resolvedAt: nowIso,
356
+ }
335
357
 
336
358
  const next = ensurePluginConfig(existing, {
337
359
  aampHost,
338
360
  slug,
339
361
  credentialsFile: DEFAULT_CREDENTIALS_FILE,
340
362
  ...(senderPolicies ? { senderPolicies } : {}),
341
- })
363
+ }, installRecord)
342
364
 
343
365
  writeJsonFile(configPath, next)
344
366
 
@@ -0,0 +1,82 @@
1
+ import { createRequire as __aampCreateRequire } from "module"; const require = __aampCreateRequire(import.meta.url);
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined")
12
+ return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __commonJS = (cb, mod) => function __require2() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+
35
+ // src/file-store.ts
36
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
37
+ import { dirname, join } from "node:path";
38
+ import { homedir } from "node:os";
39
+ function defaultCredentialsPath() {
40
+ return join(homedir(), ".openclaw", "extensions", "aamp-openclaw-plugin", ".credentials.json");
41
+ }
42
+ function loadCachedIdentity(file) {
43
+ const resolved = file ?? defaultCredentialsPath();
44
+ if (!existsSync(resolved))
45
+ return null;
46
+ try {
47
+ const parsed = JSON.parse(readFileSync(resolved, "utf-8"));
48
+ if (!parsed.email || !parsed.jmapToken || !parsed.smtpPassword)
49
+ return null;
50
+ return parsed;
51
+ } catch {
52
+ return null;
53
+ }
54
+ }
55
+ function saveCachedIdentity(identity, file) {
56
+ const resolved = file ?? defaultCredentialsPath();
57
+ mkdirSync(dirname(resolved), { recursive: true });
58
+ writeFileSync(resolved, JSON.stringify(identity, null, 2), "utf-8");
59
+ }
60
+ function ensureDir(dir) {
61
+ mkdirSync(dir, { recursive: true });
62
+ }
63
+ function readBinaryFile(path) {
64
+ return readFileSync(path);
65
+ }
66
+ function writeBinaryFile(path, content) {
67
+ mkdirSync(dirname(path), { recursive: true });
68
+ writeFileSync(path, content);
69
+ }
70
+
71
+ export {
72
+ __require,
73
+ __commonJS,
74
+ __toESM,
75
+ defaultCredentialsPath,
76
+ loadCachedIdentity,
77
+ saveCachedIdentity,
78
+ ensureDir,
79
+ readBinaryFile,
80
+ writeBinaryFile
81
+ };
82
+ //# sourceMappingURL=chunk-ORTVVAMV.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/file-store.ts"],
4
+ "sourcesContent": ["import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { dirname, join } from 'node:path'\nimport { homedir } from 'node:os'\n\nexport interface Identity {\n email: string\n jmapToken: string\n smtpPassword: string\n}\n\nexport function defaultCredentialsPath(): string {\n return join(homedir(), '.openclaw', 'extensions', 'aamp-openclaw-plugin', '.credentials.json')\n}\n\nexport function loadCachedIdentity(file?: string): Identity | null {\n const resolved = file ?? defaultCredentialsPath()\n if (!existsSync(resolved)) return null\n try {\n const parsed = JSON.parse(readFileSync(resolved, 'utf-8')) as Partial<Identity>\n if (!parsed.email || !parsed.jmapToken || !parsed.smtpPassword) return null\n return parsed as Identity\n } catch {\n return null\n }\n}\n\nexport function saveCachedIdentity(identity: Identity, file?: string): void {\n const resolved = file ?? defaultCredentialsPath()\n mkdirSync(dirname(resolved), { recursive: true })\n writeFileSync(resolved, JSON.stringify(identity, null, 2), 'utf-8')\n}\n\nexport function ensureDir(dir: string): void {\n mkdirSync(dir, { recursive: true })\n}\n\nexport function readBinaryFile(path: string): Buffer {\n return readFileSync(path)\n}\n\nexport function writeBinaryFile(path: string, content: Uint8Array | Buffer): void {\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, content)\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,SAAS,YAAY;AAC9B,SAAS,eAAe;AAQjB,SAAS,yBAAiC;AAC/C,SAAO,KAAK,QAAQ,GAAG,aAAa,cAAc,wBAAwB,mBAAmB;AAC/F;AAEO,SAAS,mBAAmB,MAAgC;AACjE,QAAM,WAAW,QAAQ,uBAAuB;AAChD,MAAI,CAAC,WAAW,QAAQ;AAAG,WAAO;AAClC,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,aAAa,UAAU,OAAO,CAAC;AACzD,QAAI,CAAC,OAAO,SAAS,CAAC,OAAO,aAAa,CAAC,OAAO;AAAc,aAAO;AACvE,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,mBAAmB,UAAoB,MAAqB;AAC1E,QAAM,WAAW,QAAQ,uBAAuB;AAChD,YAAU,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AAChD,gBAAc,UAAU,KAAK,UAAU,UAAU,MAAM,CAAC,GAAG,OAAO;AACpE;AAEO,SAAS,UAAU,KAAmB;AAC3C,YAAU,KAAK,EAAE,WAAW,KAAK,CAAC;AACpC;AAEO,SAAS,eAAe,MAAsB;AACnD,SAAO,aAAa,IAAI;AAC1B;AAEO,SAAS,gBAAgB,MAAc,SAAoC;AAChF,YAAU,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AAC5C,gBAAc,MAAM,OAAO;AAC7B;",
6
+ "names": []
7
+ }
@@ -1,3 +1,4 @@
1
+ import { createRequire as __aampCreateRequire } from "module"; const require = __aampCreateRequire(import.meta.url);
1
2
  import {
2
3
  defaultCredentialsPath,
3
4
  ensureDir,
@@ -5,7 +6,7 @@ import {
5
6
  readBinaryFile,
6
7
  saveCachedIdentity,
7
8
  writeBinaryFile
8
- } from "./chunk-W4C7IUCH.js";
9
+ } from "./chunk-ORTVVAMV.js";
9
10
  export {
10
11
  defaultCredentialsPath,
11
12
  ensureDir,
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createRequire as __aampCreateRequire } from "module"; const require = __aampCreateRequire(import.meta.url);
1
2
  import {
2
3
  __commonJS,
3
4
  __require,
@@ -8,7 +9,7 @@ import {
8
9
  readBinaryFile,
9
10
  saveCachedIdentity,
10
11
  writeBinaryFile
11
- } from "./chunk-W4C7IUCH.js";
12
+ } from "./chunk-ORTVVAMV.js";
12
13
 
13
14
  // ../sdk/node_modules/ws/lib/constants.js
14
15
  var require_constants = __commonJS({