@uibot/application 0.19.0 → 0.20.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/dist/agent-logo.d.ts +175 -0
- package/dist/agent-logo.js +1 -0
- package/dist/collection-application.js +6 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +170 -170
- package/dist/logo-requests.d.ts +64 -0
- package/dist/studio-logo.d.ts +2 -0
- package/package.json +17 -13
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
export declare const LOGO_AGENT_OPERATIONS: readonly [{
|
|
2
|
+
readonly name: "providers";
|
|
3
|
+
readonly description: "List configured image providers and exact model IDs before generating a logo.";
|
|
4
|
+
readonly inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: Record<string, unknown>;
|
|
7
|
+
required: string[];
|
|
8
|
+
additionalProperties: false;
|
|
9
|
+
};
|
|
10
|
+
readonly readOnly: true;
|
|
11
|
+
}, {
|
|
12
|
+
readonly name: "assets";
|
|
13
|
+
readonly description: "List saved logo assets and provenance. Use status with the original requestId to reconcile a generation.";
|
|
14
|
+
readonly inputSchema: {
|
|
15
|
+
type: "object";
|
|
16
|
+
properties: Record<string, unknown>;
|
|
17
|
+
required: string[];
|
|
18
|
+
additionalProperties: false;
|
|
19
|
+
};
|
|
20
|
+
readonly readOnly: true;
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "status";
|
|
23
|
+
readonly description: "Read a retained Logo request by its original UUID, including after a lost response or backend restart. running/unknown are not completion. Never automatically replay an unknown generation with a new ID.";
|
|
24
|
+
readonly inputSchema: {
|
|
25
|
+
type: "object";
|
|
26
|
+
properties: Record<string, unknown>;
|
|
27
|
+
required: string[];
|
|
28
|
+
additionalProperties: false;
|
|
29
|
+
};
|
|
30
|
+
readonly readOnly: true;
|
|
31
|
+
}, {
|
|
32
|
+
readonly name: "targets";
|
|
33
|
+
readonly description: "List supported app icon export targets and files.";
|
|
34
|
+
readonly inputSchema: {
|
|
35
|
+
type: "object";
|
|
36
|
+
properties: Record<string, unknown>;
|
|
37
|
+
required: string[];
|
|
38
|
+
additionalProperties: false;
|
|
39
|
+
};
|
|
40
|
+
readonly readOnly: true;
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "preview";
|
|
43
|
+
readonly description: "Inspect an existing logo before refining: original PNG or favicon-16/favicon-32/icon-512 on white with balanced spacing and transparent margins trimmed. Returns an image plus dimensions and SHA-256. Does not generate or change the asset.";
|
|
44
|
+
readonly inputSchema: {
|
|
45
|
+
type: "object";
|
|
46
|
+
properties: Record<string, unknown>;
|
|
47
|
+
required: string[];
|
|
48
|
+
additionalProperties: false;
|
|
49
|
+
};
|
|
50
|
+
readonly readOnly: true;
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "generate";
|
|
53
|
+
readonly description: "Generate and save one logo (may incur model cost), or refine an existing asset. Inspect the returned asset with preview before refining. Save an explicit requestId UUID before submitting. Same ID and content never dispatch twice; different content conflicts. On uncertainty query status with that same ID; never automatically generate with a new ID.";
|
|
54
|
+
readonly inputSchema: {
|
|
55
|
+
type: "object";
|
|
56
|
+
properties: Record<string, unknown>;
|
|
57
|
+
required: string[];
|
|
58
|
+
additionalProperties: false;
|
|
59
|
+
};
|
|
60
|
+
readonly readOnly: false;
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "export";
|
|
63
|
+
readonly description: "Export an existing logo as an app icon ZIP into the configured output directory. Returns a local path, byte count and SHA-256, not binary content. Requires output directory configuration.";
|
|
64
|
+
readonly inputSchema: {
|
|
65
|
+
type: "object";
|
|
66
|
+
properties: Record<string, unknown>;
|
|
67
|
+
required: string[];
|
|
68
|
+
additionalProperties: false;
|
|
69
|
+
};
|
|
70
|
+
readonly readOnly: false;
|
|
71
|
+
}];
|
|
72
|
+
export type LogoAgentOperation = (typeof LOGO_AGENT_OPERATIONS)[number]["name"];
|
|
73
|
+
export declare class LogoAgentError extends Error {
|
|
74
|
+
readonly code: string;
|
|
75
|
+
readonly outcomeUnknown: boolean;
|
|
76
|
+
readonly requestId?: string | undefined;
|
|
77
|
+
constructor(code: string, outcomeUnknown?: boolean, requestId?: string | undefined);
|
|
78
|
+
}
|
|
79
|
+
export interface LogoAgentClientOptions {
|
|
80
|
+
url: string;
|
|
81
|
+
token: string;
|
|
82
|
+
outputDir?: string;
|
|
83
|
+
fetch?: typeof fetch;
|
|
84
|
+
}
|
|
85
|
+
export interface LogoAgentResult extends Record<string, unknown> {
|
|
86
|
+
image?: {
|
|
87
|
+
type: "image";
|
|
88
|
+
mimeType: "image/png";
|
|
89
|
+
data: string;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Server-side agent seam. Does not import UI code, model SDKs or subscription credentials. */
|
|
93
|
+
export declare function createLogoAgentClient(options: LogoAgentClientOptions): {
|
|
94
|
+
operations: ({
|
|
95
|
+
readonly name: "providers";
|
|
96
|
+
readonly description: "List configured image providers and exact model IDs before generating a logo.";
|
|
97
|
+
readonly inputSchema: {
|
|
98
|
+
type: "object";
|
|
99
|
+
properties: Record<string, unknown>;
|
|
100
|
+
required: string[];
|
|
101
|
+
additionalProperties: false;
|
|
102
|
+
};
|
|
103
|
+
readonly readOnly: true;
|
|
104
|
+
} | {
|
|
105
|
+
readonly name: "assets";
|
|
106
|
+
readonly description: "List saved logo assets and provenance. Use status with the original requestId to reconcile a generation.";
|
|
107
|
+
readonly inputSchema: {
|
|
108
|
+
type: "object";
|
|
109
|
+
properties: Record<string, unknown>;
|
|
110
|
+
required: string[];
|
|
111
|
+
additionalProperties: false;
|
|
112
|
+
};
|
|
113
|
+
readonly readOnly: true;
|
|
114
|
+
} | {
|
|
115
|
+
readonly name: "status";
|
|
116
|
+
readonly description: "Read a retained Logo request by its original UUID, including after a lost response or backend restart. running/unknown are not completion. Never automatically replay an unknown generation with a new ID.";
|
|
117
|
+
readonly inputSchema: {
|
|
118
|
+
type: "object";
|
|
119
|
+
properties: Record<string, unknown>;
|
|
120
|
+
required: string[];
|
|
121
|
+
additionalProperties: false;
|
|
122
|
+
};
|
|
123
|
+
readonly readOnly: true;
|
|
124
|
+
} | {
|
|
125
|
+
readonly name: "targets";
|
|
126
|
+
readonly description: "List supported app icon export targets and files.";
|
|
127
|
+
readonly inputSchema: {
|
|
128
|
+
type: "object";
|
|
129
|
+
properties: Record<string, unknown>;
|
|
130
|
+
required: string[];
|
|
131
|
+
additionalProperties: false;
|
|
132
|
+
};
|
|
133
|
+
readonly readOnly: true;
|
|
134
|
+
} | {
|
|
135
|
+
readonly name: "preview";
|
|
136
|
+
readonly description: "Inspect an existing logo before refining: original PNG or favicon-16/favicon-32/icon-512 on white with balanced spacing and transparent margins trimmed. Returns an image plus dimensions and SHA-256. Does not generate or change the asset.";
|
|
137
|
+
readonly inputSchema: {
|
|
138
|
+
type: "object";
|
|
139
|
+
properties: Record<string, unknown>;
|
|
140
|
+
required: string[];
|
|
141
|
+
additionalProperties: false;
|
|
142
|
+
};
|
|
143
|
+
readonly readOnly: true;
|
|
144
|
+
} | {
|
|
145
|
+
readonly name: "generate";
|
|
146
|
+
readonly description: "Generate and save one logo (may incur model cost), or refine an existing asset. Inspect the returned asset with preview before refining. Save an explicit requestId UUID before submitting. Same ID and content never dispatch twice; different content conflicts. On uncertainty query status with that same ID; never automatically generate with a new ID.";
|
|
147
|
+
readonly inputSchema: {
|
|
148
|
+
type: "object";
|
|
149
|
+
properties: Record<string, unknown>;
|
|
150
|
+
required: string[];
|
|
151
|
+
additionalProperties: false;
|
|
152
|
+
};
|
|
153
|
+
readonly readOnly: false;
|
|
154
|
+
} | {
|
|
155
|
+
readonly name: "export";
|
|
156
|
+
readonly description: "Export an existing logo as an app icon ZIP into the configured output directory. Returns a local path, byte count and SHA-256, not binary content. Requires output directory configuration.";
|
|
157
|
+
readonly inputSchema: {
|
|
158
|
+
type: "object";
|
|
159
|
+
properties: Record<string, unknown>;
|
|
160
|
+
required: string[];
|
|
161
|
+
additionalProperties: false;
|
|
162
|
+
};
|
|
163
|
+
readonly readOnly: false;
|
|
164
|
+
})[];
|
|
165
|
+
call: (name: string, args?: Record<string, unknown>, signal?: AbortSignal) => Promise<LogoAgentResult>;
|
|
166
|
+
savePreview(args: Record<string, unknown>, signal?: AbortSignal): Promise<{
|
|
167
|
+
artifact: {
|
|
168
|
+
path: string;
|
|
169
|
+
contentType: string;
|
|
170
|
+
bytes: number;
|
|
171
|
+
sha256: string;
|
|
172
|
+
};
|
|
173
|
+
}>;
|
|
174
|
+
};
|
|
175
|
+
export type LogoAgentClient = ReturnType<typeof createLogoAgentClient>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as R,randomUUID as T}from"node:crypto";import{mkdir as P,realpath as j,writeFile as N}from"node:fs/promises";import{join as _}from"node:path";var u=(i,o=[])=>({type:"object",properties:i,required:o,additionalProperties:!1}),w={type:"string",minLength:1},b=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,S={original:"image","favicon-16":"web/favicon-16.png","favicon-32":"web/favicon-32.png","icon-512":"pwa/icon-512.png"},H=u({requestId:{type:"string",pattern:b.source},provider:w,model:w,brief:u({brand:{...w,maxLength:100},description:{...w,maxLength:2000},style:{enum:["symbol","monogram","mascot"]},colors:{type:"string",maxLength:300},direction:{type:"string",maxLength:2000},transparentBackground:{type:"boolean"}},["brand","description","style","colors","direction","transparentBackground"]),referenceAssetId:w,refinement:{...w,maxLength:2000}},["requestId","provider","model","brief"]),G=u({targets:{type:"array",items:{enum:["ios","android","web","pwa"]},minItems:1,maxItems:4,uniqueItems:!0},background:{type:"string",pattern:"^#[0-9a-fA-F]{6}$"},spacing:{enum:["balanced","spacious"]},trimTransparent:{type:"boolean"},removeFaintFringe:{type:"boolean",description:"Opt in to cropping near-transparent margins below 1/32 of peak alpha. May remove faint edge details; source is unchanged. Requires trimTransparent."}},["targets","background","spacing","trimTransparent"]),z=[{name:"providers",description:"List configured image providers and exact model IDs before generating a logo.",inputSchema:u({}),readOnly:!0},{name:"assets",description:"List saved logo assets and provenance. Use status with the original requestId to reconcile a generation.",inputSchema:u({}),readOnly:!0},{name:"status",description:"Read a retained Logo request by its original UUID, including after a lost response or backend restart. running/unknown are not completion. Never automatically replay an unknown generation with a new ID.",inputSchema:u({requestId:{type:"string",pattern:b.source}},["requestId"]),readOnly:!0},{name:"targets",description:"List supported app icon export targets and files.",inputSchema:u({}),readOnly:!0},{name:"preview",description:"Inspect an existing logo before refining: original PNG or favicon-16/favicon-32/icon-512 on white with balanced spacing and transparent margins trimmed. Returns an image plus dimensions and SHA-256. Does not generate or change the asset.",inputSchema:u({id:w,variant:{enum:Object.keys(S),default:"original"},removeFaintFringe:{type:"boolean",description:"Opt in for icon variants to crop near-transparent margins below 1/32 of peak alpha. May remove faint edge details; source is unchanged."}},["id"]),readOnly:!0},{name:"generate",description:"Generate and save one logo (may incur model cost), or refine an existing asset. Inspect the returned asset with preview before refining. Save an explicit requestId UUID before submitting. Same ID and content never dispatch twice; different content conflicts. On uncertainty query status with that same ID; never automatically generate with a new ID.",inputSchema:u({request:H},["request"]),readOnly:!1},{name:"export",description:"Export an existing logo as an app icon ZIP into the configured output directory. Returns a local path, byte count and SHA-256, not binary content. Requires output directory configuration.",inputSchema:u({id:w,request:G},["id","request"]),readOnly:!1}];class n extends Error{code;outcomeUnknown;requestId;constructor(i,o=!1,d){super(i);this.code=i;this.outcomeUnknown=o;this.requestId=d}}async function O(i,o,d,l){await P(i,{recursive:!0});let e=await j(i),t=_(e,`logo-${o}-${T()}.${d}`);return await N(t,l,{flag:"wx",mode:384}),{path:t,contentType:d==="png"?"image/png":"application/zip",bytes:l.length,sha256:R("sha256").update(l).digest("hex")}}async function B(i,o){let d=i.body?.getReader();if(!d)throw new n("logo-empty-response");let l=[],e=0;try{for(;;){let{done:s,value:q}=await d.read();if(s)break;if(e+=q.length,e>o)throw new n("logo-response-too-large");l.push(q)}}finally{await d.cancel().catch(()=>{})}let t=new Uint8Array(e),g=0;for(let s of l)t.set(s,g),g+=s.length;return t}function M(i){let o;try{o=new URL(i.url)}catch{throw new n("logo-invalid-backend-origin")}if(!/^https?:$/.test(o.protocol)||o.username||o.password||o.pathname!=="/"||o.search||o.hash)throw new n("logo-invalid-backend-origin");if(o.protocol==="http:"&&!["localhost","127.0.0.1","[::1]"].includes(o.hostname))throw new n("logo-https-required");if(!i.token||/[\r\n]/.test(i.token))throw new n("logo-auth-required");let d=z.filter((e)=>e.name!=="export"||i.outputDir),l=async(e,t={},g)=>{let s=d.find((r)=>r.name===e);if(!s)throw new n("logo-operation-unavailable");let q=Object.keys(s.inputSchema.properties);if(Object.keys(t).some((r)=>!q.includes(r))||s.inputSchema.required.some((r)=>t[r]===void 0))throw new n("logo-invalid-arguments");if((e==="generate"||e==="export")&&(!t.request||typeof t.request!=="object"||Array.isArray(t.request)))throw new n("logo-invalid-request");if((e==="export"||e==="preview")&&(typeof t.id!=="string"||!b.test(t.id)))throw new n("logo-invalid-asset-id");let y=e==="generate"?t.request.requestId:e==="status"?t.requestId:void 0;if((e==="generate"||e==="status")&&(typeof y!=="string"||!b.test(y)))throw new n("logo-request-id-required");let h=typeof y==="string"?y:void 0,p=t.variant===void 0?"original":t.variant;if(e==="preview"&&(typeof p!=="string"||!Object.hasOwn(S,p)))throw new n("logo-invalid-preview-variant");if(e==="preview"&&t.removeFaintFringe!==void 0&&(typeof t.removeFaintFringe!=="boolean"||p==="original"&&t.removeFaintFringe))throw new n("logo-invalid-preview-options");let D=e==="status"?`requests/${y}`:e==="targets"?"export-targets":e==="export"?`assets/${t.id}/app-kit`:e==="preview"?`assets/${t.id}/${p==="original"?"image":"preview"}`:e,k=new URL(`/api/studio/logo/${D}`,o);if(e==="preview"&&p!=="original"){if(k.search=new URLSearchParams({file:S[p],background:"#ffffff",spacing:"balanced",trim:"1"}).toString(),t.removeFaintFringe!==void 0)k.searchParams.set("fringe",t.removeFaintFringe?"1":"0")}let f;try{f=await(i.fetch??fetch)(k,{method:s.readOnly?"GET":"POST",redirect:"error",headers:{authorization:`Bearer ${i.token}`,...s.readOnly?{}:{"content-type":"application/json"}},...s.readOnly?{}:{body:JSON.stringify(t.request)},signal:g?AbortSignal.any([g,AbortSignal.timeout(600000)]):AbortSignal.timeout(600000)})}catch{throw new n("logo-transport-failed",e==="generate",h)}if(!f.ok)throw new n(`logo-http-${f.status}`,e==="generate"&&(f.status>=500||f.status===499),h);try{let r=await B(f,e==="export"?33554432:e==="preview"?20000000:1048576);if(e==="preview"){if(f.headers.get("content-type")?.split(";")[0]?.trim()!=="image/png"||r.length<45||![137,80,78,71,13,10,26,10].every((F,U)=>r[U]===F)||new TextDecoder().decode(r.subarray(12,16))!=="IHDR"||new TextDecoder().decode(r.subarray(-8,-4))!=="IEND")throw new n("logo-invalid-preview-response");let a=new DataView(r.buffer,r.byteOffset,r.byteLength),c=a.getUint32(16),v=a.getUint32(20),I=p==="original"?void 0:Number(String(p).split("-")[1]);if(!c||!v||c>4096||v>4096||c*v>4000000||I!==void 0&&(c!==I||v!==I))throw new n("logo-invalid-preview-response");return{preview:{id:t.id,variant:p,...p!=="original"?{removeFaintFringe:t.removeFaintFringe===!0}:{},contentType:"image/png",width:c,height:v,bytes:r.length,sha256:R("sha256").update(r).digest("hex")},image:{type:"image",mimeType:"image/png",data:Buffer.from(r).toString("base64")}}}if(e==="export"){if(!f.headers.get("content-type")?.startsWith("application/zip"))throw new n("logo-invalid-export-response");let a=i.outputDir;if(!a)throw new n("logo-output-directory-required");return{artifact:await O(a,String(t.id),"zip",r)}}let x=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(r));if(!x||typeof x!=="object")throw new n("logo-invalid-response");let m=x;if(e==="generate"||e==="status"){let a=m.request;if(!a||a.schema!=="uibot.logo-request.v1"||a.requestId!==h||!["running","succeeded","failed","unknown"].includes(String(a.state)))throw new n("logo-invalid-response");if(a.state==="succeeded"){let c=m.asset;if(!c||c.schema!=="uibot.logo-asset.v1"||typeof a.assetId!=="string"||!b.test(a.assetId)||c.id!==a.assetId||c.requestId!==h||typeof a.requestHash!=="string"||!/^[0-9a-f]{64}$/.test(a.requestHash)||c.requestHash!==a.requestHash)throw new n("logo-invalid-response")}else{if(m.asset!==void 0)throw new n("logo-invalid-response");m.next=`Query logo status ${h}. State ${String(a.state)} is not a generated asset; do not automatically submit a new ID.`}}else if(!Array.isArray(m[e]))throw new n("logo-invalid-response");return x}catch{throw new n("logo-response-failed",e==="generate",h)}};return{operations:d,call:l,async savePreview(e,t){if(!i.outputDir)throw new n("logo-output-directory-required");let{image:g,...s}=await l("preview",e,t);if(!g)throw new n("logo-invalid-preview-response");try{return{...s,artifact:await O(i.outputDir,String(e.id),"png",Buffer.from(g.data,"base64"))}}catch{throw new n("logo-preview-write-failed")}}}}export{z as LOGO_AGENT_OPERATIONS,n as LogoAgentError,M as createLogoAgentClient};
|