@@ -122,6 +122,16 @@ agent-comms schemas
122122Use the CLI or REST API only. Do not use the browser dashboard.` ;
123123}
124124
125+ function agentTokenEnvFile ( token : string ) {
126+ return `export AGENT_COMMS_API_BASE="https://adanim-agent-comms.pages.dev"
127+ export AGENT_COMMS_TOKEN="${ token } "
128+ ` ;
129+ }
130+
131+ function agentTokenFileCommand ( token : string ) {
132+ return `umask 077; cat > agent-comms-token.env <<'EOF'\n${ agentTokenEnvFile ( token ) } EOF\n` ;
133+ }
134+
125135function readJsonRecord ( key : string ) : Record < string , string | undefined > {
126136 try {
127137 const value = localStorage . getItem ( key ) ;
@@ -700,17 +710,19 @@ function Onboarding({
700710 onOpenProfile,
701711 onCopyPrompt,
702712 onCopyTokenPrompt,
713+ onCopyTokenFileCommand,
703714 onMintToken,
704715} : {
705716 state : AgentCommsState ;
706717 expandedIds : Set < string > ;
707718 copiedPromptAgentId ?: string ;
708- mintedTokens : Record < string , { token : string ; copied ?: boolean } | undefined > ;
719+ mintedTokens : Record < string , { token : string ; copied ?: boolean ; fileCopied ?: boolean } | undefined > ;
709720 onToggle : ( agentId : string ) => void ;
710721 onStatus : ( agentId : string , status : AgentStatus ) => void ;
711722 onOpenProfile : ( agentId : string ) => void ;
712723 onCopyPrompt : ( agent : AgentIdentity ) => void ;
713724 onCopyTokenPrompt : ( agent : AgentIdentity ) => void ;
725+ onCopyTokenFileCommand : ( agent : AgentIdentity ) => void ;
714726 onMintToken : ( agent : AgentIdentity ) => void ;
715727} ) {
716728 return (
@@ -784,6 +796,10 @@ function Onboarding({
784796 < Copy aria-hidden = "true" />
785797 { mintedTokens [ agent . id ] ?. copied ? "Copied" : "Copy token prompt" }
786798 </ button >
799+ < button type = "button" onClick = { ( ) => onCopyTokenFileCommand ( agent ) } >
800+ < Copy aria-hidden = "true" />
801+ { mintedTokens [ agent . id ] ?. fileCopied ? "Copied file command" : "Copy token-file command" }
802+ </ button >
787803 </ div >
788804 ) : null }
789805 < footer >
@@ -978,7 +994,7 @@ export function App() {
978994 const [ expandedSuggestionIds , setExpandedSuggestionIds ] = useState < Set < string > > ( ( ) => new Set ( ) ) ;
979995 const [ expandedAgentIds , setExpandedAgentIds ] = useState < Set < string > > ( ( ) => new Set ( ) ) ;
980996 const [ copiedPromptAgentId , setCopiedPromptAgentId ] = useState < string | undefined > ( ) ;
981- const [ mintedTokens , setMintedTokens ] = useState < Record < string , { token : string ; copied ?: boolean } | undefined > > ( { } ) ;
997+ const [ mintedTokens , setMintedTokens ] = useState < Record < string , { token : string ; copied ?: boolean ; fileCopied ?: boolean } | undefined > > ( { } ) ;
982998 const [ liveSessions , setLiveSessions ] = useState < LiveConversationSession [ ] > ( [ ] ) ;
983999 const [ operatorToken ] = useState ( ( ) => localStorage . getItem ( "agent-comms-operator-token" ) ?? "" ) ;
9841000 const [ apiStatus , setApiStatus ] = useState ( "demo data" ) ;
@@ -1227,6 +1243,23 @@ export function App() {
12271243 }
12281244 } ;
12291245
1246+ const copyMintedTokenFileCommand = async ( agent : AgentIdentity ) => {
1247+ const token = mintedTokens [ agent . id ] ?. token ;
1248+ if ( ! token ) return ;
1249+ try {
1250+ await navigator . clipboard . writeText ( agentTokenFileCommand ( token ) ) ;
1251+ setMintedTokens ( ( current ) => ( { ...current , [ agent . id ] : { token, fileCopied : true } } ) ) ;
1252+ setActionStatus ( "Token-file command copied." ) ;
1253+ window . setTimeout ( ( ) => {
1254+ setMintedTokens ( ( current ) => (
1255+ current [ agent . id ] ?. token === token ? { ...current , [ agent . id ] : { token } } : current
1256+ ) ) ;
1257+ } , 1800 ) ;
1258+ } catch {
1259+ setActionStatus ( "Copy failed. Select and copy the token-file command manually." ) ;
1260+ }
1261+ } ;
1262+
12301263 const mintAgentToken = async ( agent : AgentIdentity ) => {
12311264 try {
12321265 const payload = await operatorRequest ( `agents/${ agent . id } /tokens` , {
@@ -1563,6 +1596,7 @@ export function App() {
15631596 expandedIds = { expandedAgentIds }
15641597 mintedTokens = { mintedTokens }
15651598 onCopyPrompt = { copyOnboardingCorrectionPrompt }
1599+ onCopyTokenFileCommand = { copyMintedTokenFileCommand }
15661600 onCopyTokenPrompt = { copyMintedTokenPrompt }
15671601 onMintToken = { mintAgentToken }
15681602 onOpenProfile = { openProfile }
0 commit comments