oft-agt 0.5.13 → 0.5.14
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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/runtime/api-request.mjs +10 -0
- package/runtime/execute.mjs +3 -2
- package/version.mjs +1 -1
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oft-agt",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.14",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "oft-agt",
|
|
9
|
-
"version": "0.5.
|
|
9
|
+
"version": "0.5.14",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"discord.js": "^14.14.0",
|
|
12
12
|
"ws": "^8.18.0"
|
package/package.json
CHANGED
package/runtime/api-request.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {interpolateVariables} from './custom-variables.mjs';
|
|
1
2
|
import http from 'node:http';
|
|
2
3
|
import https from 'node:https';
|
|
3
4
|
import {lookup} from 'node:dns';
|
|
@@ -20,3 +21,12 @@ export async function requestApi(raw,{resolveSecret=async()=>{throw Error('Secre
|
|
|
20
21
|
export function responseVariables(c,result){const values={[c.name+'_status-code']:String(result.status),[c.name+'_status-text']:result.statusText,[c.name+'_response']:typeof result.response==='string'?result.response:JSON.stringify(result.response)};for(const o of c.outputs){let v=result.response;for(const key of o.path)v=v&&typeof v==='object'&&Object.hasOwn(v,key)?v[key]:undefined;values[c.name+'_'+o.name]=v===undefined?'':typeof v==='object'?JSON.stringify(v):String(v);}return values;}
|
|
21
22
|
|
|
22
23
|
export function redactApiResult(value,secrets){const redact=s=>{for(const secret of secrets)if(secret)s=s.split(secret).join('••••');return s;};if(typeof value==='string')return redact(value);if(Array.isArray(value))return value.map(v=>redactApiResult(v,secrets));if(value&&typeof value==='object')return Object.fromEntries(Object.entries(value).map(([k,v])=>[redact(k),redactApiResult(v,secrets)]));return value;}
|
|
24
|
+
|
|
25
|
+
export async function interpolateApiArguments(args, options) {
|
|
26
|
+
const {body = '', ...rest} = args;
|
|
27
|
+
const resolved = await interpolateVariables(rest, options);
|
|
28
|
+
if (['GET', 'HEAD'].includes(args.method)) return {...resolved, body: ''};
|
|
29
|
+
let json;
|
|
30
|
+
try { json = JSON.parse(body); } catch { return {...resolved, body: await interpolateVariables(body, options)}; }
|
|
31
|
+
return {...resolved, body: JSON.stringify(await interpolateVariables(json, options))};
|
|
32
|
+
}
|
package/runtime/execute.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {interpolateApiArguments} from './api-request.mjs';
|
|
1
2
|
import { interpolateVariables, referencedVariables, VARIABLE_WARNING_CODES } from './custom-variables.mjs';
|
|
2
3
|
import { variableRuntimeOptions } from './variable-actions.mjs';
|
|
3
4
|
import { buttonRouter } from './button-router.mjs';
|
|
@@ -133,7 +134,7 @@ async function executeAdmitted(command, interaction, client, options) {
|
|
|
133
134
|
|
|
134
135
|
context.signal.throwIfAborted();
|
|
135
136
|
|
|
136
|
-
const args=await interpolateVariables(call.args,context.variableOptions);
|
|
137
|
+
const args=await (call.fn==='apiRequest'?interpolateApiArguments:interpolateVariables)(call.args,context.variableOptions);
|
|
137
138
|
const prepared=call.fn==='sendMessage'&&args.buttons?.length?(options.buttonRouter||buttonRouter).prepare(command,args.buttons,context,optionValues):null;
|
|
138
139
|
const invoke=async()=>{try{return await registry[call.fn](context,{...args,...(prepared?{components:prepared.components}:{})});}catch(error){prepared?.cancel();throw error;}};
|
|
139
140
|
|
|
@@ -160,7 +161,7 @@ async function executeAdmitted(command, interaction, client, options) {
|
|
|
160
161
|
|
|
161
162
|
context.signal.throwIfAborted();
|
|
162
163
|
|
|
163
|
-
const args=interpolateError(await interpolateVariables(call.args,{...context.variableOptions,base:{...context.variableOptions.base,...optionValues,...variables}}),variables);
|
|
164
|
+
const args=interpolateError(await (call.fn==='apiRequest'?interpolateApiArguments:interpolateVariables)(call.args,{...context.variableOptions,base:{...context.variableOptions.base,...optionValues,...variables}}),variables);
|
|
164
165
|
const prepared=call.fn==='sendMessage'&&args.buttons?.length?(options.buttonRouter||buttonRouter).prepare(command,args.buttons,context,{...optionValues,...variables}):null;
|
|
165
166
|
const invoke=async()=>{try{return await registry[call.fn](context,{...args,...(prepared?{components:prepared.components}:{})});}catch(error){prepared?.cancel();throw error;}};
|
|
166
167
|
|
package/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_VERSION = '0.5.
|
|
1
|
+
export const AGENT_VERSION = '0.5.14';
|