@panal/sdk 0.25.0 → 0.26.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/README.md +49 -0
- package/dist/cifrado.d.ts +147 -0
- package/dist/cifrado.js +333 -0
- package/dist/client.d.ts +174 -2
- package/dist/client.js +451 -33
- package/dist/idiomas.js +2 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +5 -2
- package/dist/net.d.ts +9 -0
- package/dist/net.js +15 -1
- package/dist/tablon-reglas.d.ts +14 -0
- package/dist/tablon-reglas.js +14 -0
- package/package.json +7 -2
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export { componerNivel, conTextoDeLaFicha, esTokenDeNivel, leerNivelDeSegmento,
|
|
|
46
46
|
export { esTokenDeTipo, leerTipo, leerTipoDeSegmento, tokenDeTipo } from './tipo.js';
|
|
47
47
|
export type { TipoDeAgente } from './tipo.js';
|
|
48
48
|
export { componerEjemplo, conEjemplosDeLaFicha, EJEMPLOS_EDITABLES, esTokenDeEjemplo, falloDeEjemplo, leerEjemploDeSegmento, leerEjemplos, leerEjemplosDeMetadata, MAX_EJEMPLO, } from './ejemplos.js';
|
|
49
|
-
export { rutaDeAgente } from './net.js';
|
|
49
|
+
export { rutaDeAgente, sinBarraFinal } from './net.js';
|
|
50
50
|
export { BUZON_URL, TABLON, VENTANA_FIRMA_S, encargoSignMessage, entregaSignMessage, ofertaSignMessage, } from './tablon.js';
|
|
51
51
|
export type { EncargoDelTablon } from './tablon.js';
|
|
52
52
|
export { fichaEnIdioma, IDIOMAS, NOMBRE_IDIOMA, normalizarIdioma } from './idiomas.js';
|
|
@@ -54,5 +54,6 @@ export type { Idioma } from './idiomas.js';
|
|
|
54
54
|
export { MERCADO_PANAL, PRECIO_MAX_EDAD_S, PYTH_MONAD, PYTH_MON_USD, enDolares, esFresco, formatearDolares, leerPrecios, valorDeVenta, } from './precios.js';
|
|
55
55
|
export type { FuentePrecio, MonedaConPrecio, OpcionesPrecios, Precio, Precios } from './precios.js';
|
|
56
56
|
export { panalTablonAbi } from './tablon-abi.js';
|
|
57
|
-
export { CATEGORIAS_TABLON, EstadoTablon, MARGEN_ASIGNACION_S, MAX_ANUNCIO, MAX_ARCHIVOS_TABLON, MAX_BYTES_ARCHIVOS_TABLON, MAX_CATEGORIAS, MAX_TEXTO_ANUNCIO, MAX_OFERTAS, MAX_VENTANA_ELECCION_S, MIN_PLAZO_ENTREGA_S, ModoTablon, anuncioPara, audienciaAdmite, categoriaDelTablon, categoriasDeMascara, claveDeCampana, encargoDeLaCadena, entregaConArchivos, idDeCampana, leerAnuncio, ofertaDeLaCadena, problemaAlPublicar, problemaConArchivos, situacionDe, tablonArchivoSignMessage, tablonEncargoSignMessage, tablonEntregaSignMessage, tablonResultadoSignMessage, } from './tablon-reglas.js';
|
|
57
|
+
export { CATEGORIAS_TABLON, EstadoTablon, MARGEN_ASIGNACION_S, MAX_ANUNCIO, MAX_ARCHIVOS_TABLON, MAX_BYTES_ARCHIVOS_TABLON, MAX_CATEGORIAS, MAX_TEXTO_ANUNCIO, MAX_OFERTAS, MAX_VENTANA_ELECCION_S, MIN_PLAZO_ENTREGA_S, ModoTablon, anuncioPara, audienciaAdmite, categoriaDelTablon, categoriasDeMascara, claveDeCampana, encargoDeLaCadena, entregaConArchivos, idDeCampana, leerAnuncio, ofertaDeLaCadena, problemaAlPublicar, problemaConArchivos, situacionDe, tablonAccesoSignMessage, tablonArchivoSignMessage, tablonDisputaSignMessage, tablonEncargoSignMessage, tablonEntregaSignMessage, tablonResultadoSignMessage, } from './tablon-reglas.js';
|
|
58
58
|
export type { ArchivoParaSubir, AudienciaTablon, CategoriaTablon, EncargoConReglas, OfertaConReglas, PublicarEnElTablon, SituacionEnElTablon, } from './tablon-reglas.js';
|
|
59
|
+
export { CIFRADO_V1, aBase64, accesoSignMessage, archivosAnunciadosEnSobre, claveDesdeFirma, concederAcceso, cifrarArchivo, cifrarTexto, comprobarClavePublicada, deBase64, descifrarArchivo, descifrarTexto, destinatariosDe, disputaSignMessage, esArchivoCifrado, esTextoCifrado, mensajeParaDerivarClave, mensajeParaPublicarClave, nombreEnBuzon, puedeAbrir, type Acceso, type ArchivoAnunciado, type ClaveDeCifrado, type ClavePublicada, type Destinatario, } from './cifrado.js';
|
package/dist/index.js
CHANGED
|
@@ -54,7 +54,7 @@ export { componerEjemplo, conEjemplosDeLaFicha, EJEMPLOS_EDITABLES, esTokenDeEje
|
|
|
54
54
|
// propio agente y no un servicio de Panal.
|
|
55
55
|
// Unir una ruta con la URL de un agente. Ver por qué en `net.ts`: un agente
|
|
56
56
|
// puede vivir en un subcamino, y `new URL('/x', base)` se lo come.
|
|
57
|
-
export { rutaDeAgente } from './net.js';
|
|
57
|
+
export { rutaDeAgente, sinBarraFinal } from './net.js';
|
|
58
58
|
// El tablón: encargos sin dueño para que los coja un programa. Los mensajes de
|
|
59
59
|
// firma se exportan porque cualquiera que hable con el buzón sin este cliente
|
|
60
60
|
// —otro lenguaje, otro runtime— necesita producir exactamente estos bytes.
|
|
@@ -67,4 +67,7 @@ export { MERCADO_PANAL, PRECIO_MAX_EDAD_S, PYTH_MONAD, PYTH_MON_USD, enDolares,
|
|
|
67
67
|
// el cliente (`…BoardJob`); aquí, el ABI, los tipos y lo que se calcula sin la
|
|
68
68
|
// cadena. Ver tablon-reglas.ts y contracts/BOARD.md.
|
|
69
69
|
export { panalTablonAbi } from './tablon-abi.js';
|
|
70
|
-
export { CATEGORIAS_TABLON, EstadoTablon, MARGEN_ASIGNACION_S, MAX_ANUNCIO, MAX_ARCHIVOS_TABLON, MAX_BYTES_ARCHIVOS_TABLON, MAX_CATEGORIAS, MAX_TEXTO_ANUNCIO, MAX_OFERTAS, MAX_VENTANA_ELECCION_S, MIN_PLAZO_ENTREGA_S, ModoTablon, anuncioPara, audienciaAdmite, categoriaDelTablon, categoriasDeMascara, claveDeCampana, encargoDeLaCadena, entregaConArchivos, idDeCampana, leerAnuncio, ofertaDeLaCadena, problemaAlPublicar, problemaConArchivos, situacionDe, tablonArchivoSignMessage, tablonEncargoSignMessage, tablonEntregaSignMessage, tablonResultadoSignMessage, } from './tablon-reglas.js';
|
|
70
|
+
export { CATEGORIAS_TABLON, EstadoTablon, MARGEN_ASIGNACION_S, MAX_ANUNCIO, MAX_ARCHIVOS_TABLON, MAX_BYTES_ARCHIVOS_TABLON, MAX_CATEGORIAS, MAX_TEXTO_ANUNCIO, MAX_OFERTAS, MAX_VENTANA_ELECCION_S, MIN_PLAZO_ENTREGA_S, ModoTablon, anuncioPara, audienciaAdmite, categoriaDelTablon, categoriasDeMascara, claveDeCampana, encargoDeLaCadena, entregaConArchivos, idDeCampana, leerAnuncio, ofertaDeLaCadena, problemaAlPublicar, problemaConArchivos, situacionDe, tablonAccesoSignMessage, tablonArchivoSignMessage, tablonDisputaSignMessage, tablonEncargoSignMessage, tablonEntregaSignMessage, tablonResultadoSignMessage, } from './tablon-reglas.js';
|
|
71
|
+
// Encargos cifrados de punta a punta: la clave sale de una firma, el sobre se
|
|
72
|
+
// abre solo con la de sus destinatarios, y el buzón guarda lo que no sabe leer.
|
|
73
|
+
export { CIFRADO_V1, aBase64, accesoSignMessage, archivosAnunciadosEnSobre, claveDesdeFirma, concederAcceso, cifrarArchivo, cifrarTexto, comprobarClavePublicada, deBase64, descifrarArchivo, descifrarTexto, destinatariosDe, disputaSignMessage, esArchivoCifrado, esTextoCifrado, mensajeParaDerivarClave, mensajeParaPublicarClave, nombreEnBuzon, puedeAbrir, } from './cifrado.js';
|
package/dist/net.d.ts
CHANGED
|
@@ -68,3 +68,12 @@ export declare function fetchLimited(url: URL | string, init?: RequestInit & {
|
|
|
68
68
|
* rutas se hace en un sitio y no a mano en cada llamada.
|
|
69
69
|
*/
|
|
70
70
|
export declare function rutaDeAgente(base: string, ruta: string): string;
|
|
71
|
+
/**
|
|
72
|
+
* Una URL sin las barras del final.
|
|
73
|
+
*
|
|
74
|
+
* Con un bucle y no con `replace(/\/+$/, '')`: esa expresión, sobre un texto
|
|
75
|
+
* lleno de barras que no acaba en barra, vuelve a probar desde cada una y
|
|
76
|
+
* tarda un tiempo cuadrático. Y la URL de un agente la escribe él en su
|
|
77
|
+
* ficha: con unos miles de barras bastaría para colgar a quien la lea.
|
|
78
|
+
*/
|
|
79
|
+
export declare function sinBarraFinal(url: string): string;
|
package/dist/net.js
CHANGED
|
@@ -163,5 +163,19 @@ export async function fetchLimited(url, init = {}) {
|
|
|
163
163
|
* rutas se hace en un sitio y no a mano en cada llamada.
|
|
164
164
|
*/
|
|
165
165
|
export function rutaDeAgente(base, ruta) {
|
|
166
|
-
return `${base
|
|
166
|
+
return `${sinBarraFinal(base)}/${ruta.replace(/^\/+/, '')}`;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Una URL sin las barras del final.
|
|
170
|
+
*
|
|
171
|
+
* Con un bucle y no con `replace(/\/+$/, '')`: esa expresión, sobre un texto
|
|
172
|
+
* lleno de barras que no acaba en barra, vuelve a probar desde cada una y
|
|
173
|
+
* tarda un tiempo cuadrático. Y la URL de un agente la escribe él en su
|
|
174
|
+
* ficha: con unos miles de barras bastaría para colgar a quien la lea.
|
|
175
|
+
*/
|
|
176
|
+
export function sinBarraFinal(url) {
|
|
177
|
+
let fin = url.length;
|
|
178
|
+
while (fin > 0 && url.charCodeAt(fin - 1) === 47)
|
|
179
|
+
fin--;
|
|
180
|
+
return url.slice(0, fin);
|
|
167
181
|
}
|
package/dist/tablon-reglas.d.ts
CHANGED
|
@@ -191,6 +191,13 @@ export interface PublicarEnElTablon {
|
|
|
191
191
|
* buzón del tablón después.
|
|
192
192
|
*/
|
|
193
193
|
adjuntos?: ArchivoParaSubir[];
|
|
194
|
+
/**
|
|
195
|
+
* Confidencial: el encargo y sus adjuntos se cifran para quien publica, y al
|
|
196
|
+
* elegir una oferta se le da acceso solo a quien se elige (que tiene que
|
|
197
|
+
* tener su clave publicada). El anuncio sigue siendo público. Solo en
|
|
198
|
+
* selección: en inmediato lo cogería cualquiera sin que nadie le diera acceso.
|
|
199
|
+
*/
|
|
200
|
+
confidencial?: boolean;
|
|
194
201
|
}
|
|
195
202
|
/**
|
|
196
203
|
* Las comprobaciones de `post()` antes de firmar, con el motivo en claro.
|
|
@@ -209,6 +216,13 @@ export declare function tablonEntregaSignMessage(jobId: bigint, resultHash: Hex,
|
|
|
209
216
|
export declare function tablonResultadoSignMessage(jobId: bigint, expira: number): string;
|
|
210
217
|
/** Su cliente sube un adjunto del encargo, o su agente un archivo de la entrega. */
|
|
211
218
|
export declare function tablonArchivoSignMessage(jobId: bigint, expira: number): string;
|
|
219
|
+
/**
|
|
220
|
+
* Una parte da acceso a lo cifrado de su encargo: a quien lo cogió o a quien
|
|
221
|
+
* decide una disputa (`concederAcceso`, en cifrado.ts).
|
|
222
|
+
*/
|
|
223
|
+
export declare function tablonAccesoSignMessage(jobId: bigint, expira: number): string;
|
|
224
|
+
/** Un firmante de la multisig lee una disputa: el encargo, la entrega y sus archivos. */
|
|
225
|
+
export declare function tablonDisputaSignMessage(jobId: bigint, expira: number): string;
|
|
212
226
|
export declare const MAX_ARCHIVOS_TABLON = 5;
|
|
213
227
|
export declare const MAX_BYTES_ARCHIVOS_TABLON: number;
|
|
214
228
|
/** Un archivo para subir al tablón: su nombre, sus bytes y su tipo si se sabe. */
|
package/dist/tablon-reglas.js
CHANGED
|
@@ -213,6 +213,9 @@ export function problemaAlPublicar(p) {
|
|
|
213
213
|
if (leerAnuncio(p.anuncio).audiencia === 'personas' && p.modo !== ModoTablon.Seleccion) {
|
|
214
214
|
return 'Un encargo solo para personas se publica en selección: así eliges tú a la persona.';
|
|
215
215
|
}
|
|
216
|
+
if (p.confidencial && p.modo !== ModoTablon.Seleccion) {
|
|
217
|
+
return 'Un encargo confidencial se publica en selección: a quien lo coge se le da acceso al elegirlo.';
|
|
218
|
+
}
|
|
216
219
|
if (p.modo === ModoTablon.Seleccion) {
|
|
217
220
|
const ofertas = p.ventanaOfertasS ?? 0;
|
|
218
221
|
const eleccion = p.ventanaEleccionS ?? 0;
|
|
@@ -261,6 +264,17 @@ export function tablonResultadoSignMessage(jobId, expira) {
|
|
|
261
264
|
export function tablonArchivoSignMessage(jobId, expira) {
|
|
262
265
|
return `Panal tablón con reglas · archivo #${jobId.toString()} · ${expira}`;
|
|
263
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* Una parte da acceso a lo cifrado de su encargo: a quien lo cogió o a quien
|
|
269
|
+
* decide una disputa (`concederAcceso`, en cifrado.ts).
|
|
270
|
+
*/
|
|
271
|
+
export function tablonAccesoSignMessage(jobId, expira) {
|
|
272
|
+
return `Panal tablón con reglas · acceso #${jobId.toString()} · ${expira}`;
|
|
273
|
+
}
|
|
274
|
+
/** Un firmante de la multisig lee una disputa: el encargo, la entrega y sus archivos. */
|
|
275
|
+
export function tablonDisputaSignMessage(jobId, expira) {
|
|
276
|
+
return `Panal tablón con reglas · disputa #${jobId.toString()} · ${expira}`;
|
|
277
|
+
}
|
|
264
278
|
/*
|
|
265
279
|
* Archivos en el tablón.
|
|
266
280
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panal/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "SDK de Panal: contrata agentes de IA autonomos on-chain en Monad",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=20"
|
|
36
36
|
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@noble/ciphers": "^1.3.0",
|
|
39
|
+
"@noble/curves": "^1.9.1",
|
|
40
|
+
"@noble/hashes": "^1.8.0"
|
|
41
|
+
},
|
|
37
42
|
"peerDependencies": {
|
|
38
43
|
"viem": "^2.21.0"
|
|
39
44
|
},
|
|
@@ -45,7 +50,7 @@
|
|
|
45
50
|
"scripts": {
|
|
46
51
|
"build": "tsc -p tsconfig.json",
|
|
47
52
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
48
|
-
"test": "tsx test/sdk.test.ts && tsx test/currencies.test.ts && tsx test/x402.test.ts && tsx test/x402-server.test.ts && tsx test/envelope.test.ts && tsx test/files.test.ts && tsx test/attachments.test.ts && tsx test/llm.test.ts && tsx test/skill.test.ts && tsx test/agent-card.test.ts && tsx test/niveles.test.ts && tsx test/ejemplos.test.ts && tsx test/tablon.test.ts && tsx test/reserva.test.ts && tsx test/precios.test.ts && tsx test/tablon-reglas.test.ts",
|
|
53
|
+
"test": "tsx test/sdk.test.ts && tsx test/currencies.test.ts && tsx test/x402.test.ts && tsx test/x402-server.test.ts && tsx test/envelope.test.ts && tsx test/files.test.ts && tsx test/attachments.test.ts && tsx test/llm.test.ts && tsx test/skill.test.ts && tsx test/agent-card.test.ts && tsx test/niveles.test.ts && tsx test/ejemplos.test.ts && tsx test/tablon.test.ts && tsx test/reserva.test.ts && tsx test/precios.test.ts && tsx test/tablon-reglas.test.ts && tsx test/cifrado.test.ts",
|
|
49
54
|
"test:nombres": "tsx test/nombres.test.ts"
|
|
50
55
|
}
|
|
51
56
|
}
|