MCPcopy
hub / github.com/continuedev/continue / postAgentMetadata

Function postAgentMetadata

extensions/cli/src/util/metadata.ts:125–182  ·  view source on GitHub ↗
(
  agentId: string,
  metadata: Record<string, any>,
)

Source from the content-addressed store, hash-verified

123 * @param metadata - Arbitrary metadata object to post
124 */
125export async function postAgentMetadata(
126 agentId: string,
127 metadata: Record<string, any>,
128): Promise<void> {
129 const endpoint = `agents/${agentId}/metadata`;
130 const fullUrl = new URL(endpoint, env.apiBase).toString();
131
132 if (!agentId) {
133 logger.debug("No agent ID provided, skipping metadata update");
134 return;
135 }
136
137 if (!metadata || Object.keys(metadata).length === 0) {
138 logger.debug("Empty metadata object, skipping metadata update");
139 return;
140 }
141
142 const startTime = Date.now();
143 logger.info(`[metadata] POST ${fullUrl}`, {
144 agentId,
145 metadataKeys: Object.keys(metadata),
146 });
147 logger.info("[metadata] Request body", { metadata });
148
149 try {
150 const response = await post(endpoint, { metadata });
151 const duration = Date.now() - startTime;
152
153 if (response.ok) {
154 logger.info(
155 `[metadata] Success: ${response.status} (${duration}ms) ${fullUrl}`,
156 );
157 } else {
158 logger.warn(
159 `[metadata] Unexpected response: ${response.status} (${duration}ms) ${fullUrl}`,
160 );
161 }
162 } catch (error) {
163 const duration = Date.now() - startTime;
164 // Non-critical: Log but don't fail the entire agent execution
165 if (error instanceof AuthenticationRequiredError) {
166 logger.info(
167 `[metadata] Auth required (skipping) (${duration}ms) ${fullUrl}`,
168 );
169 } else if (error instanceof ApiRequestError) {
170 logger.warn(
171 `[metadata] Failed: ${error.status} ${error.statusText} (${duration}ms) ${fullUrl}`,
172 { response: error.response },
173 );
174 } else {
175 const errorMessage =
176 error instanceof Error ? error.message : String(error);
177 logger.warn(
178 `[metadata] Error: ${errorMessage} (${duration}ms) ${fullUrl}`,
179 );
180 }
181 }
182}

Callers 1

updateAgentMetadataFunction · 0.85

Calls 4

postFunction · 0.85
infoMethod · 0.80
warnMethod · 0.80
debugMethod · 0.45

Tested by

no test coverage detected