MCPcopy Create free account
hub / github.com/freecodexyz/free-code / parseRequestId

Function parseRequestId

src/utils/agentId.ts:74–99  ·  view source on GitHub ↗
(
  requestId: string,
)

Source from the content-addressed store, hash-verified

72 * Returns null if the request ID doesn't match the expected format.
73 */
74export function parseRequestId(
75 requestId: string,
76): { requestType: string; timestamp: number; agentId: string } | null {
77 const atIndex = requestId.indexOf('@')
78 if (atIndex === -1) {
79 return null
80 }
81
82 const prefix = requestId.slice(0, atIndex)
83 const agentId = requestId.slice(atIndex + 1)
84
85 const lastDashIndex = prefix.lastIndexOf('-')
86 if (lastDashIndex === -1) {
87 return null
88 }
89
90 const requestType = prefix.slice(0, lastDashIndex)
91 const timestampStr = prefix.slice(lastDashIndex + 1)
92 const timestamp = parseInt(timestampStr, 10)
93
94 if (isNaN(timestamp)) {
95 return null
96 }
97
98 return { requestType, timestamp, agentId }
99}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected